visaljs 0.0.4 → 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 +1 -1
- 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/prelude/fs.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
// node:fs (ADR 0012, layer 3): the synchronous file API, over the host primitives
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// node:fs (ADR 0012, layer 3): the synchronous file API, over the host primitives, and the
|
|
2
|
+
// callback API, stat's and readdir's, and read streams over it. Contents are Buffers without an
|
|
3
|
+
// encoding, else strings in any of Buffer's encodings. A callback runs on a later tick, as
|
|
4
|
+
// Node's, though the I/O itself happened synchronously (so do node:fs/promises').
|
|
5
|
+
import { errnoName, fsExists, fsReadAt, fsReaddir, fsReadFile, fsStat, fsUnlink, fsWriteFile } from "visaljs:host";
|
|
6
|
+
import { codeError, invalidArgType, invalidArgValue, notSupported, systemError, validateFunction } from "./internal/errors.js";
|
|
7
|
+
import { Readable } from "./stream.js";
|
|
5
8
|
|
|
6
9
|
function validatePath(path) {
|
|
7
10
|
if (typeof path !== "string") {
|
|
@@ -76,4 +79,173 @@ export function unlinkSync(path) {
|
|
|
76
79
|
check(fsUnlink(path), "unlink", path);
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
/* ---- stat ------------------------------------------------------------------------- */
|
|
83
|
+
|
|
84
|
+
const S_IFMT = 0o170000, S_IFREG = 0o100000, S_IFDIR = 0o040000, S_IFLNK = 0o120000, S_IFIFO = 0o010000,
|
|
85
|
+
S_IFSOCK = 0o140000, S_IFCHR = 0o020000, S_IFBLK = 0o060000;
|
|
86
|
+
|
|
87
|
+
export class Stats {
|
|
88
|
+
constructor(dev, mode, nlink, uid, gid, rdev, blksize, ino, size, blocks, atimeMs, mtimeMs, ctimeMs, birthtimeMs) {
|
|
89
|
+
Object.assign(this, { dev, mode, nlink, uid, gid, rdev, blksize, ino, size, blocks, atimeMs, mtimeMs, ctimeMs, birthtimeMs });
|
|
90
|
+
this.atime = new Date(atimeMs);
|
|
91
|
+
this.mtime = new Date(mtimeMs);
|
|
92
|
+
this.ctime = new Date(ctimeMs);
|
|
93
|
+
this.birthtime = new Date(birthtimeMs);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
isFile() { return (this.mode & S_IFMT) === S_IFREG; }
|
|
97
|
+
isDirectory() { return (this.mode & S_IFMT) === S_IFDIR; }
|
|
98
|
+
isSymbolicLink() { return (this.mode & S_IFMT) === S_IFLNK; }
|
|
99
|
+
isFIFO() { return (this.mode & S_IFMT) === S_IFIFO; }
|
|
100
|
+
isSocket() { return (this.mode & S_IFMT) === S_IFSOCK; }
|
|
101
|
+
isCharacterDevice() { return (this.mode & S_IFMT) === S_IFCHR; }
|
|
102
|
+
isBlockDevice() { return (this.mode & S_IFMT) === S_IFBLK; }
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function statOf(path, options, follow, syscall) {
|
|
106
|
+
validatePath(path);
|
|
107
|
+
const r = fsStat(path, follow);
|
|
108
|
+
if (typeof r === "number") {
|
|
109
|
+
if (options?.throwIfNoEntry === false && errnoName(r) === "ENOENT") return undefined;
|
|
110
|
+
throw systemError(r, syscall, path);
|
|
111
|
+
}
|
|
112
|
+
const [mode, size, mtimeMs, atimeMs, ctimeMs, birthtimeMs, ino, dev, nlink, uid, gid, rdev, blksize, blocks] = r;
|
|
113
|
+
return new Stats(dev, mode, nlink, uid, gid, rdev, blksize, ino, size, blocks, atimeMs, mtimeMs, ctimeMs, birthtimeMs);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function statSync(path, options) {
|
|
117
|
+
return statOf(path, options, true, "stat");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function lstatSync(path, options) {
|
|
121
|
+
return statOf(path, options, false, "lstat");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ---- readdir ---------------------------------------------------------------------- */
|
|
125
|
+
|
|
126
|
+
/* libuv's uv_dirent_type_t */
|
|
127
|
+
const UV_DIRENT_FILE = 1, UV_DIRENT_DIR = 2, UV_DIRENT_LINK = 3, UV_DIRENT_FIFO = 4, UV_DIRENT_SOCKET = 5, UV_DIRENT_CHAR = 6,
|
|
128
|
+
UV_DIRENT_BLOCK = 7;
|
|
129
|
+
const kType = Symbol("type");
|
|
130
|
+
|
|
131
|
+
export class Dirent {
|
|
132
|
+
constructor(name, type, path) {
|
|
133
|
+
this.name = name;
|
|
134
|
+
this.parentPath = path;
|
|
135
|
+
this.path = path;
|
|
136
|
+
this[kType] = type;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
isFile() { return this[kType] === UV_DIRENT_FILE; }
|
|
140
|
+
isDirectory() { return this[kType] === UV_DIRENT_DIR; }
|
|
141
|
+
isSymbolicLink() { return this[kType] === UV_DIRENT_LINK; }
|
|
142
|
+
isFIFO() { return this[kType] === UV_DIRENT_FIFO; }
|
|
143
|
+
isSocket() { return this[kType] === UV_DIRENT_SOCKET; }
|
|
144
|
+
isCharacterDevice() { return this[kType] === UV_DIRENT_CHAR; }
|
|
145
|
+
isBlockDevice() { return this[kType] === UV_DIRENT_BLOCK; }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function readdirSync(path, options) {
|
|
149
|
+
validatePath(path);
|
|
150
|
+
if (options?.recursive) throw notSupported("readdir's recursive option");
|
|
151
|
+
const encoding = encodingOf(options);
|
|
152
|
+
validateEncodingName(encoding);
|
|
153
|
+
const r = check(fsReaddir(path), "scandir", path);
|
|
154
|
+
const names = [], types = [];
|
|
155
|
+
for (let i = 0; i < r.length; i += 2) {
|
|
156
|
+
names.push(r[i]);
|
|
157
|
+
types.push(r[i + 1]);
|
|
158
|
+
}
|
|
159
|
+
/* in libuv's order, as Node's (it lists them through libuv too) */
|
|
160
|
+
const named = (name) => (encoding === undefined || isUtf8(encoding) ? name : encoding === "buffer" ? Buffer.from(name) : Buffer.from(name).toString(encoding));
|
|
161
|
+
if (options?.withFileTypes) return names.map((name, i) => new Dirent(named(name), types[i], path));
|
|
162
|
+
return names.map(named);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* ---- the callback API: the synchronous call, its outcome on a later tick ------------ */
|
|
166
|
+
|
|
167
|
+
function later(fn, args, callback) {
|
|
168
|
+
validateFunction(callback, "cb");
|
|
169
|
+
let result, error = null;
|
|
170
|
+
try {
|
|
171
|
+
result = fn(...args);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
error = e;
|
|
174
|
+
}
|
|
175
|
+
process.nextTick(() => (error ? callback(error) : callback(null, result)));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const withCallback = (fn) => (path, options, callback) => {
|
|
179
|
+
if (typeof options === "function") later(fn, [path], options);
|
|
180
|
+
else later(fn, [path, options], callback);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const readFile = withCallback(readFileSync);
|
|
184
|
+
export const stat = withCallback(statSync);
|
|
185
|
+
export const lstat = withCallback(lstatSync);
|
|
186
|
+
export const readdir = withCallback(readdirSync);
|
|
187
|
+
|
|
188
|
+
export function writeFile(path, data, options, callback) {
|
|
189
|
+
if (typeof options === "function") later(writeFileSync, [path, data], options);
|
|
190
|
+
else later(writeFileSync, [path, data, options], callback);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function unlink(path, callback) {
|
|
194
|
+
later(unlinkSync, [path], callback);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* ---- read streams --------------------------------------------------------------- */
|
|
198
|
+
|
|
199
|
+
/** A file read a chunk at a time, from `start` to `end` (inclusive), as Node's. */
|
|
200
|
+
export class ReadStream extends Readable {
|
|
201
|
+
constructor(path, options) {
|
|
202
|
+
if (typeof options === "string") options = { encoding: options };
|
|
203
|
+
options = { ...options };
|
|
204
|
+
super({ highWaterMark: options.highWaterMark ?? 64 * 1024, encoding: options.encoding, emitClose: options.emitClose ?? true, autoDestroy: options.autoClose ?? true });
|
|
205
|
+
validatePath(path);
|
|
206
|
+
this.path = path;
|
|
207
|
+
this.start = options.start;
|
|
208
|
+
this.end = options.end ?? Infinity;
|
|
209
|
+
this.pos = options.start ?? 0;
|
|
210
|
+
this.bytesRead = 0;
|
|
211
|
+
this.pending = true;
|
|
212
|
+
/* opened on the next tick, as Node's: a missing file is an error even if nothing reads */
|
|
213
|
+
process.nextTick(() => {
|
|
214
|
+
const r = fsStat(path, true);
|
|
215
|
+
if (typeof r === "number") return this.destroy(systemError(r, "open", path));
|
|
216
|
+
this.pending = false;
|
|
217
|
+
this.emit("open");
|
|
218
|
+
this.emit("ready");
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* a chunk on a later tick, as Node's read (on libuv's thread pool) delivers it: each read a chunk */
|
|
223
|
+
_read() {
|
|
224
|
+
const want = Math.min(this.readableHighWaterMark, this.end + 1 - this.pos);
|
|
225
|
+
if (want <= 0) return this.push(null);
|
|
226
|
+
const chunk = fsReadAt(this.path, this.pos, want);
|
|
227
|
+
process.nextTick(() => {
|
|
228
|
+
if (typeof chunk === "number") return this.destroy(systemError(chunk, "read", this.path));
|
|
229
|
+
if (chunk.length === 0) return this.push(null);
|
|
230
|
+
this.pos += chunk.length;
|
|
231
|
+
this.bytesRead += chunk.length;
|
|
232
|
+
this.push(chunk);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function createReadStream(path, options) {
|
|
238
|
+
return new ReadStream(path, options);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* node:fs/promises, which imports this module: read when used, not while the modules load */
|
|
242
|
+
export { default as promises } from "./fs_promises.js";
|
|
243
|
+
import promises from "./fs_promises.js";
|
|
244
|
+
|
|
245
|
+
export default {
|
|
246
|
+
readFileSync, writeFileSync, appendFileSync, existsSync, unlinkSync, statSync, lstatSync, readdirSync, readFile, writeFile,
|
|
247
|
+
unlink, stat, lstat, readdir, createReadStream, ReadStream, Stats, Dirent,
|
|
248
|
+
get promises() {
|
|
249
|
+
return promises;
|
|
250
|
+
},
|
|
251
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// node:fs/promises (ADR 0012, layer 3): node:fs's synchronous calls, their outcome as a promise.
|
|
2
|
+
// The I/O happens when the function is called, not on libuv's thread pool as in Node.
|
|
3
|
+
import {
|
|
4
|
+
appendFileSync, existsSync, lstatSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync,
|
|
5
|
+
} from "./fs.js";
|
|
6
|
+
|
|
7
|
+
const promised = (fn) => async (...args) => fn(...args);
|
|
8
|
+
|
|
9
|
+
export const readFile = promised(readFileSync);
|
|
10
|
+
export const writeFile = promised(writeFileSync);
|
|
11
|
+
export const appendFile = promised(appendFileSync);
|
|
12
|
+
export const stat = promised(statSync);
|
|
13
|
+
export const lstat = promised(lstatSync);
|
|
14
|
+
export const readdir = promised(readdirSync);
|
|
15
|
+
export const unlink = promised(unlinkSync);
|
|
16
|
+
|
|
17
|
+
/** Whether the path exists (the mode isn't checked). */
|
|
18
|
+
export async function access(path) {
|
|
19
|
+
if (!existsSync(path)) {
|
|
20
|
+
statSync(path); /* throws Node's ENOENT (or the error that stopped it) */
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default { readFile, writeFile, appendFile, stat, lstat, readdir, unlink, access };
|
package/node/prelude/http.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// connections close after keepAliveTimeout; server.timeout and setTimeout are the sockets'.
|
|
9
9
|
// Not yet: the client, headersTimeout and requestTimeout, trailers.
|
|
10
10
|
import { httpAttach, httpDate, httpDetach, httpExpired, httpFlush, httpParsers, httpWrite, timerUnref } from "visaljs:host";
|
|
11
|
+
import { bindContext, currentContext, runInContext } from "./internal/async_context.js";
|
|
11
12
|
import { codeError, invalidArgType, outOfRange, validateInteger, validateString } from "./internal/errors.js";
|
|
12
13
|
import { Agent, globalAgent } from "./internal/http_agent.js";
|
|
13
14
|
import { createConnection, Server as NetServer } from "./net.js";
|
|
@@ -543,7 +544,8 @@ export class Server extends NetServer {
|
|
|
543
544
|
/* a connection: its bytes go to llhttp; its end, timeout, errors and close are the requests' */
|
|
544
545
|
_onSocket(socket) {
|
|
545
546
|
if (this._parsers === -1) {
|
|
546
|
-
|
|
547
|
+
/* in the async context of the connection's (ADR 0020), as the server's sockets' callbacks */
|
|
548
|
+
this._parsers = httpParsers(...[
|
|
547
549
|
(conn, method, url, raw, major, minor, keepAlive, upgrade) => this._onRequest(conn, method, url, raw, major, minor, keepAlive, upgrade),
|
|
548
550
|
(conn, chunk) => this._states.get(conn)?.req?._push(chunk),
|
|
549
551
|
(conn, trailers) => {
|
|
@@ -567,7 +569,7 @@ export class Server extends NetServer {
|
|
|
567
569
|
e.reason = reason;
|
|
568
570
|
socketOnError.call(state.socket, e);
|
|
569
571
|
},
|
|
570
|
-
);
|
|
572
|
+
].map(bindContext));
|
|
571
573
|
}
|
|
572
574
|
const conn = socket._handle;
|
|
573
575
|
if (conn === null) return;
|
|
@@ -704,10 +706,16 @@ function urlToHttpOptions(url) {
|
|
|
704
706
|
const clientSockets = new Map();
|
|
705
707
|
let clientParsers = -1;
|
|
706
708
|
|
|
709
|
+
/* the async context a request was made in (ADR 0020): its response's callbacks run in it, as in
|
|
710
|
+
* Node, whichever request's the socket was */
|
|
711
|
+
const kAsyncContext = Symbol("kAsyncContext");
|
|
712
|
+
const inRequestContext = (fn) => (conn, ...args) =>
|
|
713
|
+
runInContext(clientSockets.get(conn)?._httpMessage?.[kAsyncContext], fn, undefined, [conn, ...args]);
|
|
714
|
+
|
|
707
715
|
function clientParsersId() {
|
|
708
716
|
if (clientParsers !== -1) return clientParsers;
|
|
709
717
|
const reqOf = (conn) => clientSockets.get(conn)?._httpMessage;
|
|
710
|
-
clientParsers = httpParsers(
|
|
718
|
+
clientParsers = httpParsers(...[
|
|
711
719
|
(conn, statusCode, statusMessage, raw, major, minor, keepAlive, upgrade) => {
|
|
712
720
|
const socket = clientSockets.get(conn);
|
|
713
721
|
const req = socket?._httpMessage;
|
|
@@ -759,7 +767,7 @@ function clientParsersId() {
|
|
|
759
767
|
req.emit("error", e);
|
|
760
768
|
}
|
|
761
769
|
},
|
|
762
|
-
);
|
|
770
|
+
].map(inRequestContext));
|
|
763
771
|
return clientParsers;
|
|
764
772
|
}
|
|
765
773
|
|
|
@@ -945,6 +953,7 @@ const INVALID_PATH_REGEX = /[^!-ÿ]/;
|
|
|
945
953
|
export class ClientRequest extends OutgoingMessage {
|
|
946
954
|
constructor(input, options, cb) {
|
|
947
955
|
super();
|
|
956
|
+
this[kAsyncContext] = currentContext();
|
|
948
957
|
if (typeof input === "string") input = urlToHttpOptions(new URL(input));
|
|
949
958
|
else if (input instanceof URL) input = urlToHttpOptions(input);
|
|
950
959
|
else {
|
package/node/prelude/http2.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The async context (ADR 0020): the value the runtime carries through jobs, timers and promise
|
|
2
|
+
// reactions, which node:async_hooks' AsyncLocalStorage keeps its stores in (a frame: a Map from
|
|
3
|
+
// each storage to its store, never changed once current). I/O callbacks run under none: the
|
|
4
|
+
// prelude binds each to the context it was registered in, as Node runs a handle's callbacks in
|
|
5
|
+
// the context of its resource.
|
|
6
|
+
import { asyncContextGet, asyncContextSet } from "visaljs:host";
|
|
7
|
+
|
|
8
|
+
export { asyncContextGet as currentContext, asyncContextSet as setContext };
|
|
9
|
+
|
|
10
|
+
/** fn.apply(thisArg, args) under `context`, then the current one again. */
|
|
11
|
+
export function runInContext(context, fn, thisArg, args) {
|
|
12
|
+
const prior = asyncContextGet();
|
|
13
|
+
if (prior === context) return Reflect.apply(fn, thisArg, args);
|
|
14
|
+
asyncContextSet(context);
|
|
15
|
+
try {
|
|
16
|
+
return Reflect.apply(fn, thisArg, args);
|
|
17
|
+
} finally {
|
|
18
|
+
asyncContextSet(prior);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A host callback (it runs under no context) that runs under the current one: fn itself when
|
|
23
|
+
* there's none. */
|
|
24
|
+
export function bindContext(fn) {
|
|
25
|
+
const context = asyncContextGet();
|
|
26
|
+
return context === undefined ? fn : (...args) => runInContext(context, fn, undefined, args);
|
|
27
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -56,6 +56,17 @@ export function systemError(errno, syscall, path) {
|
|
|
56
56
|
return error;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/** A failed libuv call as Node's errnoException builds it: `kill ESRCH`, with errno, code and
|
|
60
|
+
* syscall. */
|
|
61
|
+
export function errnoException(errno, syscall) {
|
|
62
|
+
const code = errnoName(errno);
|
|
63
|
+
const error = new Error(syscall + " " + code);
|
|
64
|
+
error.errno = errno;
|
|
65
|
+
error.code = code;
|
|
66
|
+
error.syscall = syscall;
|
|
67
|
+
return error;
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
export function validateString(value, name) {
|
|
60
71
|
if (typeof value !== "string") throw invalidArgType(name, "of type string", value);
|
|
61
72
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// process as an EventEmitter (ADR 0012): the runtime's process, in every binary, is a plain
|
|
2
|
+
// object. A program that may call its emitter methods gets this module first (the driver adds it:
|
|
3
|
+
// implicitModules in node/index.ts), and the runtime emits process's events through its emit.
|
|
4
|
+
import { EventEmitter } from "../events.js";
|
|
5
|
+
|
|
6
|
+
const p = globalThis.process;
|
|
7
|
+
|
|
8
|
+
/* its prototype is process.constructor.prototype, an EventEmitter's, as in Node */
|
|
9
|
+
function process() {}
|
|
10
|
+
process.prototype = Object.create(EventEmitter.prototype, {
|
|
11
|
+
constructor: { value: process, writable: true, configurable: true },
|
|
12
|
+
});
|
|
13
|
+
Object.setPrototypeOf(p, process.prototype);
|
|
14
|
+
EventEmitter.init.call(p);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// process's signal events and process.kill (ADR 0012): Node's startListeningIfSignal and
|
|
2
|
+
// stopListeningIfSignal, on libuv's signal handles (src/host_signal.c). A program gets this
|
|
3
|
+
// module when its code names process and a signal ("SIGINT") or kill (implicitModules in
|
|
4
|
+
// node/index.ts); apart from process_events.js, as it links libuv.
|
|
5
|
+
import { osConstants, processKill, signalStart, signalStop } from "visaljs:host";
|
|
6
|
+
import { codeError, errnoException, invalidArgType } from "./errors.js";
|
|
7
|
+
import "./process_events.js";
|
|
8
|
+
|
|
9
|
+
const p = globalThis.process;
|
|
10
|
+
const signals = Object.create(null); // "SIGINT" → 2, as os.constants.signals
|
|
11
|
+
const [table] = osConstants();
|
|
12
|
+
for (let i = 0; i < table.length; i += 2) signals[table[i]] = table[i + 1];
|
|
13
|
+
const watched = Object.create(null);
|
|
14
|
+
|
|
15
|
+
/* the first listener of a signal replaces its default action; listeners get (name, number) */
|
|
16
|
+
p.on("newListener", (type) => {
|
|
17
|
+
if (typeof type !== "string" || signals[type] === undefined || watched[type]) return;
|
|
18
|
+
const err = signalStart(signals[type], (signum) => p.emit(type, type, signum));
|
|
19
|
+
if (err < 0) throw errnoException(err, "uv_signal_start");
|
|
20
|
+
watched[type] = true;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/* the last one gone, the default action again */
|
|
24
|
+
p.on("removeListener", (type) => {
|
|
25
|
+
if (typeof type !== "string" || !watched[type] || p.listenerCount(type) > 0) return;
|
|
26
|
+
signalStop(signals[type]);
|
|
27
|
+
watched[type] = false;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
p.kill = function kill(pid, sig) {
|
|
31
|
+
if (pid != (pid | 0)) throw invalidArgType("pid", "of type number", pid);
|
|
32
|
+
let signum;
|
|
33
|
+
if (sig === (sig | 0)) signum = sig;
|
|
34
|
+
else {
|
|
35
|
+
sig = sig || "SIGTERM";
|
|
36
|
+
signum = signals[sig];
|
|
37
|
+
if (signum === undefined) throw codeError(TypeError, "ERR_UNKNOWN_SIGNAL", "Unknown signal: " + sig);
|
|
38
|
+
}
|
|
39
|
+
const err = processKill(pid, signum);
|
|
40
|
+
if (err < 0) throw errnoException(err, "kill");
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// node:timers' core (ADR 0012): Timeout and Immediate on the runtime's timers (timerStart and
|
|
2
|
+
// friends, runtime/src/jobs.c). Each object holds one native one-shot timer, armed under one id
|
|
3
|
+
// (also its primitive), which an interval re-arms after its callback. node:timers and
|
|
4
|
+
// node:timers/promises build on it; a program that uses them gets them as its globals too
|
|
5
|
+
// (timers_global.js).
|
|
6
|
+
import { timerClear, timerRef, timerStart } from "visaljs:host";
|
|
7
|
+
import { validateFunction } from "./errors.js";
|
|
8
|
+
|
|
9
|
+
export const TIMEOUT_MAX = 2 ** 31 - 1;
|
|
10
|
+
|
|
11
|
+
export const kId = Symbol("timerId"); /* its native timer's id, which is also its primitive */
|
|
12
|
+
export const kFire = Symbol("fire"); /* the native timer's callback: one per object */
|
|
13
|
+
export const kPending = Symbol("pending"); /* a native timer is armed */
|
|
14
|
+
export const kRefed = Symbol("refed");
|
|
15
|
+
const kHasPrimitive = Symbol("kHasPrimitive");
|
|
16
|
+
|
|
17
|
+
/* the ids of timers whose primitive was taken: clearTimeout(id) finds them (Node's knownTimersById) */
|
|
18
|
+
const knownTimersById = new Map();
|
|
19
|
+
/* every armed Timeout: a number that names one whose primitive wasn't taken clears nothing */
|
|
20
|
+
export const armed = new Map();
|
|
21
|
+
|
|
22
|
+
function emitWarning(message) {
|
|
23
|
+
if (typeof process.emitWarning === "function") process.emitWarning(message, "TimeoutOverflowWarning");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* the delay as Node takes it: 1 when below 1 ms, not a number or past 2^31 - 1 */
|
|
27
|
+
export function duration(after) {
|
|
28
|
+
after *= 1;
|
|
29
|
+
if (!(after >= 1 && after <= TIMEOUT_MAX)) {
|
|
30
|
+
if (after > TIMEOUT_MAX) emitWarning(`${after} does not fit into a 32-bit signed integer.\nTimeout duration was set to 1.`);
|
|
31
|
+
after = 1;
|
|
32
|
+
}
|
|
33
|
+
return after;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* (re)arms the native timer under the item's id: a pending one starts over */
|
|
37
|
+
export function arm(item, refed) {
|
|
38
|
+
item[kId] = timerStart(item[kFire], item._idleTimeout, refed, item[kId] ?? 0);
|
|
39
|
+
item[kPending] = true;
|
|
40
|
+
armed.set(item[kId], item);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function disarm(item) {
|
|
44
|
+
if (item[kPending]) timerClear(item[kId]);
|
|
45
|
+
item[kPending] = false;
|
|
46
|
+
armed.delete(item[kId]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class Timeout {
|
|
50
|
+
constructor(callback, after, args, isRepeat, isRefed) {
|
|
51
|
+
after = duration(after);
|
|
52
|
+
this._idleTimeout = after;
|
|
53
|
+
this._idlePrev = this;
|
|
54
|
+
this._idleNext = this;
|
|
55
|
+
this._idleStart = null;
|
|
56
|
+
this._onTimeout = callback;
|
|
57
|
+
this._timerArgs = args;
|
|
58
|
+
this._repeat = isRepeat ? after : null;
|
|
59
|
+
this._destroyed = false;
|
|
60
|
+
this[kRefed] = isRefed;
|
|
61
|
+
this[kHasPrimitive] = false;
|
|
62
|
+
this[kPending] = false;
|
|
63
|
+
this[kFire] = () => fireTimeout(this);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* the timer starts over from now; one that already fired runs again */
|
|
67
|
+
refresh() {
|
|
68
|
+
if (this._idleTimeout >= 0) {
|
|
69
|
+
this._destroyed = false;
|
|
70
|
+
arm(this, this[kRefed]);
|
|
71
|
+
}
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
unref() {
|
|
76
|
+
if (this[kRefed]) {
|
|
77
|
+
this[kRefed] = false;
|
|
78
|
+
if (this[kPending]) timerRef(this[kId], false);
|
|
79
|
+
}
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
ref() {
|
|
84
|
+
if (!this[kRefed]) {
|
|
85
|
+
this[kRefed] = true;
|
|
86
|
+
if (this[kPending]) timerRef(this[kId], true);
|
|
87
|
+
}
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
hasRef() {
|
|
92
|
+
return this[kRefed];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
close() {
|
|
96
|
+
clearTimeout(this);
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
[Symbol.toPrimitive]() {
|
|
101
|
+
const id = this[kId];
|
|
102
|
+
if (!this[kHasPrimitive]) {
|
|
103
|
+
this[kHasPrimitive] = true;
|
|
104
|
+
knownTimersById.set(id, this);
|
|
105
|
+
}
|
|
106
|
+
return id;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (typeof Symbol.dispose === "symbol") {
|
|
110
|
+
Timeout.prototype[Symbol.dispose] = function () {
|
|
111
|
+
clearTimeout(this);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function fireTimeout(timer) {
|
|
116
|
+
timer[kPending] = false;
|
|
117
|
+
armed.delete(timer[kId]);
|
|
118
|
+
const args = timer._timerArgs;
|
|
119
|
+
try {
|
|
120
|
+
if (args === undefined) timer._onTimeout();
|
|
121
|
+
else Reflect.apply(timer._onTimeout, timer, args);
|
|
122
|
+
} finally {
|
|
123
|
+
if (timer._repeat && timer._idleTimeout !== -1) {
|
|
124
|
+
timer._idleTimeout = timer._repeat;
|
|
125
|
+
if (!timer[kPending]) arm(timer, timer[kRefed]);
|
|
126
|
+
} else if (!timer[kPending] && !timer._destroyed) { /* not refreshed by its callback */
|
|
127
|
+
timer._destroyed = true;
|
|
128
|
+
if (timer[kHasPrimitive]) knownTimersById.delete(timer[kId]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function unenrollTimeout(item) {
|
|
134
|
+
if (item._destroyed) return;
|
|
135
|
+
item._destroyed = true;
|
|
136
|
+
if (item[kHasPrimitive]) knownTimersById.delete(item[kId]);
|
|
137
|
+
disarm(item);
|
|
138
|
+
item._idleTimeout = -1;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function setTimeout(callback, after, ...args) {
|
|
142
|
+
validateFunction(callback, "callback");
|
|
143
|
+
const timeout = new Timeout(callback, after, args.length ? args : undefined, false, true);
|
|
144
|
+
arm(timeout, true);
|
|
145
|
+
return timeout;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function setInterval(callback, repeat, ...args) {
|
|
149
|
+
validateFunction(callback, "callback");
|
|
150
|
+
const timeout = new Timeout(callback, repeat, args.length ? args : undefined, true, true);
|
|
151
|
+
arm(timeout, true);
|
|
152
|
+
return timeout;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* a Timeout, a primitive one gave, or a native timer's id (the runtime's and the prelude's) */
|
|
156
|
+
export function clearTimeout(timer) {
|
|
157
|
+
if (timer && timer._onTimeout) {
|
|
158
|
+
timer._onTimeout = null;
|
|
159
|
+
unenrollTimeout(timer);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (typeof timer === "number" || typeof timer === "string") {
|
|
163
|
+
const known = knownTimersById.get(Number(timer));
|
|
164
|
+
if (known !== undefined) {
|
|
165
|
+
known._onTimeout = null;
|
|
166
|
+
unenrollTimeout(known);
|
|
167
|
+
} else if (typeof timer === "number" && !armed.has(timer)) {
|
|
168
|
+
timerClear(timer);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function clearInterval(timer) {
|
|
174
|
+
clearTimeout(timer);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export class Immediate {
|
|
178
|
+
constructor(callback, args) {
|
|
179
|
+
this._idleNext = null;
|
|
180
|
+
this._idlePrev = null;
|
|
181
|
+
this._onImmediate = callback;
|
|
182
|
+
this._argv = args;
|
|
183
|
+
this._destroyed = false;
|
|
184
|
+
this[kRefed] = true;
|
|
185
|
+
this[kId] = timerStart(() => runImmediate(this), -1, true, 0);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
ref() {
|
|
189
|
+
if (this[kRefed] === false) {
|
|
190
|
+
this[kRefed] = true;
|
|
191
|
+
timerRef(this[kId], true);
|
|
192
|
+
}
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
unref() {
|
|
197
|
+
if (this[kRefed] === true) {
|
|
198
|
+
this[kRefed] = false;
|
|
199
|
+
timerRef(this[kId], false);
|
|
200
|
+
}
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
hasRef() {
|
|
205
|
+
return !!this[kRefed];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (typeof Symbol.dispose === "symbol") {
|
|
209
|
+
Immediate.prototype[Symbol.dispose] = function () {
|
|
210
|
+
clearImmediate(this);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function runImmediate(immediate) {
|
|
215
|
+
immediate._destroyed = true;
|
|
216
|
+
immediate[kRefed] = null;
|
|
217
|
+
const argv = immediate._argv;
|
|
218
|
+
if (argv === undefined) immediate._onImmediate();
|
|
219
|
+
else immediate._onImmediate(...argv);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function setImmediate(callback, ...args) {
|
|
223
|
+
validateFunction(callback, "callback");
|
|
224
|
+
return new Immediate(callback, args.length ? args : undefined);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function clearImmediate(immediate) {
|
|
228
|
+
if (!immediate || immediate._destroyed) return;
|
|
229
|
+
immediate._destroyed = true;
|
|
230
|
+
immediate[kRefed] = null;
|
|
231
|
+
immediate._onImmediate = null;
|
|
232
|
+
timerClear(immediate[kId]);
|
|
233
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The Node timer globals (ADR 0012): the runtime's setTimeout and friends, in every binary,
|
|
2
|
+
// return numbers. A program that may use what Node's return (a Timeout's unref(), refresh(),
|
|
3
|
+
// hasRef(), or node:timers itself, whose clearTimeout must take the globals' timers) gets this
|
|
4
|
+
// module first (implicitModules in node/index.ts), so that setTimeout === timers.setTimeout.
|
|
5
|
+
import { clearImmediate, clearInterval, clearTimeout, setImmediate, setInterval, setTimeout } from "../timers.js";
|
|
6
|
+
|
|
7
|
+
for (const [name, fn] of Object.entries({ setTimeout, clearTimeout, setInterval, clearInterval, setImmediate, clearImmediate })) {
|
|
8
|
+
Object.defineProperty(globalThis, name, { value: fn, writable: true, enumerable: true, configurable: true });
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// node:zlib's Brotli streams' host primitives, for programs whose code names Brotli
|
|
2
|
+
// (internal/zlib_engines.js).
|
|
3
|
+
import { brotliClose, brotliInit, brotliNew, brotliReset, brotliWrite } from "visaljs:host";
|
|
4
|
+
import { engines } from "./zlib_engines.js";
|
|
5
|
+
|
|
6
|
+
engines.brotli = { new: brotliNew, init: brotliInit, write: brotliWrite, reset: brotliReset, close: brotliClose };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// node:zlib's optional libraries (ADR 0012): Brotli's and zstd's host primitives are registered
|
|
2
|
+
// here by internal/zlib_brotli.js and internal/zlib_zstd.js, implicit modules a program gets when
|
|
3
|
+
// its own code names them, so a program that only gzips links neither (~800 and ~600 KB).
|
|
4
|
+
export const engines = { brotli: null, zstd: null };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// node:zlib's zstd streams' host primitives, for programs whose code names zstd
|
|
2
|
+
// (internal/zlib_engines.js).
|
|
3
|
+
import { zstdClose, zstdInit, zstdNew, zstdReset, zstdWrite } from "visaljs:host";
|
|
4
|
+
import { engines } from "./zlib_engines.js";
|
|
5
|
+
|
|
6
|
+
engines.zstd = { new: zstdNew, init: zstdInit, write: zstdWrite, reset: zstdReset, close: zstdClose };
|