xbintsc 0.5.22 → 0.5.31
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 +12 -3
- package/README.md +46 -11
- package/README.zh-CN.md +32 -6
- package/dist/scripts/support-matrix.d.ts +18 -0
- package/dist/scripts/support-matrix.js +141 -0
- package/dist/scripts/support-matrix.js.map +1 -0
- package/dist/src/ast/common.d.ts +2 -2
- package/dist/src/ast/declarations.d.ts +7 -1
- package/dist/src/ast/expressions.d.ts +5 -0
- package/dist/src/ast/kinds.d.ts +2 -0
- package/dist/src/ast/kinds.js +2 -0
- package/dist/src/ast/kinds.js.map +1 -1
- package/dist/src/binder/binder.d.ts +2 -1
- package/dist/src/binder/binder.js +2 -0
- package/dist/src/binder/binder.js.map +1 -1
- package/dist/src/binder/declarations.d.ts +9 -0
- package/dist/src/binder/declarations.js +64 -0
- package/dist/src/binder/declarations.js.map +1 -1
- package/dist/src/binder/references.js +85 -3
- package/dist/src/binder/references.js.map +1 -1
- package/dist/src/binder/types.d.ts +32 -0
- package/dist/src/binder/types.js.map +1 -1
- package/dist/src/canonical.d.ts +29 -0
- package/dist/src/canonical.js +35 -0
- package/dist/src/canonical.js.map +1 -0
- package/dist/src/checker/assignability.d.ts +13 -0
- package/dist/src/checker/assignability.js +146 -0
- package/dist/src/checker/assignability.js.map +1 -0
- package/dist/src/checker/calls.d.ts +13 -0
- package/dist/src/checker/calls.js +127 -0
- package/dist/src/checker/calls.js.map +1 -0
- package/dist/src/checker/checker.d.ts +26 -0
- package/dist/src/checker/checker.js +31 -0
- package/dist/src/checker/checker.js.map +1 -0
- package/dist/src/checker/declarations.d.ts +9 -0
- package/dist/src/checker/declarations.js +15 -0
- package/dist/src/checker/declarations.js.map +1 -0
- package/dist/src/checker/flow.d.ts +21 -0
- package/dist/src/checker/flow.js +241 -0
- package/dist/src/checker/flow.js.map +1 -0
- package/dist/src/checker/globals.d.ts +9 -0
- package/dist/src/checker/globals.js +29 -0
- package/dist/src/checker/globals.js.map +1 -0
- package/dist/src/checker/source.d.ts +38 -0
- package/dist/src/checker/source.js +48 -0
- package/dist/src/checker/source.js.map +1 -0
- package/dist/src/checker/type-infer.d.ts +18 -0
- package/dist/src/checker/type-infer.js +173 -0
- package/dist/src/checker/type-infer.js.map +1 -0
- package/dist/src/checker/type-model.d.ts +73 -0
- package/dist/src/checker/type-model.js +151 -0
- package/dist/src/checker/type-model.js.map +1 -0
- package/dist/src/checker/type-system.d.ts +58 -0
- package/dist/src/checker/type-system.js +569 -0
- package/dist/src/checker/type-system.js.map +1 -0
- package/dist/src/checker/typecheck-types.d.ts +22 -0
- package/dist/src/checker/typecheck-types.js +109 -0
- package/dist/src/checker/typecheck-types.js.map +1 -0
- package/dist/src/checker/typecheck.d.ts +62 -0
- package/dist/src/checker/typecheck.js +574 -0
- package/dist/src/checker/typecheck.js.map +1 -0
- package/dist/src/checker/undefined.d.ts +14 -0
- package/dist/src/checker/undefined.js +32 -0
- package/dist/src/checker/undefined.js.map +1 -0
- package/dist/src/checker/walk.d.ts +10 -0
- package/dist/src/checker/walk.js +15 -0
- package/dist/src/checker/walk.js.map +1 -0
- package/dist/src/cli/help.d.ts +7 -0
- package/dist/src/cli/help.js +64 -0
- package/dist/src/cli/help.js.map +1 -0
- package/dist/src/cli/hints.js +13 -1
- package/dist/src/cli/hints.js.map +1 -1
- package/dist/src/cli/main.js +12 -48
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +8 -8
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/invocation.js +9 -4
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls/super.d.ts +9 -1
- package/dist/src/codegen/generator/calls/super.js +56 -5
- package/dist/src/codegen/generator/calls/super.js.map +1 -1
- package/dist/src/codegen/generator/context.d.ts +13 -2
- package/dist/src/codegen/generator/context.js +25 -19
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +2 -1
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/primary.d.ts +4 -1
- package/dist/src/codegen/generator/expressions/primary.js +68 -8
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/generator.js +11 -1
- package/dist/src/codegen/generator/generator.js.map +1 -1
- package/dist/src/codegen/generator/module.d.ts +2 -0
- package/dist/src/codegen/generator/module.js +62 -26
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.d.ts +11 -1
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/statements/variables.js +20 -3
- package/dist/src/codegen/generator/statements/variables.js.map +1 -1
- package/dist/src/codegen/generator/tables.d.ts +2 -0
- package/dist/src/codegen/generator/tables.js +4 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +2 -0
- package/dist/src/driver/build-key.js +1 -0
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/bundler/graph.js +5 -1
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +16 -1
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/types.d.ts +12 -0
- package/dist/src/driver/compiler.d.ts +1 -1
- package/dist/src/driver/compiler.js +4 -0
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/fingerprint.js +2 -1
- package/dist/src/driver/fingerprint.js.map +1 -1
- package/dist/src/driver/frontend.d.ts +8 -6
- package/dist/src/driver/frontend.js +4 -0
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/options.d.ts +6 -0
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/catalog.js +2 -1
- package/dist/src/extensions/catalog.js.map +1 -1
- package/dist/src/extensions/gui/html.js +20 -6
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +63 -0
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/media/index.d.ts +27 -0
- package/dist/src/extensions/media/index.js +60 -0
- package/dist/src/extensions/media/index.js.map +1 -0
- package/dist/src/extensions/registry.d.ts +50 -0
- package/dist/src/extensions/registry.js +26 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/parser/declarations/classes.js +7 -0
- package/dist/src/parser/declarations/classes.js.map +1 -1
- package/dist/src/parser/expressions.js +14 -1
- package/dist/src/parser/expressions.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 +29 -0
- package/dist/tests/binder/binder.test.js.map +1 -1
- package/dist/tests/canonical.test.d.ts +1 -0
- package/dist/tests/canonical.test.js +19 -0
- package/dist/tests/canonical.test.js.map +1 -0
- package/dist/tests/checker/checker.test.d.ts +1 -0
- package/dist/tests/checker/checker.test.js +245 -0
- package/dist/tests/checker/checker.test.js.map +1 -0
- package/dist/tests/cli/check.test.js +20 -0
- package/dist/tests/cli/check.test.js.map +1 -1
- package/dist/tests/cli/hints.test.js +15 -0
- package/dist/tests/cli/hints.test.js.map +1 -1
- package/dist/tests/cli/process.test.js +12 -0
- package/dist/tests/cli/process.test.js.map +1 -1
- package/dist/tests/conformance/matrix.test.d.ts +6 -0
- package/dist/tests/conformance/matrix.test.js +23 -0
- package/dist/tests/conformance/matrix.test.js.map +1 -0
- package/dist/tests/conformance/test262/manifest.d.ts +115 -0
- package/dist/tests/conformance/test262/manifest.js +257 -0
- package/dist/tests/conformance/test262/manifest.js.map +1 -0
- package/dist/tests/conformance/test262.test.d.ts +11 -0
- package/dist/tests/conformance/test262.test.js +74 -0
- package/dist/tests/conformance/test262.test.js.map +1 -0
- package/dist/tests/docs/structure.test.js +9 -11
- package/dist/tests/docs/structure.test.js.map +1 -1
- package/dist/tests/e2e/child-process.test.js +3 -2
- package/dist/tests/e2e/child-process.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +21 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-objects-classes.test.js +54 -0
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/differential-syntax.test.d.ts +5 -0
- package/dist/tests/e2e/differential-syntax.test.js +95 -0
- package/dist/tests/e2e/differential-syntax.test.js.map +1 -0
- package/dist/tests/e2e/differential-values.test.js +15 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/gui-browser.test.d.ts +13 -0
- package/dist/tests/e2e/gui-browser.test.js +163 -0
- package/dist/tests/e2e/gui-browser.test.js.map +1 -0
- package/dist/tests/e2e/gui-example-browser.test.js +2 -2
- package/dist/tests/e2e/gui-example-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-example-canvas.test.js +8 -5
- package/dist/tests/e2e/gui-example-canvas.test.js.map +1 -1
- package/dist/tests/e2e/gui-example-svg.test.js +4 -3
- package/dist/tests/e2e/gui-example-svg.test.js.map +1 -1
- package/dist/tests/e2e/gui-example.test.js +4 -3
- package/dist/tests/e2e/gui-example.test.js.map +1 -1
- package/dist/tests/e2e/gui-helpers.d.ts +3 -0
- package/dist/tests/e2e/gui-helpers.js +6 -3
- package/dist/tests/e2e/gui-helpers.js.map +1 -1
- package/dist/tests/e2e/gui-media-disabled.test.d.ts +9 -0
- package/dist/tests/e2e/gui-media-disabled.test.js +42 -0
- package/dist/tests/e2e/gui-media-disabled.test.js.map +1 -0
- package/dist/tests/e2e/gui-media.test.d.ts +6 -4
- package/dist/tests/e2e/gui-media.test.js +20 -16
- package/dist/tests/e2e/gui-media.test.js.map +1 -1
- package/dist/tests/e2e/harness.d.ts +9 -0
- package/dist/tests/e2e/harness.js +14 -2
- package/dist/tests/e2e/harness.js.map +1 -1
- package/dist/tests/e2e/native-extensions.test.js +2 -1
- package/dist/tests/e2e/native-extensions.test.js.map +1 -1
- package/dist/tests/e2e/property-descriptors.test.js +20 -0
- package/dist/tests/e2e/property-descriptors.test.js.map +1 -1
- package/dist/tests/e2e/unicode-output.test.d.ts +16 -0
- package/dist/tests/e2e/unicode-output.test.js +67 -0
- package/dist/tests/e2e/unicode-output.test.js.map +1 -0
- package/dist/tests/e2e/weak-collections.test.js +16 -2
- package/dist/tests/e2e/weak-collections.test.js.map +1 -1
- package/dist/tests/extensions/media.test.d.ts +1 -0
- package/dist/tests/extensions/media.test.js +58 -0
- package/dist/tests/extensions/media.test.js.map +1 -0
- package/dist/tests/extensions/registry.test.js +8 -0
- package/dist/tests/extensions/registry.test.js.map +1 -1
- package/dist/tests/helpers.d.ts +1 -0
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/lexer/identifiers.test.js +12 -0
- package/dist/tests/lexer/identifiers.test.js.map +1 -1
- package/dist/tests/lexer/scanner.test.js +8 -0
- package/dist/tests/lexer/scanner.test.js.map +1 -1
- package/dist/tests/lexer/strings.test.js +30 -0
- package/dist/tests/lexer/strings.test.js.map +1 -1
- package/dist/tests/parser/declarations.test.js +20 -0
- package/dist/tests/parser/declarations.test.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/platform.d.ts +32 -0
- package/dist/tests/platform.js +40 -0
- package/dist/tests/platform.js.map +1 -0
- package/dist/tests/platform.test.d.ts +12 -0
- package/dist/tests/platform.test.js +51 -0
- package/dist/tests/platform.test.js.map +1 -0
- package/dist/tests/version.test.js +4 -4
- package/dist/tests/version.test.js.map +1 -1
- package/doc/ai/README.md +10 -4
- package/doc/ai/build-recipe.md +1 -0
- package/doc/ai/cli.md +18 -6
- package/doc/ai/contributing.md +59 -2
- package/doc/ai/extensions.md +46 -23
- package/doc/ai/language-support.md +25 -16
- package/doc/ai/troubleshooting.md +9 -0
- package/doc/ai/zh-CN/README.md +9 -4
- package/doc/ai/zh-CN/build-recipe.md +1 -0
- package/doc/ai/zh-CN/cli.md +14 -4
- package/doc/ai/zh-CN/contributing.md +49 -3
- package/doc/ai/zh-CN/extensions.md +29 -8
- package/doc/ai/zh-CN/language-support.md +23 -14
- package/doc/ai/zh-CN/troubleshooting.md +8 -0
- package/doc/gui/api.md +45 -0
- package/doc/gui/build.md +37 -21
- package/doc/gui/known-issues.md +17 -6
- package/doc/gui/media.md +26 -11
- package/doc/gui/runtime.md +18 -0
- package/doc/gui-scripts.md +7 -0
- package/doc/gui.md +43 -33
- package/doc/implemented/binder.md +2 -0
- package/doc/implemented/checker.md +117 -0
- package/doc/implemented/cli.md +13 -1
- package/doc/implemented/codegen.md +3 -2
- package/doc/implemented/driver.md +2 -2
- package/doc/implemented/operators.md +2 -1
- package/doc/implemented/parser.md +3 -2
- package/doc/implemented/pipeline.md +8 -1
- package/doc/implemented/stdlib.md +2 -1
- package/doc/implemented/tests.md +3 -1
- package/doc/implemented.md +2 -0
- package/doc/npm-package.md +417 -0
- package/doc/requirements.md +4 -1
- package/doc/support-matrix.md +83 -0
- package/doc/unimplemented/classes.md +3 -0
- package/doc/unimplemented/deviations.md +3 -2
- package/doc/unimplemented/toolchain.md +1 -1
- package/doc/unimplemented/types.md +24 -8
- package/doc/unimplemented.md +1 -1
- package/doc/zh-CN/gui/api.md +41 -0
- package/doc/zh-CN/gui/build.md +28 -16
- package/doc/zh-CN/gui/known-issues.md +13 -5
- package/doc/zh-CN/gui/media.md +21 -10
- package/doc/zh-CN/gui/runtime.md +16 -0
- package/doc/zh-CN/gui-scripts.md +5 -0
- package/doc/zh-CN/gui.md +37 -32
- package/doc/zh-CN/implemented/binder.md +2 -0
- package/doc/zh-CN/implemented/checker.md +99 -0
- package/doc/zh-CN/implemented/cli.md +12 -1
- package/doc/zh-CN/implemented/codegen.md +3 -2
- package/doc/zh-CN/implemented/driver.md +2 -2
- package/doc/zh-CN/implemented/operators.md +1 -1
- package/doc/zh-CN/implemented/parser.md +3 -2
- package/doc/zh-CN/implemented/pipeline.md +3 -1
- package/doc/zh-CN/implemented/stdlib.md +2 -1
- package/doc/zh-CN/implemented/tests.md +3 -1
- package/doc/zh-CN/implemented.md +2 -0
- package/doc/zh-CN/npm-package.md +391 -0
- package/doc/zh-CN/post/announce.md +47 -47
- package/doc/zh-CN/requirements.md +4 -1
- package/doc/zh-CN/support-matrix.md +82 -0
- package/doc/zh-CN/unimplemented/classes.md +3 -0
- package/doc/zh-CN/unimplemented/deviations.md +3 -2
- package/doc/zh-CN/unimplemented/toolchain.md +1 -1
- package/doc/zh-CN/unimplemented/types.md +16 -6
- package/doc/zh-CN/unimplemented.md +1 -1
- package/llms.txt +4 -1
- package/package.json +3 -1
- package/runtime/ext_gui/audio.cpp +316 -0
- package/runtime/ext_gui/browser.cpp +547 -0
- package/runtime/ext_gui/browser_escape.cpp +85 -0
- package/runtime/ext_gui/browser_loop.cpp +83 -0
- package/runtime/ext_gui/canvas.cpp +9 -3
- package/runtime/ext_gui/canvas_raster.cpp +19 -1
- package/runtime/ext_gui/dom_api.cpp +36 -0
- package/runtime/ext_gui/dom_api_document.cpp +96 -5
- package/runtime/ext_gui/dom_api_events.cpp +20 -0
- package/runtime/ext_gui/dom_api_internal.h +19 -0
- package/runtime/ext_gui/dom_api_proto.cpp +6 -0
- package/runtime/ext_gui/gui.cpp +90 -23
- package/runtime/ext_gui/gui_engine.h +44 -0
- package/runtime/ext_gui/gui_media.cpp +69 -2
- package/runtime/ext_gui/media.cpp +34 -488
- package/runtime/ext_gui/media.h +54 -19
- package/runtime/ext_gui/media_api.h +65 -0
- package/runtime/ext_gui/window.cpp +9 -0
- package/runtime/ext_media/media.cpp +507 -0
- package/runtime/ext_media/media_bridge.c +35 -0
- package/runtime/ext_node/path/path.c +7 -7
- package/runtime/ext_node/url/url.c +4 -2
- package/runtime/rt.h +15 -0
- package/runtime/xt_constructors.c +2 -1
- package/runtime/xt_containers/objects.inc +22 -2
- package/runtime/xt_io/exception.inc +4 -2
- package/runtime/xt_stdlib/math.inc +62 -0
- package/runtime/xt_stdlib2/date.inc +7 -1
- package/runtime/xt_stdlib2/objects.inc +14 -0
- package/scripts/build-gui.ts +6 -72
- package/scripts/build-media.ts +245 -0
- package/scripts/support-matrix.ts +167 -0
- package/src/ast/common.ts +2 -0
- package/src/ast/declarations.ts +12 -1
- package/src/ast/expressions.ts +6 -0
- package/src/ast/kinds.ts +2 -0
- package/src/binder/binder.ts +3 -0
- package/src/binder/declarations.ts +70 -0
- package/src/binder/references.ts +84 -3
- package/src/binder/types.ts +30 -0
- package/src/canonical.ts +37 -0
- package/src/checker/assignability.ts +134 -0
- package/src/checker/calls.ts +135 -0
- package/src/checker/checker.ts +47 -0
- package/src/checker/declarations.ts +26 -0
- package/src/checker/flow.ts +236 -0
- package/src/checker/globals.ts +40 -0
- package/src/checker/source.ts +53 -0
- package/src/checker/type-infer.ts +185 -0
- package/src/checker/type-model.ts +212 -0
- package/src/checker/type-system.ts +578 -0
- package/src/checker/typecheck-types.ts +112 -0
- package/src/checker/typecheck.ts +586 -0
- package/src/checker/undefined.ts +43 -0
- package/src/checker/walk.ts +16 -0
- package/src/cli/help.ts +65 -0
- package/src/cli/hints.ts +13 -1
- package/src/cli/main.ts +12 -49
- package/src/codegen/generator/calls/access.ts +8 -8
- package/src/codegen/generator/calls/invocation.ts +8 -5
- package/src/codegen/generator/calls/super.ts +67 -5
- package/src/codegen/generator/context.ts +31 -19
- package/src/codegen/generator/debug.ts +2 -1
- package/src/codegen/generator/expressions/primary.ts +84 -13
- package/src/codegen/generator/generator.ts +11 -1
- package/src/codegen/generator/module.ts +65 -24
- package/src/codegen/generator/state.ts +11 -1
- package/src/codegen/generator/statements/variables.ts +20 -3
- package/src/codegen/generator/tables.ts +5 -0
- package/src/driver/build-key.ts +3 -0
- package/src/driver/bundler/graph.ts +6 -2
- package/src/driver/bundler/merge.ts +14 -1
- package/src/driver/bundler/types.ts +13 -0
- package/src/driver/compiler.ts +5 -1
- package/src/driver/fingerprint.ts +2 -1
- package/src/driver/frontend.ts +13 -2
- package/src/driver/options.ts +6 -0
- package/src/driver/version.ts +1 -1
- package/src/extensions/catalog.ts +2 -1
- package/src/extensions/gui/html.ts +23 -10
- package/src/extensions/gui/index.ts +65 -0
- package/src/extensions/media/index.ts +67 -0
- package/src/extensions/registry.ts +72 -0
- package/src/index.ts +2 -0
- package/src/parser/declarations/classes.ts +7 -0
- package/src/parser/expressions.ts +13 -1
- package/src/parser/literals.ts +6 -2
|
@@ -38,6 +38,62 @@ const guiModule: ExtensionModule = {
|
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Browser globals a script written for a real page expects to find.
|
|
43
|
+
*
|
|
44
|
+
* Every entry is a *value*, not a function: reading the identifier calls a
|
|
45
|
+
* runtime getter that returns the live host object, so `document.getElementById`
|
|
46
|
+
* or `new Image()` work without a `declare` in the source. The host objects are
|
|
47
|
+
* installed on the current window by `runtime/ext_gui/browser.cpp`.
|
|
48
|
+
*
|
|
49
|
+
* `xt_browser_type` carries the name as its argument, which is how one getter
|
|
50
|
+
* serves the whole family of DOM types, and `xt_browser_missing` is deliberately
|
|
51
|
+
* `undefined` so feature probes such as `typeof OffscreenCanvas === "undefined"`
|
|
52
|
+
* take the fallback path instead of calling a stub that does nothing.
|
|
53
|
+
*/
|
|
54
|
+
const hostTypes = [
|
|
55
|
+
"Image",
|
|
56
|
+
"Audio",
|
|
57
|
+
"AudioContext",
|
|
58
|
+
"webkitAudioContext",
|
|
59
|
+
"OffscreenCanvas",
|
|
60
|
+
"ImageBitmap",
|
|
61
|
+
"ImageData",
|
|
62
|
+
"HTMLCanvasElement",
|
|
63
|
+
"HTMLImageElement",
|
|
64
|
+
"HTMLVideoElement",
|
|
65
|
+
"HTMLAudioElement",
|
|
66
|
+
"HTMLElement",
|
|
67
|
+
"Element",
|
|
68
|
+
"Node",
|
|
69
|
+
"Event",
|
|
70
|
+
"CustomEvent",
|
|
71
|
+
"ProgressEvent",
|
|
72
|
+
"EventTarget",
|
|
73
|
+
"DOMParser",
|
|
74
|
+
"Request",
|
|
75
|
+
"Headers",
|
|
76
|
+
"Response",
|
|
77
|
+
"ReadableStream",
|
|
78
|
+
"WebGLRenderingContext",
|
|
79
|
+
"WebGL2RenderingContext",
|
|
80
|
+
"XRWebGLLayer",
|
|
81
|
+
"XRWebGLBinding",
|
|
82
|
+
] as const;
|
|
83
|
+
|
|
84
|
+
const browserGlobals: Record<string, { symbol: string; argument?: string }> = {
|
|
85
|
+
window: { symbol: "xt_browser_window" },
|
|
86
|
+
self: { symbol: "xt_browser_window" },
|
|
87
|
+
document: { symbol: "xt_browser_document" },
|
|
88
|
+
navigator: { symbol: "xt_browser_navigator" },
|
|
89
|
+
localStorage: { symbol: "xt_browser_local_storage" },
|
|
90
|
+
__THREE_DEVTOOLS__: { symbol: "xt_browser_missing" },
|
|
91
|
+
createImageBitmap: { symbol: "xt_browser_missing" },
|
|
92
|
+
};
|
|
93
|
+
for (const type of hostTypes) {
|
|
94
|
+
browserGlobals[type] = { symbol: "xt_browser_type", argument: type };
|
|
95
|
+
}
|
|
96
|
+
|
|
41
97
|
/** Absolute path to the per-platform prebuilt GUI archive (`gui.a`, or
|
|
42
98
|
* `gui.lib` with the MSVC ABI on Windows). */
|
|
43
99
|
function guiArchive(): string {
|
|
@@ -120,7 +176,16 @@ export const guiExtension: Extension = {
|
|
|
120
176
|
*/
|
|
121
177
|
builtins: () => ({
|
|
122
178
|
__registerScript: { symbol: "xt_register_script" },
|
|
179
|
+
requestAnimationFrame: { symbol: "xt_browser_request_animation_frame" },
|
|
180
|
+
cancelAnimationFrame: { symbol: "xt_browser_cancel_animation_frame" },
|
|
181
|
+
matchMedia: { symbol: "xt_browser_match_media" },
|
|
182
|
+
getComputedStyle: { symbol: "xt_browser_computed_style" },
|
|
183
|
+
escape: { symbol: "xt_browser_escape" },
|
|
184
|
+
alert: { symbol: "xt_browser_alert" },
|
|
185
|
+
prompt: { symbol: "xt_browser_prompt" },
|
|
123
186
|
}),
|
|
187
|
+
/** Browser globals (`window`, `document`, the DOM type names). */
|
|
188
|
+
globalValues: () => browserGlobals,
|
|
124
189
|
/** Rewrite imported `.html` assets (see `html.ts`). */
|
|
125
190
|
assetLoaders: () => ({ ".html": loadHtmlAsset }),
|
|
126
191
|
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media extension: `<video>` / `<audio>` decoding for the GUI engine.
|
|
3
|
+
*
|
|
4
|
+
* The GUI extension is deliberately decoder-free: it models media elements,
|
|
5
|
+
* renders their frames and routes the DOM API, but keeps FFmpeg out of `gui.a`
|
|
6
|
+
* so a program that only needs windows and HTML/CSS does not pay for a media
|
|
7
|
+
* stack it never uses. This extension supplies the decoding half:
|
|
8
|
+
*
|
|
9
|
+
* - `media.a` (built by `npm run media`) contains the FFmpeg-linked player
|
|
10
|
+
* from `runtime/ext_media/media.cpp` and the static FFmpeg libraries;
|
|
11
|
+
* - `runtime/ext_media/media_bridge.c` is compiled and linked directly. Its
|
|
12
|
+
* constructor installs the player table into the GUI engine and references
|
|
13
|
+
* the backend entry points, which makes the linker extract the archive
|
|
14
|
+
* member — a static archive whose only entry point is a constructor would
|
|
15
|
+
* otherwise never be pulled in.
|
|
16
|
+
*
|
|
17
|
+
* There is no importable TypeScript module: the feature is the DOM media
|
|
18
|
+
* surface that the `gui` module already exposes. Enable both extensions:
|
|
19
|
+
*
|
|
20
|
+
* xbintsc run app.ts --ext gui,media
|
|
21
|
+
*
|
|
22
|
+
* The archive is POSIX-only for now (the build needs FFmpeg's `configure` and
|
|
23
|
+
* an MSVC-compatible FFmpeg has not been built), so Windows reports an
|
|
24
|
+
* actionable error instead of linking an inert element.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { join } from "node:path";
|
|
28
|
+
import type { Extension } from "../registry.js";
|
|
29
|
+
import { findRuntimeDir, platformSlug } from "../../driver/paths.js";
|
|
30
|
+
import { findRuntimeLibrary } from "../../driver/runtime-lib.js";
|
|
31
|
+
|
|
32
|
+
/** Absolute path to the per-platform prebuilt media archive. */
|
|
33
|
+
function mediaArchive(): string {
|
|
34
|
+
return join(findRuntimeDir(), "lib", platformSlug(), "media.a");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const mediaExtension: Extension = {
|
|
38
|
+
name: "media",
|
|
39
|
+
description: "Video/audio decoding for <video>/<audio> (requires gui, links FFmpeg)",
|
|
40
|
+
requires: ["gui"],
|
|
41
|
+
/**
|
|
42
|
+
* The registration bridge is a tiny C file linked as a normal object, so its
|
|
43
|
+
* constructor always runs. Keeping it out of `media.a` is what guarantees the
|
|
44
|
+
* archive is searched (see the header comment).
|
|
45
|
+
*/
|
|
46
|
+
runtimeSources: () => [join(findRuntimeDir(), "ext_media", "media_bridge.c")],
|
|
47
|
+
nativeObjects: () => {
|
|
48
|
+
if (process.platform === "win32") {
|
|
49
|
+
throw new Error(
|
|
50
|
+
"the media extension is not available on Windows yet: it needs an MSVC-compatible " +
|
|
51
|
+
"FFmpeg build (see doc/gui/known-issues.md). Build without --ext media; media " +
|
|
52
|
+
"elements then report an 'error' event.",
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
const archive = findRuntimeLibrary("media");
|
|
56
|
+
if (archive === undefined) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`media native library not found at ${mediaArchive()} (or media.lib).\n` +
|
|
59
|
+
`Build it for ${platformSlug()} first with \`npm run media\` (see doc/gui/build.md).`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return [archive];
|
|
63
|
+
},
|
|
64
|
+
/** `media.a` is C++ and FFmpeg itself needs libm; the GUI extension already
|
|
65
|
+
* contributes the C++ runtime and the OS frameworks. */
|
|
66
|
+
linkerFlags: () => (process.platform === "win32" ? [] : ["-lm"]),
|
|
67
|
+
};
|
|
@@ -17,6 +17,23 @@ export interface BuiltinFunction {
|
|
|
17
17
|
readonly returnVoid?: boolean;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* A global *value* rather than a function: the name resolves to whatever a
|
|
22
|
+
* runtime getter returns, so `window`, `document` or a host constructor
|
|
23
|
+
* (`new AudioContext()`) can be reached without declaring them in the source.
|
|
24
|
+
*
|
|
25
|
+
* `symbol` has the usual `(int32_t argc, xt_value *argv)` ABI and is called
|
|
26
|
+
* with no arguments, or with one argument when `argument` is set (that is how
|
|
27
|
+
* a host hands a single getter a type name such as `"HTMLCanvasElement"`).
|
|
28
|
+
* `new Name(...)` lowers to the getter followed by an ordinary `xt_new`, so a
|
|
29
|
+
* host constructor is just a global value that returns a function.
|
|
30
|
+
*/
|
|
31
|
+
export interface GlobalValue {
|
|
32
|
+
readonly symbol: string;
|
|
33
|
+
/** Passed as the only argument; omit to call the getter with none. */
|
|
34
|
+
readonly argument?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
20
37
|
/**
|
|
21
38
|
* One binding a Node-style module exports. It is either a direct runtime
|
|
22
39
|
* function with the uniform `(argc, argv)` ABI (`symbol`), or a named method
|
|
@@ -59,6 +76,14 @@ export interface AssetLoadResult {
|
|
|
59
76
|
* contain its own `import`/`export` statements, which are followed normally.
|
|
60
77
|
*/
|
|
61
78
|
readonly moduleSource: string;
|
|
79
|
+
/**
|
|
80
|
+
* Ranges of `moduleSource` that were copied verbatim from *another* file —
|
|
81
|
+
* for instance the body of `<script src="app.js">` wrapped by the `gui`
|
|
82
|
+
* `.html` loader. Nodes inside a range keep that file as their origin, so
|
|
83
|
+
* diagnostics name the file the user actually wrote and the checker's
|
|
84
|
+
* plain-JavaScript exemption still applies to a `.js` script.
|
|
85
|
+
*/
|
|
86
|
+
readonly sourceRanges?: readonly AssetSourceRange[];
|
|
62
87
|
/**
|
|
63
88
|
* Extra files the transformed module depends on that are *not* reached
|
|
64
89
|
* through imports (for cache invalidation). Imported files are already
|
|
@@ -67,6 +92,13 @@ export interface AssetLoadResult {
|
|
|
67
92
|
readonly dependencies?: readonly string[];
|
|
68
93
|
}
|
|
69
94
|
|
|
95
|
+
/** A `[start, end)` span of a generated module copied from `file`. */
|
|
96
|
+
export interface AssetSourceRange {
|
|
97
|
+
readonly start: number;
|
|
98
|
+
readonly end: number;
|
|
99
|
+
readonly file: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
70
102
|
/** Rewrites an imported file (selected by extension) into a TS module. */
|
|
71
103
|
export type AssetLoader = (path: string, source: string) => AssetLoadResult;
|
|
72
104
|
|
|
@@ -74,6 +106,12 @@ export interface Extension {
|
|
|
74
106
|
readonly name: string;
|
|
75
107
|
/** Description shown by `xbintsc ext list`. */
|
|
76
108
|
readonly description?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Other extensions this one needs. The registry rejects a build that enables
|
|
111
|
+
* it without them, so a dependent extension fails with an actionable message
|
|
112
|
+
* instead of an unresolved symbol at link time (e.g. `media` needs `gui`).
|
|
113
|
+
*/
|
|
114
|
+
readonly requires?: readonly string[];
|
|
77
115
|
/** C/asm sources compiled and linked alongside the generated module. */
|
|
78
116
|
runtimeSources?(): readonly string[];
|
|
79
117
|
/**
|
|
@@ -91,6 +129,12 @@ export interface Extension {
|
|
|
91
129
|
linkerFlags?(): readonly string[];
|
|
92
130
|
/** Global identifiers that resolve to runtime symbols when called. */
|
|
93
131
|
builtins?(): Readonly<Record<string, BuiltinFunction>>;
|
|
132
|
+
/**
|
|
133
|
+
* Global identifiers that resolve to a runtime *value* (`window`,
|
|
134
|
+
* `document`, a host constructor). They need no declaration in the source
|
|
135
|
+
* and are not callable-by-name: reading the identifier calls the getter.
|
|
136
|
+
*/
|
|
137
|
+
globalValues?(): Readonly<Record<string, GlobalValue>>;
|
|
94
138
|
/** Modules importable as `import ... from "<specifier>"`. */
|
|
95
139
|
modules?(): Readonly<Record<string, ExtensionModule>>;
|
|
96
140
|
/**
|
|
@@ -145,6 +189,24 @@ export class ExtensionRegistry {
|
|
|
145
189
|
return this.extensions.delete(name);
|
|
146
190
|
}
|
|
147
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Throw when a registered extension requires one that is not registered.
|
|
194
|
+
* Called before a build so `--ext media` without `--ext gui` reports which
|
|
195
|
+
* flags to pass instead of failing later with an unresolved symbol.
|
|
196
|
+
*/
|
|
197
|
+
validate(): this {
|
|
198
|
+
for (const extension of this.extensions.values()) {
|
|
199
|
+
for (const dependency of extension.requires ?? []) {
|
|
200
|
+
if (this.extensions.has(dependency)) continue;
|
|
201
|
+
throw new Error(
|
|
202
|
+
`extension '${extension.name}' requires the '${dependency}' extension; ` +
|
|
203
|
+
`pass --ext ${dependency},${extension.name}`,
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return this;
|
|
208
|
+
}
|
|
209
|
+
|
|
148
210
|
get(name: string): Extension | undefined {
|
|
149
211
|
return this.extensions.get(name);
|
|
150
212
|
}
|
|
@@ -167,6 +229,16 @@ export class ExtensionRegistry {
|
|
|
167
229
|
return merged;
|
|
168
230
|
}
|
|
169
231
|
|
|
232
|
+
/** Flatten every registered extension's global values into one lookup. */
|
|
233
|
+
globalValues(): Readonly<Record<string, GlobalValue>> {
|
|
234
|
+
const merged: Record<string, GlobalValue> = {};
|
|
235
|
+
for (const extension of this.extensions.values()) {
|
|
236
|
+
const values = extension.globalValues?.();
|
|
237
|
+
if (values) Object.assign(merged, values);
|
|
238
|
+
}
|
|
239
|
+
return merged;
|
|
240
|
+
}
|
|
241
|
+
|
|
170
242
|
/** Flatten every registered extension's importable modules. */
|
|
171
243
|
modules(): Readonly<Record<string, ExtensionModule>> {
|
|
172
244
|
const merged: Record<string, ExtensionModule> = {};
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { TokenKind, KEYWORDS, type Token } from "./lexer/token.js";
|
|
|
19
19
|
export * from "./ast/nodes.js";
|
|
20
20
|
export { Parser } from "./parser/parser.js";
|
|
21
21
|
export { bind, SymbolKind, ScopeKind, type BindResult, type FunctionInfo, type SymbolInfo } from "./binder/binder.js";
|
|
22
|
+
export { checkProgram, type CheckOptions } from "./checker/checker.js";
|
|
22
23
|
export { generate, type CodegenResult, type CodegenOptions } from "./codegen/llvm.js";
|
|
23
24
|
export {
|
|
24
25
|
XT_UNDEFINED,
|
|
@@ -32,6 +33,7 @@ export {
|
|
|
32
33
|
export { ExtensionRegistry, createDefaultRegistry, coreExtension, type Extension, type ExtensionModule, type ModuleExport, type ModuleExports, type AssetLoader, type AssetLoadResult } from "./extensions/registry.js";
|
|
33
34
|
export { bundledExtensions } from "./extensions/catalog.js";
|
|
34
35
|
export { nodeExtension } from "./extensions/node/index.js";
|
|
36
|
+
export { mediaExtension } from "./extensions/media/index.js";
|
|
35
37
|
export type { NodeModule } from "./extensions/node/module.js";
|
|
36
38
|
export {
|
|
37
39
|
NativeExtensionError,
|
|
@@ -85,6 +85,13 @@ export const declarationClassMethods: DeclarationClassMethods = {
|
|
|
85
85
|
this.nextToken();
|
|
86
86
|
return undefined;
|
|
87
87
|
}
|
|
88
|
+
/* `static { ... }`: a block that runs once while the class is defined. The
|
|
89
|
+
* `static` keyword was already consumed by `tryParseModifiers`, so the
|
|
90
|
+
* initializer position is the only way to tell it apart from a member. */
|
|
91
|
+
if (this.at(TokenKind.OpenBrace) && this.hasModifier(modifiers, ModifierKind.Static)) {
|
|
92
|
+
const body = this.parseBlock();
|
|
93
|
+
return { kind: SyntaxKind.ClassStaticBlockDeclaration, modifiers, body, start, end: body.end };
|
|
94
|
+
}
|
|
88
95
|
if (
|
|
89
96
|
(this.at(TokenKind.GetKeyword) || this.at(TokenKind.SetKeyword)) &&
|
|
90
97
|
!this.atAhead(1, TokenKind.OpenParen) &&
|
|
@@ -61,7 +61,19 @@ export interface ExpressionMethods {
|
|
|
61
61
|
|
|
62
62
|
export const expressionMethods: ExpressionMethods = {
|
|
63
63
|
parseExpression(this: Parser, noIn = false): Expression {
|
|
64
|
-
|
|
64
|
+
const first = this.parseAssignmentExpression(noIn);
|
|
65
|
+
if (!this.at(TokenKind.Comma)) return first;
|
|
66
|
+
const expressions: Expression[] = [first];
|
|
67
|
+
while (this.at(TokenKind.Comma)) {
|
|
68
|
+
this.nextToken();
|
|
69
|
+
expressions.push(this.parseAssignmentExpression(noIn));
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
kind: SyntaxKind.SequenceExpression,
|
|
73
|
+
expressions,
|
|
74
|
+
start: first.start,
|
|
75
|
+
end: expressions[expressions.length - 1]!.end,
|
|
76
|
+
};
|
|
65
77
|
},
|
|
66
78
|
|
|
67
79
|
parseAssignmentExpression(this: Parser, noIn = false): Expression {
|
package/src/parser/literals.ts
CHANGED
|
@@ -159,8 +159,12 @@ export const literalMethods: LiteralMethods = {
|
|
|
159
159
|
},
|
|
160
160
|
|
|
161
161
|
parseFunctionExpression(this: Parser): FunctionExpression {
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
/* `async function (...) {}` is an expression too; the `async` keyword is
|
|
163
|
+
* part of this node rather than a modifier list. */
|
|
164
|
+
const asyncToken = this.at(TokenKind.AsyncKeyword) ? this.nextToken() : undefined;
|
|
165
|
+
const functionToken = this.parseExpected(TokenKind.FunctionKeyword);
|
|
166
|
+
const start = asyncToken ? asyncToken.start : functionToken.start;
|
|
167
|
+
let flags = asyncToken ? NodeFlags.Async : NodeFlags.None;
|
|
164
168
|
if (this.at(TokenKind.Asterisk)) {
|
|
165
169
|
this.nextToken();
|
|
166
170
|
flags |= NodeFlags.Generator;
|