Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

three.js in the plugin: pinned npm release checked by sha256, so the plugin fits the directory's limits

Alex Greenshpun2e3300bcf3e5
diff --git a/scripts/sync-codex-marketplace-plugin.sh b/scripts/sync-codex-marketplace-plugin.sh
index 2a87e05..a107822 100755
--- a/scripts/sync-codex-marketplace-plugin.sh
+++ b/scripts/sync-codex-marketplace-plugin.sh
@@ -43,7 +43,9 @@ cd "${REPO_ROOT}"
# The engine's unit tests and the worked example film stay in the repository too: Anthropic's directory
# holds any plugin over 512 files for a manual review, so every release waited days. The tools that
# use them (npm test, gate --self-test, scaffold --example) say where to get them when they are absent.
-EXCLUDE='^skills/anidoodle/engine/test/|^skills/anidoodle/example/|/canvas-core/(launch|launch2|launch3|launchClip|launchCode|typeOptions|typeStyles)\.ts$|/hosts/page-(launch|launch2|launch3|launchClip|typeOptions|typeStyles)\.ts$|/engine/assets/refs/|/engine/tools/gallery\.mjs$|^skills/anidoodle/assets/styles\.jpg$|/engine/package-lock\.json$|/music/blind/|/canvas-core/cheetah[A-Za-z]*\.ts$|/music/pieces/cheetah[A-Za-z]*\.ts$|/hosts/page-cheetah[A-Za-z]*\.ts$|/test/cheetahRig\.test\.ts$|/test/craft\.test\.ts$'
+# three.js (1.3 MB, over the directory's 256 KiB file hold) and its 500 type files are left out too: the
+# plugin gets the same pinned release from npm install, checked against the same sha256 (tools/overlay.mjs).
+EXCLUDE='^skills/anidoodle/engine/test/|^skills/anidoodle/example/|/canvas-core/(launch|launch2|launch3|launchClip|launchCode|typeOptions|typeStyles)\.ts$|/hosts/page-(launch|launch2|launch3|launchClip|typeOptions|typeStyles)\.ts$|/engine/assets/refs/|/engine/tools/gallery\.mjs$|^skills/anidoodle/assets/styles\.jpg$|/engine/package-lock\.json$|/music/blind/|/canvas-core/cheetah[A-Za-z]*\.ts$|/music/pieces/cheetah[A-Za-z]*\.ts$|/hosts/page-cheetah[A-Za-z]*\.ts$|/test/cheetahRig\.test\.ts$|/test/craft\.test\.ts$|/engine/vendor/three/three\.module\.js$|/engine/vendor/three/types/'
count=0
while IFS= read -r f; do
mkdir -p "${STAGE}/$(dirname "$f")"; cp -p "$f" "${STAGE}/$f"; count=$((count + 1))
diff --git a/skills/anidoodle/engine/package-lock.json b/skills/anidoodle/engine/package-lock.json
index e48c997..c8692a8 100644
--- a/skills/anidoodle/engine/package-lock.json
+++ b/skills/anidoodle/engine/package-lock.json
@@ -8,7 +8,8 @@
"name": "anidoodle-engine",
"version": "0.10.0",
"dependencies": {
- "esbuild": "0.25.12"
+ "esbuild": "0.25.12",
+ "three": "0.170.0"
},
"devDependencies": {
"playwright-core": "1.63.0",
@@ -3343,6 +3344,12 @@
}
}
},
+ "node_modules/three": {
+ "version": "0.170.0",
+ "resolved": "https://registry.npmjs.org/three/-/three-0.170.0.tgz",
+ "integrity": "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ==",
+ "license": "MIT"
+ },
"node_modules/tiny-invariant": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
diff --git a/skills/anidoodle/engine/package.json b/skills/anidoodle/engine/package.json
index 1c6353a..f27888a 100644
--- a/skills/anidoodle/engine/package.json
+++ b/skills/anidoodle/engine/package.json
@@ -12,7 +12,8 @@
"test": "node tools/test.mjs"
},
"dependencies": {
- "esbuild": "0.25.12"
+ "esbuild": "0.25.12",
+ "three": "0.170.0"
},
"devDependencies": {
"playwright-core": "1.63.0",
diff --git a/skills/anidoodle/engine/test/threePin.test.ts b/skills/anidoodle/engine/test/threePin.test.ts
new file mode 100644
index 0000000..ff44f09
--- /dev/null
+++ b/skills/anidoodle/engine/test/threePin.test.ts
@@ -0,0 +1,20 @@
+// THREE.JS IS PINNED BY HASH. The repository vendors three.js 0.170.0; the installed plugin gets the same
+// release from npm. Whichever is found must be byte-identical to the pinned build, or the build stops.
+const fsModule = "node:fs", proc = (globalThis as any).process;
+const { readFileSync } = await import(fsModule);
+const { resolveThree, threeCandidates, THREE_SHA256 } = await import(`file://${proc.cwd()}/tools/overlay.mjs`);
+
+export const name = "three.js resolves to the pinned 0.170.0 build, vendored or from npm, and nothing else";
+export function run(ok: (cond: boolean, label: string) => void) {
+ const [vendored, npm] = threeCandidates("/e");
+ const real = resolveThree();
+ ok(typeof real === "string" && real.endsWith("three.module.js"), "this checkout resolves three.js and its hash matches the pin");
+ ok(THREE_SHA256.length === 64, "the pin is a full sha256");
+ const bytes = readFileSync(real);
+ ok(resolveThree("/e", (f: string) => (f === npm ? bytes : null)) === npm, "with no vendored copy (the plugin) the npm copy is used");
+ ok(resolveThree("/e", (f: string) => (f === vendored || f === npm ? bytes : null)) === vendored, "the vendored copy wins when both exist");
+ let msg = ""; try { resolveThree("/e", (f: string) => (f === npm ? new TextEncoder().encode("tampered") : null)); } catch (e) { msg = (e as Error).message; }
+ ok(/not the pinned 0\.170\.0 build/.test(msg), "NEGATIVE: a different three.js stops the build and says to run npm install");
+ msg = ""; try { resolveThree("/e", () => null); } catch (e) { msg = (e as Error).message; }
+ ok(/not installed: run npm install/.test(msg), "NEGATIVE: no three.js at all stops the build with the fix");
+}
diff --git a/skills/anidoodle/engine/tools/overlay.mjs b/skills/anidoodle/engine/tools/overlay.mjs
index 691bc39..b884e9c 100644
--- a/skills/anidoodle/engine/tools/overlay.mjs
+++ b/skills/anidoodle/engine/tools/overlay.mjs
@@ -4,6 +4,7 @@
// example keeps importing "../core"; a launch film can import "./mechanicalLepidoptera" and get
// the committed example. Order matters: engine/src first, so the engine always wins a name clash.
// tsconfig.json says the same thing to tsc with "rootDirs", so the checker and the bundler agree.
+import { createHash } from "node:crypto";
import { existsSync, readFileSync, statSync } from "node:fs";
import { dirname, join, relative, resolve, sep } from "node:path";
import { fileURLToPath } from "node:url";
@@ -35,13 +36,27 @@ export const resolveOverlay = (spec, dir) => {
return null;
};
-// THREE. A film imports "three" by its bare name and gets the vendored, hash-pinned build
-// (vendor/three/PROVENANCE.md): no npm package, no network, the same bytes on every machine.
-export const THREE_MODULE = join(ENGINE, "vendor/three/three.module.js");
+// THREE. A film imports "three" by its bare name and gets three.js 0.170.0, hash-pinned
+// (vendor/three/PROVENANCE.md): the same bytes on every machine. The repository vendors the file; the
+// installed plugin leaves it out (plugin directories refuse a file this size) and gets the same npm
+// release from `npm install` (package.json pins three 0.170.0). Either way the hash must match.
+export const THREE_SHA256 = "ce1fa418de16a19495a9f72495580e3015d7745c296d3ce0485897f902ddedfb";
+export const threeCandidates = (engine = ENGINE) => [join(engine, "vendor/three/three.module.js"), join(engine, "node_modules/three/build/three.module.js")];
+export const resolveThree = (engine = ENGINE, read = (f) => (existsSync(f) ? readFileSync(f) : null)) => {
+ for (const f of threeCandidates(engine)) {
+ const bytes = read(f); if (!bytes) continue;
+ const got = createHash("sha256").update(bytes).digest("hex");
+ if (got !== THREE_SHA256) throw new Error(`three.js at ${f} is not the pinned 0.170.0 build (sha256 ${got.slice(0, 12)}...): run npm install in the engine folder so package.json's exact version is used`);
+ return f;
+ }
+ throw new Error(`three.js is not installed: run npm install in the engine folder (${engine}); it pins three 0.170.0`);
+};
+let threeModule = null;
+export const THREE_MODULE_PATH = () => (threeModule ??= resolveThree());
export const overlay = {
name: "anidoodle-overlay",
setup(b) {
- b.onResolve({ filter: /^three$/ }, () => ({ path: THREE_MODULE }));
+ b.onResolve({ filter: /^three$/ }, () => { try { return { path: THREE_MODULE_PATH() }; } catch (e) { return { errors: [{ text: e.message }] }; } });
// FONT FILES. A launch look imports its typefaces by path (import serif from "../../assets/fonts/X.ttf"):
// the bytes are inlined as { path, format, data } so the film carries them and nothing is fetched. A path
// that is not there is a build error that says where to put the file.
diff --git a/skills/anidoodle/engine/tools/scaffold.mjs b/skills/anidoodle/engine/tools/scaffold.mjs
index 2f7310b..9595bb7 100644
--- a/skills/anidoodle/engine/tools/scaffold.mjs
+++ b/skills/anidoodle/engine/tools/scaffold.mjs
@@ -99,7 +99,7 @@ export const ${film}: Film = {
`);
writeFileSync(host, `import { ${film} } from "../canvas-core/${film}";\nimport { mountFilm } from "./page";\nmountFilm(${film});\n`);
const eng = rel(ENGINE);
- if (!existsSync(join(target, "tsconfig.json"))) writeFileSync(join(target, "tsconfig.json"), JSON.stringify({ compilerOptions: { target: "ES2022", module: "ESNext", moduleResolution: "bundler", strict: true, noEmit: true, skipLibCheck: true, lib: ["DOM", "ES2022"], rootDirs: ["src", `${eng}/src`], paths: { three: [`${eng}/vendor/three/types/Three.d.ts`] } }, include: ["src"] }, null, 2) + "\n");
+ if (!existsSync(join(target, "tsconfig.json"))) writeFileSync(join(target, "tsconfig.json"), JSON.stringify({ compilerOptions: { target: "ES2022", module: "ESNext", moduleResolution: "bundler", strict: true, noEmit: true, skipLibCheck: true, lib: ["DOM", "ES2022"], rootDirs: ["src", `${eng}/src`], paths: { three: [`${eng}/vendor/three/types/Three.d.ts`, `${eng}/vendor/three/three-untyped.d.ts`] } }, include: ["src"] }, null, 2) + "\n");
// npm runs a script through a shell (sh, or cmd.exe on Windows): the tool path is quoted so a folder
// with a space stays one word. Single quotes on sh (nothing inside expands), double quotes on cmd.exe.
const quote = (p) => (process.platform === "win32" ? `"${p}"` : `'${p.replace(/'/g, `'\\''`)}'`);
diff --git a/skills/anidoodle/engine/tsconfig.json b/skills/anidoodle/engine/tsconfig.json
index a4c8c4a..aabdbf3 100644
--- a/skills/anidoodle/engine/tsconfig.json
+++ b/skills/anidoodle/engine/tsconfig.json
@@ -3,7 +3,7 @@
"target": "ES2022", "module": "ESNext", "moduleResolution": "bundler", "jsx": "react-jsx",
"strict": true, "noEmit": true, "skipLibCheck": true, "esModuleInterop": true, "resolveJsonModule": true, "lib": ["DOM", "ES2022"],
"rootDirs": ["src", "../example/src"],
- "paths": { "three": ["./vendor/three/types/Three.d.ts"] }
+ "paths": { "three": ["./vendor/three/types/Three.d.ts", "./vendor/three/three-untyped.d.ts"] }
},
"include": ["src", "test", "../example/src"]
}
diff --git a/skills/anidoodle/engine/vendor/three/PROVENANCE.md b/skills/anidoodle/engine/vendor/three/PROVENANCE.md
index 6ab03d3..db2c5d5 100644
--- a/skills/anidoodle/engine/vendor/three/PROVENANCE.md
+++ b/skills/anidoodle/engine/vendor/three/PROVENANCE.md
@@ -4,4 +4,5 @@
- `types/`: `src/**/*.d.ts` from `@types/[email protected]` (sha512 `CUm2uckq...QFAyg==` matched). Type declarations only, no runtime code. sha256 of all .d.ts in path order: `0f922d42e410315f052b7360dc3ce60a24b13003c88aa41f82102659c3c98570`.
- Licence: MIT (`LICENSE`, three.js authors; @types/three is MIT too).
- Security: scanned with repo-forensics 2.14.19 (30 scanners, coverage COMPLETE) on 2026-10-28. 0 block, 0 critical. All 60 warnings adjudicated benign: 54 are doc comments ("Create a new instance of ..."), the rest are a GitHub URL and `////` rule lines read as base64, and `lists.get( scene )` read as an AWS key. No eval, no new Function. The loaders that fetch are never called: anidoodle pages have no network.
-- Nothing else from the package is used. Upgrading means a new scan and new hashes here, and `tools/test.mjs` checks the runtime hash.
+- The installed plugin leaves `three.module.js` and `types/` out (plugin directories hold files over 256 KiB and plugins over 512 files). There `package.json` pins `three` 0.170.0 exactly and `npm install` brings the same file; `tools/overlay.mjs` refuses any three.js whose sha256 is not the one above, and `three-untyped.d.ts` lets films type-check without the types.
+- Nothing else from the package is used. Upgrading means a new scan and new hashes here and in `tools/overlay.mjs` (`THREE_SHA256`); `test/threePin.test.ts` checks it.
diff --git a/skills/anidoodle/engine/vendor/three/three-untyped.d.ts b/skills/anidoodle/engine/vendor/three/three-untyped.d.ts
new file mode 100644
index 0000000..85f4d68
--- /dev/null
+++ b/skills/anidoodle/engine/vendor/three/three-untyped.d.ts
@@ -0,0 +1,5 @@
+// The installed plugin leaves out three.js's 500 type files (plugin directories cap a plugin at 512 files).
+// tsconfig falls back to this file when vendor/three/types is absent: "three" type-checks as untyped there.
+// The repository keeps the full types, so the engine's own code is always checked against them.
+declare const THREE: any;
+export = THREE;