xbintsc 0.6.28 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/ast/common.d.ts +10 -0
- 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/source.js +4 -0
- package/dist/src/checker/source.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/help.d.ts +1 -1
- package/dist/src/cli/main.js +15 -3
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +29 -11
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/element-inline.d.ts +42 -0
- package/dist/src/codegen/generator/calls/element-inline.js +388 -0
- package/dist/src/codegen/generator/calls/element-inline.js.map +1 -0
- package/dist/src/codegen/generator/calls/invocation.js +95 -1
- 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/calls.d.ts +3 -1
- package/dist/src/codegen/generator/calls.js +3 -1
- package/dist/src/codegen/generator/calls.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +20 -3
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +24 -2
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/global-values.d.ts +19 -0
- package/dist/src/codegen/generator/expressions/global-values.js +49 -0
- package/dist/src/codegen/generator/expressions/global-values.js.map +1 -0
- 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.d.ts +0 -2
- package/dist/src/codegen/generator/expressions/primary.js +13 -29
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/expressions.d.ts +2 -1
- package/dist/src/codegen/generator/expressions.js +2 -1
- package/dist/src/codegen/generator/expressions.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/layout.d.ts +65 -0
- package/dist/src/codegen/generator/layout.js +50 -0
- package/dist/src/codegen/generator/layout.js.map +1 -0
- 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 +21 -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 +18 -12
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.js +1 -1
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/diagnostics/source-text.d.ts +37 -9
- package/dist/src/diagnostics/source-text.js +124 -23
- package/dist/src/diagnostics/source-text.js.map +1 -1
- package/dist/src/diagnostics/source.d.ts +16 -6
- package/dist/src/diagnostics/source.js +25 -4
- package/dist/src/diagnostics/source.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +14 -0
- package/dist/src/driver/build-key.js +6 -1
- package/dist/src/driver/build-key.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 +79 -8
- 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 +4 -4
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +43 -13
- 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 +11 -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/compiler.js +13 -3
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/config.d.ts +1 -1
- package/dist/src/driver/frontend.js +3 -4
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/options.d.ts +1 -4
- 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 +28 -5
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/toolchain.js +28 -5
- package/dist/src/driver/toolchain.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/gui/html.js +42 -10
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +48 -0
- package/dist/src/extensions/gui/index.js.map +1 -1
- 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/registry.d.ts +27 -0
- package/dist/src/extensions/registry.js +13 -4
- package/dist/src/extensions/registry.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/expressions.js +2 -2
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/src/parser/helpers.d.ts +8 -0
- package/dist/src/parser/helpers.js +21 -0
- package/dist/src/parser/helpers.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/cli/main.test.js +9 -0
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/codegen/element-layout.test.d.ts +19 -0
- package/dist/tests/codegen/element-layout.test.js +80 -0
- package/dist/tests/codegen/element-layout.test.js.map +1 -0
- package/dist/tests/codegen/expressions.test.js +25 -0
- package/dist/tests/codegen/expressions.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +28 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/diagnostics/diagnostic.test.js +9 -0
- package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
- package/dist/tests/diagnostics/source-text.test.d.ts +1 -0
- package/dist/tests/diagnostics/source-text.test.js +50 -0
- package/dist/tests/diagnostics/source-text.test.js.map +1 -0
- package/dist/tests/diagnostics/source.test.js +17 -0
- package/dist/tests/diagnostics/source.test.js.map +1 -1
- package/dist/tests/driver/build-key.test.d.ts +1 -0
- package/dist/tests/driver/build-key.test.js +49 -0
- package/dist/tests/driver/build-key.test.js.map +1 -0
- 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/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/driver/toolchain.test.js +8 -1
- package/dist/tests/driver/toolchain.test.js.map +1 -1
- package/dist/tests/driver/usage.test.js +2 -1
- package/dist/tests/driver/usage.test.js.map +1 -1
- package/dist/tests/e2e/async-await.test.js +16 -0
- package/dist/tests/e2e/async-await.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-builtins.test.js +29 -0
- package/dist/tests/e2e/compile-builtins.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 +53 -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-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/compile-prototype-chain.test.d.ts +8 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js +24 -0
- package/dist/tests/e2e/compile-prototype-chain.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/differential-language.test.js +25 -0
- package/dist/tests/e2e/differential-language.test.js.map +1 -1
- package/dist/tests/e2e/differential-values.test.js +59 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/fetch.test.js +1 -1
- package/dist/tests/e2e/gc.test.js +22 -0
- package/dist/tests/e2e/gc.test.js.map +1 -1
- package/dist/tests/e2e/gui-audio-extra.test.d.ts +12 -0
- package/dist/tests/e2e/gui-audio-extra.test.js +185 -0
- package/dist/tests/e2e/gui-audio-extra.test.js.map +1 -0
- package/dist/tests/e2e/gui-browser.test.js +35 -2
- package/dist/tests/e2e/gui-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-dom.test.js +88 -0
- package/dist/tests/e2e/gui-dom.test.js.map +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/gui-webgl-declarations.test.d.ts +13 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js +136 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js +86 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-blit.test.js +6 -2
- package/dist/tests/e2e/gui-webgl2-blit.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js +157 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js +344 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.d.ts +15 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js +287 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.js +59 -1
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -1
- package/dist/tests/e2e/hang-watchdog.test.d.ts +10 -0
- package/dist/tests/e2e/hang-watchdog.test.js +50 -0
- package/dist/tests/e2e/hang-watchdog.test.js.map +1 -0
- 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/method-call-cache.test.d.ts +5 -0
- package/dist/tests/e2e/method-call-cache.test.js +65 -0
- package/dist/tests/e2e/method-call-cache.test.js.map +1 -0
- 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/performance-now.test.d.ts +9 -0
- package/dist/tests/e2e/performance-now.test.js +36 -0
- package/dist/tests/e2e/performance-now.test.js.map +1 -0
- package/dist/tests/e2e/property-ic.test.js +33 -0
- package/dist/tests/e2e/property-ic.test.js.map +1 -1
- 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/shape-interning.test.d.ts +16 -0
- package/dist/tests/e2e/shape-interning.test.js +55 -0
- package/dist/tests/e2e/shape-interning.test.js.map +1 -0
- package/dist/tests/e2e/string-utf16.test.js +9 -0
- package/dist/tests/e2e/string-utf16.test.js.map +1 -1
- package/dist/tests/e2e/typed-array-views.test.js +26 -0
- package/dist/tests/e2e/typed-array-views.test.js.map +1 -1
- package/dist/tests/e2e/url-search-params.test.js +19 -0
- package/dist/tests/e2e/url-search-params.test.js.map +1 -1
- package/dist/tests/e2e/web-streams.test.js +44 -29
- package/dist/tests/e2e/web-streams.test.js.map +1 -1
- package/dist/tests/extensions/gui.test.js +16 -1
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +36 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- 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 +1 -0
- package/doc/ai/contributing.md +8 -5
- package/doc/ai/extensions.md +12 -3
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/troubleshooting.md +14 -0
- package/doc/ai/zh-CN/cli.md +1 -0
- package/doc/ai/zh-CN/contributing.md +6 -3
- package/doc/ai/zh-CN/extensions.md +10 -2
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/ai/zh-CN/troubleshooting.md +12 -0
- package/doc/gui/api.md +26 -4
- package/doc/gui/dom.md +8 -0
- package/doc/gui/known-issues.md +35 -6
- package/doc/gui/runtime.md +16 -1
- package/doc/gui/webgl.md +97 -26
- package/doc/gui-scripts.md +2 -1
- package/doc/gui.md +8 -5
- package/doc/implemented/binder.md +2 -1
- package/doc/implemented/checker.md +14 -0
- package/doc/implemented/codegen.md +7 -0
- 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.md +7 -1
- package/doc/implemented/operators.md +3 -1
- package/doc/implemented/parser.md +3 -2
- package/doc/implemented/runtime-core.md +13 -2
- package/doc/implemented/stdlib.md +79 -4
- package/doc/implemented/typed-arrays.md +18 -2
- package/doc/unimplemented/classes.md +1 -0
- package/doc/unimplemented/modules.md +1 -0
- package/doc/unimplemented/stdlib.md +2 -1
- package/doc/xbintsc.config.schema.json +5 -0
- package/doc/zh-CN/gui/api.md +19 -5
- package/doc/zh-CN/gui/dom.md +6 -0
- package/doc/zh-CN/gui/known-issues.md +24 -5
- package/doc/zh-CN/gui/runtime.md +13 -1
- package/doc/zh-CN/gui/webgl.md +20 -7
- package/doc/zh-CN/gui-scripts.md +2 -1
- package/doc/zh-CN/gui.md +4 -1
- package/doc/zh-CN/implemented/binder.md +2 -1
- package/doc/zh-CN/implemented/checker.md +10 -0
- package/doc/zh-CN/implemented/codegen.md +7 -0
- 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.md +1 -1
- package/doc/zh-CN/implemented/operators.md +2 -1
- package/doc/zh-CN/implemented/parser.md +3 -2
- package/doc/zh-CN/implemented/runtime-core.md +10 -2
- package/doc/zh-CN/implemented/stdlib.md +64 -4
- package/doc/zh-CN/implemented/typed-arrays.md +14 -2
- package/doc/zh-CN/unimplemented/classes.md +1 -0
- package/doc/zh-CN/unimplemented/modules.md +1 -0
- package/doc/zh-CN/unimplemented/stdlib.md +2 -1
- package/package.json +7 -7
- package/runtime/ext_gui/audio.cpp +39 -3
- package/runtime/ext_gui/audio_extra.cpp +353 -0
- package/runtime/ext_gui/audio_extra.h +47 -0
- package/runtime/ext_gui/audio_fft.h +76 -0
- package/runtime/ext_gui/audio_internal.h +21 -0
- package/runtime/ext_gui/audio_mixer.cpp +46 -1
- package/runtime/ext_gui/audio_mixer.h +89 -1
- package/runtime/ext_gui/audio_mixer_extra.cpp +126 -0
- package/runtime/ext_gui/audio_nodes.cpp +242 -0
- package/runtime/ext_gui/audio_nodes_internal.h +81 -0
- package/runtime/ext_gui/audio_nodes_spatial.cpp +375 -0
- package/runtime/ext_gui/browser.cpp +9 -0
- package/runtime/ext_gui/browser_screen.cpp +73 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +9 -1
- package/runtime/ext_gui/dom_api_internal.h +3 -0
- package/runtime/ext_gui/dom_api_node.cpp +21 -0
- package/runtime/ext_gui/dom_api_node_read.cpp +29 -0
- package/runtime/ext_gui/dom_api_proto.cpp +3 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +16 -11
- package/runtime/ext_gui/dom_api_webgl2_msaa.cpp +64 -0
- package/runtime/ext_gui/dom_api_webgl_compressed.cpp +2 -2
- package/runtime/ext_gui/dom_api_webgl_framebuffer.cpp +68 -11
- package/runtime/ext_gui/dom_api_webgl_methods.h +3 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +4 -2
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +6 -6
- package/runtime/ext_gui/gui.cpp +6 -1
- package/runtime/ext_gui/gui_engine.h +2 -0
- package/runtime/ext_gui/gui_events.cpp +13 -8
- package/runtime/ext_gui/gui_webgl.cpp +3 -2
- package/runtime/ext_gui/style_ua.cpp +4 -0
- package/runtime/ext_gui/warnings.cpp +1 -1
- package/runtime/ext_gui/webgl.h +102 -7
- package/runtime/ext_gui/webgl_api.h +3 -2
- package/runtime/ext_gui/webgl_blit.cpp +109 -15
- package/runtime/ext_gui/webgl_blit_color.cpp +264 -0
- package/runtime/ext_gui/webgl_blit_depth.cpp +26 -8
- package/runtime/ext_gui/webgl_buffer.cpp +20 -170
- package/runtime/ext_gui/webgl_context.cpp +117 -169
- package/runtime/ext_gui/webgl_draw.cpp +116 -5
- package/runtime/ext_gui/webgl_draw_buffers.cpp +21 -6
- package/runtime/ext_gui/webgl_draw_setup.cpp +1 -0
- package/runtime/ext_gui/webgl_draw_state.h +2 -0
- package/runtime/ext_gui/webgl_feature.cpp +2 -2
- package/runtime/ext_gui/webgl_feature.h +4 -3
- package/runtime/ext_gui/webgl_framebuffer.cpp +346 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +78 -47
- package/runtime/ext_gui/webgl_objects.h +16 -2
- package/runtime/ext_gui/webgl_pipeline.cpp +1 -1
- package/runtime/ext_gui/webgl_state.cpp +45 -36
- package/runtime/ext_gui/webgl_targets.cpp +440 -0
- package/runtime/ext_gui/webgl_texture.cpp +81 -25
- package/runtime/ext_gui/window.cpp +8 -0
- 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/rt.h +63 -27
- package/runtime/rt_binary.h +44 -0
- package/runtime/rt_internal.h +61 -69
- package/runtime/rt_object.h +83 -0
- package/runtime/rt_profile.h +45 -0
- package/runtime/xt_alloc.c +154 -181
- package/runtime/xt_array_buffer.c +99 -71
- package/runtime/xt_async_io.c +3 -0
- package/runtime/xt_builtins.c +29 -24
- package/runtime/xt_constructors.c +102 -2
- package/runtime/xt_containers/access.inc +125 -12
- package/runtime/xt_containers/arrays.inc +2 -1
- package/runtime/xt_containers/cstr_cache.inc +56 -0
- package/runtime/xt_containers/function_prototypes.inc +58 -0
- package/runtime/xt_containers/method_cache.inc +121 -0
- package/runtime/xt_containers/object_keys.inc +58 -0
- package/runtime/xt_containers/objects.inc +59 -75
- package/runtime/xt_containers/shapes.inc +153 -8
- package/runtime/xt_containers.c +5 -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_release.c +70 -0
- package/runtime/xt_gc_stack.c +83 -0
- package/runtime/xt_gc_verify.c +136 -0
- package/runtime/xt_intl.c +224 -0
- package/runtime/xt_io/console.inc +66 -0
- package/runtime/xt_io/exception.inc +66 -1
- package/runtime/xt_io/watchdog.inc +101 -0
- package/runtime/xt_io.c +1 -0
- package/runtime/xt_loop.c +23 -3
- package/runtime/xt_module_values.c +82 -0
- package/runtime/xt_pool.c +151 -0
- package/runtime/xt_profile.c +126 -0
- package/runtime/xt_proxy.c +140 -0
- package/runtime/xt_stdlib/dispatch.inc +104 -9
- package/runtime/xt_stdlib/math.inc +272 -57
- package/runtime/xt_stdlib2/date.inc +7 -1
- package/runtime/xt_stdlib2/json.inc +28 -0
- package/runtime/xt_stdlib2/json_stringify.inc +71 -55
- package/runtime/xt_stdlib2/regexp-match.inc +17 -0
- package/runtime/xt_storage/indexed_db.c +4 -1
- package/runtime/xt_structured_clone.c +2 -1
- package/runtime/xt_typed_array/construction.inc +10 -0
- package/runtime/xt_typed_array/elements.inc +43 -23
- package/runtime/xt_url.c +50 -0
- package/runtime/xt_values/constructors.inc +4 -1
- package/runtime/xt_values/strings.inc +3 -1
- package/runtime/xt_web.h +27 -0
- package/runtime/xt_web_abort.c +373 -0
- package/scripts/build-runtime.ts +8 -0
- package/src/ast/common.ts +10 -0
- package/src/binder/declarations.ts +34 -0
- package/src/binder/references.ts +12 -0
- package/src/checker/globals.ts +1 -0
- package/src/checker/source.ts +3 -0
- package/src/checker/type-system.ts +23 -3
- package/src/cli/main.ts +14 -3
- package/src/codegen/generator/calls/access.ts +28 -10
- package/src/codegen/generator/calls/element-inline.ts +433 -0
- package/src/codegen/generator/calls/invocation.ts +99 -1
- package/src/codegen/generator/calls/super.ts +5 -4
- package/src/codegen/generator/calls/unwrap.ts +47 -0
- package/src/codegen/generator/calls.ts +5 -0
- package/src/codegen/generator/debug.ts +21 -3
- package/src/codegen/generator/expressions/assignment.ts +26 -2
- package/src/codegen/generator/expressions/global-values.ts +57 -0
- package/src/codegen/generator/expressions/module-values.ts +57 -19
- package/src/codegen/generator/expressions/primary.ts +13 -36
- package/src/codegen/generator/expressions.ts +3 -0
- package/src/codegen/generator/generator.ts +4 -0
- package/src/codegen/generator/layout.ts +54 -0
- package/src/codegen/generator/lookup-tables.ts +63 -0
- package/src/codegen/generator/module.ts +38 -7
- package/src/codegen/generator/state.ts +22 -0
- package/src/codegen/generator/tables.ts +18 -12
- package/src/diagnostics/diagnostic.ts +1 -1
- package/src/diagnostics/source-text.ts +118 -22
- package/src/diagnostics/source.ts +29 -7
- package/src/driver/build-key.ts +21 -1
- package/src/driver/bundler/commonjs.ts +12 -5
- package/src/driver/bundler/concatenate.ts +96 -12
- package/src/driver/bundler/deferred.ts +122 -6
- package/src/driver/bundler/dynamic-import.ts +75 -2
- package/src/driver/bundler/graph.ts +4 -4
- package/src/driver/bundler/merge.ts +42 -9
- package/src/driver/bundler/namespace-object.ts +44 -0
- package/src/driver/bundler/reexport-resolution.ts +14 -2
- package/src/driver/bundler/symbols.ts +17 -0
- package/src/driver/compiler.ts +14 -3
- package/src/driver/config.ts +1 -1
- package/src/driver/frontend.ts +3 -4
- package/src/driver/options.ts +1 -4
- package/src/driver/runtime-lib.ts +87 -2
- package/src/driver/runtime-objects.ts +28 -5
- package/src/driver/toolchain.ts +28 -5
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/html.ts +41 -11
- package/src/extensions/gui/index.ts +50 -1
- 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/registry.ts +41 -4
- package/src/lexer/scanner.ts +16 -1
- package/src/parser/context.ts +39 -3
- package/src/parser/expressions.ts +2 -2
- package/src/parser/helpers.ts +22 -0
- package/src/parser/literals.ts +6 -2
|
@@ -32,7 +32,9 @@ Location: `src/codegen/llvm.ts` (`BINARY_RUNTIME`, `emitPrefix`, `emitPostfix`,
|
|
|
32
32
|
|
|
33
33
|
- Comma expression `,` (lowers to a `SequenceExpression`: every operand is
|
|
34
34
|
evaluated left to right and the value of the last one is the result)
|
|
35
|
-
- `in` operator (`key in obj`, mapped to `xt_in`)
|
|
35
|
+
- `in` operator (`key in obj`, mapped to `xt_in`): own properties, built-in
|
|
36
|
+
methods and the whole prototype chain, so `"map" in []` and `"slice" in "abc"`
|
|
37
|
+
behave like JavaScript
|
|
36
38
|
- `delete obj.key` / `delete obj[key]` (mapped to `xt_delete`)
|
|
37
39
|
- `instanceof` (mapped to `xt_instance_of`, walking the prototype chain)
|
|
38
40
|
|
|
@@ -9,7 +9,7 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
|
|
|
9
9
|
## Statements
|
|
10
10
|
|
|
11
11
|
- Variable declarations: `var` / `let` / `const`, with multiple declarators `const a = 1, b = 2;`
|
|
12
|
-
- Function declarations, function expressions and methods, including the `async` modifier, generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`) and async generators (`async function*`, `for await...of`)
|
|
12
|
+
- Function declarations, function expressions and methods, including the `async` modifier, generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`) and async generators (`async function*`, `for await...of`). A `yield` with no operand is an expression too: `yield` followed by `,`, a closing bracket/brace/paren, `;` or a line break yields `undefined`, which is how a minified generator is written (`yield, doThing(), yield`)
|
|
13
13
|
- `class` declarations / class expressions (constructor, fields, methods, `static`, `static { ... }` blocks, `extends`)
|
|
14
14
|
- `if` / `else`
|
|
15
15
|
- `while`, `do...while`
|
|
@@ -29,7 +29,7 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
|
|
|
29
29
|
- Conditional (ternary) expressions `a ? b : c`
|
|
30
30
|
- Comma / sequence expressions `a, b, c` (in `for` headers, parenthesized groups and expression statements)
|
|
31
31
|
- Arrow functions `() => expr` / `() => { ... }` (including type parameters and return type annotations)
|
|
32
|
-
- Function expressions `function () {}` and named function expressions `function g() {}` (also `async function` expressions)
|
|
32
|
+
- Function expressions `function () {}` and named function expressions `function g() {}` (also `async function` expressions); the name may be a contextual keyword (`function get() {}`, `function constructor() {}`), like a class expression name
|
|
33
33
|
- Call expressions `f(...)`, member access `a.b`, element access `a[i]`
|
|
34
34
|
- Array literals `[1, 2]`, sparse array elision, spread `[...a]` (also over strings, `Map` and `Set`)
|
|
35
35
|
- Object literals `{ a: 1 }`, shorthand properties `{ a }`, method shorthand `{ m() {} }`, getter / setter shorthand `{ get x() {} }` / `{ set x(v) {} }`, computed keys `{ [expr]: 1 }`, object spread `{ ...obj }`
|
|
@@ -57,3 +57,4 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
|
|
|
57
57
|
## ASI
|
|
58
58
|
|
|
59
59
|
- Automatic Semicolon Insertion, based on `precededByLineBreak` / `}` / EOF.
|
|
60
|
+
|
|
@@ -16,7 +16,15 @@ standard-library surface have their own pages:
|
|
|
16
16
|
- [Async, promises and generators](./async.md)
|
|
17
17
|
- [fetch](./fetch.md)
|
|
18
18
|
|
|
19
|
-
- Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan).
|
|
19
|
+
- Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan). Collection is deferred while a bundle's module bodies run (`xt_gc_begin_startup` raises the threshold to 512 MiB until `xt_gc_end_startup`): a large module graph is built entirely inside one generated function, and collecting in the middle of it has corrupted live objects. `XT_GC_THRESHOLD` still overrides both values. The next threshold is **4×** the surviving heap: an interactive scene keeps a large live set for minutes, and at 2× a three.js page collected once every ~1.2 s; 4× halves the number of stop-the-world pauses while the threshold still follows (and shrinks with) the live set, so it cannot ratchet upwards. `XT_GC_TRACE=1` prints each collection's heap, allocation and live-kind counts plus its `took <ms>` broken into table/mark/sweep phases. Two environment switches exist for this class of bug: `XT_GC_VERIFY=1` re-scans
|
|
20
|
+
every marked object's payload before the sweep and prints any block it
|
|
21
|
+
references that stayed unmarked (a tracer or root gap), and the crash report
|
|
22
|
+
names a fault address that falls inside a block the collector freed. I/O worker threads allocate result values but never collect (`xt_gc_worker_thread`): the collector scans the main stack region and is not thread-safe, and a block born during a collection is marked so the sweep keeps it.
|
|
23
|
+
- Small-block allocation: blocks up to 2 KiB (most objects, closures, strings, and the property/array buffers behind them) come from per-size-class free lists carved out of 1 MiB slabs instead of `malloc`/`calloc`; the collector returns a block to its class, so a steady state reuses memory and object-heavy scene code stops paying a C allocator round trip per object. Large blocks keep `malloc`/`free`, I/O workers keep `calloc` (the pool is main-thread only), and a pooled block is marked by `XT_GC_POOLED` so the sweep releases it correctly.
|
|
24
|
+
- Tracing is **precise** for the kinds a program allocates in bulk: an `xt_object` marks its prototype, error stack and each property's key/value/getter/setter, an array its items and `extra`, a function its name bag, prototype and environment, and maps/sets/regexps their element arrays. Only the exotic kinds (iterators, symbols) still use the conservative payload scan. `xt_gc_mark_value` rejects every number with one tag compare, so marking a 400k-object scene does not spend its time in five `XT_IS_*` branches per property slot.
|
|
25
|
+
- The C-string property lookups behind the host bindings (`xt_object_get_cstr(w, "__xt_gl_context")`, the typed-array helpers, the runtime's own helpers) intern the key contents in a small, GC-rooted table instead of allocating an `xt_string` per call. This was the dominant allocation source for a WebGL page: the Saltline boot made ~24M such calls, and after the table the same run makes ~165k calls and allocates ~192k strings in total, roughly two orders of magnitude less garbage for the collector to sweep.
|
|
26
|
+
- Time: `performance.now()` returns milliseconds since the **program's** time origin, like a browser's navigation start or Node's process start, not the raw monotonic counter (on Windows the QPC counts from machine boot, so a process started six days into an uptime used to report six days on its first call). `xt_time_init()` snapshots the origin from the generated `main`, and animation-frame callbacks receive the same clock.
|
|
27
|
+
- Profiling: `XT_PROFILE=1` counts entries to the hottest runtime helpers (allocation, collection, property get/set, method dispatch, closure calls, array element reads, typed-array reads/writes, `Math` dispatch) and prints them to stderr at exit. It also breaks allocations down by object kind and lists the twenty most frequent C-string property names, which attributes allocation pressure to a helper or a key without a sampling profiler. The counters cost one branch when enabled and nothing when unset; pair them with a microbenchmark of the same helper to attribute time.
|
|
20
28
|
- Value construction: `xt_undefined/xt_null/xt_bool/xt_number/xt_string_new/xt_string_from_cstr`.
|
|
21
29
|
- Type conversion: `xt_truthy`, `xt_to_number`, `xt_to_string`, `xt_typeof`.
|
|
22
30
|
- Arithmetic: `add/sub/mul/div/mod/pow/neg/pos`.
|
|
@@ -28,5 +36,8 @@ standard-library surface have their own pages:
|
|
|
28
36
|
- Operator helpers: `xt_in` (`in`), `xt_delete` (`delete`), `xt_rest_args` (rest parameters / `arguments`).
|
|
29
37
|
- Box: `box_new/get/set` (for closure-captured variables).
|
|
30
38
|
- Functions and closures: `arg`, `closure_new/call/env/arity`.
|
|
31
|
-
- Exceptions: `xt_try_enter` / `xt_try_exception` / `xt_try_leave` maintain the `_setjmp` frame stack; `xt_throw` long-jumps to the nearest `try` when a frame exists, otherwise prints `Uncaught ...` and exits. A promise rejection nobody observes is fatal too: `xt_promise_report_unhandled` runs once the event loop drains, prints `Unhandled promise rejection` plus the reason and exits with status 1 (see [Async](./async.md)). Codegen also maintains a shadow call stack (function name, source file and line) that `Error.stack` captures (see [Standard library](./stdlib.md)), and a fatal-signal handler dumps the same frames on a native crash. `--debug` additionally emits `!DICompileUnit` / `!DISubprogram` / `!DILocation` metadata and compiles with `-g -fno-omit-frame-pointer`, so gdb/lldb/WinDbg map instructions back to source lines.
|
|
39
|
+
- Exceptions: `xt_try_enter` / `xt_try_exception` / `xt_try_leave` maintain the `_setjmp` frame stack; `xt_throw` long-jumps to the nearest `try` when a frame exists, otherwise prints `Uncaught ...` and exits. A promise rejection nobody observes is fatal too: `xt_promise_report_unhandled` runs once the event loop drains, prints `Unhandled promise rejection` plus the reason and exits with status 1 (see [Async](./async.md)). Codegen also maintains a shadow call stack (function name, source file and line) that `Error.stack` captures (see [Standard library](./stdlib.md)), and a fatal-signal handler dumps the same frames on a native crash. While a bundle's module bodies run, the stack names the module being initialised (` module: <path>` above the frames): every module shares one generated function, so its frames alone all carry the entry file's coordinates. Setting `XT_STACK_WATCHDOG_MS=<n>` starts a sampler thread that prints those frames whenever no function has been entered or left for *n* milliseconds, turning a silent hang (an unexpected infinite loop, a blocking host call) into a source location; the thread is not started when the variable is unset. `--debug` additionally emits `!DICompileUnit` / `!DISubprogram` / `!DILocation` metadata and compiles with `-g -fno-omit-frame-pointer`, so gdb/lldb/WinDbg map instructions back to source lines. `!DILocation` has a 16-bit `column` field, so a column from a minified bundle (they run to hundreds of thousands) is clamped to 65535 instead of making clang reject the module; the line is clamped to the 24-bit limit for the same reason.
|
|
40
|
+
- Typed pointers that the collector follows from inside a struct (a promise's reaction list, an active coroutine frame, a string's rope children) are validated against the heap table before marking, so a stale one is skipped instead of dereferenced (`XT_GC_VERIFY=1` reports it).
|
|
41
|
+
- A lazily built value (`Function.prototype[Symbol.hasInstance]`, a prototype cache, `console`, `JSON`, a symbol registry) registers its static slot as a root **before** the allocations that build the value. A static is outside the conservative stack scan, so a collection between storing the value and registering the slot sweeps an object the program still holds; the stale slot then marks a freed block, which on Windows (where the compiler kept no stack copy) corrupted the small-block free list and crashed the next `xt_pool_alloc`.
|
|
32
42
|
- Objects / functions: `xt_object` with a prototype chain, `xt_function` with a property bag (static members and `prototype`); `xt_new` (instantiation), `xt_instance_of` (prototype chain), `xt_object_freeze/is_frozen/from_entries`; `xt_constructors.c` holds the first-class constructor cache, constructor prototypes and static-value dispatch.
|
|
43
|
+
|
|
@@ -19,6 +19,31 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
19
19
|
- `Object.freeze` / `is_frozen` / `from_entries`, `Object.getPrototypeOf`.
|
|
20
20
|
- `Object.prototype`: `hasOwnProperty` / `toString` / `valueOf` / `isPrototypeOf` / `propertyIsEnumerable` / `__proto__`; `Object.getPrototypeOf({}) === Object.prototype`.
|
|
21
21
|
- First-class built-in constructors (`const A = Array`, `new A(...)`, `A.isArray`, `x instanceof A`) are covered in [Codegen](./codegen.md#llvm-ir-code-generation-codegen).
|
|
22
|
+
- A function value's `.prototype` is created on first read (with a
|
|
23
|
+
`constructor` back-reference) and shared by every closure of one declaration, so
|
|
24
|
+
the ES5 pattern `function Foo() {}; Foo.prototype.bar = ...; new Foo().bar()`
|
|
25
|
+
works. Function *values* are still fresh per reference (`Foo === Foo` is false).
|
|
26
|
+
- `Object.getOwnPropertyNames` / `Object.keys` report no own string keys for
|
|
27
|
+
`Map` / `Set` / `Date` / `RegExp` / `Promise` / `Symbol` instead of reading past
|
|
28
|
+
their allocation.
|
|
29
|
+
|
|
30
|
+
## `globalThis` and `Intl`
|
|
31
|
+
|
|
32
|
+
- `globalThis.x` / `global.x` read a *known* global as the bare name
|
|
33
|
+
(`globalThis.fetch`, `globalThis.Deno`); any other property is an ordinary
|
|
34
|
+
read on the global object, so `globalThis.missing` is `undefined` and
|
|
35
|
+
`global[key] = v` round-trips.
|
|
36
|
+
- `globalThis` (and Node's alias `global`) is a value: one plain property bag
|
|
37
|
+
shared by both spellings, so `const g = globalThis`, `globalThis.x = 1` and
|
|
38
|
+
publishing state under a symbol key on `global` all work. It is not the
|
|
39
|
+
runtime's scope object — a name the compiler does not resolve is `undefined`
|
|
40
|
+
even when a library wrote it with `global.foo = ...`.
|
|
41
|
+
- `Intl.Segmenter` with `granularity: "grapheme" | "word"`; `segment(text)`
|
|
42
|
+
returns an **array** of `{ segment, index, isWordLike }`. It is a documented
|
|
43
|
+
approximation of UAX #29 (no ICU): graphemes are code points plus combining
|
|
44
|
+
marks, variation selectors, emoji modifiers, ZWJ sequences and regional
|
|
45
|
+
indicator pairs; words are runs of whitespace, word characters and punctuation.
|
|
46
|
+
`resolvedOptions()` reports `{ locale: "en", granularity }`.
|
|
22
47
|
|
|
23
48
|
## Arrays
|
|
24
49
|
|
|
@@ -31,25 +56,28 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
31
56
|
|
|
32
57
|
- Number formatting and coercion match Node: `toFixed` / `toPrecision` / `toExponential`, hex / octal / binary parsing, and the full `+` / relational `ToPrimitive` rules. These are covered by the differential tests.
|
|
33
58
|
- `BigInt` literals and values: arbitrary precision arithmetic, bitwise and shift operators, comparisons, `toString(radix)`, `BigInt()`, `BigInt.asIntN` / `BigInt.asUintN`.
|
|
34
|
-
- `Math`: the full function set and constants.
|
|
59
|
+
- `Math`: the full function set and constants. `Math.hypot(...values)` accepts any number of arguments (ECMA-262 21.3.2.18): every argument participates, a `NaN` wins and the sum is scaled by the largest magnitude so `hypot(1e308, 1e308)` does not overflow.
|
|
60
|
+
- `Math.cbrt` uses the runtime's own fdlibm implementation (the version V8 ships) rather than the host libm, whose low bits vary: glibc computes `Math.cbrt(27)` as `3.0000000000000004`. Results are therefore bit-identical with Node on every host.
|
|
61
|
+
- `Math` call sites dispatch on the first byte of the member name before comparing the full name, so `Math.imul` / `floor` / `exp` in a numeric loop no longer pay for a linear `strcmp` chain (procedural texture and geometry code calls them hundreds of millions of times; removing the chain halved level setup on a bundled three.js page).
|
|
35
62
|
- `Math` is also a first-class object: `const cos = Math.cos`, `[1, 2].map(Math.max)` and `const { sqrt, PI } = Math` read members as values (`xt_math_object()` caches one native closure per function, so reads stay cheap).
|
|
36
63
|
- `Number` statics and `Number()` conversion; `parseInt` / `parseFloat` / `isNaN` / `isFinite`.
|
|
37
64
|
|
|
38
65
|
## JSON
|
|
39
66
|
|
|
40
67
|
- `JSON.parse` with a `reviver`; malformed input (bad numbers/strings, trailing text, missing separators) throws a catchable `SyntaxError` instead of returning `undefined`.
|
|
41
|
-
- `JSON.stringify` with a function or array `replacer`, `toJSON`, and `space` (number or string, clamped to 10). `undefined` / function / symbol values follow the standard omission rules.
|
|
68
|
+
- `JSON.stringify` with a function or array `replacer`, `toJSON`, and `space` (number or string, clamped to 10). `toJSON` runs for every object and receives the property key (`""` at the top level, the index for an array element), before the value is inspected, so a value whose `toJSON` returns `undefined` is omitted from an object and becomes `null` in an array. `undefined` / function / symbol values follow the standard omission rules.
|
|
42
69
|
- Object keys are emitted in insertion order, with integer keys ordered numerically; circular references throw.
|
|
43
70
|
|
|
44
71
|
## Date
|
|
45
72
|
|
|
46
|
-
- `Date` backed by `gmtime_r`; ISO 8601 parsing through `Date.parse` / `new Date(string)`.
|
|
73
|
+
- `Date` backed by `gmtime_r`; ISO 8601 parsing through `Date.parse` / `new Date(string)`. `toJSON` returns `null` for an invalid (NaN) time instead of throwing.
|
|
47
74
|
- `toLocaleDateString` / `toLocaleTimeString` / `toLocaleString` format the local time (`M/D/YYYY`, `h:mm:ss AM`); a small options subset (`weekday`/`year`/`month`/`day`/`hour`/`minute`/`second`/`hour12`) is honoured. `toDateString` / `toTimeString` / `toUTCString` are available too, and an invalid date formats as `Invalid Date`.
|
|
48
75
|
|
|
49
76
|
## RegExp
|
|
50
77
|
|
|
51
78
|
- `RegExp` uses the runtime's self-contained POSIX-ERE-compatible matcher (`regcomp` / `regexec` style) on every host, so results do not depend on the platform's libc. Capture groups are exposed through `exec` / `match` / `replace` / `split` / `search`.
|
|
52
79
|
- Quantifiers include `*`, `+`, `?` and the counted forms `{n}`, `{n,}` and `{n,m}` (with a lazy `?` suffix). Malformed brace groups such as `{x}` and `{,2}` stay literal, as in JavaScript; an inverted range such as `{2,1}` is also treated as literal instead of being rejected.
|
|
80
|
+
- A JavaScript pattern is translated for the matcher first (`\d`/`\w`/`\s` → classes, `(?:` → a capturing group, control-character escapes → literals). Any other escape is a **literal character** and keeps its backslash, so `\[`, `\]`, `\(`, `\.`, `\+` match those characters and do not start syntax: `"x[ i ]y".replace(/\[\s*i\s*\]/g, …)` behaves like Node. three.js's `unrollLoops` depends on exactly that shape.
|
|
53
81
|
- Matching is byte-oriented and `/g` / `/y` `lastIndex` is not honoured — see [Runtime deviations](../unimplemented/deviations.md).
|
|
54
82
|
|
|
55
83
|
## Symbol
|
|
@@ -76,7 +104,11 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
76
104
|
|
|
77
105
|
## URLSearchParams
|
|
78
106
|
|
|
79
|
-
- `URLSearchParams` is implemented in `runtime/xt_url.c`.
|
|
107
|
+
- `URLSearchParams` is implemented in `runtime/xt_url.c`. It is iterable
|
|
108
|
+
(`[Symbol.iterator]`, so `[...params]`, `for (const [k, v] of params)` and
|
|
109
|
+
`Object.fromEntries(params)` work), and `Object.fromEntries` consumes any
|
|
110
|
+
iterable — an array of pairs, a `Map`, a `URLSearchParams` or a generator —
|
|
111
|
+
rather than only an array.
|
|
80
112
|
|
|
81
113
|
## Errors
|
|
82
114
|
|
|
@@ -87,6 +119,7 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
87
119
|
## console
|
|
88
120
|
|
|
89
121
|
- `xt_print` / `xt_println` / `xt_console_log` / `info` / `warn` / `error`; `info` / `log` go to stdout, `warn` / `error` to stderr.
|
|
122
|
+
- `console` is a first-class object as well as a namespace: `const log = console.log`, `const { warn } = console`, `console.error.bind(console)` and `console.error = ...` all work, because reading `console` produces a cached object whose methods are ordinary functions (`xt_console_object`). Call sites stay direct (`console.log(...)` lowers to the runtime symbol), so the object costs nothing until a program uses it as a value.
|
|
90
123
|
- Node-style inspection: arrays `[ a, b ]`, objects `{ k: v }`, UTF-8-aware, with circular references marked.
|
|
91
124
|
- `dir` / `trace` / `assert` / `count` / `countReset` / `group` / `groupEnd` / `table` / `time` / `timeEnd` / `timeLog`.
|
|
92
125
|
|
|
@@ -102,3 +135,45 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
102
135
|
- `crypto.getRandomValues(typedArray)` fills an integer typed array (up to 65 536 bytes) from the OS CSPRNG and returns it; `crypto.randomUUID()` returns a v4 UUID string. `crypto` is also a first-class object and the methods can be detached (`const uuid = crypto.randomUUID`).
|
|
103
136
|
- `Math.random` draws from a xoshiro256** stream seeded from the OS CSPRNG (53 random bits), not from the C `rand()`.
|
|
104
137
|
- Node's `crypto.randomBytes` / `randomInt` / `randomFillSync` / `pbkdf2Sync` surface is documented in [node/crypto](../implemented/node/crypto.md).
|
|
138
|
+
|
|
139
|
+
## Proxy
|
|
140
|
+
|
|
141
|
+
`new Proxy(target, handler)` is implemented as a host view (`runtime/xt_proxy.c`):
|
|
142
|
+
the proxy is an object whose own property bag stays empty, so every string-keyed
|
|
143
|
+
lookup misses and reaches the handler.
|
|
144
|
+
|
|
145
|
+
- Traps: `get(target, key, receiver)`, `set(target, key, value, receiver)`,
|
|
146
|
+
`has(target, key)`, `deleteProperty(target, key)` and `ownKeys(target)`.
|
|
147
|
+
An absent trap forwards the operation to the target, so `new Proxy(obj, {})`
|
|
148
|
+
behaves like `obj` (writes and deletes included).
|
|
149
|
+
- `Object.keys` / `JSON.stringify` / `for...in` use the `ownKeys` result; reads
|
|
150
|
+
of those keys go through `get`. `typeof` is `"object"`, and the proxy inherits
|
|
151
|
+
the target's prototype, so inherited methods and `instanceof` work.
|
|
152
|
+
- Not modelled: function targets (`apply` / `construct` traps), `Proxy.revocable`,
|
|
153
|
+
the prototype and property-descriptor traps (`getPrototypeOf`,
|
|
154
|
+
`setPrototypeOf`, `getOwnPropertyDescriptor`, `defineProperty`,
|
|
155
|
+
`isExtensible`, …), and invariant checking (a trap may report a key the target
|
|
156
|
+
does not have). The target and handler are stored as hidden symbol-keyed
|
|
157
|
+
properties, so `Object.getOwnPropertySymbols(proxy)` reports them.
|
|
158
|
+
|
|
159
|
+
## Web platform globals
|
|
160
|
+
|
|
161
|
+
Implemented in `runtime/xt_web_abort.c` (aborts) and `runtime/xt_fetch/webapi.inc`
|
|
162
|
+
(`Headers` / `Response`, built on the `fetch` implementation):
|
|
163
|
+
|
|
164
|
+
- `AbortController` / `AbortSignal`: `abort(reason?)`, the `aborted` / `reason` /
|
|
165
|
+
`onabort` accessors, `addEventListener("abort", fn[, { once }])` /
|
|
166
|
+
`removeEventListener`, `throwIfAborted()`, and the statics `AbortSignal.abort()`,
|
|
167
|
+
`AbortSignal.timeout(ms)` and `AbortSignal.any([...])`. The default reasons are
|
|
168
|
+
`AbortError` / `TimeoutError` errors (`error.name`). `fetch` does not consume a
|
|
169
|
+
signal yet, so aborting does not cancel an in-flight request.
|
|
170
|
+
- `Headers`: the case-insensitive map `get` / `has` / `set` / `append` / `delete`
|
|
171
|
+
/ `forEach` / `keys` / `values` / `entries` / `getSetCookie`, constructible from
|
|
172
|
+
a plain object, an array of pairs or another `Headers`. `fetch` hands out
|
|
173
|
+
`Headers` instances (`instanceof` holds).
|
|
174
|
+
- `Response`: `new Response(body?, init?)` with `status` / `statusText` /
|
|
175
|
+
`headers`, and `text()` / `json()` / `arrayBuffer()` / `bytes()` / `clone()`.
|
|
176
|
+
`arrayBuffer()` resolves to a real `ArrayBuffer`, `bytes()` to a `Uint8Array`.
|
|
177
|
+
- `JSON`, `ArrayBuffer` and `DataView` are values too (`const s = JSON.stringify`,
|
|
178
|
+
`ArrayBuffer.prototype`, `new DataView(buffer)`); `JSON` keeps its dedicated
|
|
179
|
+
call lowering and also works when read as an object.
|
|
@@ -12,12 +12,28 @@ Location: `runtime/xt_typed_array.c`, `runtime/xt_array_buffer.c`.
|
|
|
12
12
|
- Element reads/writes apply the per-type coercion (`ToIntN` / `ToUintN`, `Uint8ClampedArray` rounding, `Float32` single-precision rounding).
|
|
13
13
|
- Prototype methods: `fill` / `set` / `slice` / `subarray` / `join` / `toString` / `indexOf` / `lastIndexOf` / `includes` / `forEach` / `map` / `filter` / `every` / `some` / `find` / `findIndex` / `reduce` / `reverse` / `sort` / `copyWithin` / `at` / `keys` / `values` / `entries`. Iterator methods still return arrays, not iterator objects.
|
|
14
14
|
- Typed arrays are views over an `ArrayBuffer`; `subarray` shares the buffer and `slice` copies.
|
|
15
|
+
- Element access is direct memory access, not a property lookup: an `ArrayBuffer`
|
|
16
|
+
owns one `uint8_t` block (allocation kind `XT_OBJECT_KIND_ARRAY_BUFFER`), and a
|
|
17
|
+
view resolves that block plus its byte offset once at construction (`view_bytes`
|
|
18
|
+
in `xt_object`) and then indexes it with a `memcpy`-sized read/write. The
|
|
19
|
+
general `xt_get`/`xt_set` path is only used for non-index keys and for views
|
|
20
|
+
without a real buffer. This is what makes geometry code (three.js reading and
|
|
21
|
+
writing `position`/`normal` attribute arrays) run at memory speed instead of
|
|
22
|
+
paying a runtime call per byte; the same work used to be ~50x slower than a
|
|
23
|
+
plain array.
|
|
24
|
+
- Only canonical array indices (`0 .. 2^32-2`, integral) name an element:
|
|
25
|
+
`ta[1.5]`, `ta[-1]` and `ta[2**32]` are ordinary property accesses, and an
|
|
26
|
+
out-of-range index reads `undefined` / ignores the write.
|
|
15
27
|
|
|
16
28
|
## ArrayBuffer and DataView
|
|
17
29
|
|
|
18
|
-
- `ArrayBuffer`: `byteLength`, `slice`, `ArrayBuffer.isView`.
|
|
30
|
+
- `ArrayBuffer`: `byteLength`, `slice`, `ArrayBuffer.isView`. `byteLength` and
|
|
31
|
+
`slice` are served by the runtime (`xt_get`), not stored as own properties, so
|
|
32
|
+
`Object.keys(new ArrayBuffer(8))` is empty like on the platform.
|
|
19
33
|
- `DataView`: big-endian by default, optional `littleEndian`, with `get` / `set` for Uint8 / Int8 / Uint16 / Int16 / Uint32 / Int32 / Float32 / Float64.
|
|
20
|
-
- Multiple views over one buffer share its bytes.
|
|
34
|
+
- Multiple views over one buffer share its bytes. The collector frees a buffer's
|
|
35
|
+
byte block when the buffer is swept; a view keeps its buffer reachable, so the
|
|
36
|
+
cached base pointer in a view never dangles.
|
|
21
37
|
|
|
22
38
|
## Not implemented
|
|
23
39
|
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
| `static get` / `static set` accessors | ✓ (accessors on the constructor value; inherited static setters are honoured) |
|
|
14
14
|
| `super[key]` / `super[key](...)` | ✓ |
|
|
15
15
|
| Inheritance `extends` / `super` | ✓ (single level correct; `super` takes the prototype of `this`'s prototype — see [Runtime deviations](./deviations.md)) |
|
|
16
|
+
| `extends` a native/extension class (`class X extends EventEmitter`) | ✓ (the parent is never constructed at class-definition time: a class value publishes its prototype, an extension constructor value publishes its own — `EventEmitter.prototype` — through the extension registry, and anything else gets the plain object a function's `.prototype` is. `super(...)` runs the parent's `__ctor` hook, or the parent constructor itself when it has none) |
|
|
16
17
|
| Prototype chain / method lookup | ✓ |
|
|
17
18
|
| `instanceof` | ✓ |
|
|
18
19
|
| `new` / instantiation | ✓ |
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
| Live bindings | ✗ namespace objects and imported bindings are snapshots at module-evaluation time |
|
|
14
14
|
| ESM `node_modules` packages | ✓ bare specifiers resolve up the tree through `exports` / `module` / `main`, including scoped packages and subpaths; the package sources are bundled like relative modules |
|
|
15
15
|
| CommonJS `require` / `module.exports` | ✓ inside `node_modules` only: the bundler gives each CommonJS package a synthetic `module` / `exports` pair, lowers `require("x")` to the bundled dependency's exports, and hoists external/built-in `require`s into ESM imports. `require()` in user code (outside `node_modules`) is still rejected with a diagnostic pointing at the ESM `import` form. |
|
|
16
|
+
| Dynamic `import()` | ✓ a literal specifier is bundled as a deferred module; a computed one resolves at run time against the extension modules linked into the build (bare and `node:` names) and rejects otherwise. It cannot load an arbitrary file or npm package at run time |
|
|
16
17
|
|
|
17
18
|
> Extension modules (such as `fs`) are importable by bare or `node:`-prefixed
|
|
18
19
|
> specifier — `import { readFileSync } from "fs"` / `import path from "path"` —
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
| Generators (`function*`, `yield`, `yield*`, `next`/`throw`/`return`) | ✓ implemented with stackful coroutines; `for...of`, spread and delegation supported. `return()` completes without running `finally` |
|
|
34
34
|
| Timers and microtasks | ✓ `setTimeout` / `clearTimeout` / `setInterval` / `clearInterval` / `setImmediate` / `clearImmediate` / `queueMicrotask` and `performance.now` (numeric ids, no `Timeout` / `Immediate` object). A promise settled from a timer can be awaited: the async body suspends on the pending promise and resumes when the timer fires |
|
|
35
35
|
| I/O / process and other host APIs | only via extensions (e.g. Node `fs`) |
|
|
36
|
-
| Web-platform globals (`
|
|
36
|
+
| Web-platform globals (`Reflect`, `Intl`, `FormData`, `Blob`, `Request`, `EventTarget`) | ✗ recognized (they type-check and lower to `undefined`), but no runtime implementation. `AbortController` / `AbortSignal` / `Headers` / `Response` are implemented, and `globalThis` / `global` are a plain property bag (see [Implemented: standard library](../implemented/stdlib.md#web-platform-globals)) |
|
|
37
|
+
| `Proxy` | ✓ object targets with `get` / `set` / `has` / `deleteProperty` / `ownKeys` (see [Implemented: Proxy](../implemented/stdlib.md#proxy)). ✗ function targets (`apply`/`construct`), `Proxy.revocable`, prototype and property-descriptor traps, invariant checking |
|
|
37
38
|
| Web Streams (`ReadableStream`, `WritableStream`, `TransformStream`, readers/writers, text streams) | ✓ implemented as core globals; see [Web Streams](../implemented/streams.md). BYOB byte streams and compression streams are not implemented |
|
|
38
39
|
|
|
39
40
|
## Typed arrays
|
|
@@ -58,6 +58,11 @@
|
|
|
58
58
|
"items": { "type": "string" },
|
|
59
59
|
"description": "Optional link features to keep out even when auto-detection finds a use."
|
|
60
60
|
},
|
|
61
|
+
"moduleOverrides": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"description": "Replace module specifiers with local files, e.g. { \"jiti\": \"stubs/jiti.ts\" }. Keys match the exact specifier text; values are file paths (with extension) resolved against this config's directory. An override wins over node_modules, Node built-ins and extension modules.",
|
|
64
|
+
"additionalProperties": { "type": "string" }
|
|
65
|
+
},
|
|
61
66
|
"force": {
|
|
62
67
|
"type": "boolean",
|
|
63
68
|
"description": "Ignore the incremental cache."
|
package/doc/zh-CN/gui/api.md
CHANGED
|
@@ -98,6 +98,7 @@ requestAnimationFrame(frame);
|
|
|
98
98
|
| --- | --- |
|
|
99
99
|
| `window`、`self` | 最近打开的窗口句柄(若程序尚未创建窗口,会隐式打开一个),因此 `window.innerWidth`、`window.addEventListener`、`window.setTimeout`、`window.localStorage`、`window.location`、`window.devicePixelRatio`、`window.matchMedia` 都可用 |
|
|
100
100
|
| `document` | 该窗口的 document 句柄 |
|
|
101
|
+
| 裸 window 成员 | 浏览器的全局作用域其实就是 window,因此 `innerWidth`、`innerHeight`、`outerWidth`、`outerHeight`、`devicePixelRatio`、`location`、`screen`、`scrollX`/`scrollY`、`addEventListener`/`removeEventListener`/`dispatchEvent`、`setTimeout`/`clearTimeout`/`setInterval`/`clearInterval`、`queueMicrotask`、`focus`/`blur`、`scrollTo`/`scrollBy` 不带 `window.` 前缀也能用。每一项都是从 window 上实时读取成员(`xt_get(window, name)`;调用走 `xt_call_method`),所以 `innerWidth` 会跟随窗口尺寸变化,`location.href` 仍是真实对象。`screen` 描述的是显示器(`width`/`height`/`availWidth`/`availHeight`/`colorDepth`/`pixelDepth`/`orientation`),不是窗口 |
|
|
101
102
|
| `navigator` | `userAgent`(以 `xbintsc` 结尾的桌面 Chrome 字符串)、`platform`、`vendor`、`language(s)`、`hardwareConcurrency`、`maxTouchPoints`、`onLine`、`vibrate()` |
|
|
102
103
|
| `localStorage` | 内存中的 `getItem` / `setItem` / `removeItem` / `clear` / `key` / `length` |
|
|
103
104
|
| `AudioContext`、`webkitAudioContext` | 带真实混音器与解码器的 Web Audio 图(见下) |
|
|
@@ -108,6 +109,7 @@ requestAnimationFrame(frame);
|
|
|
108
109
|
| `ImageBitmap`、`createImageBitmap(source)` | 由已解码像素支撑的不可变位图(`<img>`、`<canvas>`、`<video>` 帧、`OffscreenCanvas` 与 `ImageData` 形状);promise 立即 settle,`texImage2D` 可直接接受该对象 |
|
|
109
110
|
| `OffscreenCanvas` | 真正的 2D 离屏位图,带 `getContext("2d")`、`width`/`height`、`transferToImageBitmap()` 与 `convertToBlob()`;`canvas.transferControlToOffscreen()` 会把元素位图交给它(见 [Canvas](./canvas.md))。离屏 WebGL 上下文不提供。 |
|
|
110
111
|
| `ImageData`、`XRWebGL*`、`Request`、`Headers`、`Response`、`DOMParser` | `typeof` 探测返回 `"undefined"`(没有 XR、DOM 解析器或流式后端),让页面走自己的“不支持”分支,而不是调用空壳。`fetch` 仍然可用,并返回 response 形状的对象,但没有 `Response` 构造函数,且 `response.arrayBuffer()` 目前返回字节数组而不是 `ArrayBuffer`;`ReadableStream` 等 Web Streams 类来自核心运行时。Three.js 页面在本后端上使用真实渲染器(见[已知问题](./known-issues.md))。 |
|
|
112
|
+
| `VideoFrame`、`OfflineAudioContext`、`Float16Array` | 媒体/three.js 特性探测所期望的名字。`VideoFrame` 是真实的构造函数值,因此 `frame instanceof VideoFrame` 安全地得到 `false`,而不是抛 `TypeError`;`OfflineAudioContext` 能构造出对象,但背后没有离线渲染器(离线渲染音频仍需 `AudioContext`);`Float16Array` 是 `undefined`,因此 `typeof Float16Array < "u"` 会走降级分支(运行时没有 16 位浮点元素类型) |
|
|
111
113
|
| `requestAnimationFrame` / `cancelAnimationFrame` | 排入窗口的动画帧列表,见[运行时集成](./runtime.md) |
|
|
112
114
|
| `alert` / `confirm` / `prompt`、`matchMedia`、`getComputedStyle`、`escape` | 宿主实现。`matchMedia` 返回**实时**列表(按查询缓存):`matches` 在窗口尺寸变化时重新求值,翻转时触发 `change` 监听器。`confirm`/`prompt` 仅在 `XT_GUI_DIALOGS=1` 时使用原生对话框,否则把消息写到 stderr 并返回文档化的默认值(Annex B `escape` 按 UTF-16 码元编码,与 `decodeURIComponent(escape(bytes))` 一致) |
|
|
113
115
|
|
|
@@ -125,12 +127,24 @@ requestAnimationFrame(frame);
|
|
|
125
127
|
已实现的节点:`createGain`、`createOscillator`(sine、square、sawtooth、triangle)、
|
|
126
128
|
`createBufferSource`(buffer、loop、loopStart/loopEnd、playbackRate/detune)、
|
|
127
129
|
`createBiquadFilter`(lowpass、highpass、bandpass、lowshelf、highshelf、peaking、notch、allpass)、
|
|
128
|
-
`createDynamicsCompressor`、`createStereoPanner`、`createConstantSource
|
|
129
|
-
`createDelay(maxDelayTime)
|
|
130
|
+
`createDynamicsCompressor`、`createStereoPanner`、`createConstantSource`、
|
|
131
|
+
`createDelay(maxDelayTime)`、`createWaveShaper`(`curve`、`oversample`)、
|
|
132
|
+
`createConvolver`(`buffer`、`normalize`)、`createAnalyser`(`fftSize`、`frequencyBinCount`、
|
|
133
|
+
`smoothingTimeConstant`、`minDecibels`/`maxDecibels` 及四个 `get…Data` 方法)、
|
|
134
|
+
`createPanner`(`positionX/Y/Z` 与 `orientationX/Y/Z` 是 AudioParam,另有距离/锥角属性与
|
|
135
|
+
`setPosition`/`setOrientation`)、`createMediaElementSource`、`createMediaStreamSource`,
|
|
136
|
+
以及带九个 AudioParam 的 `context.listener`。`connect` 返回目标节点,因此可链式连接
|
|
130
137
|
(`src.connect(gain).connect(ctx.destination)`);`disconnect()` / `disconnect(target)`
|
|
131
138
|
会更新原生图;`start(when, offset, duration)` / `stop(when)` 按图的时钟生效。
|
|
132
|
-
列表之外的节点(`
|
|
133
|
-
`
|
|
139
|
+
列表之外的节点(`createChannelSplitter`、`createChannelMerger`、`createPeriodicWave`、
|
|
140
|
+
`createIIRFilter`、`createScriptProcessor` 等)不提供,其方法就是缺失的。
|
|
141
|
+
|
|
142
|
+
卷积器是**分块 FFT** 卷积(128 帧一块、256 点变换),因此一两秒的混响脉冲响应也能承受;
|
|
143
|
+
`normalize`(默认)会把响应缩放到「白噪声输入电平不变」。1.4 秒响应约占实时 10%,2.2 秒约 18%。
|
|
144
|
+
分析器使用规范中的 Blackman 窗与分贝映射,`smoothingTimeConstant` 是跨调用的滑动平均。
|
|
145
|
+
声像器按 `context.listener` 做等功率声像,并支持 linear/inverse/exponential 距离模型与锥角衰减;
|
|
146
|
+
`panningModel = "HRTF"` 会被接受但走同一条等功率路径(引擎不带 HRIR 数据集)。
|
|
147
|
+
两个媒体源是**合法的静音节点**——引擎没有采集或媒体元素音频管线,所以它们静音而不是缺失。
|
|
134
148
|
|
|
135
149
|
每个 `AudioParam` 都有实时 `value`,以及 `setValueAtTime` / `linearRampToValueAtTime` /
|
|
136
150
|
`exponentialRampToValueAtTime` / `setTargetAtTime` / `cancelScheduledValues` /
|
|
@@ -252,4 +266,4 @@ N 帧取平均)。
|
|
|
252
266
|
|
|
253
267
|
多窗口由对象模型自然得出:`createWindow` 返回一个原生对象句柄;每个句柄
|
|
254
268
|
拥有自己的 `SDL_Window`/GPU 表面与自己的 DOM 树。`run()` 驱动一个共享主循环,
|
|
255
|
-
它每帧 tick 所有窗口,并在最后一个窗口关闭时退出。
|
|
269
|
+
它每帧 tick 所有窗口,并在最后一个窗口关闭时退出。
|
package/doc/zh-CN/gui/dom.md
CHANGED
|
@@ -158,8 +158,14 @@ inner.addEventListener("click", (e) => console.log(e.target.id, e.currentTarget.
|
|
|
158
158
|
inner.click(); // 在该元素处合成一次点击
|
|
159
159
|
console.log(box.offsetWidth, box.offsetHeight); // 取整后的边框盒
|
|
160
160
|
console.log(box.contains(inner)); // 后代判断
|
|
161
|
+
console.log(inner.closest("button, .card") != null); // 自身或最近祖先匹配
|
|
161
162
|
```
|
|
162
163
|
|
|
164
|
+
`element.hidden` 是反射的布尔属性:赋 `true` 会写入 `hidden` 属性(因此
|
|
165
|
+
`hidden === true`、`getAttribute("hidden") === ""`),赋假值则移除它。UA 样式表把
|
|
166
|
+
`[hidden]` 当作 `display: none`,与浏览器一致——作者样式里设置了 `display` 的规则仍然优先,
|
|
167
|
+
所以页面通常先用 class 把 `opacity` 过渡掉,再设置 `hidden`。
|
|
168
|
+
|
|
163
169
|
### style 属性、dataset、计算样式与几何
|
|
164
170
|
|
|
165
171
|
内联 `style` 对象是一个 CSSOM 声明块。以属性名赋值/读取的是与 `setProperty`
|
|
@@ -6,20 +6,39 @@
|
|
|
6
6
|
|
|
7
7
|
## 已知问题
|
|
8
8
|
|
|
9
|
+
- **Web Audio 没有 `MediaStream`/采集管线,且两个节点的行为是近似实现。**
|
|
10
|
+
`createMediaElementSource` 与 `createMediaStreamSource` 返回合法但**静音**的节点:引擎没有
|
|
11
|
+
麦克风/摄像头采集,也不会把媒体元素自身的播放接入音频图,因此页面把二者接入图里得到的是静音,
|
|
12
|
+
而不是报错。`WaveShaperNode.oversample` 在 2 或 4 个子采样点上平均曲线,而不是对输入做带限滤波,
|
|
13
|
+
它能减轻硬曲线引入的混叠但不能消除。`PannerNode.panningModel = "HRTF"` 会被接受,但走等功率
|
|
14
|
+
路径——引擎不带 HRIR 数据集,因此结果是带距离/锥角衰减的立体声声像,而不是双耳滤波。
|
|
15
|
+
`ConvolverNode` 按能量归一化(把响应缩放到「白噪声输入电平不变」),与浏览器的归一化接近但不
|
|
16
|
+
逐位一致。
|
|
9
17
|
- **WebGL 1.0 与 2.0 运行在 GPU 上,但只实现了各自的子集。**
|
|
10
18
|
`canvas.getContext("webgl")` / `"webgl2"` 返回真正的 GPU 上下文(见
|
|
11
19
|
[WebGL](./webgl.md)):GLSL ES 着色器由内置 glslang 翻译为 SPIR-V——Vulkan
|
|
12
20
|
后端直接消费,Metal 上再由内置 SPIRV-Cross 交叉编译为 MSL——绘图缓冲
|
|
13
21
|
是一张离屏颜色纹理,页面直接合成而无须读回。WebGL 2 增加了 VAO、实例化、
|
|
14
22
|
整数属性、采样器对象、`texStorage2D`、缓冲拷贝、Uniform 块、立方体/3D/数组
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
transform feedback
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
纹理、浮点/深度/压缩纹理、多渲染目标、scissor 清除,以及 Vulkan 上的 4×
|
|
24
|
+
多重采样抗锯齿。`blitFramebuffer` 复制颜色与深度,并解析多重采样颜色源;
|
|
25
|
+
transform feedback、模板 blit 与多重采样深度 blit 尚未实现(SDL_GPU 没有
|
|
26
|
+
transform feedback 阶段、无法解析深度,也无法采样模板附件)。
|
|
27
|
+
在两种着色器格式都不接受的 SDL_GPU 后端(Direct3D 12,需要 DXIL)上两种
|
|
28
|
+
上下文都为 `null`。`.js` 资源加载器现在只修补 three.js 的着色器循环展开;
|
|
20
29
|
`WebGLRenderer` 直接运行在真实后端上,不再有 Canvas2D 回退。阴影贴图
|
|
21
30
|
(比较型 `sampler2DShadow` 采样深度纹理)、立方体贴图/环境贴图与 HDR 渲染目标
|
|
22
31
|
均已支持。
|
|
32
|
+
- **MSAA 在 Vulkan 与 Metal 上启用,并且改变了哪些 blit 合法。**
|
|
33
|
+
`antialias` 属性默认开启;受支持的上下文得到 4× 绘图缓冲,每个渲染 pass
|
|
34
|
+
结束时解析到页面合成的颜色纹理,因此 `getParameter(SAMPLES)` 为 4,部分覆盖的
|
|
35
|
+
边缘像素会是混合色。设备若不支持 4× 颜色与深度,则保持单采样路径
|
|
36
|
+
(`antialias` 为 false、`MAX_SAMPLES` 为 0,多重采样存储请求会降级为单采样的
|
|
37
|
+
renderbuffer/纹理且 `SAMPLES` 为 0)。与浏览器一致,
|
|
38
|
+
blit 到抗锯齿的默认帧缓冲是 `INVALID_OPERATION`:页面若要自己把离屏目标解析到
|
|
39
|
+
canvas,应传入 `getContext("webgl2", { antialias: false })`。多重采样颜色源只有在
|
|
40
|
+
源/目标矩形完全相同、格式相同且过滤为 `NEAREST` 时才能解析;多重采样深度附件可以
|
|
41
|
+
渲染(深度测试按样本工作),但无法通过 SDL_GPU 解析。
|
|
23
42
|
- **部分 Intel Mac 上比较型采样器会被错误编译。** 在 Intel GPU(在 Intel Iris
|
|
24
43
|
Plus Graphics + macOS 26 上观察到)上,Metal 着色器编译器会丢弃调用
|
|
25
44
|
`sample_compare` 的片元函数:绘制不产生任何像素,于是
|
package/doc/zh-CN/gui/runtime.md
CHANGED
|
@@ -48,13 +48,25 @@ deferred` 才是页面自身造成的工作。调试"漏掉的失效"时可用
|
|
|
48
48
|
动画帧回调,因此页面可以自行停止);
|
|
49
49
|
- 只有在**仍有回调**时才重新排程,空闲页面会让事件循环排空并退出进程 ——
|
|
50
50
|
这正是浏览器标签页的生命周期;
|
|
51
|
+
- **每一次**请求都会重新启动它,包括通过**窗口方法**
|
|
52
|
+
(`window.requestAnimationFrame` / `self.requestAnimationFrame`)发出的请求,
|
|
53
|
+
而不只是裸全局函数。three.js 的 `setAnimationLoop` 在其启动很久之后通过
|
|
54
|
+
`self` 申请下一帧,此时帧泵已排空;漏掉这一点会让渲染器再也拿不到帧,页面就
|
|
55
|
+
停在最后一张已呈现的画面上(Saltline 页面因此一直停在“准备就绪”:DOM 里的
|
|
56
|
+
启动遮罩其实已隐藏,但负责把它画出来的那一帧从未执行);
|
|
57
|
+
- 回调收到的时间戳是 `DOMHighResTimeStamp`,与 `performance.now()` 同一时钟,
|
|
58
|
+
而不是 `SDL_GetTicks()`(机器开机时长);
|
|
51
59
|
- 下一次 tick 排在**帧开始 + 16 ms**,而不是帧结束后再等 16 ms:帧自身耗时不再
|
|
52
60
|
叠加到间隔上,10 ms 的帧以 16 ms 周期运行(而不是 26 ms),比 16 ms 更慢的页面
|
|
53
61
|
则以全速运行,而不是每帧再落后一帧的时间;
|
|
54
62
|
- 当 `xt_gui_run_active()` 为真(程序自己调用了 `run()`)时它会让路,避免同一
|
|
55
63
|
窗口每 tick 被渲染两次;
|
|
56
64
|
- `XT_GUI_AUTOCLOSE_MS=n` 让帧泵在 `n` 毫秒后退出,测试用它来运行不会自行
|
|
57
|
-
|
|
65
|
+
关闭的页面;
|
|
66
|
+
- `XT_GUI_TRACE=1` 会把 WebGL 的 resolve/blit/渲染 pass 序列(包括已提交命令缓冲
|
|
67
|
+
的最后一批绘制)打印到 stderr,`XT_GUI_VK_DEBUG=1` 让 SDL 以调试模式创建设备,
|
|
68
|
+
从而启用 Vulkan 的 Khronos 校验层——这两个开关就是定位“半浮点解析丢失设备”时
|
|
69
|
+
使用的。
|
|
58
70
|
|
|
59
71
|
这使网络 I/O、定时器与 `await` 在 GUI 程序内部继续工作。
|
|
60
72
|
|
package/doc/zh-CN/gui/webgl.md
CHANGED
|
@@ -20,10 +20,10 @@ if (gl == null) {
|
|
|
20
20
|
|
|
21
21
|
## 一帧如何到达屏幕
|
|
22
22
|
|
|
23
|
-
- 每个上下文拥有一张离屏 `R8G8B8A8_UNORM` 颜色纹理(绘图缓冲)和一张 `D32_FLOAT` 深度纹理,尺寸取自 canvas 的 `width` / `height` 属性。`canvas.width = …` 会重建它们并丢弃内容,与 DOM
|
|
23
|
+
- 每个上下文拥有一张离屏 `R8G8B8A8_UNORM` 颜色纹理(绘图缓冲)和一张 `D32_FLOAT` 深度纹理,尺寸取自 canvas 的 `width` / `height` 属性。`canvas.width = …` 会重建它们并丢弃内容,与 DOM 规则一致。启用 MSAA 时绘制进入 4× 颜色纹理,每个渲染 pass 结束都会解析到页面合成的颜色纹理(见 [多重采样抗锯齿(MSAA)](#多重采样抗锯齿msaa))。
|
|
24
24
|
- 上下文记录到自己的 SDL_GPU 命令缓冲。`clear`/`draw*` 保持一个渲染 pass 打开;只有缓冲区/纹理上传或切换 framebuffer 才会结束它,并以 `LOAD` 开始新 pass,因此绘图缓冲在多次绘制之间保留,和 WebGL 一样;没有上传的绘制不会中断 pass。
|
|
25
25
|
- 每帧一次,在页面自己的渲染 pass 之前,引擎提交所有 WebGL 命令缓冲。随后图像管线把颜色纹理当作普通 `PaintImage` 采样,没有 CPU 拷贝。
|
|
26
|
-
- WebGL 原点在左下,SDL_GPU
|
|
26
|
+
- WebGL 原点在左下,SDL_GPU 渲染目标原点在左上,两类帧缓冲因此采用不同存储方向。默认绘图缓冲按**自上而下**存储,与合成器呈现方式一致(纹理第 0 行是图像顶部):转换 `viewport`/`scissor`,`readPixels` 反转行序,绘制时使用正的、y 翻转的 viewport。用户帧缓冲则按**自下而上**存储,与纹理采样方式一致(`v = 0` 是它的底行),因此 `viewport`/`scissor`/`readPixels` 直接按 GL 行映射,绘制时用负高度的 viewport 完成翻转。该翻转同时镜像了光栅器看到的绕序,所以自下而上的目标会翻转 GL 的正面判定(该值属于管线键的一部分,两种方向各保留一条管线)。于是渲染目标采样回来就是 WebGL 的方向,深度纹理(阴影贴图)也与写入它的投影一致。两类目标之间的 `blitFramebuffer` 不能用 `SDL_BlitGPUTexture`(它的拷贝无法反转行序),因此改为一次采样 pass;同类目标之间的 blit 仍走 GPU blit。
|
|
27
27
|
- 固定功能状态变化(`blendFunc`、`depthFunc`、`cullFace`、`colorMask` 等)会改变所需的 `SDL_GPUGraphicsPipeline`,因此管线惰性创建并缓存在程序上。键是这次绘制的**内容**:程序、图元模式、顶点布局的哈希(属性位置、格式、偏移、缓冲 pitch 与输入速率)、反射出的固定功能状态、附件格式。它刻意**不**包含上下文的单调版本计数器(`attribs_version_`、`framebuffer_version_`)与 GPU 缓冲句柄:这些值在每次绑定 VAO、切换帧缓冲或重建缓冲时都会前进,却不改变管线;用它们做键会让每帧绑定多个布局的场景(three.js 每帧为每个几何体绑定一个 VAO)每帧重建全部管线 —— 实测每帧 248 次 `SDL_CreateGPUGraphicsPipeline`,且程序级缓存无界增长。`tests/e2e/gui-webgl-pipeline-cache.test.ts` 固定了稳态:布局相同、缓冲不同的两次绘制在首帧之后不再创建管线。
|
|
28
28
|
|
|
29
29
|
## 性能
|
|
@@ -41,6 +41,18 @@ if (gl == null) {
|
|
|
41
41
|
剩余的每次 draw 开销来自后端自身的提交;大量相同对象仍应由应用改用
|
|
42
42
|
`drawElementsInstanced`。
|
|
43
43
|
|
|
44
|
+
## 多重采样抗锯齿(MSAA)
|
|
45
|
+
|
|
46
|
+
`getContext("webgl2")`(以及 `getContext("webgl")`)会遵循 `antialias` 上下文创建属性,其默认值与 WebGL 一样为 `true`。在后端支持时,绘图缓冲是 **4× 多重采样** 的:
|
|
47
|
+
|
|
48
|
+
- `getContextAttributes().antialias` 报告 `true`,默认帧缓冲的 `getParameter(SAMPLES)` 为 `4`、`SAMPLE_BUFFERS` 为 `1`、`MAX_SAMPLES` 为 `4`。`getContext("webgl2", { antialias: false })` 保持单采样路径(`SAMPLES`/`SAMPLE_BUFFERS` 报告 `0`)。
|
|
49
|
+
- 绘制写入多重采样颜色纹理,并配有同样 4× 的深度纹理。每个渲染 pass 结束时都会把颜色目标解析到页面合成的单采样纹理,因此合成器、`readPixels` 与 `blitFramebuffer` 看到的都是已解析的图像,无需额外调用。
|
|
50
|
+
- 带 scissor 的 `clear` 用一个纹理四边形绘制进多重采样目标(`SDL_BlitGPUTexture` 不能以它为目的地);四边形边缘落在像素边界上,所以 scissor 矩形内的每个像素都获得完整覆盖。
|
|
51
|
+
- `renderbufferStorageMultisample(target, samples, internalformat, width, height)` 分配 4× 颜色或深度(模板)renderbuffer;`texStorage2DMultisample` / `texImage2DMultisample` 对纹理做同样的事。把它们挂到 framebuffer 上就成为渲染目标;当颜色附件与深度附件的采样数不一致时,`checkFramebufferStatus` 返回 `FRAMEBUFFER_INCOMPLETE_MULTISAMPLE`。
|
|
52
|
+
- 当源与目标矩形、颜色格式都相同且过滤为 `NEAREST` 时,`blitFramebuffer` 会把多重采样源解析到单采样目标——即 ES 3.0 的解析规则。半浮点(或浮点)颜色目标的解析使用**采样 pass**,而不是 `SDL_BlitGPUTexture`:SDL_GPU 的 blit 是 `vkCmdBlitImage`,而 Vulkan 不要求 16F/32F 图像支持 blit 源/目标,这条无效命令会让 three.js 的 `samples > 0` 渲染目标丢失 Vulkan 设备。采样拷贝适用于所有颜色格式(three.js 执行的全矩形解析可以精确映射)。blit 到多重采样的 draw framebuffer 是 `INVALID_OPERATION`;从用户的多重采样 framebuffer `readPixels` 同样是 `INVALID_OPERATION`(需先解析)。
|
|
53
|
+
|
|
54
|
+
能运行 WebGL 的两个后端都启用 MSAA:Vulkan(Windows/Linux)与 Metal(macOS)都会解析 4× 绘图缓冲,scissor clear 与实例化绘制也包含在内。若设备无法采样 4× RGBA8 与深度,则保持单采样路径:`antialias` 报告 `false`,`MAX_SAMPLES` 为 `0`,`renderbufferStorageMultisample` / `texStorage2DMultisample` 会降级为单采样存储(`RENDERBUFFER_SAMPLES` 报告 `0`),仍请求 MSAA 的页面不会丢失附件。深度/模板附件无法通过 SDL_GPU 解析,因此多重采样的深度 blit 会被接受但不改动目标深度(模板位本来就不支持)。
|
|
55
|
+
|
|
44
56
|
## 着色器:GLSL ES 到 SPIR-V(再到 MSL)
|
|
45
57
|
|
|
46
58
|
SDL_GPU 不能在运行时编译 GLSL,且每个后端只消费自己的格式,因此引擎静态链接了两个翻译器:
|
|
@@ -70,7 +82,7 @@ SDL_GPU 不能在运行时编译 GLSL,且每个后端只消费自己的格式
|
|
|
70
82
|
| `sampler2DShadow` / `samplerCubeShadow` / `sampler2DArrayShadow` | 保留;绑定为 SDL_GPU 比较采样器 |
|
|
71
83
|
| 缺少 `#version` / `#version 100` | `#version 310 es` |
|
|
72
84
|
|
|
73
|
-
实现限制:结构体 uniform、用户 uniform 块、预处理阶段无法确定长度的 uniform 数组,以及用非常量表达式索引的采样器数组会被拒绝(shader/link info log 会说明)。`#pragma unroll_loop_start` 循环会在改写前展开,因此 three.js 生成的 `sampler2D shadowMap[ NUM_DIR_LIGHT_SHADOWS ]` / `shadowMap[ i ]` 会变成常量索引。`#ifdef` 内的着色器代码可用;非采样器 uniform 声明会被移动到顶层,保证块保持无条件。两个阶段的非采样器 uniform 会合并成同一个块,并在每个阶段各声明一次(顶点 set 1、片元 set 3),与 SDL_GPU 的 Vulkan
|
|
85
|
+
实现限制:结构体 uniform、用户 uniform 块、预处理阶段无法确定长度的 uniform 数组,以及用非常量表达式索引的采样器数组会被拒绝(shader/link info log 会说明)。`#pragma unroll_loop_start` 循环会在改写前展开,因此 three.js 生成的 `sampler2D shadowMap[ NUM_DIR_LIGHT_SHADOWS ]` / `shadowMap[ i ]` 会变成常量索引。`#ifdef` 内的着色器代码可用;非采样器 uniform 声明会被移动到顶层,保证块保持无条件。两个阶段的非采样器 uniform 会合并成同一个块,并在每个阶段各声明一次(顶点 set 1、片元 set 3),与 SDL_GPU 的 Vulkan 描述符布局一致。一个声明里写多个变量时(`uniform sampler2D a, b;`、`uniform vec3 tint, fill;`)会按声明符逐个改写:每个采样器拿到自己的 binding(因为 GLSL 的一个声明只有一套 `layout(...)`),每个非采样器各自成为一个块成员。在 Metal 上同一批声明会变成 `[[buffer(0)]]` 与 `[[texture(N)]]`/`[[sampler(N)]]`,正是 SDL_GPU Metal 后端绑定的槽位。`uniformMatrix4fv` 按列主序写入反射出的偏移;对采样器调用 `uniform1i` 时记录纹理单元。每次绘制都用动态 uniform 缓冲接口推送该块。
|
|
74
86
|
|
|
75
87
|
翻译器的限制:结构体 uniform、用户 uniform 块、预处理后仍无法确定长度的 uniform 数组、采样器数组与采样器类型不匹配的声明会被拒绝(着色器/链接日志会说明)。`#ifdef` 内的代码没问题;非采样器 uniform 声明会被移到外层顶层位置,保证块是无条件的。
|
|
76
88
|
|
|
@@ -88,9 +100,9 @@ SDL_GPU 不能在运行时编译 GLSL,且每个后端只消费自己的格式
|
|
|
88
100
|
- **缓冲与顶点属性**:`createBuffer`、`bindBuffer`、`bufferData`、`bufferSubData`、`deleteBuffer`、`getBufferParameter`、`enableVertexAttribArray`、`disableVertexAttribArray`、`vertexAttribPointer`、`vertexAttrib1f`…`4f` / `1fv`…`4fv`、`getVertexAttrib`。`bufferData` 的 `usage` 提示(`STREAM_DRAW`/`STATIC_DRAW`/`DYNAMIC_DRAW`)会被记录,`getBufferParameter(…, BUFFER_USAGE)` 可读回。
|
|
89
101
|
- **绘制**:`drawArrays`、`drawElements`(UNSIGNED_BYTE、UNSIGNED_SHORT、UNSIGNED_INT;`TRIANGLE_FAN` 与 `LINE_LOOP` 会展开为列表)。`POINTS`、`LINES`、`LINE_STRIP`、`TRIANGLES`、`TRIANGLE_STRIP` 映射到对应的 SDL 图元。
|
|
90
102
|
- **纹理**:`createTexture`、`bindTexture`、`activeTexture`、`texParameteri`/`texParameterf`、`getTexParameter`、`texImage2D`(原始像素、`<img>`、`<canvas>`、`ImageData`)、`texSubImage2D`、`generateMipmap`、`deleteTexture`。支持 `UNPACK_FLIP_Y_WEBGL` 与 `UNPACK_PREMULTIPLY_ALPHA_WEBGL`。默认转换为 RGBA8;`RGBA`/`RGB`/`LUMINANCE`/`ALPHA`/`LUMINANCE_ALPHA` 配 `UNSIGNED_BYTE` 可用。浮点纹理(`RGBA32F`、`RGBA16F`、`RGB32F`、`RGB16F`、`RG32F`/`RG16F`、`R32F`/`R16F`,`FLOAT` 或 `HALF_FLOAT` 数据,以及 WebGL 1 的 `OES_texture_float`/`OES_texture_half_float`)映射到 SDL 的 RGBA32F/RGBA16F;深度纹理(`DEPTH_COMPONENT16/24/32F`、`DEPTH_STENCIL`、`DEPTH24_STENCIL8`)映射到 `D32_FLOAT`/`D32_FLOAT_S8_UINT`,可作为采样源或深度附件。压缩纹理通过 `compressedTexImage2D`/`compressedTexSubImage2D` 上传,支持 `WEBGL_compressed_texture_s3tc`(BC1/BC2/BC3)、`WEBGL_compressed_texture_s3tc_srgb` 与 `WEBGL_compressed_texture_astc`;扩展只在设备确实支持对应格式时公布。`texImage2D` 还接受 `<video>` 的最新解码帧与 `createImageBitmap` 产生的 `ImageBitmap`。立方体贴图(`bindTexture(TEXTURE_CUBE_MAP)` + 六个 `texImage2D` 面)与 3D/数组纹理(`texImage3D`/`texStorage3D`)可用对应采样器(`samplerCube`、`sampler3D`、`sampler2DArray`)采样;`texSubImage3D` 可更新 3D/数组纹理的子区域,`framebufferTextureLayer` 可把数组/立方体贴图的指定层作为颜色附件渲染。
|
|
91
|
-
- **Framebuffer**:`createFramebuffer`、`bindFramebuffer`(`FRAMEBUFFER`/`READ_FRAMEBUFFER`/`DRAW_FRAMEBUFFER`)、`framebufferTexture2D`(`COLOR_ATTACHMENT0`、`DEPTH_ATTACHMENT`、`DEPTH_STENCIL_ATTACHMENT`)、`checkFramebufferStatus`、`createRenderbuffer`、`bindRenderbuffer`、`renderbufferStorage
|
|
103
|
+
- **Framebuffer**:`createFramebuffer`、`bindFramebuffer`(`FRAMEBUFFER`/`READ_FRAMEBUFFER`/`DRAW_FRAMEBUFFER`)、`framebufferTexture2D`(`COLOR_ATTACHMENT0`、`DEPTH_ATTACHMENT`、`DEPTH_STENCIL_ATTACHMENT`)、`checkFramebufferStatus`、`createRenderbuffer`、`bindRenderbuffer`、`renderbufferStorage`(颜色、深度或深度模板)、`renderbufferStorageMultisample`、`framebufferRenderbuffer`、`delete*`,以及 `blitFramebuffer`(颜色走 SDL blit,浮点/多重采样源先解析并用采样 pass 拷贝;深度走一个写 `gl_FragDepth` 的采样 pass;模板位被接受但不复制)。足以实现渲染到纹理、多重采样渲染目标、阴影贴图与后处理。
|
|
92
104
|
- **状态**:`enable`/`disable`/`isEnabled`(`BLEND`、`DEPTH_TEST`、`CULL_FACE`、`SCISSOR_TEST`、`STENCIL_TEST`)、`clearColor`/`clearDepth`/`clearStencil`、`clear`(开启 `SCISSOR_TEST` 时颜色、深度与模板都只清除 scissor 矩形)、`blendColor`、`blendFunc`/`blendFuncSeparate`、`blendEquation`/`blendEquationSeparate`、`depthFunc`、`depthMask`、`colorMask`、`stencilFunc`/`stencilFuncSeparate`、`stencilOp`/`stencilOpSeparate`、`stencilMask`/`stencilMaskSeparate`、`cullFace`、`frontFace`、`viewport`、`scissor`、`pixelStorei`、`finish`。模板测试真正参与光栅化,`clear(STENCIL_BUFFER_BIT)` 会清空模板附件;SDL_GPU 只有一份前后脸共用的 reference 与 compare/write mask,若前后脸设置不同,使用前脸值。
|
|
93
|
-
- **读回**:`readPixels`(RGBA/UNSIGNED_BYTE),可从默认帧缓冲或绑定的 RGBA8 framebuffer 读取;浮点/深度附件先采样到 RGBA8
|
|
105
|
+
- **读回**:`readPixels`(RGBA/UNSIGNED_BYTE),可从默认帧缓冲或绑定的 RGBA8 framebuffer 读取;浮点/深度附件先采样到 RGBA8 目标再读回,默认帧缓冲的多重采样颜色目标会自动解析到可读纹理。直接从用户的多重采样 framebuffer 读取会得到 `INVALID_OPERATION`。它会阻塞到 GPU 完成;用于测试和截图,不要每帧调用。
|
|
94
106
|
|
|
95
107
|
WebGL 2 额外提供:
|
|
96
108
|
|
|
@@ -110,7 +122,7 @@ WebGL 2 额外提供:
|
|
|
110
122
|
|
|
111
123
|
## 未实现
|
|
112
124
|
|
|
113
|
-
transform feedback(入口为空操作:SDL_GPU 没有 transform feedback
|
|
125
|
+
transform feedback(入口为空操作:SDL_GPU 没有 transform feedback 阶段)与多重采样的**深度/模板**解析(SDL_GPU 只能解析颜色目标,因此多重采样深度 blit 不会改动目标深度)。`blitFramebuffer` 复制颜色与深度;模板位被接受但不复制,因为 SDL_GPU 无法采样模板附件。着色器不能采样多重采样纹理(`sampler2DMS`):读取它需要先通过 `blitFramebuffer` 解析。
|
|
114
126
|
|
|
115
127
|
仍存在的着色器限制:结构体 uniform 与用户 uniform 块会被展平,但内建接口块(如重声明 `gl_PerVertex`)不在翻译子集内;使用它的着色器仍会以编译/链接日志失败,而不是静默出错。
|
|
116
128
|
|
|
@@ -130,6 +142,7 @@ transform feedback(入口为空操作:SDL_GPU 没有 transform feedback 阶
|
|
|
130
142
|
- `tests/e2e/gui-webgl2-3d.test.ts` 覆盖 2D 数组纹理与 3D 纹理的多层采样、`texSubImage3D` 子区域更新与 `framebufferTextureLayer` 渲染到数组层。
|
|
131
143
|
- `tests/e2e/gui-webgl2-mrt.test.ts` 覆盖两个片元输出分别写入两个颜色附件。
|
|
132
144
|
- `tests/e2e/gui-webgl2-ubo.test.ts` 覆盖 uniform 块的绑定、std140 成员与运行时更新。
|
|
145
|
+
- `tests/e2e/gui-webgl2-msaa.test.ts` 覆盖抗锯齿的默认绘图缓冲(部分覆盖的边缘像素解析为混合色)、通过 `blitFramebuffer` 解析多重采样 renderbuffer 与 `texStorage2DMultisample` 纹理、采样数不一致时的 `FRAMEBUFFER_INCOMPLETE_MULTISAMPLE`,以及从多重采样 framebuffer 读取时的拒绝行为。
|
|
133
146
|
- `tests/e2e/gui-media.test.ts` 还会把 `<video>` 的最新解码帧上传为纹理并读回像素。
|
|
134
147
|
- `examples/gui/webgl-cube` 是一个旋转、受光、带纹理的立方体;它在浏览器中原样运行,并由 `tests/e2e/gui-example-webgl.test.ts` 覆盖。
|
|
135
148
|
- `examples/gui/webgl2-cubes` 用一次绘制调用画出 64 个实例化立方体,使用 `#version 300 es` 与 VAO;由 `tests/e2e/gui-example-webgl2.test.ts` 覆盖。
|
|
@@ -141,4 +154,4 @@ transform feedback(入口为空操作:SDL_GPU 没有 transform feedback 阶
|
|
|
141
154
|
|
|
142
155
|
着色器改写器会把 three.js 的 `#pragma unroll_loop_start` 循环展开为常量索引(否则其采样器数组无法通过 Vulkan GLSL),`.js` 资源加载器则避免渲染器自带的展开器重复处理。`WebGLRenderer` 在本引擎真正的 WebGL 2 后端上原样运行,**不再打包 Canvas2D 回退**。已用 three.js r160 通过 SDL_GPU 验证:`MeshBasicMaterial`、`MeshStandardMaterial`、`MeshPhongMaterial`、`CanvasTexture`、线性雾、环境光/平行光/点光/聚光/半球光、`Sprite`、`Line`、`Points` 与 `InstancedMesh`。
|
|
143
156
|
|
|
144
|
-
本引擎子集之外的能力仍无法模拟:transform feedback 与 MSAA
|
|
157
|
+
本引擎子集之外的能力仍无法模拟:transform feedback 与多重采样深度解析。立方体贴图/环境贴图、深度纹理、HDR/浮点渲染目标、压缩纹理、Vulkan 与 Metal 上的 MSAA 颜色解析与比较型 `sampler2DShadow` 采样都已可用(three.js 阴影贴图可在两个后端使用硬件深度比较,Intel Mac 上的驱动问题见[已知问题](./known-issues.md))。需要 transform feedback 的场景无法正确渲染;此前 Canvas2D 回退能显示的内容现在全部走 GPU。
|
package/doc/zh-CN/gui-scripts.md
CHANGED
|
@@ -57,7 +57,8 @@ JS”的含义。
|
|
|
57
57
|
| 1 | **没有页面 JS 引擎。** 行为由原生 TS 实现。`<script>` 主体由 xbintsc *AOT 编译*为原生代码,并通过 `xt_call_with_this` 调用——仍然没有解释器。 |
|
|
58
58
|
| 8 | **脚本是编译期资产。** HTML 资产加载器把内联 `<script>` 主体转换为已编译模块,并替换为 `data-xt-id` 标记;运行时只*调用*已编译的函数。 |
|
|
59
59
|
| 9 | **DOM 由引擎拥有;句柄是引擎对象。** 句柄使用与窗口句柄相同的共享原型对象模型;隐藏字段携带窗口引用、文档代(generation)与节点索引。 |
|
|
60
|
-
| 10 | **`window`/`document`
|
|
60
|
+
| 10 | **`window`/`document` 作为参数注入**,而非全局变量,因此不会向编译器添加全局对象机制。浏览器里同样以裸全局形式存在的 *window 成员*(`innerWidth`、`location`、`addEventListener`、`screen` 等)由扩展声明为「window 值的成员读取」:`innerWidth` 会降低为 `xt_get(window, "innerWidth")`,因此始终是实时值。 |
|
|
61
|
+
| 11 | **`<script>` 默认是 JavaScript,除非写了 `lang="ts"`。** 这既是浏览器规则,也让压缩后的 bundle(以及任何纯 JS 页面)不进入类型检查器 —— 检查器的推断只对标注过类型的代码成立。名字解析与重复声明仍会检查,因为生成代码需要它们。 |
|
|
61
62
|
|
|
62
63
|
## 架构
|
|
63
64
|
|
package/doc/zh-CN/gui.md
CHANGED
|
@@ -275,7 +275,10 @@
|
|
|
275
275
|
- 顶点数组对象保存/恢复属性表,实例化绘制使用 SDL 的按实例输入频率,采样器
|
|
276
276
|
对象覆盖纹理单元的过滤/环绕状态。`texStorage2D`、`copyBufferSubData`、
|
|
277
277
|
`getBufferSubData` 与 `clearBuffer*` 已实现;查询/栅栏/UBO 与 transform
|
|
278
|
-
feedback
|
|
278
|
+
feedback 入口存在并优雅降级。Vulkan 与 Metal 上下文在 `antialias` 属性
|
|
279
|
+
(默认 true)允许时是 4× 多重采样的:每个 pass 都把绘图缓冲解析到页面合成的纹理,
|
|
280
|
+
`renderbufferStorageMultisample`/`texStorage2DMultisample` 分配多重采样渲染
|
|
281
|
+
目标,`blitFramebuffer` 解析颜色。见 [WebGL](./gui/webgl.md);e2e 见
|
|
279
282
|
`tests/e2e/gui-webgl2.test.ts` 与 `tests/e2e/gui-example-webgl2.test.ts`,
|
|
280
283
|
示例见 `examples/gui/webgl2-cubes`。
|
|
281
284
|
19. **M19 — 装饰性 CSS** ✅
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
- 作用域种类:模块、函数、块、`for`、`catch`
|
|
8
8
|
- 符号种类:`var` / `let` / `const` / `function` / `parameter` / `class` / `interface` / `type` / `enum` / `import` / `namespace`
|
|
9
|
-
- `var` 与函数声明提升到函数作用域;`let` / `const`
|
|
9
|
+
- `var` 与函数声明提升到函数作用域;`let` / `const` 保持块作用域。写在嵌套块内或 `for` 头部的 `var` 复用同一个提升符号,因此 `{ var x = 1 }` 在块之后依然可见(可赋值)
|
|
10
|
+
- 解构**参数**先声明其名字,再绑定模式内部的默认值,因此 `({ a = () => 1 }) => a()` 中的箭头函数能拿到自己的函数信息
|
|
10
11
|
- `switch` 主体是一个共享块作用域:所有 `case` / `default` 子句中的声明会在绑定任意子句之前预先声明
|
|
11
12
|
- `static { ... }` 类静态块绑定为类的隐藏静态函数(见[类与面向对象](../unimplemented/classes.md))
|
|
12
13
|
- 标识符 → 声明 的解析;未解析标识符收集(`CannotFindName`)
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
- 接口与类型别名(含泛型别名与 `extends`);
|
|
27
27
|
- 类:实例字段、方法、访问器、参数属性、`this.x = ...` 成员与本地祖先类。
|
|
28
28
|
静态成员不算实例成员;
|
|
29
|
+
- 声明可见性:模块顶层的 interface / type alias / class 对整个 bundle 可见,
|
|
30
|
+
而**函数体内**声明的只在其所在文件内生效。打包后的依赖里满是函数内的类
|
|
31
|
+
(`babel.cjs` 自带一个 `class Token`),它们不能劫持引用方想要的那个类型名;
|
|
29
32
|
- 数组、元组、函数类型、对象字面量与 `new LocalClass()`;
|
|
30
33
|
- 简单泛型:声明处的类型参数视为 `any`;调用时从实参推断(`T`、`T[]`、
|
|
31
34
|
`Array<T>`),或使用显式类型实参。
|
|
@@ -84,6 +87,13 @@
|
|
|
84
87
|
- 重载解析、映射类型、条件类型与模板字面量类型。
|
|
85
88
|
- `node_modules` 下被打包的源码完全不检查:检查器是针对你写的代码的门禁,
|
|
86
89
|
因为依赖内部而失败会让默认开启的检查器无法与 npm 包共存。
|
|
90
|
+
- 纯 JavaScript 源码也不做类型检查(TypeScript 只有在 `checkJs` 下才检查):
|
|
91
|
+
外部 `.js`/`.mjs`/`.cjs`/`.jsx` 脚本,以及 HTML 页面里没写 `lang="ts"` 的
|
|
92
|
+
内联 `<script>` 都算纯 JavaScript。名字仍然要解析、重复声明仍然会报(两者
|
|
93
|
+
都是生成代码所必需),但不产生类型、参数个数或属性诊断。这也正是浏览器
|
|
94
|
+
的规则:页面的脚本默认是 JavaScript,除非显式选择 TypeScript;而压缩后的
|
|
95
|
+
bundle 本来就会在字面量之后往状态对象上挂方法、用 `null` 初始化「稍后再调
|
|
96
|
+
用」的变量、通过默认参数调用函数。
|
|
87
97
|
|
|
88
98
|
## 关闭检查后的行为
|
|
89
99
|
|