Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Install the MCP SDK and zod as dependencies instead of bundling them

Nguyen Xuan Anf726361d2674
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7db86578..3cab2885 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## Unreleased
+- Make room in the npm package (part of issue #36). `@modelcontextprotocol/server` (2.4.0) and `zod` (4.6.7) are now normal dependencies that npm installs next to the package, so `build/mcp/server.mjs` imports them instead of carrying a copy: it fell from 677,484 to 165,877 bytes and `build/mcp/LICENSES.md` from 35,999 to 2,469 bytes, and the archive from 802,581 to 677,563 bytes (370,000 free under 1 MiB; the target was 300,000). The price is install size: three more packages and about 14.5 MB more on disk in a consumer (SDK 7.0 MB, its core 1.4 MB, zod 6.1 MB unpacked from the registry), and a first `npx` run downloads them. Behaviour is unchanged: `npm audit --audit-level=high` finds nothing and both MCP client generations pass `npm run smoke:mcp-package`. `licenses/mcp/` and the embedded-license scan in `scripts/build-mcp.mjs` are gone because nothing prebundled is left to cover; `manifest.json` lists the three installed dependencies under `externalDependencies`. `npm run smoke:package` now loads every `exports` entry in a clean consumer. Film and site code were already outside the archive (`build/film.js` is excluded and `67js/addons/film` is not exported). Separate lazy-loaded packages were not built: the lazy addons together are about 157 KB gzip, so splitting them out could return at most that much of an archive that already has room, for the cost of a package, a release pipeline and a version matrix each; revisit when less than 150 KB is free. `archiveBytes` budget 815,000 to 687,800.
- Fix three gaps a demo film found in the recipe light bake (part of issue #55). A baked scene with `cloth` failed at render time for every frame after t=0 with "A light map needs lightUvs on rigid geometry, with no skin or morph", because the cloth simulation replaces the sheet's geometry each frame; cloth sheet nodes are now skipped and listed in `report.skipped`. The bake now lights with spot lights (the renderer's cone and soft edge) and area lights (front side only, one deterministic shadow ray to a point of the rectangle per hit), where it ignored both; a scene without them bakes the same bytes. The presets could not finish a normal scene (`standard` passed its 20 s limit on a 56 part room, `fine` hit the 30 s preview limit): a recipe bake now has a ray work budget of 10 million units (texels x samples x bounces x rays per hit), estimated from the unwrap before any ray is traced with no clock involved. A preset is scaled down to fit and `scene_inspect` `bake` reports `used` and `reduced`; explicit `samples`, `bounces` or `texelsPerUnit` are never reduced and fail with a message naming the number that fits. `bakeLightmaps` is now `planLightmaps`, `estimateBake` and `traceLightmaps` (still exported as one call). `entry:core` did not change; `entry:light-bake` grew by 1,033 bytes gzip (budget 25,900 to 26,900) and the lazy agent entries by about 1,580; the schema stayed within its total budget (the capability notes were shortened to fit).
- Add `sculpt` and `shrinkwrap` mesh edits (part of issue #47; surface patches and a stack form are not built). `sculpt` applies up to 32 inflate, displace and smooth strokes to the vertices of the selected faces; `shrinkwrap` moves them onto a primitive, to the nearest point or projected along a direction, with an offset. Both are in `scene_capabilities` (`meshSculpt`) and in the `mesh_edit` schema, with the tool schema total unchanged (the face rule and tag prefix descriptions were shortened to pay for them). The stroke maths moved to `src/sculpt-strokes.js` and serves `sculptGeometry` too. Four Blender golden cases (two Shrinkwrap modifier comparisons; the sculpt reference runs the same brush formula on Blender's mesh), hostile input tests, and the suite task `ball-badge`, which needs a plate bent onto a ball.
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index 9c5512dc..5150c0f6 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -56,12 +56,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## MCP command and browser preview
-The packaged `build/mcp/server.mjs` and `build/mcp/preview.js` bundle the MCP SDK,
-schema validation and rendering dependencies. `build/mcp/LICENSES.md` contains
-their complete license and notice texts, including dependencies embedded in the SDK.
+The packaged `build/mcp/preview.js` and its engine chunks bundle rendering dependencies, and
+`build/mcp/LICENSES.md` contains their complete license and notice texts.
`build/mcp/manifest.json` records dependency versions, license provenance and output SHA-256 hashes.
-Pinned upstream license copies for embedded dependencies are retained in `licenses/mcp/` in the source repository.
-The external `playwright-core` browser driver includes its own license and notices in its dependency package.
+The MCP SDK (`@modelcontextprotocol/server`, Apache-2.0), `zod` (MIT) and the `playwright-core`
+browser driver are normal dependencies that npm installs next to the package. Each carries its own
+license and notices, including the dependencies prebundled inside the SDK.
## RobotExpressive (test fixture, not in the npm package)
diff --git a/bench/size/README.md b/bench/size/README.md
index b9a28cd8..0f1b68b0 100644
--- a/bench/size/README.md
+++ b/bench/size/README.md
@@ -39,7 +39,9 @@ Use `--set-budgets` to reset every budget to 2% over the current size. Use it af
## Package archive
-`archiveBytes` in `budgets.json` caps the npm archive that `npm pack` makes. `npm run smoke:package` checks it, after `npm run prepare:release`. The archive was 904,975 bytes before the MCP preview shared the package's engine chunks and 666,214 after, so lower `archiveBytes` when work shrinks it.
+`archiveBytes` in `budgets.json` caps the npm archive that `npm pack` makes. `npm run smoke:package` checks it, after `npm run prepare:release`. The archive was 904,975 bytes before the MCP preview shared the package's engine chunks and 666,214 after; features then grew it to 802,581, and making `@modelcontextprotocol/server` and `zod` installed dependencies instead of bundled code brought it to 677,563 (the budget is that plus 1.5 percent). Lower `archiveBytes` when work shrinks it.
+
+Before adding a dependency to save archive bytes, weigh it: the archive number falls, and the consumer's install size and first-run download rise. The two packages above save about 125 KB of archive for about 14.5 MB on disk.
## Limits
diff --git a/bench/size/budgets.json b/bench/size/budgets.json
index 6ad39dc4..c59f55e4 100644
--- a/bench/size/budgets.json
+++ b/bench/size/budgets.json
@@ -1,5 +1,5 @@
{
- "archiveBytes": 815000,
+ "archiveBytes": 687800,
"goals": {
"lit-box": 50000,
"gltf-box": 80000,
diff --git a/docs/release-verification.md b/docs/release-verification.md
index 49266eb4..802c145c 100644
--- a/docs/release-verification.md
+++ b/docs/release-verification.md
@@ -7,8 +7,10 @@ Source checks used Windows Node.js, installed Chrome and CPU SwiftShader. Regist
| Check | Measured result |
| --- | --- |
-| Archive | 904,975 bytes before, 666,214 after, so 382,362 bytes are free under 1 MiB. |
-| Node tests | 1129 tests passed. |
+| Archive | 802,581 bytes before, 677,563 after (the MCP SDK and zod are installed dependencies, not bundled), so 370,000 bytes are free under 1 MiB. Install size grows by about 14.5 MB. |
+| Every export | `npm run smoke:package` loads each `exports` entry in a clean consumer. |
+| Audit | `npm audit --audit-level=high` found 0 vulnerabilities with the new dependencies. |
+| Node tests | 1359 tests passed. |
| Clean source archive | `npm run smoke:package` passed. |
| Installed MCP CLI | `npm run smoke:mcp-package` (not protocol only) passed with a modern and a legacy client, and checked every `previewChunks` hash. |
| Real character | `npm run smoke:character` passed on the GPU. |
diff --git a/licenses/mcp/ajv-8.18.0.txt b/licenses/mcp/ajv-8.18.0.txt
deleted file mode 100644
index e409b403..00000000
--- a/licenses/mcp/ajv-8.18.0.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-Source: https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz
-Integrity: sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==
-
-package/LICENSE
-
-The MIT License (MIT)
-
-Copyright (c) 2015-2021 Evgeny Poberezkin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/licenses/mcp/ajv-formats-3.0.1.txt b/licenses/mcp/ajv-formats-3.0.1.txt
deleted file mode 100644
index 78bf907a..00000000
--- a/licenses/mcp/ajv-formats-3.0.1.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-Source: https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz
-Integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==
-
-package/LICENSE
-
-MIT License
-
-Copyright (c) 2020 Evgeny Poberezkin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/licenses/mcp/content-type-1.0.5.txt b/licenses/mcp/content-type-1.0.5.txt
deleted file mode 100644
index 218310de..00000000
--- a/licenses/mcp/content-type-1.0.5.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-Source: https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz
-Integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==
-
-package/LICENSE
-
-(The MIT License)
-
-Copyright (c) 2015 Douglas Christopher Wilson
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/licenses/mcp/fast-deep-equal-3.1.3.txt b/licenses/mcp/fast-deep-equal-3.1.3.txt
deleted file mode 100644
index 85f12406..00000000
--- a/licenses/mcp/fast-deep-equal-3.1.3.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-Source: https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz
-Integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
-
-package/LICENSE
-
-MIT License
-
-Copyright (c) 2017 Evgeny Poberezkin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/licenses/mcp/fast-uri-3.1.8.txt b/licenses/mcp/fast-uri-3.1.8.txt
deleted file mode 100644
index 9c93c1c0..00000000
--- a/licenses/mcp/fast-uri-3.1.8.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-Copyright (c) 2011-2021, Gary Court until https://github.com/garycourt/uri-js/commit/a1acf730b4bba3f1097c9f52e7d9d3aba8cdcaae
-Copyright (c) 2021-present The Fastify team <https://github.com/fastify/fastify#team>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * The names of any contributors may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- * * *
-
-The complete list of contributors can be found at:
-- https://github.com/garycourt/uri-js/graphs/contributors
\ No newline at end of file
diff --git a/licenses/mcp/json-schema-traverse-1.0.0.txt b/licenses/mcp/json-schema-traverse-1.0.0.txt
deleted file mode 100644
index 897178e7..00000000
--- a/licenses/mcp/json-schema-traverse-1.0.0.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-Source: https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz
-Integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
-
-package/LICENSE
-
-MIT License
-
-Copyright (c) 2017 Evgeny Poberezkin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/package-lock.json b/package-lock.json
index 6e797589..bbd93a7e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,9 @@
"version": "0.14.0",
"license": "MIT",
"dependencies": {
- "playwright-core": "1.64.1"
+ "@modelcontextprotocol/server": "2.4.0",
+ "playwright-core": "1.64.1",
+ "zod": "4.6.7"
},
"bin": {
"67js-mcp": "bin/67js-mcp.mjs"
@@ -18,7 +20,6 @@
"@codepawlhq/orglet-ui": "0.2.1",
"@dimforge/rapier3d-compat": "0.21.0",
"@modelcontextprotocol/client": "2.4.0",
- "@modelcontextprotocol/server": "2.4.0",
"ajv": "^8.20.0",
"ajv-formats": "^3.0.1",
"esbuild": "0.28.2",
@@ -31,8 +32,7 @@
"three": "0.186.1",
"three-mesh-bvh": "0.9.16",
"vite": "8.3.5",
- "wrangler": "4.156.0",
- "zod": "4.6.7"
+ "wrangler": "4.156.0"
},
"engines": {
"node": ">=20.19.0"
@@ -1328,7 +1328,6 @@
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.4.0.tgz",
"integrity": "sha512-z8QBKqdfXLPzkLQuG4xp8hrVEMm1PZ1IgxMN2sMbJiFiAKOWXnAzogXn2W4aqIBlP1ea6U5yiqVquvUNM1Cj6Q==",
- "dev": true,
"license": "Apache-2.0",
"dependencies": {
"zod": "^4.2.0"
@@ -1341,7 +1340,6 @@
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.4.0.tgz",
"integrity": "sha512-rgR9yxSaAJ+bcsi/XroT/S2AfPiIWloXAnrdfYSCms9ivVju0ishu/wW0J21Ho6+ZOR1r7RyeRbjiRuF87ix5Q==",
- "dev": true,
"license": "Apache-2.0",
"dependencies": {
"@modelcontextprotocol/core": "2.4.0",
@@ -3632,7 +3630,6 @@
"version": "4.6.7",
"resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
"integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
- "dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
diff --git a/package.json b/package.json
index b2cb18c6..ca6d21ee 100644
--- a/package.json
+++ b/package.json
@@ -132,7 +132,9 @@
"manifold-3d": "3.5.4"
},
"dependencies": {
- "playwright-core": "1.64.1"
+ "@modelcontextprotocol/server": "2.4.0",
+ "playwright-core": "1.64.1",
+ "zod": "4.6.7"
},
"peerDependenciesMeta": {
"@dimforge/rapier3d-compat": {
@@ -146,7 +148,6 @@
"@codepawlhq/orglet-ui": "0.2.1",
"@dimforge/rapier3d-compat": "0.21.0",
"@modelcontextprotocol/client": "2.4.0",
- "@modelcontextprotocol/server": "2.4.0",
"ajv": "^8.20.0",
"ajv-formats": "^3.0.1",
"esbuild": "0.28.2",
@@ -159,7 +160,6 @@
"three": "0.186.1",
"three-mesh-bvh": "0.9.16",
"vite": "8.3.5",
- "wrangler": "4.156.0",
- "zod": "4.6.7"
+ "wrangler": "4.156.0"
}
}
diff --git a/scripts/build-mcp.mjs b/scripts/build-mcp.mjs
index 5f4f741f..72e23a59 100644
--- a/scripts/build-mcp.mjs
+++ b/scripts/build-mcp.mjs
@@ -33,7 +33,6 @@ async function dependencyFor(moduleId) {
async function collectLicenses(chunks) {
const dependencies = new Map();
- const embedded = new Map();
const rootsByModule = new Map();
for (const chunk of chunks) {
for (const [moduleId, information] of Object.entries(chunk.modules)) {
@@ -46,39 +45,9 @@ async function collectLicenses(chunks) {
if (!dependency) continue;
const key = `${dependency.metadata.name}@${dependency.metadata.version}`;
dependencies.set(key, dependency);
- // The SDK ships prebundled dependencies whose module roots are invisible to Rolldown.
- if (!dependency.metadata.name.startsWith('@modelcontextprotocol/')) continue;
- const source = await readFile(moduleId.split('?')[0], 'utf8');
- for (const match of source.matchAll(/\/\/#[rR]egion [^\n]*\/\.pnpm\/([^/]+)\/node_modules\/(?:@[^/]+\/)?[^/]+\//g)) {
- const encoded = match[1].split('_')[0];
- const versionOffset = encoded.lastIndexOf('@');
- if (versionOffset < 1) continue;
- const name = encoded.slice(0, versionOffset).replace('+', '/');
- const version = encoded.slice(versionOffset + 1);
- if (!/^\d+\.\d+\.\d+/.test(version)) continue;
- embedded.set(`${name}@${version}`, { name, version, bundledBy: key });
- }
}
}
const gaps = [];
- const embeddedNotices = [];
- for (const [key, dependency] of embedded) {
- if (dependencies.has(key)) continue;
- const installed = await packageAt(join(root, 'node_modules', dependency.name));
- if (installed?.metadata.version === dependency.version) {
- dependencies.set(key, installed);
- } else {
- const filename = join(root, 'licenses', 'mcp', `${dependency.name.replaceAll('/', '_')}-${dependency.version}.txt`);
- if (existsSync(filename)) {
- const contents = await readFile(filename, 'utf8');
- embeddedNotices.push(`## ${key}\n\n${contents}`);
- dependency.licenseFile = relative(root, filename).replaceAll('\\', '/');
- dependency.licenseSha256 = digest(Buffer.from(contents));
- } else {
- gaps.push({ ...dependency, reason: 'Exact prebundled dependency license is unavailable in installed package roots or licenses/mcp.' });
- }
- }
- }
const projectLicense = await readFile(join(root, 'LICENSE'), 'utf8');
const notices = [`# MCP bundle licenses\n\n## ${JSON.parse(await readFile(join(root, 'package.json'), 'utf8')).name}\n\n${projectLicense}`];
const records = [];
@@ -92,7 +61,14 @@ async function collectLicenses(chunks) {
notices.push(`## ${key}: ${filename}\n\n${await readFile(join(dependency.directory, filename), 'utf8')}`);
}
}
- return { text: `${[...notices, ...embeddedNotices].join('\n\n')}\n`, dependencies: records, embeddedDependencies: [...embedded.values()], licenseGaps: gaps };
+ return { text: `${notices.join('\n\n')}\n`, dependencies: records, licenseGaps: gaps };
+}
+
+// Installed next to the package by npm, so the server bundle imports them instead of carrying a copy.
+const INSTALLED_DEPENDENCY_PREFIXES = ['playwright-core', '@modelcontextprotocol/', 'zod'];
+
+function isInstalledDependency(specifier) {
+ return INSTALLED_DEPENDENCY_PREFIXES.some(prefix => specifier === prefix || specifier.startsWith(prefix.endsWith('/') ? prefix : `${prefix}/`));
}
function singleModule(result, filename) {
@@ -102,7 +78,7 @@ function singleModule(result, filename) {
}
const chunk = outputs[0];
for (const specifier of chunk.imports) {
- if (!isBuiltin(specifier) && specifier !== 'playwright-core') {
+ if (!isBuiltin(specifier) && !isInstalledDependency(specifier)) {
throw new Error(`${filename} has an unexpected external import: ${specifier}.`);
}
}
@@ -116,6 +92,15 @@ function singleModule(result, filename) {
return chunk;
}
+async function installedDependencyRecords(names) {
+ const records = [];
+ for (const name of names) {
+ const installed = await packageAt(join(root, 'node_modules', name));
+ records.push({ name, version: installed.metadata.version, license: installed.metadata.license ?? null });
+ }
+ return records;
+}
+
const PREVIEW_ENTRY_FILE = 'mcp/preview.js';
/**
@@ -188,7 +173,7 @@ export async function buildMcp({ outDir = join(root, 'build', 'mcp') } = {}) {
lib: { entry: join(root, 'scripts', 'mcp-server.mjs'), formats: ['es'], fileName: () => 'server.mjs' },
rolldownOptions: {
platform: 'node',
- external: specifier => isBuiltin(specifier) || specifier === 'playwright-core' || specifier === 'manifold-3d' || specifier === '@dimforge/rapier3d-compat',
+ external: specifier => isBuiltin(specifier) || isInstalledDependency(specifier) || specifier === 'manifold-3d' || specifier === '@dimforge/rapier3d-compat',
output: { codeSplitting: false, comments: { legal: true }, banner: legalBanner },
},
},
@@ -218,9 +203,8 @@ export async function buildMcp({ outDir = join(root, 'build', 'mcp') } = {}) {
sourceDirty: Boolean(status.stdout.trim()),
nodeTarget: 'node20',
buildTool: { name: 'vite', version: (await packageAt(join(root, 'node_modules', 'vite'))).metadata.version },
- externalDependencies: [{ name: 'playwright-core', version: (await packageAt(join(root, 'node_modules', 'playwright-core'))).metadata.version }],
+ externalDependencies: await installedDependencyRecords(['playwright-core', '@modelcontextprotocol/server', 'zod']),
dependencies: licenses.dependencies,
- embeddedDependencies: licenses.embeddedDependencies,
licenseGaps: licenses.licenseGaps,
outputs,
previewChunks: previewChunks
diff --git a/scripts/smoke-mcp-package.mjs b/scripts/smoke-mcp-package.mjs
index 692d65d5..8b3b6bbf 100644
--- a/scripts/smoke-mcp-package.mjs
+++ b/scripts/smoke-mcp-package.mjs
@@ -36,8 +36,11 @@ const installed = JSON.parse(await readFile(join(installedRoot, 'package.json'),
assert.equal(installed.version, metadata.version);
assert.equal(installed.bin['67js-mcp'], './bin/67js-mcp.mjs');
const sourceManifest = JSON.parse(await readFile('package.json', 'utf8'));
-assert.deepEqual(installed.dependencies, { 'playwright-core': sourceManifest.dependencies['playwright-core'] });
-for (const dependency of ['vite', 'zod', 'three', 'gl-matrix', '@modelcontextprotocol/server', '@modelcontextprotocol/client', 'playwright']) {
+assert.deepEqual(installed.dependencies, sourceManifest.dependencies);
+for (const dependency of ['@modelcontextprotocol/server', 'playwright-core', 'zod']) {
+ assert.equal(existsSync(join(consumer, 'node_modules', dependency)), true, `The installed package must bring its runtime dependency ${dependency}.`);
+}
+for (const dependency of ['vite', 'three', 'gl-matrix', '@modelcontextprotocol/client', 'playwright']) {
assert.equal(existsSync(join(consumer, 'node_modules', dependency)), false, `Runtime must not depend on a checkout or ${dependency}.`);
}
assert.equal(existsSync(join(installedRoot, 'src')), false);
diff --git a/scripts/smoke-package.mjs b/scripts/smoke-package.mjs
index c28a37bf..fa5eed75 100644
--- a/scripts/smoke-package.mjs
+++ b/scripts/smoke-package.mjs
@@ -43,6 +43,8 @@ if (published) {
assert.equal(installedLock.packages['node_modules/67js'].integrity, release.integrity, 'Installed npm package differs from release integrity.');
}
const example = `import assert from 'node:assert/strict';
+import { existsSync, readFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
import { VERSION, Renderer67, box, assemblyOffset, cameraView, fitPerspectiveDistance, createAnimationClip, sampleAnimationClip, EFFECT_PRESETS, createMorphPose, MAX_MORPH_TARGETS, exportGlb } from '67js';
import { createModel } from '67js/addons/model';
import * as nature from '67js/addons/nature';
@@ -205,6 +207,17 @@ assert.equal(parts.length, 574);
assert.ok(parts.every(part => assemblyOffset(part, 1).some(value => value !== 0)));
assert.ok(Object.keys(nature).length > 0);
await assert.rejects(() => import('67js/addons/film'), { code: 'ERR_PACKAGE_PATH_NOT_EXPORTED' });
+const installedMetadata = JSON.parse(readFileSync(new URL('./node_modules/67js/package.json', import.meta.url), 'utf8'));
+const exportedEntries = Object.keys(installedMetadata.exports);
+assert.ok(exportedEntries.length > 30, 'The installed package must publish its export map.');
+for (const entry of exportedEntries) {
+ const specifier = entry === '.' ? '67js' : '67js/' + entry.slice(2);
+ const resolvedPath = fileURLToPath(import.meta.resolve(specifier));
+ assert.ok(existsSync(resolvedPath), 'Export ' + entry + ' resolves to a file that is missing from the package.');
+ if (entry === './package.json') continue;
+ // An entry may register itself on import and export nothing, so loading without an error is the check.
+ await import(specifier);
+}
assert.equal(cameraView('top').projection, 'orthographic');
const fitBounds = { minimum: [-1, -1, -1], maximum: [1, 1, 1] };
const fitView = { eye: [0, 0, 5], target: [0, 0, 0], fov: 45, far: 100 };