jsgotty 1.1.8 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/gotty.js CHANGED
@@ -97,25 +97,30 @@ const DEFAULTS = {
97
97
  const compiledHelperPromise = import("./single-exe/compiled.js").catch(() => null);
98
98
  const assetsHelperPromise = import("./single-exe/assetsHelper.js").catch(() => null);
99
99
 
100
- let RESOURCE_ROOT = __dirname;
101
- let STATIC_ROOT = path.resolve(RESOURCE_ROOT, "./static");
102
- let DEFAULT_INDEX = path.join(STATIC_ROOT, "index.html");
103
- let DEFAULT_MANIFEST = path.join(STATIC_ROOT, "manifest.json");
104
- let DEFAULT_HELP = path.join(STATIC_ROOT, "help.md");
105
- let DEFAULT_README = path.resolve(RESOURCE_ROOT, "./README.md");
106
- let DEFAULT_README_EN = path.resolve(RESOURCE_ROOT, "./README.en.md");
107
- let helperAssetPath = null;
108
- let helperReadInternalAssetText = null;
109
- let helperReadInternalAssetBytes = null;
110
-
111
- function configureResourceRoot(compiledHelper) {
112
- RESOURCE_ROOT = compiledHelper?.REPO_ROOT
113
- STATIC_ROOT = path.resolve(RESOURCE_ROOT, "./static");
114
- DEFAULT_INDEX = path.join(STATIC_ROOT, "index.html");
115
- DEFAULT_MANIFEST = path.join(STATIC_ROOT, "manifest.json");
116
- DEFAULT_HELP = path.join(STATIC_ROOT, "help.md");
117
- DEFAULT_README = path.resolve(RESOURCE_ROOT, "./README.md");
118
- DEFAULT_README_EN = path.resolve(RESOURCE_ROOT, "./README.en.md");
100
+ // Assets are addressed by the package-relative keys package.json declares
101
+ // ("static/index.html", "README.md"). assetsHelper turns a key into bytes,
102
+ // wherever they live: the embedded store, the compiled binary's virtual
103
+ // filesystem, or a file on disk. Nothing here builds an absolute path.
104
+ let assets = null;
105
+
106
+ // Node runs this file without the ESM-only helper. Then there is nothing
107
+ // embedded either, so a key is just a path under the source checkout.
108
+ function assetText(key) {
109
+ return assets
110
+ ? assets.readAssetTextSync(key)
111
+ : fs.readFileSync(path.join(__dirname, key), "utf8");
112
+ }
113
+
114
+ function assetFilePath(key) {
115
+ return assets ? assets.assetDiskPath(key) : path.join(__dirname, key);
116
+ }
117
+
118
+ // URL-relative path -> asset key, or null when it escapes `static/`.
119
+ // Normalizing against "/" is what makes "../../etc/passwd" unreachable.
120
+ function staticAssetKey(relativePath) {
121
+ const rel = path.posix.normalize(`/${String(relativePath ?? "")}`).slice(1);
122
+ if (!rel || rel === ".." || rel.startsWith("../")) return null;
123
+ return `static/${rel}`;
119
124
  }
120
125
 
121
126
  let cliBootstrapPromise = null;
@@ -247,8 +252,8 @@ Experimental:
247
252
  --build-for <target> Build a Bun single-file executable for target`);
248
253
  }
249
254
 
250
- function printMarkdownFile(filePath) {
251
- const text = readTextFile(filePath);
255
+ function printMarkdownFile(key) {
256
+ const text = assetText(key);
252
257
  const markdownAnsi =
253
258
  typeof Bun !== "undefined" &&
254
259
  Bun &&
@@ -259,10 +264,6 @@ function printMarkdownFile(filePath) {
259
264
  console.log(markdownAnsi ? markdownAnsi(text, { hyperlinks: true }) : text);
260
265
  }
261
266
 
262
- function printWebHelp() {
263
- printMarkdownFile(DEFAULT_HELP);
264
- }
265
-
266
267
  function fatal(message, code = 1) {
267
268
  console.error(message);
268
269
  process.exit(code);
@@ -510,15 +511,15 @@ function parseArgs(argv) {
510
511
  process.exit(0);
511
512
  break;
512
513
  case "--help-web":
513
- printWebHelp();
514
+ printMarkdownFile("static/help.md");
514
515
  process.exit(0);
515
516
  break;
516
517
  case "--readme":
517
- printMarkdownFile(DEFAULT_README);
518
+ printMarkdownFile("README.md");
518
519
  process.exit(0);
519
520
  break;
520
521
  case "--readme-en":
521
- printMarkdownFile(DEFAULT_README_EN);
522
+ printMarkdownFile("README.en.md");
522
523
  process.exit(0);
523
524
  break;
524
525
  case "--address":
@@ -664,36 +665,6 @@ function previewBuffer(buffer, limit = 96) {
664
665
  });
665
666
  }
666
667
 
667
- function readTextFile(filePath) {
668
- const bundledText = helperReadInternalAssetText?.(internalAssetPathFor(filePath));
669
- if (bundledText == null) {
670
- return fs.readFileSync(filePath, "utf8");
671
- }
672
- return bundledText;
673
- }
674
-
675
- function internalAssetPathFor(filePath) {
676
- if (!helperAssetPath) {
677
- return filePath;
678
- }
679
-
680
- const normalizedPath = path.normalize(filePath);
681
- const staticRelativePath = path.relative(STATIC_ROOT, normalizedPath);
682
- if (staticRelativePath && !staticRelativePath.startsWith("..") && !path.isAbsolute(staticRelativePath)) {
683
- return helperAssetPath("static", staticRelativePath);
684
- }
685
-
686
- if (normalizedPath === DEFAULT_README) {
687
- return helperAssetPath("README.md");
688
- }
689
-
690
- if (normalizedPath === DEFAULT_README_EN) {
691
- return helperAssetPath("README.en.md");
692
- }
693
-
694
- return filePath;
695
- }
696
-
697
668
  function contentType(filePath) {
698
669
  const ext = path.extname(filePath).toLowerCase();
699
670
  switch (ext) {
@@ -829,6 +800,28 @@ function basicAuthAuthorized(req, credential) {
829
800
  return payload === credential;
830
801
  }
831
802
 
803
+ // Match gorilla/websocket's default policy used by upstream GoTTY: non-browser
804
+ // clients without Origin are accepted, while browser connections must come
805
+ // from the same host. --ws-origin intentionally replaces this default check.
806
+ function webSocketOriginAllowed(req, originMatcher = null) {
807
+ const origin = req.headers.origin;
808
+
809
+ if (originMatcher) {
810
+ return originMatcher.test(origin || "");
811
+ }
812
+ if (!origin) {
813
+ return true;
814
+ }
815
+
816
+ try {
817
+ const originHost = new URL(origin).host;
818
+ const requestHost = req.headers.host || "";
819
+ return originHost !== "" && originHost.toLowerCase() === requestHost.toLowerCase();
820
+ } catch {
821
+ return false;
822
+ }
823
+ }
824
+
832
825
  function sendBasicAuthRequired(res) {
833
826
  res.writeHead(401, {
834
827
  "WWW-Authenticate": 'Basic realm="GoTTY"',
@@ -1357,10 +1350,26 @@ class NodePtyBackend {
1357
1350
  constructor(options) {
1358
1351
  let nodePty;
1359
1352
  try {
1353
+ // Split so the bundler cannot resolve it. This branch is unreachable
1354
+ // in a compiled binary (Bun >= 1.3.14 always takes BunPtyBackend), so
1355
+ // a static require would only bake ~54 KB of dead JS into the exe —
1356
+ // and node-pty's own `.node` loading is dynamic anyway, so it would
1357
+ // still need the files on disk.
1360
1358
  let preventSingleExe="./lib/"
1361
1359
  nodePty = require(preventSingleExe+"node-pty");
1362
1360
  } catch (error) {
1363
- throw new Error("node-pty is required on Windows but is not installed");
1361
+ const detail = error && error.message ? `: ${error.message}` : "";
1362
+ throw new Error(
1363
+ globalThis.Bun
1364
+ ? "This build falls back to node-pty because Bun " + globalThis.Bun.version
1365
+ + " is older than 1.3.14, which is where the built-in ConPTY backend landed. "
1366
+ + "A compiled binary cannot load node-pty — it is deliberately left out of the "
1367
+ + "bundle — so rebuild with Bun 1.3.14 or newer, or run from a source checkout "
1368
+ + "with node-pty installed" + detail
1369
+ : "node-pty is required to run under Node on Windows, and it could not be loaded "
1370
+ + "from ./lib/node-pty. Run with Bun 1.3.14 or newer to use the built-in ConPTY "
1371
+ + "backend instead" + detail,
1372
+ );
1364
1373
  }
1365
1374
 
1366
1375
  const system32 = path.join(process.env.windir, 'System32');
@@ -2659,8 +2668,10 @@ function createServerRuntime(command, argv, options) {
2659
2668
  );
2660
2669
  const wsPath = `${basePath}ws`;
2661
2670
  const originMatcher = options.wsOrigin ? new RegExp(options.wsOrigin) : null;
2662
- const indexTemplate = readTextFile(options.index ? expandHome(options.index) : DEFAULT_INDEX);
2663
- const manifestTemplate = readTextFile(DEFAULT_MANIFEST);
2671
+ const indexTemplate = options.index
2672
+ ? fs.readFileSync(expandHome(options.index), "utf8")
2673
+ : assetText("static/index.html");
2674
+ const manifestTemplate = assetText("static/manifest.json");
2664
2675
  const activeSessions = new Set();
2665
2676
  const reconnectRegistry = new Map();
2666
2677
  let acceptedOnce = false;
@@ -2784,7 +2795,7 @@ function createServerRuntime(command, argv, options) {
2784
2795
  }
2785
2796
 
2786
2797
  if (relativePath === "help.md" || relativePath === "help") {
2787
- const markdown = readTextFile(DEFAULT_HELP);
2798
+ const markdown = assetText("static/help.md");
2788
2799
  const markdownToHtml = global.Bun?.markdown?.html;
2789
2800
  const renderHtml = relativePath === "help" && typeof markdownToHtml === "function";
2790
2801
  const body = renderHtml
@@ -2865,18 +2876,18 @@ function createServerRuntime(command, argv, options) {
2865
2876
  return;
2866
2877
  }
2867
2878
 
2868
- const assetPath = path.normalize(path.join(STATIC_ROOT, relativePath));
2869
- if (!assetPath.startsWith(STATIC_ROOT)) {
2879
+ const assetKey = staticAssetKey(relativePath);
2880
+ if (!assetKey) {
2870
2881
  res.writeHead(403);
2871
2882
  res.end("Forbidden");
2872
2883
  return;
2873
2884
  }
2874
2885
 
2875
- const bundledAsset = helperReadInternalAssetBytes?.(internalAssetPathFor(assetPath));
2886
+ const bundledAsset = assets?.readInternalAssetBytes(assetKey);
2876
2887
  if (bundledAsset != null) {
2877
2888
  const body = bundledAsset instanceof Uint8Array ? bundledAsset : new Uint8Array(bundledAsset);
2878
2889
  res.writeHead(200, {
2879
- "Content-Type": contentType(assetPath),
2890
+ "Content-Type": contentType(assetKey),
2880
2891
  "Content-Length": body.length,
2881
2892
  "Server": "GoTTY"
2882
2893
  });
@@ -2884,7 +2895,8 @@ function createServerRuntime(command, argv, options) {
2884
2895
  return;
2885
2896
  }
2886
2897
 
2887
- fs.stat(assetPath, (error, stats) => {
2898
+ const externalPath = assetFilePath(assetKey);
2899
+ fs.stat(externalPath, (error, stats) => {
2888
2900
  if (error || !stats.isFile()) {
2889
2901
  res.writeHead(404, { "Server": "GoTTY" });
2890
2902
  res.end("Not Found");
@@ -2892,11 +2904,11 @@ function createServerRuntime(command, argv, options) {
2892
2904
  }
2893
2905
 
2894
2906
  res.writeHead(200, {
2895
- "Content-Type": contentType(assetPath),
2907
+ "Content-Type": contentType(assetKey),
2896
2908
  "Content-Length": stats.size,
2897
2909
  "Server": "GoTTY"
2898
2910
  });
2899
- fs.createReadStream(assetPath).pipe(res);
2911
+ fs.createReadStream(externalPath).pipe(res);
2900
2912
  });
2901
2913
  };
2902
2914
 
@@ -2950,12 +2962,9 @@ function createServerRuntime(command, argv, options) {
2950
2962
  return;
2951
2963
  }
2952
2964
 
2953
- if (originMatcher) {
2954
- const origin = req.headers.origin || "";
2955
- if (!originMatcher.test(origin)) {
2956
- socket.destroy();
2957
- return;
2958
- }
2965
+ if (!webSocketOriginAllowed(req, originMatcher)) {
2966
+ socket.destroy();
2967
+ return;
2959
2968
  }
2960
2969
 
2961
2970
  if (options.once && acceptedOnce && !options.reconnect) {
@@ -3290,15 +3299,9 @@ function main() {
3290
3299
  async function bootstrap() {
3291
3300
  try {
3292
3301
  const compiledHelper = await compiledHelperPromise;
3293
- configureResourceRoot(compiledHelper);
3294
3302
  await compiledHelper?.buildEarlyExit?.(process.argv,'jsgt');
3295
3303
 
3296
- const assetsHelper = await assetsHelperPromise;
3297
- if (assetsHelper) {
3298
- helperAssetPath = assetsHelper.assetPath;
3299
- helperReadInternalAssetText = assetsHelper.readInternalAssetText;
3300
- helperReadInternalAssetBytes = assetsHelper.readInternalAssetBytes;
3301
- }
3304
+ assets = await assetsHelperPromise;
3302
3305
  await globalThis.assetsLoaderPromise;
3303
3306
  } catch (error) {
3304
3307
  console.error(String(error && error.stack ? error.stack : error));
@@ -3311,6 +3314,7 @@ async function bootstrap() {
3311
3314
 
3312
3315
  module.exports.CursorStateTracker = CursorStateTracker;
3313
3316
  module.exports.KittyGraphicsParser = KittyGraphicsParser;
3317
+ module.exports.webSocketOriginAllowed = webSocketOriginAllowed;
3314
3318
 
3315
3319
  if (require.main === module) {
3316
3320
  if (KITTY_TRACE) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgotty",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "Share your terminal as a web application: A JavaScript rewrite of GoTTY",
5
5
  "bin": {
6
6
  "jsgotty": "./gotty.js"
@@ -94,6 +94,8 @@ appear in `package.json`.
94
94
  | `listInternalAssetPaths(prefix?)` | every embedded path under `prefix` |
95
95
  | `listInternalAssetDirs(prefix?)` | the immediate child names under `prefix` |
96
96
  | `assetPath(...parts)` | joins parts into a key |
97
+ | `getAssetKey(path)` | the key as stored, namespace included |
98
+ | `assetDiskPath(path)` | where the disk fallback reads that key from |
97
99
  | `SELF` | this package's namespace, `assets/<name>@<version>` |
98
100
 
99
101
  The read functions are synchronous for embedded assets on both back ends.
@@ -35,11 +35,23 @@ function detectPrefix() {
35
35
  for (const key of keys) if (key.startsWith(SELF + "/")) return SELF;
36
36
  }
37
37
 
38
- if (IS_COMPILED && existsSync(join(import.meta.dir, SELF))) return SELF;
38
+ const base = bunfsBase();
39
+ if (base && existsSync(join(base, SELF))) return SELF;
39
40
 
40
41
  return "";
41
42
  }
42
43
 
44
+ // `--assets-external` means "ignore what is embedded". The tar loader
45
+ // signals it by setting the store to null; with no loader in the graph
46
+ // (the --asset back end) it stays undefined, so only null counts.
47
+ //
48
+ // Without this the bunfs branch below stayed live in tar builds too, and
49
+ // since it is rooted at the binary's own /$bunfs/root, an external run
50
+ // enumerated the executable and its embedded tar as if they were assets.
51
+ function externalAssets() {
52
+ return globalThis.internalAssets === null;
53
+ }
54
+
43
55
  // Whether THIS package has anything embedded. A bare store check was
44
56
  // true even for an empty one, which sent every caller down the internal
45
57
  // branch to find nothing and never try the disk fallback.
@@ -140,7 +152,7 @@ export async function buildHtmlBundleImageMap(
140
152
  // binary: in the source tree this file sits in single-exe/, which is
141
153
  // not the asset root.
142
154
  function bunfsBase() {
143
- return IS_COMPILED ? import.meta.dir : null;
155
+ return IS_COMPILED && !externalAssets() ? import.meta.dir : null;
144
156
  }
145
157
 
146
158
  // Store-space keys for every regular file under <base>/<sub>.
@@ -178,15 +190,37 @@ function walkBunfs(base, sub) {
178
190
 
179
191
  // Callers always speak package-relative keys. This is the one place
180
192
  // those become store keys, so the namespace stays invisible to them.
181
- function storeKey(path) {
193
+ // Exported because a caller rolling its own fallback needs the same
194
+ // answer — `--assets-extract` writes the archive under these keys.
195
+ export function getAssetKey(path) {
182
196
  const key = assetPath(path);
183
197
  const at = assetPrefix();
184
198
  return at ? (key ? `${at}/${key}` : at) : key;
185
199
  }
186
200
 
201
+ // Where the disk fallback looks for a package-relative key.
202
+ //
203
+ // A source checkout has the plain path. A compiled binary does not:
204
+ // `--assets-extract` writes the archive exactly as packed, namespace
205
+ // included, so the extracted `README.md` lands at
206
+ // `<exe dir>/assets/<name>@<version>/README.md` and the plain join
207
+ // misses it. `assetPrefix()` cannot answer this — with
208
+ // `--assets-external` there is no store to detect it from, which is
209
+ // precisely when the fallback runs — so try SELF and keep the plain
210
+ // path for archives that were packed flat.
211
+ export function assetDiskPath(path) {
212
+ const key = assetPath(path);
213
+ const plain = join(REPO_ROOT, key);
214
+
215
+ if (!IS_COMPILED) return plain;
216
+
217
+ const namespaced = join(REPO_ROOT, SELF, key);
218
+ return existsSync(namespaced) ? namespaced : plain;
219
+ }
220
+
187
221
  export function listInternalAssetPaths(prefix = "") {
188
222
  const at = assetPrefix();
189
- const wanted = storeKey(prefix);
223
+ const wanted = getAssetKey(prefix);
190
224
  const store = getAssetStore();
191
225
  const found = new Set();
192
226
 
@@ -227,7 +261,7 @@ export function listInternalAssetDirs(prefix = "") {
227
261
  }
228
262
 
229
263
  export function getInternalAsset(path) {
230
- const key = storeKey(path);
264
+ const key = getAssetKey(path);
231
265
 
232
266
  const store = getAssetStore();
233
267
  if (store) {
@@ -275,20 +309,38 @@ export async function readAssetText(path) {
275
309
  // TextDecoder drops a leading BOM, so the embedded path never returns
276
310
  // one; readFile keeps it. Strip it here or the same file reads
277
311
  // differently depending on whether it was embedded.
278
- return (await readFile(join(REPO_ROOT, path), "utf8")).replace(/^\uFEFF/, "");
312
+ return (await readFile(assetDiskPath(path), "utf8")).replace(/^\uFEFF/, "");
279
313
  }
280
314
 
281
315
  export async function readAssetBytes(path) {
282
316
  const internal = readInternalAssetBytes(path);
283
317
  if (internal) return internal;
284
318
 
285
- const buf = await readFile(join(REPO_ROOT, path));
319
+ const buf = await readFile(assetDiskPath(path));
286
320
 
287
321
  // Buffer is a Uint8Array, but hand back a plain one so callers cannot
288
322
  // come to depend on the Buffer-only methods.
289
323
  return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
290
324
  }
291
325
 
326
+ // Sync twins of readAssetText / readAssetBytes, for callers that cannot
327
+ // await — argument parsing, module init, CommonJS programs. Same lookup
328
+ // and same fallback; only the disk read differs (node:fs sync).
329
+ export function readAssetTextSync(path) {
330
+ const internal = readInternalAssetText(path);
331
+ if (internal != null) return internal;
332
+
333
+ return readFileSync(assetDiskPath(path), "utf8").replace(/^\uFEFF/, "");
334
+ }
335
+
336
+ export function readAssetBytesSync(path) {
337
+ const internal = readInternalAssetBytes(path);
338
+ if (internal) return internal;
339
+
340
+ const buf = readFileSync(assetDiskPath(path));
341
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
342
+ }
343
+
292
344
  export function internalAssetSource(path) {
293
345
  return {
294
346
  name: path.split("/").pop() ?? path,
@@ -0,0 +1,54 @@
1
+ const assert = require("node:assert/strict");
2
+ const test = require("node:test");
3
+ const { webSocketOriginAllowed } = require("../gotty.js");
4
+
5
+ function request(host, origin) {
6
+ return {
7
+ headers: {
8
+ host,
9
+ ...(origin === undefined ? {} : { origin }),
10
+ },
11
+ };
12
+ }
13
+
14
+ test("WebSocket permits clients without Origin", () => {
15
+ assert.equal(webSocketOriginAllowed(request("127.0.0.1:8080")), true);
16
+ });
17
+
18
+ test("WebSocket permits same-origin browsers", () => {
19
+ assert.equal(
20
+ webSocketOriginAllowed(request("127.0.0.1:8080", "http://127.0.0.1:8080")),
21
+ true,
22
+ );
23
+ assert.equal(
24
+ webSocketOriginAllowed(request("Example.COM:8080", "https://example.com:8080")),
25
+ true,
26
+ );
27
+ });
28
+
29
+ test("WebSocket rejects cross-origin and malformed browser origins", () => {
30
+ assert.equal(
31
+ webSocketOriginAllowed(request("127.0.0.1:8080", "https://attacker.example")),
32
+ false,
33
+ );
34
+ assert.equal(webSocketOriginAllowed(request("127.0.0.1:8080", "null")), false);
35
+ assert.equal(webSocketOriginAllowed(request("127.0.0.1:8080", "not a URL")), false);
36
+ });
37
+
38
+ test("--ws-origin regex replaces the same-origin default", () => {
39
+ const matcher = /^https:\/\/trusted\.example$/;
40
+ assert.equal(
41
+ webSocketOriginAllowed(
42
+ request("127.0.0.1:8080", "https://trusted.example"),
43
+ matcher,
44
+ ),
45
+ true,
46
+ );
47
+ assert.equal(
48
+ webSocketOriginAllowed(
49
+ request("127.0.0.1:8080", "http://127.0.0.1:8080"),
50
+ matcher,
51
+ ),
52
+ false,
53
+ );
54
+ });
package/zmodem-node.js CHANGED
@@ -10,12 +10,12 @@ let ttyModeDepth = 0;
10
10
  let rawOutputMode = false;
11
11
  const defaultDebugLogPath = path.join(os.tmpdir(), "zmodem", "zmodem.log");
12
12
  const debugLogPath = resolveDebugLogPath();
13
- const singleExeHelpersPromise = globalThis.Bun
14
- ? Promise.all([
15
- import("./single-exe/compiled.js").catch(() => null),
16
- import("./single-exe/assetsHelper.js").catch(() => null),
17
- ])
18
- : Promise.resolve([null, null]);
13
+ const ZMODEM_ASSET = "static/js/zmodem.js";
14
+ // ESM, and Bun-only in practice: under Node there is nothing embedded, so
15
+ // the source checkout's own copy is the only answer anyway.
16
+ const assetsHelperPromise = globalThis.Bun
17
+ ? import("./single-exe/assetsHelper.js").catch(() => null)
18
+ : Promise.resolve(null);
19
19
 
20
20
  async function loadZmodem() {
21
21
  if (cachedZmodem) {
@@ -23,12 +23,14 @@ async function loadZmodem() {
23
23
  }
24
24
 
25
25
  await globalThis.assetsLoaderPromise;
26
- const [compiledHelper, assetsHelper] = await singleExeHelpersPromise;
27
- const bundleAssetPath = assetsHelper?.assetPath?.("static", "js", "zmodem.js") ?? "static/js/zmodem.js";
28
- const source =
29
- assetsHelper?.readInternalAssetText?.(bundleAssetPath) ??
30
- fs.readFileSync(path.join(compiledHelper?.REPO_ROOT ?? __dirname, "static", "js", "zmodem.js"), "utf8");
31
- const bundlePath = path.join(compiledHelper?.REPO_ROOT ?? __dirname, "static", "js", "zmodem.js");
26
+ const assets = await assetsHelperPromise;
27
+ const source = assets
28
+ ? assets.readAssetTextSync(ZMODEM_ASSET)
29
+ : fs.readFileSync(path.join(__dirname, ZMODEM_ASSET), "utf8");
30
+ // Only a label for stack traces out of the vm context.
31
+ const bundlePath = assets
32
+ ? assets.assetDiskPath(ZMODEM_ASSET)
33
+ : path.join(__dirname, ZMODEM_ASSET);
32
34
  const quietConsole = {
33
35
  debug() {},
34
36
  log() {},