@scriptc/cli-darwin-arm64 0.2.0 → 0.2.1
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/dist/THIRD_PARTY_NOTICES +1 -1
- package/dist/bin/scriptc +0 -0
- package/dist/bin/scriptc.json +1 -1
- package/dist/lib/declarations/scriptc-node-fallback.d.ts +25 -15
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/licenses/v8-number-radix.txt +61 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-arm64/package.json +1 -1
- package/dist/lib/runtime-darwin-arm64/runtime-pack.json +529 -525
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_array.c +16 -0
- package/dist/lib/runtime-sources/src/scr_assert.c +1 -0
- package/dist/lib/runtime-sources/src/scr_async.c +26 -1
- package/dist/lib/runtime-sources/src/scr_async_dyn.c +90 -16
- package/dist/lib/runtime-sources/src/scr_bigint.c +8 -0
- package/dist/lib/runtime-sources/src/scr_bytes.c +205 -41
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +581 -12
- package/dist/lib/runtime-sources/src/scr_child.c +544 -17
- package/dist/lib/runtime-sources/src/scr_console.c +1 -1
- package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +164 -31
- package/dist/lib/runtime-sources/src/scr_error.c +52 -5
- package/dist/lib/runtime-sources/src/scr_exception.c +21 -5
- package/dist/lib/runtime-sources/src/scr_fetch.c +266 -2
- package/dist/lib/runtime-sources/src/scr_http.c +3 -0
- package/dist/lib/runtime-sources/src/scr_island.c +38 -13
- package/dist/lib/runtime-sources/src/scr_json.c +1149 -91
- package/dist/lib/runtime-sources/src/scr_map.c +47 -0
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +10 -0
- package/dist/lib/runtime-sources/src/scr_object.c +11 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +108 -69
- package/dist/lib/runtime-sources/src/scr_runtime.h +190 -33
- package/dist/lib/runtime-sources/src/scr_stream.c +197 -0
- package/dist/lib/runtime-sources/src/scr_string.c +16 -1
- package/dist/lib/runtime-sources/src/scr_symbol.c +5 -0
- package/dist/lib/runtime-sources/src/scr_text_decoder_labels.h +225 -0
- package/dist/lib/runtime-sources/src/scr_url.c +172 -3
- package/dist/lib/runtime-sources/vendor/v8-number-radix/LICENSE +61 -0
- package/package.json +1 -1
|
@@ -12,6 +12,21 @@
|
|
|
12
12
|
#include <stdlib.h>
|
|
13
13
|
#include <string.h>
|
|
14
14
|
#include <time.h>
|
|
15
|
+
#include <fcntl.h>
|
|
16
|
+
#include <dirent.h>
|
|
17
|
+
#include <sys/stat.h>
|
|
18
|
+
#include <unistd.h>
|
|
19
|
+
#include <utime.h>
|
|
20
|
+
#ifndef O_SYNC
|
|
21
|
+
#define O_SYNC 0 /* Windows CRT opens have no separate synchronous flag. */
|
|
22
|
+
#endif
|
|
23
|
+
/* Bionic added glob/globfree in API 28; Android packs target API 26. */
|
|
24
|
+
#if !defined(_WIN32) && !defined(__wasi__) && (!defined(__ANDROID__) || __ANDROID_API__ >= 28)
|
|
25
|
+
#include <glob.h>
|
|
26
|
+
#define SCR_FS_HAS_GLOB 1
|
|
27
|
+
#else
|
|
28
|
+
#define SCR_FS_HAS_GLOB 0
|
|
29
|
+
#endif
|
|
15
30
|
#ifdef __APPLE__
|
|
16
31
|
#include <sys/stat.h> /* lchmod(2) — the fs.lchmodSync ladder's real tail */
|
|
17
32
|
#endif
|
|
@@ -140,6 +155,548 @@ ScrPromise *scr_fsp_read_file_bytes(ScrStr *path) {
|
|
|
140
155
|
return scr_promise_settled_ref(b, &scr_bytes_retain_v, &scr_bytes_release_v, NULL);
|
|
141
156
|
}
|
|
142
157
|
|
|
158
|
+
/* Native error-first callbacks remain callable values when a platform layer
|
|
159
|
+
* captures them. Argument failures throw at the call; filesystem failures
|
|
160
|
+
* arrive through the callback on the next event-loop turn. The synchronous
|
|
161
|
+
* filesystem spine does the work, as it does for our promise adapters. */
|
|
162
|
+
static bool scr_fs_dyn_absent(const ScrDyn *value);
|
|
163
|
+
static bool scr_fs_cb_chk(const ScrDyn *callback, const char *name);
|
|
164
|
+
static bool scr_fs_path_chk(const ScrDyn *value, const char *name);
|
|
165
|
+
static ScrDyn *scr_fs_cb_arg(ScrDyn *const *args, size_t argc, size_t index) {
|
|
166
|
+
return index < argc ? args[index] : scr_dyn_undefined();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static ScrDyn *scr_fs_cb_option(const ScrDyn *options, const char *name) {
|
|
170
|
+
if (scr_fs_dyn_absent(options)) return scr_dyn_retain(scr_dyn_undefined());
|
|
171
|
+
ScrDyn *object = options->kind == SCR_DYN_TYPED_REF ? scr_dyn_typed_ref_materialize(options) : scr_dyn_retain((ScrDyn *)options);
|
|
172
|
+
if (!object) return NULL;
|
|
173
|
+
ScrDyn *value = scr_dyn_obj_read(object, name, strlen(name));
|
|
174
|
+
scr_dyn_release(object);
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static double scr_fs_cb_number(const ScrDyn *value, const char *name, double fallback) {
|
|
179
|
+
if (scr_fs_dyn_absent(value)) return fallback;
|
|
180
|
+
if (value->kind == SCR_DYN_BIGINT) return scr_bigint_to_f64(value->v.bigint);
|
|
181
|
+
if (value->kind != SCR_DYN_NUM) {
|
|
182
|
+
scr_dyn_arg_type_fail(name, "of type number", value);
|
|
183
|
+
return fallback;
|
|
184
|
+
}
|
|
185
|
+
return value->v.num;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static double scr_fs_cb_option_number(const ScrDyn *options, const char *name, double fallback) {
|
|
189
|
+
ScrDyn *value = scr_fs_cb_option(options, name);
|
|
190
|
+
if (!value) return fallback;
|
|
191
|
+
double number = scr_fs_cb_number(value, name, fallback);
|
|
192
|
+
scr_dyn_release(value);
|
|
193
|
+
return number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static bool scr_fs_cb_option_bool(const ScrDyn *options, const char *name) {
|
|
197
|
+
ScrDyn *value = scr_fs_cb_option(options, name);
|
|
198
|
+
bool answer = value && scr_dyn_truthy(value);
|
|
199
|
+
scr_dyn_release(value);
|
|
200
|
+
return answer;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static bool scr_fs_cb_refuse_option(const ScrDyn *options, const char *name) {
|
|
204
|
+
ScrDyn *value = scr_fs_cb_option(options, name);
|
|
205
|
+
bool present = value && value->kind != SCR_DYN_UNDEF && value->kind != SCR_DYN_NULL;
|
|
206
|
+
scr_dyn_release(value);
|
|
207
|
+
if (present) {
|
|
208
|
+
char message[160];
|
|
209
|
+
int length = snprintf(message, sizeof message, "Filesystem callback option '%s' has no native lowering", name);
|
|
210
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, (size_t)length, "SC2020");
|
|
211
|
+
}
|
|
212
|
+
return present;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
static bool scr_fs_cb_signal(const ScrDyn *options) {
|
|
216
|
+
ScrDyn *signal = scr_fs_cb_option(options, "signal");
|
|
217
|
+
if (!signal) return false;
|
|
218
|
+
if (scr_fs_dyn_absent(signal)) { scr_dyn_release(signal); return true; }
|
|
219
|
+
if (signal->kind != SCR_DYN_HANDLE || signal->v.handle.tag != SCR_DYNH_ABORT_SIGNAL) {
|
|
220
|
+
scr_dyn_arg_type_fail("options.signal", "an instance of AbortSignal", signal);
|
|
221
|
+
scr_dyn_release(signal);
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
ScrStr *key = scr_str_new("aborted", 7);
|
|
225
|
+
ScrDyn *aborted = scr_dyn_handle_key_get(signal, key);
|
|
226
|
+
scr_str_release(key);
|
|
227
|
+
bool cancelled = aborted && scr_dyn_truthy(aborted);
|
|
228
|
+
scr_dyn_release(aborted); scr_dyn_release(signal);
|
|
229
|
+
if (cancelled) {
|
|
230
|
+
static const char message[] = "The operation was aborted";
|
|
231
|
+
ScrStr *text = scr_str_new(message, sizeof message - 1);
|
|
232
|
+
ScrError *error = scr_error_new(SCR_ERR_ERROR, text);
|
|
233
|
+
scr_str_release(text);
|
|
234
|
+
scr_str_release(error->name);
|
|
235
|
+
error->name = scr_str_new("AbortError", 10);
|
|
236
|
+
error->name_present = true;
|
|
237
|
+
scr_error_set_code(error, "ABORT_ERR");
|
|
238
|
+
scr_throw_obj(error, scr_error_retain_v, scr_error_release_v, scr_error_trace_arg());
|
|
239
|
+
}
|
|
240
|
+
return !scr_exc_pending();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
static double scr_fs_cb_open(const ScrStr *path, const ScrDyn *flag, double mode, const char *fallback) {
|
|
244
|
+
const char *f = flag->kind == SCR_DYN_UNDEF ? fallback : flag->kind == SCR_DYN_STR ? flag->v.str->data : NULL;
|
|
245
|
+
if (!f) {
|
|
246
|
+
static const char message[] = "Runtime numeric filesystem flags have no portable native lowering";
|
|
247
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, sizeof message - 1, "SC2020");
|
|
248
|
+
return -1;
|
|
249
|
+
}
|
|
250
|
+
int bits;
|
|
251
|
+
if (!strcmp(f, "r")) bits = O_RDONLY;
|
|
252
|
+
else if (!strcmp(f, "r+")) bits = O_RDWR;
|
|
253
|
+
else if (!strcmp(f, "rs") || !strcmp(f, "sr")) bits = O_RDONLY | O_SYNC;
|
|
254
|
+
else if (!strcmp(f, "rs+") || !strcmp(f, "sr+")) bits = O_RDWR | O_SYNC;
|
|
255
|
+
else if (!strcmp(f, "w")) bits = O_WRONLY | O_CREAT | O_TRUNC;
|
|
256
|
+
else if (!strcmp(f, "w+")) bits = O_RDWR | O_CREAT | O_TRUNC;
|
|
257
|
+
else if (!strcmp(f, "wx") || !strcmp(f, "xw")) bits = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL;
|
|
258
|
+
else if (!strcmp(f, "wx+") || !strcmp(f, "xw+")) bits = O_RDWR | O_CREAT | O_TRUNC | O_EXCL;
|
|
259
|
+
else if (!strcmp(f, "a")) bits = O_WRONLY | O_CREAT | O_APPEND;
|
|
260
|
+
else if (!strcmp(f, "a+")) bits = O_RDWR | O_CREAT | O_APPEND;
|
|
261
|
+
else if (!strcmp(f, "ax") || !strcmp(f, "xa")) bits = O_WRONLY | O_CREAT | O_APPEND | O_EXCL;
|
|
262
|
+
else if (!strcmp(f, "ax+") || !strcmp(f, "xa+")) bits = O_RDWR | O_CREAT | O_APPEND | O_EXCL;
|
|
263
|
+
else if (!strcmp(f, "as") || !strcmp(f, "sa")) bits = O_WRONLY | O_CREAT | O_APPEND | O_SYNC;
|
|
264
|
+
else if (!strcmp(f, "as+") || !strcmp(f, "sa+")) bits = O_RDWR | O_CREAT | O_APPEND | O_SYNC;
|
|
265
|
+
else {
|
|
266
|
+
char message[160];
|
|
267
|
+
int length = snprintf(message, sizeof message, "The argument 'flags' is invalid. Received '%s'", f);
|
|
268
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, message, (size_t)length, "ERR_INVALID_ARG_VALUE");
|
|
269
|
+
return -1;
|
|
270
|
+
}
|
|
271
|
+
if (scr_exc_pending()) return -1;
|
|
272
|
+
int fd = open(path->data, bits, (mode_t)mode);
|
|
273
|
+
if (fd < 0) scr_fs_throw(errno, "open", path);
|
|
274
|
+
return fd;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
static ScrStr *scr_fs_cb_path(const ScrDyn *value, const char *name) {
|
|
278
|
+
if (!scr_fs_path_chk(value, name)) return NULL;
|
|
279
|
+
ScrStr *path = value->kind == SCR_DYN_STR ? scr_str_retain(value->v.str)
|
|
280
|
+
: scr_str_new((const char *)value->v.bytes->data, value->v.bytes->len);
|
|
281
|
+
if (memchr(path->data, 0, path->len)) {
|
|
282
|
+
scr_dyn_arg_value_fail(name, "must be a string, Uint8Array, or URL without null bytes", value);
|
|
283
|
+
scr_str_release(path);
|
|
284
|
+
return NULL;
|
|
285
|
+
}
|
|
286
|
+
return path;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
static ScrDyn *scr_fs_cb_string(ScrStr *text) {
|
|
290
|
+
if (!text) return NULL;
|
|
291
|
+
ScrDyn *value = scr_dyn_new_str(text);
|
|
292
|
+
scr_str_release(text);
|
|
293
|
+
return value;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
static ScrStr *scr_fs_cb_join(const ScrStr *directory, const char *name) {
|
|
297
|
+
ScrStr *suffix = scr_str_new("/", 1);
|
|
298
|
+
ScrStr *base = scr_str_concat((ScrStr *)directory, suffix);
|
|
299
|
+
scr_str_release(suffix);
|
|
300
|
+
suffix = scr_str_new(name, strlen(name));
|
|
301
|
+
ScrStr *path = scr_str_concat(base, suffix);
|
|
302
|
+
scr_str_release(base); scr_str_release(suffix);
|
|
303
|
+
return path;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
static void scr_fs_cb_copy(const ScrStr *source, const ScrStr *destination, bool recursive, bool force, bool preserve) {
|
|
307
|
+
struct stat status;
|
|
308
|
+
if (
|
|
309
|
+
#ifdef _WIN32
|
|
310
|
+
stat(source->data, &status)
|
|
311
|
+
#else
|
|
312
|
+
lstat(source->data, &status)
|
|
313
|
+
#endif
|
|
314
|
+
< 0) { scr_fs_throw(errno, "stat", source); return; }
|
|
315
|
+
#ifndef _WIN32
|
|
316
|
+
if (S_ISLNK(status.st_mode)) {
|
|
317
|
+
const char *message = "Symbolic-link cp entries have no native lowering";
|
|
318
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, strlen(message), "SC2020");
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
#endif
|
|
322
|
+
if (S_ISDIR(status.st_mode)) {
|
|
323
|
+
if (!recursive) { scr_fs_throw(EISDIR, "cp", source); return; }
|
|
324
|
+
scr_fs_mkdir_recursive_mode((ScrStr *)destination, status.st_mode & 0777);
|
|
325
|
+
if (scr_exc_pending()) return;
|
|
326
|
+
DIR *directory = opendir(source->data);
|
|
327
|
+
if (!directory) { scr_fs_throw(errno, "opendir", source); return; }
|
|
328
|
+
struct dirent *entry;
|
|
329
|
+
while (!scr_exc_pending() && (entry = readdir(directory))) {
|
|
330
|
+
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) continue;
|
|
331
|
+
ScrStr *from = scr_fs_cb_join(source, entry->d_name), *to = scr_fs_cb_join(destination, entry->d_name);
|
|
332
|
+
scr_fs_cb_copy(from, to, true, force, preserve);
|
|
333
|
+
scr_str_release(from); scr_str_release(to);
|
|
334
|
+
}
|
|
335
|
+
closedir(directory);
|
|
336
|
+
} else {
|
|
337
|
+
if (!force && scr_fs_exists((ScrStr *)destination)) return;
|
|
338
|
+
scr_fs_copyfile((ScrStr *)source, (ScrStr *)destination);
|
|
339
|
+
}
|
|
340
|
+
if (preserve && !scr_exc_pending()) {
|
|
341
|
+
struct utimbuf times = { status.st_atime, status.st_mtime };
|
|
342
|
+
if (utime(destination->data, ×) < 0) scr_fs_throw(errno, "utime", destination);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
static ScrDyn *scr_fs_cb_stat_test(ScrClosure *closure, ScrDyn *const *args, size_t argc) {
|
|
347
|
+
(void)args; (void)argc;
|
|
348
|
+
return scr_dyn_new_bool(scr_box_get_bool(closure->caps[0]));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
static void scr_fs_cb_stat_method(ScrDyn *object, const char *name, bool answer) {
|
|
352
|
+
ScrClosure *closure = scr_closure_new(NULL, 1);
|
|
353
|
+
closure->caps[0] = scr_box_new(SCR_BOX_BOOL);
|
|
354
|
+
scr_box_set_bool(closure->caps[0], answer);
|
|
355
|
+
scr_dyn_obj_set(object, name, strlen(name), scr_dyn_new_func(closure, scr_fs_cb_stat_test, 0, "native:fs.Stats", name));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
static void scr_fs_cb_stat_number(ScrDyn *object, const char *name, int64_t number, bool bigint) {
|
|
359
|
+
ScrDyn *value;
|
|
360
|
+
if (bigint) {
|
|
361
|
+
ScrBigInt *integer = scr_bigint_from_i64(number);
|
|
362
|
+
value = scr_dyn_new_bigint(integer);
|
|
363
|
+
scr_bigint_release(integer);
|
|
364
|
+
} else value = scr_dyn_new_num((double)number);
|
|
365
|
+
scr_dyn_obj_set(object, name, strlen(name), value);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
static void scr_fs_cb_stat_date(ScrDyn *object, const char *name, double milliseconds) {
|
|
369
|
+
ScrDyn *arguments = scr_dyn_new_arr();
|
|
370
|
+
scr_dyn_arr_push(arguments, scr_dyn_new_num(milliseconds));
|
|
371
|
+
ScrDyn *date = scr_dyn_native_date_new(arguments);
|
|
372
|
+
scr_dyn_release(arguments);
|
|
373
|
+
if (date) scr_dyn_obj_set(object, name, strlen(name), date);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
static ScrDyn *scr_fs_cb_stats(const ScrStr *path, double fd, const ScrDyn *options, bool nofollow) {
|
|
377
|
+
struct stat status;
|
|
378
|
+
#ifdef _WIN32
|
|
379
|
+
(void)nofollow;
|
|
380
|
+
int rc = path ? stat(path->data, &status) : fstat((int)fd, &status);
|
|
381
|
+
#else
|
|
382
|
+
int rc = path ? (nofollow ? lstat(path->data, &status) : stat(path->data, &status)) : fstat((int)fd, &status);
|
|
383
|
+
#endif
|
|
384
|
+
if (rc < 0) { scr_fs_throw(errno, path ? (nofollow ? "lstat" : "stat") : "fstat", path); return NULL; }
|
|
385
|
+
bool bigint = scr_fs_cb_option_bool(options, "bigint");
|
|
386
|
+
ScrDyn *object = scr_dyn_new_obj();
|
|
387
|
+
#define SCR_FS_STAT_FIELD(field) scr_fs_cb_stat_number(object, #field, (int64_t)status.st_##field, bigint)
|
|
388
|
+
SCR_FS_STAT_FIELD(dev); SCR_FS_STAT_FIELD(ino); SCR_FS_STAT_FIELD(mode); SCR_FS_STAT_FIELD(nlink);
|
|
389
|
+
SCR_FS_STAT_FIELD(uid); SCR_FS_STAT_FIELD(gid); SCR_FS_STAT_FIELD(rdev); SCR_FS_STAT_FIELD(size);
|
|
390
|
+
#ifndef _WIN32
|
|
391
|
+
SCR_FS_STAT_FIELD(blksize); SCR_FS_STAT_FIELD(blocks);
|
|
392
|
+
#endif
|
|
393
|
+
#undef SCR_FS_STAT_FIELD
|
|
394
|
+
double atime = (double)status.st_atime * 1000, mtime = (double)status.st_mtime * 1000, ctime = (double)status.st_ctime * 1000;
|
|
395
|
+
double birthtime = 0;
|
|
396
|
+
#ifdef __APPLE__
|
|
397
|
+
atime += status.st_atimespec.tv_nsec / 1000000.0; mtime += status.st_mtimespec.tv_nsec / 1000000.0;
|
|
398
|
+
ctime += status.st_ctimespec.tv_nsec / 1000000.0;
|
|
399
|
+
birthtime = (double)status.st_birthtimespec.tv_sec * 1000 + status.st_birthtimespec.tv_nsec / 1000000.0;
|
|
400
|
+
#elif !defined(_WIN32) && !defined(__wasi__)
|
|
401
|
+
atime += status.st_atim.tv_nsec / 1000000.0; mtime += status.st_mtim.tv_nsec / 1000000.0;
|
|
402
|
+
ctime += status.st_ctim.tv_nsec / 1000000.0;
|
|
403
|
+
#endif
|
|
404
|
+
scr_fs_cb_stat_date(object, "atime", atime); scr_fs_cb_stat_date(object, "mtime", mtime);
|
|
405
|
+
scr_fs_cb_stat_date(object, "ctime", ctime); scr_fs_cb_stat_date(object, "birthtime", birthtime);
|
|
406
|
+
if (bigint) {
|
|
407
|
+
scr_fs_cb_stat_number(object, "atimeMs", (int64_t)atime, true);
|
|
408
|
+
scr_fs_cb_stat_number(object, "mtimeMs", (int64_t)mtime, true);
|
|
409
|
+
scr_fs_cb_stat_number(object, "ctimeMs", (int64_t)ctime, true);
|
|
410
|
+
scr_fs_cb_stat_number(object, "birthtimeMs", (int64_t)birthtime, true);
|
|
411
|
+
} else {
|
|
412
|
+
scr_dyn_obj_set(object, "atimeMs", 7, scr_dyn_new_num(atime));
|
|
413
|
+
scr_dyn_obj_set(object, "mtimeMs", 7, scr_dyn_new_num(mtime));
|
|
414
|
+
scr_dyn_obj_set(object, "ctimeMs", 7, scr_dyn_new_num(ctime));
|
|
415
|
+
scr_dyn_obj_set(object, "birthtimeMs", 11, scr_dyn_new_num(birthtime));
|
|
416
|
+
}
|
|
417
|
+
scr_fs_cb_stat_method(object, "isFile", S_ISREG(status.st_mode));
|
|
418
|
+
scr_fs_cb_stat_method(object, "isDirectory", S_ISDIR(status.st_mode));
|
|
419
|
+
#ifndef _WIN32
|
|
420
|
+
scr_fs_cb_stat_method(object, "isSymbolicLink", S_ISLNK(status.st_mode));
|
|
421
|
+
scr_fs_cb_stat_method(object, "isBlockDevice", S_ISBLK(status.st_mode));
|
|
422
|
+
scr_fs_cb_stat_method(object, "isCharacterDevice", S_ISCHR(status.st_mode));
|
|
423
|
+
scr_fs_cb_stat_method(object, "isFIFO", S_ISFIFO(status.st_mode));
|
|
424
|
+
scr_fs_cb_stat_method(object, "isSocket", S_ISSOCK(status.st_mode));
|
|
425
|
+
#else
|
|
426
|
+
scr_fs_cb_stat_method(object, "isSymbolicLink", false);
|
|
427
|
+
scr_fs_cb_stat_method(object, "isBlockDevice", false);
|
|
428
|
+
scr_fs_cb_stat_method(object, "isCharacterDevice", S_ISCHR(status.st_mode));
|
|
429
|
+
scr_fs_cb_stat_method(object, "isFIFO", false); scr_fs_cb_stat_method(object, "isSocket", false);
|
|
430
|
+
#endif
|
|
431
|
+
return object;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
#ifndef SCR_LIB
|
|
435
|
+
static void scr_fs_cb_fire(ScrClosure *closure) {
|
|
436
|
+
ScrDyn *callback = scr_box_get_ref(closure->caps[0]);
|
|
437
|
+
ScrDyn *arguments = scr_box_get_ref(closure->caps[1]);
|
|
438
|
+
ScrDyn *result = scr_dyn_apply(callback, arguments, "the filesystem callback");
|
|
439
|
+
scr_dyn_release(result); scr_dyn_release(callback); scr_dyn_release(arguments);
|
|
440
|
+
}
|
|
441
|
+
#endif
|
|
442
|
+
|
|
443
|
+
static void scr_fs_cb_schedule(const ScrDyn *callback, ScrDyn *result, const ScrDyn *buffer) {
|
|
444
|
+
ScrDyn *arguments = scr_dyn_new_arr();
|
|
445
|
+
if (scr_exc_pending()) {
|
|
446
|
+
ScrCaught *caught = scr_exc_take();
|
|
447
|
+
ScrDyn *error = scr_caught_to_dyn(caught);
|
|
448
|
+
scr_caught_release(caught);
|
|
449
|
+
scr_dyn_arr_push(arguments, error);
|
|
450
|
+
scr_dyn_release(result);
|
|
451
|
+
} else {
|
|
452
|
+
scr_dyn_arr_push(arguments, scr_dyn_new_null());
|
|
453
|
+
if (result) scr_dyn_arr_push(arguments, result);
|
|
454
|
+
if (buffer) scr_dyn_arr_push(arguments, scr_dyn_retain((ScrDyn *)buffer));
|
|
455
|
+
}
|
|
456
|
+
#ifndef SCR_LIB
|
|
457
|
+
ScrClosure *closure = scr_closure_new((void *)scr_fs_cb_fire, 2);
|
|
458
|
+
closure->caps[0] = scr_box_new_obj(scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v);
|
|
459
|
+
closure->caps[1] = scr_box_new_obj(scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v);
|
|
460
|
+
scr_box_set_ref(closure->caps[0], scr_dyn_retain((ScrDyn *)callback));
|
|
461
|
+
scr_box_set_ref(closure->caps[1], arguments);
|
|
462
|
+
scr_set_timeout(closure, 0);
|
|
463
|
+
#else
|
|
464
|
+
(void)callback;
|
|
465
|
+
scr_dyn_release(arguments);
|
|
466
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, "Filesystem callbacks require an executable event loop", 52, "SC4005");
|
|
467
|
+
#endif
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
static bool scr_fs_read_validate(const ScrDyn *, const ScrDyn *, const ScrDyn *, const ScrDyn *, const ScrDyn *);
|
|
471
|
+
static bool scr_fs_encoding_chk(const ScrDyn *);
|
|
472
|
+
|
|
473
|
+
static ScrDyn *scr_fs_cb_invoke(ScrStr *member, ScrDyn *const *args, size_t argc) {
|
|
474
|
+
const char *op = member->data;
|
|
475
|
+
bool fileCallback = !strcmp(op, "readFile") || !strcmp(op, "mkdtemp");
|
|
476
|
+
const ScrDyn *callback = argc >= (fileCallback ? 2u : 1u) ? args[argc - 1] : scr_dyn_undefined();
|
|
477
|
+
if (!scr_fs_cb_chk(callback, fileCallback ? "cb" : "callback")) return NULL;
|
|
478
|
+
size_t count = argc - 1;
|
|
479
|
+
#define ARG(index) scr_fs_cb_arg(args, count, index)
|
|
480
|
+
if (!strcmp(op, "readFile") && !scr_fs_encoding_chk(ARG(1))) return NULL;
|
|
481
|
+
if (!strcmp(op, "read") && count >= 4 && !scr_fs_read_validate(ARG(0), ARG(1), ARG(2), ARG(3), ARG(4))) return NULL;
|
|
482
|
+
bool descriptor = !strcmp(op, "close") || !strcmp(op, "fstat") || !strcmp(op, "ftruncate") || !strcmp(op, "fsync") || !strcmp(op, "read") || !strcmp(op, "write");
|
|
483
|
+
ScrStr *path = descriptor ? NULL : scr_fs_cb_path(ARG(0), !strcmp(op, "mkdtemp") ? "prefix" : "path");
|
|
484
|
+
if (!descriptor && !path) return NULL;
|
|
485
|
+
double fd = descriptor ? scr_fs_cb_number(ARG(0), "fd", -1) : -1;
|
|
486
|
+
if (scr_exc_pending()) { scr_str_release(path); return NULL; }
|
|
487
|
+
ScrDyn *result = NULL;
|
|
488
|
+
const ScrDyn *buffer = NULL;
|
|
489
|
+
if (!strcmp(op, "readFile")) {
|
|
490
|
+
const ScrDyn *options = ARG(1);
|
|
491
|
+
if (options->kind != SCR_DYN_STR && (!scr_fs_cb_signal(options) || scr_fs_cb_refuse_option(options, "flag"))) goto done;
|
|
492
|
+
ScrDyn *encoding = options->kind == SCR_DYN_STR ? scr_dyn_retain((ScrDyn *)options) : scr_fs_cb_option(options, "encoding");
|
|
493
|
+
if (encoding) result = scr_fs_read_file_sync_dyn(path, encoding);
|
|
494
|
+
scr_dyn_release(encoding);
|
|
495
|
+
} else if (!strcmp(op, "writeFile") || !strcmp(op, "appendFile")) {
|
|
496
|
+
const ScrDyn *options = ARG(2);
|
|
497
|
+
if (options->kind != SCR_DYN_STR && !scr_fs_cb_signal(options)) goto done;
|
|
498
|
+
ScrDyn *encoding = options->kind == SCR_DYN_STR ? scr_dyn_retain((ScrDyn *)options) : scr_fs_cb_option(options, "encoding");
|
|
499
|
+
ScrStr *codec = encoding && encoding->kind == SCR_DYN_STR ? scr_str_retain(encoding->v.str) : scr_str_new("utf8", 4);
|
|
500
|
+
ScrBytes *data = encoding ? scr_buffer_from_dyn(ARG(1), codec) : NULL;
|
|
501
|
+
scr_str_release(codec);
|
|
502
|
+
scr_dyn_release(encoding);
|
|
503
|
+
if (data) {
|
|
504
|
+
ScrDyn *flag = scr_fs_cb_option(options->kind == SCR_DYN_STR ? scr_dyn_undefined() : options, "flag");
|
|
505
|
+
double mode = scr_fs_cb_option_number(options->kind == SCR_DYN_STR ? scr_dyn_undefined() : options, "mode", 0666);
|
|
506
|
+
double fd = flag ? scr_fs_cb_open(path, flag, mode, !strcmp(op, "appendFile") ? "a" : "w") : -1;
|
|
507
|
+
scr_dyn_release(flag);
|
|
508
|
+
if (fd >= 0) {
|
|
509
|
+
size_t offset = 0;
|
|
510
|
+
while (offset < data->len && !scr_exc_pending()) {
|
|
511
|
+
double written = scr_fs_write_sync(fd, data, (double)offset, (double)(data->len - offset), -1);
|
|
512
|
+
if (written <= 0) break;
|
|
513
|
+
offset += (size_t)written;
|
|
514
|
+
}
|
|
515
|
+
int saved = errno;
|
|
516
|
+
close((int)fd);
|
|
517
|
+
errno = saved;
|
|
518
|
+
}
|
|
519
|
+
scr_bytes_release(data);
|
|
520
|
+
}
|
|
521
|
+
} else if (!strcmp(op, "access")) scr_fs_access(path, scr_fs_cb_number(ARG(1), "mode", 0));
|
|
522
|
+
else if (!strcmp(op, "mkdir")) {
|
|
523
|
+
const ScrDyn *options = ARG(1);
|
|
524
|
+
double mode = options->kind == SCR_DYN_NUM ? options->v.num : scr_fs_cb_option_number(options, "mode", 0777);
|
|
525
|
+
if (scr_fs_cb_option_bool(options->kind == SCR_DYN_NUM ? scr_dyn_undefined() : options, "recursive")) scr_fs_mkdir_recursive_mode(path, mode);
|
|
526
|
+
else scr_fs_mkdir_mode(path, mode);
|
|
527
|
+
} else if (!strcmp(op, "mkdtemp")) result = scr_fs_cb_string(scr_fs_mkdtemp(path));
|
|
528
|
+
else if (!strcmp(op, "rm")) scr_fs_rm_opts_retry(path, scr_fs_cb_option_bool(ARG(1), "recursive"), scr_fs_cb_option_bool(ARG(1), "force"), scr_fs_cb_option_number(ARG(1), "maxRetries", 0), scr_fs_cb_option_number(ARG(1), "retryDelay", 100));
|
|
529
|
+
else if (!strcmp(op, "rmdir")) scr_fs_rmdir(path);
|
|
530
|
+
else if (!strcmp(op, "unlink")) scr_fs_unlink(path);
|
|
531
|
+
else if (!strcmp(op, "chmod")) scr_fs_chmod(path, scr_fs_cb_number(ARG(1), "mode", 0));
|
|
532
|
+
else if (!strcmp(op, "chown")) scr_fs_chown(path, scr_fs_cb_number(ARG(1), "uid", 0), scr_fs_cb_number(ARG(2), "gid", 0));
|
|
533
|
+
else if (!strcmp(op, "realpath")) result = scr_fs_cb_string(scr_fs_realpath(path));
|
|
534
|
+
else if (!strcmp(op, "stat") || !strcmp(op, "lstat")) result = scr_fs_cb_stats(path, -1, ARG(1), !strcmp(op, "lstat"));
|
|
535
|
+
else if (!strcmp(op, "fstat")) result = scr_fs_cb_stats(NULL, fd, ARG(1), false);
|
|
536
|
+
else if (!strcmp(op, "close")) scr_fs_close(fd);
|
|
537
|
+
else if (!strcmp(op, "fsync")) scr_fs_fsync(fd);
|
|
538
|
+
else if (!strcmp(op, "open")) {
|
|
539
|
+
double opened = scr_fs_cb_open(path, ARG(1), scr_fs_cb_number(ARG(2), "mode", 0666), "r");
|
|
540
|
+
if (!scr_exc_pending()) result = scr_dyn_new_num(opened);
|
|
541
|
+
} else if (!strcmp(op, "cp")) {
|
|
542
|
+
if (scr_fs_cb_refuse_option(ARG(2), "filter") || scr_fs_cb_refuse_option(ARG(2), "dereference") || scr_fs_cb_refuse_option(ARG(2), "verbatimSymlinks") || scr_fs_cb_refuse_option(ARG(2), "errorOnExist") || scr_fs_cb_refuse_option(ARG(2), "mode")) goto done;
|
|
543
|
+
ScrStr *destination = scr_fs_cb_path(ARG(1), "dest");
|
|
544
|
+
if (destination) {
|
|
545
|
+
ScrDyn *force = scr_fs_cb_option(ARG(2), "force");
|
|
546
|
+
scr_fs_cb_copy(path, destination, scr_fs_cb_option_bool(ARG(2), "recursive"),
|
|
547
|
+
force && (force->kind == SCR_DYN_UNDEF || scr_dyn_truthy(force)), scr_fs_cb_option_bool(ARG(2), "preserveTimestamps"));
|
|
548
|
+
scr_dyn_release(force); scr_str_release(destination);
|
|
549
|
+
}
|
|
550
|
+
} else if (!strcmp(op, "glob")) {
|
|
551
|
+
#if SCR_FS_HAS_GLOB
|
|
552
|
+
if (strstr(path->data, "**") || scr_fs_cb_option_bool(ARG(1), "withFileTypes")) {
|
|
553
|
+
const char *message = "Recursive glob patterns and Dirent results have no native lowering";
|
|
554
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, strlen(message), "SC2020");
|
|
555
|
+
goto done;
|
|
556
|
+
}
|
|
557
|
+
ScrDyn *cwd = scr_fs_cb_option(ARG(1), "cwd");
|
|
558
|
+
ScrDyn *exclude = scr_fs_cb_option(ARG(1), "exclude");
|
|
559
|
+
if (exclude && exclude->kind != SCR_DYN_UNDEF) {
|
|
560
|
+
const char *message = "fs.glob exclude options have no native lowering";
|
|
561
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, strlen(message), "SC2020");
|
|
562
|
+
} else {
|
|
563
|
+
ScrStr *pattern = cwd && cwd->kind == SCR_DYN_STR ? scr_fs_cb_join(cwd->v.str, path->data) : scr_str_retain(path);
|
|
564
|
+
glob_t matches = {0};
|
|
565
|
+
int rc = glob(pattern->data, 0, NULL, &matches);
|
|
566
|
+
if (rc && rc != GLOB_NOMATCH) scr_fs_throw(rc == GLOB_NOSPACE ? ENOMEM : EIO, "glob", path);
|
|
567
|
+
else {
|
|
568
|
+
result = scr_dyn_new_arr();
|
|
569
|
+
size_t prefix = cwd && cwd->kind == SCR_DYN_STR ? cwd->v.str->len + 1 : 0;
|
|
570
|
+
for (size_t i = 0; i < matches.gl_pathc; i++) {
|
|
571
|
+
const char *name = matches.gl_pathv[i] + prefix;
|
|
572
|
+
scr_dyn_arr_push(result, scr_fs_cb_string(scr_str_new(name, strlen(name))));
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
globfree(&matches); scr_str_release(pattern);
|
|
576
|
+
}
|
|
577
|
+
scr_dyn_release(cwd); scr_dyn_release(exclude);
|
|
578
|
+
#else
|
|
579
|
+
scr_fs_throw(ENOSYS, "glob", path);
|
|
580
|
+
#endif
|
|
581
|
+
} else if (!strcmp(op, "read") || !strcmp(op, "write")) {
|
|
582
|
+
bool readOp = !strcmp(op, "read");
|
|
583
|
+
const ScrDyn *options = ARG(1);
|
|
584
|
+
ScrDyn *ownedBuffer = NULL;
|
|
585
|
+
if (readOp && !scr_dyn_bytes_is(options, SCR_BYTES_U8)) { ownedBuffer = scr_fs_cb_option(options, "buffer"); buffer = ownedBuffer; }
|
|
586
|
+
else buffer = options;
|
|
587
|
+
ScrBytes *bytes = buffer && buffer->kind == SCR_DYN_BYTES ? scr_dyn_bytes_unbox(buffer) : NULL;
|
|
588
|
+
if (!bytes) scr_dyn_arg_type_fail("buffer", "an instance of Buffer, TypedArray, or DataView", buffer ? buffer : scr_dyn_undefined());
|
|
589
|
+
else {
|
|
590
|
+
double offset = ownedBuffer ? scr_fs_cb_option_number(options, "offset", 0) : scr_fs_cb_number(ARG(2), "offset", 0);
|
|
591
|
+
double length = ownedBuffer ? scr_fs_cb_option_number(options, "length", bytes->len - offset) : scr_fs_cb_number(ARG(3), "length", bytes->len - offset);
|
|
592
|
+
double position = ownedBuffer ? scr_fs_cb_option_number(options, "position", -1) : scr_fs_cb_number(ARG(4), "position", -1);
|
|
593
|
+
if (!scr_exc_pending()) result = scr_dyn_new_num(readOp ? scr_fs_read_sync(fd, bytes, offset, length, position) : scr_fs_write_sync(fd, bytes, offset, length, position));
|
|
594
|
+
}
|
|
595
|
+
scr_bytes_release(bytes);
|
|
596
|
+
/* The completion retains the original buffer, including options.buffer. */
|
|
597
|
+
if (ownedBuffer) {
|
|
598
|
+
scr_fs_cb_schedule(callback, result, ownedBuffer);
|
|
599
|
+
scr_dyn_release(ownedBuffer); scr_str_release(path);
|
|
600
|
+
return scr_dyn_retain(scr_dyn_undefined());
|
|
601
|
+
}
|
|
602
|
+
} else if (!strcmp(op, "copyFile") || !strcmp(op, "rename") || !strcmp(op, "link") || !strcmp(op, "symlink")) {
|
|
603
|
+
ScrStr *destination = scr_fs_cb_path(ARG(1), "dest");
|
|
604
|
+
if (destination) {
|
|
605
|
+
if (!strcmp(op, "rename")) scr_fs_rename(path, destination);
|
|
606
|
+
else if (!strcmp(op, "link")) scr_fs_link(path, destination);
|
|
607
|
+
else if (!strcmp(op, "copyFile")) {
|
|
608
|
+
double flags = scr_fs_cb_number(ARG(2), "mode", 0);
|
|
609
|
+
if (flags == 1 && scr_fs_exists(destination)) scr_fs_throw(EEXIST, "copyfile", destination);
|
|
610
|
+
else if (flags != 0 && flags != 1) {
|
|
611
|
+
static const char message[] = "fs.copyFile clone flags have no native lowering";
|
|
612
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, sizeof message - 1, "SC2020");
|
|
613
|
+
} else if (!scr_exc_pending()) scr_fs_copyfile(path, destination);
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
#if !defined(_WIN32)
|
|
617
|
+
if (symlink(path->data, destination->data) < 0) scr_fs_throw(errno, "symlink", path);
|
|
618
|
+
#else
|
|
619
|
+
scr_fs_throw(ENOSYS, "symlink", path);
|
|
620
|
+
#endif
|
|
621
|
+
}
|
|
622
|
+
scr_str_release(destination);
|
|
623
|
+
}
|
|
624
|
+
} else if (!strcmp(op, "truncate") || !strcmp(op, "ftruncate")) {
|
|
625
|
+
double length = scr_fs_cb_number(ARG(1), "len", 0);
|
|
626
|
+
if (!scr_exc_pending()) {
|
|
627
|
+
int rc = descriptor ? ftruncate((int)fd, (off_t)length) : truncate(path->data, (off_t)length);
|
|
628
|
+
if (rc < 0) scr_fs_throw(errno, descriptor ? "ftruncate" : "truncate", path);
|
|
629
|
+
}
|
|
630
|
+
} else if (!strcmp(op, "readlink")) {
|
|
631
|
+
#ifndef _WIN32
|
|
632
|
+
size_t capacity = 256;
|
|
633
|
+
char *text = NULL;
|
|
634
|
+
for (;;) {
|
|
635
|
+
char *grown = realloc(text, capacity);
|
|
636
|
+
if (!grown) scr_bytes_io_oom();
|
|
637
|
+
text = grown;
|
|
638
|
+
ssize_t size = readlink(path->data, text, capacity);
|
|
639
|
+
if (size < 0) { scr_fs_throw(errno, "readlink", path); break; }
|
|
640
|
+
if ((size_t)size < capacity) { result = scr_fs_cb_string(scr_str_new(text, (size_t)size)); break; }
|
|
641
|
+
capacity *= 2;
|
|
642
|
+
}
|
|
643
|
+
free(text);
|
|
644
|
+
#else
|
|
645
|
+
scr_fs_throw(ENOSYS, "readlink", path);
|
|
646
|
+
#endif
|
|
647
|
+
} else if (!strcmp(op, "utimes")) {
|
|
648
|
+
double access = scr_fs_to_unix_timestamp(ARG(1)), modified = scr_fs_to_unix_timestamp(ARG(2));
|
|
649
|
+
#if !defined(_WIN32)
|
|
650
|
+
struct timespec times[2] = {
|
|
651
|
+
{ (time_t)floor(access), (long)((access - floor(access)) * 1000000000) },
|
|
652
|
+
{ (time_t)floor(modified), (long)((modified - floor(modified)) * 1000000000) },
|
|
653
|
+
};
|
|
654
|
+
if (!scr_exc_pending() && utimensat(AT_FDCWD, path->data, times, 0) < 0) scr_fs_throw(errno, "utime", path);
|
|
655
|
+
#else
|
|
656
|
+
struct utimbuf times = { (time_t)access, (time_t)modified };
|
|
657
|
+
if (!scr_exc_pending() && utime(path->data, ×) < 0) scr_fs_throw(errno, "utime", path);
|
|
658
|
+
#endif
|
|
659
|
+
} else if (!strcmp(op, "readdir")) {
|
|
660
|
+
if (scr_fs_cb_refuse_option(ARG(1), "encoding") || scr_fs_cb_option_bool(ARG(1), "withFileTypes") || scr_fs_cb_option_bool(ARG(1), "recursive")) {
|
|
661
|
+
if (!scr_exc_pending()) { const char *message = "Recursive readdir and Dirent results have no native lowering"; scr_throw_error_msg_code(SCR_ERR_ERROR, message, strlen(message), "SC2020"); }
|
|
662
|
+
goto done;
|
|
663
|
+
}
|
|
664
|
+
ScrArr *names = scr_fs_readdir(path);
|
|
665
|
+
if (names) {
|
|
666
|
+
result = scr_dyn_new_arr();
|
|
667
|
+
for (size_t i = 0; i < (size_t)scr_arr_len(names); i++) scr_dyn_arr_push(result, scr_fs_cb_string(scr_arr_get_ref(names, (double)i)));
|
|
668
|
+
scr_arr_release(names);
|
|
669
|
+
}
|
|
670
|
+
} else {
|
|
671
|
+
char message[160];
|
|
672
|
+
int length = snprintf(message, sizeof message, "Native filesystem callback fs.%s with these options has no lowering", op);
|
|
673
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, (size_t)length, "SC2020");
|
|
674
|
+
}
|
|
675
|
+
#undef ARG
|
|
676
|
+
done:
|
|
677
|
+
scr_str_release(path);
|
|
678
|
+
scr_fs_cb_schedule(callback, result, buffer);
|
|
679
|
+
return scr_dyn_retain(scr_dyn_undefined());
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
static ScrDyn *scr_fs_cb_value_call(ScrClosure *closure, ScrDyn *const *args, size_t argc) {
|
|
683
|
+
ScrStr *member = scr_box_get_ref(closure->caps[0]);
|
|
684
|
+
ScrDyn *result = scr_fs_cb_invoke(member, args, argc);
|
|
685
|
+
scr_str_release(member);
|
|
686
|
+
return result;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
ScrDyn *scr_fs_callback_value(ScrStr *member) {
|
|
690
|
+
ScrClosure *closure = scr_closure_new(NULL, 1);
|
|
691
|
+
closure->caps[0] = scr_box_new(SCR_BOX_STR);
|
|
692
|
+
scr_box_set_ref(closure->caps[0], scr_str_retain(member));
|
|
693
|
+
return scr_dyn_new_func(closure, scr_fs_cb_value_call, 0, "native:fs.callback", "filesystemCallback");
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
ScrDyn *scr_fs_callback_call(ScrStr *member, const ScrDyn *args) {
|
|
697
|
+
return scr_fs_cb_invoke(member, args->v.arr.items, args->v.arr.len);
|
|
698
|
+
}
|
|
699
|
+
|
|
143
700
|
/* ── crypto.randomBytes → a real Buffer ────────────────────────────────── */
|
|
144
701
|
|
|
145
702
|
ScrBytes *scr_crypto_random_bytes(double n) {
|
|
@@ -383,6 +940,12 @@ static bool scr_fs_path_chk(const ScrDyn *p, const char *name) {
|
|
|
383
940
|
* options record's `encoding` member): Node throws ERR_INVALID_ARG_VALUE
|
|
384
941
|
* for any truthy value Buffer.isEncoding rejects. */
|
|
385
942
|
static bool scr_fs_encoding_chk(const ScrDyn *opts) {
|
|
943
|
+
if (opts->kind == SCR_DYN_TYPED_REF) {
|
|
944
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(opts);
|
|
945
|
+
bool valid = view && !scr_exc_pending() && scr_fs_encoding_chk(view);
|
|
946
|
+
scr_dyn_release(view);
|
|
947
|
+
return valid;
|
|
948
|
+
}
|
|
386
949
|
const ScrDyn *enc = opts;
|
|
387
950
|
if (opts->kind == SCR_DYN_OBJ) {
|
|
388
951
|
enc = scr_dyn_obj_get(opts, "encoding", 8);
|
|
@@ -670,15 +1233,15 @@ static bool scr_fs_int_range_chk(const ScrDyn *v, const char *name, double min,
|
|
|
670
1233
|
return true;
|
|
671
1234
|
}
|
|
672
1235
|
|
|
673
|
-
|
|
674
|
-
|
|
1236
|
+
static bool scr_fs_read_validate(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offset,
|
|
1237
|
+
const ScrDyn *length, const ScrDyn *position) {
|
|
675
1238
|
if (buffer->kind != SCR_DYN_BYTES) {
|
|
676
1239
|
scr_dyn_arg_type_fail("buffer", "an instance of Buffer, TypedArray, or DataView", buffer);
|
|
677
|
-
return;
|
|
1240
|
+
return false;
|
|
678
1241
|
}
|
|
679
1242
|
if (fd->kind != SCR_DYN_NUM) {
|
|
680
1243
|
scr_dyn_arg_type_fail("fd", "of type number", fd);
|
|
681
|
-
return;
|
|
1244
|
+
return false;
|
|
682
1245
|
}
|
|
683
1246
|
double buflen = scr_bytes_byte_len(buffer->v.bytes);
|
|
684
1247
|
if (!scr_fs_dyn_absent(offset)) {
|
|
@@ -686,12 +1249,12 @@ void scr_fs_read_chk(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offse
|
|
|
686
1249
|
* Node renders each with its own max. */
|
|
687
1250
|
if (!scr_fs_int_range_chk(offset, "offset", 0, 9007199254740991.0,
|
|
688
1251
|
">= 0 && <= 9007199254740991")) {
|
|
689
|
-
return;
|
|
1252
|
+
return false;
|
|
690
1253
|
}
|
|
691
1254
|
if (offset->v.num > buflen) {
|
|
692
1255
|
char range[64];
|
|
693
1256
|
snprintf(range, sizeof range, ">= 0 && <= %.0f", buflen);
|
|
694
|
-
if (!scr_fs_int_range_chk(offset, "offset", 0, buflen, range)) return;
|
|
1257
|
+
if (!scr_fs_int_range_chk(offset, "offset", 0, buflen, range)) return false;
|
|
695
1258
|
}
|
|
696
1259
|
}
|
|
697
1260
|
double off = offset->kind == SCR_DYN_NUM ? offset->v.num : 0;
|
|
@@ -708,10 +1271,10 @@ void scr_fs_read_chk(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offse
|
|
|
708
1271
|
int len = snprintf(msg, sizeof msg,
|
|
709
1272
|
"The value of \"length\" is out of range. %s Received %s", shape, recv);
|
|
710
1273
|
scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)len, "ERR_OUT_OF_RANGE");
|
|
711
|
-
return;
|
|
1274
|
+
return false;
|
|
712
1275
|
}
|
|
713
1276
|
scr_dyn_arg_type_fail("length", "of type number", length);
|
|
714
|
-
return;
|
|
1277
|
+
return false;
|
|
715
1278
|
}
|
|
716
1279
|
if (length->v.num > buflen - off) {
|
|
717
1280
|
char recv[48], msg[160];
|
|
@@ -720,20 +1283,26 @@ void scr_fs_read_chk(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offse
|
|
|
720
1283
|
"The value of \"length\" is out of range. It must be <= %.0f. Received %s",
|
|
721
1284
|
buflen - off, recv);
|
|
722
1285
|
scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)len, "ERR_OUT_OF_RANGE");
|
|
723
|
-
return;
|
|
1286
|
+
return false;
|
|
724
1287
|
}
|
|
725
1288
|
}
|
|
726
1289
|
if (!scr_fs_dyn_absent(position)) {
|
|
727
1290
|
if (position->kind != SCR_DYN_NUM) {
|
|
728
1291
|
scr_dyn_arg_type_fail("position", "of type bigint or integer", position);
|
|
729
|
-
return;
|
|
1292
|
+
return false;
|
|
730
1293
|
}
|
|
731
1294
|
if (!scr_fs_int_range_chk(position, "position", -1, 9007199254740991.0,
|
|
732
1295
|
">= -1 && <= 9007199254740991")) {
|
|
733
|
-
return;
|
|
1296
|
+
return false;
|
|
734
1297
|
}
|
|
735
1298
|
}
|
|
736
|
-
|
|
1299
|
+
return true;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
void scr_fs_read_chk(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offset,
|
|
1304
|
+
const ScrDyn *length, const ScrDyn *position, const ScrStr *fence) {
|
|
1305
|
+
if (scr_fs_read_validate(fd, buffer, offset, length, position)) scr_throw_lowering_fence(fence);
|
|
737
1306
|
}
|
|
738
1307
|
|
|
739
1308
|
/* createReadStream/createWriteStream(path, options?): getOptions'
|