fix(test-vendor): append the zerolag global aliases

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.
This commit is contained in:
lior
2026-08-09 10:27:25 +03:00
parent be449e6e9e
commit 9fd856a918
+22 -1
View File
@@ -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/`);