visaljs 0.0.7 → 0.0.8
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/README.md +63 -2
- package/THIRD_PARTY_LICENSES +1216 -0
- package/cli.js +4413 -324
- package/node/include/js_node.h +57 -1
- package/node/include/js_uv.h +8 -1
- package/node/prelude/_stream_duplex.js +4 -0
- package/node/prelude/_stream_passthrough.js +4 -0
- package/node/prelude/_stream_readable.js +4 -0
- package/node/prelude/_stream_transform.js +4 -0
- package/node/prelude/_stream_writable.js +4 -0
- package/node/prelude/assert.js +1334 -0
- package/node/prelude/assert_strict.js +12 -0
- package/node/prelude/async_hooks.js +1 -1
- package/node/prelude/buffer.js +43 -3
- package/node/prelude/child_process.js +1098 -0
- package/node/prelude/cluster.js +52 -0
- package/node/prelude/console.js +328 -0
- package/node/prelude/constants.js +10 -0
- package/node/prelude/crypto.js +1 -1
- package/node/prelude/diagnostics_channel.js +1 -1
- package/node/prelude/dns.js +1 -1
- package/node/prelude/domain.js +115 -0
- package/node/prelude/events.js +144 -16
- package/node/prelude/fs.js +1138 -151
- package/node/prelude/fs_promises.js +117 -11
- package/node/prelude/http.js +104 -27
- package/node/prelude/http2.js +1 -1
- package/node/prelude/https.js +148 -0
- package/node/prelude/inspector.js +27 -0
- package/node/prelude/inspector_promises.js +4 -0
- package/node/prelude/internal/async_context.js +1 -1
- package/node/prelude/internal/buffer_transcode.js +44 -0
- package/node/prelude/internal/comparisons.js +916 -0
- package/node/prelude/internal/compression_streams.js +153 -0
- package/node/prelude/internal/crypto/asym.js +27 -14
- package/node/prelude/internal/crypto/cipher.js +16 -5
- package/node/prelude/internal/crypto/diffiehellman.js +3 -2
- package/node/prelude/internal/crypto/hash.js +2 -1
- package/node/prelude/internal/crypto/kdf.js +14 -9
- package/node/prelude/internal/crypto/keys.js +63 -50
- package/node/prelude/internal/crypto/random.js +2 -1
- package/node/prelude/internal/crypto/util.js +4 -4
- package/node/prelude/internal/dotenv.js +98 -0
- package/node/prelude/internal/errors.js +21 -5
- package/node/prelude/internal/events_extras.js +116 -0
- package/node/prelude/internal/events_on.js +100 -0
- package/node/prelude/internal/features.js +55 -0
- package/node/prelude/internal/fetch.js +364 -0
- package/node/prelude/internal/form_data.js +376 -0
- package/node/prelude/internal/fs_bigint_stats.js +41 -0
- package/node/prelude/internal/fs_blob.js +19 -0
- package/node/prelude/internal/fs_cp.js +709 -0
- package/node/prelude/internal/fs_dir.js +166 -0
- package/node/prelude/internal/fs_filehandle.js +287 -0
- package/node/prelude/internal/fs_glob.js +296 -0
- package/node/prelude/internal/fs_statfs.js +42 -0
- package/node/prelude/internal/fs_stats.js +89 -0
- package/node/prelude/internal/fs_streams.js +541 -0
- package/node/prelude/internal/fs_utils.js +286 -0
- package/node/prelude/internal/fs_watch.js +580 -0
- package/node/prelude/internal/http_agent.js +26 -0
- package/node/prelude/internal/mime.js +249 -0
- package/node/prelude/internal/net.js +1 -0
- package/node/prelude/internal/parse_args.js +288 -0
- package/node/prelude/internal/perf_histogram.js +435 -0
- package/node/prelude/internal/perf_observe.js +119 -0
- package/node/prelude/internal/performance_global.js +19 -0
- package/node/prelude/internal/process_events.js +49 -1
- package/node/prelude/internal/process_memory.js +14 -0
- package/node/prelude/internal/process_more.js +414 -0
- package/node/prelude/internal/process_signals.js +2 -1
- package/node/prelude/internal/process_stdin.js +52 -0
- package/node/prelude/internal/process_stdio.js +36 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/readline.js +338 -0
- package/node/prelude/internal/socketaddress.js +8 -4
- package/node/prelude/internal/source_map.js +122 -0
- package/node/prelude/internal/stream_compose.js +74 -0
- package/node/prelude/internal/stream_from.js +6 -0
- package/node/prelude/internal/stream_operators.js +23 -0
- package/node/prelude/internal/stream_pipeline.js +7 -0
- package/node/prelude/internal/stream_transform.js +10 -0
- package/node/prelude/internal/stream_web_adapters.js +143 -0
- package/node/prelude/internal/streams/add_abort_signal.js +58 -0
- package/node/prelude/internal/streams/compose.js +244 -0
- package/node/prelude/internal/streams/destroy.js +358 -0
- package/node/prelude/internal/streams/duplex.js +199 -0
- package/node/prelude/internal/streams/duplexify.js +378 -0
- package/node/prelude/internal/streams/end_of_stream.js +387 -0
- package/node/prelude/internal/streams/errors.js +216 -0
- package/node/prelude/internal/streams/from.js +211 -0
- package/node/prelude/internal/streams/legacy.js +120 -0
- package/node/prelude/internal/streams/operators.js +375 -0
- package/node/prelude/internal/streams/passthrough.js +45 -0
- package/node/prelude/internal/streams/pipeline.js +468 -0
- package/node/prelude/internal/streams/readable.js +1835 -0
- package/node/prelude/internal/streams/state.js +48 -0
- package/node/prelude/internal/streams/transform.js +203 -0
- package/node/prelude/internal/streams/utils.js +355 -0
- package/node/prelude/internal/streams/validators.js +108 -0
- package/node/prelude/internal/streams/writable.js +1160 -0
- package/node/prelude/internal/structured_clone.js +238 -0
- package/node/prelude/internal/system_errors.js +37 -0
- package/node/prelude/internal/test_runner/mock.js +431 -0
- package/node/prelude/internal/test_runner/reporters.js +404 -0
- package/node/prelude/internal/test_runner/test.js +1571 -0
- package/node/prelude/internal/timers.js +38 -7
- package/node/prelude/internal/timers_global.js +1 -1
- package/node/prelude/internal/tls/common.js +8 -2
- package/node/prelude/internal/tls/wrap.js +3 -15
- package/node/prelude/internal/tls/x509.js +1 -1
- package/node/prelude/internal/tty_read_stream.js +39 -0
- package/node/prelude/internal/tty_streams.js +3 -0
- package/node/prelude/internal/util_debuglog.js +68 -0
- package/node/prelude/internal/util_diff.js +63 -0
- package/node/prelude/internal/util_more.js +111 -0
- package/node/prelude/internal/util_styles.js +76 -0
- package/node/prelude/internal/zlib_engines.js +1 -1
- package/node/prelude/module.js +194 -7
- package/node/prelude/net.js +2 -1
- package/node/prelude/os.js +88 -11
- package/node/prelude/path.js +11 -7
- package/node/prelude/path_posix.js +1 -1
- package/node/prelude/path_win32.js +1 -1
- package/node/prelude/perf_hooks.js +147 -0
- package/node/prelude/process.js +36 -1
- package/node/prelude/punycode.js +188 -0
- package/node/prelude/querystring.js +1 -1
- package/node/prelude/readline.js +8 -0
- package/node/prelude/readline_promises.js +88 -0
- package/node/prelude/repl.js +38 -0
- package/node/prelude/sea.js +23 -0
- package/node/prelude/stream.js +70 -1332
- package/node/prelude/stream_consumers.js +34 -0
- package/node/prelude/stream_promises.js +1 -1
- package/node/prelude/stream_web.js +15 -2
- package/node/prelude/string_decoder.js +1 -1
- package/node/prelude/sys.js +7 -0
- package/node/prelude/test.js +56 -0
- package/node/prelude/test_reporters.js +269 -0
- package/node/prelude/timers.js +7 -84
- package/node/prelude/timers_promises.js +1 -1
- package/node/prelude/tls.js +2 -1
- package/node/prelude/trace_events.js +52 -0
- package/node/prelude/tty.js +10 -4
- package/node/prelude/url.js +88 -27
- package/node/prelude/util.js +121 -5
- package/node/prelude/util_types.js +4 -3
- package/node/prelude/v8.js +814 -0
- package/node/prelude/vm.js +86 -0
- package/node/prelude/wasi.js +10 -0
- package/node/prelude/worker_threads.js +56 -0
- package/node/prelude/zlib.js +58 -25
- package/node/src/host_brotli.c +59 -11
- package/node/src/host_fs.c +342 -11
- package/node/src/host_fswatch.c +170 -0
- package/node/src/host_http.c +143 -20
- package/node/src/host_loop.c +25 -2
- package/node/src/host_net.c +55 -7
- package/node/src/host_os.c +55 -1
- package/node/src/host_proc.c +291 -0
- package/node/src/host_process.c +488 -0
- package/node/src/host_sys.c +64 -2
- package/node/src/host_zlib.c +27 -7
- package/node/src/host_zstd.c +41 -6
- package/node/third_party/hdrhistogram/LICENSE +42 -0
- package/node/third_party/hdrhistogram/README.md +5 -0
- package/node/third_party/libuv/LICENSE +0 -0
- package/node/third_party/libuv/LICENSE-extra +36 -0
- package/node/third_party/libuv/include/uv/aix.h +0 -0
- package/node/third_party/libuv/include/uv/bsd.h +0 -0
- package/node/third_party/libuv/include/uv/darwin.h +0 -0
- package/node/third_party/libuv/include/uv/errno.h +0 -0
- package/node/third_party/libuv/include/uv/linux.h +0 -0
- package/node/third_party/libuv/include/uv/os390.h +0 -0
- package/node/third_party/libuv/include/uv/posix.h +0 -0
- package/node/third_party/libuv/include/uv/sunos.h +0 -0
- package/node/third_party/libuv/include/uv/threadpool.h +0 -0
- package/node/third_party/libuv/include/uv/tree.h +0 -0
- package/node/third_party/libuv/include/uv/unix.h +0 -0
- package/node/third_party/libuv/include/uv/version.h +0 -0
- package/node/third_party/libuv/include/uv/win.h +0 -0
- package/node/third_party/libuv/include/uv.h +0 -0
- package/node/third_party/libuv/src/fs-poll.c +0 -0
- package/node/third_party/libuv/src/heap-inl.h +0 -0
- package/node/third_party/libuv/src/idna.c +0 -0
- package/node/third_party/libuv/src/idna.h +0 -0
- package/node/third_party/libuv/src/inet.c +0 -0
- package/node/third_party/libuv/src/queue.h +0 -0
- package/node/third_party/libuv/src/random.c +0 -0
- package/node/third_party/libuv/src/strscpy.c +0 -0
- package/node/third_party/libuv/src/strscpy.h +0 -0
- package/node/third_party/libuv/src/strtok.c +0 -0
- package/node/third_party/libuv/src/strtok.h +0 -0
- package/node/third_party/libuv/src/thread-common.c +0 -0
- package/node/third_party/libuv/src/threadpool.c +0 -0
- package/node/third_party/libuv/src/timer.c +0 -0
- package/node/third_party/libuv/src/unix/async.c +0 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
- package/node/third_party/libuv/src/unix/core.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
- package/node/third_party/libuv/src/unix/darwin.c +0 -0
- package/node/third_party/libuv/src/unix/dl.c +0 -0
- package/node/third_party/libuv/src/unix/fs.c +0 -0
- package/node/third_party/libuv/src/unix/fsevents.c +0 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
- package/node/third_party/libuv/src/unix/internal.h +0 -0
- package/node/third_party/libuv/src/unix/kqueue.c +0 -0
- package/node/third_party/libuv/src/unix/linux.c +0 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
- package/node/third_party/libuv/src/unix/loop.c +0 -0
- package/node/third_party/libuv/src/unix/pipe.c +0 -0
- package/node/third_party/libuv/src/unix/poll.c +0 -0
- package/node/third_party/libuv/src/unix/process.c +0 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
- package/node/third_party/libuv/src/unix/proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
- package/node/third_party/libuv/src/unix/signal.c +0 -0
- package/node/third_party/libuv/src/unix/stream.c +0 -0
- package/node/third_party/libuv/src/unix/tcp.c +0 -0
- package/node/third_party/libuv/src/unix/thread.c +0 -0
- package/node/third_party/libuv/src/unix/tty.c +0 -0
- package/node/third_party/libuv/src/unix/udp.c +0 -0
- package/node/third_party/libuv/src/uv-common.c +0 -0
- package/node/third_party/libuv/src/uv-common.h +0 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
- package/node/third_party/libuv/src/version.c +0 -0
- package/node/third_party/llhttp/LICENSE +0 -0
- package/node/third_party/llhttp/api.c +0 -0
- package/node/third_party/llhttp/http.c +0 -0
- package/node/third_party/llhttp/llhttp.c +0 -0
- package/node/third_party/llhttp/llhttp.h +0 -0
- package/node/third_party/nodejs/LICENSE +47 -0
- package/node/third_party/nodejs/README.md +5 -0
- package/node/third_party/parseargs/LICENSE +21 -0
- package/node/third_party/parseargs/README.md +5 -0
- package/node/third_party/punycode/LICENSE +20 -0
- package/node/third_party/punycode/README.md +5 -0
- package/node/third_party/zlib/LICENSE.chromium +27 -0
- package/package.json +1 -1
- package/prebuilt/darwin-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-arm64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-arm64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/darwin-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-x64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-x64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_atoms.gen.h +0 -0
- package/runtime/include/js_atoms.h +1 -1
- package/runtime/include/js_bigint.h +1 -1
- package/runtime/include/js_buffer.h +4 -4
- package/runtime/include/js_builtins.h +41 -3
- package/runtime/include/js_console.h +9 -4
- package/runtime/include/js_convert.h +1 -1
- package/runtime/include/js_core.def +5 -4
- package/runtime/include/js_crypto.h +1 -1
- package/runtime/include/js_error.h +1 -1
- package/runtime/include/js_exception.h +21 -1
- package/runtime/include/js_function.h +33 -9
- package/runtime/include/js_gc.h +172 -30
- package/runtime/include/js_generator.h +2 -2
- package/runtime/include/js_host.h +19 -1
- package/runtime/include/js_jobs.h +5 -5
- package/runtime/include/js_module.h +1 -1
- package/runtime/include/js_object.h +142 -15
- package/runtime/include/js_ops.h +107 -5
- package/runtime/include/js_promise.h +3 -3
- package/runtime/include/js_regexp.h +1 -1
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +1 -1
- package/runtime/include/js_web.h +2 -1
- package/runtime/include/jscell.h +22 -15
- package/runtime/include/jscontext.h +74 -39
- package/runtime/include/jsnum.h +1 -1
- package/runtime/include/jsstring.h +19 -6
- package/runtime/include/jsvalue.h +7 -3
- package/runtime/src/arguments.c +2 -2
- package/runtime/src/array.c +4 -1
- package/runtime/src/arraybuffer.c +19 -7
- package/runtime/src/async_iter.c +4 -3
- package/runtime/src/atoms.c +1 -1
- package/runtime/src/base64.c +2 -2
- package/runtime/src/bigint.c +1 -1
- package/runtime/src/blob.c +22 -9
- package/runtime/src/boringssl_support.cc +1 -1
- package/runtime/src/buffer.c +299 -91
- package/runtime/src/builtin_table.c +1 -1
- package/runtime/src/builtins.c +30 -4
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +18 -3
- package/runtime/src/components.c +1 -1
- package/runtime/src/console.c +14 -7
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +1 -1
- package/runtime/src/crypto.c +1 -1
- package/runtime/src/crypto_asym.c +1 -1
- package/runtime/src/crypto_bn.c +1 -1
- package/runtime/src/crypto_cipher.c +10 -3
- package/runtime/src/crypto_hash.c +1 -1
- package/runtime/src/crypto_host.c +1 -1
- package/runtime/src/crypto_internal.h +1 -1
- package/runtime/src/crypto_kdf.c +1 -1
- package/runtime/src/crypto_key.c +14 -1
- package/runtime/src/crypto_pkey.c +1 -1
- package/runtime/src/crypto_subtle.c +142 -58
- package/runtime/src/crypto_tls.c +1 -1
- package/runtime/src/date.c +5 -2
- package/runtime/src/domexception.c +2 -2
- package/runtime/src/elements.c +56 -17
- package/runtime/src/elements.h +7 -2
- package/runtime/src/encoding.c +1 -1
- package/runtime/src/error.c +4 -4
- package/runtime/src/events.c +23 -14
- package/runtime/src/exception.c +1 -1
- package/runtime/src/fetch.c +241 -17
- package/runtime/src/function.c +31 -19
- package/runtime/src/gc.c +1716 -207
- package/runtime/src/gc_visit.h +87 -0
- package/runtime/src/generator.c +5 -3
- package/runtime/src/global.c +14 -6
- package/runtime/src/headers.c +10 -10
- package/runtime/src/inspect.c +76 -17
- package/runtime/src/internal.h +5 -2
- package/runtime/src/iterate.c +94 -2
- package/runtime/src/iterator.c +1 -1
- package/runtime/src/jobs.c +11 -5
- package/runtime/src/jsnum.c +2 -2
- package/runtime/src/json.c +1 -1
- package/runtime/src/math.c +9 -1
- package/runtime/src/module.c +3 -3
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +107 -74
- package/runtime/src/ops.c +21 -3
- package/runtime/src/os.c +192 -1
- package/runtime/src/os.h +33 -2
- package/runtime/src/process.c +73 -8
- package/runtime/src/promise.c +4 -4
- package/runtime/src/proxy.c +1 -1
- package/runtime/src/reflect.c +1 -1
- package/runtime/src/regexp.c +134 -2
- package/runtime/src/regexp_anchor.h +1 -1
- package/runtime/src/regexp_message.h +1 -1
- package/runtime/src/shape.c +10 -19
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +22 -8
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +64 -25
- package/runtime/src/string_builtins.c +7 -7
- package/runtime/src/symbol.c +2 -7
- package/runtime/src/test_host.c +3 -3
- package/runtime/src/tls_roots.gen.h +102 -620
- package/runtime/src/typedarray.c +8 -3
- package/runtime/src/tznames.gen.h +2 -1
- package/runtime/src/uri.c +1 -1
- package/runtime/src/url.c +42 -39
- package/runtime/src/weak.c +15 -12
- package/runtime/src/web.c +21 -3
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +7 -6
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +7 -7
- package/runtime/third_party/ada-idna/convert.mjs +89 -27
- package/runtime/third_party/ada-idna/idna.c +30 -31
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
- package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
- package/runtime/third_party/mozilla-ca/LICENSE +373 -0
- package/runtime/third_party/mozilla-ca/README.md +9 -0
- package/runtime/third_party/nodejs/LICENSE +47 -0
- package/runtime/third_party/nodejs/README.md +7 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +1 -1
- package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
- package/runtime/third_party/quickjs-regexp/README.md +2 -2
- package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
- package/runtime/third_party/unicode/LICENSE +39 -0
- package/runtime/third_party/unicode/README.md +9 -0
- package/runtime/third_party/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
- package/runtime/third_party/v8-ieee754/README.md +3 -2
- package/runtime/third_party/v8-ieee754/convert.py +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
- package/runtime/tools/regexp_compile.c +2 -2
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
// fs.ReadStream and fs.WriteStream, as Node's lib/internal/fs/streams.js: Readable and Writable
|
|
2
|
+
// over fs's callback calls (open, read, write, writev, fsync, close), or a custom `fs` option's,
|
|
3
|
+
// or a FileHandle's. Functions, as Node's are: callable without new, and graceful-fs calls them on
|
|
4
|
+
// its own instances (apply). Linked into programs that name them (implicitModules in
|
|
5
|
+
// node/index.ts), which then link node:stream: fs's wrappers (lazyConstructor) reach them.
|
|
6
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
7
|
+
import fs, { ReadStream as ReadStreamWrapper, WriteStream as WriteStreamWrapper } from "../fs.js";
|
|
8
|
+
import { Readable, Writable, finished } from "../stream.js";
|
|
9
|
+
import { features, provideClass } from "./features.js";
|
|
10
|
+
import { copyObject, getOptions, getValidatedFd, toPathIfFileURL, validatePath } from "./fs_utils.js";
|
|
11
|
+
import { errorOrDestroy } from "./streams/destroy.js";
|
|
12
|
+
import { codes } from "./streams/errors.js";
|
|
13
|
+
import { kEmptyObject, validateBoolean, validateFunction, validateInteger } from "./streams/validators.js";
|
|
14
|
+
import { codeError } from "./errors.js";
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
ERR_FEATURE_UNAVAILABLE_ON_PLATFORM, ERR_INCOMPATIBLE_OPTION_PAIR, ERR_INVALID_ARG_TYPE, ERR_INVALID_THIS, ERR_METHOD_NOT_IMPLEMENTED,
|
|
18
|
+
ERR_MISSING_OPTION, ERR_OUT_OF_RANGE, ERR_STREAM_DESTROYED,
|
|
19
|
+
} = codes;
|
|
20
|
+
|
|
21
|
+
const kIoDone = Symbol("kIoDone");
|
|
22
|
+
const kIsPerformingIO = Symbol("kIsPerformingIO");
|
|
23
|
+
const kFs = Symbol("kFs");
|
|
24
|
+
const kHandle = Symbol("kHandle");
|
|
25
|
+
|
|
26
|
+
/* Node's ERR_SYSTEM_ERROR, for a write that keeps writing nothing */
|
|
27
|
+
const systemErrorFailed = (what) => codeError(Error, "ERR_SYSTEM_ERROR", `A system error occurred: ${what}`);
|
|
28
|
+
|
|
29
|
+
function validateThisInternalField(object, fieldKey, className) {
|
|
30
|
+
if (typeof object !== "object" || object === null || !(fieldKey in object)) throw new ERR_INVALID_THIS(className);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* util.deprecate's: the warning on the first call */
|
|
34
|
+
function deprecate(fn, message, code) {
|
|
35
|
+
let warned = false;
|
|
36
|
+
return function deprecated(...args) {
|
|
37
|
+
if (!warned) {
|
|
38
|
+
warned = true;
|
|
39
|
+
process.emitWarning(message, "DeprecationWarning", code);
|
|
40
|
+
}
|
|
41
|
+
return Reflect.apply(fn, this, args);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _construct(callback) {
|
|
46
|
+
const stream = this; // eslint-disable-line @typescript-eslint/no-this-alias
|
|
47
|
+
if (typeof stream.fd === "number") {
|
|
48
|
+
callback();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (stream.open !== openWriteFs && stream.open !== openReadFs) {
|
|
53
|
+
// Backwards compat for monkey patching open().
|
|
54
|
+
const orgEmit = stream.emit;
|
|
55
|
+
stream.emit = function (...args) {
|
|
56
|
+
if (args[0] === "open") {
|
|
57
|
+
this.emit = orgEmit;
|
|
58
|
+
callback();
|
|
59
|
+
Reflect.apply(orgEmit, this, args);
|
|
60
|
+
} else if (args[0] === "error") {
|
|
61
|
+
this.emit = orgEmit;
|
|
62
|
+
callback(args[1]);
|
|
63
|
+
} else {
|
|
64
|
+
Reflect.apply(orgEmit, this, args);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
stream.open();
|
|
68
|
+
} else {
|
|
69
|
+
stream[kFs].open(stream.path, stream.flags, stream.mode, (er, fd) => {
|
|
70
|
+
if (er) {
|
|
71
|
+
callback(er);
|
|
72
|
+
} else {
|
|
73
|
+
stream.fd = fd;
|
|
74
|
+
callback();
|
|
75
|
+
stream.emit("open", stream.fd);
|
|
76
|
+
stream.emit("ready");
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// This generates an fs operations structure for a FileHandle
|
|
83
|
+
const FileHandleOperations = (handle) => {
|
|
84
|
+
return {
|
|
85
|
+
open: (_path, _flags, _mode, _cb) => {
|
|
86
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("open()");
|
|
87
|
+
},
|
|
88
|
+
close: (fd, cb) => {
|
|
89
|
+
handle.close().then(() => cb(), cb);
|
|
90
|
+
},
|
|
91
|
+
fsync: (fd, cb) => {
|
|
92
|
+
handle.sync().then(() => cb(), cb);
|
|
93
|
+
},
|
|
94
|
+
read: (fd, buf, offset, length, pos, cb) => {
|
|
95
|
+
handle.read(buf, offset, length, pos).then((r) => cb(null, r.bytesRead, r.buffer), (err) => cb(err, 0, buf));
|
|
96
|
+
},
|
|
97
|
+
write: (fd, buf, offset, length, pos, cb) => {
|
|
98
|
+
handle.write(buf, offset, length, pos).then((r) => cb(null, r.bytesWritten, r.buffer), (err) => cb(err, 0, buf));
|
|
99
|
+
},
|
|
100
|
+
writev: (fd, buffers, pos, cb) => {
|
|
101
|
+
handle.writev(buffers, pos).then((r) => cb(null, r.bytesWritten, r.buffers), (err) => cb(err, 0, buffers));
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function close(stream, err, cb) {
|
|
107
|
+
if (!stream.fd) {
|
|
108
|
+
cb(err);
|
|
109
|
+
} else if (stream.flush) {
|
|
110
|
+
stream[kFs].fsync(stream.fd, (flushErr) => {
|
|
111
|
+
_close(stream, err || flushErr, cb);
|
|
112
|
+
});
|
|
113
|
+
} else {
|
|
114
|
+
_close(stream, err, cb);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function _close(stream, err, cb) {
|
|
119
|
+
stream[kFs].close(stream.fd, (er) => {
|
|
120
|
+
cb(er || err);
|
|
121
|
+
});
|
|
122
|
+
stream.fd = null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function importFd(stream, options) {
|
|
126
|
+
if (typeof options.fd === "number") {
|
|
127
|
+
// When fd is a raw descriptor, we must keep our fingers crossed
|
|
128
|
+
// that the descriptor won't get closed, or worse, replaced with
|
|
129
|
+
// another one
|
|
130
|
+
// https://github.com/nodejs/node/issues/35862
|
|
131
|
+
stream[kFs] = options.fs || fs;
|
|
132
|
+
return options.fd;
|
|
133
|
+
} else if (typeof options.fd === "object" && features.FileHandle !== undefined && options.fd instanceof features.FileHandle) {
|
|
134
|
+
// When fd is a FileHandle we can listen for 'close' events
|
|
135
|
+
if (options.fs) {
|
|
136
|
+
// FileHandle is not supported with custom fs operations
|
|
137
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("FileHandle with fs");
|
|
138
|
+
}
|
|
139
|
+
stream[kHandle] = options.fd;
|
|
140
|
+
stream[kFs] = FileHandleOperations(stream[kHandle]);
|
|
141
|
+
options.fd.on("close", stream.close.bind(stream));
|
|
142
|
+
return options.fd.fd;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
throw new ERR_INVALID_ARG_TYPE("options.fd", ["number", "FileHandle"], options.fd);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* a Windows HANDLE as the stream's file: Windows only in Node, and not supported here */
|
|
149
|
+
function importWindowsHandle(stream, options) {
|
|
150
|
+
if (options.windowsHandle == null) throw new ERR_MISSING_OPTION("options.windowsHandle");
|
|
151
|
+
throw new ERR_FEATURE_UNAVAILABLE_ON_PLATFORM("windowsHandle");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function ReadStream(path, options) {
|
|
155
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
|
156
|
+
|
|
157
|
+
// A little bit bigger buffer and water marks by default
|
|
158
|
+
options = copyObject(getOptions(options, kEmptyObject));
|
|
159
|
+
if (options.highWaterMark === undefined) options.highWaterMark = 64 * 1024;
|
|
160
|
+
|
|
161
|
+
if (options.autoDestroy === undefined) {
|
|
162
|
+
options.autoDestroy = false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (options.fd != null && options.windowsHandle != null) {
|
|
166
|
+
throw new ERR_INCOMPATIBLE_OPTION_PAIR("windowsHandle", "fd");
|
|
167
|
+
} else if (options.windowsHandle != null) {
|
|
168
|
+
this.fd = getValidatedFd(importWindowsHandle(this, options));
|
|
169
|
+
} else if (options.fd == null) {
|
|
170
|
+
this.fd = null;
|
|
171
|
+
this[kFs] = options.fs || fs;
|
|
172
|
+
validateFunction(this[kFs].open, "options.fs.open");
|
|
173
|
+
|
|
174
|
+
// Path will be ignored when fd is specified, so it can be falsy
|
|
175
|
+
this.path = toPathIfFileURL(path);
|
|
176
|
+
this.flags = options.flags === undefined ? "r" : options.flags;
|
|
177
|
+
this.mode = options.mode === undefined ? 0o666 : options.mode;
|
|
178
|
+
|
|
179
|
+
validatePath(this.path);
|
|
180
|
+
} else {
|
|
181
|
+
this.fd = getValidatedFd(importFd(this, options));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
options.autoDestroy = options.autoClose === undefined ? true : options.autoClose;
|
|
185
|
+
|
|
186
|
+
validateFunction(this[kFs].read, "options.fs.read");
|
|
187
|
+
|
|
188
|
+
if (options.autoDestroy) {
|
|
189
|
+
validateFunction(this[kFs].close, "options.fs.close");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.start = options.start;
|
|
193
|
+
this.end = options.end;
|
|
194
|
+
this.pos = undefined;
|
|
195
|
+
this.bytesRead = 0;
|
|
196
|
+
this[kIsPerformingIO] = false;
|
|
197
|
+
|
|
198
|
+
if (this.start !== undefined) {
|
|
199
|
+
validateInteger(this.start, "start", 0);
|
|
200
|
+
|
|
201
|
+
this.pos = this.start;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (this.end === undefined) {
|
|
205
|
+
this.end = Infinity;
|
|
206
|
+
} else if (this.end !== Infinity) {
|
|
207
|
+
validateInteger(this.end, "end", 0);
|
|
208
|
+
|
|
209
|
+
if (this.start !== undefined && this.start > this.end) {
|
|
210
|
+
throw new ERR_OUT_OF_RANGE("start", `<= "end" (here: ${this.end})`, this.start);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
Readable.call(this, options);
|
|
215
|
+
}
|
|
216
|
+
Object.setPrototypeOf(ReadStream.prototype, Readable.prototype);
|
|
217
|
+
Object.setPrototypeOf(ReadStream, Readable);
|
|
218
|
+
|
|
219
|
+
Object.defineProperty(ReadStream.prototype, "autoClose", {
|
|
220
|
+
get() {
|
|
221
|
+
validateThisInternalField(this, kFs, "ReadStream");
|
|
222
|
+
return this._readableState.autoDestroy;
|
|
223
|
+
},
|
|
224
|
+
set(val) {
|
|
225
|
+
validateThisInternalField(this, kFs, "ReadStream");
|
|
226
|
+
this._readableState.autoDestroy = val;
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const openReadFs = deprecate(function () {
|
|
231
|
+
// Noop.
|
|
232
|
+
}, "ReadStream.prototype.open() is deprecated", "DEP0135");
|
|
233
|
+
ReadStream.prototype.open = openReadFs;
|
|
234
|
+
|
|
235
|
+
ReadStream.prototype._construct = _construct;
|
|
236
|
+
|
|
237
|
+
ReadStream.prototype._read = function (n) {
|
|
238
|
+
n = this.pos !== undefined ? Math.min(this.end - this.pos + 1, n) : Math.min(this.end - this.bytesRead + 1, n);
|
|
239
|
+
|
|
240
|
+
if (n <= 0) {
|
|
241
|
+
this.push(null);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const buf = Buffer.allocUnsafeSlow(n);
|
|
246
|
+
|
|
247
|
+
this[kIsPerformingIO] = true;
|
|
248
|
+
this[kFs].read(this.fd, buf, 0, n, this.pos, (er, bytesRead, buf) => {
|
|
249
|
+
this[kIsPerformingIO] = false;
|
|
250
|
+
|
|
251
|
+
// Tell ._destroy() that it's safe to close the fd now.
|
|
252
|
+
if (this.destroyed) {
|
|
253
|
+
this.emit(kIoDone, er);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (er) {
|
|
258
|
+
errorOrDestroy(this, er);
|
|
259
|
+
} else if (bytesRead > 0) {
|
|
260
|
+
if (this.pos !== undefined) {
|
|
261
|
+
this.pos += bytesRead;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
this.bytesRead += bytesRead;
|
|
265
|
+
|
|
266
|
+
if (bytesRead !== buf.length) {
|
|
267
|
+
// Slow path. Shrink to fit.
|
|
268
|
+
// Copy instead of slice so that we don't retain
|
|
269
|
+
// large backing buffer for small reads.
|
|
270
|
+
const dst = Buffer.allocUnsafeSlow(bytesRead);
|
|
271
|
+
buf.copy(dst, 0, 0, bytesRead);
|
|
272
|
+
buf = dst;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
this.push(buf);
|
|
276
|
+
} else {
|
|
277
|
+
this.push(null);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
ReadStream.prototype._destroy = function (err, cb) {
|
|
283
|
+
// Wait for any pending IO (kIsPerformingIO) to complete (kIoDone) before closing the fd.
|
|
284
|
+
if (this[kIsPerformingIO]) {
|
|
285
|
+
this.once(kIoDone, (er) => close(this, err || er, cb));
|
|
286
|
+
} else {
|
|
287
|
+
close(this, err, cb);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
ReadStream.prototype.close = function (cb) {
|
|
292
|
+
if (typeof cb === "function") finished(this, cb);
|
|
293
|
+
this.destroy();
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
Object.defineProperty(ReadStream.prototype, "pending", {
|
|
297
|
+
get() {
|
|
298
|
+
return this.fd === null;
|
|
299
|
+
},
|
|
300
|
+
configurable: true,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
export function WriteStream(path, options) {
|
|
304
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
|
305
|
+
|
|
306
|
+
options = copyObject(getOptions(options, kEmptyObject));
|
|
307
|
+
|
|
308
|
+
// Only buffers are supported.
|
|
309
|
+
options.decodeStrings = true;
|
|
310
|
+
|
|
311
|
+
if (options.fd != null && options.windowsHandle != null) {
|
|
312
|
+
throw new ERR_INCOMPATIBLE_OPTION_PAIR("windowsHandle", "fd");
|
|
313
|
+
} else if (options.windowsHandle != null) {
|
|
314
|
+
this.fd = getValidatedFd(importWindowsHandle(this, options));
|
|
315
|
+
} else if (options.fd == null) {
|
|
316
|
+
this.fd = null;
|
|
317
|
+
this[kFs] = options.fs || fs;
|
|
318
|
+
validateFunction(this[kFs].open, "options.fs.open");
|
|
319
|
+
|
|
320
|
+
// Path will be ignored when fd is specified, so it can be falsy
|
|
321
|
+
this.path = toPathIfFileURL(path);
|
|
322
|
+
this.flags = options.flags === undefined ? "w" : options.flags;
|
|
323
|
+
this.mode = options.mode === undefined ? 0o666 : options.mode;
|
|
324
|
+
|
|
325
|
+
validatePath(this.path);
|
|
326
|
+
} else {
|
|
327
|
+
this.fd = getValidatedFd(importFd(this, options));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
options.autoDestroy = options.autoClose === undefined ? true : options.autoClose;
|
|
331
|
+
|
|
332
|
+
if (!this[kFs].write && !this[kFs].writev) {
|
|
333
|
+
throw new ERR_INVALID_ARG_TYPE("options.fs.write", "function", this[kFs].write);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (this[kFs].write) {
|
|
337
|
+
validateFunction(this[kFs].write, "options.fs.write");
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (this[kFs].writev) {
|
|
341
|
+
validateFunction(this[kFs].writev, "options.fs.writev");
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (options.autoDestroy) {
|
|
345
|
+
validateFunction(this[kFs].close, "options.fs.close");
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
this.flush = options.flush;
|
|
349
|
+
if (this.flush == null) {
|
|
350
|
+
this.flush = false;
|
|
351
|
+
} else {
|
|
352
|
+
validateBoolean(this.flush, "options.flush");
|
|
353
|
+
validateFunction(this[kFs].fsync, "options.fs.fsync");
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// It's enough to override either, in which case only one will be used.
|
|
357
|
+
if (!this[kFs].write) {
|
|
358
|
+
this._write = null;
|
|
359
|
+
}
|
|
360
|
+
if (!this[kFs].writev) {
|
|
361
|
+
this._writev = null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
this.start = options.start;
|
|
365
|
+
this.pos = undefined;
|
|
366
|
+
this.bytesWritten = 0;
|
|
367
|
+
this[kIsPerformingIO] = false;
|
|
368
|
+
|
|
369
|
+
if (this.start !== undefined) {
|
|
370
|
+
validateInteger(this.start, "start", 0);
|
|
371
|
+
|
|
372
|
+
this.pos = this.start;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
Writable.call(this, options);
|
|
376
|
+
|
|
377
|
+
if (options.encoding) this.setDefaultEncoding(options.encoding);
|
|
378
|
+
}
|
|
379
|
+
Object.setPrototypeOf(WriteStream.prototype, Writable.prototype);
|
|
380
|
+
Object.setPrototypeOf(WriteStream, Writable);
|
|
381
|
+
|
|
382
|
+
Object.defineProperty(WriteStream.prototype, "autoClose", {
|
|
383
|
+
get() {
|
|
384
|
+
validateThisInternalField(this, kFs, "WriteStream");
|
|
385
|
+
return this._writableState.autoDestroy;
|
|
386
|
+
},
|
|
387
|
+
set(val) {
|
|
388
|
+
validateThisInternalField(this, kFs, "WriteStream");
|
|
389
|
+
this._writableState.autoDestroy = val;
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
const openWriteFs = deprecate(function () {
|
|
394
|
+
// Noop.
|
|
395
|
+
}, "WriteStream.prototype.open() is deprecated", "DEP0135");
|
|
396
|
+
WriteStream.prototype.open = openWriteFs;
|
|
397
|
+
|
|
398
|
+
WriteStream.prototype._construct = _construct;
|
|
399
|
+
|
|
400
|
+
function writeAll(data, size, pos, cb, retries = 0) {
|
|
401
|
+
this[kFs].write(this.fd, data, 0, size, pos, (er, bytesWritten, buffer) => {
|
|
402
|
+
// No data currently available and operation should be retried later.
|
|
403
|
+
if (er?.code === "EAGAIN") {
|
|
404
|
+
er = null;
|
|
405
|
+
bytesWritten = 0;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (this.destroyed || er) {
|
|
409
|
+
return cb(er || new ERR_STREAM_DESTROYED("write"));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
this.bytesWritten += bytesWritten;
|
|
413
|
+
|
|
414
|
+
retries = bytesWritten ? 0 : retries + 1;
|
|
415
|
+
size -= bytesWritten;
|
|
416
|
+
pos += bytesWritten;
|
|
417
|
+
|
|
418
|
+
// Try writing non-zero number of bytes up to 5 times.
|
|
419
|
+
if (retries > 5) {
|
|
420
|
+
cb(systemErrorFailed("write failed"));
|
|
421
|
+
} else if (size) {
|
|
422
|
+
writeAll.call(this, buffer.slice(bytesWritten), size, pos, cb, retries);
|
|
423
|
+
} else {
|
|
424
|
+
cb();
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function writevAll(chunks, size, pos, cb, retries = 0) {
|
|
430
|
+
this[kFs].writev(this.fd, chunks, this.pos, (er, bytesWritten, buffers) => {
|
|
431
|
+
// No data currently available and operation should be retried later.
|
|
432
|
+
if (er?.code === "EAGAIN") {
|
|
433
|
+
er = null;
|
|
434
|
+
bytesWritten = 0;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (this.destroyed || er) {
|
|
438
|
+
return cb(er || new ERR_STREAM_DESTROYED("writev"));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
this.bytesWritten += bytesWritten;
|
|
442
|
+
|
|
443
|
+
retries = bytesWritten ? 0 : retries + 1;
|
|
444
|
+
size -= bytesWritten;
|
|
445
|
+
pos += bytesWritten;
|
|
446
|
+
|
|
447
|
+
// Try writing non-zero number of bytes up to 5 times.
|
|
448
|
+
if (retries > 5) {
|
|
449
|
+
cb(systemErrorFailed("writev failed"));
|
|
450
|
+
} else if (size) {
|
|
451
|
+
writevAll.call(this, [Buffer.concat(buffers).slice(bytesWritten)], size, pos, cb, retries);
|
|
452
|
+
} else {
|
|
453
|
+
cb();
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
WriteStream.prototype._write = function (data, encoding, cb) {
|
|
459
|
+
this[kIsPerformingIO] = true;
|
|
460
|
+
writeAll.call(this, data, data.length, this.pos, (er) => {
|
|
461
|
+
this[kIsPerformingIO] = false;
|
|
462
|
+
if (this.destroyed) {
|
|
463
|
+
// Tell ._destroy() that it's safe to close the fd now.
|
|
464
|
+
cb(er);
|
|
465
|
+
return this.emit(kIoDone, er);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
cb(er);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
if (this.pos !== undefined) this.pos += data.length;
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
WriteStream.prototype._writev = function (data, cb) {
|
|
475
|
+
const len = data.length;
|
|
476
|
+
const chunks = new Array(len);
|
|
477
|
+
let size = 0;
|
|
478
|
+
|
|
479
|
+
for (let i = 0; i < len; i++) {
|
|
480
|
+
const chunk = data[i].chunk;
|
|
481
|
+
|
|
482
|
+
chunks[i] = chunk;
|
|
483
|
+
size += chunk.length;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
this[kIsPerformingIO] = true;
|
|
487
|
+
writevAll.call(this, chunks, size, this.pos, (er) => {
|
|
488
|
+
this[kIsPerformingIO] = false;
|
|
489
|
+
if (this.destroyed) {
|
|
490
|
+
// Tell ._destroy() that it's safe to close the fd now.
|
|
491
|
+
cb(er);
|
|
492
|
+
return this.emit(kIoDone, er);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
cb(er);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
if (this.pos !== undefined) this.pos += size;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
WriteStream.prototype._destroy = function (err, cb) {
|
|
502
|
+
// Wait for any pending IO (kIsPerformingIO) to complete (kIoDone) before closing the fd.
|
|
503
|
+
if (this[kIsPerformingIO]) {
|
|
504
|
+
this.once(kIoDone, (er) => close(this, err || er, cb));
|
|
505
|
+
} else {
|
|
506
|
+
close(this, err, cb);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
WriteStream.prototype.close = function (cb) {
|
|
511
|
+
if (cb) {
|
|
512
|
+
if (this.closed) {
|
|
513
|
+
process.nextTick(cb);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
this.on("close", cb);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// If we are not autoClosing, we should call
|
|
520
|
+
// destroy on 'finish'.
|
|
521
|
+
if (!this.autoClose) {
|
|
522
|
+
this.on("finish", this.destroy);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// We use end() instead of destroy() because of
|
|
526
|
+
// https://github.com/nodejs/node/issues/2006
|
|
527
|
+
this.end();
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
// There is no shutdown() for files.
|
|
531
|
+
WriteStream.prototype.destroySoon = WriteStream.prototype.end;
|
|
532
|
+
|
|
533
|
+
Object.defineProperty(WriteStream.prototype, "pending", {
|
|
534
|
+
get() {
|
|
535
|
+
return this.fd === null;
|
|
536
|
+
},
|
|
537
|
+
configurable: true,
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
provideClass(ReadStreamWrapper, ReadStream);
|
|
541
|
+
provideClass(WriteStreamWrapper, WriteStream);
|