From 9fd856a918ce88bc1b001d0a77fff36cb5c9d101 Mon Sep 17 00:00:00 2001 From: lior Date: Sun, 9 Aug 2026 10:27:25 +0300 Subject: [PATCH] fix(test-vendor): append the zerolag global aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The zerolag bundle exports only `XtermZerolagInput`, but app.js constructs `new LocalEchoOverlay(terminal)` directly. scripts/build.mjs appends global aliases after esbuild (build.mjs:53-66); the first version of this script omitted that step. Without them initTerminal() throws `LocalEchoOverlay is not defined` at the line that builds the overlay — and because that is midway through the function, EVERY later step silently never runs, including the mobile touch handlers on #terminalContainer. The page still had a terminal, so the failure looked like a tap-routing bug rather than a boot error. Verified: boot errors none, and all four terminalContainer touch listeners (touchstart/touchmove/touchend/touchcancel) now register. --- scripts/prepare-test-vendor.mjs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/prepare-test-vendor.mjs b/scripts/prepare-test-vendor.mjs index 7527aca9..66717b31 100644 --- a/scripts/prepare-test-vendor.mjs +++ b/scripts/prepare-test-vendor.mjs @@ -19,7 +19,7 @@ * Idempotent: skips outputs already newer than their source. */ import { execFileSync } from 'node:child_process'; -import { copyFileSync, existsSync, mkdirSync, statSync } from 'node:fs'; +import { appendFileSync, copyFileSync, existsSync, mkdirSync, statSync } from 'node:fs'; import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -100,6 +100,27 @@ for (const asset of ASSETS) { ); } built += 1; + + // The zerolag bundle exports only `XtermZerolagInput`. app.js constructs + // `new LocalEchoOverlay(terminal)` directly, so scripts/build.mjs appends + // global aliases after esbuild — without them initTerminal() throws + // `LocalEchoOverlay is not defined` at the point it builds the overlay, and + // every later step (including the mobile touch handlers) silently never runs. + if (asset.out === 'xterm-zerolag-input.js') { + appendFileSync( + dest, + '\n// Global aliases for browser usage\n' + + 'if(typeof window!=="undefined"){' + + 'window.ZerolagInputAddon=XtermZerolagInput.ZerolagInputAddon;' + + 'window.LocalEchoOverlay=class extends XtermZerolagInput.ZerolagInputAddon{' + + 'constructor(terminal){' + + 'super({prompt:{type:"character",char:"\\u276f",offset:2}});' + + 'this.activate(terminal);' + + '}' + + '};' + + '}\n' + ); + } } console.log(`[test-vendor] ${built} built, ${skipped} up to date -> src/web/public/vendor/`);