@volter/tabnode 0.2.14-volter.88
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/LICENSE +22 -0
- package/README.md +78 -0
- package/THIRD-PARTY-NOTICES.md +12 -0
- package/dist/__sw__.js +526 -0
- package/dist/assets/runtime-worker-4MKaHFVb.js +75221 -0
- package/dist/assets/runtime-worker-4MKaHFVb.js.map +1 -0
- package/dist/code-transforms.d.ts +21 -0
- package/dist/code-transforms.d.ts.map +1 -0
- package/dist/config/cdn.d.ts +12 -0
- package/dist/config/cdn.d.ts.map +1 -0
- package/dist/create-runtime.d.ts +22 -0
- package/dist/create-runtime.d.ts.map +1 -0
- package/dist/host-globals.d.ts +62 -0
- package/dist/host-globals.d.ts.map +1 -0
- package/dist/index.cjs +36021 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +36020 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node-internals.d.ts +68 -0
- package/dist/node-internals.d.ts.map +1 -0
- package/dist/node-lib/binding/blob.d.ts +12 -0
- package/dist/node-lib/binding/blob.d.ts.map +1 -0
- package/dist/node-lib/binding/buffer.d.ts +144 -0
- package/dist/node-lib/binding/buffer.d.ts.map +1 -0
- package/dist/node-lib/binding/cares_wrap.d.ts +14 -0
- package/dist/node-lib/binding/cares_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/fds.d.ts +30 -0
- package/dist/node-lib/binding/fds.d.ts.map +1 -0
- package/dist/node-lib/binding/fs.d.ts +157 -0
- package/dist/node-lib/binding/fs.d.ts.map +1 -0
- package/dist/node-lib/binding/handles.d.ts +81 -0
- package/dist/node-lib/binding/handles.d.ts.map +1 -0
- package/dist/node-lib/binding/http_parser.d.ts +122 -0
- package/dist/node-lib/binding/http_parser.d.ts.map +1 -0
- package/dist/node-lib/binding/index.d.ts +3 -0
- package/dist/node-lib/binding/index.d.ts.map +1 -0
- package/dist/node-lib/binding/llhttp-wasm.d.ts +22 -0
- package/dist/node-lib/binding/llhttp-wasm.d.ts.map +1 -0
- package/dist/node-lib/binding/misc.d.ts +123 -0
- package/dist/node-lib/binding/misc.d.ts.map +1 -0
- package/dist/node-lib/binding/pipe_wrap.d.ts +84 -0
- package/dist/node-lib/binding/pipe_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/process_wrap.d.ts +173 -0
- package/dist/node-lib/binding/process_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/spawn_sync.d.ts +30 -0
- package/dist/node-lib/binding/spawn_sync.d.ts.map +1 -0
- package/dist/node-lib/binding/stream_wrap.d.ts +191 -0
- package/dist/node-lib/binding/stream_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/stubs.d.ts +23 -0
- package/dist/node-lib/binding/stubs.d.ts.map +1 -0
- package/dist/node-lib/binding/tcp_wrap.d.ts +98 -0
- package/dist/node-lib/binding/tcp_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/tty_wrap.d.ts +36 -0
- package/dist/node-lib/binding/tty_wrap.d.ts.map +1 -0
- package/dist/node-lib/binding/util.d.ts +126 -0
- package/dist/node-lib/binding/util.d.ts.map +1 -0
- package/dist/node-lib/binding/uv.d.ts +32 -0
- package/dist/node-lib/binding/uv.d.ts.map +1 -0
- package/dist/node-lib/binding/zlib-pako.d.ts +22 -0
- package/dist/node-lib/binding/zlib-pako.d.ts.map +1 -0
- package/dist/node-lib/binding/zlib.d.ts +38 -0
- package/dist/node-lib/binding/zlib.d.ts.map +1 -0
- package/dist/node-lib/buffer-module.d.ts +51 -0
- package/dist/node-lib/buffer-module.d.ts.map +1 -0
- package/dist/node-lib/child-process-module.d.ts +26 -0
- package/dist/node-lib/child-process-module.d.ts.map +1 -0
- package/dist/node-lib/events-module.d.ts +58 -0
- package/dist/node-lib/events-module.d.ts.map +1 -0
- package/dist/node-lib/fs-module.d.ts +5 -0
- package/dist/node-lib/fs-module.d.ts.map +1 -0
- package/dist/node-lib/http-bridge.d.ts +43 -0
- package/dist/node-lib/http-bridge.d.ts.map +1 -0
- package/dist/node-lib/http-module.d.ts +35 -0
- package/dist/node-lib/http-module.d.ts.map +1 -0
- package/dist/node-lib/internals/addresses.d.ts +40 -0
- package/dist/node-lib/internals/addresses.d.ts.map +1 -0
- package/dist/node-lib/internals/buffer-and-streams.d.ts +96 -0
- package/dist/node-lib/internals/buffer-and-streams.d.ts.map +1 -0
- package/dist/node-lib/internals/child-process.d.ts +27 -0
- package/dist/node-lib/internals/child-process.d.ts.map +1 -0
- package/dist/node-lib/internals/events-util.d.ts +83 -0
- package/dist/node-lib/internals/events-util.d.ts.map +1 -0
- package/dist/node-lib/internals/index.d.ts +2 -0
- package/dist/node-lib/internals/index.d.ts.map +1 -0
- package/dist/node-lib/internals/modules.d.ts +67 -0
- package/dist/node-lib/internals/modules.d.ts.map +1 -0
- package/dist/node-lib/internals/readline-access.d.ts +2 -0
- package/dist/node-lib/internals/readline-access.d.ts.map +1 -0
- package/dist/node-lib/internals/runtime.d.ts +150 -0
- package/dist/node-lib/internals/runtime.d.ts.map +1 -0
- package/dist/node-lib/internals/util.d.ts +33 -0
- package/dist/node-lib/internals/util.d.ts.map +1 -0
- package/dist/node-lib/lazy.d.ts +31 -0
- package/dist/node-lib/lazy.d.ts.map +1 -0
- package/dist/node-lib/load.d.ts +27 -0
- package/dist/node-lib/load.d.ts.map +1 -0
- package/dist/node-lib/module-hooks.d.ts +89 -0
- package/dist/node-lib/module-hooks.d.ts.map +1 -0
- package/dist/node-lib/net-module.d.ts +181 -0
- package/dist/node-lib/net-module.d.ts.map +1 -0
- package/dist/node-lib/node-versions.d.ts +27 -0
- package/dist/node-lib/node-versions.d.ts.map +1 -0
- package/dist/node-lib/public-modules.d.ts +2 -0
- package/dist/node-lib/public-modules.d.ts.map +1 -0
- package/dist/node-lib/require-hook.d.ts +15 -0
- package/dist/node-lib/require-hook.d.ts.map +1 -0
- package/dist/node-lib/small-modules.d.ts +16 -0
- package/dist/node-lib/small-modules.d.ts.map +1 -0
- package/dist/node-lib/sources.d.ts +4 -0
- package/dist/node-lib/sources.d.ts.map +1 -0
- package/dist/node-lib/stream-module.d.ts +77 -0
- package/dist/node-lib/stream-module.d.ts.map +1 -0
- package/dist/node-lib/timers.d.ts +19 -0
- package/dist/node-lib/timers.d.ts.map +1 -0
- package/dist/node-lib/util-module.d.ts +76 -0
- package/dist/node-lib/util-module.d.ts.map +1 -0
- package/dist/node-resolution.d.ts +50 -0
- package/dist/node-resolution.d.ts.map +1 -0
- package/dist/node-resolver.d.ts +7 -0
- package/dist/node-resolver.d.ts.map +1 -0
- package/dist/npm/index.d.ts +73 -0
- package/dist/npm/index.d.ts.map +1 -0
- package/dist/npm/registry.d.ts +111 -0
- package/dist/npm/registry.d.ts.map +1 -0
- package/dist/npm/resolver.d.ts +79 -0
- package/dist/npm/resolver.d.ts.map +1 -0
- package/dist/npm/tarball.d.ts +28 -0
- package/dist/npm/tarball.d.ts.map +1 -0
- package/dist/process-tokens.d.ts +77 -0
- package/dist/process-tokens.d.ts.map +1 -0
- package/dist/punycode-source.d.ts +3 -0
- package/dist/punycode-source.d.ts.map +1 -0
- package/dist/runtime-interface.d.ts +74 -0
- package/dist/runtime-interface.d.ts.map +1 -0
- package/dist/runtime.d.ts +144 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/server-bridge.d.ts +147 -0
- package/dist/server-bridge.d.ts.map +1 -0
- package/dist/shims/async_hooks.d.ts +50 -0
- package/dist/shims/async_hooks.d.ts.map +1 -0
- package/dist/shims/child_process.d.ts +104 -0
- package/dist/shims/child_process.d.ts.map +1 -0
- package/dist/shims/cluster.d.ts +52 -0
- package/dist/shims/cluster.d.ts.map +1 -0
- package/dist/shims/command-line.d.ts +43 -0
- package/dist/shims/command-line.d.ts.map +1 -0
- package/dist/shims/constants.d.ts +222 -0
- package/dist/shims/constants.d.ts.map +1 -0
- package/dist/shims/crypto-constants.d.ts +12 -0
- package/dist/shims/crypto-constants.d.ts.map +1 -0
- package/dist/shims/crypto.d.ts +144 -0
- package/dist/shims/crypto.d.ts.map +1 -0
- package/dist/shims/dgram.d.ts +34 -0
- package/dist/shims/dgram.d.ts.map +1 -0
- package/dist/shims/dns.d.ts +91 -0
- package/dist/shims/dns.d.ts.map +1 -0
- package/dist/shims/domain.d.ts +25 -0
- package/dist/shims/domain.d.ts.map +1 -0
- package/dist/shims/esbuild.d.ts +205 -0
- package/dist/shims/esbuild.d.ts.map +1 -0
- package/dist/shims/fs.d.ts +25 -0
- package/dist/shims/fs.d.ts.map +1 -0
- package/dist/shims/http2.d.ts +81 -0
- package/dist/shims/http2.d.ts.map +1 -0
- package/dist/shims/inspector.d.ts +25 -0
- package/dist/shims/inspector.d.ts.map +1 -0
- package/dist/shims/module.d.ts +22 -0
- package/dist/shims/module.d.ts.map +1 -0
- package/dist/shims/os.d.ts +159 -0
- package/dist/shims/os.d.ts.map +1 -0
- package/dist/shims/path.d.ts +52 -0
- package/dist/shims/path.d.ts.map +1 -0
- package/dist/shims/perf_hooks.d.ts +50 -0
- package/dist/shims/perf_hooks.d.ts.map +1 -0
- package/dist/shims/process.d.ts +226 -0
- package/dist/shims/process.d.ts.map +1 -0
- package/dist/shims/rollup.d.ts +71 -0
- package/dist/shims/rollup.d.ts.map +1 -0
- package/dist/shims/string_decoder.d.ts +41 -0
- package/dist/shims/string_decoder.d.ts.map +1 -0
- package/dist/shims/sync-child.d.ts +64 -0
- package/dist/shims/sync-child.d.ts.map +1 -0
- package/dist/shims/tls.d.ts +53 -0
- package/dist/shims/tls.d.ts.map +1 -0
- package/dist/shims/url.d.ts +84 -0
- package/dist/shims/url.d.ts.map +1 -0
- package/dist/shims/v8.d.ts +73 -0
- package/dist/shims/v8.d.ts.map +1 -0
- package/dist/shims/vfs-adapter.d.ts +126 -0
- package/dist/shims/vfs-adapter.d.ts.map +1 -0
- package/dist/shims/vm.d.ts +52 -0
- package/dist/shims/vm.d.ts.map +1 -0
- package/dist/shims/wasi.d.ts +78 -0
- package/dist/shims/wasi.d.ts.map +1 -0
- package/dist/shims/worker_threads.d.ts +66 -0
- package/dist/shims/worker_threads.d.ts.map +1 -0
- package/dist/shims/zlib-constants.d.ts +66 -0
- package/dist/shims/zlib-constants.d.ts.map +1 -0
- package/dist/shims/zlib.d.ts +102 -0
- package/dist/shims/zlib.d.ts.map +1 -0
- package/dist/transform.d.ts +24 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/types/package-json.d.ts +18 -0
- package/dist/types/package-json.d.ts.map +1 -0
- package/dist/utils/binary-encoding.d.ts +13 -0
- package/dist/utils/binary-encoding.d.ts.map +1 -0
- package/dist/utils/glob.d.ts +19 -0
- package/dist/utils/glob.d.ts.map +1 -0
- package/dist/utils/hash.d.ts +6 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/virtual-fs.d.ts +259 -0
- package/dist/virtual-fs.d.ts.map +1 -0
- package/dist/vite-plugin.cjs +50 -0
- package/dist/vite-plugin.cjs.map +1 -0
- package/dist/vite-plugin.d.ts +36 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.mjs +31 -0
- package/dist/vite-plugin.mjs.map +1 -0
- package/dist/worker/runtime-worker.d.ts +8 -0
- package/dist/worker/runtime-worker.d.ts.map +1 -0
- package/dist/worker-runtime.d.ts +50 -0
- package/dist/worker-runtime.d.ts.map +1 -0
- package/package.json +88 -0
- package/src/code-transforms.ts +560 -0
- package/src/config/cdn.ts +13 -0
- package/src/create-runtime.ts +89 -0
- package/src/host-globals.ts +121 -0
- package/src/index.ts +235 -0
- package/src/node-internals.ts +283 -0
- package/src/node-lib/LICENSE +47 -0
- package/src/node-lib/_http_agent.js +547 -0
- package/src/node-lib/_http_client.js +996 -0
- package/src/node-lib/_http_common.js +269 -0
- package/src/node-lib/_http_incoming.js +453 -0
- package/src/node-lib/_http_outgoing.js +1262 -0
- package/src/node-lib/_http_server.js +1230 -0
- package/src/node-lib/assert/strict.js +3 -0
- package/src/node-lib/assert.js +844 -0
- package/src/node-lib/binding/blob.ts +35 -0
- package/src/node-lib/binding/buffer.ts +465 -0
- package/src/node-lib/binding/cares_wrap.ts +57 -0
- package/src/node-lib/binding/fds.ts +80 -0
- package/src/node-lib/binding/fs.ts +857 -0
- package/src/node-lib/binding/handles.ts +187 -0
- package/src/node-lib/binding/http_parser.ts +536 -0
- package/src/node-lib/binding/index.ts +77 -0
- package/src/node-lib/binding/llhttp-wasm.ts +670 -0
- package/src/node-lib/binding/misc.ts +252 -0
- package/src/node-lib/binding/pipe_wrap.ts +166 -0
- package/src/node-lib/binding/process_wrap.ts +371 -0
- package/src/node-lib/binding/spawn_sync.ts +141 -0
- package/src/node-lib/binding/stream_wrap.ts +413 -0
- package/src/node-lib/binding/stubs.ts +19 -0
- package/src/node-lib/binding/tcp_wrap.ts +254 -0
- package/src/node-lib/binding/tty_wrap.ts +56 -0
- package/src/node-lib/binding/util.ts +274 -0
- package/src/node-lib/binding/uv.ts +102 -0
- package/src/node-lib/binding/zlib-pako.ts +50 -0
- package/src/node-lib/binding/zlib.ts +259 -0
- package/src/node-lib/buffer-module.ts +70 -0
- package/src/node-lib/buffer.js +1373 -0
- package/src/node-lib/child-process-module.ts +58 -0
- package/src/node-lib/child_process.js +1046 -0
- package/src/node-lib/constants.js +41 -0
- package/src/node-lib/diagnostics_channel.js +438 -0
- package/src/node-lib/events-module.ts +80 -0
- package/src/node-lib/events.js +1223 -0
- package/src/node-lib/fs-module.ts +43 -0
- package/src/node-lib/fs.js +3377 -0
- package/src/node-lib/http-bridge.ts +299 -0
- package/src/node-lib/http-module.ts +53 -0
- package/src/node-lib/http.js +198 -0
- package/src/node-lib/https.js +429 -0
- package/src/node-lib/internal/assert/assertion_error.js +417 -0
- package/src/node-lib/internal/assert/calltracker.js +153 -0
- package/src/node-lib/internal/assert/myers_diff.js +177 -0
- package/src/node-lib/internal/assert/utils.js +278 -0
- package/src/node-lib/internal/buffer.js +1120 -0
- package/src/node-lib/internal/child_process/serialization.js +169 -0
- package/src/node-lib/internal/child_process.js +1135 -0
- package/src/node-lib/internal/constants.js +56 -0
- package/src/node-lib/internal/deps/minimatch/index.js +1628 -0
- package/src/node-lib/internal/errors.js +1912 -0
- package/src/node-lib/internal/events/abort_listener.js +54 -0
- package/src/node-lib/internal/events/symbols.js +11 -0
- package/src/node-lib/internal/fixed_queue.js +119 -0
- package/src/node-lib/internal/freelist.js +30 -0
- package/src/node-lib/internal/fs/cp/cp-sync.js +242 -0
- package/src/node-lib/internal/fs/cp/cp.js +382 -0
- package/src/node-lib/internal/fs/dir.js +369 -0
- package/src/node-lib/internal/fs/glob.js +763 -0
- package/src/node-lib/internal/fs/promises.js +1312 -0
- package/src/node-lib/internal/fs/read/context.js +129 -0
- package/src/node-lib/internal/fs/recursive_watch.js +275 -0
- package/src/node-lib/internal/fs/rimraf.js +311 -0
- package/src/node-lib/internal/fs/streams.js +571 -0
- package/src/node-lib/internal/fs/sync_write_stream.js +49 -0
- package/src/node-lib/internal/fs/utils.js +987 -0
- package/src/node-lib/internal/fs/watchers.js +418 -0
- package/src/node-lib/internal/http.js +62 -0
- package/src/node-lib/internal/mime.js +389 -0
- package/src/node-lib/internal/modules/customization_hooks.js +406 -0
- package/src/node-lib/internal/net.js +95 -0
- package/src/node-lib/internal/querystring.js +119 -0
- package/src/node-lib/internal/readline/callbacks.js +132 -0
- package/src/node-lib/internal/readline/emitKeypressEvents.js +99 -0
- package/src/node-lib/internal/readline/interface.js +1418 -0
- package/src/node-lib/internal/readline/promises.js +144 -0
- package/src/node-lib/internal/readline/utils.js +405 -0
- package/src/node-lib/internal/socket_list.js +108 -0
- package/src/node-lib/internal/stream_base_commons.js +280 -0
- package/src/node-lib/internal/streams/add-abort-signal.js +60 -0
- package/src/node-lib/internal/streams/compose.js +257 -0
- package/src/node-lib/internal/streams/destroy.js +361 -0
- package/src/node-lib/internal/streams/duplex.js +203 -0
- package/src/node-lib/internal/streams/duplexify.js +379 -0
- package/src/node-lib/internal/streams/duplexpair.js +62 -0
- package/src/node-lib/internal/streams/end-of-stream.js +331 -0
- package/src/node-lib/internal/streams/from.js +208 -0
- package/src/node-lib/internal/streams/lazy_transform.js +57 -0
- package/src/node-lib/internal/streams/legacy.js +125 -0
- package/src/node-lib/internal/streams/operators.js +436 -0
- package/src/node-lib/internal/streams/passthrough.js +47 -0
- package/src/node-lib/internal/streams/pipeline.js +465 -0
- package/src/node-lib/internal/streams/readable.js +1762 -0
- package/src/node-lib/internal/streams/state.js +51 -0
- package/src/node-lib/internal/streams/transform.js +204 -0
- package/src/node-lib/internal/streams/utils.js +363 -0
- package/src/node-lib/internal/streams/writable.js +1163 -0
- package/src/node-lib/internal/tty.js +260 -0
- package/src/node-lib/internal/util/colors.js +40 -0
- package/src/node-lib/internal/util/comparisons.js +1028 -0
- package/src/node-lib/internal/util/debuglog.js +524 -0
- package/src/node-lib/internal/util/inspect.js +2535 -0
- package/src/node-lib/internal/util/parse_args/parse_args.js +412 -0
- package/src/node-lib/internal/util/parse_args/utils.js +197 -0
- package/src/node-lib/internal/util.js +1003 -0
- package/src/node-lib/internal/validators.js +654 -0
- package/src/node-lib/internals/addresses.ts +159 -0
- package/src/node-lib/internals/buffer-and-streams.ts +224 -0
- package/src/node-lib/internals/child-process.ts +64 -0
- package/src/node-lib/internals/events-util.ts +105 -0
- package/src/node-lib/internals/index.ts +66 -0
- package/src/node-lib/internals/modules.ts +117 -0
- package/src/node-lib/internals/readline-access.ts +16 -0
- package/src/node-lib/internals/runtime.ts +277 -0
- package/src/node-lib/internals/util.ts +98 -0
- package/src/node-lib/lazy.ts +158 -0
- package/src/node-lib/load.ts +390 -0
- package/src/node-lib/module-hooks.ts +281 -0
- package/src/node-lib/net-module.ts +248 -0
- package/src/node-lib/net.js +2540 -0
- package/src/node-lib/node-versions.ts +34 -0
- package/src/node-lib/os.js +356 -0
- package/src/node-lib/path.js +1694 -0
- package/src/node-lib/primordials.js +743 -0
- package/src/node-lib/public-modules.ts +109 -0
- package/src/node-lib/punycode.js +455 -0
- package/src/node-lib/querystring.js +484 -0
- package/src/node-lib/readline/promises.js +73 -0
- package/src/node-lib/readline.js +523 -0
- package/src/node-lib/require-hook.ts +27 -0
- package/src/node-lib/small-modules.ts +35 -0
- package/src/node-lib/sources.ts +200 -0
- package/src/node-lib/stream/promises.js +44 -0
- package/src/node-lib/stream-module.ts +101 -0
- package/src/node-lib/stream.js +152 -0
- package/src/node-lib/timers.ts +33 -0
- package/src/node-lib/tty.js +168 -0
- package/src/node-lib/util-module.ts +104 -0
- package/src/node-lib/util.js +689 -0
- package/src/node-lib/wasi.js +179 -0
- package/src/node-lib/zlib.js +1036 -0
- package/src/node-resolution.ts +241 -0
- package/src/node-resolver.ts +33 -0
- package/src/npm/index.ts +425 -0
- package/src/npm/registry.ts +235 -0
- package/src/npm/resolver.ts +589 -0
- package/src/npm/tarball.ts +246 -0
- package/src/process-tokens.ts +156 -0
- package/src/punycode-source.ts +6 -0
- package/src/runtime-interface.ts +85 -0
- package/src/runtime.ts +3073 -0
- package/src/server-bridge.ts +971 -0
- package/src/shims/async_hooks.ts +181 -0
- package/src/shims/child_process.ts +1591 -0
- package/src/shims/cluster.ts +79 -0
- package/src/shims/command-line.ts +79 -0
- package/src/shims/constants.ts +68 -0
- package/src/shims/crypto-constants.ts +11 -0
- package/src/shims/crypto.ts +1061 -0
- package/src/shims/dgram.ts +47 -0
- package/src/shims/dns.ts +185 -0
- package/src/shims/domain.ts +58 -0
- package/src/shims/esbuild.ts +1638 -0
- package/src/shims/fs.ts +82 -0
- package/src/shims/http2.ts +96 -0
- package/src/shims/inspector.ts +30 -0
- package/src/shims/module.ts +86 -0
- package/src/shims/os.ts +195 -0
- package/src/shims/path.ts +246 -0
- package/src/shims/perf_hooks.ts +92 -0
- package/src/shims/process.ts +804 -0
- package/src/shims/rollup.ts +149 -0
- package/src/shims/string_decoder.ts +396 -0
- package/src/shims/sync-child.ts +469 -0
- package/src/shims/tls.ts +94 -0
- package/src/shims/url.ts +217 -0
- package/src/shims/v8.ts +113 -0
- package/src/shims/vfs-adapter.ts +408 -0
- package/src/shims/vm.ts +132 -0
- package/src/shims/wasi.ts +1440 -0
- package/src/shims/worker_threads.ts +114 -0
- package/src/shims/zlib-constants.ts +65 -0
- package/src/shims/zlib.ts +228 -0
- package/src/transform.ts +324 -0
- package/src/types/external.d.ts +55 -0
- package/src/types/package-json.ts +17 -0
- package/src/types/pako-zlib.d.ts +30 -0
- package/src/types/sha.js.d.ts +14 -0
- package/src/utils/binary-encoding.ts +43 -0
- package/src/utils/glob.ts +54 -0
- package/src/utils/hash.ts +12 -0
- package/src/virtual-fs.ts +1048 -0
- package/src/vite-plugin.ts +76 -0
- package/src/worker/runtime-worker.ts +128 -0
- package/src/worker-runtime.ts +145 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tarball Extractor
|
|
3
|
+
* Downloads and extracts npm package tarballs into the virtual file system
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import pako from 'pako';
|
|
7
|
+
import { VirtualFS } from '../virtual-fs';
|
|
8
|
+
import * as path from '../shims/path';
|
|
9
|
+
|
|
10
|
+
export interface ExtractOptions {
|
|
11
|
+
stripComponents?: number; // Number of leading path components to strip (default: 1 for npm's "package/" prefix)
|
|
12
|
+
filter?: (path: string) => boolean;
|
|
13
|
+
onProgress?: (message: string) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface TarEntry {
|
|
17
|
+
name: string;
|
|
18
|
+
type: 'file' | 'directory' | 'symlink' | 'unknown';
|
|
19
|
+
size: number;
|
|
20
|
+
mode: number;
|
|
21
|
+
content?: Uint8Array;
|
|
22
|
+
linkTarget?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Parse a tar archive from raw bytes
|
|
27
|
+
*/
|
|
28
|
+
function* parseTar(data: Uint8Array): Generator<TarEntry> {
|
|
29
|
+
const decoder = new TextDecoder();
|
|
30
|
+
let offset = 0;
|
|
31
|
+
// The name a pax extended header or a GNU long-name entry gave the entry
|
|
32
|
+
// that follows it.
|
|
33
|
+
let __nextName: string | undefined;
|
|
34
|
+
|
|
35
|
+
while (offset < data.length - 512) {
|
|
36
|
+
// Read 512-byte header
|
|
37
|
+
const header = data.slice(offset, offset + 512);
|
|
38
|
+
offset += 512;
|
|
39
|
+
|
|
40
|
+
// Check for end of archive (two zero blocks)
|
|
41
|
+
if (header.every((b) => b === 0)) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Parse header fields
|
|
46
|
+
const name = parseString(header, 0, 100);
|
|
47
|
+
const mode = parseOctal(header, 100, 8);
|
|
48
|
+
const size = parseOctal(header, 124, 12);
|
|
49
|
+
const typeFlag = String.fromCharCode(header[156]);
|
|
50
|
+
const linkName = parseString(header, 157, 100);
|
|
51
|
+
const prefix = parseString(header, 345, 155);
|
|
52
|
+
|
|
53
|
+
// Skip empty entries
|
|
54
|
+
if (!name) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Combine prefix and name for long paths
|
|
59
|
+
const fullName = __nextName !== void 0 ? __nextName : prefix ? `${prefix}/${name}` : name;
|
|
60
|
+
__nextName = void 0;
|
|
61
|
+
|
|
62
|
+
// Determine entry type
|
|
63
|
+
let type: TarEntry['type'];
|
|
64
|
+
switch (typeFlag) {
|
|
65
|
+
case '0':
|
|
66
|
+
case '\0':
|
|
67
|
+
case '':
|
|
68
|
+
type = 'file';
|
|
69
|
+
break;
|
|
70
|
+
case '5':
|
|
71
|
+
type = 'directory';
|
|
72
|
+
break;
|
|
73
|
+
case '1':
|
|
74
|
+
case '2':
|
|
75
|
+
type = 'symlink';
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
type = 'unknown';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Read file content (empty files get an empty Uint8Array)
|
|
82
|
+
let content: Uint8Array | undefined;
|
|
83
|
+
// Every entry's payload is skipped, not a file entry's only: an entry of
|
|
84
|
+
// another kind that carries one — the pax extended header npm's older
|
|
85
|
+
// tarballs put before every file — left its payload in place and the next
|
|
86
|
+
// header was read out of it. serve-favicon 2.5.0 came out of the store as
|
|
87
|
+
// files named by lines of its README and no package.json.
|
|
88
|
+
const __payload = size > 0 ? Math.ceil(size / 512) * 512 : 0;
|
|
89
|
+
if (typeFlag === "x" || typeFlag === "L") {
|
|
90
|
+
const __text = new TextDecoder().decode(data.slice(offset, offset + size));
|
|
91
|
+
offset += __payload;
|
|
92
|
+
if (typeFlag === "L") {
|
|
93
|
+
__nextName = __text.replace(/\0+$/, "");
|
|
94
|
+
} else {
|
|
95
|
+
for (const __line of __text.split("\n")) {
|
|
96
|
+
const __match = /^\d+ path=(.*)$/.exec(__line);
|
|
97
|
+
if (__match) __nextName = __match[1];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (type === 'file') {
|
|
103
|
+
content = size > 0 ? data.slice(offset, offset + size) : new Uint8Array(0);
|
|
104
|
+
}
|
|
105
|
+
offset += __payload;
|
|
106
|
+
|
|
107
|
+
yield {
|
|
108
|
+
name: fullName,
|
|
109
|
+
type,
|
|
110
|
+
size,
|
|
111
|
+
mode,
|
|
112
|
+
content,
|
|
113
|
+
linkTarget: type === 'symlink' ? linkName : undefined,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Parse a null-terminated string from tar header
|
|
120
|
+
*/
|
|
121
|
+
function parseString(data: Uint8Array, offset: number, length: number): string {
|
|
122
|
+
const bytes = data.slice(offset, offset + length);
|
|
123
|
+
const nullIndex = bytes.indexOf(0);
|
|
124
|
+
const actualBytes = nullIndex >= 0 ? bytes.slice(0, nullIndex) : bytes;
|
|
125
|
+
return new TextDecoder().decode(actualBytes);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Parse an octal number from tar header
|
|
130
|
+
*/
|
|
131
|
+
function parseOctal(data: Uint8Array, offset: number, length: number): number {
|
|
132
|
+
const str = parseString(data, offset, length).trim();
|
|
133
|
+
return parseInt(str, 8) || 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Decompress gzipped data
|
|
138
|
+
*/
|
|
139
|
+
export function decompress(data: ArrayBuffer | Uint8Array): Uint8Array {
|
|
140
|
+
const input = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
141
|
+
return pako.inflate(input);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Extract a tarball to the virtual file system
|
|
146
|
+
*/
|
|
147
|
+
export function extractTarball(
|
|
148
|
+
tarballData: ArrayBuffer | Uint8Array,
|
|
149
|
+
vfs: VirtualFS,
|
|
150
|
+
destPath: string,
|
|
151
|
+
options: ExtractOptions = {}
|
|
152
|
+
): string[] {
|
|
153
|
+
const { stripComponents = 1, filter, onProgress } = options;
|
|
154
|
+
|
|
155
|
+
// Decompress gzip
|
|
156
|
+
onProgress?.('Decompressing...');
|
|
157
|
+
const tarData = decompress(tarballData);
|
|
158
|
+
|
|
159
|
+
// Parse and extract tar entries
|
|
160
|
+
const extractedFiles: string[] = [];
|
|
161
|
+
|
|
162
|
+
for (const entry of parseTar(tarData)) {
|
|
163
|
+
// Skip non-file/directory entries for now
|
|
164
|
+
if (entry.type !== 'file' && entry.type !== 'directory') {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Strip leading path components (npm packages have "package/" prefix)
|
|
169
|
+
let entryPath = entry.name;
|
|
170
|
+
if (stripComponents > 0) {
|
|
171
|
+
const parts = entryPath.split('/').filter(Boolean);
|
|
172
|
+
if (parts.length <= stripComponents) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
entryPath = parts.slice(stripComponents).join('/');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Apply filter if provided
|
|
179
|
+
if (filter && !filter(entryPath)) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Build destination path
|
|
184
|
+
const fullPath = path.join(destPath, entryPath);
|
|
185
|
+
|
|
186
|
+
if (entry.type === 'directory') {
|
|
187
|
+
vfs.mkdirSync(fullPath, { recursive: true });
|
|
188
|
+
} else if (entry.type === 'file' && entry.content) {
|
|
189
|
+
// Ensure parent directory exists
|
|
190
|
+
const parentDir = path.dirname(fullPath);
|
|
191
|
+
vfs.mkdirSync(parentDir, { recursive: true });
|
|
192
|
+
|
|
193
|
+
// Write file
|
|
194
|
+
vfs.writeFileSync(fullPath, entry.content);
|
|
195
|
+
extractedFiles.push(fullPath);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
onProgress?.(`Extracted ${extractedFiles.length} files`);
|
|
200
|
+
|
|
201
|
+
return extractedFiles;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Download and extract a tarball from URL
|
|
206
|
+
*/
|
|
207
|
+
// The store's hook gets the engine's own extractor for a package it must fetch.
|
|
208
|
+
(globalThis as Record<symbol, unknown>)[Symbol.for("@volter/browser-runtime/package-extract")] = extractTarball;
|
|
209
|
+
|
|
210
|
+
/** Run `work` over `items` with `size` of them in flight, each lane taking the next. */
|
|
211
|
+
export async function __browserRuntimeInstallPool<T>(items: T[], size: number, work: (item: T) => Promise<void>): Promise<void> {
|
|
212
|
+
let next = 0;
|
|
213
|
+
await Promise.all(Array.from({ length: Math.min(size, items.length) }, async () => {
|
|
214
|
+
for (;;) {
|
|
215
|
+
const index = next++;
|
|
216
|
+
if (index >= items.length) return;
|
|
217
|
+
await work(items[index]);
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export async function downloadAndExtract(
|
|
223
|
+
url: string,
|
|
224
|
+
vfs: VirtualFS,
|
|
225
|
+
destPath: string,
|
|
226
|
+
options: ExtractOptions = {}
|
|
227
|
+
): Promise<string[]> {
|
|
228
|
+
const { onProgress } = options;
|
|
229
|
+
|
|
230
|
+
onProgress?.(`Downloading ${url}...`);
|
|
231
|
+
|
|
232
|
+
const response = await fetch(url);
|
|
233
|
+
if (!response.ok) {
|
|
234
|
+
throw new Error(`Failed to download tarball: ${response.status}`);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const data = await response.arrayBuffer();
|
|
238
|
+
|
|
239
|
+
return extractTarball(data, vfs, destPath, options);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export default {
|
|
243
|
+
decompress,
|
|
244
|
+
extractTarball,
|
|
245
|
+
downloadAndExtract,
|
|
246
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A run the embedding host has named, and the registry the container answers
|
|
3
|
+
* about it from.
|
|
4
|
+
*
|
|
5
|
+
* `container.run(command, { processToken })` names one run. The `node` command
|
|
6
|
+
* records the guest process it creates under that name, for as long as the run
|
|
7
|
+
* lasts, and forgets it when the run ends. Nothing here starts or ends a
|
|
8
|
+
* program: it is the registry three doors read, and the name a server
|
|
9
|
+
* registers itself under while its run is the one launching.
|
|
10
|
+
*
|
|
11
|
+
* The name reaches the `node` command through the shell's environment, under
|
|
12
|
+
* the reserved variable below, because two runs can be in flight at once on
|
|
13
|
+
* one shell and a module-level "the current run" would answer the later one
|
|
14
|
+
* for both. The guest never sees the variable: the environment the `node`
|
|
15
|
+
* command gives its process has it removed.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { AsyncLocalStorage } from './shims/async_hooks';
|
|
19
|
+
|
|
20
|
+
/** Whatever the embedding runtime uses to name one guest process. */
|
|
21
|
+
export type ProcessToken = string;
|
|
22
|
+
|
|
23
|
+
/** The environment variable a run's name travels in, from `exec` to `node`. */
|
|
24
|
+
export const PROCESS_TOKEN_ENV = '__TABNODE_PROCESS_TOKEN';
|
|
25
|
+
|
|
26
|
+
/** What the engine can answer about one named run. */
|
|
27
|
+
export interface OwnedRun {
|
|
28
|
+
/** The timers the run's guest still holds, as Node's loop counts them. */
|
|
29
|
+
pendingTimers(): number;
|
|
30
|
+
/** Clear those timers, as ending the process clears them. */
|
|
31
|
+
stopTimers(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Report an exception nobody caught as this run's own, the way Node's
|
|
34
|
+
* process reports one: the run's `uncaughtException` listeners, else its
|
|
35
|
+
* stderr and exit 1. False when the run no longer answers.
|
|
36
|
+
*/
|
|
37
|
+
reportUncaught(error: unknown): boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const runs = new Map<ProcessToken, OwnedRun>();
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The run whose guest code is executing, as an async-local value rather than a
|
|
44
|
+
* module global. A module-level "the current run" answered the LATEST run for
|
|
45
|
+
* every reader, so a guest that spawned a child while another run was in
|
|
46
|
+
* flight was attributed to the wrong parent. The engine's own storage carries
|
|
47
|
+
* the value into timers, immediates, microtasks and `then` callbacks scheduled
|
|
48
|
+
* from inside the run; a native `await` continuation is its documented limit.
|
|
49
|
+
*/
|
|
50
|
+
const executing = new AsyncLocalStorage<ProcessToken>();
|
|
51
|
+
|
|
52
|
+
/** Run `fn` as this token's guest code, so the doors below name that run. */
|
|
53
|
+
export function enterRun<T>(token: ProcessToken, fn: () => T): T {
|
|
54
|
+
return executing.run(token, fn as (...args: unknown[]) => T);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Record a named run's guest for the run's lifetime. The answer releases it;
|
|
59
|
+
* releasing twice is harmless, as a run ends once.
|
|
60
|
+
*/
|
|
61
|
+
export function __recordRun(token: ProcessToken, run: OwnedRun): () => void {
|
|
62
|
+
runs.set(token, run);
|
|
63
|
+
let released = false;
|
|
64
|
+
return () => {
|
|
65
|
+
if (released) return;
|
|
66
|
+
released = true;
|
|
67
|
+
if (runs.get(token) === run) runs.delete(token);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The run recorded under this name, while it lasts. */
|
|
72
|
+
export function __runFor(token: ProcessToken): OwnedRun | undefined {
|
|
73
|
+
return runs.get(token);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The run now launching a guest, for a handle or a server the guest opens
|
|
78
|
+
* after its entry has returned, when no run is the current one any more.
|
|
79
|
+
* `enterRun`'s async-local value covers the guest's own turn and everything
|
|
80
|
+
* scheduled from inside it; a listen that lands after a native `await`
|
|
81
|
+
* continuation is attributed here.
|
|
82
|
+
*/
|
|
83
|
+
export let __lastLaunchedToken: ProcessToken | null = null;
|
|
84
|
+
export function __setLastLaunchedToken(token: ProcessToken | null): void {
|
|
85
|
+
__lastLaunchedToken = token;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The run a guest is being launched under, where the host named one. */
|
|
89
|
+
export function __currentProcessToken(): ProcessToken | null {
|
|
90
|
+
return executing.getStore() ?? null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* End a named run's timers. The servers it owns are released by `http`'s own
|
|
95
|
+
* half, `__releaseOwnedServers`, which calls this for the timers.
|
|
96
|
+
*/
|
|
97
|
+
export function __stopOwnedProcess(token: ProcessToken): void {
|
|
98
|
+
runs.get(token)?.stopTimers();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A process's own number.
|
|
103
|
+
*
|
|
104
|
+
* Node gives every process a distinct pid and `process.ppid` names its
|
|
105
|
+
* parent's; a program reads both, and other programs read a program's pid out
|
|
106
|
+
* of a file and ask whether it is still there. The engine gave every guest
|
|
107
|
+
* `pid: 1` and `ppid: 0`, while the parent's `ChildProcess` handle carried a
|
|
108
|
+
* real, distinct number minted by `process_wrap` -- so a child and its parent
|
|
109
|
+
* disagreed about the child's pid, and worse, every run answered
|
|
110
|
+
* `process.kill(1, 0)` with "yes, that is me".
|
|
111
|
+
*
|
|
112
|
+
* What that cost: openvscode-server's extension host takes a lock on its
|
|
113
|
+
* workspace storage directory (`vs/workbench/api/node/extHostStoragePaths`),
|
|
114
|
+
* writes `{ pid: process.pid }` into `vscode.lock`, and a later host reads
|
|
115
|
+
* that file and asks `processExists(pid)` -- `try { process.kill(pid, 0);
|
|
116
|
+
* return true } catch { return false }` -- before stealing a stale lock. Every
|
|
117
|
+
* host wrote pid 1 and every later host asked about pid 1, which is its own,
|
|
118
|
+
* so the lock read as held by a live process forever. `ExtensionStoragePaths.
|
|
119
|
+
* whenReady` never resolved, every `_loadExtensionContext` awaits it, and so
|
|
120
|
+
* every extension in the tab sat at "Activating..." and `vscode.git` never
|
|
121
|
+
* started at all.
|
|
122
|
+
*/
|
|
123
|
+
let __nextPid = 1000 + Math.floor(Math.random() * 30000);
|
|
124
|
+
const pidsOfRuns = new Map<ProcessToken, { pid: number; ppid: number }>();
|
|
125
|
+
|
|
126
|
+
/** The next process number this engine hands out. */
|
|
127
|
+
export function mintPid(): number {
|
|
128
|
+
return __nextPid++;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Record the numbers a named run was started with, for the run to read back. */
|
|
132
|
+
export function setRunPid(token: ProcessToken, pid: number, ppid: number): void {
|
|
133
|
+
pidsOfRuns.set(token, { pid, ppid });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The numbers a named run was started with, where one was recorded. */
|
|
137
|
+
export function runPid(token: ProcessToken | null | undefined): { pid: number; ppid: number } | undefined {
|
|
138
|
+
return token === null || token === undefined ? undefined : pidsOfRuns.get(token);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A run that has ended is no longer a process; its number is nobody's. */
|
|
142
|
+
export function forgetRunPid(token: ProcessToken): void {
|
|
143
|
+
pidsOfRuns.delete(token);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Whether a live run carries this number, which is what `kill(pid, 0)` asks. */
|
|
147
|
+
export function pidIsLive(pid: number): boolean {
|
|
148
|
+
for (const entry of pidsOfRuns.values()) if (entry.pid === pid) return true;
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The numbers a live process carries, looked up by its own pid. */
|
|
153
|
+
export function processByPid(pid: number): { pid: number; ppid: number } | undefined {
|
|
154
|
+
for (const entry of pidsOfRuns.values()) if (entry.pid === pid) return entry;
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// punycode 2.3.1 (MIT, Mathias Bynens), the library Node ships as its deprecated
|
|
2
|
+
// `punycode` builtin, embedded so the engine answers `require("punycode")`
|
|
3
|
+
// with Node's own API: whatwg-url under node-fetch under google-auth-library asks
|
|
4
|
+
// for it on the way into Dub's login action. Regenerate from the package, never edit.
|
|
5
|
+
export const PUNYCODE_VERSION = "2.3.1";
|
|
6
|
+
export const PUNYCODE_SOURCE = "'use strict';\n\n/** Highest positive signed 32-bit float value */\nconst maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1\n\n/** Bootstring parameters */\nconst base = 36;\nconst tMin = 1;\nconst tMax = 26;\nconst skew = 38;\nconst damp = 700;\nconst initialBias = 72;\nconst initialN = 128; // 0x80\nconst delimiter = '-'; // '\\x2D'\n\n/** Regular expressions */\nconst regexPunycode = /^xn--/;\nconst regexNonASCII = /[^\\0-\\x7F]/; // Note: U+007F DEL is excluded too.\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g; // RFC 3490 separators\n\n/** Error messages */\nconst errors = {\n\t'overflow': 'Overflow: input needs wider integers to process',\n\t'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n\t'invalid-input': 'Invalid input'\n};\n\n/** Convenience shortcuts */\nconst baseMinusTMin = base - tMin;\nconst floor = Math.floor;\nconst stringFromCharCode = String.fromCharCode;\n\n/*--------------------------------------------------------------------------*/\n\n/**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\nfunction error(type) {\n\tthrow new RangeError(errors[type]);\n}\n\n/**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\nfunction map(array, callback) {\n\tconst result = [];\n\tlet length = array.length;\n\twhile (length--) {\n\t\tresult[length] = callback(array[length]);\n\t}\n\treturn result;\n}\n\n/**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {String} A new string of characters returned by the callback\n * function.\n */\nfunction mapDomain(domain, callback) {\n\tconst parts = domain.split('@');\n\tlet result = '';\n\tif (parts.length > 1) {\n\t\t// In email addresses, only the domain name should be punycoded. Leave\n\t\t// the local part (i.e. everything up to `@`) intact.\n\t\tresult = parts[0] + '@';\n\t\tdomain = parts[1];\n\t}\n\t// Avoid `split(regex)` for IE8 compatibility. See #17.\n\tdomain = domain.replace(regexSeparators, '\\x2E');\n\tconst labels = domain.split('.');\n\tconst encoded = map(labels, callback).join('.');\n\treturn result + encoded;\n}\n\n/**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see <https://mathiasbynens.be/notes/javascript-encoding>\n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\nfunction ucs2decode(string) {\n\tconst output = [];\n\tlet counter = 0;\n\tconst length = string.length;\n\twhile (counter < length) {\n\t\tconst value = string.charCodeAt(counter++);\n\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t// It's a high surrogate, and there is a next character.\n\t\t\tconst extra = string.charCodeAt(counter++);\n\t\t\tif ((extra & 0xFC00) == 0xDC00) { // Low surrogate.\n\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t} else {\n\t\t\t\t// It's an unmatched surrogate; only append this code unit, in case the\n\t\t\t\t// next code unit is the high surrogate of a surrogate pair.\n\t\t\t\toutput.push(value);\n\t\t\t\tcounter--;\n\t\t\t}\n\t\t} else {\n\t\t\toutput.push(value);\n\t\t}\n\t}\n\treturn output;\n}\n\n/**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\nconst ucs2encode = codePoints => String.fromCodePoint(...codePoints);\n\n/**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\nconst basicToDigit = function(codePoint) {\n\tif (codePoint >= 0x30 && codePoint < 0x3A) {\n\t\treturn 26 + (codePoint - 0x30);\n\t}\n\tif (codePoint >= 0x41 && codePoint < 0x5B) {\n\t\treturn codePoint - 0x41;\n\t}\n\tif (codePoint >= 0x61 && codePoint < 0x7B) {\n\t\treturn codePoint - 0x61;\n\t}\n\treturn base;\n};\n\n/**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\nconst digitToBasic = function(digit, flag) {\n\t// 0..25 map to ASCII a..z or A..Z\n\t// 26..35 map to ASCII 0..9\n\treturn digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n};\n\n/**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\nconst adapt = function(delta, numPoints, firstTime) {\n\tlet k = 0;\n\tdelta = firstTime ? floor(delta / damp) : delta >> 1;\n\tdelta += floor(delta / numPoints);\n\tfor (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {\n\t\tdelta = floor(delta / baseMinusTMin);\n\t}\n\treturn floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n};\n\n/**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\nconst decode = function(input) {\n\t// Don't use UCS-2.\n\tconst output = [];\n\tconst inputLength = input.length;\n\tlet i = 0;\n\tlet n = initialN;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points: let `basic` be the number of input code\n\t// points before the last delimiter, or `0` if there is none, then copy\n\t// the first basic code points to the output.\n\n\tlet basic = input.lastIndexOf(delimiter);\n\tif (basic < 0) {\n\t\tbasic = 0;\n\t}\n\n\tfor (let j = 0; j < basic; ++j) {\n\t\t// if it's not a basic code point\n\t\tif (input.charCodeAt(j) >= 0x80) {\n\t\t\terror('not-basic');\n\t\t}\n\t\toutput.push(input.charCodeAt(j));\n\t}\n\n\t// Main decoding loop: start just after the last delimiter if any basic code\n\t// points were copied; start at the beginning otherwise.\n\n\tfor (let index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {\n\n\t\t// `index` is the index of the next character to be consumed.\n\t\t// Decode a generalized variable-length integer into `delta`,\n\t\t// which gets added to `i`. The overflow checking is easier\n\t\t// if we increase `i` as we go, then subtract off its starting\n\t\t// value at the end to obtain `delta`.\n\t\tconst oldi = i;\n\t\tfor (let w = 1, k = base; /* no condition */; k += base) {\n\n\t\t\tif (index >= inputLength) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\n\t\t\tconst digit = basicToDigit(input.charCodeAt(index++));\n\n\t\t\tif (digit >= base) {\n\t\t\t\terror('invalid-input');\n\t\t\t}\n\t\t\tif (digit > floor((maxInt - i) / w)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\ti += digit * w;\n\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\n\t\t\tif (digit < t) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst baseMinusT = base - t;\n\t\t\tif (w > floor(maxInt / baseMinusT)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tw *= baseMinusT;\n\n\t\t}\n\n\t\tconst out = output.length + 1;\n\t\tbias = adapt(i - oldi, out, oldi == 0);\n\n\t\t// `i` was supposed to wrap around from `out` to `0`,\n\t\t// incrementing `n` each time, so we'll fix that now:\n\t\tif (floor(i / out) > maxInt - n) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tn += floor(i / out);\n\t\ti %= out;\n\n\t\t// Insert `n` at position `i` of the output.\n\t\toutput.splice(i++, 0, n);\n\n\t}\n\n\treturn String.fromCodePoint(...output);\n};\n\n/**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\nconst encode = function(input) {\n\tconst output = [];\n\n\t// Convert the input in UCS-2 to an array of Unicode code points.\n\tinput = ucs2decode(input);\n\n\t// Cache the length.\n\tconst inputLength = input.length;\n\n\t// Initialize the state.\n\tlet n = initialN;\n\tlet delta = 0;\n\tlet bias = initialBias;\n\n\t// Handle the basic code points.\n\tfor (const currentValue of input) {\n\t\tif (currentValue < 0x80) {\n\t\t\toutput.push(stringFromCharCode(currentValue));\n\t\t}\n\t}\n\n\tconst basicLength = output.length;\n\tlet handledCPCount = basicLength;\n\n\t// `handledCPCount` is the number of code points that have been handled;\n\t// `basicLength` is the number of basic code points.\n\n\t// Finish the basic string with a delimiter unless it's empty.\n\tif (basicLength) {\n\t\toutput.push(delimiter);\n\t}\n\n\t// Main encoding loop:\n\twhile (handledCPCount < inputLength) {\n\n\t\t// All non-basic code points < n have been handled already. Find the next\n\t\t// larger one:\n\t\tlet m = maxInt;\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue >= n && currentValue < m) {\n\t\t\t\tm = currentValue;\n\t\t\t}\n\t\t}\n\n\t\t// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,\n\t\t// but guard against overflow.\n\t\tconst handledCPCountPlusOne = handledCPCount + 1;\n\t\tif (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n\t\t\terror('overflow');\n\t\t}\n\n\t\tdelta += (m - n) * handledCPCountPlusOne;\n\t\tn = m;\n\n\t\tfor (const currentValue of input) {\n\t\t\tif (currentValue < n && ++delta > maxInt) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\t\t\tif (currentValue === n) {\n\t\t\t\t// Represent delta as a generalized variable-length integer.\n\t\t\t\tlet q = delta;\n\t\t\t\tfor (let k = base; /* no condition */; k += base) {\n\t\t\t\t\tconst t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\t\t\t\t\tif (q < t) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst qMinusT = q - t;\n\t\t\t\t\tconst baseMinusT = base - t;\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tstringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))\n\t\t\t\t\t);\n\t\t\t\t\tq = floor(qMinusT / baseMinusT);\n\t\t\t\t}\n\n\t\t\t\toutput.push(stringFromCharCode(digitToBasic(q, 0)));\n\t\t\t\tbias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);\n\t\t\t\tdelta = 0;\n\t\t\t\t++handledCPCount;\n\t\t\t}\n\t\t}\n\n\t\t++delta;\n\t\t++n;\n\n\t}\n\treturn output.join('');\n};\n\n/**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\nconst toUnicode = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexPunycode.test(string)\n\t\t\t? decode(string.slice(4).toLowerCase())\n\t\t\t: string;\n\t});\n};\n\n/**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\nconst toASCII = function(input) {\n\treturn mapDomain(input, function(string) {\n\t\treturn regexNonASCII.test(string)\n\t\t\t? 'xn--' + encode(string)\n\t\t\t: string;\n\t});\n};\n\n/*--------------------------------------------------------------------------*/\n\n/** Define the public API */\nconst punycode = {\n\t/**\n\t * A string representing the current Punycode.js version number.\n\t * @memberOf punycode\n\t * @type String\n\t */\n\t'version': '2.3.1',\n\t/**\n\t * An object of methods to convert from JavaScript's internal character\n\t * representation (UCS-2) to Unicode code points, and back.\n\t * @see <https://mathiasbynens.be/notes/javascript-encoding>\n\t * @memberOf punycode\n\t * @type Object\n\t */\n\t'ucs2': {\n\t\t'decode': ucs2decode,\n\t\t'encode': ucs2encode\n\t},\n\t'decode': decode,\n\t'encode': encode,\n\t'toASCII': toASCII,\n\t'toUnicode': toUnicode\n};\n\nmodule.exports = punycode;\n";
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Interface - Common interface for main-thread and worker runtimes
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { VirtualFS } from './virtual-fs';
|
|
6
|
+
|
|
7
|
+
export interface IRuntimeOptions {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
env?: Record<string, string>;
|
|
10
|
+
onConsole?: (method: string, args: unknown[]) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IModule {
|
|
14
|
+
id: string;
|
|
15
|
+
filename: string;
|
|
16
|
+
exports: unknown;
|
|
17
|
+
loaded: boolean;
|
|
18
|
+
children: IModule[];
|
|
19
|
+
paths: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IExecuteResult {
|
|
23
|
+
exports: unknown;
|
|
24
|
+
module: IModule;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Common runtime interface implemented by both MainThreadRuntime and WorkerRuntime
|
|
29
|
+
*/
|
|
30
|
+
export interface IRuntime {
|
|
31
|
+
/**
|
|
32
|
+
* Execute code as a module
|
|
33
|
+
*/
|
|
34
|
+
execute(code: string, filename?: string): Promise<IExecuteResult>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Run a file from the virtual file system
|
|
38
|
+
*/
|
|
39
|
+
runFile(filename: string): Promise<IExecuteResult>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Clear the module cache
|
|
43
|
+
*/
|
|
44
|
+
clearCache(): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get the virtual file system (only available on main thread runtime)
|
|
48
|
+
*/
|
|
49
|
+
getVFS?(): VirtualFS;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Terminate the runtime (only applicable to worker runtime)
|
|
53
|
+
*/
|
|
54
|
+
terminate?(): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Options for creating a runtime
|
|
59
|
+
*/
|
|
60
|
+
export interface CreateRuntimeOptions extends IRuntimeOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Which thread the guest runs on.
|
|
63
|
+
* - false (default): the caller's thread
|
|
64
|
+
* - true: a worker of the engine's own
|
|
65
|
+
* - 'auto': a worker where the realm has them, the caller's thread otherwise
|
|
66
|
+
*
|
|
67
|
+
* A worker is a thread, not an origin: it reaches the page's storage and
|
|
68
|
+
* its network. An embedder that needs origin isolation serves the run from
|
|
69
|
+
* an origin of its own, which is the substrate's isolation worker.
|
|
70
|
+
*/
|
|
71
|
+
useWorker?: boolean | 'auto';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* VFS snapshot for transferring to worker
|
|
76
|
+
*/
|
|
77
|
+
export interface VFSSnapshot {
|
|
78
|
+
files: VFSFileEntry[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface VFSFileEntry {
|
|
82
|
+
path: string;
|
|
83
|
+
type: 'file' | 'directory';
|
|
84
|
+
content?: string; // base64 encoded for binary files
|
|
85
|
+
}
|