36const resp = await fetch("https://maxm-wasmBlobHost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm");
37const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
38export default async function(req: Request): Promise<Response> {
39 return handler(req);
40}
40}
41
42function callHandlerWithString(
43 instance: WebAssembly.Instance,
44 payload: string,
47 return callHandlerWithBytes(instance, bytes);
48}
49function callHandlerWithJson(instance: WebAssembly.Instance, payload: any) {
50 const bytes = new TextEncoder("utf8").encode(JSON.stringify(payload));
51 return callHandlerWithBytes(instance, bytes);
54const MASK = 2n ** 32n - 1n;
55
56function callHandlerWithBytes(
57 instance: WebAssembly.Instance,
58 bytes: Uint8Array,
88}
89
90async function handleRequest(
91 instance: WebAssembly.Instance,
92 req: Request,
108}
109
110export async function wasmHandler(wasmBytes: Uint8Array): Promise<(Request) => Promise<Response>> {
111 const init = async (wasmBytes: Uint8Array) => {
112 const context = new Context({ args: [], env: Deno.env.toObject() });
1export function generateBubbles() {
2 let bubbles = '';
3 for (let i = 0; i < 30; i++) {
2import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL";
3
4export default async function(req: Request) {
5 const url = new URL(req.url);
6 const name = url.pathname.slice(1);
63 let quill = new Quill('#editor', options)
64
65 function save() {
66 return fetch('${thisWebURL()}/${name}', {
67 method: 'POST',
76 const saveStatus = document.getElementById('save-status');
77 quill.on('text-change', debounce(
78 async function(delta, oldDelta, source) {
79 saveStatus.innerHTML = 'Saving...';
80 await save();
9const WASM_BLOB_PREFIX = `${author}-${name}-wasm-wasm-blob`;
10
11async function readAllBytes(stream: ReadableStream<Uint8Array>): Promise<Buffer> {
12 const reader = stream.getReader();
13 const chunks: Uint8Array[] = [];
24}
25
26function getSha256Hash(buffer: Buffer): string {
27 const hash = createHash("sha256");
28 hash.update(buffer);
29 return hash.digest("hex");
30}
31function trimPrefix(str, prefix) {
32 if (str.startsWith(prefix)) {
33 return str.slice(prefix.length);
39};
40
41export default async function(req: Request): Promise<Response> {
42 if (req.method === "POST") {
43 const body = await readAllBytes(req.body);
1import valTownBadge from "https://esm.town/v/jxnblk/valTownBadge02";
2
3export default function badgeMiddleware(handler, url: string) {
4 return async function(req: Request): Promise<Response> {
5 if (req.method !== "GET") return await handler(req);
6
1function getHREF(mod) {
2 const url = new URL(mod);
3 return `https://val.town${url.pathname}`;
8}
9
10export default function GetBadgeHTML(url: string, opts: BadgeOptions = {}): string {
11 const href = getHREF(url);
12 const {
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4
11 user: "website that shows the current time",
12 content: `/** @jsxImportSource npm:react */
13export default function() {
14 return <h1>{new Date().toLocaleTimeString()}</h1>;
15}`,
91 );
92});
93export async function compile(description: string) {
94 const messages = [
95 {
86};
87
88function slotToConstraints(slot: Slot): Constraint[] {
89 console.assert(slot.row >= 0 && slot.row <= 8);
90 console.assert(slot.col >= 0 && slot.col <= 8);
100}
101
102function constraintsToSlot(constraints: Constraint[]): Slot {
103 console.assert(constraints.length === 4);
104 let row = null;
136}
137
138function cIndex(constraint: Constraint): number {
139 switch (constraint.kind) {
140 case "slot":
347}
348
349export function solve(sudoku: Sudoku): Sudoku | null {
350 sudoku = Sudoku.parse(sudoku);
351 const matrix = new Matrix();
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.