xbintsc 0.6.24 → 0.7.0
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/AGENTS.md +1 -1
- package/dist/src/binder/declarations.d.ts +1 -0
- package/dist/src/binder/declarations.js +37 -0
- package/dist/src/binder/declarations.js.map +1 -1
- package/dist/src/binder/references.js +12 -0
- package/dist/src/binder/references.js.map +1 -1
- package/dist/src/checker/globals.js +1 -0
- package/dist/src/checker/globals.js.map +1 -1
- package/dist/src/checker/type-system.d.ts +5 -0
- package/dist/src/checker/type-system.js +22 -3
- package/dist/src/checker/type-system.js.map +1 -1
- package/dist/src/cli/extensions.js +11 -3
- package/dist/src/cli/extensions.js.map +1 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/help.js +1 -1
- package/dist/src/codegen/generator/calls/access.js +25 -0
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/invocation.js +13 -0
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls/super.js +3 -4
- package/dist/src/codegen/generator/calls/super.js.map +1 -1
- package/dist/src/codegen/generator/calls/unwrap.d.ts +18 -0
- package/dist/src/codegen/generator/calls/unwrap.js +45 -0
- package/dist/src/codegen/generator/calls/unwrap.js.map +1 -0
- package/dist/src/codegen/generator/expressions/assignment.js +14 -0
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/module-values.d.ts +6 -0
- package/dist/src/codegen/generator/expressions/module-values.js +51 -17
- package/dist/src/codegen/generator/expressions/module-values.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.js +9 -5
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/generator.js +4 -0
- package/dist/src/codegen/generator/generator.js.map +1 -1
- package/dist/src/codegen/generator/lookup-tables.d.ts +22 -0
- package/dist/src/codegen/generator/lookup-tables.js +48 -0
- package/dist/src/codegen/generator/lookup-tables.js.map +1 -0
- package/dist/src/codegen/generator/module.js +38 -7
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.js +24 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +2 -6
- package/dist/src/codegen/generator/tables.js +37 -13
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/bundler/commonjs.d.ts +9 -2
- package/dist/src/driver/bundler/commonjs.js +11 -4
- package/dist/src/driver/bundler/commonjs.js.map +1 -1
- package/dist/src/driver/bundler/concatenate.d.ts +20 -0
- package/dist/src/driver/bundler/concatenate.js +68 -4
- package/dist/src/driver/bundler/concatenate.js.map +1 -1
- package/dist/src/driver/bundler/deferred.d.ts +29 -1
- package/dist/src/driver/bundler/deferred.js +114 -5
- package/dist/src/driver/bundler/deferred.js.map +1 -1
- package/dist/src/driver/bundler/dynamic-import.d.ts +6 -0
- package/dist/src/driver/bundler/dynamic-import.js +59 -3
- package/dist/src/driver/bundler/dynamic-import.js.map +1 -1
- package/dist/src/driver/bundler/graph.d.ts +13 -0
- package/dist/src/driver/bundler/graph.js +11 -7
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +32 -8
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/namespace-object.d.ts +11 -0
- package/dist/src/driver/bundler/namespace-object.js +32 -0
- package/dist/src/driver/bundler/namespace-object.js.map +1 -1
- package/dist/src/driver/bundler/reexport-resolution.js +8 -2
- package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
- package/dist/src/driver/bundler/symbols.d.ts +4 -0
- package/dist/src/driver/bundler/symbols.js +14 -1
- package/dist/src/driver/bundler/symbols.js.map +1 -1
- package/dist/src/driver/config.d.ts +1 -1
- package/dist/src/driver/fingerprint.d.ts +2 -2
- package/dist/src/driver/fingerprint.js +3 -3
- package/dist/src/driver/fingerprint.js.map +1 -1
- package/dist/src/driver/link-features.js +1 -1
- package/dist/src/driver/link-features.js.map +1 -1
- package/dist/src/driver/options.d.ts +1 -4
- package/dist/src/driver/paths.js +8 -4
- package/dist/src/driver/paths.js.map +1 -1
- package/dist/src/driver/runtime-lib.d.ts +27 -0
- package/dist/src/driver/runtime-lib.js +78 -2
- package/dist/src/driver/runtime-lib.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +37 -6
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/driver/version.js.map +1 -1
- package/dist/src/extensions/catalog.js +5 -1
- package/dist/src/extensions/catalog.js.map +1 -1
- package/dist/src/extensions/gui/index.js +0 -1
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/link-feature.d.ts +8 -0
- package/dist/src/extensions/node/buffer/index.d.ts +5 -4
- package/dist/src/extensions/node/buffer/index.js +5 -4
- package/dist/src/extensions/node/buffer/index.js.map +1 -1
- package/dist/src/extensions/node/events/index.js +8 -1
- package/dist/src/extensions/node/events/index.js.map +1 -1
- package/dist/src/extensions/node/fs/callbacks.d.ts +9 -0
- package/dist/src/extensions/node/fs/callbacks.js +42 -0
- package/dist/src/extensions/node/fs/callbacks.js.map +1 -0
- package/dist/src/extensions/node/fs/index.d.ts +2 -3
- package/dist/src/extensions/node/fs/index.js +11 -4
- package/dist/src/extensions/node/fs/index.js.map +1 -1
- package/dist/src/extensions/node/process/index.d.ts +10 -3
- package/dist/src/extensions/node/process/index.js +30 -5
- package/dist/src/extensions/node/process/index.js.map +1 -1
- package/dist/src/extensions/node/stream-web/index.d.ts +6 -1
- package/dist/src/extensions/node/stream-web/index.js +59 -4
- package/dist/src/extensions/node/stream-web/index.js.map +1 -1
- package/dist/src/extensions/node/worker_threads/index.d.ts +14 -4
- package/dist/src/extensions/node/worker_threads/index.js +24 -11
- package/dist/src/extensions/node/worker_threads/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +16 -1
- package/dist/src/extensions/registry.js +17 -5
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/extensions/wasm-asset.d.ts +16 -0
- package/dist/src/extensions/wasm-asset.js +28 -0
- package/dist/src/extensions/wasm-asset.js.map +1 -0
- package/dist/src/extensions/wasm.d.ts +17 -0
- package/dist/src/extensions/wasm.js +68 -0
- package/dist/src/extensions/wasm.js.map +1 -0
- package/dist/src/extensions/webworker/index.d.ts +24 -0
- package/dist/src/extensions/webworker/index.js +54 -0
- package/dist/src/extensions/webworker/index.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lexer/scanner.d.ts +7 -1
- package/dist/src/lexer/scanner.js +15 -0
- package/dist/src/lexer/scanner.js.map +1 -1
- package/dist/src/parser/context.d.ts +10 -0
- package/dist/src/parser/context.js +42 -3
- package/dist/src/parser/context.js.map +1 -1
- package/dist/src/parser/literals.js +6 -2
- package/dist/src/parser/literals.js.map +1 -1
- package/dist/tests/binder/binder.test.js +43 -0
- package/dist/tests/binder/binder.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +15 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/driver/bundler-resolve.test.js +12 -0
- package/dist/tests/driver/bundler-resolve.test.js.map +1 -1
- package/dist/tests/driver/commonjs-prelude.test.d.ts +11 -0
- package/dist/tests/driver/commonjs-prelude.test.js +69 -0
- package/dist/tests/driver/commonjs-prelude.test.js.map +1 -0
- package/dist/tests/driver/compiler.test.js +42 -1
- package/dist/tests/driver/compiler.test.js.map +1 -1
- package/dist/tests/driver/html-deferred-cycles.test.d.ts +10 -0
- package/dist/tests/driver/html-deferred-cycles.test.js +75 -0
- package/dist/tests/driver/html-deferred-cycles.test.js.map +1 -0
- package/dist/tests/driver/link-features.test.js +9 -0
- package/dist/tests/driver/link-features.test.js.map +1 -1
- package/dist/tests/driver/namespace-type-exports.test.d.ts +9 -0
- package/dist/tests/driver/namespace-type-exports.test.js +59 -0
- package/dist/tests/driver/namespace-type-exports.test.js.map +1 -0
- package/dist/tests/driver/runtime-lib.test.js +49 -1
- package/dist/tests/driver/runtime-lib.test.js.map +1 -1
- package/dist/tests/e2e/async-fs.test.js +44 -0
- package/dist/tests/e2e/async-fs.test.js.map +1 -1
- package/dist/tests/e2e/compile-basics.test.js +53 -0
- package/dist/tests/e2e/compile-basics.test.js.map +1 -1
- package/dist/tests/e2e/compile-deferred-marker.test.d.ts +14 -0
- package/dist/tests/e2e/compile-deferred-marker.test.js +68 -0
- package/dist/tests/e2e/compile-deferred-marker.test.js.map +1 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.d.ts +12 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.js +89 -0
- package/dist/tests/e2e/compile-deferred-reexport.test.js.map +1 -0
- package/dist/tests/e2e/compile-error-module.test.d.ts +9 -0
- package/dist/tests/e2e/compile-error-module.test.js +29 -0
- package/dist/tests/e2e/compile-error-module.test.js.map +1 -0
- package/dist/tests/e2e/compile-gc-promises.test.d.ts +11 -0
- package/dist/tests/e2e/compile-gc-promises.test.js +52 -0
- package/dist/tests/e2e/compile-gc-promises.test.js.map +1 -0
- package/dist/tests/e2e/compile-modules.test.js +40 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/compile-node-fs-callbacks.test.d.ts +6 -0
- package/dist/tests/e2e/compile-node-fs-callbacks.test.js +46 -0
- package/dist/tests/e2e/compile-node-fs-callbacks.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-inheritance.test.d.ts +6 -0
- package/dist/tests/e2e/compile-node-inheritance.test.js +48 -0
- package/dist/tests/e2e/compile-node-inheritance.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-require.test.d.ts +9 -0
- package/dist/tests/e2e/compile-node-require.test.js +29 -0
- package/dist/tests/e2e/compile-node-require.test.js.map +1 -0
- package/dist/tests/e2e/compile-node-stats.test.d.ts +8 -0
- package/dist/tests/e2e/compile-node-stats.test.js +26 -0
- package/dist/tests/e2e/compile-node-stats.test.js.map +1 -0
- package/dist/tests/e2e/compile-proxy.test.d.ts +6 -0
- package/dist/tests/e2e/compile-proxy.test.js +66 -0
- package/dist/tests/e2e/compile-proxy.test.js.map +1 -0
- package/dist/tests/e2e/compile-web-globals.test.d.ts +6 -0
- package/dist/tests/e2e/compile-web-globals.test.js +94 -0
- package/dist/tests/e2e/compile-web-globals.test.js.map +1 -0
- package/dist/tests/e2e/fetch.test.js +1 -1
- package/dist/tests/e2e/gui-script-import-order.test.js +24 -0
- package/dist/tests/e2e/gui-script-import-order.test.js.map +1 -1
- package/dist/tests/e2e/harness.d.ts +6 -0
- package/dist/tests/e2e/harness.js +13 -1
- package/dist/tests/e2e/harness.js.map +1 -1
- package/dist/tests/e2e/json-stringify-to-json.test.d.ts +10 -0
- package/dist/tests/e2e/json-stringify-to-json.test.js +61 -0
- package/dist/tests/e2e/json-stringify-to-json.test.js.map +1 -0
- package/dist/tests/e2e/node-crypto-random.test.d.ts +8 -0
- package/dist/tests/e2e/node-crypto-random.test.js +148 -0
- package/dist/tests/e2e/node-crypto-random.test.js.map +1 -0
- package/dist/tests/e2e/node-modules.test.js +1 -1
- package/dist/tests/e2e/node-modules.test.js.map +1 -1
- package/dist/tests/e2e/node-process.test.d.ts +7 -0
- package/dist/tests/e2e/node-process.test.js +50 -0
- package/dist/tests/e2e/node-process.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.js +31 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.js.map +1 -1
- package/dist/tests/e2e/web-streams.test.d.ts +8 -0
- package/dist/tests/e2e/web-streams.test.js +289 -0
- package/dist/tests/e2e/web-streams.test.js.map +1 -0
- package/dist/tests/e2e/web-worker.test.d.ts +7 -0
- package/dist/tests/e2e/web-worker.test.js +74 -0
- package/dist/tests/e2e/web-worker.test.js.map +1 -0
- package/dist/tests/e2e/webassembly.test.d.ts +8 -0
- package/dist/tests/e2e/webassembly.test.js +113 -0
- package/dist/tests/e2e/webassembly.test.js.map +1 -0
- package/dist/tests/e2e/worker-api.test.d.ts +14 -0
- package/dist/tests/e2e/worker-api.test.js +460 -0
- package/dist/tests/e2e/worker-api.test.js.map +1 -0
- package/dist/tests/e2e/worker-threads.test.d.ts +8 -0
- package/dist/tests/e2e/worker-threads.test.js +160 -0
- package/dist/tests/e2e/worker-threads.test.js.map +1 -0
- package/dist/tests/extensions/wasm.test.d.ts +1 -0
- package/dist/tests/extensions/wasm.test.js +53 -0
- package/dist/tests/extensions/wasm.test.js.map +1 -0
- package/dist/tests/parser/literals.test.js +19 -0
- package/dist/tests/parser/literals.test.js.map +1 -1
- package/dist/tests/parser/statements.test.js +13 -0
- package/dist/tests/parser/statements.test.js.map +1 -1
- package/doc/ai/cli.md +2 -1
- package/doc/ai/contributing.md +11 -4
- package/doc/ai/extensions.md +25 -2
- package/doc/ai/language-support.md +14 -2
- package/doc/ai/zh-CN/cli.md +2 -1
- package/doc/ai/zh-CN/contributing.md +8 -3
- package/doc/ai/zh-CN/extensions.md +23 -2
- package/doc/ai/zh-CN/language-support.md +13 -2
- package/doc/gui/api.md +1 -1
- package/doc/implemented/binder.md +2 -1
- package/doc/implemented/checker.md +5 -0
- package/doc/implemented/cli.md +1 -1
- package/doc/implemented/extensions.md +6 -5
- package/doc/implemented/lexer.md +1 -1
- package/doc/implemented/modules.md +23 -1
- package/doc/implemented/node/buffer.md +18 -5
- package/doc/implemented/node/fs.md +22 -1
- package/doc/implemented/node/process.md +65 -5
- package/doc/implemented/node/stream-web.md +31 -0
- package/doc/implemented/node/worker-threads.md +88 -5
- package/doc/implemented/node.md +9 -2
- package/doc/implemented/operators.md +3 -1
- package/doc/implemented/parser.md +1 -1
- package/doc/implemented/runtime-core.md +6 -2
- package/doc/implemented/stdlib.md +69 -2
- package/doc/implemented/streams.md +82 -0
- package/doc/implemented/wasm.md +80 -18
- package/doc/implemented/web-worker.md +84 -0
- package/doc/implemented.md +6 -2
- package/doc/unimplemented/classes.md +1 -0
- package/doc/unimplemented/deviations.md +1 -0
- package/doc/unimplemented/modules.md +1 -0
- package/doc/unimplemented/node/worker-threads.md +23 -0
- package/doc/unimplemented/node.md +1 -0
- package/doc/unimplemented/stdlib.md +3 -1
- package/doc/unimplemented/wasm.md +21 -9
- package/doc/unimplemented.md +1 -1
- package/doc/xbintsc.config.schema.json +5 -0
- package/doc/zh-CN/gui/api.md +1 -1
- package/doc/zh-CN/implemented/binder.md +2 -1
- package/doc/zh-CN/implemented/checker.md +3 -0
- package/doc/zh-CN/implemented/cli.md +1 -1
- package/doc/zh-CN/implemented/extensions.md +7 -6
- package/doc/zh-CN/implemented/lexer.md +1 -1
- package/doc/zh-CN/implemented/modules.md +17 -1
- package/doc/zh-CN/implemented/node/buffer.md +3 -1
- package/doc/zh-CN/implemented/node/fs.md +19 -1
- package/doc/zh-CN/implemented/node/process.md +59 -5
- package/doc/zh-CN/implemented/node/stream-web.md +24 -0
- package/doc/zh-CN/implemented/node/worker-threads.md +77 -4
- package/doc/zh-CN/implemented/node.md +3 -2
- package/doc/zh-CN/implemented/operators.md +2 -1
- package/doc/zh-CN/implemented/parser.md +1 -1
- package/doc/zh-CN/implemented/runtime-core.md +3 -2
- package/doc/zh-CN/implemented/stdlib.md +58 -2
- package/doc/zh-CN/implemented/streams.md +60 -0
- package/doc/zh-CN/implemented/wasm.md +73 -16
- package/doc/zh-CN/implemented/web-worker.md +79 -0
- package/doc/zh-CN/implemented.md +6 -2
- package/doc/zh-CN/unimplemented/classes.md +1 -0
- package/doc/zh-CN/unimplemented/deviations.md +1 -0
- package/doc/zh-CN/unimplemented/modules.md +1 -0
- package/doc/zh-CN/unimplemented/node/worker-threads.md +20 -0
- package/doc/zh-CN/unimplemented/node.md +1 -0
- package/doc/zh-CN/unimplemented/stdlib.md +3 -1
- package/doc/zh-CN/unimplemented/wasm.md +16 -8
- package/doc/zh-CN/unimplemented.md +1 -1
- package/llms.txt +2 -0
- package/package.json +8 -7
- package/runtime/ext_gui/browser.cpp +1 -1
- package/runtime/ext_node/buffer/buffer.c +5 -4
- package/runtime/ext_node/buffer/parts/byte-access.inc +115 -11
- package/runtime/ext_node/buffer/parts/prototype.inc +4 -1
- package/runtime/ext_node/events/events.c +9 -0
- package/runtime/ext_node/fs/callbacks.c +138 -0
- package/runtime/ext_node/fs/fs_ops.c +28 -15
- package/runtime/ext_node/module/module.c +18 -9
- package/runtime/ext_node/process/process.c +117 -32
- package/runtime/ext_node/process/streams.c +370 -0
- package/runtime/ext_node/process/streams.h +20 -0
- package/runtime/ext_node/stream_web/stream_web.c +20 -6
- package/runtime/rt.h +36 -0
- package/runtime/rt_internal.h +10 -10
- package/runtime/worker/worker_api.c +422 -0
- package/runtime/worker/worker_codec.c +489 -0
- package/runtime/worker/worker_core.c +445 -0
- package/runtime/worker/worker_internal.h +223 -0
- package/runtime/worker/worker_platform.c +344 -0
- package/runtime/worker/worker_ports.c +203 -0
- package/runtime/worker/worker_transport.c +464 -0
- package/runtime/worker/worker_wire.c +150 -0
- package/runtime/xt_alloc.c +67 -49
- package/runtime/xt_async_io.c +3 -0
- package/runtime/xt_builtins.c +41 -23
- package/runtime/xt_constructors.c +148 -2
- package/runtime/xt_containers/access.inc +29 -1
- package/runtime/xt_containers/function_prototypes.inc +58 -0
- package/runtime/xt_containers/objects.inc +18 -2
- package/runtime/xt_containers.c +1 -0
- package/runtime/xt_exit.c +34 -0
- package/runtime/xt_fetch/headers.inc +1 -0
- package/runtime/xt_fetch/response.inc +28 -8
- package/runtime/xt_fetch/webapi.inc +82 -0
- package/runtime/xt_fetch.c +5 -0
- package/runtime/xt_gc_verify.c +135 -0
- package/runtime/xt_intl.c +224 -0
- package/runtime/xt_io/exception.inc +40 -1
- package/runtime/xt_module_values.c +82 -0
- package/runtime/xt_proxy.c +140 -0
- package/runtime/xt_stdlib/dispatch.inc +98 -9
- package/runtime/xt_stdlib2/date.inc +7 -1
- package/runtime/xt_stdlib2/error.inc +4 -0
- package/runtime/xt_stdlib2/json.inc +28 -0
- package/runtime/xt_stdlib2/json_stringify.inc +70 -53
- package/runtime/xt_streams/common.inc +232 -0
- package/runtime/xt_streams/constructors.inc +232 -0
- package/runtime/xt_streams/encoding.inc +124 -0
- package/runtime/xt_streams/readable-extra.inc +372 -0
- package/runtime/xt_streams/readable.inc +415 -0
- package/runtime/xt_streams/transform.inc +195 -0
- package/runtime/xt_streams/writable.inc +542 -0
- package/runtime/xt_streams.c +30 -0
- package/runtime/xt_wasm/wasm.h +148 -0
- package/runtime/xt_wasm/wasm_api.c +357 -0
- package/runtime/xt_wasm/wasm_api.h +37 -0
- package/runtime/xt_wasm/wasm_bridge.c +30 -0
- package/runtime/xt_wasm/wasm_instance.c +591 -0
- package/runtime/xt_wasm/wasm_module.c +270 -0
- package/runtime/xt_wasm/wasm_values.c +177 -0
- package/runtime/xt_web.h +27 -0
- package/runtime/xt_web_abort.c +373 -0
- package/runtime/xt_webassembly.c +15 -4
- package/scripts/build-runtime.ts +8 -0
- package/scripts/fetch-vendored.ts +187 -20
- package/scripts/package-release.ts +3 -2
- package/src/binder/declarations.ts +34 -0
- package/src/binder/references.ts +12 -0
- package/src/checker/globals.ts +1 -0
- package/src/checker/type-system.ts +23 -3
- package/src/cli/extensions.ts +11 -3
- package/src/cli/help.ts +1 -1
- package/src/codegen/generator/calls/access.ts +23 -0
- package/src/codegen/generator/calls/invocation.ts +12 -0
- package/src/codegen/generator/calls/super.ts +5 -4
- package/src/codegen/generator/calls/unwrap.ts +47 -0
- package/src/codegen/generator/expressions/assignment.ts +15 -0
- package/src/codegen/generator/expressions/module-values.ts +57 -19
- package/src/codegen/generator/expressions/primary.ts +9 -9
- package/src/codegen/generator/generator.ts +4 -0
- package/src/codegen/generator/lookup-tables.ts +63 -0
- package/src/codegen/generator/module.ts +38 -7
- package/src/codegen/generator/state.ts +24 -0
- package/src/codegen/generator/tables.ts +37 -13
- package/src/driver/bundler/commonjs.ts +12 -5
- package/src/driver/bundler/concatenate.ts +84 -7
- package/src/driver/bundler/deferred.ts +122 -6
- package/src/driver/bundler/dynamic-import.ts +75 -2
- package/src/driver/bundler/graph.ts +11 -7
- package/src/driver/bundler/merge.ts +31 -5
- package/src/driver/bundler/namespace-object.ts +44 -0
- package/src/driver/bundler/reexport-resolution.ts +12 -2
- package/src/driver/bundler/symbols.ts +17 -0
- package/src/driver/config.ts +1 -1
- package/src/driver/fingerprint.ts +3 -3
- package/src/driver/link-features.ts +1 -1
- package/src/driver/options.ts +1 -4
- package/src/driver/paths.ts +8 -4
- package/src/driver/runtime-lib.ts +87 -2
- package/src/driver/runtime-objects.ts +37 -6
- package/src/driver/version.ts +1 -1
- package/src/extensions/catalog.ts +5 -1
- package/src/extensions/gui/index.ts +0 -1
- package/src/extensions/link-feature.ts +8 -0
- package/src/extensions/node/buffer/index.ts +5 -4
- package/src/extensions/node/events/index.ts +8 -1
- package/src/extensions/node/fs/callbacks.ts +45 -0
- package/src/extensions/node/fs/index.ts +11 -4
- package/src/extensions/node/process/index.ts +30 -5
- package/src/extensions/node/stream-web/index.ts +59 -4
- package/src/extensions/node/worker_threads/index.ts +24 -11
- package/src/extensions/registry.ts +34 -6
- package/src/extensions/wasm-asset.ts +32 -0
- package/src/extensions/wasm.ts +74 -0
- package/src/extensions/webworker/index.ts +58 -0
- package/src/index.ts +1 -0
- package/src/lexer/scanner.ts +16 -1
- package/src/parser/context.ts +39 -3
- package/src/parser/literals.ts +6 -2
- package/vendor/wasm3/.pin +1 -0
- package/vendor/wasm3/LICENSE +21 -0
- package/vendor/wasm3/m3_api_libc.c +265 -0
- package/vendor/wasm3/m3_api_libc.h +19 -0
- package/vendor/wasm3/m3_api_meta_wasi.c +1107 -0
- package/vendor/wasm3/m3_api_tracer.c +173 -0
- package/vendor/wasm3/m3_api_tracer.h +19 -0
- package/vendor/wasm3/m3_api_uvwasi.c +1290 -0
- package/vendor/wasm3/m3_api_wasi.c +1207 -0
- package/vendor/wasm3/m3_api_wasi.h +74 -0
- package/vendor/wasm3/m3_api_wasi_host.h +137 -0
- package/vendor/wasm3/m3_api_wasi_posix.h +979 -0
- package/vendor/wasm3/m3_api_wasi_win32.h +1093 -0
- package/vendor/wasm3/m3_atomic.h +114 -0
- package/vendor/wasm3/m3_bind.c +174 -0
- package/vendor/wasm3/m3_bind.h +20 -0
- package/vendor/wasm3/m3_code.c +232 -0
- package/vendor/wasm3/m3_code.h +74 -0
- package/vendor/wasm3/m3_compile.c +6603 -0
- package/vendor/wasm3/m3_compile.h +354 -0
- package/vendor/wasm3/m3_config.h +448 -0
- package/vendor/wasm3/m3_config_platforms.h +345 -0
- package/vendor/wasm3/m3_core.c +1034 -0
- package/vendor/wasm3/m3_core.h +526 -0
- package/vendor/wasm3/m3_deterministic.c +65 -0
- package/vendor/wasm3/m3_deterministic.h +59 -0
- package/vendor/wasm3/m3_env.c +3146 -0
- package/vendor/wasm3/m3_env.h +748 -0
- package/vendor/wasm3/m3_exception.h +33 -0
- package/vendor/wasm3/m3_exec.c +8 -0
- package/vendor/wasm3/m3_exec.h +4110 -0
- package/vendor/wasm3/m3_exec_atomic.h +146 -0
- package/vendor/wasm3/m3_exec_defs.h +76 -0
- package/vendor/wasm3/m3_function.c +278 -0
- package/vendor/wasm3/m3_function.h +244 -0
- package/vendor/wasm3/m3_host.h +226 -0
- package/vendor/wasm3/m3_host_none.h +76 -0
- package/vendor/wasm3/m3_host_posix.h +543 -0
- package/vendor/wasm3/m3_host_win32.h +253 -0
- package/vendor/wasm3/m3_info.c +616 -0
- package/vendor/wasm3/m3_info.h +38 -0
- package/vendor/wasm3/m3_math_utils.h +560 -0
- package/vendor/wasm3/m3_module.c +431 -0
- package/vendor/wasm3/m3_parse.c +1549 -0
- package/vendor/wasm3/m3_snapshot.c +3825 -0
- package/vendor/wasm3/m3_validate.c +1770 -0
- package/vendor/wasm3/m3_validate.h +25 -0
- package/vendor/wasm3/m3_wasi.h +10 -0
- package/vendor/wasm3/m3_xxh64.c +211 -0
- package/vendor/wasm3/wasm3.h +684 -0
- package/vendor/wasm3/wasm3_defs.h +350 -0
- package/runtime/ext_node/worker_threads/worker_threads.c +0 -214
|
@@ -36,6 +36,23 @@ export function declarationName(node: Node): Identifier | undefined {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** True when every declaration of this symbol is erased before codegen: an
|
|
40
|
+
* interface, a type alias, or an ambient `declare`. Such a symbol has no
|
|
41
|
+
* runtime slot, so a module namespace object must not reference it. */
|
|
42
|
+
export function isTypeOnlySymbol(symbol: SymbolInfo): boolean {
|
|
43
|
+
return symbol.declarations.length > 0 && symbol.declarations.every(isErasedDeclaration);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isErasedDeclaration(node: Node): boolean {
|
|
47
|
+
if (
|
|
48
|
+
node.kind === SyntaxKind.InterfaceDeclaration ||
|
|
49
|
+
node.kind === SyntaxKind.TypeAliasDeclaration
|
|
50
|
+
) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return hasModifier(node, ModifierKind.Declare);
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
/** Rewrite a symbol's declaration and every reference to `finalName`. */
|
|
40
57
|
export function renameSymbol(symbol: SymbolInfo, finalName: string): void {
|
|
41
58
|
for (const declaration of symbol.declarations) {
|
package/src/driver/config.ts
CHANGED
|
@@ -59,7 +59,7 @@ export interface ProjectConfig {
|
|
|
59
59
|
readonly features?: readonly string[];
|
|
60
60
|
/** Optional link features to keep out even when auto-detection finds a use. */
|
|
61
61
|
readonly noFeatures?: readonly string[];
|
|
62
|
-
/**
|
|
62
|
+
/** Exact module specifiers mapped to local replacement files. */
|
|
63
63
|
readonly moduleOverrides?: Readonly<Record<string, string>>;
|
|
64
64
|
readonly force?: boolean;
|
|
65
65
|
readonly app?: AppConfig;
|
|
@@ -40,14 +40,14 @@ export function runtimeFingerprint(runtimeDir: string): string {
|
|
|
40
40
|
*
|
|
41
41
|
* They live outside `runtime/` — the tree is fetched, not committed — so
|
|
42
42
|
* {@link runtimeFingerprint} cannot see them, yet changing one changes the
|
|
43
|
-
* linked binary. Only the
|
|
44
|
-
*
|
|
43
|
+
* linked binary. Only the packages compiled at program-build time are hashed:
|
|
44
|
+
* `stb`/`nanosvg` are baked into `gui.a`, whose content the registry
|
|
45
45
|
* fingerprint already covers.
|
|
46
46
|
*/
|
|
47
47
|
export function vendoredRuntimeFingerprint(runtimeDir: string): string {
|
|
48
48
|
const vendorDir = resolve(runtimeDir, "..", "vendor");
|
|
49
49
|
const parts: string[] = [];
|
|
50
|
-
for (const name of ["miniz", "sqlite3"]) {
|
|
50
|
+
for (const name of ["miniz", "sqlite3", "wasm3"]) {
|
|
51
51
|
const dir = join(vendorDir, name);
|
|
52
52
|
if (!existsSync(dir)) continue;
|
|
53
53
|
for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
@@ -161,7 +161,7 @@ export function resolveLinkFeatures(
|
|
|
161
161
|
nativeObjects = feature.nativeObjects?.() ?? [];
|
|
162
162
|
} catch (error) {
|
|
163
163
|
const message = error instanceof Error ? error.message : String(error);
|
|
164
|
-
if (strict.has(feature.name)) {
|
|
164
|
+
if (strict.has(feature.name) || feature.required === true) {
|
|
165
165
|
diagnostics.error(DiagnosticCode.LinkFeatureUnavailable, message);
|
|
166
166
|
} else {
|
|
167
167
|
diagnostics.warning(
|
package/src/driver/options.ts
CHANGED
|
@@ -71,10 +71,7 @@ export interface BuildOptions {
|
|
|
71
71
|
readonly features?: readonly string[];
|
|
72
72
|
/** Optional link features to keep out even when the scan detects a use. */
|
|
73
73
|
readonly noFeatures?: readonly string[];
|
|
74
|
-
/**
|
|
75
|
-
* Bare module specifiers mapped to local replacement files. A specifier in
|
|
76
|
-
* this map resolves to its file (an absolute path) before `node_modules`.
|
|
77
|
-
*/
|
|
74
|
+
/** Specifiers mapped to local replacement files, checked before `node_modules`. */
|
|
78
75
|
readonly moduleOverrides?: Readonly<Record<string, string>>;
|
|
79
76
|
}
|
|
80
77
|
|
package/src/driver/paths.ts
CHANGED
|
@@ -33,12 +33,16 @@ export function findRuntimeDir(): string {
|
|
|
33
33
|
*/
|
|
34
34
|
export function findVendorDir(): string {
|
|
35
35
|
const candidate = resolve(findRuntimeDir(), "..", "vendor");
|
|
36
|
-
const markers = [
|
|
36
|
+
const markers = [
|
|
37
|
+
join("sqlite3", "sqlite3.c"),
|
|
38
|
+
join("miniz", "miniz.c"),
|
|
39
|
+
join("wasm3", "wasm3.h"),
|
|
40
|
+
];
|
|
37
41
|
if (markers.some((marker) => existsSync(join(candidate, marker)))) return candidate;
|
|
38
42
|
throw new Error(
|
|
39
|
-
"Unable to locate the xbintsc vendor directory (missing vendor/miniz/miniz.c
|
|
40
|
-
"vendor/sqlite3/sqlite3.c); run `npm run vendor` in a
|
|
41
|
-
"xbintsc so the package's vendored sources are present.",
|
|
43
|
+
"Unable to locate the xbintsc vendor directory (missing vendor/miniz/miniz.c, " +
|
|
44
|
+
"vendor/sqlite3/sqlite3.c or vendor/wasm3/wasm3.h); run `npm run vendor` in a " +
|
|
45
|
+
"source checkout, or reinstall xbintsc so the package's vendored sources are present.",
|
|
42
46
|
);
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
* dependency.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
23
|
-
import { dirname, join } from "node:path";
|
|
22
|
+
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
23
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
24
|
+
import { hashParts } from "./cache.js";
|
|
24
25
|
import { findRuntimeDir, platformSlug } from "./paths.js";
|
|
25
26
|
|
|
26
27
|
/** Archive suffixes, in the order a name is probed. */
|
|
@@ -94,3 +95,87 @@ export function findRuntimeLibrary(
|
|
|
94
95
|
}
|
|
95
96
|
return undefined;
|
|
96
97
|
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/** Name of the file recording which sources an archive was built from. */
|
|
101
|
+
export const RUNTIME_STAMP_FILE = "runtime-stamp.json";
|
|
102
|
+
|
|
103
|
+
/** Source files that make up the runtime archives (the archives' own folder is
|
|
104
|
+
* skipped: it holds the `.a`/`.lib` outputs and the stamp). */
|
|
105
|
+
function runtimeSourceFiles(runtimeDir: string): string[] {
|
|
106
|
+
const files: string[] = [];
|
|
107
|
+
const walk = (dir: string): void => {
|
|
108
|
+
let entries: string[];
|
|
109
|
+
try {
|
|
110
|
+
entries = readdirSync(dir);
|
|
111
|
+
} catch {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
for (const name of entries.sort()) {
|
|
115
|
+
const full = join(dir, name);
|
|
116
|
+
if (statSync(full).isDirectory()) {
|
|
117
|
+
if (name === "lib") continue;
|
|
118
|
+
walk(full);
|
|
119
|
+
} else if (/\.(c|h|inc)$/.test(name)) {
|
|
120
|
+
files.push(full);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
walk(runtimeDir);
|
|
125
|
+
return files;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Fingerprint of the C runtime sources an archive is compiled from.
|
|
130
|
+
*
|
|
131
|
+
* A prebuilt `core`/`ext_<name>` archive is only usable when it was built from
|
|
132
|
+
* exactly these sources: the driver compares the archive's stamp with this
|
|
133
|
+
* value and compiles from source when they differ. Without the stamp a stale
|
|
134
|
+
* archive links silently whenever every symbol it needs still exists — the
|
|
135
|
+
* program then runs the *old* runtime, which is very hard to diagnose.
|
|
136
|
+
*/
|
|
137
|
+
export function runtimeSourceFingerprint(runtimeDir: string, compilerVersion: string, flags: readonly string[]): string {
|
|
138
|
+
const parts: string[] = ["runtime-archive", compilerVersion, process.platform, process.arch, [...flags].join(" ")];
|
|
139
|
+
for (const file of runtimeSourceFiles(runtimeDir)) {
|
|
140
|
+
parts.push(relative(runtimeDir, file).split(sep).join("/"), readFileSync(file, "utf8"));
|
|
141
|
+
}
|
|
142
|
+
return hashParts(parts);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The recorded fingerprint of the archives in `dir`, if any. */
|
|
146
|
+
export function readRuntimeStamp(dir: string): string | undefined {
|
|
147
|
+
try {
|
|
148
|
+
const parsed: unknown = JSON.parse(readFileSync(join(dir, RUNTIME_STAMP_FILE), "utf8"));
|
|
149
|
+
if (typeof parsed !== "object" || parsed === null) return undefined;
|
|
150
|
+
const fingerprint = (parsed as { fingerprint?: unknown }).fingerprint;
|
|
151
|
+
return typeof fingerprint === "string" ? fingerprint : undefined;
|
|
152
|
+
} catch {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Record the fingerprint next to the archives a build just produced. */
|
|
158
|
+
export function writeRuntimeStamp(dir: string, fingerprint: string, compilerVersion: string): void {
|
|
159
|
+
writeFileSync(
|
|
160
|
+
join(dir, RUNTIME_STAMP_FILE),
|
|
161
|
+
`${JSON.stringify({ compilerVersion, fingerprint }, null, "\t")}\n`,
|
|
162
|
+
"utf8",
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A prebuilt archive, but only when it was built from the sources now on disk.
|
|
168
|
+
*
|
|
169
|
+
* Returns `undefined` for a missing archive *and* for a stale one, so the caller
|
|
170
|
+
* falls back to compiling the runtime; `stale` tells the two apart for the
|
|
171
|
+
* message.
|
|
172
|
+
*/
|
|
173
|
+
export function freshRuntimeLibrary(
|
|
174
|
+
name: string,
|
|
175
|
+
dirs: readonly string[],
|
|
176
|
+
fingerprint: string,
|
|
177
|
+
): { path?: string; stale?: string } {
|
|
178
|
+
const path = findRuntimeLibrary(name, dirs);
|
|
179
|
+
if (!path) return {};
|
|
180
|
+
return readRuntimeStamp(dirname(path)) === fingerprint ? { path } : { stale: path };
|
|
181
|
+
}
|
|
@@ -11,7 +11,7 @@ import { basename, join, resolve, sep } from "node:path";
|
|
|
11
11
|
import type { ExtensionRegistry } from "../extensions/registry.js";
|
|
12
12
|
import type { ResolvedLinkFeature } from "./link-features.js";
|
|
13
13
|
import { hashParts } from "./cache.js";
|
|
14
|
-
import {
|
|
14
|
+
import { freshRuntimeLibrary, runtimeLibDirs, runtimeSourceFingerprint } from "./runtime-lib.js";
|
|
15
15
|
import { compileC, optimizationFlags, RUNTIME_CFLAGS, sysrootFlags, type PgoMode, type Runner } from "./toolchain.js";
|
|
16
16
|
import { COMPILER_VERSION } from "./version.js";
|
|
17
17
|
|
|
@@ -31,9 +31,14 @@ export const RUNTIME_SOURCES = [
|
|
|
31
31
|
"xt_async.c",
|
|
32
32
|
"xt_loop.c",
|
|
33
33
|
"xt_async_io.c",
|
|
34
|
+
"xt_exit.c",
|
|
35
|
+
"xt_intl.c",
|
|
34
36
|
"xt_generator.c",
|
|
35
37
|
"xt_coroutine.c",
|
|
36
38
|
"xt_fetch.c",
|
|
39
|
+
"xt_web_abort.c",
|
|
40
|
+
"xt_proxy.c",
|
|
41
|
+
"xt_gc_verify.c",
|
|
37
42
|
"xt_symbol.c",
|
|
38
43
|
"xt_builtins.c",
|
|
39
44
|
"xt_constructors.c",
|
|
@@ -42,11 +47,23 @@ export const RUNTIME_SOURCES = [
|
|
|
42
47
|
"xt_random.c",
|
|
43
48
|
"xt_crypto.c",
|
|
44
49
|
"xt_text_codec.c",
|
|
50
|
+
"xt_streams.c",
|
|
45
51
|
"xt_url.c",
|
|
46
52
|
"xt_url_object.c",
|
|
47
53
|
"xt_array_buffer.c",
|
|
48
54
|
"xt_io.c",
|
|
49
55
|
"xt_protocol_registry.c",
|
|
56
|
+
/* Worker transport. It lives in the core runtime (not in an extension's
|
|
57
|
+
* sources) because both `node:worker_threads` and the `webworker` extension
|
|
58
|
+
* link it; a single definition avoids duplicate symbols when both are
|
|
59
|
+
* enabled. Unused members are dropped by the linker's section GC. */
|
|
60
|
+
"worker/worker_platform.c",
|
|
61
|
+
"worker/worker_wire.c",
|
|
62
|
+
"worker/worker_codec.c",
|
|
63
|
+
"worker/worker_core.c",
|
|
64
|
+
"worker/worker_transport.c",
|
|
65
|
+
"worker/worker_api.c",
|
|
66
|
+
"worker/worker_ports.c",
|
|
50
67
|
] as const;
|
|
51
68
|
|
|
52
69
|
export interface RuntimeObjects {
|
|
@@ -114,7 +131,7 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
|
|
|
114
131
|
* invalidate objects just like the runtime's own (the packages are sibling to
|
|
115
132
|
* `runtime/`, and absent in a checkout that has not run `npm run vendor`). */
|
|
116
133
|
const vendorDir = resolve(runtimeDir, "..", "vendor");
|
|
117
|
-
for (const name of ["miniz", "sqlite3"]) {
|
|
134
|
+
for (const name of ["miniz", "sqlite3", "wasm3"]) {
|
|
118
135
|
const dir = join(vendorDir, name);
|
|
119
136
|
if (existsSync(dir)) collectHeaders(dir);
|
|
120
137
|
}
|
|
@@ -142,7 +159,17 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
|
|
|
142
159
|
};
|
|
143
160
|
|
|
144
161
|
const runtimeInclude = [runtimeDir];
|
|
145
|
-
|
|
162
|
+
/* A shipped archive is only used when it was built from the sources on disk;
|
|
163
|
+
* a stale one links silently and the program runs an old runtime. */
|
|
164
|
+
const fingerprint = runtimeSourceFingerprint(runtimeDir, COMPILER_VERSION, RUNTIME_CFLAGS);
|
|
165
|
+
const staleArchives: string[] = [];
|
|
166
|
+
const prebuilt = (name: string): string | undefined => {
|
|
167
|
+
if (!preferPrebuilt) return undefined;
|
|
168
|
+
const found = freshRuntimeLibrary(name, options.runtimeLibDirs ?? runtimeLibDirs(), fingerprint);
|
|
169
|
+
if (found.stale !== undefined) staleArchives.push(found.stale);
|
|
170
|
+
return found.path;
|
|
171
|
+
};
|
|
172
|
+
const coreArchive = prebuilt("core");
|
|
146
173
|
const runtimeObjects = coreArchive
|
|
147
174
|
? [coreArchive]
|
|
148
175
|
: RUNTIME_SOURCES.map((source) => compileOne(join(runtimeDir, source), basename(source, ".c"), runtimeInclude));
|
|
@@ -155,9 +182,7 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
|
|
|
155
182
|
for (const extension of registry.all()) {
|
|
156
183
|
const sources = extension.runtimeSources ? extension.runtimeSources() : [];
|
|
157
184
|
if (sources.length === 0) continue;
|
|
158
|
-
const archive =
|
|
159
|
-
? findRuntimeLibrary(`ext_${extension.name}`, options.runtimeLibDirs)
|
|
160
|
-
: undefined;
|
|
185
|
+
const archive = prebuilt(`ext_${extension.name}`);
|
|
161
186
|
if (archive) {
|
|
162
187
|
extensionObjects.push(archive);
|
|
163
188
|
prebuiltArchives.push(archive);
|
|
@@ -172,6 +197,12 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
|
|
|
172
197
|
);
|
|
173
198
|
}
|
|
174
199
|
}
|
|
200
|
+
if (staleArchives.length > 0) {
|
|
201
|
+
/* Once per process: the archives stay stale until `npm run runtime` . */
|
|
202
|
+
process.stderr.write(
|
|
203
|
+
"xbintsc: prebuilt runtime archive is stale (the runtime sources changed); compiling the C runtime from source\n",
|
|
204
|
+
);
|
|
205
|
+
}
|
|
175
206
|
// A native archive may be shared by several manifests; link each once.
|
|
176
207
|
const featureObjects: string[] = [];
|
|
177
208
|
for (const feature of options.features ?? []) {
|
package/src/driver/version.ts
CHANGED
|
@@ -13,8 +13,12 @@
|
|
|
13
13
|
import type { Extension } from "./registry.js";
|
|
14
14
|
import { nodeExtension } from "./node/index.js";
|
|
15
15
|
import { guiExtension } from "./gui/index.js";
|
|
16
|
+
import { webworkerExtension } from "./webworker/index.js";
|
|
16
17
|
|
|
17
18
|
/** Every extension bundled with xbintsc, in registration order. */
|
|
18
19
|
export function bundledExtensions(): readonly Extension[] {
|
|
19
|
-
|
|
20
|
+
/* `webworker` is registered after `gui`: both define `self`, and the worker
|
|
21
|
+
* extension's `self` must resolve to the worker scope (a page still reaches
|
|
22
|
+
* the window through `window`). */
|
|
23
|
+
return [nodeExtension, guiExtension, webworkerExtension];
|
|
20
24
|
}
|
|
@@ -67,6 +67,14 @@ export interface LinkFeature {
|
|
|
67
67
|
linkerFlags?(): readonly string[];
|
|
68
68
|
/** Other link features this one needs (activated with it). */
|
|
69
69
|
readonly requires?: readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* A required feature has no graceful degradation: if its sources are
|
|
72
|
+
* unavailable the build fails with the feature's own message even when the
|
|
73
|
+
* feature was selected by the usage scan rather than `--feature`. Optional
|
|
74
|
+
* features (GUI media, image decoders, ...) warn and let the program fall
|
|
75
|
+
* back at run time instead.
|
|
76
|
+
*/
|
|
77
|
+
readonly required?: boolean;
|
|
70
78
|
/** Whether the program may use this feature. */
|
|
71
79
|
used(usage: ProgramUsage): boolean;
|
|
72
80
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node's `Buffer` module.
|
|
3
3
|
*
|
|
4
|
-
* Buffers are
|
|
5
|
-
* plus `length`) with methods
|
|
6
|
-
*
|
|
7
|
-
* without a dedicated binary value type
|
|
4
|
+
* Buffers are ordinary xbintsc objects whose bytes live in an `ArrayBuffer`
|
|
5
|
+
* store behind dynamic-property hooks (plus a `length` property) with methods
|
|
6
|
+
* supplied by the C runtime, so `Buffer.from`, `Buffer.alloc` and the instance
|
|
7
|
+
* methods (`toString`, `slice`, ...) work without a dedicated binary value type
|
|
8
|
+
* in the compiler, and `buf[i]` still reads a byte.
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import type { NodeModule } from "../module.js";
|
|
@@ -14,7 +14,14 @@ import type { ModuleExports } from "../../registry.js";
|
|
|
14
14
|
const methods = ["listenerCount", "getEventListeners", "getMaxListeners", "setMaxListeners", "once", "addAbortListener"] as const;
|
|
15
15
|
|
|
16
16
|
const exports: ModuleExports = {
|
|
17
|
-
EventEmitter: {
|
|
17
|
+
EventEmitter: {
|
|
18
|
+
symbol: "xt_event_emitter_ctor",
|
|
19
|
+
isConstructor: true,
|
|
20
|
+
// `class X extends EventEmitter` chains onto this prototype, so the
|
|
21
|
+
// inherited listener API is reachable (and `x instanceof EventEmitter`
|
|
22
|
+
// holds when the same constructor value is compared).
|
|
23
|
+
prototypeSymbol: "xt_events_prototype",
|
|
24
|
+
},
|
|
18
25
|
defaultMaxListeners: { valueSymbol: "xt_events_default_max_listeners" },
|
|
19
26
|
...Object.fromEntries(methods.map((method) => [method, { namespace: "events", method }])),
|
|
20
27
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The callback forms of Node's `fs` API.
|
|
3
|
+
*
|
|
4
|
+
* Each name forwards to the promise implementation in `callbacks.c`, which
|
|
5
|
+
* attaches `callback(null, value)` / `callback(error)` handlers. `exists` keeps
|
|
6
|
+
* Node's odd shape: one boolean argument and no error.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { BuiltinFunction } from "../../registry.js";
|
|
10
|
+
|
|
11
|
+
const callback = (name: string): BuiltinFunction => ({ symbol: `xt_node_${name}_cb` });
|
|
12
|
+
|
|
13
|
+
export const fsCallbackBuiltins: Readonly<Record<string, BuiltinFunction>> = {
|
|
14
|
+
readFile: callback("read_file"),
|
|
15
|
+
writeFile: callback("write_file"),
|
|
16
|
+
appendFile: callback("append_file"),
|
|
17
|
+
mkdir: callback("mkdir"),
|
|
18
|
+
mkdtemp: callback("mkdtemp"),
|
|
19
|
+
readdir: callback("readdir"),
|
|
20
|
+
rm: callback("rm"),
|
|
21
|
+
rmdir: callback("rmdir"),
|
|
22
|
+
unlink: callback("unlink"),
|
|
23
|
+
rename: callback("rename"),
|
|
24
|
+
copyFile: callback("copy_file"),
|
|
25
|
+
cp: callback("cp"),
|
|
26
|
+
realpath: callback("realpath"),
|
|
27
|
+
stat: callback("stat"),
|
|
28
|
+
lstat: callback("lstat"),
|
|
29
|
+
statfs: callback("statfs"),
|
|
30
|
+
access: callback("access"),
|
|
31
|
+
open: callback("open"),
|
|
32
|
+
chmod: callback("chmod"),
|
|
33
|
+
lchmod: callback("lchmod"),
|
|
34
|
+
chown: callback("chown"),
|
|
35
|
+
lchown: callback("lchown"),
|
|
36
|
+
truncate: callback("truncate"),
|
|
37
|
+
utimes: callback("utimes"),
|
|
38
|
+
lutimes: callback("lutimes"),
|
|
39
|
+
link: callback("link"),
|
|
40
|
+
symlink: callback("symlink"),
|
|
41
|
+
readlink: callback("readlink"),
|
|
42
|
+
opendir: callback("opendir"),
|
|
43
|
+
glob: callback("glob"),
|
|
44
|
+
exists: callback("exists"),
|
|
45
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node's `fs` module: synchronous file and directory operations backed by
|
|
3
|
-
* `runtime/ext_node/fs`,
|
|
4
|
-
*
|
|
5
|
-
* `readFile`/`writeFile` forms are not supported; `*Sync` and `fs.promises` are.
|
|
3
|
+
* `runtime/ext_node/fs`, the callback forms (`readFile`, `writeFile`, `stat`,
|
|
4
|
+
* …) built on the asynchronous I/O pool, and the `fs.promises` namespace.
|
|
6
5
|
* `watch`/`watchFile` return API-shaped watchers that never emit.
|
|
7
6
|
*
|
|
8
7
|
* `fs.constants` and `fs.promises` are exposed as value getters, so both
|
|
@@ -16,9 +15,16 @@ import type { ModuleExports } from "../../registry.js";
|
|
|
16
15
|
import { readFileBuiltins } from "./read-file.js";
|
|
17
16
|
import { writeFileBuiltins } from "./write-file.js";
|
|
18
17
|
import { fsOpsBuiltins } from "./fs-ops.js";
|
|
18
|
+
import { fsCallbackBuiltins } from "./callbacks.js";
|
|
19
19
|
import { fsStreamBuiltins } from "./streams.js";
|
|
20
20
|
|
|
21
|
-
const builtins = {
|
|
21
|
+
const builtins = {
|
|
22
|
+
...readFileBuiltins,
|
|
23
|
+
...writeFileBuiltins,
|
|
24
|
+
...fsOpsBuiltins,
|
|
25
|
+
...fsCallbackBuiltins,
|
|
26
|
+
...fsStreamBuiltins,
|
|
27
|
+
};
|
|
22
28
|
|
|
23
29
|
const exports: ModuleExports = {
|
|
24
30
|
...builtins,
|
|
@@ -31,6 +37,7 @@ export const fsModule: NodeModule = {
|
|
|
31
37
|
runtimeSources: () => [
|
|
32
38
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/read_file.c"),
|
|
33
39
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/write_file.c"),
|
|
40
|
+
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/callbacks.c"),
|
|
34
41
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/fs_ops.c"),
|
|
35
42
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/fd_ops.c"),
|
|
36
43
|
resolveFrom(import.meta.url, "../../../../runtime/ext_node/fs/meta_ops.c"),
|
|
@@ -2,18 +2,40 @@
|
|
|
2
2
|
* Node's `process` object backed by `runtime/ext_node/process`.
|
|
3
3
|
*
|
|
4
4
|
* The compiler lowers `process.<method>(...)` to
|
|
5
|
-
* `xt_process_call(<method>, argc, argv)
|
|
6
|
-
* `xt_process_get(<property>)`
|
|
7
|
-
*
|
|
5
|
+
* `xt_process_call(<method>, argc, argv)`, `process.<property>` to
|
|
6
|
+
* `xt_process_get(<property>)` and `process.<property> = value` to
|
|
7
|
+
* `xt_process_set(<property>, value)` (see `NAMESPACE_STATICS` /
|
|
8
|
+
* `NAMESPACE_PROPERTIES` / `NAMESPACE_PROPERTY_SETTERS` in
|
|
9
|
+
* `src/codegen/generator/tables.ts`). Importing the module aliases that
|
|
8
10
|
* namespace (`import process from "process"`); named method exports dispatch
|
|
9
11
|
* through `xt_process_call`.
|
|
12
|
+
*
|
|
13
|
+
* The object is also an EventEmitter (`on`/`once`/`off`/`emit`, with "exit"
|
|
14
|
+
* fired before the process ends) and owns the three standard streams, so
|
|
15
|
+
* `process.stdin.setRawMode(true)` and `process.stdout.columns` reach the same
|
|
16
|
+
* singletons.
|
|
10
17
|
*/
|
|
11
18
|
|
|
12
19
|
import type { NodeModule } from "../module.js";
|
|
13
20
|
import { resolveFrom } from "../module.js";
|
|
14
21
|
import type { ModuleExports } from "../../registry.js";
|
|
15
22
|
|
|
16
|
-
const methods = [
|
|
23
|
+
const methods = [
|
|
24
|
+
"cwd",
|
|
25
|
+
"exit",
|
|
26
|
+
"uptime",
|
|
27
|
+
"hrtime",
|
|
28
|
+
"getuid",
|
|
29
|
+
"on",
|
|
30
|
+
"once",
|
|
31
|
+
"addListener",
|
|
32
|
+
"prependListener",
|
|
33
|
+
"off",
|
|
34
|
+
"removeListener",
|
|
35
|
+
"removeAllListeners",
|
|
36
|
+
"emit",
|
|
37
|
+
"nextTick",
|
|
38
|
+
] as const;
|
|
17
39
|
|
|
18
40
|
const exports: ModuleExports = Object.fromEntries(
|
|
19
41
|
methods.map((method) => [method, { namespace: "process", method }]),
|
|
@@ -22,7 +44,10 @@ const exports: ModuleExports = Object.fromEntries(
|
|
|
22
44
|
export const processModule: NodeModule = {
|
|
23
45
|
name: "process",
|
|
24
46
|
namespace: "process",
|
|
25
|
-
runtimeSources: () => [
|
|
47
|
+
runtimeSources: () => [
|
|
48
|
+
resolveFrom(import.meta.url, "../../../../runtime/ext_node/process/process.c"),
|
|
49
|
+
resolveFrom(import.meta.url, "../../../../runtime/ext_node/process/streams.c"),
|
|
50
|
+
],
|
|
26
51
|
builtins: () => ({}),
|
|
27
52
|
exports: () => exports,
|
|
28
53
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node's `stream/web` subpath module
|
|
2
|
+
* Node's `stream/web` subpath module.
|
|
3
|
+
*
|
|
4
|
+
* The WHATWG stream classes are implemented by the core runtime (`xt_streams.c`)
|
|
5
|
+
* and are also available as browser globals. This module re-exports the same
|
|
6
|
+
* constructors; only `ReadableStreamTee` and the compression streams stay
|
|
7
|
+
* Node-specific.
|
|
3
8
|
*/
|
|
4
9
|
|
|
5
10
|
import type { NodeModule } from "../module.js";
|
|
@@ -7,10 +12,60 @@ import { resolveFrom } from "../module.js";
|
|
|
7
12
|
import type { ModuleExports } from "../../registry.js";
|
|
8
13
|
|
|
9
14
|
const exports: ModuleExports = {
|
|
15
|
+
ReadableStream: {
|
|
16
|
+
symbol: "xt_readable_stream_ctor",
|
|
17
|
+
valueSymbol: "xt_readable_stream_constructor_value",
|
|
18
|
+
isConstructor: true,
|
|
19
|
+
},
|
|
20
|
+
ReadableStreamDefaultReader: { symbol: "xt_readable_stream_default_reader_ctor", isConstructor: true },
|
|
21
|
+
ReadableStreamBYOBReader: { symbol: "xt_readable_stream_byob_reader_ctor", isConstructor: true },
|
|
22
|
+
ReadableStreamBYOBRequest: { symbol: "xt_readable_stream_byob_request_ctor", isConstructor: true },
|
|
23
|
+
ReadableStreamDefaultController: {
|
|
24
|
+
symbol: "xt_readable_stream_default_controller_ctor",
|
|
25
|
+
isConstructor: true,
|
|
26
|
+
},
|
|
27
|
+
WritableStream: {
|
|
28
|
+
symbol: "xt_writable_stream_ctor",
|
|
29
|
+
valueSymbol: "xt_writable_stream_constructor_value",
|
|
30
|
+
isConstructor: true,
|
|
31
|
+
},
|
|
32
|
+
WritableStreamDefaultWriter: { symbol: "xt_writable_stream_default_writer_ctor", isConstructor: true },
|
|
33
|
+
WritableStreamDefaultController: {
|
|
34
|
+
symbol: "xt_writable_stream_default_controller_ctor",
|
|
35
|
+
isConstructor: true,
|
|
36
|
+
},
|
|
37
|
+
TransformStream: {
|
|
38
|
+
symbol: "xt_transform_stream_ctor",
|
|
39
|
+
valueSymbol: "xt_transform_stream_constructor_value",
|
|
40
|
+
isConstructor: true,
|
|
41
|
+
},
|
|
42
|
+
TransformStreamDefaultController: {
|
|
43
|
+
symbol: "xt_transform_stream_default_controller_ctor",
|
|
44
|
+
isConstructor: true,
|
|
45
|
+
},
|
|
46
|
+
ByteLengthQueuingStrategy: {
|
|
47
|
+
symbol: "xt_byte_length_queuing_strategy_ctor",
|
|
48
|
+
valueSymbol: "xt_byte_strategy_constructor_value",
|
|
49
|
+
isConstructor: true,
|
|
50
|
+
},
|
|
51
|
+
CountQueuingStrategy: {
|
|
52
|
+
symbol: "xt_count_queuing_strategy_ctor",
|
|
53
|
+
valueSymbol: "xt_count_strategy_constructor_value",
|
|
54
|
+
isConstructor: true,
|
|
55
|
+
},
|
|
56
|
+
TextEncoderStream: {
|
|
57
|
+
symbol: "xt_text_encoder_stream_ctor",
|
|
58
|
+
valueSymbol: "xt_text_encoder_stream_constructor_value",
|
|
59
|
+
isConstructor: true,
|
|
60
|
+
},
|
|
61
|
+
TextDecoderStream: {
|
|
62
|
+
symbol: "xt_text_decoder_stream_ctor",
|
|
63
|
+
valueSymbol: "xt_text_decoder_stream_constructor_value",
|
|
64
|
+
isConstructor: true,
|
|
65
|
+
},
|
|
66
|
+
CompressionStream: { symbol: "xt_compression_stream_ctor", isConstructor: true },
|
|
67
|
+
DecompressionStream: { symbol: "xt_decompression_stream_ctor", isConstructor: true },
|
|
10
68
|
ReadableStreamTee: { valueSymbol: "xt_stream_web_tee" },
|
|
11
|
-
ReadableStream: { symbol: "xt_stream_web_unsupported_ctor", isConstructor: true },
|
|
12
|
-
WritableStream: { symbol: "xt_stream_web_unsupported_ctor", isConstructor: true },
|
|
13
|
-
TransformStream: { symbol: "xt_stream_web_unsupported_ctor", isConstructor: true },
|
|
14
69
|
};
|
|
15
70
|
|
|
16
71
|
export const streamWebModule: NodeModule = {
|
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node's `worker_threads` module.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* A worker is a second process running the same executable (xbintsc has no
|
|
5
|
+
* threads; see `runtime/worker/`). The worker entry is the current program, so
|
|
6
|
+
* pass `import.meta.filename` and branch on `isMainThread`:
|
|
7
|
+
*
|
|
8
|
+
* if (isMainThread) {
|
|
9
|
+
* const worker = new Worker(import.meta.filename, { workerData: "ping" });
|
|
10
|
+
* worker.on("message", (reply) => console.log(reply));
|
|
11
|
+
* worker.postMessage("hello");
|
|
12
|
+
* } else {
|
|
13
|
+
* parentPort.on("message", (value) => parentPort.postMessage(value));
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* `MessageChannel` / `MessagePort` are local to a process; transferring a port
|
|
17
|
+
* to a worker is not implemented.
|
|
8
18
|
*/
|
|
9
19
|
|
|
10
20
|
import type { NodeModule } from "../module.js";
|
|
11
|
-
import { resolveFrom } from "../module.js";
|
|
12
21
|
import type { ModuleExports } from "../../registry.js";
|
|
13
22
|
|
|
14
23
|
const exports: ModuleExports = {
|
|
15
|
-
Worker: { symbol: "
|
|
16
|
-
isMainThread: { valueSymbol: "
|
|
17
|
-
workerData: { valueSymbol: "
|
|
18
|
-
parentPort: { valueSymbol: "
|
|
19
|
-
|
|
24
|
+
Worker: { symbol: "xt_wt_worker", isConstructor: true },
|
|
25
|
+
isMainThread: { valueSymbol: "xt_wt_is_main_thread" },
|
|
26
|
+
workerData: { valueSymbol: "xt_wt_worker_data" },
|
|
27
|
+
parentPort: { valueSymbol: "xt_wt_parent_port" },
|
|
28
|
+
MessageChannel: { symbol: "xt_wt_message_channel", isConstructor: true },
|
|
29
|
+
MessagePort: { symbol: "xt_wt_message_port", isConstructor: true },
|
|
30
|
+
receiveMessageOnPort: { symbol: "xt_wt_receive_message_on_port" },
|
|
31
|
+
markAsUncloneable: { symbol: "xt_wt_mark_as_uncloneable" },
|
|
20
32
|
};
|
|
21
33
|
|
|
22
34
|
export const workerThreadsModule: NodeModule = {
|
|
23
35
|
name: "worker_threads",
|
|
24
|
-
|
|
36
|
+
/** The transport lives in the core runtime; only the bindings are here. */
|
|
37
|
+
runtimeSources: () => [],
|
|
25
38
|
builtins: () => ({}),
|
|
26
39
|
exports: () => exports,
|
|
27
40
|
};
|