listSqliteTablesmain.tsx1 match
1import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
23export async function listSqliteTables() {
4return (await sqlite.execute(
5`select name from sqlite_schema where type='table' and name != 'libsql_wasm_func_table' and name != 'sqlite_sequence'`,
test_explorer_uimain.tsx5 matches
57};
5859function TestItem({ test, run }: { test: Test; run: () => void }) {
60return (
61<div>
75}
7677function groupBySlug(tests: Test[]): Record<string, Test[]> {
78const groups = {};
79for (const test of Object.values(tests)) {
89}
9091function useTests(initialTests: Test[]) {
92const id = (test: Test) => `${test.val.name}/${test.name}`;
93const [tests, setTests] = useState(Object.fromEntries(initialTests.map((test) => {
118}
119120function TestExplorerView({ tests }: Props) {
121const { groups, runTest } = useTests(tests);
122return (
187}
188189export default function(props: { tests: Test[] }) {
190return (
191<>
24export default router.fetch;
2526export async function createScreenshot(code: string, theme: string = "dark-plus"): Promise<URL> {
27const apiUrl = "https://sourcecodeshots.com/api/image/permalink";
28const { url } = await ky.post(apiUrl, {
35}
3637async function fetchValCode(alias: string): Promise<string> {
38const prefixUrl = "https://api.val.town/v1/alias";
39const { code } = await ky.get(alias, { prefixUrl }).json();
authDescribeScopesmain.tsx1 match
3import { pathMatches } from "https://esm.town/v/postpostscript/pathAsScope";
45export async function authDescribeScopes(scopes: string[]) {
6return Promise.all(scopes.map(async (scope) => {
7const [author, name, ..._scopeName] = scope.slice(1).split("/");
filterValsREADME.md1 match
1# filterVals
23This val exports a utility function that returns a list of all a user's val, filtered by a callback function.
45## Example
20};
2122export function publicKeys() {
23try {
24return JSON.parse(Deno.env.get("JWKS_PUBLIC"));
38});
3940export default async function(req: Request) {
41return Response.json(publicKeys());
42}
hono_countermain.tsx1 match
3import { useState } from "https://esm.sh/hono/jsx/dom";
45export default function Counter(props: { initialCount?: number }) {
6const [count, setCount] = useState(props.initialCount || 0);
7return (
test_explorer_historymain.tsx3 matches
10};
1112export async function createHistory() {
13const resp = await sqlite.execute(`CREATE TABLE test_history (
14val_slug TEXT,
20}
2122export async function readHistory(): Promise<HistoryEntry[]> {
23const { columns, rows } = await sqlite.execute("SELECT * from test_history");
24const history = rows.map(row =>
31}
3233export async function writeHistory(entries: HistoryEntry[]) {
34const resp = await sqlite.execute(
35sql`INSERT OR REPLACE INTO test_history (val_slug, test_name, status, last_run_at) VALUES ${
honoExamplemain.tsx1 match
8});
910function capitalize(string) {
11return string.charAt(0).toUpperCase() + string.slice(1);
12}
5const moduleSourceCache = new Map<string, string>();
67export async function importModule<ModuleType>(moduleName: string, checkPrivacy = true) {
8const url = moduleName[0] === "@"
9? `https://esm.town/v/${moduleName.slice(1)}`
30}
3132export function moduleSource(moduleName: string) {
33const url = moduleName[0] === "@"
34? `https://esm.town/v/${moduleName.slice(1)}`
45}
4647export async function moduleSourceHash(moduleName: string) {
48return sha(await moduleSource(moduleName));
49}
5051export async function call<ModuleType, const TMethod extends string | string[]>(
52moduleName: string,
53methodName: TMethod,
59const module = await importModule<ModuleType>(moduleName);
60const method = accessDeep(module, methodName);
61if (!(method instanceof Function)) {
62const key = methodName instanceof Array
63? methodName.join(".")
68}
6970export function getValNameFromUrl(url: string) {
71// https://esm.town/v/postpostscript/meta?v=11
72// @^^^^^^^^^^^^^^^^^^^
74}
7576export function getValEmailFromUrl(url: string) {
77// e.g. postpostscript.callbackEmail@valtown.email
78const name = url.split("?")[0].split("/").slice(4, 6).join(".");
80}
8182export function getValEndpointFromUrl(url: string) {
83// https://esm.town/v/postpostscript/meta?v=11
84// ^^^^^^^^^^^^^^^^^^^
86}
8788export function getValEndpointFromName(url: string) {
89const [handle, name] = url.split(/[^\w]/g).filter(Boolean);
90return `https://${[handle, name].join("-").toLowerCase()}.web.val.run`;
91}
9293export function getValUrlFromName(name: string, domain = "esm.town") {
94const _name = name.replace("@", "");
95return `https://${domain}/v/${_name}`;