visaljs 0.0.5 → 0.0.6
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/cli.js +469 -53
- package/node/include/js_node.h +36 -0
- package/node/prelude/async_hooks.js +63 -8
- package/node/prelude/buffer.js +0 -0
- package/node/prelude/diagnostics_channel.js +322 -0
- package/node/prelude/dns.js +3 -2
- package/node/prelude/events.js +17 -3
- package/node/prelude/fs.js +177 -5
- package/node/prelude/fs_promises.js +24 -0
- package/node/prelude/http.js +13 -4
- package/node/prelude/http2.js +0 -0
- package/node/prelude/internal/async_context.js +27 -0
- package/node/prelude/internal/crypto/asym.js +0 -0
- package/node/prelude/internal/crypto/cipher.js +0 -0
- package/node/prelude/internal/crypto/kdf.js +0 -0
- package/node/prelude/internal/crypto/keys.js +0 -0
- package/node/prelude/internal/crypto/random.js +0 -0
- package/node/prelude/internal/crypto/util.js +0 -0
- package/node/prelude/internal/errors.js +11 -0
- package/node/prelude/internal/process_events.js +14 -0
- package/node/prelude/internal/process_signals.js +42 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/timers.js +233 -0
- package/node/prelude/internal/timers_global.js +9 -0
- package/node/prelude/internal/zlib_brotli.js +6 -0
- package/node/prelude/internal/zlib_engines.js +4 -0
- package/node/prelude/internal/zlib_zstd.js +6 -0
- package/node/prelude/module.js +22 -6
- package/node/prelude/net.js +9 -8
- package/node/prelude/os.js +0 -0
- package/node/prelude/path.js +1599 -186
- package/node/prelude/path_posix.js +9 -0
- package/node/prelude/path_win32.js +9 -0
- package/node/prelude/process.js +3 -0
- package/node/prelude/querystring.js +0 -0
- package/node/prelude/stream.js +18 -6
- package/node/prelude/stream_promises.js +0 -0
- package/node/prelude/stream_web.js +0 -0
- package/node/prelude/string_decoder.js +0 -0
- package/node/prelude/timers.js +92 -0
- package/node/prelude/timers_promises.js +133 -0
- package/node/prelude/tty.js +0 -0
- package/node/prelude/url.js +0 -0
- package/node/prelude/util.js +0 -0
- package/node/prelude/zlib.js +912 -72
- package/node/src/host_brotli.c +157 -0
- package/node/src/host_fs.c +95 -1
- package/node/src/host_loop.c +10 -4
- package/node/src/host_os.c +0 -0
- package/node/src/host_signal.c +70 -0
- package/node/src/host_sys.c +50 -0
- package/node/src/host_zlib.c +314 -0
- package/node/src/host_zstd.c +179 -0
- package/node/third_party/brotli/LICENSE +19 -0
- package/node/third_party/brotli/common/constants.c +15 -0
- package/node/third_party/brotli/common/constants.h +201 -0
- package/node/third_party/brotli/common/context.c +156 -0
- package/node/third_party/brotli/common/context.h +113 -0
- package/node/third_party/brotli/common/dictionary.c +5916 -0
- package/node/third_party/brotli/common/dictionary.h +64 -0
- package/node/third_party/brotli/common/platform.c +23 -0
- package/node/third_party/brotli/common/platform.h +541 -0
- package/node/third_party/brotli/common/shared_dictionary.c +521 -0
- package/node/third_party/brotli/common/shared_dictionary_internal.h +75 -0
- package/node/third_party/brotli/common/transform.c +291 -0
- package/node/third_party/brotli/common/transform.h +85 -0
- package/node/third_party/brotli/common/version.h +51 -0
- package/node/third_party/brotli/dec/bit_reader.c +78 -0
- package/node/third_party/brotli/dec/bit_reader.h +423 -0
- package/node/third_party/brotli/dec/decode.c +2875 -0
- package/node/third_party/brotli/dec/huffman.c +342 -0
- package/node/third_party/brotli/dec/huffman.h +122 -0
- package/node/third_party/brotli/dec/prefix.h +733 -0
- package/node/third_party/brotli/dec/state.c +183 -0
- package/node/third_party/brotli/dec/state.h +400 -0
- package/node/third_party/brotli/enc/backward_references.c +207 -0
- package/node/third_party/brotli/enc/backward_references.h +40 -0
- package/node/third_party/brotli/enc/backward_references_hq.c +939 -0
- package/node/third_party/brotli/enc/backward_references_hq.h +96 -0
- package/node/third_party/brotli/enc/backward_references_inc.h +189 -0
- package/node/third_party/brotli/enc/bit_cost.c +36 -0
- package/node/third_party/brotli/enc/bit_cost.h +64 -0
- package/node/third_party/brotli/enc/bit_cost_inc.h +127 -0
- package/node/third_party/brotli/enc/block_encoder_inc.h +34 -0
- package/node/third_party/brotli/enc/block_splitter.c +217 -0
- package/node/third_party/brotli/enc/block_splitter.h +52 -0
- package/node/third_party/brotli/enc/block_splitter_inc.h +481 -0
- package/node/third_party/brotli/enc/brotli_bit_stream.c +1336 -0
- package/node/third_party/brotli/enc/brotli_bit_stream.h +89 -0
- package/node/third_party/brotli/enc/cluster.c +57 -0
- package/node/third_party/brotli/enc/cluster.h +49 -0
- package/node/third_party/brotli/enc/cluster_inc.h +325 -0
- package/node/third_party/brotli/enc/command.c +28 -0
- package/node/third_party/brotli/enc/command.h +191 -0
- package/node/third_party/brotli/enc/compound_dictionary.c +207 -0
- package/node/third_party/brotli/enc/compound_dictionary.h +74 -0
- package/node/third_party/brotli/enc/compress_fragment.c +800 -0
- package/node/third_party/brotli/enc/compress_fragment.h +86 -0
- package/node/third_party/brotli/enc/compress_fragment_two_pass.c +657 -0
- package/node/third_party/brotli/enc/compress_fragment_two_pass.h +72 -0
- package/node/third_party/brotli/enc/dictionary_hash.c +1848 -0
- package/node/third_party/brotli/enc/dictionary_hash.h +25 -0
- package/node/third_party/brotli/enc/encode.c +1996 -0
- package/node/third_party/brotli/enc/encoder_dict.c +640 -0
- package/node/third_party/brotli/enc/encoder_dict.h +157 -0
- package/node/third_party/brotli/enc/entropy_encode.c +504 -0
- package/node/third_party/brotli/enc/entropy_encode.h +123 -0
- package/node/third_party/brotli/enc/entropy_encode_static.h +542 -0
- package/node/third_party/brotli/enc/fast_log.c +105 -0
- package/node/third_party/brotli/enc/fast_log.h +67 -0
- package/node/third_party/brotli/enc/find_match_length.h +72 -0
- package/node/third_party/brotli/enc/hash.h +728 -0
- package/node/third_party/brotli/enc/hash_composite_inc.h +140 -0
- package/node/third_party/brotli/enc/hash_forgetful_chain_inc.h +295 -0
- package/node/third_party/brotli/enc/hash_longest_match64_inc.h +262 -0
- package/node/third_party/brotli/enc/hash_longest_match_inc.h +258 -0
- package/node/third_party/brotli/enc/hash_longest_match_quickly_inc.h +266 -0
- package/node/third_party/brotli/enc/hash_rolling_inc.h +212 -0
- package/node/third_party/brotli/enc/hash_to_binary_tree_inc.h +330 -0
- package/node/third_party/brotli/enc/histogram.c +100 -0
- package/node/third_party/brotli/enc/histogram.h +64 -0
- package/node/third_party/brotli/enc/histogram_inc.h +51 -0
- package/node/third_party/brotli/enc/literal_cost.c +180 -0
- package/node/third_party/brotli/enc/literal_cost.h +32 -0
- package/node/third_party/brotli/enc/memory.c +194 -0
- package/node/third_party/brotli/enc/memory.h +131 -0
- package/node/third_party/brotli/enc/metablock.c +677 -0
- package/node/third_party/brotli/enc/metablock.h +106 -0
- package/node/third_party/brotli/enc/metablock_inc.h +185 -0
- package/node/third_party/brotli/enc/params.h +47 -0
- package/node/third_party/brotli/enc/prefix.h +54 -0
- package/node/third_party/brotli/enc/quality.h +202 -0
- package/node/third_party/brotli/enc/ringbuffer.h +168 -0
- package/node/third_party/brotli/enc/state.h +104 -0
- package/node/third_party/brotli/enc/static_dict.c +542 -0
- package/node/third_party/brotli/enc/static_dict.h +41 -0
- package/node/third_party/brotli/enc/static_dict_lut.h +5866 -0
- package/node/third_party/brotli/enc/utf8_util.c +85 -0
- package/node/third_party/brotli/enc/utf8_util.h +33 -0
- package/node/third_party/brotli/enc/write_bits.h +88 -0
- package/node/third_party/brotli/include/brotli/decode.h +409 -0
- package/node/third_party/brotli/include/brotli/encode.h +501 -0
- package/node/third_party/brotli/include/brotli/port.h +305 -0
- package/node/third_party/brotli/include/brotli/shared_dictionary.h +100 -0
- package/node/third_party/brotli/include/brotli/types.h +83 -0
- package/node/third_party/libuv/LICENSE +0 -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/zlib/LICENSE +19 -0
- package/node/third_party/zlib/README.chromium +38 -0
- package/node/third_party/zlib/adler32.c +197 -0
- package/node/third_party/zlib/chromeconf.h +203 -0
- package/node/third_party/zlib/contrib/optimizations/insert_string.h +80 -0
- package/node/third_party/zlib/cpu_features.c +213 -0
- package/node/third_party/zlib/cpu_features.h +22 -0
- package/node/third_party/zlib/crc32.c +1192 -0
- package/node/third_party/zlib/crc32.h +9446 -0
- package/node/third_party/zlib/deflate.c +2289 -0
- package/node/third_party/zlib/deflate.h +407 -0
- package/node/third_party/zlib/gzguts.h +214 -0
- package/node/third_party/zlib/inffast.c +327 -0
- package/node/third_party/zlib/inffast.h +26 -0
- package/node/third_party/zlib/inffixed.h +94 -0
- package/node/third_party/zlib/inflate.c +1528 -0
- package/node/third_party/zlib/inflate.h +126 -0
- package/node/third_party/zlib/inftrees.c +299 -0
- package/node/third_party/zlib/inftrees.h +62 -0
- package/node/third_party/zlib/trees.c +1161 -0
- package/node/third_party/zlib/trees.h +128 -0
- package/node/third_party/zlib/zconf.h +558 -0
- package/node/third_party/zlib/zlib.h +1967 -0
- package/node/third_party/zlib/zutil.c +299 -0
- package/node/third_party/zlib/zutil.h +275 -0
- package/node/third_party/zstd/LICENSE +30 -0
- package/node/third_party/zstd/common/allocations.h +55 -0
- package/node/third_party/zstd/common/bits.h +205 -0
- package/node/third_party/zstd/common/bitstream.h +454 -0
- package/node/third_party/zstd/common/compiler.h +464 -0
- package/node/third_party/zstd/common/cpu.h +249 -0
- package/node/third_party/zstd/common/debug.c +30 -0
- package/node/third_party/zstd/common/debug.h +107 -0
- package/node/third_party/zstd/common/entropy_common.c +340 -0
- package/node/third_party/zstd/common/error_private.c +64 -0
- package/node/third_party/zstd/common/error_private.h +158 -0
- package/node/third_party/zstd/common/fse.h +625 -0
- package/node/third_party/zstd/common/fse_decompress.c +315 -0
- package/node/third_party/zstd/common/huf.h +277 -0
- package/node/third_party/zstd/common/mem.h +422 -0
- package/node/third_party/zstd/common/pool.c +371 -0
- package/node/third_party/zstd/common/pool.h +81 -0
- package/node/third_party/zstd/common/portability_macros.h +171 -0
- package/node/third_party/zstd/common/threading.c +182 -0
- package/node/third_party/zstd/common/threading.h +142 -0
- package/node/third_party/zstd/common/xxhash.c +18 -0
- package/node/third_party/zstd/common/xxhash.h +7094 -0
- package/node/third_party/zstd/common/zstd_common.c +48 -0
- package/node/third_party/zstd/common/zstd_deps.h +123 -0
- package/node/third_party/zstd/common/zstd_internal.h +324 -0
- package/node/third_party/zstd/common/zstd_trace.h +156 -0
- package/node/third_party/zstd/compress/clevels.h +134 -0
- package/node/third_party/zstd/compress/fse_compress.c +625 -0
- package/node/third_party/zstd/compress/hist.c +191 -0
- package/node/third_party/zstd/compress/hist.h +82 -0
- package/node/third_party/zstd/compress/huf_compress.c +1464 -0
- package/node/third_party/zstd/compress/zstd_compress.c +7843 -0
- package/node/third_party/zstd/compress/zstd_compress_internal.h +1636 -0
- package/node/third_party/zstd/compress/zstd_compress_literals.c +235 -0
- package/node/third_party/zstd/compress/zstd_compress_literals.h +39 -0
- package/node/third_party/zstd/compress/zstd_compress_sequences.c +442 -0
- package/node/third_party/zstd/compress/zstd_compress_sequences.h +55 -0
- package/node/third_party/zstd/compress/zstd_compress_superblock.c +688 -0
- package/node/third_party/zstd/compress/zstd_compress_superblock.h +32 -0
- package/node/third_party/zstd/compress/zstd_cwksp.h +765 -0
- package/node/third_party/zstd/compress/zstd_double_fast.c +778 -0
- package/node/third_party/zstd/compress/zstd_double_fast.h +42 -0
- package/node/third_party/zstd/compress/zstd_fast.c +985 -0
- package/node/third_party/zstd/compress/zstd_fast.h +30 -0
- package/node/third_party/zstd/compress/zstd_lazy.c +2199 -0
- package/node/third_party/zstd/compress/zstd_lazy.h +193 -0
- package/node/third_party/zstd/compress/zstd_ldm.c +745 -0
- package/node/third_party/zstd/compress/zstd_ldm.h +109 -0
- package/node/third_party/zstd/compress/zstd_ldm_geartab.h +106 -0
- package/node/third_party/zstd/compress/zstd_opt.c +1580 -0
- package/node/third_party/zstd/compress/zstd_opt.h +72 -0
- package/node/third_party/zstd/compress/zstd_preSplit.c +238 -0
- package/node/third_party/zstd/compress/zstd_preSplit.h +33 -0
- package/node/third_party/zstd/compress/zstdmt_compress.c +1923 -0
- package/node/third_party/zstd/compress/zstdmt_compress.h +102 -0
- package/node/third_party/zstd/decompress/huf_decompress.c +1944 -0
- package/node/third_party/zstd/decompress/zstd_ddict.c +244 -0
- package/node/third_party/zstd/decompress/zstd_ddict.h +44 -0
- package/node/third_party/zstd/decompress/zstd_decompress.c +2410 -0
- package/node/third_party/zstd/decompress/zstd_decompress_block.c +2209 -0
- package/node/third_party/zstd/decompress/zstd_decompress_block.h +73 -0
- package/node/third_party/zstd/decompress/zstd_decompress_internal.h +240 -0
- package/node/third_party/zstd/zdict.h +481 -0
- package/node/third_party/zstd/zstd.h +3198 -0
- package/node/third_party/zstd/zstd_errors.h +107 -0
- package/package.json +2 -3
- package/runtime/include/js_atoms.gen.h +0 -0
- package/runtime/include/js_atoms.h +0 -0
- package/runtime/include/js_bigint.h +0 -0
- package/runtime/include/js_buffer.h +0 -0
- package/runtime/include/js_builtins.h +0 -0
- package/runtime/include/js_console.h +5 -2
- package/runtime/include/js_convert.h +0 -0
- package/runtime/include/js_core.def +0 -0
- package/runtime/include/js_error.h +0 -0
- package/runtime/include/js_exception.h +0 -0
- package/runtime/include/js_function.h +0 -0
- package/runtime/include/js_gc.h +0 -0
- package/runtime/include/js_generator.h +0 -0
- package/runtime/include/js_host.h +5 -3
- package/runtime/include/js_jobs.h +18 -1
- package/runtime/include/js_module.h +0 -0
- package/runtime/include/js_object.h +0 -0
- package/runtime/include/js_ops.h +0 -0
- package/runtime/include/js_promise.h +1 -0
- package/runtime/include/js_regexp.h +0 -0
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +0 -0
- package/runtime/include/js_web.h +0 -0
- package/runtime/include/jscell.h +0 -0
- package/runtime/include/jscontext.h +14 -0
- package/runtime/include/jsnum.h +0 -0
- package/runtime/include/jsstring.h +0 -0
- package/runtime/include/jsvalue.h +0 -0
- package/runtime/src/arguments.c +0 -0
- package/runtime/src/array.c +0 -0
- package/runtime/src/arraybuffer.c +0 -0
- package/runtime/src/async_iter.c +0 -0
- package/runtime/src/atoms.c +0 -0
- package/runtime/src/base64.c +0 -0
- package/runtime/src/bigint.c +0 -0
- package/runtime/src/blob.c +0 -0
- package/runtime/src/buffer.c +20 -16
- package/runtime/src/builtin_table.c +0 -0
- package/runtime/src/builtins.c +0 -0
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +0 -0
- package/runtime/src/components.c +0 -0
- package/runtime/src/console.c +15 -2
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +0 -0
- package/runtime/src/crypto.c +0 -0
- package/runtime/src/crypto_host.c +0 -0
- package/runtime/src/crypto_kdf.c +0 -0
- package/runtime/src/crypto_key.c +0 -0
- package/runtime/src/date.c +0 -0
- package/runtime/src/domexception.c +0 -0
- package/runtime/src/elements.c +0 -0
- package/runtime/src/elements.h +0 -0
- package/runtime/src/encoding.c +0 -0
- package/runtime/src/error.c +0 -0
- package/runtime/src/events.c +1 -1
- package/runtime/src/exception.c +0 -0
- package/runtime/src/fetch.c +0 -0
- package/runtime/src/function.c +0 -0
- package/runtime/src/gc.c +2 -0
- package/runtime/src/generator.c +0 -0
- package/runtime/src/global.c +0 -0
- package/runtime/src/headers.c +0 -0
- package/runtime/src/inspect.c +0 -0
- package/runtime/src/internal.h +0 -0
- package/runtime/src/iterate.c +0 -0
- package/runtime/src/iterator.c +0 -0
- package/runtime/src/jobs.c +123 -44
- package/runtime/src/jsnum.c +0 -0
- package/runtime/src/json.c +0 -0
- package/runtime/src/math.c +0 -0
- package/runtime/src/module.c +0 -0
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +0 -0
- package/runtime/src/ops.c +0 -0
- package/runtime/src/os.c +0 -0
- package/runtime/src/os.h +0 -0
- package/runtime/src/process.c +92 -8
- package/runtime/src/promise.c +7 -2
- package/runtime/src/proxy.c +0 -0
- package/runtime/src/reflect.c +0 -0
- package/runtime/src/regexp.c +0 -0
- package/runtime/src/regexp_anchor.h +0 -0
- package/runtime/src/regexp_message.h +0 -0
- package/runtime/src/shape.c +0 -0
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +0 -0
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +0 -0
- package/runtime/src/string_builtins.c +0 -0
- package/runtime/src/symbol.c +0 -0
- package/runtime/src/test_host.c +0 -0
- package/runtime/src/typedarray.c +0 -0
- package/runtime/src/tznames.gen.h +0 -0
- package/runtime/src/uri.c +0 -0
- package/runtime/src/url.c +0 -0
- package/runtime/src/weak.c +1 -4
- package/runtime/src/web.c +0 -0
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +0 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +0 -0
- package/runtime/third_party/ada-idna/convert.mjs +0 -0
- package/runtime/third_party/ada-idna/idna.c +0 -0
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +0 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +0 -0
- 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 +0 -0
- 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/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/README.md +0 -0
- 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 +0 -0
package/node/include/js_node.h
CHANGED
|
@@ -12,15 +12,28 @@ JSValue js_host_fs_read_file(JSContext *ctx, JSValue callee, JSValue this_val, u
|
|
|
12
12
|
JSValue js_host_fs_write_file(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
13
13
|
JSValue js_host_fs_exists(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
14
14
|
JSValue js_host_fs_unlink(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
15
|
+
JSValue js_host_fs_stat(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
16
|
+
JSValue js_host_fs_readdir(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
17
|
+
JSValue js_host_fs_read_at(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
15
18
|
|
|
16
19
|
/* host_sys.c */
|
|
17
20
|
/* A C errno as the libuv error code Node reports (-ENOENT on POSIX; UV_ENOENT, -4058, on Windows). */
|
|
18
21
|
int js_node_uv_error(int e);
|
|
19
22
|
JSValue js_host_errno_name(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
20
23
|
JSValue js_host_timer_unref(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
24
|
+
JSValue js_host_timer_start(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
25
|
+
JSValue js_host_timer_ref(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
26
|
+
JSValue js_host_async_context_get(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
27
|
+
JSValue js_host_async_context_set(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
28
|
+
JSValue js_host_timer_clear(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
21
29
|
JSValue js_host_tty_isatty(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
22
30
|
JSValue js_host_errno_message(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
23
31
|
|
|
32
|
+
/* host_signal.c: process's signal events and process.kill */
|
|
33
|
+
JSValue js_host_signal_start(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
34
|
+
JSValue js_host_signal_stop(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
35
|
+
JSValue js_host_process_kill(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
36
|
+
|
|
24
37
|
/* host_http.c: llhttp on node:net's sockets (node:http) */
|
|
25
38
|
JSValue js_host_http_parsers(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
26
39
|
JSValue js_host_http_attach(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
@@ -68,4 +81,27 @@ JSValue js_host_os_constants(JSContext *ctx, JSValue callee, JSValue this_val, u
|
|
|
68
81
|
* with a TypeError pending. */
|
|
69
82
|
char *js_host_path_arg(JSContext *ctx, uint32_t argc, const JSValue *argv, uint32_t i);
|
|
70
83
|
|
|
84
|
+
/* host_zlib.c: Node's zlib binding over Chromium's zlib (node:zlib) */
|
|
85
|
+
JSValue js_host_zlib_new(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
86
|
+
JSValue js_host_zlib_init(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
87
|
+
JSValue js_host_zlib_write(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
88
|
+
JSValue js_host_zlib_params(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
89
|
+
JSValue js_host_zlib_reset(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
90
|
+
JSValue js_host_zlib_close(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
91
|
+
JSValue js_host_zlib_crc32(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
92
|
+
|
|
93
|
+
/* host_brotli.c: Node's Brotli binding (node:zlib) */
|
|
94
|
+
JSValue js_host_brotli_new(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
95
|
+
JSValue js_host_brotli_init(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
96
|
+
JSValue js_host_brotli_write(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
97
|
+
JSValue js_host_brotli_reset(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
98
|
+
JSValue js_host_brotli_close(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
99
|
+
|
|
100
|
+
/* host_zstd.c: Node's zstd binding (node:zlib) */
|
|
101
|
+
JSValue js_host_zstd_new(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
102
|
+
JSValue js_host_zstd_init(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
103
|
+
JSValue js_host_zstd_write(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
104
|
+
JSValue js_host_zstd_reset(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
105
|
+
JSValue js_host_zstd_close(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
106
|
+
|
|
71
107
|
#endif /* JS_NODE_H */
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
// node:async_hooks (ADR 0012, layer 3):
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
import {
|
|
1
|
+
// node:async_hooks (ADR 0012, layer 3; ADR 0020): AsyncLocalStorage, its stores kept in the async
|
|
2
|
+
// context the runtime carries through promises, jobs and timers, as Node's AsyncContextFrame
|
|
3
|
+
// does; AsyncResource, which keeps the context it was created in for a callback (on-finished,
|
|
4
|
+
// raw-body). Hooks never fire: visaljs has no async resources to report.
|
|
5
|
+
import { currentContext, runInContext, setContext } from "./internal/async_context.js";
|
|
6
|
+
import { invalidArgType, validateFunction, validateString } from "./internal/errors.js";
|
|
6
7
|
|
|
7
8
|
let nextAsyncId = 2; /* 1 is the main program's, as in Node */
|
|
8
9
|
|
|
9
10
|
export class AsyncResource {
|
|
10
11
|
#asyncId;
|
|
11
12
|
#triggerAsyncId;
|
|
13
|
+
#context;
|
|
12
14
|
|
|
13
15
|
constructor(type, opts = {}) {
|
|
14
16
|
validateString(type, "type");
|
|
15
17
|
this.#asyncId = nextAsyncId++;
|
|
16
18
|
this.#triggerAsyncId = typeof opts === "number" ? opts : (opts.triggerAsyncId ?? 1);
|
|
19
|
+
this.#context = currentContext();
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
runInAsyncScope(fn, thisArg, ...args) {
|
|
20
|
-
return
|
|
23
|
+
return runInContext(this.#context, fn, thisArg, args);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
emitDestroy() {
|
|
@@ -77,9 +80,61 @@ export function createHook() {
|
|
|
77
80
|
};
|
|
78
81
|
}
|
|
79
82
|
|
|
83
|
+
/* A frame: each storage's store, the context's value. A new one replaces the current one; it
|
|
84
|
+
* isn't changed while current, but disable() (as Node's). */
|
|
85
|
+
class AsyncContextFrame extends Map {
|
|
86
|
+
constructor(storage, store) {
|
|
87
|
+
super(currentContext());
|
|
88
|
+
this.set(storage, store);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
80
92
|
export class AsyncLocalStorage {
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
#defaultValue;
|
|
94
|
+
#name = "";
|
|
95
|
+
|
|
96
|
+
constructor(options = {}) {
|
|
97
|
+
if (options === null || typeof options !== "object") throw invalidArgType("options", "of type object", options);
|
|
98
|
+
this.#defaultValue = options.defaultValue;
|
|
99
|
+
if (options.name !== undefined) this.#name = `${options.name}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get name() {
|
|
103
|
+
return this.#name;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** fn, run in the context current now, wherever it is called. */
|
|
107
|
+
static bind(fn) {
|
|
108
|
+
return AsyncResource.bind(fn);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** (fn, ...args) => fn(...args) in the context current now. */
|
|
112
|
+
static snapshot() {
|
|
113
|
+
const resource = new AsyncResource("AsyncLocalStorageSnapshot");
|
|
114
|
+
return function runInAsyncScope(fn, ...args) {
|
|
115
|
+
return resource.runInAsyncScope(fn, this, ...args);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
disable() {
|
|
120
|
+
currentContext()?.delete(this);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
enterWith(store) {
|
|
124
|
+
setContext(new AsyncContextFrame(this, store));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
run(store, fn, ...args) {
|
|
128
|
+
return runInContext(new AsyncContextFrame(this, store), fn, null, args);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exit(fn, ...args) {
|
|
132
|
+
return this.run(undefined, fn, ...args);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getStore() {
|
|
136
|
+
const frame = currentContext();
|
|
137
|
+
return frame?.has(this) ? frame.get(this) : this.#defaultValue;
|
|
83
138
|
}
|
|
84
139
|
}
|
|
85
140
|
|
package/node/prelude/buffer.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
// node:diagnostics_channel (ADR 0012, layer 3): named channels a library publishes on and tools
|
|
2
|
+
// subscribe to, and TracingChannel's start / end / asyncStart / asyncEnd / error around a call.
|
|
3
|
+
// Node's algorithm: a channel with neither subscribers nor bound stores is inactive (publish does
|
|
4
|
+
// nothing, hasSubscribers is false) and held weakly; subscribing swaps in ActiveChannel's
|
|
5
|
+
// prototype. A subscriber's error doesn't stop the others: it is thrown on the next tick, as an
|
|
6
|
+
// uncaught exception.
|
|
7
|
+
import { invalidArgType, validateFunction } from "./internal/errors.js";
|
|
8
|
+
|
|
9
|
+
/* name → channel: weakly held, except while it has subscribers or stores (Node's WeakRefMap) */
|
|
10
|
+
class WeakRefMap {
|
|
11
|
+
#entries = new Map();
|
|
12
|
+
|
|
13
|
+
get(key) {
|
|
14
|
+
return this.#entries.get(key)?.ref.deref();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
set(key, value) {
|
|
18
|
+
this.#entries.set(key, { ref: new WeakRef(value), strong: undefined, count: 0 });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
incRef(key) {
|
|
22
|
+
const entry = this.#entries.get(key);
|
|
23
|
+
if (entry && entry.count++ === 0) entry.strong = entry.ref.deref();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
decRef(key) {
|
|
27
|
+
const entry = this.#entries.get(key);
|
|
28
|
+
if (entry && --entry.count === 0) entry.strong = undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const channels = new WeakRefMap();
|
|
33
|
+
|
|
34
|
+
function uncaught(err) {
|
|
35
|
+
process.nextTick(() => {
|
|
36
|
+
throw err;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function markActive(channel) {
|
|
41
|
+
Object.setPrototypeOf(channel, ActiveChannel.prototype);
|
|
42
|
+
channel._subscribers = [];
|
|
43
|
+
channel._stores = new Map();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function maybeMarkInactive(channel) {
|
|
47
|
+
if (!channel._subscribers.length && !channel._stores.size) {
|
|
48
|
+
Object.setPrototypeOf(channel, Channel.prototype);
|
|
49
|
+
channel._subscribers = undefined;
|
|
50
|
+
channel._stores = undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function defaultTransform(data) {
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* next() run in the store's context: store.run(transform(data), next) */
|
|
59
|
+
function wrapStoreRun(store, data, next, transform = defaultTransform) {
|
|
60
|
+
return () => {
|
|
61
|
+
let context;
|
|
62
|
+
try {
|
|
63
|
+
context = transform(data);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
uncaught(err);
|
|
66
|
+
return next();
|
|
67
|
+
}
|
|
68
|
+
return store.run(context, next);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class ActiveChannel {
|
|
73
|
+
subscribe(subscription) {
|
|
74
|
+
validateFunction(subscription, "subscription");
|
|
75
|
+
this._subscribers = [...this._subscribers, subscription]; /* a publish under way keeps its list */
|
|
76
|
+
channels.incRef(this.name);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
unsubscribe(subscription) {
|
|
80
|
+
const index = this._subscribers.indexOf(subscription);
|
|
81
|
+
if (index === -1) return false;
|
|
82
|
+
this._subscribers = [...this._subscribers.slice(0, index), ...this._subscribers.slice(index + 1)];
|
|
83
|
+
channels.decRef(this.name);
|
|
84
|
+
maybeMarkInactive(this);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
bindStore(store, transform) {
|
|
89
|
+
if (!this._stores.has(store)) channels.incRef(this.name);
|
|
90
|
+
this._stores.set(store, transform);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
unbindStore(store) {
|
|
94
|
+
if (!this._stores.has(store)) return false;
|
|
95
|
+
this._stores.delete(store);
|
|
96
|
+
channels.decRef(this.name);
|
|
97
|
+
maybeMarkInactive(this);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get hasSubscribers() {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
publish(data) {
|
|
106
|
+
const subscribers = this._subscribers;
|
|
107
|
+
for (let i = 0; i < (subscribers?.length || 0); i++) {
|
|
108
|
+
try {
|
|
109
|
+
const onMessage = subscribers[i];
|
|
110
|
+
onMessage(data, this.name);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
uncaught(err);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
runStores(data, fn, thisArg, ...args) {
|
|
118
|
+
let run = () => {
|
|
119
|
+
this.publish(data);
|
|
120
|
+
return Reflect.apply(fn, thisArg, args);
|
|
121
|
+
};
|
|
122
|
+
for (const [store, transform] of this._stores.entries()) run = wrapStoreRun(store, data, run, transform);
|
|
123
|
+
return run();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export class Channel {
|
|
128
|
+
constructor(name) {
|
|
129
|
+
this._subscribers = undefined;
|
|
130
|
+
this._stores = undefined;
|
|
131
|
+
this.name = name;
|
|
132
|
+
channels.set(name, this);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* an active channel's prototype is ActiveChannel's: it is a Channel still */
|
|
136
|
+
static [Symbol.hasInstance](instance) {
|
|
137
|
+
if (instance === null || (typeof instance !== "object" && typeof instance !== "function")) return false;
|
|
138
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
139
|
+
return prototype === Channel.prototype || prototype === ActiveChannel.prototype;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
subscribe(subscription) {
|
|
143
|
+
markActive(this);
|
|
144
|
+
this.subscribe(subscription);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
unsubscribe() {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
bindStore(store, transform) {
|
|
152
|
+
markActive(this);
|
|
153
|
+
this.bindStore(store, transform);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
unbindStore() {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get hasSubscribers() {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
publish() {}
|
|
165
|
+
|
|
166
|
+
runStores(data, fn, thisArg, ...args) {
|
|
167
|
+
return Reflect.apply(fn, thisArg, args);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function channel(name) {
|
|
172
|
+
const existing = channels.get(name);
|
|
173
|
+
if (existing) return existing;
|
|
174
|
+
if (typeof name !== "string" && typeof name !== "symbol") throw invalidArgType("channel", "one of type string or symbol", name);
|
|
175
|
+
return new Channel(name);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function subscribe(name, subscription) {
|
|
179
|
+
channel(name).subscribe(subscription);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function unsubscribe(name, subscription) {
|
|
183
|
+
return channel(name).unsubscribe(subscription);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function hasSubscribers(name) {
|
|
187
|
+
const existing = channels.get(name);
|
|
188
|
+
return existing ? existing.hasSubscribers : false;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* ---- TracingChannel ------------------------------------------------------------------ */
|
|
192
|
+
|
|
193
|
+
const traceEvents = ["start", "end", "asyncStart", "asyncEnd", "error"];
|
|
194
|
+
|
|
195
|
+
function tracingChannelFrom(nameOrChannels, name) {
|
|
196
|
+
if (typeof nameOrChannels === "string") return channel(`tracing:${nameOrChannels}:${name}`);
|
|
197
|
+
if (typeof nameOrChannels === "object" && nameOrChannels !== null) {
|
|
198
|
+
const found = nameOrChannels[name];
|
|
199
|
+
if (!(found instanceof Channel)) throw invalidArgType(`nameOrChannels.${name}`, "an instance of Channel", found);
|
|
200
|
+
return found;
|
|
201
|
+
}
|
|
202
|
+
throw invalidArgType("nameOrChannels", "of type string or an instance of TracingChannel or Object", nameOrChannels);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
class TracingChannel {
|
|
206
|
+
constructor(nameOrChannels) {
|
|
207
|
+
for (const eventName of traceEvents) {
|
|
208
|
+
Object.defineProperty(this, eventName, { value: tracingChannelFrom(nameOrChannels, eventName) });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
get hasSubscribers() {
|
|
213
|
+
return this.start.hasSubscribers || this.end.hasSubscribers || this.asyncStart.hasSubscribers ||
|
|
214
|
+
this.asyncEnd.hasSubscribers || this.error.hasSubscribers;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
subscribe(handlers) {
|
|
218
|
+
for (const name of traceEvents) {
|
|
219
|
+
if (!handlers[name]) continue;
|
|
220
|
+
this[name]?.subscribe(handlers[name]);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
unsubscribe(handlers) {
|
|
225
|
+
let done = true;
|
|
226
|
+
for (const name of traceEvents) {
|
|
227
|
+
if (!handlers[name]) continue;
|
|
228
|
+
if (!this[name]?.unsubscribe(handlers[name])) done = false;
|
|
229
|
+
}
|
|
230
|
+
return done;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
traceSync(fn, context = {}, thisArg, ...args) {
|
|
234
|
+
if (!this.hasSubscribers) return Reflect.apply(fn, thisArg, args);
|
|
235
|
+
const { start, end, error } = this;
|
|
236
|
+
return start.runStores(context, () => {
|
|
237
|
+
try {
|
|
238
|
+
const result = Reflect.apply(fn, thisArg, args);
|
|
239
|
+
context.result = result;
|
|
240
|
+
return result;
|
|
241
|
+
} catch (err) {
|
|
242
|
+
context.error = err;
|
|
243
|
+
error.publish(context);
|
|
244
|
+
throw err;
|
|
245
|
+
} finally {
|
|
246
|
+
end.publish(context);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
tracePromise(fn, context = {}, thisArg, ...args) {
|
|
252
|
+
if (!this.hasSubscribers) return Reflect.apply(fn, thisArg, args);
|
|
253
|
+
const { start, end, asyncStart, asyncEnd, error } = this;
|
|
254
|
+
function reject(err) {
|
|
255
|
+
context.error = err;
|
|
256
|
+
error.publish(context);
|
|
257
|
+
asyncStart.publish(context);
|
|
258
|
+
asyncEnd.publish(context);
|
|
259
|
+
return Promise.reject(err);
|
|
260
|
+
}
|
|
261
|
+
function resolve(result) {
|
|
262
|
+
context.result = result;
|
|
263
|
+
asyncStart.publish(context);
|
|
264
|
+
asyncEnd.publish(context);
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
return start.runStores(context, () => {
|
|
268
|
+
try {
|
|
269
|
+
let promise = Reflect.apply(fn, thisArg, args);
|
|
270
|
+
if (!(promise instanceof Promise)) promise = Promise.resolve(promise); /* a thenable, a value */
|
|
271
|
+
return promise.then(resolve, reject);
|
|
272
|
+
} catch (err) {
|
|
273
|
+
context.error = err;
|
|
274
|
+
error.publish(context);
|
|
275
|
+
throw err;
|
|
276
|
+
} finally {
|
|
277
|
+
end.publish(context);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* the callback at args[position] (-1: the last) reports the async half */
|
|
283
|
+
traceCallback(fn, position = -1, context = {}, thisArg, ...args) {
|
|
284
|
+
if (!this.hasSubscribers) return Reflect.apply(fn, thisArg, args);
|
|
285
|
+
const { start, end, asyncStart, asyncEnd, error } = this;
|
|
286
|
+
function wrappedCallback(err, res) {
|
|
287
|
+
if (err) {
|
|
288
|
+
context.error = err;
|
|
289
|
+
error.publish(context);
|
|
290
|
+
} else {
|
|
291
|
+
context.result = res;
|
|
292
|
+
}
|
|
293
|
+
asyncStart.runStores(context, () => {
|
|
294
|
+
try {
|
|
295
|
+
return Reflect.apply(callback, this, arguments);
|
|
296
|
+
} finally {
|
|
297
|
+
asyncEnd.publish(context);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
const callback = args.at(position);
|
|
302
|
+
validateFunction(callback, "callback");
|
|
303
|
+
args.splice(position, 1, wrappedCallback);
|
|
304
|
+
return start.runStores(context, () => {
|
|
305
|
+
try {
|
|
306
|
+
return Reflect.apply(fn, thisArg, args);
|
|
307
|
+
} catch (err) {
|
|
308
|
+
context.error = err;
|
|
309
|
+
error.publish(context);
|
|
310
|
+
throw err;
|
|
311
|
+
} finally {
|
|
312
|
+
end.publish(context);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export function tracingChannel(nameOrChannels) {
|
|
319
|
+
return new TracingChannel(nameOrChannels);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export default { channel, hasSubscribers, subscribe, tracingChannel, unsubscribe, Channel };
|
package/node/prelude/dns.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// is (results in the system's order, Node's default "verbatim"). Not yet: the resolve* queries
|
|
3
3
|
// (c-ares) and Resolver.
|
|
4
4
|
import { dnsLookup, errnoName } from "visaljs:host";
|
|
5
|
+
import { bindContext } from "./internal/async_context.js";
|
|
5
6
|
import { codeError, invalidArgType } from "./internal/errors.js";
|
|
6
7
|
import { isIP } from "./internal/net.js";
|
|
7
8
|
|
|
@@ -76,11 +77,11 @@ export function lookup(hostname, options, callback) {
|
|
|
76
77
|
process.nextTick(() => (all ? callback(null, [{ address: hostname, family: matched }]) : callback(null, hostname, matched)));
|
|
77
78
|
return {};
|
|
78
79
|
}
|
|
79
|
-
const r = dnsLookup(hostname, family, (errno, code, list) => {
|
|
80
|
+
const r = dnsLookup(hostname, family, bindContext((errno, code, list) => {
|
|
80
81
|
if (errno) callback(dnsException(errno, code, "getaddrinfo", hostname));
|
|
81
82
|
else if (all) callback(null, list.map(([address, family]) => ({ address, family })));
|
|
82
83
|
else callback(null, list[0][0], list[0][1]);
|
|
83
|
-
});
|
|
84
|
+
}));
|
|
84
85
|
if (r < 0) process.nextTick(callback, dnsException(r, errnoName(r), "getaddrinfo", hostname));
|
|
85
86
|
return {};
|
|
86
87
|
}
|
package/node/prelude/events.js
CHANGED
|
@@ -173,13 +173,27 @@ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
|
173
173
|
EventEmitter.prototype.removeAllListeners = function (type) {
|
|
174
174
|
const events = this._events;
|
|
175
175
|
if (events === undefined) return this;
|
|
176
|
+
if (events.removeListener === undefined) { /* nobody hears of it: drop them at once */
|
|
177
|
+
if (arguments.length === 0) {
|
|
178
|
+
this._events = Object.create(null);
|
|
179
|
+
this._eventsCount = 0;
|
|
180
|
+
} else if (events[type] !== undefined) {
|
|
181
|
+
if (--this._eventsCount === 0) this._events = Object.create(null);
|
|
182
|
+
else delete events[type];
|
|
183
|
+
}
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
/* one by one, last first, each a 'removeListener' (process stops watching a signal so) */
|
|
176
187
|
if (arguments.length === 0) {
|
|
188
|
+
for (const key of Reflect.ownKeys(events)) if (key !== "removeListener") this.removeAllListeners(key);
|
|
189
|
+
this.removeAllListeners("removeListener");
|
|
177
190
|
this._events = Object.create(null);
|
|
178
191
|
this._eventsCount = 0;
|
|
179
|
-
|
|
180
|
-
if (--this._eventsCount === 0) this._events = Object.create(null);
|
|
181
|
-
else delete events[type];
|
|
192
|
+
return this;
|
|
182
193
|
}
|
|
194
|
+
const listeners = events[type];
|
|
195
|
+
if (typeof listeners === "function") this.removeListener(type, listeners);
|
|
196
|
+
else if (listeners !== undefined) for (let i = listeners.length - 1; i >= 0; i--) this.removeListener(type, listeners[i]);
|
|
183
197
|
return this;
|
|
184
198
|
};
|
|
185
199
|
|