@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,406 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
ArrayPrototypeFindIndex,
|
|
5
|
+
ArrayPrototypePush,
|
|
6
|
+
ArrayPrototypeSplice,
|
|
7
|
+
ObjectAssign,
|
|
8
|
+
ObjectFreeze,
|
|
9
|
+
StringPrototypeSlice,
|
|
10
|
+
StringPrototypeStartsWith,
|
|
11
|
+
Symbol,
|
|
12
|
+
} = primordials;
|
|
13
|
+
const {
|
|
14
|
+
isAnyArrayBuffer,
|
|
15
|
+
isArrayBufferView,
|
|
16
|
+
} = require('internal/util/types');
|
|
17
|
+
|
|
18
|
+
const { BuiltinModule } = require('internal/bootstrap/realm');
|
|
19
|
+
const {
|
|
20
|
+
ERR_INVALID_RETURN_PROPERTY_VALUE,
|
|
21
|
+
} = require('internal/errors').codes;
|
|
22
|
+
const { validateFunction } = require('internal/validators');
|
|
23
|
+
const { isAbsolute } = require('path');
|
|
24
|
+
const { pathToFileURL, fileURLToPath } = require('internal/url');
|
|
25
|
+
|
|
26
|
+
let debug = require('internal/util/debuglog').debuglog('module_hooks', (fn) => {
|
|
27
|
+
debug = fn;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {import('internal/modules/cjs/loader.js').Module} Module
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {(
|
|
35
|
+
* specifier: string,
|
|
36
|
+
* context: Partial<ModuleResolveContext>,
|
|
37
|
+
* ) => ModuleResolveResult
|
|
38
|
+
* } NextResolve
|
|
39
|
+
* @typedef {(
|
|
40
|
+
* specifier: string,
|
|
41
|
+
* context: ModuleResolveContext,
|
|
42
|
+
* nextResolve: NextResolve,
|
|
43
|
+
* ) => ModuleResolveResult
|
|
44
|
+
* } ResolveHook
|
|
45
|
+
* @typedef {(
|
|
46
|
+
* url: string,
|
|
47
|
+
* context: Partial<ModuleLoadContext>,
|
|
48
|
+
* ) => ModuleLoadResult
|
|
49
|
+
* } NextLoad
|
|
50
|
+
* @typedef {(
|
|
51
|
+
* url: string,
|
|
52
|
+
* context: ModuleLoadContext,
|
|
53
|
+
* nextLoad: NextLoad,
|
|
54
|
+
* ) => ModuleLoadResult
|
|
55
|
+
* } LoadHook
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
// Use arrays for better insertion and iteration performance, we don't care
|
|
59
|
+
// about deletion performance as much.
|
|
60
|
+
|
|
61
|
+
/** @type {ResolveHook[]} */
|
|
62
|
+
const resolveHooks = [];
|
|
63
|
+
/** @type {LoadHook[]} */
|
|
64
|
+
const loadHooks = [];
|
|
65
|
+
const hookId = Symbol('kModuleHooksIdKey');
|
|
66
|
+
let nextHookId = 0;
|
|
67
|
+
|
|
68
|
+
class ModuleHooks {
|
|
69
|
+
/**
|
|
70
|
+
* @param {ResolveHook|undefined} resolve User-provided hook.
|
|
71
|
+
* @param {LoadHook|undefined} load User-provided hook.
|
|
72
|
+
*/
|
|
73
|
+
constructor(resolve, load) {
|
|
74
|
+
this[hookId] = Symbol(`module-hook-${nextHookId++}`);
|
|
75
|
+
// Always initialize all hooks, if it's unspecified it'll be an owned undefined.
|
|
76
|
+
this.resolve = resolve;
|
|
77
|
+
this.load = load;
|
|
78
|
+
|
|
79
|
+
if (resolve) {
|
|
80
|
+
ArrayPrototypePush(resolveHooks, this);
|
|
81
|
+
}
|
|
82
|
+
if (load) {
|
|
83
|
+
ArrayPrototypePush(loadHooks, this);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
ObjectFreeze(this);
|
|
87
|
+
}
|
|
88
|
+
// TODO(joyeecheung): we may want methods that allow disabling/enabling temporarily
|
|
89
|
+
// which just sets the item in the array to undefined temporarily.
|
|
90
|
+
// TODO(joyeecheung): this can be the [Symbol.dispose] implementation to pair with
|
|
91
|
+
// `using` when the explicit resource management proposal is shipped by V8.
|
|
92
|
+
/**
|
|
93
|
+
* Deregister the hook instance.
|
|
94
|
+
*/
|
|
95
|
+
deregister() {
|
|
96
|
+
const id = this[hookId];
|
|
97
|
+
let index = ArrayPrototypeFindIndex(resolveHooks, (hook) => hook[hookId] === id);
|
|
98
|
+
if (index !== -1) {
|
|
99
|
+
ArrayPrototypeSplice(resolveHooks, index, 1);
|
|
100
|
+
}
|
|
101
|
+
index = ArrayPrototypeFindIndex(loadHooks, (hook) => hook[hookId] === id);
|
|
102
|
+
if (index !== -1) {
|
|
103
|
+
ArrayPrototypeSplice(loadHooks, index, 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* TODO(joyeecheung): taken an optional description?
|
|
110
|
+
* @param {{ resolve?: ResolveHook, load?: LoadHook }} hooks User-provided hooks
|
|
111
|
+
* @returns {ModuleHooks}
|
|
112
|
+
*/
|
|
113
|
+
function registerHooks(hooks) {
|
|
114
|
+
const { resolve, load } = hooks;
|
|
115
|
+
if (resolve) {
|
|
116
|
+
validateFunction(resolve, 'hooks.resolve');
|
|
117
|
+
}
|
|
118
|
+
if (load) {
|
|
119
|
+
validateFunction(load, 'hooks.load');
|
|
120
|
+
}
|
|
121
|
+
return new ModuleHooks(resolve, load);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @param {string} filename
|
|
126
|
+
* @returns {string}
|
|
127
|
+
*/
|
|
128
|
+
function convertCJSFilenameToURL(filename) {
|
|
129
|
+
if (!filename) { return filename; }
|
|
130
|
+
let normalizedId = filename;
|
|
131
|
+
if (StringPrototypeStartsWith(filename, 'node:')) {
|
|
132
|
+
normalizedId = StringPrototypeSlice(filename, 5);
|
|
133
|
+
}
|
|
134
|
+
if (BuiltinModule.canBeRequiredByUsers(normalizedId)) {
|
|
135
|
+
return `node:${normalizedId}`;
|
|
136
|
+
}
|
|
137
|
+
// Handle the case where filename is neither a path, nor a built-in id,
|
|
138
|
+
// which is possible via monkey-patching.
|
|
139
|
+
if (isAbsolute(filename)) {
|
|
140
|
+
return pathToFileURL(filename).href;
|
|
141
|
+
}
|
|
142
|
+
return filename;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @param {string} url
|
|
147
|
+
* @returns {string}
|
|
148
|
+
*/
|
|
149
|
+
function convertURLToCJSFilename(url) {
|
|
150
|
+
if (!url) { return url; }
|
|
151
|
+
const builtinId = BuiltinModule.normalizeRequirableId(url);
|
|
152
|
+
if (builtinId) {
|
|
153
|
+
return builtinId;
|
|
154
|
+
}
|
|
155
|
+
if (StringPrototypeStartsWith(url, 'file://')) {
|
|
156
|
+
return fileURLToPath(url);
|
|
157
|
+
}
|
|
158
|
+
return url;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Convert a list of hooks into a function that can be used to do an operation through
|
|
163
|
+
* a chain of hooks. If any of the hook returns without calling the next hook, it
|
|
164
|
+
* must return shortCircuit: true to stop the chain from continuing to avoid
|
|
165
|
+
* forgetting to invoke the next hook by mistake.
|
|
166
|
+
* @param {ModuleHooks[]} hooks A list of hooks whose last argument is `nextHook`.
|
|
167
|
+
* @param {'load'|'resolve'} name Name of the hook in ModuleHooks.
|
|
168
|
+
* @param {Function} defaultStep The default step in the chain.
|
|
169
|
+
* @param {Function} validate A function that validates and sanitize the result returned by the chain.
|
|
170
|
+
*/
|
|
171
|
+
function buildHooks(hooks, name, defaultStep, validate, mergedContext) {
|
|
172
|
+
let lastRunIndex = hooks.length;
|
|
173
|
+
/**
|
|
174
|
+
* Helper function to wrap around invocation of user hook or the default step
|
|
175
|
+
* in order to fill in missing arguments or check returned results.
|
|
176
|
+
* Due to the merging of the context, this must be a closure.
|
|
177
|
+
* @param {number} index Index in the chain. Default step is 0, last added hook is 1,
|
|
178
|
+
* and so on.
|
|
179
|
+
* @param {Function} userHookOrDefault Either the user hook or the default step to invoke.
|
|
180
|
+
* @param {Function|undefined} next The next wrapped step. If this is the default step, it's undefined.
|
|
181
|
+
* @returns {Function} Wrapped hook or default step.
|
|
182
|
+
*/
|
|
183
|
+
function wrapHook(index, userHookOrDefault, next) {
|
|
184
|
+
return function nextStep(arg0, context) {
|
|
185
|
+
lastRunIndex = index;
|
|
186
|
+
if (context && context !== mergedContext) {
|
|
187
|
+
ObjectAssign(mergedContext, context);
|
|
188
|
+
}
|
|
189
|
+
const hookResult = userHookOrDefault(arg0, mergedContext, next);
|
|
190
|
+
if (lastRunIndex > 0 && lastRunIndex === index && !hookResult.shortCircuit) {
|
|
191
|
+
throw new ERR_INVALID_RETURN_PROPERTY_VALUE('true', name, 'shortCircuit',
|
|
192
|
+
hookResult.shortCircuit);
|
|
193
|
+
}
|
|
194
|
+
return validate(arg0, mergedContext, hookResult);
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const chain = [wrapHook(0, defaultStep)];
|
|
198
|
+
for (let i = 0; i < hooks.length; ++i) {
|
|
199
|
+
const wrappedHook = wrapHook(i + 1, hooks[i][name], chain[i]);
|
|
200
|
+
ArrayPrototypePush(chain, wrappedHook);
|
|
201
|
+
}
|
|
202
|
+
return chain[chain.length - 1];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @typedef {object} ModuleResolveResult
|
|
207
|
+
* @property {string} url Resolved URL of the module.
|
|
208
|
+
* @property {string|undefined} format Format of the module.
|
|
209
|
+
* @property {ImportAttributes|undefined} importAttributes Import attributes for the request.
|
|
210
|
+
* @property {boolean|undefined} shortCircuit Whether the next hook has been skipped.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Validate the result returned by a chain of resolve hook.
|
|
215
|
+
* @param {string} specifier Specifier passed into the hooks.
|
|
216
|
+
* @param {ModuleResolveContext} context Context passed into the hooks.
|
|
217
|
+
* @param {ModuleResolveResult} result Result produced by resolve hooks.
|
|
218
|
+
* @returns {ModuleResolveResult}
|
|
219
|
+
*/
|
|
220
|
+
function validateResolve(specifier, context, result) {
|
|
221
|
+
const { url, format, importAttributes } = result;
|
|
222
|
+
if (typeof url !== 'string') {
|
|
223
|
+
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(
|
|
224
|
+
'a URL string',
|
|
225
|
+
'resolve',
|
|
226
|
+
'url',
|
|
227
|
+
url,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (format && typeof format !== 'string') {
|
|
232
|
+
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(
|
|
233
|
+
'a string',
|
|
234
|
+
'resolve',
|
|
235
|
+
'format',
|
|
236
|
+
format,
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (importAttributes && typeof importAttributes !== 'object') {
|
|
241
|
+
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(
|
|
242
|
+
'an object',
|
|
243
|
+
'resolve',
|
|
244
|
+
'importAttributes',
|
|
245
|
+
importAttributes,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
__proto__: null,
|
|
251
|
+
url,
|
|
252
|
+
format,
|
|
253
|
+
importAttributes,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @typedef {object} ModuleLoadResult
|
|
259
|
+
* @property {string|undefined} format Format of the loaded module.
|
|
260
|
+
* @property {string|ArrayBuffer|TypedArray} source Source code of the module.
|
|
261
|
+
* @property {boolean|undefined} shortCircuit Whether the next hook has been skipped.
|
|
262
|
+
*/
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Validate the result returned by a chain of resolve hook.
|
|
266
|
+
* @param {string} url URL passed into the hooks.
|
|
267
|
+
* @param {ModuleLoadContext} context Context passed into the hooks.
|
|
268
|
+
* @param {ModuleLoadResult} result Result produced by load hooks.
|
|
269
|
+
* @returns {ModuleLoadResult}
|
|
270
|
+
*/
|
|
271
|
+
function validateLoad(url, context, result) {
|
|
272
|
+
const { source, format } = result;
|
|
273
|
+
// To align with module.register(), the load hooks are still invoked for
|
|
274
|
+
// the builtins even though the default load step only provides null as source,
|
|
275
|
+
// and any source content for builtins provided by the user hooks are ignored.
|
|
276
|
+
if (!StringPrototypeStartsWith(url, 'node:') &&
|
|
277
|
+
typeof result.source !== 'string' &&
|
|
278
|
+
!isAnyArrayBuffer(source) &&
|
|
279
|
+
!isArrayBufferView(source)) {
|
|
280
|
+
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(
|
|
281
|
+
'a string, an ArrayBuffer, or a TypedArray',
|
|
282
|
+
'load',
|
|
283
|
+
'source',
|
|
284
|
+
source,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (typeof format !== 'string' && format !== undefined) {
|
|
289
|
+
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(
|
|
290
|
+
'a string',
|
|
291
|
+
'load',
|
|
292
|
+
'format',
|
|
293
|
+
format,
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return {
|
|
298
|
+
__proto__: null,
|
|
299
|
+
format,
|
|
300
|
+
source,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
class ModuleResolveContext {
|
|
305
|
+
/**
|
|
306
|
+
* Context for the resolve hook.
|
|
307
|
+
* @param {string|undefined} parentURL Parent URL.
|
|
308
|
+
* @param {ImportAttributes|undefined} importAttributes Import attributes.
|
|
309
|
+
* @param {string[]} conditions Conditions.
|
|
310
|
+
*/
|
|
311
|
+
constructor(parentURL, importAttributes, conditions) {
|
|
312
|
+
this.parentURL = parentURL;
|
|
313
|
+
this.importAttributes = importAttributes;
|
|
314
|
+
this.conditions = conditions;
|
|
315
|
+
// TODO(joyeecheung): a field to differentiate between require and import?
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
class ModuleLoadContext {
|
|
320
|
+
/**
|
|
321
|
+
* Context for the load hook.
|
|
322
|
+
* @param {string|undefined} format URL.
|
|
323
|
+
* @param {ImportAttributes|undefined} importAttributes Import attributes.
|
|
324
|
+
* @param {string[]} conditions Conditions.
|
|
325
|
+
*/
|
|
326
|
+
constructor(format, importAttributes, conditions) {
|
|
327
|
+
this.format = format;
|
|
328
|
+
this.importAttributes = importAttributes;
|
|
329
|
+
this.conditions = conditions;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
let decoder;
|
|
334
|
+
/**
|
|
335
|
+
* Load module source for a url, through a hooks chain if it exists.
|
|
336
|
+
* @param {string} url
|
|
337
|
+
* @param {string|undefined} originalFormat
|
|
338
|
+
* @param {ImportAttributes|undefined} importAttributes
|
|
339
|
+
* @param {string[]} conditions
|
|
340
|
+
* @param {(url: string, context: ModuleLoadContext) => ModuleLoadResult} defaultLoad
|
|
341
|
+
* @returns {ModuleLoadResult}
|
|
342
|
+
*/
|
|
343
|
+
function loadWithHooks(url, originalFormat, importAttributes, conditions, defaultLoad) {
|
|
344
|
+
debug('loadWithHooks', url, originalFormat);
|
|
345
|
+
const context = new ModuleLoadContext(originalFormat, importAttributes, conditions);
|
|
346
|
+
if (loadHooks.length === 0) {
|
|
347
|
+
return defaultLoad(url, context);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const runner = buildHooks(loadHooks, 'load', defaultLoad, validateLoad, context);
|
|
351
|
+
|
|
352
|
+
const result = runner(url, context);
|
|
353
|
+
const { source, format } = result;
|
|
354
|
+
if (!isAnyArrayBuffer(source) && !isArrayBufferView(source)) {
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
switch (format) {
|
|
359
|
+
// Text formats:
|
|
360
|
+
case undefined:
|
|
361
|
+
case 'module':
|
|
362
|
+
case 'commonjs':
|
|
363
|
+
case 'json':
|
|
364
|
+
case 'module-typescript':
|
|
365
|
+
case 'commonjs-typescript':
|
|
366
|
+
case 'typescript': {
|
|
367
|
+
decoder ??= new (require('internal/encoding').TextDecoder)();
|
|
368
|
+
result.source = decoder.decode(source);
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
default:
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
return result;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Resolve module request to a url, through a hooks chain if it exists.
|
|
379
|
+
* @param {string} specifier
|
|
380
|
+
* @param {string|undefined} parentURL
|
|
381
|
+
* @param {ImportAttributes|undefined} importAttributes
|
|
382
|
+
* @param {string[]} conditions
|
|
383
|
+
* @param {(specifier: string, context: ModuleResolveContext) => ModuleResolveResult} defaultResolve
|
|
384
|
+
* @returns {ModuleResolveResult}
|
|
385
|
+
*/
|
|
386
|
+
function resolveWithHooks(specifier, parentURL, importAttributes, conditions, defaultResolve) {
|
|
387
|
+
debug('resolveWithHooks', specifier, parentURL, importAttributes);
|
|
388
|
+
const context = new ModuleResolveContext(parentURL, importAttributes, conditions);
|
|
389
|
+
if (resolveHooks.length === 0) {
|
|
390
|
+
return defaultResolve(specifier, context);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const runner = buildHooks(resolveHooks, 'resolve', defaultResolve, validateResolve, context);
|
|
394
|
+
|
|
395
|
+
return runner(specifier, context);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
module.exports = {
|
|
399
|
+
convertCJSFilenameToURL,
|
|
400
|
+
convertURLToCJSFilename,
|
|
401
|
+
loadHooks,
|
|
402
|
+
loadWithHooks,
|
|
403
|
+
registerHooks,
|
|
404
|
+
resolveHooks,
|
|
405
|
+
resolveWithHooks,
|
|
406
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
RegExp,
|
|
5
|
+
RegExpPrototypeTest,
|
|
6
|
+
Symbol,
|
|
7
|
+
} = primordials;
|
|
8
|
+
|
|
9
|
+
const Buffer = require('buffer').Buffer;
|
|
10
|
+
const { writeBuffer } = internalBinding('fs');
|
|
11
|
+
const {
|
|
12
|
+
UVException,
|
|
13
|
+
} = require('internal/errors');
|
|
14
|
+
|
|
15
|
+
// IPv4 Segment
|
|
16
|
+
const v4Seg = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])';
|
|
17
|
+
const v4Str = `(?:${v4Seg}\\.){3}${v4Seg}`;
|
|
18
|
+
const IPv4Reg = new RegExp(`^${v4Str}$`);
|
|
19
|
+
|
|
20
|
+
// IPv6 Segment
|
|
21
|
+
const v6Seg = '(?:[0-9a-fA-F]{1,4})';
|
|
22
|
+
const IPv6Reg = new RegExp('^(?:' +
|
|
23
|
+
`(?:${v6Seg}:){7}(?:${v6Seg}|:)|` +
|
|
24
|
+
`(?:${v6Seg}:){6}(?:${v4Str}|:${v6Seg}|:)|` +
|
|
25
|
+
`(?:${v6Seg}:){5}(?::${v4Str}|(?::${v6Seg}){1,2}|:)|` +
|
|
26
|
+
`(?:${v6Seg}:){4}(?:(?::${v6Seg}){0,1}:${v4Str}|(?::${v6Seg}){1,3}|:)|` +
|
|
27
|
+
`(?:${v6Seg}:){3}(?:(?::${v6Seg}){0,2}:${v4Str}|(?::${v6Seg}){1,4}|:)|` +
|
|
28
|
+
`(?:${v6Seg}:){2}(?:(?::${v6Seg}){0,3}:${v4Str}|(?::${v6Seg}){1,5}|:)|` +
|
|
29
|
+
`(?:${v6Seg}:){1}(?:(?::${v6Seg}){0,4}:${v4Str}|(?::${v6Seg}){1,6}|:)|` +
|
|
30
|
+
`(?::(?:(?::${v6Seg}){0,5}:${v4Str}|(?::${v6Seg}){1,7}|:))` +
|
|
31
|
+
')(?:%[0-9a-zA-Z-.:]{1,})?$');
|
|
32
|
+
|
|
33
|
+
function isIPv4(s) {
|
|
34
|
+
// TODO(aduh95): Replace RegExpPrototypeTest with RegExpPrototypeExec when it
|
|
35
|
+
// no longer creates a perf regression in the dns benchmark.
|
|
36
|
+
// eslint-disable-next-line node-core/avoid-prototype-pollution
|
|
37
|
+
return RegExpPrototypeTest(IPv4Reg, s);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isIPv6(s) {
|
|
41
|
+
// TODO(aduh95): Replace RegExpPrototypeTest with RegExpPrototypeExec when it
|
|
42
|
+
// no longer creates a perf regression in the dns benchmark.
|
|
43
|
+
// eslint-disable-next-line node-core/avoid-prototype-pollution
|
|
44
|
+
return RegExpPrototypeTest(IPv6Reg, s);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function isIP(s) {
|
|
48
|
+
if (isIPv4(s)) return 4;
|
|
49
|
+
if (isIPv6(s)) return 6;
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function makeSyncWrite(fd) {
|
|
54
|
+
return function(chunk, enc, cb) {
|
|
55
|
+
if (enc !== 'buffer')
|
|
56
|
+
chunk = Buffer.from(chunk, enc);
|
|
57
|
+
|
|
58
|
+
this._handle.bytesWritten += chunk.length;
|
|
59
|
+
|
|
60
|
+
const ctx = {};
|
|
61
|
+
writeBuffer(fd, chunk, 0, chunk.length, null, undefined, ctx);
|
|
62
|
+
if (ctx.errno !== undefined) {
|
|
63
|
+
const ex = new UVException(ctx);
|
|
64
|
+
ex.errno = ctx.errno;
|
|
65
|
+
return cb(ex);
|
|
66
|
+
}
|
|
67
|
+
cb();
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
|
|
73
|
+
* https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
|
|
74
|
+
* https://www.iana.org/assignments/special-use-domain-names/special-use-domain-names.xhtml
|
|
75
|
+
*/
|
|
76
|
+
function isLoopback(host) {
|
|
77
|
+
const hostLower = host.toLowerCase();
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
hostLower === 'localhost' ||
|
|
81
|
+
hostLower.startsWith('127.') ||
|
|
82
|
+
hostLower.startsWith('[::1]') ||
|
|
83
|
+
hostLower.startsWith('[0:0:0:0:0:0:0:1]')
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
kReinitializeHandle: Symbol('kReinitializeHandle'),
|
|
89
|
+
isIP,
|
|
90
|
+
isIPv4,
|
|
91
|
+
isIPv6,
|
|
92
|
+
makeSyncWrite,
|
|
93
|
+
normalizedArgsSymbol: Symbol('normalizedArgs'),
|
|
94
|
+
isLoopback,
|
|
95
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
Array,
|
|
5
|
+
Int8Array,
|
|
6
|
+
NumberPrototypeToString,
|
|
7
|
+
StringPrototypeCharCodeAt,
|
|
8
|
+
StringPrototypeSlice,
|
|
9
|
+
StringPrototypeToUpperCase,
|
|
10
|
+
} = primordials;
|
|
11
|
+
|
|
12
|
+
const { ERR_INVALID_URI } = require('internal/errors').codes;
|
|
13
|
+
|
|
14
|
+
const hexTable = new Array(256);
|
|
15
|
+
for (let i = 0; i < 256; ++i)
|
|
16
|
+
hexTable[i] = '%' +
|
|
17
|
+
StringPrototypeToUpperCase((i < 16 ? '0' : '') +
|
|
18
|
+
NumberPrototypeToString(i, 16));
|
|
19
|
+
|
|
20
|
+
const isHexTable = new Int8Array([
|
|
21
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15
|
|
22
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31
|
|
23
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 32 - 47
|
|
24
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48 - 63
|
|
25
|
+
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 64 - 79
|
|
26
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80 - 95
|
|
27
|
+
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 96 - 111
|
|
28
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 112 - 127
|
|
29
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 128 ...
|
|
30
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
31
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
32
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
33
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
34
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
35
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
36
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ... 256
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {string} str
|
|
41
|
+
* @param {Int8Array} noEscapeTable
|
|
42
|
+
* @param {string[]} hexTable
|
|
43
|
+
* @returns {string}
|
|
44
|
+
*/
|
|
45
|
+
function encodeStr(str, noEscapeTable, hexTable) {
|
|
46
|
+
const len = str.length;
|
|
47
|
+
if (len === 0)
|
|
48
|
+
return '';
|
|
49
|
+
|
|
50
|
+
let out = '';
|
|
51
|
+
let lastPos = 0;
|
|
52
|
+
let i = 0;
|
|
53
|
+
|
|
54
|
+
outer:
|
|
55
|
+
for (; i < len; i++) {
|
|
56
|
+
let c = StringPrototypeCharCodeAt(str, i);
|
|
57
|
+
|
|
58
|
+
// ASCII
|
|
59
|
+
while (c < 0x80) {
|
|
60
|
+
if (noEscapeTable[c] !== 1) {
|
|
61
|
+
if (lastPos < i)
|
|
62
|
+
out += StringPrototypeSlice(str, lastPos, i);
|
|
63
|
+
lastPos = i + 1;
|
|
64
|
+
out += hexTable[c];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (++i === len)
|
|
68
|
+
break outer;
|
|
69
|
+
|
|
70
|
+
c = StringPrototypeCharCodeAt(str, i);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (lastPos < i)
|
|
74
|
+
out += StringPrototypeSlice(str, lastPos, i);
|
|
75
|
+
|
|
76
|
+
// Multi-byte characters ...
|
|
77
|
+
if (c < 0x800) {
|
|
78
|
+
lastPos = i + 1;
|
|
79
|
+
out += hexTable[0xC0 | (c >> 6)] +
|
|
80
|
+
hexTable[0x80 | (c & 0x3F)];
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (c < 0xD800 || c >= 0xE000) {
|
|
84
|
+
lastPos = i + 1;
|
|
85
|
+
out += hexTable[0xE0 | (c >> 12)] +
|
|
86
|
+
hexTable[0x80 | ((c >> 6) & 0x3F)] +
|
|
87
|
+
hexTable[0x80 | (c & 0x3F)];
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
// Surrogate pair
|
|
91
|
+
++i;
|
|
92
|
+
|
|
93
|
+
// This branch should never happen because all URLSearchParams entries
|
|
94
|
+
// should already be converted to USVString. But, included for
|
|
95
|
+
// completion's sake anyway.
|
|
96
|
+
if (i >= len)
|
|
97
|
+
throw new ERR_INVALID_URI();
|
|
98
|
+
|
|
99
|
+
const c2 = StringPrototypeCharCodeAt(str, i) & 0x3FF;
|
|
100
|
+
|
|
101
|
+
lastPos = i + 1;
|
|
102
|
+
c = 0x10000 + (((c & 0x3FF) << 10) | c2);
|
|
103
|
+
out += hexTable[0xF0 | (c >> 18)] +
|
|
104
|
+
hexTable[0x80 | ((c >> 12) & 0x3F)] +
|
|
105
|
+
hexTable[0x80 | ((c >> 6) & 0x3F)] +
|
|
106
|
+
hexTable[0x80 | (c & 0x3F)];
|
|
107
|
+
}
|
|
108
|
+
if (lastPos === 0)
|
|
109
|
+
return str;
|
|
110
|
+
if (lastPos < len)
|
|
111
|
+
return out + StringPrototypeSlice(str, lastPos);
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = {
|
|
116
|
+
encodeStr,
|
|
117
|
+
hexTable,
|
|
118
|
+
isHexTable,
|
|
119
|
+
};
|