@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,987 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
ArrayIsArray,
|
|
5
|
+
BigInt,
|
|
6
|
+
Date,
|
|
7
|
+
DateNow,
|
|
8
|
+
DatePrototypeGetTime,
|
|
9
|
+
ErrorCaptureStackTrace,
|
|
10
|
+
FunctionPrototypeCall,
|
|
11
|
+
MathMin,
|
|
12
|
+
MathRound,
|
|
13
|
+
Number,
|
|
14
|
+
NumberIsFinite,
|
|
15
|
+
ObjectDefineProperties,
|
|
16
|
+
ObjectDefineProperty,
|
|
17
|
+
ObjectIs,
|
|
18
|
+
ObjectSetPrototypeOf,
|
|
19
|
+
ReflectApply,
|
|
20
|
+
ReflectOwnKeys,
|
|
21
|
+
RegExpPrototypeSymbolReplace,
|
|
22
|
+
StringPrototypeEndsWith,
|
|
23
|
+
StringPrototypeIncludes,
|
|
24
|
+
Symbol,
|
|
25
|
+
TypedArrayPrototypeAt,
|
|
26
|
+
TypedArrayPrototypeIncludes,
|
|
27
|
+
} = primordials;
|
|
28
|
+
|
|
29
|
+
const { Buffer } = require('buffer');
|
|
30
|
+
const {
|
|
31
|
+
UVException,
|
|
32
|
+
codes: {
|
|
33
|
+
ERR_FS_EISDIR,
|
|
34
|
+
ERR_FS_INVALID_SYMLINK_TYPE,
|
|
35
|
+
ERR_INCOMPATIBLE_OPTION_PAIR,
|
|
36
|
+
ERR_INVALID_ARG_TYPE,
|
|
37
|
+
ERR_INVALID_ARG_VALUE,
|
|
38
|
+
ERR_OUT_OF_RANGE,
|
|
39
|
+
},
|
|
40
|
+
hideStackFrames,
|
|
41
|
+
} = require('internal/errors');
|
|
42
|
+
const {
|
|
43
|
+
isArrayBufferView,
|
|
44
|
+
isBigInt64Array,
|
|
45
|
+
isDate,
|
|
46
|
+
isUint8Array,
|
|
47
|
+
} = require('internal/util/types');
|
|
48
|
+
const {
|
|
49
|
+
kEmptyObject,
|
|
50
|
+
once,
|
|
51
|
+
deprecate,
|
|
52
|
+
isWindows,
|
|
53
|
+
} = require('internal/util');
|
|
54
|
+
const { toPathIfFileURL } = require('internal/url');
|
|
55
|
+
const {
|
|
56
|
+
validateAbortSignal,
|
|
57
|
+
validateBoolean,
|
|
58
|
+
validateFunction,
|
|
59
|
+
validateInt32,
|
|
60
|
+
validateInteger,
|
|
61
|
+
validateObject,
|
|
62
|
+
validateUint32,
|
|
63
|
+
} = require('internal/validators');
|
|
64
|
+
const pathModule = require('path');
|
|
65
|
+
const kType = Symbol('type');
|
|
66
|
+
const kStats = Symbol('stats');
|
|
67
|
+
const assert = require('internal/assert');
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
fs: {
|
|
71
|
+
F_OK = 0,
|
|
72
|
+
W_OK = 0,
|
|
73
|
+
R_OK = 0,
|
|
74
|
+
X_OK = 0,
|
|
75
|
+
COPYFILE_EXCL,
|
|
76
|
+
COPYFILE_FICLONE,
|
|
77
|
+
COPYFILE_FICLONE_FORCE,
|
|
78
|
+
O_APPEND,
|
|
79
|
+
O_CREAT,
|
|
80
|
+
O_EXCL,
|
|
81
|
+
O_RDONLY,
|
|
82
|
+
O_RDWR,
|
|
83
|
+
O_SYNC,
|
|
84
|
+
O_TRUNC,
|
|
85
|
+
O_WRONLY,
|
|
86
|
+
S_IFBLK,
|
|
87
|
+
S_IFCHR,
|
|
88
|
+
S_IFDIR,
|
|
89
|
+
S_IFIFO,
|
|
90
|
+
S_IFLNK,
|
|
91
|
+
S_IFMT,
|
|
92
|
+
S_IFREG,
|
|
93
|
+
S_IFSOCK,
|
|
94
|
+
UV_FS_SYMLINK_DIR,
|
|
95
|
+
UV_FS_SYMLINK_JUNCTION,
|
|
96
|
+
UV_DIRENT_UNKNOWN,
|
|
97
|
+
UV_DIRENT_FILE,
|
|
98
|
+
UV_DIRENT_DIR,
|
|
99
|
+
UV_DIRENT_LINK,
|
|
100
|
+
UV_DIRENT_FIFO,
|
|
101
|
+
UV_DIRENT_SOCKET,
|
|
102
|
+
UV_DIRENT_CHAR,
|
|
103
|
+
UV_DIRENT_BLOCK,
|
|
104
|
+
},
|
|
105
|
+
os: {
|
|
106
|
+
errno: {
|
|
107
|
+
EISDIR,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
} = internalBinding('constants');
|
|
111
|
+
|
|
112
|
+
// The access modes can be any of F_OK, R_OK, W_OK or X_OK. Some might not be
|
|
113
|
+
// available on specific systems. They can be used in combination as well
|
|
114
|
+
// (F_OK | R_OK | W_OK | X_OK).
|
|
115
|
+
const kMinimumAccessMode = MathMin(F_OK, W_OK, R_OK, X_OK);
|
|
116
|
+
const kMaximumAccessMode = F_OK | W_OK | R_OK | X_OK;
|
|
117
|
+
|
|
118
|
+
const kDefaultCopyMode = 0;
|
|
119
|
+
// The copy modes can be any of COPYFILE_EXCL, COPYFILE_FICLONE or
|
|
120
|
+
// COPYFILE_FICLONE_FORCE. They can be used in combination as well
|
|
121
|
+
// (COPYFILE_EXCL | COPYFILE_FICLONE | COPYFILE_FICLONE_FORCE).
|
|
122
|
+
const kMinimumCopyMode = MathMin(
|
|
123
|
+
kDefaultCopyMode,
|
|
124
|
+
COPYFILE_EXCL,
|
|
125
|
+
COPYFILE_FICLONE,
|
|
126
|
+
COPYFILE_FICLONE_FORCE,
|
|
127
|
+
);
|
|
128
|
+
const kMaximumCopyMode = COPYFILE_EXCL |
|
|
129
|
+
COPYFILE_FICLONE |
|
|
130
|
+
COPYFILE_FICLONE_FORCE;
|
|
131
|
+
|
|
132
|
+
// Most platforms don't allow reads or writes >= 2 GiB.
|
|
133
|
+
// See https://github.com/libuv/libuv/pull/1501.
|
|
134
|
+
const kIoMaxLength = 2 ** 31 - 1;
|
|
135
|
+
|
|
136
|
+
// Use 64kb in case the file type is not a regular file and thus do not know the
|
|
137
|
+
// actual file size. Increasing the value further results in more frequent over
|
|
138
|
+
// allocation for small files and consumes CPU time and memory that should be
|
|
139
|
+
// used else wise.
|
|
140
|
+
// Use up to 512kb per read otherwise to partition reading big files to prevent
|
|
141
|
+
// blocking other threads in case the available threads are all in use.
|
|
142
|
+
const kReadFileUnknownBufferLength = 64 * 1024;
|
|
143
|
+
const kReadFileBufferLength = 512 * 1024;
|
|
144
|
+
|
|
145
|
+
const kWriteFileMaxChunkSize = 512 * 1024;
|
|
146
|
+
|
|
147
|
+
const kMaxUserId = 2 ** 32 - 1;
|
|
148
|
+
|
|
149
|
+
let fs;
|
|
150
|
+
function lazyLoadFs() {
|
|
151
|
+
return fs ??= require('fs');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function assertEncoding(encoding) {
|
|
155
|
+
if (encoding && !Buffer.isEncoding(encoding)) {
|
|
156
|
+
const reason = 'is invalid encoding';
|
|
157
|
+
throw new ERR_INVALID_ARG_VALUE('encoding', encoding, reason);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
class Dirent {
|
|
162
|
+
constructor(name, type, path) {
|
|
163
|
+
this.name = name;
|
|
164
|
+
this.parentPath = path;
|
|
165
|
+
this.path = path;
|
|
166
|
+
this[kType] = type;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
isDirectory() {
|
|
170
|
+
return this[kType] === UV_DIRENT_DIR;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
isFile() {
|
|
174
|
+
return this[kType] === UV_DIRENT_FILE;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
isBlockDevice() {
|
|
178
|
+
return this[kType] === UV_DIRENT_BLOCK;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
isCharacterDevice() {
|
|
182
|
+
return this[kType] === UV_DIRENT_CHAR;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
isSymbolicLink() {
|
|
186
|
+
return this[kType] === UV_DIRENT_LINK;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
isFIFO() {
|
|
190
|
+
return this[kType] === UV_DIRENT_FIFO;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
isSocket() {
|
|
194
|
+
return this[kType] === UV_DIRENT_SOCKET;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
class DirentFromStats extends Dirent {
|
|
199
|
+
constructor(name, stats, path) {
|
|
200
|
+
super(name, null, path);
|
|
201
|
+
this[kStats] = stats;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
for (const name of ReflectOwnKeys(Dirent.prototype)) {
|
|
206
|
+
if (name === 'constructor') {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
DirentFromStats.prototype[name] = function() {
|
|
210
|
+
return this[kStats][name]();
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function copyObject(source) {
|
|
215
|
+
const target = {};
|
|
216
|
+
for (const key in source)
|
|
217
|
+
target[key] = source[key];
|
|
218
|
+
return target;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const bufferSep = Buffer.from(pathModule.sep);
|
|
222
|
+
|
|
223
|
+
function join(path, name) {
|
|
224
|
+
if ((typeof path === 'string' || isUint8Array(path)) &&
|
|
225
|
+
name === undefined) {
|
|
226
|
+
return path;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (typeof path === 'string' && isUint8Array(name)) {
|
|
230
|
+
const pathBuffer = Buffer.from(pathModule.join(path, pathModule.sep));
|
|
231
|
+
return Buffer.concat([pathBuffer, name]);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (typeof path === 'string' && typeof name === 'string') {
|
|
235
|
+
return pathModule.join(path, name);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (isUint8Array(path) && isUint8Array(name)) {
|
|
239
|
+
return Buffer.concat([path, bufferSep, name]);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
throw new ERR_INVALID_ARG_TYPE(
|
|
243
|
+
'path', ['string', 'Buffer'], path);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function getDirents(path, { 0: names, 1: types }, callback) {
|
|
247
|
+
let i;
|
|
248
|
+
if (typeof callback === 'function') {
|
|
249
|
+
const len = names.length;
|
|
250
|
+
let toFinish = 0;
|
|
251
|
+
callback = once(callback);
|
|
252
|
+
for (i = 0; i < len; i++) {
|
|
253
|
+
const type = types[i];
|
|
254
|
+
if (type === UV_DIRENT_UNKNOWN) {
|
|
255
|
+
const name = names[i];
|
|
256
|
+
const idx = i;
|
|
257
|
+
toFinish++;
|
|
258
|
+
let filepath;
|
|
259
|
+
try {
|
|
260
|
+
filepath = join(path, name);
|
|
261
|
+
} catch (err) {
|
|
262
|
+
callback(err);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
lazyLoadFs().lstat(filepath, (err, stats) => {
|
|
266
|
+
if (err) {
|
|
267
|
+
callback(err);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
names[idx] = new DirentFromStats(name, stats, path);
|
|
271
|
+
if (--toFinish === 0) {
|
|
272
|
+
callback(null, names);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
} else {
|
|
276
|
+
names[i] = new Dirent(names[i], types[i], path);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (toFinish === 0) {
|
|
280
|
+
callback(null, names);
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
const len = names.length;
|
|
284
|
+
for (i = 0; i < len; i++) {
|
|
285
|
+
names[i] = getDirent(path, names[i], types[i]);
|
|
286
|
+
}
|
|
287
|
+
return names;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function getDirent(path, name, type, callback) {
|
|
292
|
+
if (typeof callback === 'function') {
|
|
293
|
+
if (type === UV_DIRENT_UNKNOWN) {
|
|
294
|
+
let filepath;
|
|
295
|
+
try {
|
|
296
|
+
filepath = join(path, name);
|
|
297
|
+
} catch (err) {
|
|
298
|
+
callback(err);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
lazyLoadFs().lstat(filepath, (err, stats) => {
|
|
302
|
+
if (err) {
|
|
303
|
+
callback(err);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
callback(null, new DirentFromStats(name, stats, filepath));
|
|
307
|
+
});
|
|
308
|
+
} else {
|
|
309
|
+
callback(null, new Dirent(name, type, path));
|
|
310
|
+
}
|
|
311
|
+
} else if (type === UV_DIRENT_UNKNOWN) {
|
|
312
|
+
const filepath = join(path, name);
|
|
313
|
+
const stats = lazyLoadFs().lstatSync(filepath);
|
|
314
|
+
return new DirentFromStats(name, stats, path);
|
|
315
|
+
} else {
|
|
316
|
+
return new Dirent(name, type, path);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function getOptions(options, defaultOptions = kEmptyObject) {
|
|
321
|
+
if (options == null || typeof options === 'function') {
|
|
322
|
+
return defaultOptions;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (typeof options === 'string') {
|
|
326
|
+
defaultOptions = { ...defaultOptions };
|
|
327
|
+
defaultOptions.encoding = options;
|
|
328
|
+
options = defaultOptions;
|
|
329
|
+
} else if (typeof options !== 'object') {
|
|
330
|
+
throw new ERR_INVALID_ARG_TYPE('options', ['string', 'Object'], options);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (options.encoding !== 'buffer')
|
|
334
|
+
assertEncoding(options.encoding);
|
|
335
|
+
|
|
336
|
+
if (options.signal !== undefined) {
|
|
337
|
+
validateAbortSignal(options.signal, 'options.signal');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return options;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @param {InternalFSBinding.FSSyncContext} ctx
|
|
345
|
+
*/
|
|
346
|
+
function handleErrorFromBinding(ctx) {
|
|
347
|
+
if (ctx.errno !== undefined) { // libuv error numbers
|
|
348
|
+
const err = new UVException(ctx);
|
|
349
|
+
ErrorCaptureStackTrace(err, handleErrorFromBinding);
|
|
350
|
+
throw err;
|
|
351
|
+
}
|
|
352
|
+
if (ctx.error !== undefined) { // Errors created in C++ land.
|
|
353
|
+
// TODO(joyeecheung): currently, ctx.error are encoding errors
|
|
354
|
+
// usually caused by memory problems. We need to figure out proper error
|
|
355
|
+
// code(s) for this.
|
|
356
|
+
ErrorCaptureStackTrace(ctx.error, handleErrorFromBinding);
|
|
357
|
+
throw ctx.error;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function preprocessSymlinkDestination(path, type, linkPath) {
|
|
362
|
+
if (!isWindows) {
|
|
363
|
+
// No preprocessing is needed on Unix.
|
|
364
|
+
return path;
|
|
365
|
+
}
|
|
366
|
+
path = '' + path;
|
|
367
|
+
if (type === 'junction') {
|
|
368
|
+
// Junctions paths need to be absolute and \\?\-prefixed.
|
|
369
|
+
// A relative target is relative to the link's parent directory.
|
|
370
|
+
path = pathModule.resolve(linkPath, '..', path);
|
|
371
|
+
return pathModule.toNamespacedPath(path);
|
|
372
|
+
}
|
|
373
|
+
if (pathModule.isAbsolute(path)) {
|
|
374
|
+
// If the path is absolute, use the \\?\-prefix to enable long filenames
|
|
375
|
+
return pathModule.toNamespacedPath(path);
|
|
376
|
+
}
|
|
377
|
+
// Windows symlinks don't tolerate forward slashes.
|
|
378
|
+
return RegExpPrototypeSymbolReplace(/\//g, path, '\\');
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// Constructor for file stats.
|
|
382
|
+
function StatsBase(dev, mode, nlink, uid, gid, rdev, blksize,
|
|
383
|
+
ino, size, blocks) {
|
|
384
|
+
this.dev = dev;
|
|
385
|
+
this.mode = mode;
|
|
386
|
+
this.nlink = nlink;
|
|
387
|
+
this.uid = uid;
|
|
388
|
+
this.gid = gid;
|
|
389
|
+
this.rdev = rdev;
|
|
390
|
+
this.blksize = blksize;
|
|
391
|
+
this.ino = ino;
|
|
392
|
+
this.size = size;
|
|
393
|
+
this.blocks = blocks;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
StatsBase.prototype.isDirectory = function() {
|
|
397
|
+
return this._checkModeProperty(S_IFDIR);
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
StatsBase.prototype.isFile = function() {
|
|
401
|
+
return this._checkModeProperty(S_IFREG);
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
StatsBase.prototype.isBlockDevice = function() {
|
|
405
|
+
return this._checkModeProperty(S_IFBLK);
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
StatsBase.prototype.isCharacterDevice = function() {
|
|
409
|
+
return this._checkModeProperty(S_IFCHR);
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
StatsBase.prototype.isSymbolicLink = function() {
|
|
413
|
+
return this._checkModeProperty(S_IFLNK);
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
StatsBase.prototype.isFIFO = function() {
|
|
417
|
+
return this._checkModeProperty(S_IFIFO);
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
StatsBase.prototype.isSocket = function() {
|
|
421
|
+
return this._checkModeProperty(S_IFSOCK);
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const kNsPerMsBigInt = 1_000_000n;
|
|
425
|
+
const kNsPerSecBigInt = 1_000_000_000n;
|
|
426
|
+
const kMsPerSec = 1_000;
|
|
427
|
+
const kNsPerMs = 1_000_000;
|
|
428
|
+
function msFromTimeSpec(sec, nsec) {
|
|
429
|
+
return sec * kMsPerSec + nsec / kNsPerMs;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function nsFromTimeSpecBigInt(sec, nsec) {
|
|
433
|
+
return sec * kNsPerSecBigInt + nsec;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// The Date constructor performs Math.floor() on the absolute value
|
|
437
|
+
// of the timestamp: https://tc39.es/ecma262/#sec-timeclip
|
|
438
|
+
// Since there may be a precision loss when the timestamp is
|
|
439
|
+
// converted to a floating point number, we manually round
|
|
440
|
+
// the timestamp here before passing it to Date().
|
|
441
|
+
// Refs: https://github.com/nodejs/node/pull/12607
|
|
442
|
+
// Refs: https://github.com/nodejs/node/pull/43714
|
|
443
|
+
function dateFromMs(ms) {
|
|
444
|
+
// Coercing to number, ms can be bigint
|
|
445
|
+
return new Date(MathRound(Number(ms)));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const lazyDateFields = {
|
|
449
|
+
__proto__: null,
|
|
450
|
+
atime: {
|
|
451
|
+
__proto__: null,
|
|
452
|
+
enumerable: true,
|
|
453
|
+
configurable: true,
|
|
454
|
+
get() {
|
|
455
|
+
return this.atime = dateFromMs(this.atimeMs);
|
|
456
|
+
},
|
|
457
|
+
set(value) {
|
|
458
|
+
ObjectDefineProperty(this, 'atime', { __proto__: null, value, writable: true });
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
mtime: {
|
|
462
|
+
__proto__: null,
|
|
463
|
+
enumerable: true,
|
|
464
|
+
configurable: true,
|
|
465
|
+
get() {
|
|
466
|
+
return this.mtime = dateFromMs(this.mtimeMs);
|
|
467
|
+
},
|
|
468
|
+
set(value) {
|
|
469
|
+
ObjectDefineProperty(this, 'mtime', { __proto__: null, value, writable: true });
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
ctime: {
|
|
473
|
+
__proto__: null,
|
|
474
|
+
enumerable: true,
|
|
475
|
+
configurable: true,
|
|
476
|
+
get() {
|
|
477
|
+
return this.ctime = dateFromMs(this.ctimeMs);
|
|
478
|
+
},
|
|
479
|
+
set(value) {
|
|
480
|
+
ObjectDefineProperty(this, 'ctime', { __proto__: null, value, writable: true });
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
birthtime: {
|
|
484
|
+
__proto__: null,
|
|
485
|
+
enumerable: true,
|
|
486
|
+
configurable: true,
|
|
487
|
+
get() {
|
|
488
|
+
return this.birthtime = dateFromMs(this.birthtimeMs);
|
|
489
|
+
},
|
|
490
|
+
set(value) {
|
|
491
|
+
ObjectDefineProperty(this, 'birthtime', { __proto__: null, value, writable: true });
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
function BigIntStats(dev, mode, nlink, uid, gid, rdev, blksize,
|
|
497
|
+
ino, size, blocks,
|
|
498
|
+
atimeNs, mtimeNs, ctimeNs, birthtimeNs) {
|
|
499
|
+
ReflectApply(StatsBase, this, [dev, mode, nlink, uid, gid, rdev, blksize,
|
|
500
|
+
ino, size, blocks]);
|
|
501
|
+
|
|
502
|
+
this.atimeMs = atimeNs / kNsPerMsBigInt;
|
|
503
|
+
this.mtimeMs = mtimeNs / kNsPerMsBigInt;
|
|
504
|
+
this.ctimeMs = ctimeNs / kNsPerMsBigInt;
|
|
505
|
+
this.birthtimeMs = birthtimeNs / kNsPerMsBigInt;
|
|
506
|
+
this.atimeNs = atimeNs;
|
|
507
|
+
this.mtimeNs = mtimeNs;
|
|
508
|
+
this.ctimeNs = ctimeNs;
|
|
509
|
+
this.birthtimeNs = birthtimeNs;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
ObjectSetPrototypeOf(BigIntStats.prototype, StatsBase.prototype);
|
|
513
|
+
ObjectSetPrototypeOf(BigIntStats, StatsBase);
|
|
514
|
+
ObjectDefineProperties(BigIntStats.prototype, lazyDateFields);
|
|
515
|
+
|
|
516
|
+
BigIntStats.prototype._checkModeProperty = function(property) {
|
|
517
|
+
if (isWindows && (property === S_IFIFO || property === S_IFBLK ||
|
|
518
|
+
property === S_IFSOCK)) {
|
|
519
|
+
return false; // Some types are not available on Windows
|
|
520
|
+
}
|
|
521
|
+
return (this.mode & BigInt(S_IFMT)) === BigInt(property);
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
function Stats(dev, mode, nlink, uid, gid, rdev, blksize,
|
|
525
|
+
ino, size, blocks,
|
|
526
|
+
atimeMs, mtimeMs, ctimeMs, birthtimeMs) {
|
|
527
|
+
FunctionPrototypeCall(StatsBase, this, dev, mode, nlink, uid, gid, rdev,
|
|
528
|
+
blksize, ino, size, blocks);
|
|
529
|
+
this.atimeMs = atimeMs;
|
|
530
|
+
this.mtimeMs = mtimeMs;
|
|
531
|
+
this.ctimeMs = ctimeMs;
|
|
532
|
+
this.birthtimeMs = birthtimeMs;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
ObjectSetPrototypeOf(Stats.prototype, StatsBase.prototype);
|
|
536
|
+
ObjectSetPrototypeOf(Stats, StatsBase);
|
|
537
|
+
ObjectDefineProperties(Stats.prototype, lazyDateFields);
|
|
538
|
+
|
|
539
|
+
Stats.prototype._checkModeProperty = function(property) {
|
|
540
|
+
if (isWindows && (property === S_IFIFO || property === S_IFBLK ||
|
|
541
|
+
property === S_IFSOCK)) {
|
|
542
|
+
return false; // Some types are not available on Windows
|
|
543
|
+
}
|
|
544
|
+
return (this.mode & S_IFMT) === property;
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* @param {Float64Array | BigInt64Array} stats
|
|
549
|
+
* @param {number} offset
|
|
550
|
+
* @returns {BigIntStats | Stats}
|
|
551
|
+
*/
|
|
552
|
+
function getStatsFromBinding(stats, offset = 0) {
|
|
553
|
+
if (isBigInt64Array(stats)) {
|
|
554
|
+
return new BigIntStats(
|
|
555
|
+
stats[0 + offset], stats[1 + offset], stats[2 + offset],
|
|
556
|
+
stats[3 + offset], stats[4 + offset], stats[5 + offset],
|
|
557
|
+
stats[6 + offset], stats[7 + offset], stats[8 + offset],
|
|
558
|
+
stats[9 + offset],
|
|
559
|
+
nsFromTimeSpecBigInt(stats[10 + offset], stats[11 + offset]),
|
|
560
|
+
nsFromTimeSpecBigInt(stats[12 + offset], stats[13 + offset]),
|
|
561
|
+
nsFromTimeSpecBigInt(stats[14 + offset], stats[15 + offset]),
|
|
562
|
+
nsFromTimeSpecBigInt(stats[16 + offset], stats[17 + offset]),
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
return new Stats(
|
|
566
|
+
stats[0 + offset], stats[1 + offset], stats[2 + offset],
|
|
567
|
+
stats[3 + offset], stats[4 + offset], stats[5 + offset],
|
|
568
|
+
stats[6 + offset], stats[7 + offset], stats[8 + offset],
|
|
569
|
+
stats[9 + offset],
|
|
570
|
+
msFromTimeSpec(stats[10 + offset], stats[11 + offset]),
|
|
571
|
+
msFromTimeSpec(stats[12 + offset], stats[13 + offset]),
|
|
572
|
+
msFromTimeSpec(stats[14 + offset], stats[15 + offset]),
|
|
573
|
+
msFromTimeSpec(stats[16 + offset], stats[17 + offset]),
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
class StatFs {
|
|
578
|
+
constructor(type, bsize, blocks, bfree, bavail, files, ffree) {
|
|
579
|
+
this.type = type;
|
|
580
|
+
this.bsize = bsize;
|
|
581
|
+
this.blocks = blocks;
|
|
582
|
+
this.bfree = bfree;
|
|
583
|
+
this.bavail = bavail;
|
|
584
|
+
this.files = files;
|
|
585
|
+
this.ffree = ffree;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function getStatFsFromBinding(stats) {
|
|
590
|
+
return new StatFs(
|
|
591
|
+
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[6],
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function stringToFlags(flags, name = 'flags') {
|
|
596
|
+
if (typeof flags === 'number') {
|
|
597
|
+
validateInt32(flags, name);
|
|
598
|
+
return flags;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (flags == null) {
|
|
602
|
+
return O_RDONLY;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
switch (flags) {
|
|
606
|
+
case 'r' : return O_RDONLY;
|
|
607
|
+
case 'rs' : // Fall through.
|
|
608
|
+
case 'sr' : return O_RDONLY | O_SYNC;
|
|
609
|
+
case 'r+' : return O_RDWR;
|
|
610
|
+
case 'rs+' : // Fall through.
|
|
611
|
+
case 'sr+' : return O_RDWR | O_SYNC;
|
|
612
|
+
|
|
613
|
+
case 'w' : return O_TRUNC | O_CREAT | O_WRONLY;
|
|
614
|
+
case 'wx' : // Fall through.
|
|
615
|
+
case 'xw' : return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL;
|
|
616
|
+
|
|
617
|
+
case 'w+' : return O_TRUNC | O_CREAT | O_RDWR;
|
|
618
|
+
case 'wx+': // Fall through.
|
|
619
|
+
case 'xw+': return O_TRUNC | O_CREAT | O_RDWR | O_EXCL;
|
|
620
|
+
|
|
621
|
+
case 'a' : return O_APPEND | O_CREAT | O_WRONLY;
|
|
622
|
+
case 'ax' : // Fall through.
|
|
623
|
+
case 'xa' : return O_APPEND | O_CREAT | O_WRONLY | O_EXCL;
|
|
624
|
+
case 'as' : // Fall through.
|
|
625
|
+
case 'sa' : return O_APPEND | O_CREAT | O_WRONLY | O_SYNC;
|
|
626
|
+
|
|
627
|
+
case 'a+' : return O_APPEND | O_CREAT | O_RDWR;
|
|
628
|
+
case 'ax+': // Fall through.
|
|
629
|
+
case 'xa+': return O_APPEND | O_CREAT | O_RDWR | O_EXCL;
|
|
630
|
+
case 'as+': // Fall through.
|
|
631
|
+
case 'sa+': return O_APPEND | O_CREAT | O_RDWR | O_SYNC;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
throw new ERR_INVALID_ARG_VALUE('flags', flags);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
const stringToSymlinkType = hideStackFrames((type) => {
|
|
638
|
+
let flags = 0;
|
|
639
|
+
if (typeof type === 'string') {
|
|
640
|
+
switch (type) {
|
|
641
|
+
case 'dir':
|
|
642
|
+
flags |= UV_FS_SYMLINK_DIR;
|
|
643
|
+
break;
|
|
644
|
+
case 'junction':
|
|
645
|
+
flags |= UV_FS_SYMLINK_JUNCTION;
|
|
646
|
+
break;
|
|
647
|
+
case 'file':
|
|
648
|
+
break;
|
|
649
|
+
default:
|
|
650
|
+
throw new ERR_FS_INVALID_SYMLINK_TYPE(type);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return flags;
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// converts Date or number to a fractional UNIX timestamp
|
|
657
|
+
function toUnixTimestamp(time, name = 'time') {
|
|
658
|
+
// eslint-disable-next-line eqeqeq
|
|
659
|
+
if (typeof time === 'string' && +time == time) {
|
|
660
|
+
return +time;
|
|
661
|
+
}
|
|
662
|
+
if (NumberIsFinite(time)) {
|
|
663
|
+
if (time < 0) {
|
|
664
|
+
return DateNow() / 1000;
|
|
665
|
+
}
|
|
666
|
+
return time;
|
|
667
|
+
}
|
|
668
|
+
if (isDate(time)) {
|
|
669
|
+
// Convert to 123.456 UNIX timestamp
|
|
670
|
+
return DatePrototypeGetTime(time) / 1000;
|
|
671
|
+
}
|
|
672
|
+
throw new ERR_INVALID_ARG_TYPE(name, ['Date', 'Time in seconds'], time);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const validateOffsetLengthRead = hideStackFrames(
|
|
676
|
+
(offset, length, bufferLength) => {
|
|
677
|
+
if (offset < 0) {
|
|
678
|
+
throw new ERR_OUT_OF_RANGE.HideStackFramesError('offset', '>= 0', offset);
|
|
679
|
+
}
|
|
680
|
+
if (length < 0) {
|
|
681
|
+
throw new ERR_OUT_OF_RANGE.HideStackFramesError('length', '>= 0', length);
|
|
682
|
+
}
|
|
683
|
+
if (offset + length > bufferLength) {
|
|
684
|
+
throw new ERR_OUT_OF_RANGE.HideStackFramesError('length',
|
|
685
|
+
`<= ${bufferLength - offset}`, length);
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
);
|
|
689
|
+
|
|
690
|
+
const validateOffsetLengthWrite = hideStackFrames(
|
|
691
|
+
(offset, length, byteLength) => {
|
|
692
|
+
if (offset > byteLength) {
|
|
693
|
+
throw new ERR_OUT_OF_RANGE.HideStackFramesError('offset', `<= ${byteLength}`, offset);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (length > byteLength - offset) {
|
|
697
|
+
throw new ERR_OUT_OF_RANGE.HideStackFramesError('length', `<= ${byteLength - offset}`, length);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (length < 0) {
|
|
701
|
+
throw new ERR_OUT_OF_RANGE.HideStackFramesError('length', '>= 0', length);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
validateInt32.withoutStackTrace(length, 'length', 0);
|
|
705
|
+
},
|
|
706
|
+
);
|
|
707
|
+
|
|
708
|
+
const validatePath = hideStackFrames((path, propName = 'path') => {
|
|
709
|
+
if (typeof path !== 'string' && !isUint8Array(path)) {
|
|
710
|
+
throw new ERR_INVALID_ARG_TYPE.HideStackFramesError(propName, ['string', 'Buffer', 'URL'], path);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const pathIsString = typeof path === 'string';
|
|
714
|
+
const pathIsUint8Array = isUint8Array(path);
|
|
715
|
+
|
|
716
|
+
// We can only perform meaningful checks on strings and Uint8Arrays.
|
|
717
|
+
if ((!pathIsString && !pathIsUint8Array) ||
|
|
718
|
+
(pathIsString && !StringPrototypeIncludes(path, '\u0000')) ||
|
|
719
|
+
(pathIsUint8Array && !TypedArrayPrototypeIncludes(path, 0))) {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
throw new ERR_INVALID_ARG_VALUE.HideStackFramesError(
|
|
724
|
+
propName,
|
|
725
|
+
path,
|
|
726
|
+
'must be a string, Uint8Array, or URL without null bytes',
|
|
727
|
+
);
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
const getValidatedPath = hideStackFrames((fileURLOrPath, propName = 'path') => {
|
|
731
|
+
const path = toPathIfFileURL(fileURLOrPath);
|
|
732
|
+
validatePath(path, propName);
|
|
733
|
+
return path;
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
const getValidatedFd = hideStackFrames((fd, propName = 'fd') => {
|
|
737
|
+
if (ObjectIs(fd, -0)) {
|
|
738
|
+
return 0;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
validateInt32(fd, propName, 0);
|
|
742
|
+
|
|
743
|
+
return fd;
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
const validateBufferArray = hideStackFrames((buffers, propName = 'buffers') => {
|
|
747
|
+
if (!ArrayIsArray(buffers))
|
|
748
|
+
throw new ERR_INVALID_ARG_TYPE.HideStackFramesError(propName, 'ArrayBufferView[]', buffers);
|
|
749
|
+
|
|
750
|
+
for (let i = 0; i < buffers.length; i++) {
|
|
751
|
+
if (!isArrayBufferView(buffers[i]))
|
|
752
|
+
throw new ERR_INVALID_ARG_TYPE.HideStackFramesError(propName, 'ArrayBufferView[]', buffers);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
return buffers;
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
let nonPortableTemplateWarn = true;
|
|
759
|
+
|
|
760
|
+
function warnOnNonPortableTemplate(template) {
|
|
761
|
+
// Template strings passed to the mkdtemp() family of functions should not
|
|
762
|
+
// end with 'X' because they are handled inconsistently across platforms.
|
|
763
|
+
if (nonPortableTemplateWarn &&
|
|
764
|
+
((typeof template === 'string' && StringPrototypeEndsWith(template, 'X')) ||
|
|
765
|
+
(typeof template !== 'string' && TypedArrayPrototypeAt(template, -1) === 0x58))) {
|
|
766
|
+
process.emitWarning('mkdtemp() templates ending with X are not portable. ' +
|
|
767
|
+
'For details see: https://nodejs.org/api/fs.html');
|
|
768
|
+
nonPortableTemplateWarn = false;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
const defaultCpOptions = {
|
|
773
|
+
dereference: false,
|
|
774
|
+
errorOnExist: false,
|
|
775
|
+
filter: undefined,
|
|
776
|
+
force: true,
|
|
777
|
+
preserveTimestamps: false,
|
|
778
|
+
recursive: false,
|
|
779
|
+
verbatimSymlinks: false,
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
const defaultRmOptions = {
|
|
783
|
+
recursive: false,
|
|
784
|
+
force: false,
|
|
785
|
+
retryDelay: 100,
|
|
786
|
+
maxRetries: 0,
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
const defaultRmdirOptions = {
|
|
790
|
+
retryDelay: 100,
|
|
791
|
+
maxRetries: 0,
|
|
792
|
+
recursive: false,
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
const validateCpOptions = hideStackFrames((options) => {
|
|
796
|
+
if (options === undefined)
|
|
797
|
+
return { ...defaultCpOptions };
|
|
798
|
+
validateObject(options, 'options');
|
|
799
|
+
options = { ...defaultCpOptions, ...options };
|
|
800
|
+
validateBoolean(options.dereference, 'options.dereference');
|
|
801
|
+
validateBoolean(options.errorOnExist, 'options.errorOnExist');
|
|
802
|
+
validateBoolean(options.force, 'options.force');
|
|
803
|
+
validateBoolean(options.preserveTimestamps, 'options.preserveTimestamps');
|
|
804
|
+
validateBoolean(options.recursive, 'options.recursive');
|
|
805
|
+
validateBoolean(options.verbatimSymlinks, 'options.verbatimSymlinks');
|
|
806
|
+
options.mode = getValidMode(options.mode, 'copyFile');
|
|
807
|
+
if (options.dereference === true && options.verbatimSymlinks === true) {
|
|
808
|
+
throw new ERR_INCOMPATIBLE_OPTION_PAIR.HideStackFramesError('dereference', 'verbatimSymlinks');
|
|
809
|
+
}
|
|
810
|
+
if (options.filter !== undefined) {
|
|
811
|
+
validateFunction(options.filter, 'options.filter');
|
|
812
|
+
}
|
|
813
|
+
return options;
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
const validateRmOptions = hideStackFrames((path, options, expectDir, cb) => {
|
|
817
|
+
options = validateRmdirOptions(options, defaultRmOptions);
|
|
818
|
+
validateBoolean(options.force, 'options.force');
|
|
819
|
+
|
|
820
|
+
lazyLoadFs().lstat(path, (err, stats) => {
|
|
821
|
+
if (err) {
|
|
822
|
+
if (options.force && err.code === 'ENOENT') {
|
|
823
|
+
return cb(null, options);
|
|
824
|
+
}
|
|
825
|
+
return cb(err, options);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
if (expectDir && !stats.isDirectory()) {
|
|
829
|
+
return cb(false);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
if (stats.isDirectory() && !options.recursive) {
|
|
833
|
+
const err = new ERR_FS_EISDIR.HideStackFramesError({
|
|
834
|
+
code: 'EISDIR',
|
|
835
|
+
message: 'is a directory',
|
|
836
|
+
path,
|
|
837
|
+
syscall: 'rm',
|
|
838
|
+
errno: EISDIR,
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
return cb(err);
|
|
842
|
+
}
|
|
843
|
+
return cb(null, options);
|
|
844
|
+
});
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
const validateRmOptionsSync = hideStackFrames((path, options, expectDir) => {
|
|
848
|
+
options = validateRmdirOptions.withoutStackTrace(options, defaultRmOptions);
|
|
849
|
+
validateBoolean.withoutStackTrace(options.force, 'options.force');
|
|
850
|
+
|
|
851
|
+
if (!options.force || expectDir || !options.recursive) {
|
|
852
|
+
const isDirectory = lazyLoadFs()
|
|
853
|
+
.lstatSync(path, { throwIfNoEntry: !options.force })?.isDirectory();
|
|
854
|
+
|
|
855
|
+
if (expectDir && !isDirectory) {
|
|
856
|
+
return false;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
if (isDirectory && !options.recursive) {
|
|
860
|
+
throw new ERR_FS_EISDIR.HideStackFramesError({
|
|
861
|
+
code: 'EISDIR',
|
|
862
|
+
message: 'is a directory',
|
|
863
|
+
path,
|
|
864
|
+
syscall: 'rm',
|
|
865
|
+
errno: EISDIR,
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
return options;
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
let recursiveRmdirWarned;
|
|
874
|
+
function emitRecursiveRmdirWarning() {
|
|
875
|
+
if (recursiveRmdirWarned === undefined) {
|
|
876
|
+
// TODO(joyeecheung): use getOptionValue('--no-deprecation') instead.
|
|
877
|
+
recursiveRmdirWarned = process.noDeprecation;
|
|
878
|
+
}
|
|
879
|
+
if (!recursiveRmdirWarned) {
|
|
880
|
+
process.emitWarning(
|
|
881
|
+
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +
|
|
882
|
+
'will be removed. Use fs.rm(path, { recursive: true }) instead',
|
|
883
|
+
'DeprecationWarning',
|
|
884
|
+
'DEP0147',
|
|
885
|
+
);
|
|
886
|
+
recursiveRmdirWarned = true;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
const validateRmdirOptions = hideStackFrames(
|
|
891
|
+
(options, defaults = defaultRmdirOptions) => {
|
|
892
|
+
if (options === undefined)
|
|
893
|
+
return defaults;
|
|
894
|
+
validateObject.withoutStackTrace(options, 'options');
|
|
895
|
+
|
|
896
|
+
options = { ...defaults, ...options };
|
|
897
|
+
|
|
898
|
+
validateBoolean.withoutStackTrace(options.recursive, 'options.recursive');
|
|
899
|
+
validateInt32.withoutStackTrace(options.retryDelay, 'options.retryDelay', 0);
|
|
900
|
+
validateUint32.withoutStackTrace(options.maxRetries, 'options.maxRetries');
|
|
901
|
+
|
|
902
|
+
return options;
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
const getValidMode = hideStackFrames((mode, type) => {
|
|
906
|
+
let min = kMinimumAccessMode;
|
|
907
|
+
let max = kMaximumAccessMode;
|
|
908
|
+
let def = F_OK;
|
|
909
|
+
if (type === 'copyFile') {
|
|
910
|
+
min = kMinimumCopyMode;
|
|
911
|
+
max = kMaximumCopyMode;
|
|
912
|
+
def = mode || kDefaultCopyMode;
|
|
913
|
+
} else {
|
|
914
|
+
assert(type === 'access');
|
|
915
|
+
}
|
|
916
|
+
if (mode == null) {
|
|
917
|
+
return def;
|
|
918
|
+
}
|
|
919
|
+
validateInteger.withoutStackTrace(mode, 'mode', min, max);
|
|
920
|
+
return mode;
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
const validateStringAfterArrayBufferView = hideStackFrames((buffer, name) => {
|
|
924
|
+
if (typeof buffer !== 'string') {
|
|
925
|
+
throw new ERR_INVALID_ARG_TYPE.HideStackFramesError(
|
|
926
|
+
name,
|
|
927
|
+
['string', 'Buffer', 'TypedArray', 'DataView'],
|
|
928
|
+
buffer,
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
const validatePosition = hideStackFrames((position, name, length) => {
|
|
934
|
+
if (typeof position === 'number') {
|
|
935
|
+
validateInteger.withoutStackTrace(position, name, -1);
|
|
936
|
+
} else if (typeof position === 'bigint') {
|
|
937
|
+
const maxPosition = 2n ** 63n - 1n - BigInt(length);
|
|
938
|
+
if (!(position >= -1n && position <= maxPosition)) {
|
|
939
|
+
throw new ERR_OUT_OF_RANGE.HideStackFramesError(name,
|
|
940
|
+
`>= -1 && <= ${maxPosition}`,
|
|
941
|
+
position);
|
|
942
|
+
}
|
|
943
|
+
} else {
|
|
944
|
+
throw new ERR_INVALID_ARG_TYPE.HideStackFramesError(name, ['integer', 'bigint'], position);
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
module.exports = {
|
|
949
|
+
constants: {
|
|
950
|
+
kIoMaxLength,
|
|
951
|
+
kMaxUserId,
|
|
952
|
+
kReadFileBufferLength,
|
|
953
|
+
kReadFileUnknownBufferLength,
|
|
954
|
+
kWriteFileMaxChunkSize,
|
|
955
|
+
},
|
|
956
|
+
assertEncoding,
|
|
957
|
+
BigIntStats, // for testing
|
|
958
|
+
copyObject,
|
|
959
|
+
Dirent,
|
|
960
|
+
DirentFromStats,
|
|
961
|
+
emitRecursiveRmdirWarning,
|
|
962
|
+
getDirent,
|
|
963
|
+
getDirents,
|
|
964
|
+
getOptions,
|
|
965
|
+
getValidatedFd,
|
|
966
|
+
getValidatedPath,
|
|
967
|
+
handleErrorFromBinding,
|
|
968
|
+
preprocessSymlinkDestination,
|
|
969
|
+
realpathCacheKey: Symbol('realpathCacheKey'),
|
|
970
|
+
getStatFsFromBinding,
|
|
971
|
+
getStatsFromBinding,
|
|
972
|
+
stringToFlags,
|
|
973
|
+
stringToSymlinkType,
|
|
974
|
+
Stats: deprecate(Stats, 'fs.Stats constructor is deprecated.', 'DEP0180'),
|
|
975
|
+
toUnixTimestamp,
|
|
976
|
+
validateBufferArray,
|
|
977
|
+
validateCpOptions,
|
|
978
|
+
validateOffsetLengthRead,
|
|
979
|
+
validateOffsetLengthWrite,
|
|
980
|
+
validatePath,
|
|
981
|
+
validatePosition,
|
|
982
|
+
validateRmOptions,
|
|
983
|
+
validateRmOptionsSync,
|
|
984
|
+
validateRmdirOptions,
|
|
985
|
+
validateStringAfterArrayBufferView,
|
|
986
|
+
warnOnNonPortableTemplate,
|
|
987
|
+
};
|