processTrackBlobsJobmain.tsx5 matches
20title: text("title"),
21url: text("url"),
22image_url: text("image_url"),
23thumbnail_url: text("thumbnail_url"),
24icon_url: text("icon_url"),
36title text,
37url text,
38image_url text,
39thumbnail_url text,
40icon_url text,
63title,
64url: external_urls.spotify,
65image_url: album.images[0].url,
66thumbnail_url: album.images[1].url,
67icon_url: album.images[2].url,
68duration_ms,
69duration: duration_ms / 1_000.0,
13title: text("title"),
14url: text("url"),
15image_url: text("image_url"),
16thumbnail_url: text("thumbnail_url"),
17icon_url: text("icon_url"),
28title: String!
29url: String!
30image_url: String
31thumbnail_url: String
32icon_url: String
68title
69url
70image_url
71}
72}
tealPheasantmain.tsx1 match
20"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0",
21"Accept":
22"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8",
23"Accept-Language": "en-US,en;q=0.5",
24"Content-Type": "application/x-www-form-urlencoded",
327---
328
329Val Town comes with blob storage built-in. It allows for storing any data: text, JSON, images. You can access it via [\`std/blob\`](https://www.val.town/v/std/blob).
330
331Blob storage is scoped globally to your account. If you set a blob in one val, you can retrieve it by the same key in another val. It's backed by Cloudflare R2.
illustratedPrimermain.tsx26 matches
1import inputHeader from "https://esm.town/v/substrate/inputHeader";
2import { ComputeJSON, ComputeText, GenerateImage, sb, Substrate } from "npm:substrate";
3import { z } from "npm:zod";
4import { zodToJsonSchema } from "npm:zod-to-json-schema";
21});
22const prompt1 = new ComputeText({
23prompt: sb.interpolate`generate a description of an image of ${
24c1.future.json_object.get("concepts").at(0)
25}. Be creative depicting abstract topics using detailed abstract imagery. Include details on the background, angle & framing, and style.`,
26});
27const prompt2 = new ComputeText({
28prompt: sb.interpolate`generate a description of an image of ${
29c1.future.json_object.get("concepts").at(1)
30}. Be creative depicting abstract topics using detailed abstract imagery. Include details on the background, angle & framing, and style.`,
31});
32const caption1 = new ComputeText({
39${caption1.future.text}`,
40}, { cache_age: 800 });
41const image1 = new GenerateImage({ prompt: prompt1.future.text });
42const image2 = new GenerateImage({ prompt: prompt2.future.text });
43const c2 = new ComputeJSON({
44prompt: sb.interpolate`List advanced concepts related to: ${c1.future.json_object.get("concepts").at(0)}
49});
50const prompt3 = new ComputeText({
51prompt: sb.interpolate`generate a description of an image of ${
52c2.future.json_object.get("concepts").at(0)
53}. Be creative depicting abstract topics using detailed abstract imagery. Include details on the background, angle & framing, and style.`,
54});
55const prompt4 = new ComputeText({
56prompt: sb.interpolate`generate a description of an image of ${
57c2.future.json_object.get("concepts").at(1)
58}. Be creative depicting abstract topics using detailed abstract imagery. Include details on the background, angle & framing, and style.`,
59});
60const caption3 = new ComputeText({
73${caption3.future.text}`,
74});
75const image3 = new GenerateImage({ prompt: prompt3.future.text });
76const image4 = new GenerateImage({ prompt: prompt4.future.text });
77const nodes = [image1, caption1, image2, caption2, image3, caption3, image4, caption4];
78const stream = await substrate.stream(...nodes);
7984async start(controller) {
85const pairs = [
86{ image: null, caption: null, title: null },
87{ image: null, caption: null, title: null },
88{ image: null, caption: null, title: null },
89{ image: null, caption: null, title: null },
90];
9192const outputPair = (pair, index) => {
93if (pair.image && pair.caption) {
94controller.enqueue(new TextEncoder().encode(
95`<div style="display:flex;justify-content:center;align-items:center;margin-bottom:20px;">
96<div style="margin:0 10px;">${pair.image}</div>
97<div style="margin:0 10px;font-size:1.2rem;">
98<a href="/?input=${pair.title}"><b>${capitalize(pair.title)}</b></a><br/>${pair.caption}</div>
99</div>`,
100));
101pairs[index] = { image: null, caption: null, title: null }; // Reset after output
102}
103};
119if (index !== -1) {
120const pairIndex = Math.floor(index / 2);
121const isImage = index % 2 === 0;
122const content = event.data.image_uri
123? `<img src="${event.data.image_uri}" width=400/>`
124: `<div style="font-family:system-ui,sans-serif;">${event.data.text}</div>`;
125126if (isImage) {
127pairs[pairIndex].image = content;
128} else {
129pairs[pairIndex].caption = content;
infiniteSVGGraphmain.tsx16 matches
8// Val-name scoped table addressing.
9const { name } = extractValInfo(import.meta.url);
10const tableName = `${name}_svg_images`;
11const heartHashTableName = `${name}_heart_hash`;
1294const decoder = new TextDecoder();
95const svgCode = document.getElementById("svgCode");
96const svgImage = document.getElementById("svgImage");
97let foundSVGEnd = false;
98let htmlContent = "";
99let jsonResponse = "";
100svgCode.textContent = "";
101svgImage.innerHTML = "";
102while (true) {
103const { done, value } = await reader.read();
105if (!foundSVGEnd) {
106svgCode.textContent += decoder.decode(value, { stream: true });
107svgImage.innerHTML = svgCode.textContent + "</svg>";
108Prism.highlightElement(svgCode);
109if (svgCode.textContent.indexOf("</svg>") > -1) {
338<div class="bg-white p-6 rounded-lg shadow-md mb-8">
339<div class="flex space-x-4 mb-4">
340<div class="w-1/2 border p-4 rounded" id="svgImage">
341${svg.svg.svg_source}
342</div>
398const stream = await openai.chat.completions.create({
399messages: [
400{ role: "user", content: "make me an svg image" },
401{ role: "system", content: "```xml\n" + svg.svg_source + "\n```" },
402{ role: "user", content: "Edit this svg. " + prompt },
421});
422try {
423const svgDoc = parser.parseFromString(svgString, "image/svg+xml");
424if (!svgDoc) return false;
425const parserError = svgDoc.getElementsByTagName("parsererror");
434let foundSVGEnd = false;
435let buffer = "";
436let svgImage = "";
437return new Response(
438new ReadableStream({
444if (!foundSVGStart && location > -1) {
445foundSVGStart = true;
446svgImage = buffer.slice(location);
447controller.enqueue(encoder.encode(buffer.slice(location)));
448buffer = "";
449} else if (foundSVGStart && !foundSVGEnd) {
450svgImage += line;
451let endLocation = svgImage.indexOf("</svg>");
452if (endLocation > -1) {
453svgImage = svgImage.slice(0, endLocation + "</svg>".length);
454foundSVGEnd = true;
455console.log(JSON.stringify(svgImage));
456}
457controller.enqueue(encoder.encode(line));
459}
460controller.enqueue(encoder.encode(" "));
461if (isValidSVG(svgImage)) {
462try {
463let resp = await sqlite.execute({
464sql: `INSERT INTO ${tableName} (prompt, svg_source, parent_id) VALUES (?, ?, ?) RETURNING *`,
465args: [prompt, svgImage, svg.id],
466});
467controller.enqueue(encoder.encode(JSON.stringify(resultSetToSVG(resp)[0])));
496let svg = await getSVG(c.req.param("id"));
497return new Response(addSVGNamespace(svg.svg_source), {
498headers: { "Content-Type": "image/svg+xml", "Cache-Control": "max-age=86400" },
499});
500});
codeOnValTownREADME.md1 match
1# Code on Val Town
23
45Adds a "Code on Val Town" ribbon to your page. This lets your website visitors navigate to the code behind it.
1# Code on Val Town
23
45Adds a "Code on Val Town" ribbon to your page. This lets your website visitors navigate to the code behind it.
codeOnValTownREADME.md1 match
1# Code on Val Town
23
45Adds a "Code on Val Town" ribbon to your page. This lets your website visitors navigate to the code behind it.