sandboxedjs 0.1.73 → 0.1.74

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.
@@ -1,4 +1,4 @@
1
- import { R as RuntimeVolume, d as VolumeStat, e as VolumeStats } from './contracts-CVgctitO.js';
1
+ import { R as RuntimeVolume, d as VolumeStat, e as VolumeStats } from './contracts-C2_dTgk3.js';
2
2
 
3
3
  type NodeKind = "file" | "directory" | "symlink";
4
4
  interface MemoryVolumeSnapshotEntry {
@@ -1,4 +1,4 @@
1
- import { R as RuntimeVolume, d as VolumeStat, e as VolumeStats } from './contracts-CVgctitO.cjs';
1
+ import { R as RuntimeVolume, d as VolumeStat, e as VolumeStats } from './contracts-C2_dTgk3.cjs';
2
2
 
3
3
  type NodeKind = "file" | "directory" | "symlink";
4
4
  interface MemoryVolumeSnapshotEntry {
@@ -1,6 +1,6 @@
1
- import { V as Vfs, C as Cred, a as VirtualTcpNetwork } from './contracts-CVgctitO.cjs';
2
- export { m as ROOT_CRED, v as makeCred } from './contracts-CVgctitO.cjs';
3
- export { M as MemoryVolume } from './memory-volume-DlMSAh-K.cjs';
1
+ import { V as Vfs, C as Cred, a as VirtualTcpNetwork } from './contracts-C2_dTgk3.cjs';
2
+ export { m as ROOT_CRED, v as makeCred } from './contracts-C2_dTgk3.cjs';
3
+ export { M as MemoryVolume } from './memory-volume-DqEWFo7t.cjs';
4
4
 
5
5
  /**
6
6
  * Open-file descriptions: the thing a descriptor points *at*.
@@ -1,6 +1,6 @@
1
- import { V as Vfs, C as Cred, a as VirtualTcpNetwork } from './contracts-CVgctitO.js';
2
- export { m as ROOT_CRED, v as makeCred } from './contracts-CVgctitO.js';
3
- export { M as MemoryVolume } from './memory-volume-CWuWScIs.js';
1
+ import { V as Vfs, C as Cred, a as VirtualTcpNetwork } from './contracts-C2_dTgk3.js';
2
+ export { m as ROOT_CRED, v as makeCred } from './contracts-C2_dTgk3.js';
3
+ export { M as MemoryVolume } from './memory-volume-CG56p660.js';
4
4
 
5
5
  /**
6
6
  * Open-file descriptions: the thing a descriptor points *at*.
@@ -12,7 +12,11 @@ var {
12
12
  createFsProxy,
13
13
  emnapiAsyncWorkPlugin,
14
14
  emnapiTSFNPlugin
15
- } = require2("@napi-rs/wasm-runtime");
15
+ } = await import(
16
+ /* @vite-ignore */
17
+ /* webpackIgnore: true */
18
+ options.runtimeModuleUrl
19
+ );
16
20
  var { memfsExported } = await import(
17
21
  /* @vite-ignore */
18
22
  /* webpackIgnore: true */
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tools/rolldown-wasi-worker.ts"],"names":["require"],"mappings":";;;;;AAiCA,IAAM,OAAA,GAAW,cAAc,EAAC;AAChC,IAAMA,QAAAA,GAAU,aAAA,CAAc,OAAA,CAAQ,aAAA,IAAiB,YAAY,GAAG,CAAA;AAEtE,IAAM;AAAA,EACJ,yBAAA;AAAA,EACA,cAAA;AAAA,EACA,IAAA;AAAA,EACA,aAAA;AAAA,EACA,qBAAA;AAAA,EACA;AACF,CAAA,GAAIA,SAAQ,uBAAuB,CAAA;AAInC,IAAM,EAAE,aAAA,EAAc,GAAI,MAAM;AAAA;AAAA;AAAA,EAAoD,OAAA,CAAQ;AAAA,CAAA;AAU5F,MAAA,CAAO,OAAO,UAAA,EAAY;AAAA,EACxB,IAAA,EAAM,UAAA;AAAA,EACN,OAAA,EAAAA,QAAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAc,IAAA,EAAc;AAC1B,IAAA,IAAI,MAAM,CAAA,EAAG,YAAA,CAAa,MAAM,MAAM,CAAC,CAAA,cAAA,EAAiB,IAAI,CAAA,CAAE,CAAA;AAAA,EAChE,CAAA;AAAA,EACA,YAAY,OAAA,EAAkB;AAC5B,IAAA,UAAA,EAAY,YAAY,OAAO,CAAA;AAAA,EACjC;AACF,CAAC,CAAA;AAED,IAAI,UAAA,EAAY;AACd,EAAA,UAAA,CAAW,EAAA,CAAG,SAAA,EAAW,CAAC,IAAA,KAAS;AACjC,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a,MAAA,GAAS,CAAA;AAAA,EACxB;AACF,CAAC,CAAA;AAEA,UAAA,CAAmB,SAAA,GAAY,CAAC,KAAA,KAAmB,OAAA,CAAQ,OAAO,KAAK,CAAA","file":"rolldown-wasi-worker.js","sourcesContent":["/**\n * A Rolldown WASI worker thread whose filesystem is the container's.\n *\n * Rolldown's npm package ships two of these. The browser one builds its\n * filesystem from an in-memory volume proxied back to the main thread; the\n * Node one calls `node:wasi` with `preopens: { \"/\": \"/\" }` and reads the real\n * disk. Neither is usable as-is here: the browser file wants browser worker\n * globals, and the Node file wants the host's filesystem — which is precisely\n * the thing a container must not hand to the code running inside it.\n *\n * So this is the crossing of the two: Node's worker plumbing around the\n * browser's filesystem. Every path Rolldown opens on this thread is forwarded\n * to the main thread and served out of the memory volume the container mirrors\n * itself into, so the bundler and the rest of the container see one filesystem.\n *\n * Bundled as its own entry point, because a worker is fetched as its own\n * module graph rather than through the main bundle.\n */\n\nimport { createRequire } from \"node:module\";\nimport { readFileSync } from \"node:fs\";\nimport { parentPort, workerData, Worker } from \"node:worker_threads\";\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Resolved against the binding's own location, not this file's.\n *\n * `@napi-rs/wasm-runtime` arrives as a dependency of the Rolldown binding,\n * which an installer is free to place anywhere — nested, hoisted, in a store\n * behind a symlink. Anchoring the lookup to the package that actually depends\n * on it is what keeps this working under npm, pnpm and Yarn alike.\n */\nconst options = (workerData ?? {}) as { runtimeAnchor?: string; fsModuleUrl?: string };\nconst require = createRequire(options.runtimeAnchor ?? import.meta.url);\n\nconst {\n instantiateNapiModuleSync,\n MessageHandler,\n WASI,\n createFsProxy,\n emnapiAsyncWorkPlugin,\n emnapiTSFNPlugin,\n} = require(\"@napi-rs/wasm-runtime\");\n/* Passed in as a resolved URL: the runtime publishes `./fs` to `import` only,\n * so it cannot be required, and resolving it from here would assume the\n * installer hoisted the package next to this worker. */\nconst { memfsExported } = await import(/* @vite-ignore */ /* webpackIgnore: true */ options.fsModuleUrl!);\n\n/**\n * The browser worker globals `MessageHandler` is written against.\n *\n * emnapi decides how to talk to a thread from the environment it finds, and\n * the handler itself is written for a browser worker: it is handed events and\n * replies with a bare `postMessage`. Node's port is bridged onto those names\n * rather than the handler being rewritten.\n */\nObject.assign(globalThis, {\n self: globalThis,\n require,\n Worker,\n importScripts(file: string) {\n (0, eval)(`${readFileSync(file, \"utf8\")}//# sourceURL=${file}`);\n },\n postMessage(message: unknown) {\n parentPort?.postMessage(message);\n },\n});\n\nif (parentPort) {\n parentPort.on(\"message\", (data) => {\n (globalThis as any).onmessage?.({ data });\n });\n}\n\nconst errorOutputs: unknown[][] = [];\n\nconst handler = new MessageHandler({\n onLoad({ wasmModule, wasmMemory }: { wasmModule: WebAssembly.Module; wasmMemory: WebAssembly.Memory }) {\n const wasi = new WASI({\n /* The proxy is the whole point: every syscall goes to the main thread,\n * which answers from the volume the container keeps in step. */\n fs: createFsProxy(memfsExported),\n preopens: { \"/\": \"/\" },\n print: (...args: unknown[]) => console.log(...args),\n printErr: (...args: unknown[]) => {\n console.error(...args);\n errorOutputs.push(args);\n },\n });\n\n return instantiateNapiModuleSync(wasmModule, {\n childThread: true,\n wasi,\n /* The wasm links a \"basic\" emnapi archive with no C implementations of\n * async work or threadsafe functions, so every thread has to bring the\n * JavaScript ones. */\n plugins: [emnapiAsyncWorkPlugin, emnapiTSFNPlugin],\n overwriteImports(importObject: any) {\n importObject.env = {\n ...importObject.env,\n ...importObject.napi,\n ...importObject.emnapi,\n memory: wasmMemory,\n };\n },\n });\n },\n onError(error: unknown) {\n (globalThis as any).postMessage({ type: \"error\", error, errorOutputs: [...errorOutputs] });\n errorOutputs.length = 0;\n },\n});\n\n(globalThis as any).onmessage = (event: unknown) => handler.handle(event);\n"]}
1
+ {"version":3,"sources":["../src/tools/rolldown-wasi-worker.ts"],"names":["require"],"mappings":";;;;;AAiCA,IAAM,OAAA,GAAW,cAAc,EAAC;AAChC,IAAMA,QAAAA,GAAU,aAAA,CA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CAAI,GAAG,IAAI,CAAA;AAAA,MAClD,QAAA,EAAU,IAAI,IAAA,KAAoB;AAChC,QAAA,OAAA,CAAQ,KAAA,CAAM,GAAG,IAAI,CAAA;AACrB,QAAA,YAAA,CAAa,KAAK,IAAI,CAAA;AAAA,MACxB;AAAA,KACD,CAAA;AAED,IAAA,OAAO,0BAA0B,UAAA,EAAY;AAAA,MAC3C,WAAA,EAAa,IAAA;AAAA,MACb,IAAA;AAAA;AAAA;AAAA;AAAA,MAIA,OAAA,EAAS,CAAC,qBAAA,EAAuB,gBAAgB,CAAA;AAAA,MACjD,iBAAiB,YAAA,EAAmB;AAClC,QAAA,YAAA,CAAa,GAAA,GAAM;AAAA,UACjB,GAAG,YAAA,CAAa,GAAA;AAAA,UAChB,GAAG,YAAA,CAAa,IAAA;AAAA,UAChB,GAAG,YAAA,CAAa,MAAA;AAAA,UAChB,MAAA,EAAQ;AAAA,SACV;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH,CAAA;AAAA,EACA,QAAQ,KAAA,EAAgB;AACtB,IAAC,UAAA,CAAmB,WAAA,CAAY,EAAE,IAAA,EAAM,OAAA,EAAS,KAAA,EAAO,YAAA,EAAc,CAAC,GAAG,YAAY,CAAA,EAAG,CAAA;AACzF,IAAA,YAAA,CAAa,MAAA,GAAS,CAAA;AAAA,EACxB;AACF,CAAC,CAAA;AAEA,UAAA,CAAmB,SAAA,GAAY,CAAC,KAAA,KAAmB,OAAA,CAAQ,OAAO,KAAK,CAAA","file":"rolldown-wasi-worker.js","sourcesContent":["/**\n * A Rolldown WASI worker thread whose filesystem is the container's.\n *\n * Rolldown's npm package ships two of these. The browser one builds its\n * filesystem from an in-memory volume proxied back to the main thread; the\n * Node one calls `node:wasi` with `preopens: { \"/\": \"/\" }` and reads the real\n * disk. Neither is usable as-is here: the browser file wants browser worker\n * globals, and the Node file wants the host's filesystem — which is precisely\n * the thing a container must not hand to the code running inside it.\n *\n * So this is the crossing of the two: Node's worker plumbing around the\n * browser's filesystem. Every path Rolldown opens on this thread is forwarded\n * to the main thread and served out of the memory volume the container mirrors\n * itself into, so the bundler and the rest of the container see one filesystem.\n *\n * Bundled as its own entry point, because a worker is fetched as its own\n * module graph rather than through the main bundle.\n */\n\nimport { createRequire } from \"node:module\";\nimport { readFileSync } from \"node:fs\";\nimport { parentPort, workerData, Worker } from \"node:worker_threads\";\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Resolved against the binding's own location, not this file's.\n *\n * `@napi-rs/wasm-runtime` arrives as a dependency of the Rolldown binding,\n * which an installer is free to place anywhere — nested, hoisted, in a store\n * behind a symlink. Anchoring the lookup to the package that actually depends\n * on it is what keeps this working under npm, pnpm and Yarn alike.\n */\nconst options = (workerData ?? {}) as { runtimeAnchor?: string; runtimeModuleUrl?: string; fsModuleUrl?: string };\nconst require = createRequire(options.runtimeAnchor ?? import.meta.url);\n\n/* Imported from the URL the main thread resolved, for the reason the main\n * thread imports it: `require` of the runtime reaches emnapi 2's ES module,\n * which a Node without require(esm) refuses. The same URL also keeps both\n * threads on one copy of the runtime. */\nconst {\n instantiateNapiModuleSync,\n MessageHandler,\n WASI,\n createFsProxy,\n emnapiAsyncWorkPlugin,\n emnapiTSFNPlugin,\n} = await import(/* @vite-ignore */ /* webpackIgnore: true */ options.runtimeModuleUrl!);\n/* Passed in as a resolved URL: the runtime publishes `./fs` to `import` only,\n * so it cannot be required, and resolving it from here would assume the\n * installer hoisted the package next to this worker. */\nconst { memfsExported } = await import(/* @vite-ignore */ /* webpackIgnore: true */ options.fsModuleUrl!);\n\n/**\n * The browser worker globals `MessageHandler` is written against.\n *\n * emnapi decides how to talk to a thread from the environment it finds, and\n * the handler itself is written for a browser worker: it is handed events and\n * replies with a bare `postMessage`. Node's port is bridged onto those names\n * rather than the handler being rewritten.\n */\nObject.assign(globalThis, {\n self: globalThis,\n require,\n Worker,\n importScripts(file: string) {\n (0, eval)(`${readFileSync(file, \"utf8\")}//# sourceURL=${file}`);\n },\n postMessage(message: unknown) {\n parentPort?.postMessage(message);\n },\n});\n\nif (parentPort) {\n parentPort.on(\"message\", (data) => {\n (globalThis as any).onmessage?.({ data });\n });\n}\n\nconst errorOutputs: unknown[][] = [];\n\nconst handler = new MessageHandler({\n onLoad({ wasmModule, wasmMemory }: { wasmModule: WebAssembly.Module; wasmMemory: WebAssembly.Memory }) {\n const wasi = new WASI({\n /* The proxy is the whole point: every syscall goes to the main thread,\n * which answers from the volume the container keeps in step. */\n fs: createFsProxy(memfsExported),\n preopens: { \"/\": \"/\" },\n print: (...args: unknown[]) => console.log(...args),\n printErr: (...args: unknown[]) => {\n console.error(...args);\n errorOutputs.push(args);\n },\n });\n\n return instantiateNapiModuleSync(wasmModule, {\n childThread: true,\n wasi,\n /* The wasm links a \"basic\" emnapi archive with no C implementations of\n * async work or threadsafe functions, so every thread has to bring the\n * JavaScript ones. */\n plugins: [emnapiAsyncWorkPlugin, emnapiTSFNPlugin],\n overwriteImports(importObject: any) {\n importObject.env = {\n ...importObject.env,\n ...importObject.napi,\n ...importObject.emnapi,\n memory: wasmMemory,\n };\n },\n });\n },\n onError(error: unknown) {\n (globalThis as any).postMessage({ type: \"error\", error, errorOutputs: [...errorOutputs] });\n errorOutputs.length = 0;\n },\n});\n\n(globalThis as any).onmessage = (event: unknown) => handler.handle(event);\n"]}