@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,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The internals Node's `internal/modules/customization_hooks.js` names.
|
|
3
|
+
*
|
|
4
|
+
* Each object holds exactly the names that file destructures from it. Node's
|
|
5
|
+
* real `internal/bootstrap/realm` is the builtin loader of a Node process --
|
|
6
|
+
* a snapshot, a compile cache and every `lib/` file -- and what the hooks file
|
|
7
|
+
* takes from it is two questions about a name: is this something a program can
|
|
8
|
+
* require, and what is its canonical id. The engine answers both from the same
|
|
9
|
+
* list its `module.builtinModules` reports, so a hook that reads `node:fs`
|
|
10
|
+
* reads the name the guest's own `module.isBuiltin` agrees with.
|
|
11
|
+
*/
|
|
12
|
+
import * as moduleShim from '../../shims/module';
|
|
13
|
+
import { fileURLToPath, pathToFileURL } from '../../shims/url';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `internal/bootstrap/realm`'s `BuiltinModule`, the two class methods the
|
|
17
|
+
* hooks file calls to turn a CommonJS filename into a URL and back.
|
|
18
|
+
*/
|
|
19
|
+
export const internalBootstrapRealm = {
|
|
20
|
+
BuiltinModule: {
|
|
21
|
+
/**
|
|
22
|
+
* Whether a normalized id (no `node:`) is a builtin a program may require.
|
|
23
|
+
* Node asks this of a filename to decide whether it is `node:<id>` rather
|
|
24
|
+
* than a path; a name the engine does not answer is a path or nothing.
|
|
25
|
+
*/
|
|
26
|
+
canBeRequiredByUsers(id: string): boolean {
|
|
27
|
+
return moduleShim.builtinModules.includes(id);
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* The canonical id of a requirable builtin, `node:` prefix or not, and
|
|
31
|
+
* undefined for anything else -- a `file:` URL, a path, a bare package
|
|
32
|
+
* name. Node returns undefined rather than throwing, and the hooks file
|
|
33
|
+
* tests the result rather than catching.
|
|
34
|
+
*/
|
|
35
|
+
normalizeRequirableId(id: string): string | undefined {
|
|
36
|
+
if (typeof id !== 'string') return void 0;
|
|
37
|
+
const name = id.startsWith('node:') ? id.slice(5) : id;
|
|
38
|
+
return moduleShim.builtinModules.includes(name) ? name : void 0;
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Whether `id` is a compiled builtin, which `internal/util/inspect`
|
|
42
|
+
* asks of every `node:` stack frame when it colorizes an Error. Node's
|
|
43
|
+
* class answers from the realm's module map; the engine answers from
|
|
44
|
+
* the same list `canBeRequiredByUsers` reads, plus `internal/` files
|
|
45
|
+
* inspect also greys. The method was missing, so a pipe child that
|
|
46
|
+
* still had FORCE_COLOR threw `exists is not a function` while printing
|
|
47
|
+
* an assertion and the test exited 1.
|
|
48
|
+
*/
|
|
49
|
+
exists(id: string): boolean {
|
|
50
|
+
if (typeof id !== 'string') return false;
|
|
51
|
+
const name = id.startsWith('node:') ? id.slice(5) : id;
|
|
52
|
+
return name.startsWith('internal/') || moduleShim.builtinModules.includes(name);
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* `internal/url`: the conversions between a path and a URL that the hooks
|
|
59
|
+
* file makes, and the three names `_http_client.js` and `https.js` take to
|
|
60
|
+
* turn a URL into the options a request is made from.
|
|
61
|
+
*/
|
|
62
|
+
export const internalUrl = {
|
|
63
|
+
fileURLToPath,
|
|
64
|
+
pathToFileURL,
|
|
65
|
+
/**
|
|
66
|
+
* Node's `toPathIfFileURL`: `fs` takes a path or a `file:` URL for every
|
|
67
|
+
* one of its calls, and this is the one line that turns the second into
|
|
68
|
+
* the first. Anything else is handed on untouched, for `fs` to validate.
|
|
69
|
+
*/
|
|
70
|
+
toPathIfFileURL: (value: unknown): unknown => {
|
|
71
|
+
if (value instanceof URL) return fileURLToPath(value);
|
|
72
|
+
if (typeof value === 'string' && value.startsWith('file://')) return fileURLToPath(value);
|
|
73
|
+
return value;
|
|
74
|
+
},
|
|
75
|
+
get URL() { return (globalThis as unknown as { URL: unknown }).URL; },
|
|
76
|
+
/** Node's `isURL`: a `URL` of this realm, or one shaped like it. */
|
|
77
|
+
isURL: (value: unknown): boolean =>
|
|
78
|
+
value instanceof URL ||
|
|
79
|
+
(value !== null && typeof value === 'object' &&
|
|
80
|
+
typeof (value as { href?: unknown }).href === 'string' &&
|
|
81
|
+
typeof (value as { origin?: unknown }).origin === 'string' &&
|
|
82
|
+
typeof (value as { protocol?: unknown }).protocol === 'string'),
|
|
83
|
+
/**
|
|
84
|
+
* Node's `urlToHttpOptions`: the request options a `URL` stands for. The
|
|
85
|
+
* rules are Node's own -- an IPv6 host loses its brackets, the path is the
|
|
86
|
+
* pathname and the search together, and a password without a user is still
|
|
87
|
+
* an auth pair.
|
|
88
|
+
*/
|
|
89
|
+
urlToHttpOptions: (url: URL): Record<string, unknown> => {
|
|
90
|
+
const options: Record<string, unknown> = {
|
|
91
|
+
protocol: url.protocol,
|
|
92
|
+
hostname: typeof url.hostname === 'string' && url.hostname.startsWith('[')
|
|
93
|
+
? url.hostname.slice(1, -1)
|
|
94
|
+
: url.hostname,
|
|
95
|
+
hash: url.hash,
|
|
96
|
+
search: url.search,
|
|
97
|
+
pathname: url.pathname,
|
|
98
|
+
path: `${url.pathname || ''}${url.search || ''}`,
|
|
99
|
+
href: url.href,
|
|
100
|
+
};
|
|
101
|
+
if (url.port !== '') options.port = Number(url.port);
|
|
102
|
+
if (url.username || url.password) {
|
|
103
|
+
options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
|
|
104
|
+
}
|
|
105
|
+
return options;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* `internal/encoding`: the realm's own `TextDecoder`. The hooks file decodes
|
|
111
|
+
* an `ArrayBuffer` or a typed array a load hook returned into the source
|
|
112
|
+
* string the loader compiles.
|
|
113
|
+
*/
|
|
114
|
+
export const internalEncoding = {
|
|
115
|
+
get TextDecoder() { return (globalThis as unknown as { TextDecoder: unknown }).TextDecoder; },
|
|
116
|
+
get TextEncoder() { return (globalThis as unknown as { TextEncoder: unknown }).TextEncoder; },
|
|
117
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine's `readline`, read on the first ask.
|
|
3
|
+
*
|
|
4
|
+
* `internal/fs/promises.js` takes `Interface` from `internal/readline/
|
|
5
|
+
* interface` at its top, so every use of `fs/promises` needs the class.
|
|
6
|
+
* `readline`'s own `Interface` extends the vendored `EventEmitter`, and this
|
|
7
|
+
* file is on the loader's path, so the name is read when it is wanted rather
|
|
8
|
+
* than when this module is evaluated -- the rule `../lazy.ts` states.
|
|
9
|
+
*/
|
|
10
|
+
import { nodeLibInternalRequire } from '../load';
|
|
11
|
+
|
|
12
|
+
export function readlineModule(): Record<string, unknown> {
|
|
13
|
+
// Node's own `internal/readline/interface` is vendored now, so the name
|
|
14
|
+
// resolves to that file rather than to the engine's shim.
|
|
15
|
+
return nodeLibInternalRequire('internal/readline/interface') as Record<string, unknown>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The internals Node's `net` names that are neither vendored nor a binding:
|
|
3
|
+
* async ids, timers, stream defaults, the option table, and the three
|
|
4
|
+
* one-line answers (`assert`, `hasObserver`, `isBuildingSnapshot`).
|
|
5
|
+
*
|
|
6
|
+
* Each object holds exactly the names the vendored files destructure.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `internal/async_hooks`. The engine has no async-hooks graph, so an id is a
|
|
11
|
+
* number nobody follows and a trigger scope is the call itself. The two
|
|
12
|
+
* symbols matter and are real: `owner_symbol` is how a handle finds its
|
|
13
|
+
* stream — `onStreamRead` reads `this[owner_symbol]` on every chunk — and
|
|
14
|
+
* `async_id_symbol` is where `net.js` keeps a socket's id.
|
|
15
|
+
*/
|
|
16
|
+
let nextAsyncId = 1;
|
|
17
|
+
const symbols = {
|
|
18
|
+
async_id_symbol: Symbol('async_id_symbol'),
|
|
19
|
+
trigger_async_id_symbol: Symbol('trigger_async_id_symbol'),
|
|
20
|
+
owner_symbol: Symbol('owner_symbol'),
|
|
21
|
+
init_symbol: Symbol('init_symbol'),
|
|
22
|
+
destroy_symbol: Symbol('destroy_symbol'),
|
|
23
|
+
async_id_fields: Symbol('async_id_fields'),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const internalAsyncHooks = {
|
|
27
|
+
symbols,
|
|
28
|
+
newAsyncId: (): number => nextAsyncId++,
|
|
29
|
+
/**
|
|
30
|
+
* Node's `getOrSetAsyncId`: the id an object already carries, or a new one
|
|
31
|
+
* put on it. `_http_server.js` asks it of every socket it accepts, to name
|
|
32
|
+
* the scope the connection listener runs in.
|
|
33
|
+
*/
|
|
34
|
+
getOrSetAsyncId: (object: Record<symbol, unknown>): number => {
|
|
35
|
+
const key = symbols.async_id_symbol;
|
|
36
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) return object[key] as number;
|
|
37
|
+
object[key] = nextAsyncId++;
|
|
38
|
+
return object[key] as number;
|
|
39
|
+
},
|
|
40
|
+
getDefaultTriggerAsyncId: (): number => 0,
|
|
41
|
+
defaultTriggerAsyncIdScope: <A extends unknown[], R>(
|
|
42
|
+
_triggerAsyncId: number, block: (...args: A) => R, ...args: A
|
|
43
|
+
): R => block(...args),
|
|
44
|
+
initHooksExist: (): boolean => false,
|
|
45
|
+
afterHooksExist: (): boolean => false,
|
|
46
|
+
destroyHooksExist: (): boolean => false,
|
|
47
|
+
emitInit: (): void => {},
|
|
48
|
+
emitBefore: (): void => {},
|
|
49
|
+
emitAfter: (): void => {},
|
|
50
|
+
emitDestroy: (): void => {},
|
|
51
|
+
hasAsyncIdStack: (): boolean => false,
|
|
52
|
+
registerDestroyHook: (): void => {},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Node's `AsyncResource`, which `events.js` extends to build
|
|
57
|
+
* `EventEmitterAsyncResource`. A tab has no async-hooks graph, so an id is a
|
|
58
|
+
* number nobody follows -- but it is a real positive id, because a program
|
|
59
|
+
* that asks `asyncId` of a resource, as Node's own tests do, must see one.
|
|
60
|
+
* Served through `require('async_hooks')` so the vendored file can extend it;
|
|
61
|
+
* the class lives here, never in that file.
|
|
62
|
+
*/
|
|
63
|
+
let nextAsyncResourceId = 1;
|
|
64
|
+
export class AsyncResource {
|
|
65
|
+
#asyncId: number;
|
|
66
|
+
#triggerAsyncId: number;
|
|
67
|
+
|
|
68
|
+
constructor(_type: string, options?: { triggerAsyncId?: number; requireManualDestroy?: boolean }) {
|
|
69
|
+
this.#asyncId = nextAsyncResourceId++;
|
|
70
|
+
this.#triggerAsyncId = options?.triggerAsyncId ?? 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
runInAsyncScope<T>(fn: (...args: never[]) => T, thisArg?: unknown, ...args: never[]): T {
|
|
74
|
+
return fn.apply(thisArg, args);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
emitDestroy(): this { return this; }
|
|
78
|
+
asyncId(): number { return this.#asyncId; }
|
|
79
|
+
triggerAsyncId(): number { return this.#triggerAsyncId; }
|
|
80
|
+
|
|
81
|
+
static bind<T extends (...args: never[]) => unknown>(fn: T, _type?: string): T {
|
|
82
|
+
return fn;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* `internal/timers`. Only `setStreamTimeout` in
|
|
88
|
+
* `internal/stream_base_commons.js` uses it, for `socket.setTimeout`, and
|
|
89
|
+
* Node's timer for that is unref'd: a socket's idle timeout never holds a
|
|
90
|
+
* process open. The engine counts a guest's own timers to decide whether a
|
|
91
|
+
* program is still working, and a timer made here is made with the realm's
|
|
92
|
+
* own `setTimeout` rather than the guest's view of it, so it is not counted —
|
|
93
|
+
* which is exactly what unref'd means.
|
|
94
|
+
*/
|
|
95
|
+
const kTimeout = Symbol('timeout');
|
|
96
|
+
|
|
97
|
+
/** The realm's own timer, never the guest's counted one. */
|
|
98
|
+
function realmSetTimeout(fn: () => void, ms: number): unknown {
|
|
99
|
+
const realm = globalThis as unknown as {
|
|
100
|
+
__browserRuntimeNativeSetTimeout?: (fn: () => void, ms: number) => unknown;
|
|
101
|
+
};
|
|
102
|
+
return (realm.__browserRuntimeNativeSetTimeout ?? globalThis.setTimeout).call(globalThis, fn, ms);
|
|
103
|
+
}
|
|
104
|
+
function realmClearTimeout(id: unknown): void {
|
|
105
|
+
const realm = globalThis as unknown as {
|
|
106
|
+
__browserRuntimeNativeClearTimeout?: (id: unknown) => void;
|
|
107
|
+
};
|
|
108
|
+
(realm.__browserRuntimeNativeClearTimeout ?? globalThis.clearTimeout).call(globalThis, id as number);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* What `setUnrefTimeout` answers: a timer that can be refreshed in place, as
|
|
113
|
+
* Node's `Timeout` can, and that `timers.clearTimeout` here knows how to stop.
|
|
114
|
+
*/
|
|
115
|
+
export class UnrefTimeout {
|
|
116
|
+
private id: unknown = null;
|
|
117
|
+
private readonly onTimeout: () => void;
|
|
118
|
+
private readonly msecs: number;
|
|
119
|
+
|
|
120
|
+
constructor(onTimeout: () => void, msecs: number) {
|
|
121
|
+
this.onTimeout = onTimeout;
|
|
122
|
+
this.msecs = msecs;
|
|
123
|
+
this.id = realmSetTimeout(() => { this.id = null; this.onTimeout(); }, msecs);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
refresh(): this {
|
|
127
|
+
if (this.id !== null) realmClearTimeout(this.id);
|
|
128
|
+
this.id = realmSetTimeout(() => { this.id = null; this.onTimeout(); }, this.msecs);
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
stop(): void {
|
|
133
|
+
if (this.id !== null) realmClearTimeout(this.id);
|
|
134
|
+
this.id = null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ref(): this { return this; }
|
|
138
|
+
unref(): this { return this; }
|
|
139
|
+
hasRef(): boolean { return false; }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const TIMEOUT_MAX = 2 ** 31 - 1;
|
|
143
|
+
|
|
144
|
+
export const internalTimers = {
|
|
145
|
+
kTimeout,
|
|
146
|
+
TIMEOUT_MAX,
|
|
147
|
+
setUnrefTimeout: (fn: () => void, msecs: number): UnrefTimeout => new UnrefTimeout(fn, msecs),
|
|
148
|
+
/** Node's `getTimerDuration`: a number in range, and 1 for anything under it. */
|
|
149
|
+
getTimerDuration(msecs: unknown, name: string): number {
|
|
150
|
+
if (typeof msecs !== 'number') {
|
|
151
|
+
throw Object.assign(new TypeError(`The "${name}" argument must be of type number. Received ${typeof msecs}`), { code: 'ERR_INVALID_ARG_TYPE' });
|
|
152
|
+
}
|
|
153
|
+
if (msecs < 0 || !Number.isFinite(msecs)) {
|
|
154
|
+
throw Object.assign(new RangeError(`The value of "${name}" is out of range. It must be a non-negative finite number. Received ${msecs}`), { code: 'ERR_OUT_OF_RANGE' });
|
|
155
|
+
}
|
|
156
|
+
if (msecs === 0) return 0;
|
|
157
|
+
if (msecs > TIMEOUT_MAX) return 1;
|
|
158
|
+
return msecs < 1 ? 1 : msecs;
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/** `internal/streams/state`: Node's default high-water marks. */
|
|
163
|
+
export const internalStreamsState = {
|
|
164
|
+
getDefaultHighWaterMark: (objectMode?: boolean): number => (objectMode ? 16 : 65536),
|
|
165
|
+
setDefaultHighWaterMark: (): void => {},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/** `internal/process/task_queues`: the realm's own microtask queue. */
|
|
169
|
+
export const internalTaskQueues = {
|
|
170
|
+
queueMicrotask: (fn: () => void): void => queueMicrotask(fn),
|
|
171
|
+
setHasTickScheduled: (): void => {},
|
|
172
|
+
runNextTicks: (): void => {},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/** `internal/event_target`: the one symbol `abort_listener.js` reads. */
|
|
176
|
+
// Registry symbols, not unique ones: the engine's bundle can be evaluated
|
|
177
|
+
// more than once in a realm -- a page's copy and a worker's -- and each
|
|
178
|
+
// evaluation would otherwise mint its own key. The default below was defined
|
|
179
|
+
// under one key and `events.js` read another, so a fresh `EventTarget`
|
|
180
|
+
// answered nothing while one that had been set answered fine.
|
|
181
|
+
const kEventsSymbol = Symbol.for('nodejs.event_target.events');
|
|
182
|
+
// Every `EventTarget` answers the symbol above with an empty map, for the
|
|
183
|
+
// reason given on `kEvents` below. One getter on the prototype, installed
|
|
184
|
+
// where the binding is defined rather than inside a guest's realm, because
|
|
185
|
+
// `events.js` reads it off whatever target it was handed.
|
|
186
|
+
if (typeof EventTarget === 'function' && !(kEventsSymbol in EventTarget.prototype)) {
|
|
187
|
+
const empty = new Map<unknown, unknown>();
|
|
188
|
+
Object.defineProperty(EventTarget.prototype, kEventsSymbol, { get: () => empty, configurable: true });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export const internalEventTarget = {
|
|
192
|
+
kResistStopPropagation: Symbol('kResistStopPropagation'),
|
|
193
|
+
/** `internal/streams/operators.js` marks its abort listener weak with this. */
|
|
194
|
+
kWeakHandler: Symbol('kWeakHandler'),
|
|
195
|
+
/**
|
|
196
|
+
* Whether a thing is an `EventTarget`. `events.js` asks before it treats a
|
|
197
|
+
* value as one -- `once`, `on`, `getEventListeners` and `setMaxListeners`
|
|
198
|
+
* all take either an emitter or a target. Node's own `EventTarget` is a
|
|
199
|
+
* class in `internal/event_target.js`; the engine's is the realm's, which
|
|
200
|
+
* is where that class comes from in the first place.
|
|
201
|
+
*/
|
|
202
|
+
isEventTarget: (value: unknown): boolean =>
|
|
203
|
+
typeof EventTarget === 'function' && value instanceof EventTarget,
|
|
204
|
+
/**
|
|
205
|
+
* The map Node keeps its own EventTarget's listeners in.
|
|
206
|
+
*
|
|
207
|
+
* THE LOSS, named: the realm's `EventTarget` keeps its listeners where no
|
|
208
|
+
* JavaScript can reach them. The DOM has no way to ask what is listening --
|
|
209
|
+
* `addEventListener` is a door in, and there is no door out -- so
|
|
210
|
+
* `events.getEventListeners(target)` cannot answer for one. It reads this
|
|
211
|
+
* map unguarded, so every target answers with an empty one: the call
|
|
212
|
+
* reports no listeners rather than throwing at a program that asked a fair
|
|
213
|
+
* question. An `EventEmitter` is unaffected; it answers from its own
|
|
214
|
+
* `listeners()`, which is the branch above this one in `events.js`.
|
|
215
|
+
*/
|
|
216
|
+
kEvents: kEventsSymbol,
|
|
217
|
+
kNewListener: Symbol('kNewListener'),
|
|
218
|
+
kRemoveListener: Symbol('kRemoveListener'),
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* `internal/options`: the command-line options Node's `net` reads. The engine
|
|
223
|
+
* takes no command line of its own, so each is Node's own default.
|
|
224
|
+
*/
|
|
225
|
+
const optionValues: Record<string, unknown> = {
|
|
226
|
+
'--network-family-autoselection': true,
|
|
227
|
+
'--network-family-autoselection-attempt-timeout': 250,
|
|
228
|
+
'--no-deprecation': false,
|
|
229
|
+
'--throw-deprecation': false,
|
|
230
|
+
'--trace-deprecation': false,
|
|
231
|
+
'--pending-deprecation': false,
|
|
232
|
+
'--report-uncaught-exception': false,
|
|
233
|
+
'--experimental-print-required-tla': false,
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export const internalOptions = {
|
|
237
|
+
getOptionValue: (name: string): unknown => optionValues[name],
|
|
238
|
+
getEmbedderOptions: () => ({ shouldNotRegisterESMLoader: false, noGlobalSearchPaths: false, noBrowserGlobals: false }),
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/** `internal/perf/observe`: nothing observes `net` in the engine. */
|
|
242
|
+
export const internalPerfObserve = {
|
|
243
|
+
hasObserver: (): boolean => false,
|
|
244
|
+
startPerf: (): void => {},
|
|
245
|
+
stopPerf: (): void => {},
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/** `internal/assert`: Node's internal assertion, which no program should ever see. */
|
|
249
|
+
export function internalAssert(value: unknown, message?: string): asserts value {
|
|
250
|
+
if (!value) throw new Error(`Internal assertion failed${message ? `: ${message}` : ''}`);
|
|
251
|
+
}
|
|
252
|
+
internalAssert.fail = (message?: string): never => {
|
|
253
|
+
throw new Error(`Internal assertion failed${message ? `: ${message}` : ''}`);
|
|
254
|
+
};
|
|
255
|
+
internalAssert.ok = internalAssert;
|
|
256
|
+
|
|
257
|
+
/** `internal/v8/startup_snapshot`: the engine never builds one. */
|
|
258
|
+
export const internalStartupSnapshot = {
|
|
259
|
+
namespace: {
|
|
260
|
+
isBuildingSnapshot: (): boolean => false,
|
|
261
|
+
addSerializeCallback: (): void => {},
|
|
262
|
+
addDeserializeCallback: (): void => {},
|
|
263
|
+
setDeserializeMainFunction: (): void => {},
|
|
264
|
+
},
|
|
265
|
+
runDeserializeCallbacks: (): void => {},
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* `internal/process/permission`: the engine runs no permission model, so
|
|
270
|
+
* nothing is denied and there are no flags for `child_process.js` to copy
|
|
271
|
+
* into a child's `NODE_OPTIONS`.
|
|
272
|
+
*/
|
|
273
|
+
export const internalPermission = {
|
|
274
|
+
isEnabled: (): boolean => false,
|
|
275
|
+
has: (): boolean => true,
|
|
276
|
+
availableFlags: (): string[] => [],
|
|
277
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `internal/util/types`, bound by hand -- which is also `util.types`, because
|
|
3
|
+
* Node's `util.types` IS this module.
|
|
4
|
+
*
|
|
5
|
+
* Node's own is `internalBinding('types')`, V8 asking a value what it is from
|
|
6
|
+
* the outside. The engine asks the one question a tab can ask: the value's
|
|
7
|
+
* own `Object.prototype.toString` tag, which V8 fills in from the same
|
|
8
|
+
* internal type and which a program cannot forge without saying so. A
|
|
9
|
+
* `Symbol.toStringTag` a program sets IS such a statement, and Node's answer
|
|
10
|
+
* and this one differ only for an object that has lied about itself.
|
|
11
|
+
*
|
|
12
|
+
* Two exceptions, each for a reason a tab cannot get around:
|
|
13
|
+
*
|
|
14
|
+
* A `Proxy` shows the tag of the thing it wraps, by design, so no tag can
|
|
15
|
+
* find one. The engine's realm records every proxy it makes -- `runtime.ts`
|
|
16
|
+
* replaces the realm's `Proxy` for a guest -- and `isProxy` answers from that
|
|
17
|
+
* record. undici's `Headers` guard asks it of every init it converts, and a
|
|
18
|
+
* proxy the host made before the guest's realm existed is not in the record.
|
|
19
|
+
*
|
|
20
|
+
* `isExternal` is always false: nothing in a tab is a native handle.
|
|
21
|
+
*
|
|
22
|
+
* `internal/util` itself is no longer here: it is Node's own file now, and
|
|
23
|
+
* every name the vendored files used to take from a hand-bound object is
|
|
24
|
+
* Node's own code, on the bindings under `../binding/`.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Every proxy a guest's realm has made. `runtime.ts` fills it, from the
|
|
29
|
+
* `Proxy` it installs for a guest; this module reads it.
|
|
30
|
+
*/
|
|
31
|
+
export const recordedProxies = new WeakSet<object>();
|
|
32
|
+
|
|
33
|
+
const tagOf = (value: unknown): string => Object.prototype.toString.call(value);
|
|
34
|
+
|
|
35
|
+
/** The `size` getters, which need a real Map or Set behind `this`. */
|
|
36
|
+
const mapSize = Object.getOwnPropertyDescriptor(Map.prototype, 'size')?.get as () => number;
|
|
37
|
+
const setSize = Object.getOwnPropertyDescriptor(Set.prototype, 'size')?.get as () => number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether a value carries the internal slot a built-in method needs. Calling
|
|
41
|
+
* the method is the only test of a slot JavaScript has, and a value without
|
|
42
|
+
* one throws rather than answering -- which is the answer.
|
|
43
|
+
*/
|
|
44
|
+
function hasSlot(value: unknown, method: (...args: never[]) => unknown, args: unknown[] = []): boolean {
|
|
45
|
+
if (value === null || (typeof value !== 'object' && typeof value !== 'function')) return false;
|
|
46
|
+
try { (method as (...a: unknown[]) => unknown).apply(value, args); return true; } catch { return false; }
|
|
47
|
+
}
|
|
48
|
+
const taggedAs = (tag: string) => (value: unknown): boolean => tagOf(value) === tag;
|
|
49
|
+
|
|
50
|
+
/** `internal/util/types`, which is `util.types`. */
|
|
51
|
+
export const internalUtilTypes: Record<string, (value: unknown) => boolean> = {
|
|
52
|
+
isArgumentsObject: taggedAs('[object Arguments]'),
|
|
53
|
+
isArrayBuffer: taggedAs('[object ArrayBuffer]'),
|
|
54
|
+
isSharedArrayBuffer: taggedAs('[object SharedArrayBuffer]'),
|
|
55
|
+
isAnyArrayBuffer: (value) => tagOf(value) === '[object ArrayBuffer]' || tagOf(value) === '[object SharedArrayBuffer]',
|
|
56
|
+
isArrayBufferView: (value) => ArrayBuffer.isView(value),
|
|
57
|
+
isDataView: taggedAs('[object DataView]'),
|
|
58
|
+
isTypedArray: (value) => ArrayBuffer.isView(value) && tagOf(value) !== '[object DataView]',
|
|
59
|
+
isUint8Array: taggedAs('[object Uint8Array]'),
|
|
60
|
+
isAsyncFunction: taggedAs('[object AsyncFunction]'),
|
|
61
|
+
isGeneratorFunction: (value) => tagOf(value) === '[object GeneratorFunction]' || tagOf(value) === '[object AsyncGeneratorFunction]',
|
|
62
|
+
isGeneratorObject: (value) => tagOf(value) === '[object Generator]' || tagOf(value) === '[object AsyncGenerator]',
|
|
63
|
+
isRegExp: taggedAs('[object RegExp]'),
|
|
64
|
+
isMapIterator: taggedAs('[object Map Iterator]'),
|
|
65
|
+
isSetIterator: taggedAs('[object Set Iterator]'),
|
|
66
|
+
isModuleNamespaceObject: taggedAs('[object Module]'),
|
|
67
|
+
isPromise: taggedAs('[object Promise]'),
|
|
68
|
+
isNativeError: (value) => value instanceof Error && tagOf(value) === '[object Error]',
|
|
69
|
+
// A boxed primitive is asked the one question only a real one can answer:
|
|
70
|
+
// its own prototype's `valueOf` needs the internal slot and throws without
|
|
71
|
+
// it. A tag would say yes to `Object.create(String.prototype)`, which has
|
|
72
|
+
// no slot at all, and `isDeepStrictEqual` then compared it as a string and
|
|
73
|
+
// threw where Node answered.
|
|
74
|
+
isBooleanObject: (value) => hasSlot(value, Boolean.prototype.valueOf),
|
|
75
|
+
isNumberObject: (value) => hasSlot(value, Number.prototype.valueOf),
|
|
76
|
+
isStringObject: (value) => hasSlot(value, String.prototype.valueOf),
|
|
77
|
+
isSymbolObject: (value) => hasSlot(value, Symbol.prototype.valueOf),
|
|
78
|
+
isBigIntObject: (value) => hasSlot(value, BigInt.prototype.valueOf),
|
|
79
|
+
isDate: (value) => hasSlot(value, Date.prototype.valueOf),
|
|
80
|
+
isMap: (value) => hasSlot(value, mapSize),
|
|
81
|
+
isSet: (value) => hasSlot(value, setSize),
|
|
82
|
+
isWeakMap: (value) => hasSlot(value, WeakMap.prototype.has, ['x']),
|
|
83
|
+
isWeakSet: (value) => hasSlot(value, WeakSet.prototype.has, ['x']),
|
|
84
|
+
isKeyObject: () => false,
|
|
85
|
+
isCryptoKey: (value) => typeof CryptoKey !== 'undefined' && value instanceof CryptoKey,
|
|
86
|
+
isExternal: () => false,
|
|
87
|
+
isProxy: (value) => (typeof value === 'object' || typeof value === 'function') && value !== null && recordedProxies.has(value as object),
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
internalUtilTypes.isBoxedPrimitive = (value) =>
|
|
91
|
+
internalUtilTypes.isBooleanObject(value) || internalUtilTypes.isNumberObject(value) ||
|
|
92
|
+
internalUtilTypes.isStringObject(value) || internalUtilTypes.isSymbolObject(value) ||
|
|
93
|
+
internalUtilTypes.isBigIntObject(value);
|
|
94
|
+
|
|
95
|
+
for (const name of ['Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'Int8Array', 'Int16Array',
|
|
96
|
+
'Int32Array', 'Float16Array', 'Float32Array', 'Float64Array', 'BigInt64Array', 'BigUint64Array']) {
|
|
97
|
+
internalUtilTypes[`is${name}`] = taggedAs(`[object ${name}]`);
|
|
98
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A vendored Node module, and a class out of one, named before the loader can
|
|
3
|
+
* build it.
|
|
4
|
+
*
|
|
5
|
+
* The engine's own TypeScript imports `Buffer` and `Readable` the way any
|
|
6
|
+
* program does -- as values, at the top of a file. But `buffer` and `stream`
|
|
7
|
+
* are vendored Node files that `./load.ts` builds out of the binding and the
|
|
8
|
+
* internals, and several of the engine's own shims are what that loader
|
|
9
|
+
* resolves a public name to: the two sit in one import cycle, and which side a
|
|
10
|
+
* bundler evaluates first is its own decision, not a thing the source can
|
|
11
|
+
* state. Taking the class at import time therefore failed to load the engine
|
|
12
|
+
* at all, differently on each build.
|
|
13
|
+
*
|
|
14
|
+
* So a name here stands for the thing rather than being it, until the first
|
|
15
|
+
* time anyone touches it. `Buffer.from(…)` is one property read through a
|
|
16
|
+
* proxy and then the real call; `x instanceof Buffer` reads the real class's
|
|
17
|
+
* `Symbol.hasInstance`; `new Readable()` constructs the real one. Node's own
|
|
18
|
+
* files never go through this -- they `require('buffer')` and get the class.
|
|
19
|
+
*/
|
|
20
|
+
// The loader itself, not the hook a binding uses: importing it is what puts
|
|
21
|
+
// it in the graph at all, so a program that only ever touches `Readable`
|
|
22
|
+
// still has a loader to build it with.
|
|
23
|
+
import { nodeLibInternalRequire } from './load';
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/** The module a name stands for, loaded once, on the first property read. */
|
|
27
|
+
function loadedModule(name: string, cache: { value?: Record<string, unknown> }): Record<string, unknown> {
|
|
28
|
+
return cache.value ??= nodeLibInternalRequire(name) as Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A vendored module object, whose properties are read when they are asked for.
|
|
33
|
+
*
|
|
34
|
+
* A module object is a program's to write on, and packages do: `graceful-fs`
|
|
35
|
+
* -- which half of npm loads, openvscode-server through `fs-extra` and
|
|
36
|
+
* `@vscode/deviceid` -- defines `Symbol.for('graceful-fs.queue')` on `fs` with
|
|
37
|
+
* `Object.defineProperty` and then clones the module, which walks its keys.
|
|
38
|
+
* Every trap here read the loaded module and none read the proxy's own target,
|
|
39
|
+
* where a define with no trap of its own lands: the read came back
|
|
40
|
+
* `undefined`, `key in fs` answered false, and `Reflect.ownKeys(fs)` threw
|
|
41
|
+
* `'ownKeys' on proxy: trap result did not include
|
|
42
|
+
* 'Symbol(graceful-fs.queue)'` -- a proxy may neither hide nor deny a
|
|
43
|
+
* non-configurable own key of its target. graceful-fs threw out of its own
|
|
44
|
+
* module load, so every program that loads it died there: in the substrate's
|
|
45
|
+
* tab, openvscode-server's server at boot and its extension host, which exited
|
|
46
|
+
* 1 without a word because a forked host's console goes to its parent over IPC
|
|
47
|
+
* and the server drops those messages.
|
|
48
|
+
*
|
|
49
|
+
* So a define lands on the module, as it would in Node, and a
|
|
50
|
+
* non-configurable one lands on the target as well because the proxy has to
|
|
51
|
+
* report it from there; every read answers the target first and the module
|
|
52
|
+
* after. This is the shape the guest global's proxy in `src/runtime.ts` uses,
|
|
53
|
+
* for the same reason.
|
|
54
|
+
*/
|
|
55
|
+
export function lazyModule<T extends object>(name: string): T {
|
|
56
|
+
const cache: { value?: Record<string, unknown> } = {};
|
|
57
|
+
const own = (target: object, key: PropertyKey): boolean =>
|
|
58
|
+
Reflect.getOwnPropertyDescriptor(target, key) !== undefined;
|
|
59
|
+
return new Proxy({} as T, {
|
|
60
|
+
get: (target, key, receiver) => (own(target, key)
|
|
61
|
+
? Reflect.get(target, key, receiver)
|
|
62
|
+
: Reflect.get(loadedModule(name, cache), key)),
|
|
63
|
+
set: (target, key, value, receiver) => (own(target, key)
|
|
64
|
+
? Reflect.set(target, key, value, receiver)
|
|
65
|
+
: Reflect.set(loadedModule(name, cache), key, value)),
|
|
66
|
+
has: (target, key) => own(target, key) || Reflect.has(loadedModule(name, cache), key),
|
|
67
|
+
defineProperty: (target, key, descriptor) => {
|
|
68
|
+
const module = loadedModule(name, cache);
|
|
69
|
+
if (descriptor.configurable === false) {
|
|
70
|
+
if (!Reflect.defineProperty(target, key, descriptor)) return false;
|
|
71
|
+
Reflect.defineProperty(module, key, { ...descriptor, configurable: true });
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return Reflect.defineProperty(module, key, descriptor)
|
|
75
|
+
|| Reflect.defineProperty(target, key, descriptor);
|
|
76
|
+
},
|
|
77
|
+
deleteProperty: (target, key) => {
|
|
78
|
+
if (own(target, key) && !Reflect.deleteProperty(target, key)) return false;
|
|
79
|
+
return Reflect.deleteProperty(loadedModule(name, cache), key);
|
|
80
|
+
},
|
|
81
|
+
ownKeys: (target) => {
|
|
82
|
+
const keys = Reflect.ownKeys(target);
|
|
83
|
+
for (const key of Reflect.ownKeys(loadedModule(name, cache))) if (!keys.includes(key)) keys.push(key);
|
|
84
|
+
return keys;
|
|
85
|
+
},
|
|
86
|
+
getOwnPropertyDescriptor: (target, key) => {
|
|
87
|
+
const mine = Reflect.getOwnPropertyDescriptor(target, key);
|
|
88
|
+
if (mine !== undefined) return mine;
|
|
89
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(loadedModule(name, cache), key);
|
|
90
|
+
return descriptor === undefined ? undefined : { ...descriptor, configurable: true };
|
|
91
|
+
},
|
|
92
|
+
}) as T;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* One export of a vendored module that is a class or a function: callable,
|
|
97
|
+
* constructible, and the same object to `instanceof` as the real one.
|
|
98
|
+
*/
|
|
99
|
+
export function lazyExport<T>(name: string, key: string): T {
|
|
100
|
+
const cache: { value?: Record<string, unknown> } = {};
|
|
101
|
+
// The prototype a subclass takes when it is DEFINED. `class Socket extends
|
|
102
|
+
// EventEmitter` reads `EventEmitter.prototype` at the moment the class is
|
|
103
|
+
// written, which is while the bundle is still evaluating -- before the
|
|
104
|
+
// loader, its bindings, or the shims those bindings read have run their own
|
|
105
|
+
// bodies, and several of them are in one import cycle with this file (the
|
|
106
|
+
// `constants` binding reads the `crypto` shim, which is an EventEmitter).
|
|
107
|
+
// Loading there is not late, it is impossible. So a class defined that early
|
|
108
|
+
// is given this empty object as its parent prototype, and the first time the
|
|
109
|
+
// real class is built the object is grafted onto the real prototype: the
|
|
110
|
+
// subclass's chain becomes `Subclass.prototype -> stand -> EventEmitter.
|
|
111
|
+
// prototype`, so every method resolves and `instanceof` holds. After the
|
|
112
|
+
// graft the real prototype is what is handed out, so an instance Node's own
|
|
113
|
+
// code made is an instance of the same class to everyone.
|
|
114
|
+
const stand = Object.create(null) as object;
|
|
115
|
+
let grafted = false;
|
|
116
|
+
const real = (): object => {
|
|
117
|
+
const value = loadedModule(name, cache)[key] as object;
|
|
118
|
+
if (!grafted) {
|
|
119
|
+
grafted = true;
|
|
120
|
+
const prototype = (value as { prototype?: object }).prototype;
|
|
121
|
+
if (prototype) Object.setPrototypeOf(stand, prototype);
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
};
|
|
125
|
+
// A plain function is the target because it is the one thing that is both
|
|
126
|
+
// callable and constructible; nothing of it is ever read.
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
128
|
+
const target = function stand() {} as unknown as object;
|
|
129
|
+
return new Proxy(target, {
|
|
130
|
+
get: (_t, propertyKey, receiver) => {
|
|
131
|
+
// Before the real class exists, `prototype` is the stand-in above; from
|
|
132
|
+
// the first load on it is the real one.
|
|
133
|
+
if (propertyKey === 'prototype' && !grafted && !cache.value) return stand;
|
|
134
|
+
return Reflect.get(real(), propertyKey, receiver);
|
|
135
|
+
},
|
|
136
|
+
set: (_t, propertyKey, value) => Reflect.set(real(), propertyKey, value),
|
|
137
|
+
has: (_t, propertyKey) => Reflect.has(real(), propertyKey),
|
|
138
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(real()),
|
|
139
|
+
// A module whose exports IS this function -- `require("events")` is
|
|
140
|
+
// Node's `EventEmitter` -- is read as a module too: destructured,
|
|
141
|
+
// enumerated, asked for its own keys. The target's own `prototype`,
|
|
142
|
+
// `length` and `name` are non-configurable and must be reported as the
|
|
143
|
+
// target has them, so they are answered from the target and everything
|
|
144
|
+
// else from the real class.
|
|
145
|
+
ownKeys: () => {
|
|
146
|
+
const own = Reflect.ownKeys(target);
|
|
147
|
+
return [...Reflect.ownKeys(real()).filter((key) => !own.includes(key)), ...own];
|
|
148
|
+
},
|
|
149
|
+
getOwnPropertyDescriptor: (_t, propertyKey) => {
|
|
150
|
+
const fromTarget = Reflect.getOwnPropertyDescriptor(target, propertyKey);
|
|
151
|
+
if (fromTarget !== undefined) return fromTarget;
|
|
152
|
+
const own = Reflect.getOwnPropertyDescriptor(real(), propertyKey);
|
|
153
|
+
return own === undefined ? undefined : { ...own, configurable: true };
|
|
154
|
+
},
|
|
155
|
+
apply: (_t, thisArg, args) => Reflect.apply(real() as (...a: unknown[]) => unknown, thisArg, args as unknown[]),
|
|
156
|
+
construct: (_t, args, newTarget) => Reflect.construct(real() as new (...a: unknown[]) => object, args as unknown[], newTarget === target ? (real() as new (...a: unknown[]) => object) : newTarget),
|
|
157
|
+
}) as T;
|
|
158
|
+
}
|