mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
prelude-live.js holds widget (with widget.gpu) and __widget_live; a step widget template's program
is prelude + "\n" + source, a live one's prelude + "\n" + livePrelude + "\n" + source, and
versions hash the program as served. Lint reserves both preludes' names; positions stay
source-relative per mode. Steps compile and run faster than before widget.gpu.
Also lands the widgets-gpu.md changes 0786c7331 described but didn't carry: the live input's gpu,
the flag globals, the normalised op shapes, error ops, which canvases an error stops, Host checks
and Conformance; and widgets-live.md's rule that GPU batches never overtake waiting posts.
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
#!/usr/bin/env bun
|
|
|
|
// Embeds the canonical `.js` sources as strings, so they import as plain TypeScript (tsc has no text loader).
|
|
|
|
import path from "node:path"
|
|
import { format, resolveConfig } from "prettier"
|
|
|
|
const src = path.resolve(import.meta.dir, "../src")
|
|
const names = [
|
|
"prelude",
|
|
"prelude-live",
|
|
"widget-templates/suggestions",
|
|
"widget-templates/form",
|
|
"widget-templates/confirm",
|
|
"widget-templates/chart",
|
|
"widget-templates/backdrop",
|
|
...[
|
|
"pie",
|
|
"scatter",
|
|
"histogram",
|
|
"area",
|
|
"heatmap",
|
|
"treemap",
|
|
"sankey",
|
|
"graph",
|
|
"tree",
|
|
"timeline",
|
|
"funnel",
|
|
"radar",
|
|
"gauge",
|
|
"boxplot",
|
|
"flowchart",
|
|
"sequence",
|
|
"table",
|
|
].map((name) => `widget-templates/${name}`),
|
|
]
|
|
const sources = await Promise.all(names.map((name) => Bun.file(path.join(src, `${name}.js`)).text()))
|
|
|
|
const file = path.join(src, "source.ts")
|
|
const text = [
|
|
"// Generated by script/generate.ts from prelude.js, prelude-live.js and widget-templates/*.js. Do not edit; run `bun run generate`.",
|
|
"",
|
|
...names.map(
|
|
(name, index) =>
|
|
`export const ${path.basename(name).replace(/-(\w)/g, (_, letter: string) => letter.toUpperCase())} = ${JSON.stringify(sources[index])}`,
|
|
),
|
|
"",
|
|
].join("\n")
|
|
|
|
await Bun.write(file, await format(text, { ...(await resolveConfig(file)), filepath: file }))
|