Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.
TypeScript agent-skillsanimationcanvasclaude-codeclaude-pluginclaude-skillscodex-plugincreative-codecreative-codingcreative-toolsdeterministicgenerative-arthand-drawnillustrationlaunch-videomotion-designmotion-graphicspluginprocedural-generationskill
standard host pages are built in memory, so the plugin leaves the identical files out
Alex Greenshpuna557cf7670c7
diff --git a/scripts/sync-codex-marketplace-plugin.sh b/scripts/sync-codex-marketplace-plugin.shindex a107822..9bc8087 100755--- a/scripts/sync-codex-marketplace-plugin.sh+++ b/scripts/sync-codex-marketplace-plugin.sh@@ -51,6 +51,16 @@ while IFS= read -r f; domkdir -p "${STAGE}/$(dirname "$f")"; cp -p "$f" "${STAGE}/$f"; count=$((count + 1))done < <(git ls-files skills/ | grep -v -E "${EXCLUDE}")+# a host page that is exactly the standard one (import the film, mountFilm) is left out: the tools build that+# page in memory when a film has none (engine/tools/names.mjs standardHost), pixel-identical. Custom pages stay.+dropped=0+for h in "${STAGE}"/skills/anidoodle/engine/src/hosts/page-*.ts; do+ n="$(basename "$h" .ts)"; n="${n#page-}"+ want="$(printf 'import { %s } from "../canvas-core/%s";\nimport { mountFilm } from "./page";\n\nmountFilm(%s);' "$n" "$n" "$n")"+ if [ "$(cat "$h")" = "${want}" ] && [ -f "${STAGE}/skills/anidoodle/engine/src/canvas-core/${n}.ts" ]; then rm "$h"; dropped=$((dropped + 1)); fi+done+echo "left out ${dropped} standard host pages (built in memory)"+# a showcase or launch film in the installed plugin is a leak of the repository's own promotion: refuse to publish oneleaked="$(cd "${STAGE}" && find . -type f \( -iname 'cheetah*' -o -iname 'page-cheetah*' -o -name 'launch[0-9]*.ts' -o -name 'launchClip.ts' \) | head -5)"[ -z "${leaked}" ] || { echo "ERROR: repository-only films reached the plugin folder:" >&2; echo "${leaked}" >&2; exit 5; }diff --git a/skills/anidoodle/engine/test/standardHost.test.ts b/skills/anidoodle/engine/test/standardHost.test.tsnew file mode 100644index 0000000..1382d12--- /dev/null+++ b/skills/anidoodle/engine/test/standardHost.test.ts@@ -0,0 +1,16 @@+// THE STANDARD HOST PAGE. A film with no src/hosts/page-<film>.ts of its own is still a known film and builds+// with the standard page (import it, mountFilm), so the installed plugin can leave those identical files out.+const proc = (globalThis as any).process;+const { standardHost, filmModule, knownFilms } = await import(`file://${proc.cwd()}/tools/names.mjs`);++export const name = "a film without its own host page builds with the standard one";+export function run(ok: (cond: boolean, label: string) => void) {+ ok(standardHost("koi") === 'import { koi } from "../canvas-core/koi";\nimport { mountFilm } from "./page";\n\nmountFilm(koi);\n', "the standard page is the four lines every plain host has");+ ok(typeof filmModule("koi") === "string" && filmModule("koi").endsWith("canvas-core/koi.ts"), "koi's module is found by its name");+ ok(filmModule("koi-9x16") === filmModule("koi"), "a shape suffix finds the same module");+ ok(filmModule("core") === undefined, "NEGATIVE: a module that does not export a Film under its own name is not a film");+ ok(filmModule("noSuchFilm") === undefined, "NEGATIVE: an unknown name is not a film");+ const k = knownFilms();+ ok(k.includes("koi") && k.includes("launchExampleBrand"), "known films include films with and without a host page file");+ ok(!k.includes("core") && !k.includes("film"), "NEGATIVE: helper modules are not listed as films");+}diff --git a/skills/anidoodle/engine/tools/build-page.mjs b/skills/anidoodle/engine/tools/build-page.mjsindex cb9a9f9..bba23e2 100644--- a/skills/anidoodle/engine/tools/build-page.mjs+++ b/skills/anidoodle/engine/tools/build-page.mjs@@ -3,9 +3,9 @@import { build } from "esbuild";import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";import { createHash } from "node:crypto";-import { extname, join, relative, resolve } from "node:path";+import { dirname, extname, join, relative, resolve } from "node:path";import { enginePath, overlay, resolveOverlay } from "./overlay.mjs";-import { requireFilm, splitShape } from "./names.mjs";+import { filmModule, requireFilm, splitShape, standardHost } from "./names.mjs";import { loadFilmModule, prepareFilmSounds, filmFloat32 } from './audio.mjs';import { isMain } from "./is-main.mjs";@@ -49,8 +49,11 @@ export const buildPage = async ({ entry, out, title, plugins: extra = [] }) => {const { base, shape } = splitShape(title);if (shape) { entry = entry.replace(`page-${title}.ts`, `page-${base}.ts`); title = base; }if (!existsSync(entry)) entry = resolveOverlay("./" + entry, process.cwd()) ?? entry; // e.g. the example's own host page- if (!existsSync(entry) && title) requireFilm(title, "build", "a film name: src/hosts/page-<film>.ts"); // a clear exit with the known films, not an esbuild trace- const main = await build({ absWorkingDir: process.cwd(), entryPoints: [resolve(entry)], bundle: true, format: "iife", target: "es2020", minify: true, write: false, legalComments: "none", metafile: true, plugins: [...plugins, tagFilms] });+ // no host page of its own: the standard one (names.mjs standardHost), built in memory next to the film's module+ const mod = !existsSync(entry) && title ? filmModule(title) : null;+ if (!existsSync(entry) && !mod && title) requireFilm(title, "build", "a film name: src/hosts/page-<film>.ts"); // a clear exit with the known films, not an esbuild trace+ const from = mod ? { stdin: { contents: standardHost(title), resolveDir: join(dirname(dirname(mod)), "hosts"), sourcefile: `page-${title}.ts`, loader: "ts" }, tsconfig: enginePath("tsconfig.json") } : { entryPoints: [resolve(entry)] };+ const main = await build({ absWorkingDir: process.cwd(), ...from, bundle: true, format: "iife", target: "es2020", minify: true, write: false, legalComments: "none", metafile: true, plugins: [...plugins, tagFilms] });const js = main.outputFiles[0].text;// read the manifest out of the film module itself, so the page and the film can never disagreeconst { film, music } = await loadFilmModule(shape ? `${title}-${shape}` : title, plugins);diff --git a/skills/anidoodle/engine/tools/names.mjs b/skills/anidoodle/engine/tools/names.mjsindex 375402b..7e6afd3 100644--- a/skills/anidoodle/engine/tools/names.mjs+++ b/skills/anidoodle/engine/tools/names.mjs@@ -1,5 +1,5 @@// Names shared by the tools: where a film's MP4 lands by default, and which films exist.-import { existsSync, readdirSync } from "node:fs";+import { existsSync, readdirSync, readFileSync } from "node:fs";import { join } from "node:path";import { ROOTS } from "./overlay.mjs";@@ -10,9 +10,23 @@ export const defaultOutput = (film) => `out/${film}.mp4`;export const SHAPE_NAMES = ["16x9", "1x1", "4x5", "9x16"];export const splitShape = (film) => { const m = /^(.+)-(16x9|1x1|4x5|9x16)$/.exec(film ?? ""); return m ? { base: m[1], shape: m[2] } : { base: film, shape: null }; };-/** Every film this project can build: one host page, src/hosts/page-<film>.ts (the worked example's too). */-export const knownFilms = () => [...new Set([join(process.cwd(), "src"), ...ROOTS].flatMap((r) => { const d = join(r, "hosts"); return existsSync(d) ? readdirSync(d).filter((f) => /^page-.+\.ts$/.test(f)).map((f) => f.slice(5, -3)) : []; }))].sort();-const hostOf = (film) => [join(process.cwd(), "src"), ...ROOTS].map((r) => join(r, "hosts", `page-${splitShape(film).base}.ts`)).find((f) => existsSync(f));+// THE STANDARD HOST PAGE. Most films need nothing but "import the film, mount it". A film with no host page+// of its own gets exactly that page, built in memory (build-page.mjs): the installed plugin leaves those+// identical pages out to stay under the plugin directory's 512-file limit. A film that needs more (fixtures,+// a social card) keeps its own src/hosts/page-<film>.ts, which always wins.+export const standardHost = (name) => `import { ${name} } from "../canvas-core/${name}";\nimport { mountFilm } from "./page";\n\nmountFilm(${name});\n`;+const SRC_ROOTS = () => [join(process.cwd(), "src"), ...ROOTS];+const exportsFilm = (file, name) => new RegExp(`export\\s+const\\s+${name.replace(/\$/g, "\\$")}\\s*:\\s*Film\\b`).test(readFileSync(file, "utf8"));+/** The module that exports <film> as a Film under the same name (src/canvas-core/<film>.ts), or undefined. */+export const filmModule = (film) => { const b = splitShape(film).base; return SRC_ROOTS().map((r) => join(r, "canvas-core", `${b}.ts`)).find((f) => existsSync(f) && exportsFilm(f, b)); };+/** Every film this project can build: one with a host page src/hosts/page-<film>.ts, or a module that exports a Film under its own name. */+export const knownFilms = () => [...new Set(SRC_ROOTS().flatMap((r) => {+ const h = join(r, "hosts"), c = join(r, "canvas-core");+ const hosts = existsSync(h) ? readdirSync(h).filter((f) => /^page-.+\.ts$/.test(f)).map((f) => f.slice(5, -3)) : [];+ const mods = existsSync(c) ? readdirSync(c).filter((f) => /^[A-Za-z_$][\w$]*\.ts$/.test(f)).map((f) => f.slice(0, -3)).filter((n) => exportsFilm(join(c, `${n}.ts`), n)) : [];+ return [...hosts, ...mods];+}))].sort();+const hostOf = (film) => SRC_ROOTS().map((r) => join(r, "hosts", `page-${splitShape(film).base}.ts`)).find((f) => existsSync(f)) ?? filmModule(film);/** The film named on the command line, or a clear exit: the usage when none is given, the known films when it is not one. */export const requireFilm = (film, tool, usage) => {