visaljs 0.0.7 → 0.0.9
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 +68 -4
- package/THIRD_PARTY_LICENSES +1216 -0
- package/cli.js +4461 -321
- package/node/include/js_node.h +57 -1
- package/node/include/js_uv.h +8 -1
- package/node/prelude/_http_agent.js +5 -0
- package/node/prelude/_http_server.js +7 -0
- 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 +8 -2
- package/node/prelude/domain.js +115 -0
- package/node/prelude/events.js +148 -16
- package/node/prelude/fs.js +1138 -151
- package/node/prelude/fs_promises.js +117 -11
- package/node/prelude/http.js +784 -301
- package/node/prelude/http2.js +1 -1
- package/node/prelude/https.js +159 -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 +113 -0
- package/node/prelude/internal/events_on.js +100 -0
- package/node/prelude/internal/features.js +72 -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 +114 -2
- package/node/prelude/internal/http_symbols.js +3 -0
- package/node/prelude/internal/mime.js +249 -0
- package/node/prelude/internal/net.js +1 -0
- package/node/prelude/internal/net_bound.js +123 -0
- package/node/prelude/internal/net_onread.js +73 -0
- package/node/prelude/internal/net_tos.js +54 -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 +125 -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 +5 -16
- 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 +219 -8
- package/node/prelude/net.js +197 -49
- 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 +151 -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 +292 -39
- package/node/src/host_loop.c +25 -2
- package/node/src/host_net.c +130 -16
- 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 +5 -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 +5 -1
- package/runtime/include/jscell.h +22 -15
- package/runtime/include/jscontext.h +82 -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 +38 -4
- 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 +42 -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 +1720 -211
- 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 +9 -6
- 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 +700 -11
- package/runtime/src/regexp_anchor.h +1 -1
- package/runtime/src/regexp_message.h +1 -1
- package/runtime/src/shape.c +78 -20
- 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 +110 -36
- 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,435 @@
|
|
|
1
|
+
// perf_hooks' createHistogram and monitorEventLoopDelay: histograms as Node's, on HdrHistogram's
|
|
2
|
+
// buckets (HdrHistogram_c's arithmetic, ported): values kept to `figures` significant digits, min
|
|
3
|
+
// and max, mean and stddev from each bucket's median, percentiles as HdrHistogram's iterator gives
|
|
4
|
+
// them. Linked into programs that name them (internal/features.js).
|
|
5
|
+
// HdrHistogram_c's arithmetic is public domain (CC0), or BSD 2-clause:
|
|
6
|
+
// node/third_party/hdrhistogram/LICENSE.
|
|
7
|
+
import { codeError, invalidArgType } from "./errors.js";
|
|
8
|
+
import { features } from "./features.js";
|
|
9
|
+
|
|
10
|
+
const INT64_MAX = 2 ** 63; /* HdrHistogram's INT64_MAX, as a double (Node shows 9223372036854776000) */
|
|
11
|
+
const MAX_SAFE = Number.MAX_SAFE_INTEGER;
|
|
12
|
+
|
|
13
|
+
/* an integer's bit length, exactly (Math.log2 rounds near powers of two above 2^31) */
|
|
14
|
+
function bitLength(x) {
|
|
15
|
+
const high = Math.floor(x / 4294967296);
|
|
16
|
+
return high > 0 ? 64 - Math.clz32(high) : 32 - Math.clz32(x);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const outOfRange = (name, range, value) =>
|
|
20
|
+
codeError(RangeError, "ERR_OUT_OF_RANGE", `The value of "${name}" is out of range. It must be ${range}. Received ${value}`);
|
|
21
|
+
|
|
22
|
+
/* HdrHistogram's state: its geometry and counts */
|
|
23
|
+
class Hdr {
|
|
24
|
+
constructor(lowest, highest, figures) {
|
|
25
|
+
const largestSingleUnit = 2 * 10 ** figures;
|
|
26
|
+
const subBucketCountMagnitude = Math.ceil(Math.log2(largestSingleUnit));
|
|
27
|
+
this.subBucketHalfCountMagnitude = Math.max(subBucketCountMagnitude, 1) - 1;
|
|
28
|
+
this.unitMagnitude = Math.floor(Math.log2(lowest));
|
|
29
|
+
this.subBucketCount = 2 ** (this.subBucketHalfCountMagnitude + 1);
|
|
30
|
+
this.subBucketHalfCount = this.subBucketCount / 2;
|
|
31
|
+
this.subBucketMask = (this.subBucketCount - 1) * 2 ** this.unitMagnitude;
|
|
32
|
+
let smallestUntrackable = this.subBucketCount * 2 ** this.unitMagnitude;
|
|
33
|
+
let bucketsNeeded = 1;
|
|
34
|
+
while (smallestUntrackable <= highest) {
|
|
35
|
+
if (smallestUntrackable > MAX_SAFE / 2) {
|
|
36
|
+
bucketsNeeded++;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
smallestUntrackable *= 2;
|
|
40
|
+
bucketsNeeded++;
|
|
41
|
+
}
|
|
42
|
+
this.countsLen = (bucketsNeeded + 1) * this.subBucketHalfCount;
|
|
43
|
+
this.counts = new Float64Array(this.countsLen);
|
|
44
|
+
this.lowest = lowest;
|
|
45
|
+
this.highest = highest;
|
|
46
|
+
this.reset();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
reset() {
|
|
50
|
+
this.counts.fill(0);
|
|
51
|
+
this.totalCount = 0;
|
|
52
|
+
this.minValue = INT64_MAX;
|
|
53
|
+
this.maxValue = 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* the bucket of a value: its bit length above the sub-buckets' */
|
|
57
|
+
bucketIndex(value) {
|
|
58
|
+
const v = Math.max(value, 0) + 0;
|
|
59
|
+
const withMask = v > this.subBucketMask ? v : this.subBucketMask; /* v | mask: the mask is all ones below its top */
|
|
60
|
+
const pow2ceiling = bitLength(withMask);
|
|
61
|
+
return pow2ceiling - this.unitMagnitude - (this.subBucketHalfCountMagnitude + 1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
subBucketIndex(value, bucketIndex) {
|
|
65
|
+
return Math.floor(value / 2 ** (bucketIndex + this.unitMagnitude));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
countsIndex(bucketIndex, subBucketIndex) {
|
|
69
|
+
return (bucketIndex + 1) * 2 ** this.subBucketHalfCountMagnitude + (subBucketIndex - this.subBucketHalfCount);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
indexOf(value) {
|
|
73
|
+
const b = this.bucketIndex(value);
|
|
74
|
+
return this.countsIndex(b, this.subBucketIndex(value, b));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
valueAtIndex(index) {
|
|
78
|
+
let bucketIndex = Math.floor(index / 2 ** this.subBucketHalfCountMagnitude) - 1;
|
|
79
|
+
let subBucketIndex = (index % this.subBucketHalfCount) + this.subBucketHalfCount;
|
|
80
|
+
if (bucketIndex < 0) {
|
|
81
|
+
subBucketIndex -= this.subBucketHalfCount;
|
|
82
|
+
bucketIndex = 0;
|
|
83
|
+
}
|
|
84
|
+
return subBucketIndex * 2 ** (bucketIndex + this.unitMagnitude);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
sizeOfRange(value) {
|
|
88
|
+
const b = this.bucketIndex(value);
|
|
89
|
+
const s = this.subBucketIndex(value, b);
|
|
90
|
+
return 2 ** (this.unitMagnitude + (s >= this.subBucketCount ? b + 1 : b));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
lowestEquivalent(value) {
|
|
94
|
+
const b = this.bucketIndex(value);
|
|
95
|
+
return this.subBucketIndex(value, b) * 2 ** (b + this.unitMagnitude);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
highestEquivalent(value) {
|
|
99
|
+
return this.lowestEquivalent(value) + this.sizeOfRange(value) - 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
medianEquivalent(value) {
|
|
103
|
+
return this.lowestEquivalent(value) + Math.floor(this.sizeOfRange(value) / 2);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** false when the value is beyond the histogram's range */
|
|
107
|
+
record(value, count = 1) {
|
|
108
|
+
if (value < 0) return false;
|
|
109
|
+
const index = this.indexOf(value);
|
|
110
|
+
if (index < 0 || index >= this.countsLen) return false;
|
|
111
|
+
this.counts[index] += count;
|
|
112
|
+
this.totalCount += count;
|
|
113
|
+
if (value < this.minValue && value !== 0) this.minValue = value;
|
|
114
|
+
if (value > this.maxValue) this.maxValue = value;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
min() {
|
|
119
|
+
return this.totalCount === 0 ? INT64_MAX : this.lowestEquivalent(this.minValue);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
max() {
|
|
123
|
+
return this.maxValue === 0 ? 0 : this.highestEquivalent(this.maxValue);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* each recorded value's index and count */
|
|
127
|
+
*recorded() {
|
|
128
|
+
for (let i = 0; i < this.countsLen; i++) if (this.counts[i] !== 0) yield [this.valueAtIndex(i), this.counts[i]];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
mean() {
|
|
132
|
+
let total = 0;
|
|
133
|
+
for (const [value, count] of this.recorded()) total += count * this.medianEquivalent(value);
|
|
134
|
+
return total / this.totalCount;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
stddev() {
|
|
138
|
+
const mean = this.mean();
|
|
139
|
+
let total = 0;
|
|
140
|
+
for (const [value, count] of this.recorded()) {
|
|
141
|
+
const dev = this.medianEquivalent(value) - mean;
|
|
142
|
+
total += dev * dev * count;
|
|
143
|
+
}
|
|
144
|
+
return Math.sqrt(total / this.totalCount);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* Node 24's skewness and excess kurtosis: the standardized third and fourth moments over each
|
|
148
|
+
bucket's median, 0 below 3 (4) values or with no variance */
|
|
149
|
+
moment(order) {
|
|
150
|
+
if (this.totalCount < order) return 0;
|
|
151
|
+
const mean = this.mean();
|
|
152
|
+
let m2 = 0, mk = 0;
|
|
153
|
+
for (const [value, count] of this.recorded()) { /* Node's histogram.cc, operation for operation */
|
|
154
|
+
const dev = this.medianEquivalent(value) - mean;
|
|
155
|
+
const d2 = dev * dev;
|
|
156
|
+
m2 += count * d2;
|
|
157
|
+
mk += order === 3 ? count * d2 * dev : count * d2 * d2;
|
|
158
|
+
}
|
|
159
|
+
const n = this.totalCount;
|
|
160
|
+
const variance = m2 / n;
|
|
161
|
+
if (variance === 0) return 0;
|
|
162
|
+
return order === 3 ? (mk / n) / (variance * Math.sqrt(variance)) : (mk / n) / (variance * variance) - 3;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
valueAtPercentile(percentile) {
|
|
166
|
+
const requested = Math.min(percentile, 100);
|
|
167
|
+
let countAtPercentile = Math.trunc((requested / 100) * this.totalCount + 0.5);
|
|
168
|
+
countAtPercentile = Math.max(countAtPercentile, 1);
|
|
169
|
+
let value = 0, seen = 0;
|
|
170
|
+
for (let i = 0; i < this.countsLen; i++) {
|
|
171
|
+
seen += this.counts[i];
|
|
172
|
+
if (seen >= countAtPercentile) {
|
|
173
|
+
value = this.valueAtIndex(i);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return percentile === 0 ? this.lowestEquivalent(value) : this.highestEquivalent(value);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* HdrHistogram's percentile iterator (one tick per half distance): [percentile, value] */
|
|
181
|
+
percentiles() {
|
|
182
|
+
const out = [];
|
|
183
|
+
let countsIndex = -1, cumulative = 0, count = 0, value = 0;
|
|
184
|
+
let toIterateTo = 0, seenLast = false;
|
|
185
|
+
const hasNext = () => cumulative < this.totalCount;
|
|
186
|
+
const moveNext = () => {
|
|
187
|
+
countsIndex++;
|
|
188
|
+
if (countsIndex >= this.countsLen) return false;
|
|
189
|
+
count = this.counts[countsIndex];
|
|
190
|
+
cumulative += count;
|
|
191
|
+
value = this.valueAtIndex(countsIndex);
|
|
192
|
+
return true;
|
|
193
|
+
};
|
|
194
|
+
const basicNext = () => (hasNext() && countsIndex < this.countsLen ? moveNext() : false);
|
|
195
|
+
for (;;) {
|
|
196
|
+
if (!hasNext()) {
|
|
197
|
+
if (seenLast) break;
|
|
198
|
+
seenLast = true;
|
|
199
|
+
out.push([100, value]);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (countsIndex === -1 && !basicNext()) break;
|
|
203
|
+
let found = false;
|
|
204
|
+
do {
|
|
205
|
+
const current = (100 * cumulative) / this.totalCount;
|
|
206
|
+
if (count !== 0 && toIterateTo <= current) {
|
|
207
|
+
out.push([toIterateTo, value]);
|
|
208
|
+
const temp = Math.trunc(Math.log(100 / (100 - toIterateTo)) / Math.log(2)) + 1;
|
|
209
|
+
if (!Number.isFinite(temp)) return out;
|
|
210
|
+
toIterateTo += 100 / 2 ** temp;
|
|
211
|
+
found = true;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
} while (basicNext());
|
|
215
|
+
if (!found && !hasNext()) continue;
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const kHdr = Symbol("kHdr");
|
|
222
|
+
const kRecord = Symbol("kRecord");
|
|
223
|
+
|
|
224
|
+
/** A histogram's figures (Node's Histogram). */
|
|
225
|
+
class Histogram {
|
|
226
|
+
/* Node 24's exponentially weighted moving average of what's recorded, when a half-life is set:
|
|
227
|
+
alpha = 1 - 2^(-1/halfLife); with a threshold, the share above it too */
|
|
228
|
+
#ewma = { alpha: 0, threshold: 0, initialized: false, mean: 0, variance: 0, errorRate: 0 };
|
|
229
|
+
|
|
230
|
+
constructor(hdr, halfLife = 0, threshold = 0) {
|
|
231
|
+
this[kHdr] = hdr;
|
|
232
|
+
this.exceedsCount = 0;
|
|
233
|
+
if (halfLife > 0) this.#ewma.alpha = 1 - Math.exp(-Math.log(2) / halfLife);
|
|
234
|
+
this.#ewma.threshold = threshold;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Records a value (count times), counting it as exceeding when out of range. */
|
|
238
|
+
[kRecord](value, count = 1) {
|
|
239
|
+
if (!this[kHdr].record(value, count)) {
|
|
240
|
+
this.exceedsCount += count;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const e = this.#ewma;
|
|
244
|
+
if (e.alpha <= 0) return;
|
|
245
|
+
if (!e.initialized) {
|
|
246
|
+
e.initialized = true;
|
|
247
|
+
e.mean = value;
|
|
248
|
+
e.variance = 0;
|
|
249
|
+
if (e.threshold > 0) e.errorRate = value > e.threshold ? 1 : 0;
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const diff = value - e.mean;
|
|
253
|
+
e.mean += e.alpha * diff;
|
|
254
|
+
e.variance = (1 - e.alpha) * (e.variance + e.alpha * diff * diff);
|
|
255
|
+
if (e.threshold > 0) e.errorRate += e.alpha * ((value > e.threshold ? 1 : 0) - e.errorRate);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
get ewmaMean() {
|
|
259
|
+
return this.#ewma.initialized ? this.#ewma.mean : 0;
|
|
260
|
+
}
|
|
261
|
+
get ewmaStddev() {
|
|
262
|
+
return this.#ewma.initialized ? Math.sqrt(this.#ewma.variance) : 0;
|
|
263
|
+
}
|
|
264
|
+
get ewmaErrorRate() {
|
|
265
|
+
return this.#ewma.initialized ? this.#ewma.errorRate : 0;
|
|
266
|
+
}
|
|
267
|
+
get kurtosis() {
|
|
268
|
+
return this[kHdr].moment(4);
|
|
269
|
+
}
|
|
270
|
+
get skewness() {
|
|
271
|
+
return this[kHdr].moment(3);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
get count() {
|
|
275
|
+
return this[kHdr].totalCount;
|
|
276
|
+
}
|
|
277
|
+
get countBigInt() {
|
|
278
|
+
return BigInt(this.count);
|
|
279
|
+
}
|
|
280
|
+
get min() {
|
|
281
|
+
return this[kHdr].min();
|
|
282
|
+
}
|
|
283
|
+
get minBigInt() {
|
|
284
|
+
return this[kHdr].totalCount === 0 ? 9223372036854775807n : BigInt(this.min);
|
|
285
|
+
}
|
|
286
|
+
get max() {
|
|
287
|
+
return this[kHdr].max();
|
|
288
|
+
}
|
|
289
|
+
get maxBigInt() {
|
|
290
|
+
return BigInt(this.max);
|
|
291
|
+
}
|
|
292
|
+
get mean() {
|
|
293
|
+
return this[kHdr].mean();
|
|
294
|
+
}
|
|
295
|
+
get stddev() {
|
|
296
|
+
return this[kHdr].stddev();
|
|
297
|
+
}
|
|
298
|
+
get exceeds() {
|
|
299
|
+
return this.exceedsCount;
|
|
300
|
+
}
|
|
301
|
+
get exceedsBigInt() {
|
|
302
|
+
return BigInt(this.exceedsCount);
|
|
303
|
+
}
|
|
304
|
+
get percentiles() {
|
|
305
|
+
return new Map(this[kHdr].percentiles());
|
|
306
|
+
}
|
|
307
|
+
get percentilesBigInt() {
|
|
308
|
+
return new Map(this[kHdr].percentiles().map(([p, v]) => [p, BigInt(v)]));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
percentile(percentile) {
|
|
312
|
+
if (typeof percentile !== "number") throw invalidArgType("percentile", "of type number", percentile);
|
|
313
|
+
if (!(percentile > 0 && percentile <= 100)) throw outOfRange("percentile", "> 0 && <= 100", percentile);
|
|
314
|
+
return this[kHdr].valueAtPercentile(percentile);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
percentileBigInt(percentile) {
|
|
318
|
+
return BigInt(this.percentile(percentile));
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
reset() {
|
|
322
|
+
this[kHdr].reset();
|
|
323
|
+
this.exceedsCount = 0;
|
|
324
|
+
Object.assign(this.#ewma, { initialized: false, mean: 0, variance: 0, errorRate: 0 });
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
toJSON() {
|
|
328
|
+
return {
|
|
329
|
+
count: this.count, min: this.min, max: this.max, mean: this.mean, exceeds: this.exceeds, stddev: this.stddev,
|
|
330
|
+
skewness: this.skewness, kurtosis: this.kurtosis, ewmaMean: this.ewmaMean, ewmaStddev: this.ewmaStddev,
|
|
331
|
+
ewmaErrorRate: this.ewmaErrorRate, percentiles: Object.fromEntries(this.percentiles),
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** createHistogram's: record values, deltas, other histograms. */
|
|
337
|
+
class RecordableHistogram extends Histogram {
|
|
338
|
+
#previous = 0;
|
|
339
|
+
|
|
340
|
+
record(val) {
|
|
341
|
+
if (typeof val === "bigint") val = Number(val);
|
|
342
|
+
else if (typeof val !== "number") throw invalidArgType("val", "of type number", val);
|
|
343
|
+
if (!(val >= 1 && val <= MAX_SAFE)) throw outOfRange("val", ">= 1 && <= 9007199254740991", val);
|
|
344
|
+
this[kRecord](val);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** The time since the last call (ns): nothing on the first. */
|
|
348
|
+
recordDelta() {
|
|
349
|
+
const [s, ns] = process.hrtime();
|
|
350
|
+
const now = s * 1e9 + ns;
|
|
351
|
+
if (this.#previous !== 0) {
|
|
352
|
+
const delta = now - this.#previous;
|
|
353
|
+
if (delta >= 1) this[kRecord](delta);
|
|
354
|
+
}
|
|
355
|
+
this.#previous = now;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
add(other) {
|
|
359
|
+
if (!(other instanceof Histogram)) throw invalidArgType("other", "an instance of RecordableHistogram", other);
|
|
360
|
+
for (const [value, count] of other[kHdr].recorded()) {
|
|
361
|
+
if (!this[kHdr].record(value, count)) this.exceedsCount += count;
|
|
362
|
+
}
|
|
363
|
+
if (other[kHdr].totalCount > 0) {
|
|
364
|
+
this[kHdr].minValue = Math.min(this[kHdr].minValue, other[kHdr].minValue);
|
|
365
|
+
this[kHdr].maxValue = Math.max(this[kHdr].maxValue, other[kHdr].maxValue);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function integerOption(options, name, fallback, min) {
|
|
371
|
+
const value = options[name] ?? fallback;
|
|
372
|
+
if (typeof value !== "number" && typeof value !== "bigint") throw invalidArgType(`options.${name}`, "of type number", value);
|
|
373
|
+
const n = Number(value);
|
|
374
|
+
if (!Number.isInteger(n) || n < min || n > MAX_SAFE) throw outOfRange(`options.${name}`, `>= ${min} && <= 9007199254740991`, value);
|
|
375
|
+
return n;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** createHistogram({ lowest = 1, highest = Number.MAX_SAFE_INTEGER, figures = 3, halfLife = 0, threshold = 0 }). */
|
|
379
|
+
function createHistogram(options = {}) {
|
|
380
|
+
if (options === null || typeof options !== "object") throw invalidArgType("options", "of type object", options);
|
|
381
|
+
const lowest = integerOption(options, "lowest", 1, 1);
|
|
382
|
+
const highest = integerOption(options, "highest", MAX_SAFE, 2 * lowest);
|
|
383
|
+
const figures = options.figures ?? 3;
|
|
384
|
+
if (typeof figures !== "number") throw invalidArgType("options.figures", "of type number", figures);
|
|
385
|
+
if (!Number.isInteger(figures) || figures < 1 || figures > 5) throw outOfRange("options.figures", ">= 1 && <= 5", figures);
|
|
386
|
+
/* Node 24: the moving average's half-life (in values) and threshold */
|
|
387
|
+
const { halfLife = 0, threshold = 0 } = options;
|
|
388
|
+
if (typeof halfLife !== "number") throw invalidArgType("options.halfLife", "of type number", halfLife);
|
|
389
|
+
if (halfLife < 0) throw outOfRange("options.halfLife", ">= 0", halfLife);
|
|
390
|
+
if (typeof threshold !== "number") throw invalidArgType("options.threshold", "of type number", threshold);
|
|
391
|
+
if (threshold < 0) throw outOfRange("options.threshold", ">= 0", threshold);
|
|
392
|
+
return new RecordableHistogram(new Hdr(lowest, highest, figures), halfLife, threshold);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** monitorEventLoopDelay's: the event loop's delay sampled every resolution ms, in ns. */
|
|
396
|
+
class IntervalHistogram extends Histogram {
|
|
397
|
+
#timer = null;
|
|
398
|
+
#resolution;
|
|
399
|
+
#previous = 0;
|
|
400
|
+
|
|
401
|
+
constructor(hdr, resolution) {
|
|
402
|
+
super(hdr);
|
|
403
|
+
this.#resolution = resolution;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
enable() {
|
|
407
|
+
if (this.#timer !== null) return false;
|
|
408
|
+
this.#previous = 0;
|
|
409
|
+
this.#timer = globalThis.setInterval(() => {
|
|
410
|
+
const [s, ns] = process.hrtime();
|
|
411
|
+
const now = s * 1e9 + ns;
|
|
412
|
+
if (this.#previous !== 0) this[kRecord](now - this.#previous);
|
|
413
|
+
this.#previous = now;
|
|
414
|
+
}, this.#resolution);
|
|
415
|
+
this.#timer.unref?.();
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
disable() {
|
|
420
|
+
if (this.#timer === null) return false;
|
|
421
|
+
globalThis.clearInterval(this.#timer);
|
|
422
|
+
this.#timer = null;
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
class ELDHistogram extends IntervalHistogram {}
|
|
428
|
+
|
|
429
|
+
function monitorEventLoopDelay(options = {}) {
|
|
430
|
+
if (options === null || typeof options !== "object") throw invalidArgType("options", "of type object", options);
|
|
431
|
+
const resolution = integerOption(options, "resolution", 10, 1);
|
|
432
|
+
return new ELDHistogram(new Hdr(1, MAX_SAFE, 3), resolution);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
Object.assign(features, { createHistogram, monitorEventLoopDelay });
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// perf_hooks' PerformanceObserver, PerformanceObserverEntryList and PerformanceResourceTiming, as
|
|
2
|
+
// Node's: marks and measures go to the observers of their type, delivered together in a later
|
|
3
|
+
// setImmediate, sorted by start time; buffered gives an observer the entries made before it.
|
|
4
|
+
// Linked into programs that name them (internal/features.js).
|
|
5
|
+
import {
|
|
6
|
+
PerformanceObserver as ObserverWrapper, PerformanceObserverEntryList as ListWrapper, PerformanceResourceTiming as ResourceWrapper,
|
|
7
|
+
PerformanceEntry, performance,
|
|
8
|
+
} from "../perf_hooks.js";
|
|
9
|
+
import { codeError, invalidArgType } from "./errors.js";
|
|
10
|
+
import { features, provideClass } from "./features.js";
|
|
11
|
+
|
|
12
|
+
const kConstruct = Symbol("construct");
|
|
13
|
+
const supportedEntryTypes = Object.freeze(["dns", "function", "gc", "http", "http2", "mark", "measure", "net", "quic", "resource"]); /* Node 24's */
|
|
14
|
+
const observers = new Set();
|
|
15
|
+
|
|
16
|
+
const byStartTime = (entries) => entries.slice().sort((a, b) => a.startTime - b.startTime);
|
|
17
|
+
|
|
18
|
+
class PerformanceObserverEntryList {
|
|
19
|
+
#entries;
|
|
20
|
+
|
|
21
|
+
constructor(key, entries) {
|
|
22
|
+
if (key !== kConstruct) throw codeError(TypeError, "ERR_ILLEGAL_CONSTRUCTOR", "Illegal constructor");
|
|
23
|
+
this.#entries = byStartTime(entries);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getEntries() {
|
|
27
|
+
return this.#entries.slice();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getEntriesByType(type) {
|
|
31
|
+
return this.#entries.filter((e) => e.entryType === `${type}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getEntriesByName(name, type) {
|
|
35
|
+
return this.#entries.filter((e) => e.name === `${name}` && (type === undefined || e.entryType === `${type}`));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class PerformanceObserver {
|
|
40
|
+
#callback;
|
|
41
|
+
#types = new Set();
|
|
42
|
+
#pending = [];
|
|
43
|
+
#scheduled = false;
|
|
44
|
+
|
|
45
|
+
constructor(callback) {
|
|
46
|
+
if (typeof callback !== "function") throw invalidArgType("callback", "of type function", callback);
|
|
47
|
+
this.#callback = callback;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static get supportedEntryTypes() {
|
|
51
|
+
return supportedEntryTypes;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** observe({ entryTypes }) or observe({ type, buffered }). */
|
|
55
|
+
observe(options = {}) {
|
|
56
|
+
if (options === null || typeof options !== "object") throw invalidArgType("options", "of type object", options);
|
|
57
|
+
const { entryTypes, type, buffered } = options;
|
|
58
|
+
if (entryTypes === undefined && type === undefined) {
|
|
59
|
+
throw codeError(TypeError, "ERR_MISSING_ARGS", 'The "options.entryTypes" and "options.type" arguments must be specified');
|
|
60
|
+
}
|
|
61
|
+
if (entryTypes !== undefined && type !== undefined) {
|
|
62
|
+
throw codeError(TypeError, "ERR_INVALID_ARG_VALUE", "The argument 'options.entryTypes' can not be used with 'options.type'");
|
|
63
|
+
}
|
|
64
|
+
if (entryTypes !== undefined) {
|
|
65
|
+
if (!Array.isArray(entryTypes)) throw invalidArgType("options.entryTypes", "an instance of Array", entryTypes);
|
|
66
|
+
this.#types = new Set(entryTypes.filter((t) => supportedEntryTypes.includes(t)));
|
|
67
|
+
} else {
|
|
68
|
+
if (!supportedEntryTypes.includes(type)) return;
|
|
69
|
+
this.#types.add(type);
|
|
70
|
+
if (buffered) for (const entry of performance.getEntriesByType(type)) this._enqueue(entry);
|
|
71
|
+
}
|
|
72
|
+
if (this.#types.size > 0) observers.add(this);
|
|
73
|
+
else this.disconnect();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
disconnect() {
|
|
77
|
+
observers.delete(this);
|
|
78
|
+
this.#types.clear();
|
|
79
|
+
this.#pending = [];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
takeRecords() {
|
|
83
|
+
const records = this.#pending;
|
|
84
|
+
this.#pending = [];
|
|
85
|
+
return records;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_observes(type) {
|
|
89
|
+
return this.#types.has(type);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* an entry for the callback, which runs once in a later setImmediate with all of them */
|
|
93
|
+
_enqueue(entry) {
|
|
94
|
+
this.#pending.push(entry);
|
|
95
|
+
if (this.#scheduled) return;
|
|
96
|
+
this.#scheduled = true;
|
|
97
|
+
setImmediate(() => {
|
|
98
|
+
this.#scheduled = false;
|
|
99
|
+
const entries = this.takeRecords();
|
|
100
|
+
if (entries.length) this.#callback(new PerformanceObserverEntryList(kConstruct, entries), this);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** A fetch's timing: made by Node's fetch, which a compiled program's fetch doesn't record. */
|
|
106
|
+
class PerformanceResourceTiming extends PerformanceEntry {
|
|
107
|
+
constructor() {
|
|
108
|
+
throw codeError(TypeError, "ERR_ILLEGAL_CONSTRUCTOR", "Illegal constructor");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* whether an observer takes entries of this type: net.js times a connect only then */
|
|
113
|
+
features.perfObserving = (type) => {
|
|
114
|
+
for (const observer of observers) if (observer._observes(type)) return true;
|
|
115
|
+
return false;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/* perf_hooks.js calls this with each mark and measure, net.js with a connect's entry */
|
|
119
|
+
features.perfObserve = (entry) => {
|
|
120
|
+
for (const observer of observers) if (observer._observes(entry.entryType)) observer._enqueue(entry);
|
|
121
|
+
};
|
|
122
|
+
provideClass(ObserverWrapper, PerformanceObserver);
|
|
123
|
+
provideClass(ListWrapper, PerformanceObserverEntryList);
|
|
124
|
+
provideClass(ResourceWrapper, PerformanceResourceTiming);
|
|
125
|
+
Object.defineProperty(ObserverWrapper, "supportedEntryTypes", { get: () => supportedEntryTypes, configurable: true });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Node's performance globals: node:perf_hooks' performance and its classes. A program that may
|
|
2
|
+
// use them gets this module first (implicitModules in node/index.ts). As in Node, `performance`
|
|
3
|
+
// is an accessor (an assignment changes what it gives), and the classes are non-enumerable.
|
|
4
|
+
import { Performance, PerformanceEntry, PerformanceMark, PerformanceMeasure, performance } from "../perf_hooks.js";
|
|
5
|
+
|
|
6
|
+
let current = performance;
|
|
7
|
+
Object.defineProperty(globalThis, "performance", {
|
|
8
|
+
get() {
|
|
9
|
+
return current;
|
|
10
|
+
},
|
|
11
|
+
set(value) {
|
|
12
|
+
current = value;
|
|
13
|
+
},
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
});
|
|
17
|
+
for (const [name, value] of Object.entries({ Performance, PerformanceEntry, PerformanceMark, PerformanceMeasure })) {
|
|
18
|
+
Object.defineProperty(globalThis, name, { value, writable: true, enumerable: false, configurable: true });
|
|
19
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// process as an EventEmitter
|
|
1
|
+
// process as an EventEmitter: the runtime's process, in every binary, is a plain
|
|
2
2
|
// object. A program that may call its emitter methods gets this module first (the driver adds it:
|
|
3
3
|
// implicitModules in node/index.ts), and the runtime emits process's events through its emit.
|
|
4
4
|
import { EventEmitter } from "../events.js";
|
|
5
|
+
import { invalidArgType, validateString } from "./errors.js";
|
|
5
6
|
|
|
6
7
|
const p = globalThis.process;
|
|
7
8
|
|
|
@@ -12,3 +13,50 @@ process.prototype = Object.create(EventEmitter.prototype, {
|
|
|
12
13
|
});
|
|
13
14
|
Object.setPrototypeOf(p, process.prototype);
|
|
14
15
|
EventEmitter.init.call(p);
|
|
16
|
+
|
|
17
|
+
/* emitWarning, as Node's (lib/internal/process/warning.js): the warning as an Error (name the
|
|
18
|
+
* type, code, detail), printed by the runtime's emitWarning (Node's own 'warning' listener), and
|
|
19
|
+
* emitted as 'warning' on the next tick */
|
|
20
|
+
const printWarning = p.emitWarning;
|
|
21
|
+
p.emitWarning = function emitWarning(warning, type, code, ctor) {
|
|
22
|
+
if (p.noDeprecation && type === "DeprecationWarning") return;
|
|
23
|
+
let detail;
|
|
24
|
+
if (type !== null && typeof type === "object" && !Array.isArray(type)) {
|
|
25
|
+
ctor = type.ctor;
|
|
26
|
+
code = type.code;
|
|
27
|
+
if (typeof type.detail === "string") detail = type.detail;
|
|
28
|
+
type = type.type || "Warning";
|
|
29
|
+
} else if (typeof type === "function") {
|
|
30
|
+
ctor = type;
|
|
31
|
+
code = undefined;
|
|
32
|
+
type = "Warning";
|
|
33
|
+
}
|
|
34
|
+
if (type !== undefined) validateString(type, "type");
|
|
35
|
+
if (typeof code === "function") {
|
|
36
|
+
ctor = code;
|
|
37
|
+
code = undefined;
|
|
38
|
+
} else if (code !== undefined) {
|
|
39
|
+
validateString(code, "code");
|
|
40
|
+
}
|
|
41
|
+
if (typeof warning === "string") {
|
|
42
|
+
warning = new Error(warning);
|
|
43
|
+
warning.name = String(type || "Warning");
|
|
44
|
+
if (code !== undefined) warning.code = code;
|
|
45
|
+
if (detail !== undefined) warning.detail = detail;
|
|
46
|
+
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(warning, ctor || p.emitWarning);
|
|
47
|
+
} else if (!(warning instanceof Error)) {
|
|
48
|
+
throw invalidArgType("warning", "of type string or an instance of Error", warning);
|
|
49
|
+
}
|
|
50
|
+
if (warning.name === "DeprecationWarning") {
|
|
51
|
+
if (p.noDeprecation) return;
|
|
52
|
+
if (p.throwDeprecation) {
|
|
53
|
+
p.nextTick(() => {
|
|
54
|
+
throw warning;
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const text = typeof warning.detail === "string" ? `${warning.message}\n${warning.detail}` : warning.message;
|
|
60
|
+
printWarning.call(p, text, String(warning.name), warning.code === undefined ? undefined : String(warning.code));
|
|
61
|
+
p.nextTick(() => p.emit("warning", warning));
|
|
62
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// process.memoryUsage(): added to the runtime's process when the program may call it
|
|
2
|
+
// (implicitModules in node/index.ts), since it links libuv. heapTotal and heapUsed are the GC
|
|
3
|
+
// heap's; a compiled program has no separate external or ArrayBuffer accounting (0).
|
|
4
|
+
import { processMemory } from "visaljs:host";
|
|
5
|
+
|
|
6
|
+
function memoryUsage() {
|
|
7
|
+
const [rss, heapTotal, heapUsed] = processMemory();
|
|
8
|
+
return { rss, heapTotal, heapUsed, external: 0, arrayBuffers: 0 };
|
|
9
|
+
}
|
|
10
|
+
memoryUsage.rss = function rss() {
|
|
11
|
+
return processMemory()[0];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Object.defineProperty(globalThis.process, "memoryUsage", { value: memoryUsage, writable: true, enumerable: true, configurable: true });
|