visaljs 0.0.6 → 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 +4414 -325
- 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 -5
- 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,580 @@
|
|
|
1
|
+
// fs.watch, fs.watchFile and unwatchFile, and fs/promises' watch, as Node's
|
|
2
|
+
// lib/internal/fs/watchers.js and lib/fs.js: FSWatcher on libuv's file system events (inotify,
|
|
3
|
+
// kqueue, …), StatWatcher on its stat poller, and the `ignore` option (glob patterns, regular
|
|
4
|
+
// expressions, functions). A recursive watch on Linux is Node's lib/internal/fs/recursive_watch.js
|
|
5
|
+
// (libuv can't watch a tree there): a watcher for each file and directory. Linked into programs
|
|
6
|
+
// that name them (internal/features.js).
|
|
7
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
8
|
+
import { errnoMessage, errnoName, fsPollStart, fsWatchClose, fsWatchRef, fsWatchStart } from "visaljs:host";
|
|
9
|
+
import { EventEmitter } from "../events.js";
|
|
10
|
+
import { readdirSync, statSync } from "../fs.js";
|
|
11
|
+
import { basename, join, relative, resolve, sep } from "../path.js";
|
|
12
|
+
import { isRegExp } from "../util_types.js";
|
|
13
|
+
import { feature, features } from "./features.js";
|
|
14
|
+
import { copyObject, getOptions, getValidatedPath } from "./fs_utils.js";
|
|
15
|
+
import { statsFrom } from "./fs_stats.js";
|
|
16
|
+
import { AbortError, codes } from "./streams/errors.js";
|
|
17
|
+
import {
|
|
18
|
+
kEmptyObject, validateAbortSignal, validateBoolean, validateFunction, validateInteger, validateObject, validateOneOf, validateUint32,
|
|
19
|
+
} from "./streams/validators.js";
|
|
20
|
+
|
|
21
|
+
const { ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE } = codes;
|
|
22
|
+
const isWindows = process.platform === "win32";
|
|
23
|
+
const isMacOS = process.platform === "darwin";
|
|
24
|
+
const UV_RENAME = 1;
|
|
25
|
+
|
|
26
|
+
/* UVException's: "ENOENT: no such file or directory, watch '<path>'", with `filename` too */
|
|
27
|
+
function watchError(errno, path, message = "") {
|
|
28
|
+
const code = errnoName(errno);
|
|
29
|
+
const text = message || errnoMessage(errno);
|
|
30
|
+
const error = new Error(`${code}: ${text}, watch${path == null ? "" : ` '${path}'`}`);
|
|
31
|
+
Object.assign(error, { errno, code, syscall: "watch" });
|
|
32
|
+
if (path != null) error.path = path;
|
|
33
|
+
error.filename = path;
|
|
34
|
+
return error;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ERR_FS_WATCH_QUEUE_OVERFLOW = (max) =>
|
|
38
|
+
Object.assign(new Error(`fs.watch() queued more than ${max} events`), { code: "ERR_FS_WATCH_QUEUE_OVERFLOW" });
|
|
39
|
+
|
|
40
|
+
/* ---- the ignore option ----------------------------------------------------------------------- */
|
|
41
|
+
|
|
42
|
+
function validateIgnoreOptionElement(value, name) {
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
if (value.length === 0) throw new ERR_INVALID_ARG_VALUE(name, value, "must be a non-empty string");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (isRegExp(value)) return;
|
|
48
|
+
if (typeof value === "function") return;
|
|
49
|
+
throw new ERR_INVALID_ARG_TYPE(name, ["string", "RegExp", "Function"], value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function validateIgnoreOption(value, name) {
|
|
53
|
+
if (value == null) return;
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
for (let i = 0; i < value.length; i++) validateIgnoreOptionElement(value[i], `${name}[${i}]`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
validateIgnoreOptionElement(value, name);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* a glob pattern's matcher, as Node's minimatch options: matchBase (a pattern without a slash is
|
|
62
|
+
* matched against the basename), case-insensitive on Windows and macOS */
|
|
63
|
+
function globMatcher(pattern) {
|
|
64
|
+
const nocase = isWindows || isMacOS;
|
|
65
|
+
const p = nocase ? pattern.toLowerCase() : pattern;
|
|
66
|
+
const matchBase = !p.includes("/");
|
|
67
|
+
return (filename) => {
|
|
68
|
+
let f = nocase ? filename.toLowerCase() : filename;
|
|
69
|
+
if (matchBase) f = basename(f);
|
|
70
|
+
return feature("matchesGlob")(f, p); /* fs_glob.js, linked for a watch with ignore */
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A function telling whether a filename is ignored, or null without the option. */
|
|
75
|
+
export function createIgnoreMatcher(ignore) {
|
|
76
|
+
if (ignore == null) return null;
|
|
77
|
+
const matchers = Array.isArray(ignore) ? ignore : [ignore];
|
|
78
|
+
const compiled = [];
|
|
79
|
+
for (const matcher of matchers) {
|
|
80
|
+
if (typeof matcher === "string") compiled.push(globMatcher(matcher));
|
|
81
|
+
else if (isRegExp(matcher)) compiled.push((filename) => matcher.exec(filename) !== null);
|
|
82
|
+
else compiled.push(matcher);
|
|
83
|
+
}
|
|
84
|
+
return (filename) => {
|
|
85
|
+
for (let i = 0; i < compiled.length; i++) {
|
|
86
|
+
if (compiled[i](filename)) return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* a name from the host (UTF-8) in the watcher's encoding, as Node's binding encodes it */
|
|
93
|
+
function encodeName(name, encoding) {
|
|
94
|
+
if (name == null) return name;
|
|
95
|
+
if (encoding === "buffer") return Buffer.from(name);
|
|
96
|
+
if (!encoding || encoding === "utf8" || encoding === "utf-8") return name;
|
|
97
|
+
return Buffer.from(name).toString(encoding);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* ---- FSWatcher -------------------------------------------------------------------------------- */
|
|
101
|
+
|
|
102
|
+
const kFSWatchStart = Symbol("kFSWatchStart");
|
|
103
|
+
const kHandle = Symbol("kHandle"); /* the host's watcher id: null closed, -1 not started */
|
|
104
|
+
|
|
105
|
+
export class FSWatcher extends EventEmitter {
|
|
106
|
+
[kHandle] = -1;
|
|
107
|
+
_ignoreMatcher = null;
|
|
108
|
+
#encoding;
|
|
109
|
+
|
|
110
|
+
#onchange(status, filename) {
|
|
111
|
+
if (status < 0) {
|
|
112
|
+
if (this[kHandle] !== null) {
|
|
113
|
+
// We don't use this.close() here to avoid firing the close event.
|
|
114
|
+
if (this[kHandle] >= 0) fsWatchClose(this[kHandle]);
|
|
115
|
+
this[kHandle] = null;
|
|
116
|
+
}
|
|
117
|
+
this.emit("error", watchError(status, filename));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
filename = encodeName(filename, this.#encoding);
|
|
121
|
+
// Filter events if ignore matcher is set and filename is available
|
|
122
|
+
if (filename != null && this._ignoreMatcher?.(filename)) return;
|
|
123
|
+
this.emit("change", status & UV_RENAME ? "rename" : "change", filename);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
[kFSWatchStart](filename, persistent, recursive, encoding, ignore, throwIfNoEntry = true) {
|
|
127
|
+
if (this[kHandle] === null) return; // closed
|
|
128
|
+
if (this[kHandle] >= 0) return; // already started
|
|
129
|
+
filename = getValidatedPath(filename, "filename");
|
|
130
|
+
// Validate and create the ignore matcher
|
|
131
|
+
validateIgnoreOption(ignore, "options.ignore");
|
|
132
|
+
this._ignoreMatcher = createIgnoreMatcher(ignore);
|
|
133
|
+
this.#encoding = encoding;
|
|
134
|
+
const id = fsWatchStart(filename, recursive, (status, name) => this.#onchange(status, name));
|
|
135
|
+
if (id < 0) {
|
|
136
|
+
if (!throwIfNoEntry && errnoName(id) === "ENOENT") return;
|
|
137
|
+
throw watchError(id, filename, errnoName(id) === "ENOSPC" ? "System limit for number of file watchers reached" : "");
|
|
138
|
+
}
|
|
139
|
+
this[kHandle] = id;
|
|
140
|
+
if (!persistent) fsWatchRef(id, false);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// A no-op, as Node's (backward compatibility).
|
|
144
|
+
start() {}
|
|
145
|
+
|
|
146
|
+
close() {
|
|
147
|
+
if (this[kHandle] === null) return; // closed
|
|
148
|
+
if (this[kHandle] < 0) return; // not started
|
|
149
|
+
fsWatchClose(this[kHandle]);
|
|
150
|
+
this[kHandle] = null;
|
|
151
|
+
process.nextTick(() => this.emit("close"));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
ref() {
|
|
155
|
+
if (this[kHandle] >= 0) fsWatchRef(this[kHandle], true);
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
unref() {
|
|
160
|
+
if (this[kHandle] >= 0) fsWatchRef(this[kHandle], false);
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* ---- the recursive watcher on Linux: lib/internal/fs/recursive_watch.js ------------------------- */
|
|
166
|
+
|
|
167
|
+
class RecursiveFSWatcher extends EventEmitter {
|
|
168
|
+
#options = null;
|
|
169
|
+
#closed = false;
|
|
170
|
+
#files = new Map();
|
|
171
|
+
#watchers = new Map();
|
|
172
|
+
#symbolicFiles = new Set();
|
|
173
|
+
#rootPath = resolve();
|
|
174
|
+
#watchingFile = false;
|
|
175
|
+
#ignoreMatcher = null;
|
|
176
|
+
|
|
177
|
+
constructor(options = kEmptyObject) {
|
|
178
|
+
super();
|
|
179
|
+
const { persistent, recursive, signal, encoding, ignore } = options;
|
|
180
|
+
let { throwIfNoEntry } = options;
|
|
181
|
+
if (recursive != null) validateBoolean(recursive, "options.recursive");
|
|
182
|
+
if (persistent != null) validateBoolean(persistent, "options.persistent");
|
|
183
|
+
if (signal != null) validateAbortSignal(signal, "options.signal");
|
|
184
|
+
if (throwIfNoEntry != null) validateBoolean(throwIfNoEntry, "options.throwIfNoEntry");
|
|
185
|
+
else throwIfNoEntry = true;
|
|
186
|
+
if (encoding != null && typeof encoding !== "string") throw new ERR_INVALID_ARG_VALUE("options.encoding", encoding);
|
|
187
|
+
validateIgnoreOption(ignore, "options.ignore");
|
|
188
|
+
this.#ignoreMatcher = createIgnoreMatcher(ignore);
|
|
189
|
+
this.#options = { persistent, recursive, signal, encoding, throwIfNoEntry };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
close() {
|
|
193
|
+
if (this.#closed) return;
|
|
194
|
+
this.#closed = true;
|
|
195
|
+
for (const file of this.#files.keys()) {
|
|
196
|
+
this.#watchers.get(file)?.close();
|
|
197
|
+
this.#watchers.delete(file);
|
|
198
|
+
}
|
|
199
|
+
this.#files.clear();
|
|
200
|
+
this.#symbolicFiles.clear();
|
|
201
|
+
this.emit("close");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
#unwatchFiles(file) {
|
|
205
|
+
this.#symbolicFiles.delete(file);
|
|
206
|
+
const childPrefix = file + sep;
|
|
207
|
+
for (const filename of this.#files.keys()) {
|
|
208
|
+
if (filename === file || filename.startsWith(childPrefix)) {
|
|
209
|
+
this.#files.delete(filename);
|
|
210
|
+
this.#watchers.get(filename)?.close();
|
|
211
|
+
this.#watchers.delete(filename);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#watchFolder(folder) {
|
|
217
|
+
try {
|
|
218
|
+
const files = readdirSync(folder, { withFileTypes: true });
|
|
219
|
+
for (const file of files) {
|
|
220
|
+
if (this.#closed) break;
|
|
221
|
+
const f = join(folder, file.name);
|
|
222
|
+
const relativePath = relative(this.#rootPath, f);
|
|
223
|
+
if (this.#ignoreMatcher?.(relativePath)) continue;
|
|
224
|
+
if (!this.#files.has(f)) {
|
|
225
|
+
this.emit("change", "rename", relativePath);
|
|
226
|
+
if (file.isSymbolicLink()) this.#symbolicFiles.add(f);
|
|
227
|
+
try {
|
|
228
|
+
this.#watchFile(f);
|
|
229
|
+
if (file.isDirectory() && !file.isSymbolicLink()) this.#watchFolder(f);
|
|
230
|
+
} catch (err) {
|
|
231
|
+
if (err.code !== "ENOENT") throw err;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
} catch (error) {
|
|
236
|
+
if (error.code !== "ENOENT") this.emit("error", error);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
#watchFile(file) {
|
|
241
|
+
if (this.#closed) return;
|
|
242
|
+
if (this.#files.has(file)) return;
|
|
243
|
+
this.#files.set(file, statSync(file));
|
|
244
|
+
const watcher = watch(file, { persistent: this.#options.persistent }, () => {
|
|
245
|
+
const existingStat = this.#files.get(file);
|
|
246
|
+
let currentStats;
|
|
247
|
+
try {
|
|
248
|
+
currentStats = statSync(file);
|
|
249
|
+
this.#files.set(file, currentStats);
|
|
250
|
+
} catch {
|
|
251
|
+
// (the file is gone)
|
|
252
|
+
}
|
|
253
|
+
if (currentStats === undefined || (currentStats.birthtimeMs === 0 && existingStat.birthtimeMs !== 0)) {
|
|
254
|
+
this.#files.delete(file);
|
|
255
|
+
this.#watchers.delete(file);
|
|
256
|
+
watcher.close();
|
|
257
|
+
this.emit("change", "rename", relative(this.#rootPath, file));
|
|
258
|
+
this.#unwatchFiles(file);
|
|
259
|
+
} else if (file === this.#rootPath && this.#watchingFile) {
|
|
260
|
+
this.emit("change", "change", basename(file));
|
|
261
|
+
} else if (this.#symbolicFiles.has(file)) {
|
|
262
|
+
this.emit("change", "rename", relative(this.#rootPath, file));
|
|
263
|
+
} else if (currentStats.isDirectory()) {
|
|
264
|
+
this.#watchFolder(file);
|
|
265
|
+
} else {
|
|
266
|
+
this.emit("change", "change", relative(this.#rootPath, file));
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
this.#watchers.set(file, watcher);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
[kFSWatchStart](filename) {
|
|
273
|
+
filename = resolve(getValidatedPath(filename));
|
|
274
|
+
try {
|
|
275
|
+
const file = statSync(filename);
|
|
276
|
+
this.#rootPath = filename;
|
|
277
|
+
this.#closed = false;
|
|
278
|
+
this.#watchingFile = file.isFile();
|
|
279
|
+
this.#watchFile(filename);
|
|
280
|
+
if (file.isDirectory()) this.#watchFolder(filename);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
if (!this.#options.throwIfNoEntry && error.code === "ENOENT") {
|
|
283
|
+
error.filename = filename;
|
|
284
|
+
throw error;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/* (Node's: its files' stats, not watchers, so these change nothing) */
|
|
290
|
+
ref() {}
|
|
291
|
+
unref() {}
|
|
292
|
+
|
|
293
|
+
[Symbol.asyncIterator]() {
|
|
294
|
+
const { signal } = this.#options;
|
|
295
|
+
const promiseExecutor = signal == null ?
|
|
296
|
+
(res) => {
|
|
297
|
+
this.once("change", (eventType, filename) => res({ __proto__: null, value: { eventType, filename } }));
|
|
298
|
+
} :
|
|
299
|
+
(res, reject) => {
|
|
300
|
+
const onAbort = () => {
|
|
301
|
+
this.close();
|
|
302
|
+
reject(new AbortError(undefined, { cause: signal.reason }));
|
|
303
|
+
};
|
|
304
|
+
if (signal.aborted) return onAbort();
|
|
305
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
306
|
+
this.once("change", (eventType, filename) => {
|
|
307
|
+
signal.removeEventListener("abort", onAbort);
|
|
308
|
+
res({ __proto__: null, value: { eventType, filename } });
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
return {
|
|
312
|
+
next: () => (this.#closed ? { __proto__: null, done: true } : new Promise(promiseExecutor)),
|
|
313
|
+
return: () => {
|
|
314
|
+
this.close();
|
|
315
|
+
return { __proto__: null, done: true };
|
|
316
|
+
},
|
|
317
|
+
[Symbol.asyncIterator]() {
|
|
318
|
+
return this;
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/* ---- fs.watch ---------------------------------------------------------------------------------- */
|
|
325
|
+
|
|
326
|
+
/** watch(filename[, options][, listener]): an FSWatcher, its 'change' events (eventType, filename). */
|
|
327
|
+
function watch(filename, options, listener) {
|
|
328
|
+
if (typeof options === "function") listener = options;
|
|
329
|
+
options = getOptions(options);
|
|
330
|
+
// Don't make changes directly on options object
|
|
331
|
+
options = copyObject(options);
|
|
332
|
+
if (options.persistent === undefined) options.persistent = true;
|
|
333
|
+
if (options.recursive === undefined) options.recursive = false;
|
|
334
|
+
if (options.throwIfNoEntry === undefined) options.throwIfNoEntry = true;
|
|
335
|
+
|
|
336
|
+
let watcher;
|
|
337
|
+
const path = getValidatedPath(filename);
|
|
338
|
+
if (options.recursive && !isMacOS && !isWindows) {
|
|
339
|
+
watcher = new RecursiveFSWatcher(options);
|
|
340
|
+
watcher[kFSWatchStart](path);
|
|
341
|
+
} else {
|
|
342
|
+
watcher = new FSWatcher();
|
|
343
|
+
watcher[kFSWatchStart](path, options.persistent, options.recursive, options.encoding, options.ignore, options.throwIfNoEntry);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (listener) watcher.addListener("change", listener);
|
|
347
|
+
if (options.signal) {
|
|
348
|
+
if (options.signal.aborted) {
|
|
349
|
+
process.nextTick(() => watcher.close());
|
|
350
|
+
} else {
|
|
351
|
+
const onAbort = () => watcher.close();
|
|
352
|
+
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
353
|
+
watcher.once("close", () => options.signal.removeEventListener("abort", onAbort));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return watcher;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/* ---- fs.watchFile ------------------------------------------------------------------------------ */
|
|
360
|
+
|
|
361
|
+
const kOldStatus = Symbol("kOldStatus");
|
|
362
|
+
const kUseBigint = Symbol("kUseBigint");
|
|
363
|
+
const kFSStatWatcherStart = Symbol("kFSStatWatcherStart");
|
|
364
|
+
const KFSStatWatcherRefCount = Symbol("KFSStatWatcherRefCount");
|
|
365
|
+
const KFSStatWatcherMaxRefCount = Symbol("KFSStatWatcherMaxRefCount");
|
|
366
|
+
const kFSStatWatcherAddOrCleanRef = Symbol("kFSStatWatcherAddOrCleanRef");
|
|
367
|
+
const NLINK = 8; /* fsStat's array: nlink's index */
|
|
368
|
+
|
|
369
|
+
export function StatWatcher(bigint) {
|
|
370
|
+
EventEmitter.call(this);
|
|
371
|
+
this._handle = null;
|
|
372
|
+
this[kOldStatus] = -1;
|
|
373
|
+
this[kUseBigint] = bigint;
|
|
374
|
+
this[KFSStatWatcherRefCount] = 1;
|
|
375
|
+
this[KFSStatWatcherMaxRefCount] = 1;
|
|
376
|
+
}
|
|
377
|
+
Object.setPrototypeOf(StatWatcher.prototype, EventEmitter.prototype);
|
|
378
|
+
Object.setPrototypeOf(StatWatcher, EventEmitter);
|
|
379
|
+
|
|
380
|
+
/* the host's callback: the status (0, or -errno while the file is missing) and both stats */
|
|
381
|
+
function onchange(self, newStatus, current, previous) {
|
|
382
|
+
if (self[kOldStatus] === -1 && newStatus === -1 && current[NLINK] === previous[NLINK]) return;
|
|
383
|
+
self[kOldStatus] = newStatus;
|
|
384
|
+
self.emit("change", statsFrom(current, self[kUseBigint]), statsFrom(previous, self[kUseBigint]));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
StatWatcher.prototype[kFSStatWatcherStart] = function (filename, persistent, interval) {
|
|
388
|
+
if (this._handle !== null) return;
|
|
389
|
+
// (the poll is started below, once the arguments are checked)
|
|
390
|
+
this[kOldStatus] = -1;
|
|
391
|
+
filename = getValidatedPath(filename, "filename");
|
|
392
|
+
validateUint32(interval, "interval");
|
|
393
|
+
// Coerce -0 to +0.
|
|
394
|
+
interval += 0;
|
|
395
|
+
const id = fsPollStart(filename, interval, (status, current, previous) => onchange(this, status, current, previous));
|
|
396
|
+
if (id < 0) {
|
|
397
|
+
const error = watchError(id, filename);
|
|
398
|
+
error.filename = filename;
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
401
|
+
this._handle = id;
|
|
402
|
+
if (!persistent) this.unref();
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// A no-op, as Node's (backward compatibility).
|
|
406
|
+
StatWatcher.prototype.start = () => {};
|
|
407
|
+
|
|
408
|
+
StatWatcher.prototype.stop = function () {
|
|
409
|
+
if (this._handle === null) return;
|
|
410
|
+
process.nextTick(() => this.emit("stop"));
|
|
411
|
+
fsWatchClose(this._handle);
|
|
412
|
+
this._handle = null;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
StatWatcher.prototype[kFSStatWatcherAddOrCleanRef] = function (operate) {
|
|
416
|
+
if (operate === "add") {
|
|
417
|
+
this[KFSStatWatcherRefCount]++;
|
|
418
|
+
this[KFSStatWatcherMaxRefCount]++;
|
|
419
|
+
} else if (operate === "clean") {
|
|
420
|
+
this[KFSStatWatcherMaxRefCount]--;
|
|
421
|
+
this.unref();
|
|
422
|
+
} else if (operate === "cleanAll") {
|
|
423
|
+
this[KFSStatWatcherMaxRefCount] = 0;
|
|
424
|
+
this[KFSStatWatcherRefCount] = 0;
|
|
425
|
+
if (this._handle !== null) fsWatchRef(this._handle, false);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
StatWatcher.prototype.ref = function () {
|
|
430
|
+
// Avoid refCount calling ref multiple times causing unref to have no effect.
|
|
431
|
+
if (this[KFSStatWatcherRefCount] === this[KFSStatWatcherMaxRefCount]) return this;
|
|
432
|
+
if (this._handle !== null && this[KFSStatWatcherRefCount]++ === 0) fsWatchRef(this._handle, true);
|
|
433
|
+
return this;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
StatWatcher.prototype.unref = function () {
|
|
437
|
+
// Avoid refCount calling unref multiple times causing ref to have no effect.
|
|
438
|
+
if (this[KFSStatWatcherRefCount] === 0) return this;
|
|
439
|
+
if (this._handle !== null && --this[KFSStatWatcherRefCount] === 0) fsWatchRef(this._handle, false);
|
|
440
|
+
return this;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
/* one StatWatcher per file, as Node's: its listeners are watchFile's */
|
|
444
|
+
const statWatchers = new Map();
|
|
445
|
+
|
|
446
|
+
/** watchFile(filename[, options], listener(current, previous)): Stats polled every interval ms. */
|
|
447
|
+
function watchFile(filename, options, listener) {
|
|
448
|
+
filename = getValidatedPath(filename);
|
|
449
|
+
filename = resolve(filename);
|
|
450
|
+
if (options === null || typeof options !== "object") {
|
|
451
|
+
listener = options;
|
|
452
|
+
options = null;
|
|
453
|
+
}
|
|
454
|
+
options = {
|
|
455
|
+
// Poll interval in milliseconds. 5007 is what libev used to use.
|
|
456
|
+
interval: 5007,
|
|
457
|
+
persistent: true,
|
|
458
|
+
...options,
|
|
459
|
+
};
|
|
460
|
+
validateFunction(listener, "listener");
|
|
461
|
+
let stat = statWatchers.get(filename);
|
|
462
|
+
if (stat === undefined) {
|
|
463
|
+
stat = new StatWatcher(options.bigint);
|
|
464
|
+
stat[kFSStatWatcherStart](filename, options.persistent, options.interval);
|
|
465
|
+
statWatchers.set(filename, stat);
|
|
466
|
+
} else {
|
|
467
|
+
stat[kFSStatWatcherAddOrCleanRef]("add");
|
|
468
|
+
}
|
|
469
|
+
stat.addListener("change", listener);
|
|
470
|
+
return stat;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** unwatchFile(filename[, listener]): that listener, or all; the poller stops with the last. */
|
|
474
|
+
function unwatchFile(filename, listener) {
|
|
475
|
+
filename = getValidatedPath(filename);
|
|
476
|
+
filename = resolve(filename);
|
|
477
|
+
const stat = statWatchers.get(filename);
|
|
478
|
+
if (stat === undefined) return;
|
|
479
|
+
if (typeof listener === "function") {
|
|
480
|
+
const beforeListenerCount = stat.listenerCount("change");
|
|
481
|
+
stat.removeListener("change", listener);
|
|
482
|
+
if (stat.listenerCount("change") < beforeListenerCount) stat[kFSStatWatcherAddOrCleanRef]("clean");
|
|
483
|
+
} else {
|
|
484
|
+
stat.removeAllListeners("change");
|
|
485
|
+
stat[kFSStatWatcherAddOrCleanRef]("cleanAll");
|
|
486
|
+
}
|
|
487
|
+
if (stat.listenerCount("change") === 0) {
|
|
488
|
+
stat.stop();
|
|
489
|
+
statWatchers.delete(filename);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/* ---- fs/promises' watch -------------------------------------------------------------------- */
|
|
494
|
+
|
|
495
|
+
async function* watchNative(filename, options = kEmptyObject) {
|
|
496
|
+
const path = getValidatedPath(filename);
|
|
497
|
+
validateObject(options, "options");
|
|
498
|
+
const { persistent = true, recursive = false, encoding = "utf8", maxQueue = 2048, overflow = "ignore", signal, ignore } = options;
|
|
499
|
+
validateBoolean(persistent, "options.persistent");
|
|
500
|
+
validateBoolean(recursive, "options.recursive");
|
|
501
|
+
validateInteger(maxQueue, "options.maxQueue");
|
|
502
|
+
validateOneOf(overflow, "options.overflow", ["ignore", "error"]);
|
|
503
|
+
validateAbortSignal(signal, "options.signal");
|
|
504
|
+
validateIgnoreOption(ignore, "options.ignore");
|
|
505
|
+
if (encoding && !Buffer.isEncoding(encoding)) throw new ERR_INVALID_ARG_VALUE("encoding", encoding, "is invalid encoding");
|
|
506
|
+
if (signal?.aborted) throw new AbortError(undefined, { cause: signal.reason });
|
|
507
|
+
|
|
508
|
+
let id = -1;
|
|
509
|
+
const close = () => {
|
|
510
|
+
if (id >= 0) fsWatchClose(id);
|
|
511
|
+
id = -1;
|
|
512
|
+
};
|
|
513
|
+
const ignoreMatcher = createIgnoreMatcher(ignore);
|
|
514
|
+
let { promise, resolve: wake } = Promise.withResolvers();
|
|
515
|
+
const queue = [];
|
|
516
|
+
const oncancel = () => {
|
|
517
|
+
close();
|
|
518
|
+
wake();
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
try {
|
|
522
|
+
if (signal) signal.addEventListener("abort", oncancel, { once: true });
|
|
523
|
+
id = fsWatchStart(path, recursive, (status, name) => {
|
|
524
|
+
if (status < 0) {
|
|
525
|
+
close();
|
|
526
|
+
queue.push(watchError(status, name));
|
|
527
|
+
wake();
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const filename = encodeName(name, encoding);
|
|
531
|
+
// Filter events if ignore matcher is set and filename is available
|
|
532
|
+
if (filename != null && ignoreMatcher?.(filename)) return;
|
|
533
|
+
const eventType = status & UV_RENAME ? "rename" : "change";
|
|
534
|
+
if (queue.length < maxQueue) {
|
|
535
|
+
queue.push({ __proto__: null, eventType, filename });
|
|
536
|
+
wake();
|
|
537
|
+
} else if (overflow === "error") {
|
|
538
|
+
queue.length = 0;
|
|
539
|
+
queue.push(ERR_FS_WATCH_QUEUE_OVERFLOW(maxQueue));
|
|
540
|
+
wake();
|
|
541
|
+
} else {
|
|
542
|
+
process.emitWarning("fs.watch maxQueue exceeded");
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
if (id < 0) {
|
|
546
|
+
const error = watchError(id, filename, errnoName(id) === "ENOSPC" ? "System limit for number of file watchers reached" : "");
|
|
547
|
+
id = -1;
|
|
548
|
+
throw error;
|
|
549
|
+
}
|
|
550
|
+
if (!persistent) fsWatchRef(id, false);
|
|
551
|
+
|
|
552
|
+
while (!signal?.aborted) {
|
|
553
|
+
await promise;
|
|
554
|
+
while (queue.length) {
|
|
555
|
+
const item = queue.shift();
|
|
556
|
+
if (item instanceof Error) throw item;
|
|
557
|
+
yield item;
|
|
558
|
+
}
|
|
559
|
+
({ promise, resolve: wake } = Promise.withResolvers());
|
|
560
|
+
}
|
|
561
|
+
if (signal?.aborted) throw new AbortError(undefined, { cause: signal?.reason });
|
|
562
|
+
} finally {
|
|
563
|
+
close();
|
|
564
|
+
signal?.removeEventListener("abort", oncancel);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/* lib/internal/fs/promises.js' watch: a recursive one on Linux is the recursive watcher's */
|
|
569
|
+
async function* watchPromise(filename, options = kEmptyObject) {
|
|
570
|
+
const { recursive = false } = options;
|
|
571
|
+
if (recursive && !isMacOS && !isWindows) {
|
|
572
|
+
const watcher = new RecursiveFSWatcher(options);
|
|
573
|
+
watcher[kFSWatchStart](filename);
|
|
574
|
+
yield* watcher;
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
yield* watchNative(filename, options);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
Object.assign(features, { watch, watchFile, unwatchFile, watchPromise });
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// at most maxSockets each, the rest of the requests queued; with keepAlive, a socket whose
|
|
3
3
|
// response is done goes to freeSockets (unref'd, so it doesn't keep the program running) for
|
|
4
4
|
// the next request to the same origin, until the agent's timeout or the server's Keep-Alive hint.
|
|
5
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
5
6
|
import { EventEmitter } from "../events.js";
|
|
6
7
|
import { createConnection } from "../net.js";
|
|
7
8
|
import { invalidArgType, invalidArgValue, outOfRange } from "./errors.js";
|
|
9
|
+
import { isIP } from "./net.js";
|
|
8
10
|
|
|
9
11
|
function freeSocketErrorListener() {
|
|
10
12
|
this.destroy();
|
|
@@ -90,11 +92,34 @@ Agent.prototype.getName = function getName(options = {}) {
|
|
|
90
92
|
return name;
|
|
91
93
|
};
|
|
92
94
|
|
|
95
|
+
/* the TLS server name (SNI): the Host header's host, else the host; never an IP address. Plain
|
|
96
|
+
* HTTP ignores it; https's agent reads it, and its sessions are keyed by it (Node's) */
|
|
97
|
+
function calculateServerName(options, req) {
|
|
98
|
+
let servername = options.host;
|
|
99
|
+
const hostHeader = req.getHeader("host");
|
|
100
|
+
if (hostHeader) {
|
|
101
|
+
if (typeof hostHeader !== "string") throw invalidArgType("options.headers.host", "of type string", hostHeader);
|
|
102
|
+
if (hostHeader.startsWith("[")) {
|
|
103
|
+
const index = hostHeader.indexOf("]");
|
|
104
|
+
servername = index === -1 ? hostHeader : hostHeader.slice(1, index);
|
|
105
|
+
} else {
|
|
106
|
+
servername = hostHeader.split(":", 1)[0];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (isIP(servername)) servername = "";
|
|
110
|
+
return servername;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function normalizeServerName(options, req) {
|
|
114
|
+
if (!options.servername && options.servername !== "") options.servername = calculateServerName(options, req);
|
|
115
|
+
}
|
|
116
|
+
|
|
93
117
|
/* a request: a free socket, a new one (under maxSockets), or the queue */
|
|
94
118
|
Agent.prototype.addRequest = function addRequest(req, options, port, localAddress) {
|
|
95
119
|
if (typeof options === "string") options = { __proto__: null, host: options, port, localAddress };
|
|
96
120
|
options = { __proto__: null, ...options, ...this.options };
|
|
97
121
|
if (options.socketPath) options.path = options.socketPath;
|
|
122
|
+
normalizeServerName(options, req);
|
|
98
123
|
const name = this.getName(options);
|
|
99
124
|
this.sockets[name] ||= [];
|
|
100
125
|
const freeSockets = this.freeSockets[name];
|
|
@@ -125,6 +150,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port, localAddres
|
|
|
125
150
|
Agent.prototype.createSocket = function createSocket(req, options, cb) {
|
|
126
151
|
options = { __proto__: null, ...options, ...this.options };
|
|
127
152
|
if (options.socketPath) options.path = options.socketPath;
|
|
153
|
+
normalizeServerName(options, req);
|
|
128
154
|
const name = this.getName(options);
|
|
129
155
|
options._agentKey = name;
|
|
130
156
|
options.encoding = null;
|