From 18792fad78720dafa2c52ab646e577ddd7959296 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:37:03 +0200 Subject: [PATCH 01/17] feat: enable Zstd websocket compression by default --- src/connection.js | 56 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/src/connection.js b/src/connection.js index 7aab7d2..e378ef1 100644 --- a/src/connection.js +++ b/src/connection.js @@ -6,6 +6,26 @@ import { APP_VERSION } from './app-info.js'; const RECONNECT_DELAY_MS = 1000; const CONNECTION_ATTEMPT_TIMEOUT_MS = 2500; +let zstdDecompressorPromise; + +async function getZstdDecompressor() { + if (!zstdDecompressorPromise) { + zstdDecompressorPromise = import('zstddec') + .then(async ({ ZSTDDecoder }) => { + const decoder = new ZSTDDecoder(); + await decoder.init(); + return (data) => decoder.decode(data); + }) + .catch((error) => { + // Allow a later reconnect attempt to retry initialization if loading the + // local decoder failed transiently. + zstdDecompressorPromise = undefined; + throw error; + }); + } + return zstdDecompressorPromise; +} + // Three.js is Y-up, right-handed and metre-based. Ask Augmenta/Pleiades to // deliver tracking and setup data directly in that convention. const THREE_JS_AXIS_TRANSFORM = Object.freeze({ @@ -38,6 +58,7 @@ export function createConnectionController({ let targetIndex = 0; let targetKey = ''; let attemptTimer; + let connectionAttemptGeneration = 0; function getState() { return { wantsConnection, socketOpen, retrying, activeVersion, phase, note }; @@ -70,6 +91,7 @@ export function createConnectionController({ } function stopTransport(reason = 'User disconnect') { + connectionAttemptGeneration += 1; clearReconnectTimer(); clearAttemptTimer(); socketOpen = false; @@ -107,7 +129,7 @@ export function createConnectionController({ reconnectTimer = window.setTimeout(() => { reconnectTimer = undefined; - attemptConnection(); + void attemptConnection(); }, delay); } @@ -119,14 +141,15 @@ export function createConnectionController({ publish('connecting', `Server uses protocol V${version}. Reconnecting with the matching parser…`); reconnectTimer = window.setTimeout(() => { reconnectTimer = undefined; - attemptConnection(); + void attemptConnection(); }, 0); } - function attemptConnection() { + async function attemptConnection() { if (!wantsConnection) return; clearReconnectTimer(); + const attemptGeneration = ++connectionAttemptGeneration; let target; let protocol; @@ -160,10 +183,25 @@ export function createConnectionController({ publish('connecting', `Connecting to ${target.label} with protocol V${version}…`); } + let decompressor; + try { + decompressor = await getZstdDecompressor(); + } catch (error) { + if (attemptGeneration !== connectionAttemptGeneration || !wantsConnection) return; + wantsConnection = false; + retrying = false; + const message = error instanceof Error ? error.message : String(error); + publish('error', `Could not initialize Zstd decompression: ${message}`); + return; + } + + if (attemptGeneration !== connectionAttemptGeneration || !wantsConnection) return; + const connection = new AugmentaWebSocketClient(target.url, { clientName: 'Augmenta Three.js Debug Viewer', applicationName: 'Augmenta ThreeJS Example', applicationVersion: APP_VERSION, + decompressor, options: { version, downSample, @@ -171,7 +209,11 @@ export function createConnectionController({ streamClusters, streamClusterPoints, streamZonePoints: true, - useCompression: false, + // Keep the realtime stream compressed by default, matching the Unity, + // TouchDesigner and VVVV clients. This cuts WebSocket bandwidth and + // backlog pressure; zstddec is initialized before the connection and + // the JS SDK invokes it synchronously before parsing each binary frame. + useCompression: true, displayPointIntensity: true, // Quaternions preserve Pleiades' exact OBB orientation. The viewer // performs the left-handed -> right-handed basis reflection explicitly. @@ -196,7 +238,7 @@ export function createConnectionController({ socketOpen = true; publish( 'connected', - `Connected to ${target.label}. Protocol V${activeVersion}; uncompressed debug stream.` + `Connected to ${target.label}. Protocol V${activeVersion}; Zstd-compressed debug stream.` ); }); @@ -274,7 +316,7 @@ export function createConnectionController({ autoNegotiatedVersion = undefined; wantsConnection = true; retrying = false; - attemptConnection(); + void attemptConnection(); } function stop() { @@ -290,7 +332,7 @@ export function createConnectionController({ retrying = false; autoNegotiatedVersion = undefined; stopTransport(reason); - attemptConnection(); + void attemptConnection(); } return { getState, start, stop, restart }; From 82e01990c117580d9ed0117c3793153b72919e73 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:37:18 +0200 Subject: [PATCH 02/17] build: map browser Zstd decoder --- index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 8fba720..d5d4407 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,8 @@ "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.186.1/build/three.module.js", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.186.1/examples/jsm/", - "augmenta-client-sdk": "./vendor/AugmentaClientSDK-JS/dist/esm/index.js" + "augmenta-client-sdk": "./vendor/AugmentaClientSDK-JS/dist/esm/index.js", + "zstddec": "https://cdn.jsdelivr.net/npm/zstddec@0.3.1/dist/zstddec.modern.js" } } From a3ead3454765e93fd026f3757f8503808f79bdff Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:38:13 +0200 Subject: [PATCH 03/17] build: bundle Zstd decoder into Pages artifact --- scripts/assemble-site.mjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/assemble-site.mjs b/scripts/assemble-site.mjs index 15d83ae..100f656 100644 --- a/scripts/assemble-site.mjs +++ b/scripts/assemble-site.mjs @@ -14,7 +14,9 @@ const root = process.cwd(); const out = join(root, '_site'); const rev = (process.env.GITHUB_SHA || 'local').slice(0, 12); const threeRoot = join(root, '.pages-runtime', 'node_modules', 'three'); +const zstdRoot = join(root, '.pages-runtime', 'node_modules', 'zstddec', 'dist'); const sdkOut = join(out, 'vendor', 'AugmentaClientSDK-JS', rev, 'dist', 'esm'); +const zstdOut = join(out, 'vendor', 'zstddec', rev, 'dist'); function requirePath(path, label) { if (!existsSync(path)) { @@ -32,10 +34,12 @@ function replaceRequired(source, search, replacement) { requirePath(join(root, 'vendor', 'AugmentaClientSDK-JS', 'dist', 'esm'), 'built Augmenta SDK'); requirePath(join(root, 'vendor', 'qrcode-generator', 'qrcode.js'), 'vendored QR generator'); requirePath(join(threeRoot, 'build', 'three.module.js'), 'Three.js runtime'); +requirePath(join(zstdRoot, 'zstddec.modern.js'), 'Zstd browser decoder'); rmSync(out, { recursive: true, force: true }); mkdirSync(join(out, 'src'), { recursive: true }); mkdirSync(sdkOut, { recursive: true }); +mkdirSync(zstdOut, { recursive: true }); mkdirSync(join(out, 'vendor', 'qrcode-generator'), { recursive: true }); copyFileSync(join(root, 'index.html'), join(out, 'index.html')); @@ -54,6 +58,10 @@ cpSync( sdkOut, { recursive: true } ); +// zstddec embeds the WebAssembly decoder in its browser module, so copying the +// built dist directory keeps compressed Augmenta streams self-contained on +// GitHub Pages with no runtime CDN dependency. +cpSync(zstdRoot, zstdOut, { recursive: true }); copyFileSync( join(root, 'vendor', 'qrcode-generator', 'qrcode.js'), join(out, 'vendor', 'qrcode-generator', 'qrcode.js') @@ -98,6 +106,11 @@ html = replaceRequired( './vendor/AugmentaClientSDK-JS/dist/esm/index.js', `./vendor/AugmentaClientSDK-JS/${rev}/dist/esm/index.js` ); +html = replaceRequired( + html, + 'https://cdn.jsdelivr.net/npm/zstddec@0.3.1/dist/zstddec.modern.js', + `./vendor/zstddec/${rev}/dist/zstddec.modern.js` +); html = replaceRequired(html, './src/styles.css', `./src/styles.css?v=${rev}`); html = replaceRequired(html, './src/qr.js', `./src/qr.js?v=${rev}`); html = replaceRequired(html, './src/main.js', `./src/main.js?v=${rev}`); From a7cb569f34d83227476c6e99dcc97d941079be5e Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:38:21 +0200 Subject: [PATCH 04/17] ci: install Zstd decoder for browser runtime --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90325da..9c4bf11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: - name: Install Pages runtime dependencies shell: bash run: | - npm install --prefix .pages-runtime --no-save --no-package-lock --ignore-scripts three@0.186.1 + npm install --prefix .pages-runtime --no-save --no-package-lock --ignore-scripts three@0.186.1 zstddec@0.3.1 - name: Validate example JavaScript shell: bash From 12817ff271f6c8977db4201c1540bae15d660df3 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:38:24 +0200 Subject: [PATCH 05/17] ci: install Zstd decoder for browser runtime --- .github/workflows/pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 447a0b0..abbfce0 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -42,7 +42,7 @@ jobs: - name: Install Pages runtime dependencies shell: bash run: | - npm install --prefix .pages-runtime --no-save --no-package-lock --ignore-scripts three@0.186.1 + npm install --prefix .pages-runtime --no-save --no-package-lock --ignore-scripts three@0.186.1 zstddec@0.3.1 - name: Validate example JavaScript shell: bash From c113a215100b0e7aa8aa55cc8bde6d8c5a5aff63 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:38:53 +0200 Subject: [PATCH 06/17] docs: add Zstd decoder license --- THIRD_PARTY_LICENSES | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/THIRD_PARTY_LICENSES b/THIRD_PARTY_LICENSES index 5b2ac62..9dd31bb 100644 --- a/THIRD_PARTY_LICENSES +++ b/THIRD_PARTY_LICENSES @@ -66,3 +66,63 @@ 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. + +4. zstddec 0.3.1 +----------------- + +Project: https://github.com/donmccurdy/zstddec-wasm +License: MIT AND BSD-3-Clause + +The MIT License (MIT) + +Copyright (c) 2020 Don McCurdy + +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. + +BSD License + +For Zstandard software + +Copyright (c) 2016-present, Yann Collet, Facebook, Inc. 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. + + * Neither the name Facebook nor the names of its contributors may 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 HOLDER OR 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. + From c43cd34201ad97a38bdfb32f17f9eb2e1d28046e Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:38:56 +0200 Subject: [PATCH 07/17] test: validate browser Zstd decompression --- tests/websocket-compression.test.mjs | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/websocket-compression.test.mjs diff --git a/tests/websocket-compression.test.mjs b/tests/websocket-compression.test.mjs new file mode 100644 index 0000000..e47f210 --- /dev/null +++ b/tests/websocket-compression.test.mjs @@ -0,0 +1,37 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import test from 'node:test'; + +const compressedFixture = Uint8Array.from([ + 40, 181, 47, 253, 4, 88, 241, 0, 0, 65, 117, 103, 109, 101, 110, 116, + 97, 32, 90, 115, 116, 100, 32, 105, 110, 116, 101, 103, 114, 97, 116, 105, + 111, 110, 32, 116, 101, 115, 116, 185, 49, 3, 224 +]); + +test('bundled zstd decoder can decode Augmenta binary payloads synchronously after init', async () => { + const { ZSTDDecoder } = await import('../.pages-runtime/node_modules/zstddec/dist/zstddec.modern.js'); + const decoder = new ZSTDDecoder(); + await decoder.init(); + + const decoded = decoder.decode(compressedFixture); + assert.equal(new TextDecoder().decode(decoded), 'Augmenta Zstd integration test'); + + // The SDK requires a synchronous decompressor once the transport is running. + const decompressor = (data) => decoder.decode(data); + assert.equal( + new TextDecoder().decode(decompressor(compressedFixture)), + 'Augmenta Zstd integration test' + ); +}); + +test('Three.js runtime requests compression and ships the decoder in the Pages artifact', () => { + const connection = readFileSync(new URL('../src/connection.js', import.meta.url), 'utf8'); + const index = readFileSync(new URL('../index.html', import.meta.url), 'utf8'); + const assemble = readFileSync(new URL('../scripts/assemble-site.mjs', import.meta.url), 'utf8'); + + assert.match(connection, /useCompression:\s*true/); + assert.match(connection, /decompressor,/); + assert.match(connection, /import\('zstddec'\)/); + assert.match(index, /zstddec@0\.3\.1/); + assert.match(assemble, /zstddec\.modern\.js/); +}); From 83ec6f75fe7abba213c46fb0cd958df292fcb869 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:41:17 +0200 Subject: [PATCH 08/17] fix: use package-safe Zstd browser import --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index d5d4407..8c37795 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@ "three": "https://cdn.jsdelivr.net/npm/three@0.186.1/build/three.module.js", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.186.1/examples/jsm/", "augmenta-client-sdk": "./vendor/AugmentaClientSDK-JS/dist/esm/index.js", - "zstddec": "https://cdn.jsdelivr.net/npm/zstddec@0.3.1/dist/zstddec.modern.js" + "zstddec": "https://cdn.jsdelivr.net/npm/zstddec@0.3.1/+esm" } } From ad9ec27d65c3b5ed84b8b1dbb8ee1ac77ea68d3a Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:41:20 +0200 Subject: [PATCH 09/17] fix: resolve packaged Zstd browser entrypoint dynamically --- scripts/assemble-site.mjs | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/scripts/assemble-site.mjs b/scripts/assemble-site.mjs index 100f656..22aff51 100644 --- a/scripts/assemble-site.mjs +++ b/scripts/assemble-site.mjs @@ -14,9 +14,9 @@ const root = process.cwd(); const out = join(root, '_site'); const rev = (process.env.GITHUB_SHA || 'local').slice(0, 12); const threeRoot = join(root, '.pages-runtime', 'node_modules', 'three'); -const zstdRoot = join(root, '.pages-runtime', 'node_modules', 'zstddec', 'dist'); +const zstdRoot = join(root, '.pages-runtime', 'node_modules', 'zstddec'); const sdkOut = join(out, 'vendor', 'AugmentaClientSDK-JS', rev, 'dist', 'esm'); -const zstdOut = join(out, 'vendor', 'zstddec', rev, 'dist'); +const zstdOut = join(out, 'vendor', 'zstddec', rev); function requirePath(path, label) { if (!existsSync(path)) { @@ -34,7 +34,26 @@ function replaceRequired(source, search, replacement) { requirePath(join(root, 'vendor', 'AugmentaClientSDK-JS', 'dist', 'esm'), 'built Augmenta SDK'); requirePath(join(root, 'vendor', 'qrcode-generator', 'qrcode.js'), 'vendored QR generator'); requirePath(join(threeRoot, 'build', 'three.module.js'), 'Three.js runtime'); -requirePath(join(zstdRoot, 'zstddec.modern.js'), 'Zstd browser decoder'); +requirePath(join(zstdRoot, 'package.json'), 'Zstd decoder package'); + +const zstdPackage = JSON.parse(readFileSync(join(zstdRoot, 'package.json'), 'utf8')); +const zstdExports = zstdPackage.exports; +const zstdEntrypoint = ( + typeof zstdExports === 'string' + ? zstdExports + : zstdExports?.['.']?.browser + ?? zstdExports?.['.']?.default + ?? zstdExports?.browser + ?? zstdExports?.default + ?? zstdPackage.browser + ?? zstdPackage.module + ?? zstdPackage.main +); +if (typeof zstdEntrypoint !== 'string' || !zstdEntrypoint) { + throw new Error('Could not resolve the zstddec browser entrypoint.'); +} +const zstdEntrypointRelative = zstdEntrypoint.replace(/^\.\//, ''); +requirePath(join(zstdRoot, zstdEntrypointRelative), 'Zstd browser decoder entrypoint'); rmSync(out, { recursive: true, force: true }); mkdirSync(join(out, 'src'), { recursive: true }); @@ -58,9 +77,9 @@ cpSync( sdkOut, { recursive: true } ); -// zstddec embeds the WebAssembly decoder in its browser module, so copying the -// built dist directory keeps compressed Augmenta streams self-contained on -// GitHub Pages with no runtime CDN dependency. +// zstddec embeds the WebAssembly decoder in its browser package, so copying the +// package keeps compressed Augmenta streams self-contained on GitHub Pages with +// no runtime CDN dependency. cpSync(zstdRoot, zstdOut, { recursive: true }); copyFileSync( join(root, 'vendor', 'qrcode-generator', 'qrcode.js'), @@ -108,8 +127,8 @@ html = replaceRequired( ); html = replaceRequired( html, - 'https://cdn.jsdelivr.net/npm/zstddec@0.3.1/dist/zstddec.modern.js', - `./vendor/zstddec/${rev}/dist/zstddec.modern.js` + 'https://cdn.jsdelivr.net/npm/zstddec@0.3.1/+esm', + `./vendor/zstddec/${rev}/${zstdEntrypointRelative}` ); html = replaceRequired(html, './src/styles.css', `./src/styles.css?v=${rev}`); html = replaceRequired(html, './src/qr.js', `./src/qr.js?v=${rev}`); From 891ea3971d13df9cc7688c300a11d8d93b828b59 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:41:23 +0200 Subject: [PATCH 10/17] ci: expose Zstd decoder to Node integration tests --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c4bf11..ad67b99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,7 @@ jobs: run: | mkdir -p node_modules ln -s ../vendor/AugmentaClientSDK-JS node_modules/augmenta-client-sdk + ln -s ../.pages-runtime/node_modules/zstddec node_modules/zstddec node --test tests/*.test.mjs - name: Assemble Pages artifact From 42b23b736aaa78b4c78fd93a63c194fa0bc6492c Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:41:26 +0200 Subject: [PATCH 11/17] ci: expose Zstd decoder to Node integration tests --- .github/workflows/pages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index abbfce0..8241503 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -56,6 +56,7 @@ jobs: run: | mkdir -p node_modules ln -s ../vendor/AugmentaClientSDK-JS node_modules/augmenta-client-sdk + ln -s ../.pages-runtime/node_modules/zstddec node_modules/zstddec node --test tests/*.test.mjs - name: Assemble static site From 64dcdcd3f7beb01ed2db8951946ff0a7a915ff28 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:41:29 +0200 Subject: [PATCH 12/17] test: resolve Zstd decoder through package exports --- tests/websocket-compression.test.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/websocket-compression.test.mjs b/tests/websocket-compression.test.mjs index e47f210..28e92bb 100644 --- a/tests/websocket-compression.test.mjs +++ b/tests/websocket-compression.test.mjs @@ -9,7 +9,7 @@ const compressedFixture = Uint8Array.from([ ]); test('bundled zstd decoder can decode Augmenta binary payloads synchronously after init', async () => { - const { ZSTDDecoder } = await import('../.pages-runtime/node_modules/zstddec/dist/zstddec.modern.js'); + const { ZSTDDecoder } = await import('zstddec'); const decoder = new ZSTDDecoder(); await decoder.init(); @@ -32,6 +32,6 @@ test('Three.js runtime requests compression and ships the decoder in the Pages a assert.match(connection, /useCompression:\s*true/); assert.match(connection, /decompressor,/); assert.match(connection, /import\('zstddec'\)/); - assert.match(index, /zstddec@0\.3\.1/); - assert.match(assemble, /zstddec\.modern\.js/); + assert.match(index, /zstddec@0\.3\.1\\/\\+esm/); + assert.match(assemble, /zstdEntrypointRelative/); }); From de6f0c1497210db9432a49392f0e5ae7fed8a267 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:41:47 +0200 Subject: [PATCH 13/17] test: fix Zstd import-map assertion --- tests/websocket-compression.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/websocket-compression.test.mjs b/tests/websocket-compression.test.mjs index 28e92bb..504787a 100644 --- a/tests/websocket-compression.test.mjs +++ b/tests/websocket-compression.test.mjs @@ -32,6 +32,6 @@ test('Three.js runtime requests compression and ships the decoder in the Pages a assert.match(connection, /useCompression:\s*true/); assert.match(connection, /decompressor,/); assert.match(connection, /import\('zstddec'\)/); - assert.match(index, /zstddec@0\.3\.1\\/\\+esm/); + assert.match(index, /zstddec@0\.3\.1\/\+esm/); assert.match(assemble, /zstdEntrypointRelative/); }); From 91b12b53bbad7cc85b856725550204c95ed108f4 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:44:20 +0200 Subject: [PATCH 14/17] test: load Zstd decoder from package export map --- tests/websocket-compression.test.mjs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/websocket-compression.test.mjs b/tests/websocket-compression.test.mjs index 504787a..fde997d 100644 --- a/tests/websocket-compression.test.mjs +++ b/tests/websocket-compression.test.mjs @@ -9,7 +9,20 @@ const compressedFixture = Uint8Array.from([ ]); test('bundled zstd decoder can decode Augmenta binary payloads synchronously after init', async () => { - const { ZSTDDecoder } = await import('zstddec'); + const zstdRoot = new URL('../.pages-runtime/node_modules/zstddec/', import.meta.url); + const packageJson = JSON.parse(readFileSync(new URL('package.json', zstdRoot), 'utf8')); + const packageExports = packageJson.exports; + const entrypoint = ( + typeof packageExports === 'string' + ? packageExports + : packageExports?.['.']?.default + ?? packageExports?.default + ?? packageJson.module + ?? packageJson.main + ); + assert.equal(typeof entrypoint, 'string'); + + const { ZSTDDecoder } = await import(new URL(entrypoint, zstdRoot).href); const decoder = new ZSTDDecoder(); await decoder.init(); From ca6824b060243d69817c54bd48f5f675658a5118 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:44:23 +0200 Subject: [PATCH 15/17] ci: keep runtime decoder isolated from app dependencies --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad67b99..9c4bf11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,6 @@ jobs: run: | mkdir -p node_modules ln -s ../vendor/AugmentaClientSDK-JS node_modules/augmenta-client-sdk - ln -s ../.pages-runtime/node_modules/zstddec node_modules/zstddec node --test tests/*.test.mjs - name: Assemble Pages artifact From 8e6537c03292edcabc0fec76c6f32a8448eeb857 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:44:26 +0200 Subject: [PATCH 16/17] ci: keep runtime decoder isolated from app dependencies --- .github/workflows/pages.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 8241503..abbfce0 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -56,7 +56,6 @@ jobs: run: | mkdir -p node_modules ln -s ../vendor/AugmentaClientSDK-JS node_modules/augmenta-client-sdk - ln -s ../.pages-runtime/node_modules/zstddec node_modules/zstddec node --test tests/*.test.mjs - name: Assemble static site From 41b372001d759b233143d8c91e0917661b3e32b4 Mon Sep 17 00:00:00 2001 From: David-Alexandre Chanel Date: Mon, 5 Oct 2026 19:45:36 +0200 Subject: [PATCH 17/17] test: use Zstd fixture with declared content size --- tests/websocket-compression.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/websocket-compression.test.mjs b/tests/websocket-compression.test.mjs index fde997d..aab059e 100644 --- a/tests/websocket-compression.test.mjs +++ b/tests/websocket-compression.test.mjs @@ -3,7 +3,7 @@ import { readFileSync } from 'node:fs'; import test from 'node:test'; const compressedFixture = Uint8Array.from([ - 40, 181, 47, 253, 4, 88, 241, 0, 0, 65, 117, 103, 109, 101, 110, 116, + 40, 181, 47, 253, 36, 30, 241, 0, 0, 65, 117, 103, 109, 101, 110, 116, 97, 32, 90, 115, 116, 100, 32, 105, 110, 116, 101, 103, 114, 97, 116, 105, 111, 110, 32, 116, 101, 115, 116, 185, 49, 3, 224 ]);