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}`;
provideBlobToHtmlmain.tsx1 match
4export { provideBlob } from "https://esm.town/v/postpostscript/provideBlob";
56export function provideBlobToHtml(jsPromise: RawHTML, placeholder?: unknown) {
7const id = "provideBlobHtml-" + Math.random().toString().slice(3);
8return html`
search_liked_valsmain.tsx1 match
2import { valToListItem } from "https://esm.town/v/pomdtr/val_to_listitem";
34export default async function(ctx: BrowserContext<{ user: string }>) {
5const { user: userID } = ctx.params;
6const resp = await fetch(`https://api.val.town/v1/me/likes?limit=100`, {
recommendsmain.tsx3 matches
1import { html } from "https://esm.town/v/postpostscript/html";
23export async function randomLike() {
4const { data } = await fetch("https://api.val.town/v1/me/likes", {
5headers: {
11}
1213export async function randomLikeLink() {
14try {
15const { author: { username }, name } = await randomLike();
25}
2627export async function recommends() {
28return html`
29Check out a random Val I've liked!
5export { Vue };
67export function vueSfc(name: string, template: string) {
8window.moduleCache ??= {
9vue: Vue,
52}
5354export function vueSfcInline(strings: TemplateStringsArray, ...replacements: any[]) {
55const id = rawHtml`vueSfcInline-${Math.random().toString().slice(3)}`;
56
fetchBlueskyPostmain.tsx1 match
3import ky from "npm:ky";
45export async function fetchPost(url: string | URL) {
6const postURL = new URL(url);
7if (postURL.hostname !== "bsky.app") {
pinkGuanacomain.tsx3 matches
23const { greet } = await import(jsm`
4export function greet(name) {
5console.log(\`Hello \${name}!\`);
6}
1011const { sum } = await import(tsm`
12export function sum(a: number, b: number): number {
13return a + b;
14}
1718const { shout } = await import(createModuleURL(
19`export function shout(name: string) {
20console.log(\`HELLO \${name.toUpperCase()}!\`);
21}`,