Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test: keep the three vendor closure check inside the loader (#10464)

[._.]/ Adam Eivyec761a9737ab
diff --git a/server/services/codeAnimation/threeVendor.js b/server/services/codeAnimation/threeVendor.js
index 90566b1552..5ae45c80ce 100644
--- a/server/services/codeAnimation/threeVendor.js
+++ b/server/services/codeAnimation/threeVendor.js
@@ -48,7 +48,7 @@ const RELATIVE_IMPORT = /(?:^|\n)\s*(?:import|export)\b[^'"\n;]*?from\s*['"](\.{
const sha256 = (data) => createHash('sha256').update(data).digest('hex');
/** The relative specifiers a vendored module imports, resolved against its own path. */
-export function relativeImportsOf(path, text) {
+function relativeImportsOf(path, text) {
const found = [];
for (const match of text.matchAll(RELATIVE_IMPORT)) {
found.push(posix.normalize(posix.join(posix.dirname(path), match[1] || match[2])));
diff --git a/server/services/codeAnimation/threeVendor.test.js b/server/services/codeAnimation/threeVendor.test.js
index f156d267a1..ef71f2651e 100644
--- a/server/services/codeAnimation/threeVendor.test.js
+++ b/server/services/codeAnimation/threeVendor.test.js
@@ -1,20 +1,17 @@
import { describe, expect, it } from 'vitest';
import { createHash } from 'crypto';
-import { THREE_ADDON_ALLOWLIST, THREE_IMPORT_MAP, importsThree, injectThreeImportMap, readThreeVendor, relativeImportsOf, threeStagedFiles } from './threeVendor.js';
+import { THREE_ADDON_ALLOWLIST, THREE_IMPORT_MAP, importsThree, injectThreeImportMap, readThreeVendor, threeStagedFiles } from './threeVendor.js';
describe('three.js vendor set', () => {
it('ships only the allowlisted addons, and every relative import inside them stays inside the set', async () => {
const { files } = await readThreeVendor();
const paths = files.map((file) => file.path);
expect(paths.filter((path) => path.startsWith('addons/'))).toEqual(THREE_ADDON_ALLOWLIST.map((name) => `addons/${name}`));
- // The loader already fails closed on a stray import; assert the property directly.
- const known = new Set(paths);
- for (const file of files.filter((entry) => entry.path.endsWith('.js'))) {
- for (const target of relativeImportsOf(file.path, file.data.toString('utf8'))) expect(known.has(target)).toBe(true);
- }
- // The graph is not vacuous: EffectComposer pulls CopyShader in from a sibling directory.
- const composer = files.find((file) => file.path === 'addons/postprocessing/EffectComposer.js');
- expect(relativeImportsOf(composer.path, composer.data.toString('utf8'))).toContain('addons/shaders/CopyShader.js');
+ // The loader fails closed on any relative import outside the set (readThreeVendor
+ // would have rejected above); also pin that the graph is not vacuous: EffectComposer
+ // imports CopyShader from a sibling directory, so that file must be vendored.
+ expect(paths).toContain('addons/shaders/CopyShader.js');
+ expect(files.find((file) => file.path === 'addons/postprocessing/EffectComposer.js').data.toString('utf8')).toContain("'../shaders/CopyShader.js'");
});
it('stages every file under vendor/ with a dependencies.json whose hashes match the bytes', async () => {