@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,763 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
ArrayFrom,
|
|
5
|
+
ArrayIsArray,
|
|
6
|
+
ArrayPrototypeAt,
|
|
7
|
+
ArrayPrototypeFlatMap,
|
|
8
|
+
ArrayPrototypeMap,
|
|
9
|
+
ArrayPrototypePop,
|
|
10
|
+
ArrayPrototypePush,
|
|
11
|
+
ArrayPrototypeSome,
|
|
12
|
+
Promise,
|
|
13
|
+
PromisePrototypeThen,
|
|
14
|
+
SafeMap,
|
|
15
|
+
SafeSet,
|
|
16
|
+
StringPrototypeEndsWith,
|
|
17
|
+
} = primordials;
|
|
18
|
+
|
|
19
|
+
const { lstatSync, readdirSync } = require('fs');
|
|
20
|
+
const { lstat, readdir } = require('fs/promises');
|
|
21
|
+
const { join, resolve, basename, isAbsolute, dirname } = require('path');
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
kEmptyObject,
|
|
25
|
+
isWindows,
|
|
26
|
+
isMacOS,
|
|
27
|
+
} = require('internal/util');
|
|
28
|
+
const {
|
|
29
|
+
validateObject,
|
|
30
|
+
validateString,
|
|
31
|
+
validateStringArray,
|
|
32
|
+
} = require('internal/validators');
|
|
33
|
+
const { DirentFromStats } = require('internal/fs/utils');
|
|
34
|
+
const {
|
|
35
|
+
codes: {
|
|
36
|
+
ERR_INVALID_ARG_TYPE,
|
|
37
|
+
},
|
|
38
|
+
hideStackFrames,
|
|
39
|
+
} = require('internal/errors');
|
|
40
|
+
const assert = require('internal/assert');
|
|
41
|
+
const { toPathIfFileURL } = require('internal/url');
|
|
42
|
+
|
|
43
|
+
let minimatch;
|
|
44
|
+
function lazyMinimatch() {
|
|
45
|
+
minimatch ??= require('internal/deps/minimatch/index');
|
|
46
|
+
return minimatch;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} path
|
|
51
|
+
* @returns {Promise<DirentFromStats|null>}
|
|
52
|
+
*/
|
|
53
|
+
async function getDirent(path) {
|
|
54
|
+
let stat;
|
|
55
|
+
try {
|
|
56
|
+
stat = await lstat(path);
|
|
57
|
+
} catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return new DirentFromStats(basename(path), stat, dirname(path));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {string} path
|
|
65
|
+
* @returns {DirentFromStats|null}
|
|
66
|
+
*/
|
|
67
|
+
function getDirentSync(path) {
|
|
68
|
+
const stat = lstatSync(path, { throwIfNoEntry: false });
|
|
69
|
+
if (stat === undefined) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return new DirentFromStats(basename(path), stat, dirname(path));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @callback validateStringArrayOrFunction
|
|
77
|
+
* @param {*} value
|
|
78
|
+
* @param {string} name
|
|
79
|
+
*/
|
|
80
|
+
const validateStringArrayOrFunction = hideStackFrames((value, name) => {
|
|
81
|
+
if (ArrayIsArray(value)) {
|
|
82
|
+
for (let i = 0; i < value.length; ++i) {
|
|
83
|
+
if (typeof value[i] !== 'string') {
|
|
84
|
+
throw new ERR_INVALID_ARG_TYPE(`${name}[${i}]`, 'string', value[i]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (typeof value !== 'function') {
|
|
90
|
+
throw new ERR_INVALID_ARG_TYPE(name, ['string[]', 'function'], value);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @param {string} pattern
|
|
96
|
+
* @param {options} options
|
|
97
|
+
* @returns {Minimatch}
|
|
98
|
+
*/
|
|
99
|
+
function createMatcher(pattern, options = kEmptyObject) {
|
|
100
|
+
const opts = {
|
|
101
|
+
__proto__: null,
|
|
102
|
+
nocase: isWindows || isMacOS,
|
|
103
|
+
windowsPathsNoEscape: true,
|
|
104
|
+
nonegate: true,
|
|
105
|
+
nocomment: true,
|
|
106
|
+
optimizationLevel: 2,
|
|
107
|
+
platform: process.platform,
|
|
108
|
+
nocaseMagicOnly: true,
|
|
109
|
+
...options,
|
|
110
|
+
};
|
|
111
|
+
return new (lazyMinimatch().Minimatch)(pattern, opts);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class Cache {
|
|
115
|
+
#cache = new SafeMap();
|
|
116
|
+
#statsCache = new SafeMap();
|
|
117
|
+
#readdirCache = new SafeMap();
|
|
118
|
+
|
|
119
|
+
stat(path) {
|
|
120
|
+
const cached = this.#statsCache.get(path);
|
|
121
|
+
if (cached) {
|
|
122
|
+
return cached;
|
|
123
|
+
}
|
|
124
|
+
const promise = getDirent(path);
|
|
125
|
+
this.#statsCache.set(path, promise);
|
|
126
|
+
return promise;
|
|
127
|
+
}
|
|
128
|
+
statSync(path) {
|
|
129
|
+
const cached = this.#statsCache.get(path);
|
|
130
|
+
// Do not return a promise from a sync function.
|
|
131
|
+
if (cached && !(cached instanceof Promise)) {
|
|
132
|
+
return cached;
|
|
133
|
+
}
|
|
134
|
+
const val = getDirentSync(path);
|
|
135
|
+
this.#statsCache.set(path, val);
|
|
136
|
+
return val;
|
|
137
|
+
}
|
|
138
|
+
addToStatCache(path, val) {
|
|
139
|
+
this.#statsCache.set(path, val);
|
|
140
|
+
}
|
|
141
|
+
async readdir(path) {
|
|
142
|
+
const cached = this.#readdirCache.get(path);
|
|
143
|
+
if (cached) {
|
|
144
|
+
return cached;
|
|
145
|
+
}
|
|
146
|
+
const promise = PromisePrototypeThen(readdir(path, { __proto__: null, withFileTypes: true }), null, () => null);
|
|
147
|
+
this.#readdirCache.set(path, promise);
|
|
148
|
+
return promise;
|
|
149
|
+
}
|
|
150
|
+
readdirSync(path) {
|
|
151
|
+
const cached = this.#readdirCache.get(path);
|
|
152
|
+
if (cached) {
|
|
153
|
+
return cached;
|
|
154
|
+
}
|
|
155
|
+
let val;
|
|
156
|
+
try {
|
|
157
|
+
val = readdirSync(path, { __proto__: null, withFileTypes: true });
|
|
158
|
+
} catch {
|
|
159
|
+
val = [];
|
|
160
|
+
}
|
|
161
|
+
this.#readdirCache.set(path, val);
|
|
162
|
+
return val;
|
|
163
|
+
}
|
|
164
|
+
add(path, pattern) {
|
|
165
|
+
let cache = this.#cache.get(path);
|
|
166
|
+
if (!cache) {
|
|
167
|
+
cache = new SafeSet();
|
|
168
|
+
this.#cache.set(path, cache);
|
|
169
|
+
}
|
|
170
|
+
const originalSize = cache.size;
|
|
171
|
+
pattern.indexes.forEach((index) => cache.add(pattern.cacheKey(index)));
|
|
172
|
+
return cache.size !== originalSize + pattern.indexes.size;
|
|
173
|
+
}
|
|
174
|
+
seen(path, pattern, index) {
|
|
175
|
+
return this.#cache.get(path)?.has(pattern.cacheKey(index));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
class Pattern {
|
|
180
|
+
#pattern;
|
|
181
|
+
#globStrings;
|
|
182
|
+
indexes;
|
|
183
|
+
symlinks;
|
|
184
|
+
last;
|
|
185
|
+
|
|
186
|
+
constructor(pattern, globStrings, indexes, symlinks) {
|
|
187
|
+
this.#pattern = pattern;
|
|
188
|
+
this.#globStrings = globStrings;
|
|
189
|
+
this.indexes = indexes;
|
|
190
|
+
this.symlinks = symlinks;
|
|
191
|
+
this.last = pattern.length - 1;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
isLast(isDirectory) {
|
|
195
|
+
return this.indexes.has(this.last) ||
|
|
196
|
+
(this.at(-1) === '' && isDirectory &&
|
|
197
|
+
this.indexes.has(this.last - 1) && this.at(-2) === lazyMinimatch().GLOBSTAR);
|
|
198
|
+
}
|
|
199
|
+
isFirst() {
|
|
200
|
+
return this.indexes.has(0);
|
|
201
|
+
}
|
|
202
|
+
get hasSeenSymlinks() {
|
|
203
|
+
return ArrayPrototypeSome(ArrayFrom(this.indexes), (i) => !this.symlinks.has(i));
|
|
204
|
+
}
|
|
205
|
+
at(index) {
|
|
206
|
+
return ArrayPrototypeAt(this.#pattern, index);
|
|
207
|
+
}
|
|
208
|
+
child(indexes, symlinks = new SafeSet()) {
|
|
209
|
+
return new Pattern(this.#pattern, this.#globStrings, indexes, symlinks);
|
|
210
|
+
}
|
|
211
|
+
test(index, path) {
|
|
212
|
+
if (index > this.#pattern.length) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
const pattern = this.#pattern[index];
|
|
216
|
+
if (pattern === lazyMinimatch().GLOBSTAR) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (typeof pattern === 'string') {
|
|
220
|
+
return pattern === path;
|
|
221
|
+
}
|
|
222
|
+
if (typeof pattern?.test === 'function') {
|
|
223
|
+
return pattern.test(path);
|
|
224
|
+
}
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
cacheKey(index) {
|
|
229
|
+
let key = '';
|
|
230
|
+
for (let i = index; i < this.#globStrings.length; i++) {
|
|
231
|
+
key += this.#globStrings[i];
|
|
232
|
+
if (i !== this.#globStrings.length - 1) {
|
|
233
|
+
key += '/';
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return key;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
class ResultSet extends SafeSet {
|
|
241
|
+
#root = '.';
|
|
242
|
+
#isExcluded = () => false;
|
|
243
|
+
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
|
244
|
+
|
|
245
|
+
setup(root, isExcludedFn) {
|
|
246
|
+
this.#root = root;
|
|
247
|
+
this.#isExcluded = isExcludedFn;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
add(value) {
|
|
251
|
+
if (this.#isExcluded(resolve(this.#root, value))) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
super.add(value);
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
class Glob {
|
|
260
|
+
#root;
|
|
261
|
+
#exclude;
|
|
262
|
+
#cache = new Cache();
|
|
263
|
+
#results = new ResultSet();
|
|
264
|
+
#queue = [];
|
|
265
|
+
#subpatterns = new SafeMap();
|
|
266
|
+
#patterns;
|
|
267
|
+
#withFileTypes;
|
|
268
|
+
#isExcluded = () => false;
|
|
269
|
+
constructor(pattern, options = kEmptyObject) {
|
|
270
|
+
validateObject(options, 'options');
|
|
271
|
+
const { exclude, cwd, withFileTypes } = options;
|
|
272
|
+
this.#root = toPathIfFileURL(cwd) ?? '.';
|
|
273
|
+
this.#withFileTypes = !!withFileTypes;
|
|
274
|
+
if (exclude != null) {
|
|
275
|
+
validateStringArrayOrFunction(exclude, 'options.exclude');
|
|
276
|
+
if (ArrayIsArray(exclude)) {
|
|
277
|
+
assert(typeof this.#root === 'string');
|
|
278
|
+
// Convert the path part of exclude patterns to absolute paths for
|
|
279
|
+
// consistent comparison before instantiating matchers.
|
|
280
|
+
const matchers = exclude
|
|
281
|
+
.map((pattern) => resolve(this.#root, pattern))
|
|
282
|
+
.map((pattern) => createMatcher(pattern));
|
|
283
|
+
this.#isExcluded = (value) =>
|
|
284
|
+
matchers.some((matcher) => matcher.match(value));
|
|
285
|
+
this.#results.setup(this.#root, this.#isExcluded);
|
|
286
|
+
} else {
|
|
287
|
+
this.#exclude = exclude;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
let patterns;
|
|
291
|
+
if (typeof pattern === 'object') {
|
|
292
|
+
validateStringArray(pattern, 'patterns');
|
|
293
|
+
patterns = pattern;
|
|
294
|
+
} else {
|
|
295
|
+
validateString(pattern, 'patterns');
|
|
296
|
+
patterns = [pattern];
|
|
297
|
+
}
|
|
298
|
+
this.matchers = ArrayPrototypeMap(patterns, (pattern) => createMatcher(pattern));
|
|
299
|
+
this.#patterns = ArrayPrototypeFlatMap(this.matchers, (matcher) => ArrayPrototypeMap(matcher.set,
|
|
300
|
+
(pattern, i) => new Pattern(
|
|
301
|
+
pattern,
|
|
302
|
+
matcher.globParts[i],
|
|
303
|
+
new SafeSet().add(0),
|
|
304
|
+
new SafeSet(),
|
|
305
|
+
)));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
globSync() {
|
|
309
|
+
ArrayPrototypePush(this.#queue, { __proto__: null, path: '.', patterns: this.#patterns });
|
|
310
|
+
while (this.#queue.length > 0) {
|
|
311
|
+
const item = ArrayPrototypePop(this.#queue);
|
|
312
|
+
for (let i = 0; i < item.patterns.length; i++) {
|
|
313
|
+
this.#addSubpatterns(item.path, item.patterns[i]);
|
|
314
|
+
}
|
|
315
|
+
this.#subpatterns
|
|
316
|
+
.forEach((patterns, path) => ArrayPrototypePush(this.#queue, { __proto__: null, path, patterns }));
|
|
317
|
+
this.#subpatterns.clear();
|
|
318
|
+
}
|
|
319
|
+
return ArrayFrom(
|
|
320
|
+
this.#results,
|
|
321
|
+
this.#withFileTypes ? (path) => this.#cache.statSync(
|
|
322
|
+
isAbsolute(path) ?
|
|
323
|
+
path :
|
|
324
|
+
join(this.#root, path),
|
|
325
|
+
) : undefined,
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
#addSubpattern(path, pattern) {
|
|
329
|
+
if (this.#isExcluded(path)) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const fullpath = resolve(this.#root, path);
|
|
333
|
+
|
|
334
|
+
// If path is a directory, add trailing slash and test patterns again.
|
|
335
|
+
if (this.#isExcluded(`${fullpath}/`) && this.#cache.statSync(fullpath).isDirectory()) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (this.#exclude) {
|
|
340
|
+
if (this.#withFileTypes) {
|
|
341
|
+
const stat = this.#cache.statSync(path);
|
|
342
|
+
if (stat !== null) {
|
|
343
|
+
if (this.#exclude(stat)) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
} else if (this.#exclude(path)) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (!this.#subpatterns.has(path)) {
|
|
352
|
+
this.#subpatterns.set(path, [pattern]);
|
|
353
|
+
} else {
|
|
354
|
+
ArrayPrototypePush(this.#subpatterns.get(path), pattern);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
#addSubpatterns(path, pattern) {
|
|
358
|
+
const seen = this.#cache.add(path, pattern);
|
|
359
|
+
if (seen) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const fullpath = resolve(this.#root, path);
|
|
363
|
+
const stat = this.#cache.statSync(fullpath);
|
|
364
|
+
const last = pattern.last;
|
|
365
|
+
const isDirectory = stat?.isDirectory() || (stat?.isSymbolicLink() && pattern.hasSeenSymlinks);
|
|
366
|
+
const isLast = pattern.isLast(isDirectory);
|
|
367
|
+
const isFirst = pattern.isFirst();
|
|
368
|
+
|
|
369
|
+
if (this.#isExcluded(fullpath)) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (isFirst && isWindows && typeof pattern.at(0) === 'string' && StringPrototypeEndsWith(pattern.at(0), ':')) {
|
|
373
|
+
// Absolute path, go to root
|
|
374
|
+
this.#addSubpattern(`${pattern.at(0)}\\`, pattern.child(new SafeSet().add(1)));
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
if (isFirst && pattern.at(0) === '') {
|
|
378
|
+
// Absolute path, go to root
|
|
379
|
+
this.#addSubpattern('/', pattern.child(new SafeSet().add(1)));
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (isFirst && pattern.at(0) === '..') {
|
|
383
|
+
// Start with .., go to parent
|
|
384
|
+
this.#addSubpattern('../', pattern.child(new SafeSet().add(1)));
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (isFirst && pattern.at(0) === '.') {
|
|
388
|
+
// Start with ., proceed
|
|
389
|
+
this.#addSubpattern('.', pattern.child(new SafeSet().add(1)));
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (isLast && typeof pattern.at(-1) === 'string') {
|
|
394
|
+
// Add result if it exists
|
|
395
|
+
const p = pattern.at(-1);
|
|
396
|
+
const stat = this.#cache.statSync(join(fullpath, p));
|
|
397
|
+
if (stat && (p || isDirectory)) {
|
|
398
|
+
this.#results.add(join(path, p));
|
|
399
|
+
}
|
|
400
|
+
if (pattern.indexes.size === 1 && pattern.indexes.has(last)) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
} else if (isLast && pattern.at(-1) === lazyMinimatch().GLOBSTAR &&
|
|
404
|
+
(path !== '.' || pattern.at(0) === '.' || (last === 0 && stat))) {
|
|
405
|
+
// If pattern ends with **, add to results
|
|
406
|
+
// if path is ".", add it only if pattern starts with "." or pattern is exactly "**"
|
|
407
|
+
this.#results.add(path);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (!isDirectory) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
let children;
|
|
415
|
+
const firstPattern = pattern.indexes.size === 1 && pattern.at(pattern.indexes.values().next().value);
|
|
416
|
+
if (typeof firstPattern === 'string') {
|
|
417
|
+
const stat = this.#cache.statSync(join(fullpath, firstPattern));
|
|
418
|
+
if (stat) {
|
|
419
|
+
stat.name = firstPattern;
|
|
420
|
+
children = [stat];
|
|
421
|
+
} else {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
children = this.#cache.readdirSync(fullpath);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
for (let i = 0; i < children.length; i++) {
|
|
429
|
+
const entry = children[i];
|
|
430
|
+
const entryPath = join(path, entry.name);
|
|
431
|
+
this.#cache.addToStatCache(join(fullpath, entry.name), entry);
|
|
432
|
+
|
|
433
|
+
const subPatterns = new SafeSet();
|
|
434
|
+
const nSymlinks = new SafeSet();
|
|
435
|
+
for (const index of pattern.indexes) {
|
|
436
|
+
// For each child, check potential patterns
|
|
437
|
+
if (this.#cache.seen(entryPath, pattern, index) || this.#cache.seen(entryPath, pattern, index + 1)) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const current = pattern.at(index);
|
|
441
|
+
const nextIndex = index + 1;
|
|
442
|
+
const next = pattern.at(nextIndex);
|
|
443
|
+
const fromSymlink = pattern.symlinks.has(index);
|
|
444
|
+
|
|
445
|
+
if (current === lazyMinimatch().GLOBSTAR) {
|
|
446
|
+
if (entry.name[0] === '.' || (this.#exclude && this.#exclude(this.#withFileTypes ? entry : entry.name))) {
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
if (!fromSymlink && entry.isDirectory()) {
|
|
450
|
+
// If directory, add ** to its potential patterns
|
|
451
|
+
subPatterns.add(index);
|
|
452
|
+
} else if (!fromSymlink && index === last) {
|
|
453
|
+
// If ** is last, add to results
|
|
454
|
+
this.#results.add(entryPath);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Any pattern after ** is also a potential pattern
|
|
458
|
+
// so we can already test it here
|
|
459
|
+
const nextMatches = pattern.test(nextIndex, entry.name);
|
|
460
|
+
if (nextMatches && nextIndex === last && !isLast) {
|
|
461
|
+
// If next pattern is the last one, add to results
|
|
462
|
+
this.#results.add(entryPath);
|
|
463
|
+
} else if (nextMatches && entry.isDirectory()) {
|
|
464
|
+
// Pattern matched, meaning two patterns forward
|
|
465
|
+
// are also potential patterns
|
|
466
|
+
// e.g **/b/c when entry is a/b - add c to potential patterns
|
|
467
|
+
subPatterns.add(index + 2);
|
|
468
|
+
}
|
|
469
|
+
if ((nextMatches || pattern.at(0) === '.') &&
|
|
470
|
+
(entry.isDirectory() || entry.isSymbolicLink()) && !fromSymlink) {
|
|
471
|
+
// If pattern after ** matches, or pattern starts with "."
|
|
472
|
+
// and entry is a directory or symlink, add to potential patterns
|
|
473
|
+
subPatterns.add(nextIndex);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (entry.isSymbolicLink()) {
|
|
477
|
+
nSymlinks.add(index);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (next === '..' && entry.isDirectory()) {
|
|
481
|
+
// In case pattern is "**/..",
|
|
482
|
+
// both parent and current directory should be added to the queue
|
|
483
|
+
// if this is the last pattern, add to results instead
|
|
484
|
+
const parent = join(path, '..');
|
|
485
|
+
if (nextIndex < last) {
|
|
486
|
+
if (!this.#subpatterns.has(path) && !this.#cache.seen(path, pattern, nextIndex + 1)) {
|
|
487
|
+
this.#subpatterns.set(path, [pattern.child(new SafeSet().add(nextIndex + 1))]);
|
|
488
|
+
}
|
|
489
|
+
if (!this.#subpatterns.has(parent) && !this.#cache.seen(parent, pattern, nextIndex + 1)) {
|
|
490
|
+
this.#subpatterns.set(parent, [pattern.child(new SafeSet().add(nextIndex + 1))]);
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
if (!this.#cache.seen(path, pattern, nextIndex)) {
|
|
494
|
+
this.#cache.add(path, pattern.child(new SafeSet().add(nextIndex)));
|
|
495
|
+
this.#results.add(path);
|
|
496
|
+
}
|
|
497
|
+
if (!this.#cache.seen(path, pattern, nextIndex) || !this.#cache.seen(parent, pattern, nextIndex)) {
|
|
498
|
+
this.#cache.add(parent, pattern.child(new SafeSet().add(nextIndex)));
|
|
499
|
+
this.#results.add(parent);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (typeof current === 'string') {
|
|
505
|
+
if (pattern.test(index, entry.name) && index !== last) {
|
|
506
|
+
// If current pattern matches entry name
|
|
507
|
+
// the next pattern is a potential pattern
|
|
508
|
+
subPatterns.add(nextIndex);
|
|
509
|
+
} else if (current === '.' && pattern.test(nextIndex, entry.name)) {
|
|
510
|
+
// If current pattern is ".", proceed to test next pattern
|
|
511
|
+
if (nextIndex === last) {
|
|
512
|
+
this.#results.add(entryPath);
|
|
513
|
+
} else {
|
|
514
|
+
subPatterns.add(nextIndex + 1);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
if (typeof current === 'object' && pattern.test(index, entry.name)) {
|
|
519
|
+
// If current pattern is a regex that matches entry name (e.g *.js)
|
|
520
|
+
// add next pattern to potential patterns, or to results if it's the last pattern
|
|
521
|
+
if (index === last) {
|
|
522
|
+
this.#results.add(entryPath);
|
|
523
|
+
} else if (entry.isDirectory()) {
|
|
524
|
+
subPatterns.add(nextIndex);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (subPatterns.size > 0) {
|
|
529
|
+
// If there are potential patterns, add to queue
|
|
530
|
+
this.#addSubpattern(entryPath, pattern.child(subPatterns, nSymlinks));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
async* glob() {
|
|
537
|
+
ArrayPrototypePush(this.#queue, { __proto__: null, path: '.', patterns: this.#patterns });
|
|
538
|
+
while (this.#queue.length > 0) {
|
|
539
|
+
const item = ArrayPrototypePop(this.#queue);
|
|
540
|
+
for (let i = 0; i < item.patterns.length; i++) {
|
|
541
|
+
yield* this.#iterateSubpatterns(item.path, item.patterns[i]);
|
|
542
|
+
}
|
|
543
|
+
this.#subpatterns
|
|
544
|
+
.forEach((patterns, path) => ArrayPrototypePush(this.#queue, { __proto__: null, path, patterns }));
|
|
545
|
+
this.#subpatterns.clear();
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
async* #iterateSubpatterns(path, pattern) {
|
|
549
|
+
const seen = this.#cache.add(path, pattern);
|
|
550
|
+
if (seen) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
const fullpath = resolve(this.#root, path);
|
|
554
|
+
const stat = await this.#cache.stat(fullpath);
|
|
555
|
+
const last = pattern.last;
|
|
556
|
+
const isDirectory = stat?.isDirectory() || (stat?.isSymbolicLink() && pattern.hasSeenSymlinks);
|
|
557
|
+
const isLast = pattern.isLast(isDirectory);
|
|
558
|
+
const isFirst = pattern.isFirst();
|
|
559
|
+
|
|
560
|
+
if (this.#isExcluded(fullpath)) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (isFirst && isWindows && typeof pattern.at(0) === 'string' && StringPrototypeEndsWith(pattern.at(0), ':')) {
|
|
564
|
+
// Absolute path, go to root
|
|
565
|
+
this.#addSubpattern(`${pattern.at(0)}\\`, pattern.child(new SafeSet().add(1)));
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (isFirst && pattern.at(0) === '') {
|
|
569
|
+
// Absolute path, go to root
|
|
570
|
+
this.#addSubpattern('/', pattern.child(new SafeSet().add(1)));
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (isFirst && pattern.at(0) === '..') {
|
|
574
|
+
// Start with .., go to parent
|
|
575
|
+
this.#addSubpattern('../', pattern.child(new SafeSet().add(1)));
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
if (isFirst && pattern.at(0) === '.') {
|
|
579
|
+
// Start with ., proceed
|
|
580
|
+
this.#addSubpattern('.', pattern.child(new SafeSet().add(1)));
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (isLast && typeof pattern.at(-1) === 'string') {
|
|
585
|
+
// Add result if it exists
|
|
586
|
+
const p = pattern.at(-1);
|
|
587
|
+
const stat = await this.#cache.stat(join(fullpath, p));
|
|
588
|
+
if (stat && (p || isDirectory)) {
|
|
589
|
+
const result = join(path, p);
|
|
590
|
+
if (!this.#results.has(result)) {
|
|
591
|
+
if (this.#results.add(result)) {
|
|
592
|
+
yield this.#withFileTypes ? stat : result;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
if (pattern.indexes.size === 1 && pattern.indexes.has(last)) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
} else if (isLast && pattern.at(-1) === lazyMinimatch().GLOBSTAR &&
|
|
600
|
+
(path !== '.' || pattern.at(0) === '.' || (last === 0 && stat))) {
|
|
601
|
+
// If pattern ends with **, add to results
|
|
602
|
+
// if path is ".", add it only if pattern starts with "." or pattern is exactly "**"
|
|
603
|
+
if (!this.#results.has(path)) {
|
|
604
|
+
if (this.#results.add(path)) {
|
|
605
|
+
yield this.#withFileTypes ? stat : path;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
if (!isDirectory) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
let children;
|
|
615
|
+
const firstPattern = pattern.indexes.size === 1 && pattern.at(pattern.indexes.values().next().value);
|
|
616
|
+
if (typeof firstPattern === 'string') {
|
|
617
|
+
const stat = await this.#cache.stat(join(fullpath, firstPattern));
|
|
618
|
+
if (stat) {
|
|
619
|
+
stat.name = firstPattern;
|
|
620
|
+
children = [stat];
|
|
621
|
+
} else {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
} else {
|
|
625
|
+
children = await this.#cache.readdir(fullpath);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
for (let i = 0; i < children.length; i++) {
|
|
629
|
+
const entry = children[i];
|
|
630
|
+
const entryPath = join(path, entry.name);
|
|
631
|
+
this.#cache.addToStatCache(join(fullpath, entry.name), entry);
|
|
632
|
+
|
|
633
|
+
const subPatterns = new SafeSet();
|
|
634
|
+
const nSymlinks = new SafeSet();
|
|
635
|
+
for (const index of pattern.indexes) {
|
|
636
|
+
// For each child, check potential patterns
|
|
637
|
+
if (this.#cache.seen(entryPath, pattern, index) || this.#cache.seen(entryPath, pattern, index + 1)) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const current = pattern.at(index);
|
|
641
|
+
const nextIndex = index + 1;
|
|
642
|
+
const next = pattern.at(nextIndex);
|
|
643
|
+
const fromSymlink = pattern.symlinks.has(index);
|
|
644
|
+
|
|
645
|
+
if (current === lazyMinimatch().GLOBSTAR) {
|
|
646
|
+
if (entry.name[0] === '.' || (this.#exclude && this.#exclude(this.#withFileTypes ? entry : entry.name))) {
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
if (!fromSymlink && entry.isDirectory()) {
|
|
650
|
+
// If directory, add ** to its potential patterns
|
|
651
|
+
subPatterns.add(index);
|
|
652
|
+
} else if (!fromSymlink && index === last) {
|
|
653
|
+
// If ** is last, add to results
|
|
654
|
+
if (!this.#results.has(entryPath)) {
|
|
655
|
+
if (this.#results.add(entryPath)) {
|
|
656
|
+
yield this.#withFileTypes ? entry : entryPath;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Any pattern after ** is also a potential pattern
|
|
662
|
+
// so we can already test it here
|
|
663
|
+
const nextMatches = pattern.test(nextIndex, entry.name);
|
|
664
|
+
if (nextMatches && nextIndex === last && !isLast) {
|
|
665
|
+
// If next pattern is the last one, add to results
|
|
666
|
+
if (!this.#results.has(entryPath)) {
|
|
667
|
+
if (this.#results.add(entryPath)) {
|
|
668
|
+
yield this.#withFileTypes ? entry : entryPath;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
} else if (nextMatches && entry.isDirectory()) {
|
|
672
|
+
// Pattern matched, meaning two patterns forward
|
|
673
|
+
// are also potential patterns
|
|
674
|
+
// e.g **/b/c when entry is a/b - add c to potential patterns
|
|
675
|
+
subPatterns.add(index + 2);
|
|
676
|
+
}
|
|
677
|
+
if ((nextMatches || pattern.at(0) === '.') &&
|
|
678
|
+
(entry.isDirectory() || entry.isSymbolicLink()) && !fromSymlink) {
|
|
679
|
+
// If pattern after ** matches, or pattern starts with "."
|
|
680
|
+
// and entry is a directory or symlink, add to potential patterns
|
|
681
|
+
subPatterns.add(nextIndex);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
if (entry.isSymbolicLink()) {
|
|
685
|
+
nSymlinks.add(index);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if (next === '..' && entry.isDirectory()) {
|
|
689
|
+
// In case pattern is "**/..",
|
|
690
|
+
// both parent and current directory should be added to the queue
|
|
691
|
+
// if this is the last pattern, add to results instead
|
|
692
|
+
const parent = join(path, '..');
|
|
693
|
+
if (nextIndex < last) {
|
|
694
|
+
if (!this.#subpatterns.has(path) && !this.#cache.seen(path, pattern, nextIndex + 1)) {
|
|
695
|
+
this.#subpatterns.set(path, [pattern.child(new SafeSet().add(nextIndex + 1))]);
|
|
696
|
+
}
|
|
697
|
+
if (!this.#subpatterns.has(parent) && !this.#cache.seen(parent, pattern, nextIndex + 1)) {
|
|
698
|
+
this.#subpatterns.set(parent, [pattern.child(new SafeSet().add(nextIndex + 1))]);
|
|
699
|
+
}
|
|
700
|
+
} else {
|
|
701
|
+
if (!this.#cache.seen(path, pattern, nextIndex)) {
|
|
702
|
+
this.#cache.add(path, pattern.child(new SafeSet().add(nextIndex)));
|
|
703
|
+
if (!this.#results.has(path)) {
|
|
704
|
+
if (this.#results.add(path)) {
|
|
705
|
+
yield this.#withFileTypes ? this.#cache.statSync(fullpath) : path;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (!this.#cache.seen(path, pattern, nextIndex) || !this.#cache.seen(parent, pattern, nextIndex)) {
|
|
710
|
+
this.#cache.add(parent, pattern.child(new SafeSet().add(nextIndex)));
|
|
711
|
+
if (!this.#results.has(parent)) {
|
|
712
|
+
if (this.#results.add(parent)) {
|
|
713
|
+
yield this.#withFileTypes ? this.#cache.statSync(join(this.#root, parent)) : parent;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
if (typeof current === 'string') {
|
|
721
|
+
if (pattern.test(index, entry.name) && index !== last) {
|
|
722
|
+
// If current pattern matches entry name
|
|
723
|
+
// the next pattern is a potential pattern
|
|
724
|
+
subPatterns.add(nextIndex);
|
|
725
|
+
} else if (current === '.' && pattern.test(nextIndex, entry.name)) {
|
|
726
|
+
// If current pattern is ".", proceed to test next pattern
|
|
727
|
+
if (nextIndex === last) {
|
|
728
|
+
if (!this.#results.has(entryPath)) {
|
|
729
|
+
if (this.#results.add(entryPath)) {
|
|
730
|
+
yield this.#withFileTypes ? entry : entryPath;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
} else {
|
|
734
|
+
subPatterns.add(nextIndex + 1);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
if (typeof current === 'object' && pattern.test(index, entry.name)) {
|
|
739
|
+
// If current pattern is a regex that matches entry name (e.g *.js)
|
|
740
|
+
// add next pattern to potential patterns, or to results if it's the last pattern
|
|
741
|
+
if (index === last) {
|
|
742
|
+
if (!this.#results.has(entryPath)) {
|
|
743
|
+
if (this.#results.add(entryPath)) {
|
|
744
|
+
yield this.#withFileTypes ? entry : entryPath;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
} else if (entry.isDirectory()) {
|
|
748
|
+
subPatterns.add(nextIndex);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
if (subPatterns.size > 0) {
|
|
753
|
+
// If there are potential patterns, add to queue
|
|
754
|
+
this.#addSubpattern(entryPath, pattern.child(subPatterns, nSymlinks));
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
module.exports = {
|
|
761
|
+
__proto__: null,
|
|
762
|
+
Glob,
|
|
763
|
+
};
|