xbintsc 0.5.23 → 0.5.32
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 +11 -2
- package/README.md +47 -16
- package/README.zh-CN.md +21 -2
- 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 +99 -4
- 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 +2 -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 +3 -0
- package/dist/src/codegen/generator/module.js +116 -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 +26 -7
- 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 +3 -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/gui/css.d.ts +26 -0
- package/dist/src/extensions/gui/css.js +100 -0
- package/dist/src/extensions/gui/css.js.map +1 -0
- package/dist/src/extensions/gui/html.js +28 -7
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +79 -2
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/gui/three.d.ts +16 -0
- package/dist/src/extensions/gui/three.js +22 -0
- package/dist/src/extensions/gui/three.js.map +1 -0
- package/dist/src/extensions/media/index.d.ts +6 -5
- package/dist/src/extensions/media/index.js +12 -14
- package/dist/src/extensions/media/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +38 -0
- package/dist/src/extensions/registry.js +10 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/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/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 +45 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-objects-classes.test.js +77 -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-effects.test.d.ts +6 -0
- package/dist/tests/e2e/gui-effects.test.js +262 -0
- package/dist/tests/e2e/gui-effects.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 +5 -4
- 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-webgl.test.d.ts +10 -0
- package/dist/tests/e2e/gui-example-webgl.test.js +75 -0
- package/dist/tests/e2e/gui-example-webgl.test.js.map +1 -0
- package/dist/tests/e2e/gui-example-webgl2.test.d.ts +8 -0
- package/dist/tests/e2e/gui-example-webgl2.test.js +72 -0
- package/dist/tests/e2e/gui-example-webgl2.test.js.map +1 -0
- 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.js +4 -3
- package/dist/tests/e2e/gui-helpers.js.map +1 -1
- package/dist/tests/e2e/gui-layout.test.js +48 -0
- package/dist/tests/e2e/gui-layout.test.js.map +1 -1
- package/dist/tests/e2e/gui-media.test.js +10 -8
- package/dist/tests/e2e/gui-media.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl.test.d.ts +11 -0
- package/dist/tests/e2e/gui-webgl.test.js +179 -0
- package/dist/tests/e2e/gui-webgl.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2.test.js +238 -0
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -0
- 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.js +5 -3
- package/dist/tests/e2e/unicode-output.test.js.map +1 -1
- 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/gui.test.js +41 -0
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/extensions/media.test.js +7 -3
- package/dist/tests/extensions/media.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/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 +17 -5
- package/doc/ai/contributing.md +59 -2
- package/doc/ai/extensions.md +38 -7
- package/doc/ai/language-support.md +25 -16
- package/doc/ai/troubleshooting.md +12 -8
- 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 +13 -3
- package/doc/ai/zh-CN/contributing.md +49 -3
- package/doc/ai/zh-CN/extensions.md +33 -6
- package/doc/ai/zh-CN/language-support.md +23 -14
- package/doc/ai/zh-CN/troubleshooting.md +10 -6
- package/doc/gui/api.md +47 -1
- package/doc/gui/build.md +72 -16
- package/doc/gui/canvas.md +11 -3
- package/doc/gui/dom.md +33 -18
- package/doc/gui/known-issues.md +58 -15
- package/doc/gui/layout.md +18 -0
- package/doc/gui/media.md +17 -13
- package/doc/gui/rendering.md +50 -3
- package/doc/gui/runtime.md +18 -0
- package/doc/gui/webgl.md +256 -0
- package/doc/gui-scripts.md +7 -0
- package/doc/gui.md +108 -17
- 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 +419 -0
- package/doc/requirements.md +22 -10
- 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 +43 -1
- package/doc/zh-CN/gui/build.md +64 -15
- package/doc/zh-CN/gui/canvas.md +9 -2
- package/doc/zh-CN/gui/dom.md +20 -7
- package/doc/zh-CN/gui/known-issues.md +46 -13
- package/doc/zh-CN/gui/layout.md +14 -0
- package/doc/zh-CN/gui/media.md +15 -11
- package/doc/zh-CN/gui/rendering.md +41 -4
- package/doc/zh-CN/gui/runtime.md +16 -0
- package/doc/zh-CN/gui/webgl.md +115 -0
- package/doc/zh-CN/gui-scripts.md +5 -0
- package/doc/zh-CN/gui.md +89 -14
- 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 +394 -0
- package/doc/zh-CN/post/announce.md +47 -47
- package/doc/zh-CN/requirements.md +16 -7
- 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 +6 -1
- package/package.json +2 -1
- package/runtime/ext_gui/audio.cpp +316 -0
- package/runtime/ext_gui/browser.cpp +573 -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 +12 -21
- package/runtime/ext_gui/canvas_internal.h +10 -0
- package/runtime/ext_gui/canvas_raster.cpp +79 -1
- package/runtime/ext_gui/clip_values.cpp +246 -0
- package/runtime/ext_gui/css.cpp +94 -0
- package/runtime/ext_gui/css.h +22 -1
- package/runtime/ext_gui/css_match.cpp +3 -0
- package/runtime/ext_gui/css_selector.cpp +9 -0
- package/runtime/ext_gui/css_sheet.cpp +89 -45
- package/runtime/ext_gui/document.cpp +4 -1
- package/runtime/ext_gui/document.h +2 -0
- package/runtime/ext_gui/dom.h +16 -0
- package/runtime/ext_gui/dom_api.cpp +37 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +17 -80
- package/runtime/ext_gui/dom_api_canvas_extra.cpp +130 -1
- package/runtime/ext_gui/dom_api_canvas_pending.cpp +41 -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 +278 -0
- package/runtime/ext_gui/dom_api_proto.cpp +6 -0
- package/runtime/ext_gui/dom_api_webgl.cpp +376 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +434 -0
- package/runtime/ext_gui/dom_api_webgl2_draw.cpp +269 -0
- package/runtime/ext_gui/dom_api_webgl_buffer.cpp +212 -0
- package/runtime/ext_gui/dom_api_webgl_rt.h +30 -0
- package/runtime/ext_gui/dom_api_webgl_shader.cpp +443 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +444 -0
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +445 -0
- package/runtime/ext_gui/effect_values.cpp +312 -0
- package/runtime/ext_gui/gradient_values.cpp +476 -0
- package/runtime/ext_gui/grid_values.cpp +230 -0
- package/runtime/ext_gui/gui.cpp +90 -23
- package/runtime/ext_gui/gui_canvas.cpp +50 -2
- package/runtime/ext_gui/gui_engine.h +71 -0
- package/runtime/ext_gui/gui_events.cpp +4 -1
- package/runtime/ext_gui/gui_media.cpp +1 -1
- package/runtime/ext_gui/gui_webgl.cpp +83 -0
- package/runtime/ext_gui/layout.cpp +21 -0
- package/runtime/ext_gui/layout_flow.cpp +81 -4
- package/runtime/ext_gui/layout_flow_internal.h +31 -0
- package/runtime/ext_gui/layout_grid.cpp +374 -0
- package/runtime/ext_gui/media.h +1 -1
- package/runtime/ext_gui/media_api.h +2 -2
- package/runtime/ext_gui/media_query.cpp +211 -0
- package/runtime/ext_gui/paint.cpp +111 -77
- package/runtime/ext_gui/paint.h +33 -3
- package/runtime/ext_gui/paint_background.cpp +229 -0
- package/runtime/ext_gui/paint_clip.cpp +268 -0
- package/runtime/ext_gui/paint_effects.cpp +324 -0
- package/runtime/ext_gui/paint_internal.h +85 -0
- package/runtime/ext_gui/renderer.cpp +8 -31
- package/runtime/ext_gui/renderer_clip.cpp +196 -0
- package/runtime/ext_gui/renderer_image.cpp +13 -8
- package/runtime/ext_gui/renderer_internal.h +15 -8
- package/runtime/ext_gui/renderer_text.cpp +6 -31
- package/runtime/ext_gui/style.cpp +343 -20
- package/runtime/ext_gui/style.h +144 -3
- package/runtime/ext_gui/style_print.cpp +134 -1
- package/runtime/ext_gui/style_values.cpp +152 -126
- package/runtime/ext_gui/style_values_internal.h +35 -0
- package/runtime/ext_gui/webgl.h +466 -0
- package/runtime/ext_gui/webgl2_constants.h +274 -0
- package/runtime/ext_gui/webgl_buffer.cpp +565 -0
- package/runtime/ext_gui/webgl_constants.h +317 -0
- package/runtime/ext_gui/webgl_context.cpp +466 -0
- package/runtime/ext_gui/webgl_draw.cpp +495 -0
- package/runtime/ext_gui/webgl_glsl.h +125 -0
- package/runtime/ext_gui/webgl_glsl_compile.cpp +431 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +349 -0
- package/runtime/ext_gui/webgl_glsl_scan.cpp +581 -0
- package/runtime/ext_gui/webgl_msl.cpp +62 -0
- package/runtime/ext_gui/webgl_msl.h +33 -0
- package/runtime/ext_gui/webgl_pipeline.cpp +274 -0
- package/runtime/ext_gui/webgl_program_internal.h +18 -0
- package/runtime/ext_gui/webgl_shader.cpp +582 -0
- package/runtime/ext_gui/webgl_texture.cpp +293 -0
- package/runtime/ext_gui/webgl_uniform.cpp +167 -0
- package/runtime/ext_gui/webgl_webgl2.cpp +224 -0
- package/runtime/ext_gui/window.cpp +9 -0
- package/runtime/ext_media/media.cpp +1 -1
- package/runtime/ext_media/media_bridge.c +9 -3
- 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/rt_internal.h +1 -0
- package/runtime/xt_constructors.c +2 -1
- package/runtime/xt_containers/access.inc +8 -0
- package/runtime/xt_containers/objects.inc +22 -2
- package/runtime/xt_io/exception.inc +4 -2
- package/runtime/xt_regex/api.inc +2 -0
- package/runtime/xt_regex/matcher.inc +16 -3
- package/runtime/xt_regex/parser.inc +8 -2
- package/runtime/xt_regex/types.inc +3 -0
- 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/runtime/xt_stdlib2/regexp-match.inc +60 -21
- package/runtime/xt_stdlib2/regexp.inc +1 -0
- package/runtime/xt_typed_array.c +1 -1
- package/scripts/build-gui.ts +90 -3
- package/scripts/build-media.ts +323 -58
- package/scripts/setup-vs-toolchain.ps1 +152 -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 +97 -4
- 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 +2 -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 +115 -24
- package/src/codegen/generator/state.ts +11 -1
- package/src/codegen/generator/statements/variables.ts +26 -6
- 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 +4 -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/gui/css.ts +113 -0
- package/src/extensions/gui/html.ts +31 -11
- package/src/extensions/gui/index.ts +81 -2
- package/src/extensions/gui/three.ts +25 -0
- package/src/extensions/media/index.ts +13 -16
- package/src/extensions/registry.ts +48 -0
- package/src/index.ts +1 -0
- package/src/parser/declarations/classes.ts +7 -0
- package/src/parser/expressions.ts +13 -1
- package/src/parser/literals.ts +6 -2
package/doc/ai/cli.md
CHANGED
|
@@ -12,15 +12,25 @@ the help text leaves implicit.
|
|
|
12
12
|
| `xbintsc run <file.ts> [-- args]` | Compile to an executable and execute it | yes (`--emit exe` only) |
|
|
13
13
|
| `xbintsc watch <file.ts>` | Rebuild whenever the source tree changes (Ctrl+C to stop) | yes |
|
|
14
14
|
| `xbintsc emit <file.ts>` | Print LLVM IR to stdout, write nothing | no |
|
|
15
|
-
| `xbintsc check <file.ts>` | Front-end check (syntax, imports, supported subset); writes nothing | no |
|
|
15
|
+
| `xbintsc check <file.ts>` | Front-end check (syntax, imports, semantic checks, supported subset); writes nothing | no |
|
|
16
16
|
| `xbintsc doctor` | Report the resolved toolchain, runtime and icon tools | only for the probe |
|
|
17
17
|
| `xbintsc version` | Print the version | no |
|
|
18
18
|
| `xbintsc help` | Print the help text | no |
|
|
19
19
|
|
|
20
|
-
`check` is not a type checker: annotations are erased, so a
|
|
21
|
-
`check` can still fail at runtime. It catches syntax errors,
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
`check` is not a full type checker: annotations are erased after checking, so a
|
|
21
|
+
program that passes `check` can still fail at runtime. It catches syntax errors,
|
|
22
|
+
unresolved imports, constructs outside the supported subset, and the semantic
|
|
23
|
+
checker's diagnostics: unresolved names (TS3002), same-scope redeclarations
|
|
24
|
+
(TS3001), call-arity mismatches (TS4004), missing properties on known shapes
|
|
25
|
+
(TS4003), definite assignability mismatches (TS4001) and calls to non-callable
|
|
26
|
+
values (TS4002). That makes it a fast pre-commit or editor gate. `--no-check`
|
|
27
|
+
skips the semantic part; see [the checker page](../implemented/checker.md).
|
|
28
|
+
|
|
29
|
+
The checker is on by default for **every** command (`build`, `run`, `emit`,
|
|
30
|
+
`watch` and `check`). The flag is part of the incremental cache key, so a
|
|
31
|
+
`--no-check` build never reuses a checked artifact. Errors are reported before
|
|
32
|
+
clang runs, which is what makes `xbintsc check` cheap in an editor or a
|
|
33
|
+
pre-commit hook.
|
|
24
34
|
|
|
25
35
|
Any command also accepts `--help`, which prints the help text and exits 0. An
|
|
26
36
|
unknown command prints an error plus the help text and exits 1.
|
|
@@ -50,6 +60,8 @@ so restart it after installing a dependency.
|
|
|
50
60
|
--verbose Print progress information
|
|
51
61
|
--time Print per-phase build timings
|
|
52
62
|
--debug Emit debug info (DWARF/CodeView) and keep frame pointers
|
|
63
|
+
--check Run the semantic checker (default)
|
|
64
|
+
--no-check Skip the semantic checker; only erase type syntax
|
|
53
65
|
--lto Compile program and runtime to LTO bitcode; link with lld
|
|
54
66
|
--pgo-generate [dir] Build an instrumented binary writing profiles to dir
|
|
55
67
|
--pgo-use [dir] Build with the profiles collected from --pgo-generate
|
package/doc/ai/contributing.md
CHANGED
|
@@ -37,8 +37,9 @@ created by `release.yml`, never by the hook.
|
|
|
37
37
|
| `npm run bench` | build and time the fixed benchmark suite (optionally vs Node) |
|
|
38
38
|
|
|
39
39
|
Unit tests live one directory per module under `tests/` (`lexer`, `parser`,
|
|
40
|
-
`binder`, `codegen`, `driver`, `extensions`, `cli`, `
|
|
41
|
-
tree. Edge-case tests belong next to the module they
|
|
40
|
+
`binder`, `checker`, `codegen`, `driver`, `extensions`, `cli`, `conformance`,
|
|
41
|
+
`e2e`) and mirror the source tree. Edge-case tests belong next to the module they
|
|
42
|
+
cover.
|
|
42
43
|
|
|
43
44
|
`tests/e2e/` compiles real programs and runs the resulting binaries, including a
|
|
44
45
|
**differential harness** (`tests/e2e/differential-*.test.ts`) that executes the
|
|
@@ -49,6 +50,62 @@ clang skip themselves when it is unavailable (`hasClang()` in
|
|
|
49
50
|
[tests/helpers.ts](../../tests/helpers.ts)) — do not turn that into a silent
|
|
50
51
|
pass.
|
|
51
52
|
|
|
53
|
+
`tests/conformance/` is the executable definition of the supported subset. It
|
|
54
|
+
runs unmodified test262 files from a pinned checkout (see
|
|
55
|
+
[`tests/conformance/test262/SOURCE.md`](../../tests/conformance/test262/SOURCE.md)).
|
|
56
|
+
When a feature becomes usable, copy a test262 case that exercises it and add a
|
|
57
|
+
supported entry; when you document a boundary, pin a valid test262 case that
|
|
58
|
+
xbintsc still rejects with its diagnostic code. Then run `npm run docs:matrix`
|
|
59
|
+
to regenerate [the support matrix](../../support-matrix.md); a test fails when
|
|
60
|
+
the committed table is stale.
|
|
61
|
+
|
|
62
|
+
### Keeping tests portable
|
|
63
|
+
|
|
64
|
+
The suite runs natively on Linux, macOS and Windows (x64 and arm64), so a test
|
|
65
|
+
that passes on one host must pass on all of them. Three rules cover every
|
|
66
|
+
difference the compiler intentionally has:
|
|
67
|
+
|
|
68
|
+
- **Text is LF.** `.gitattributes` checks every text file out with LF, and
|
|
69
|
+
`.editorconfig` makes editors write LF by default. Read repository files
|
|
70
|
+
through `readTextFile()` in [tests/platform.ts](../../tests/platform.ts),
|
|
71
|
+
which also normalises a stale CRLF checkout; never compare a generated
|
|
72
|
+
document against a raw `readFileSync(..., "utf8")` copy. `runProgram()`
|
|
73
|
+
normalises captured stdout/stderr too, so a CRLF from a child process cannot
|
|
74
|
+
fail a comparison; pass `raw: true` when a case pins exact bytes (the UTF-8
|
|
75
|
+
output tests do).
|
|
76
|
+
- **Paths are built, not spelled.** Use `node:path` (`join`, `resolve`,
|
|
77
|
+
`relative`) for native expectations. The compiler emits `/` in its
|
|
78
|
+
host-independent artifacts (LLVM IR, cache manifests, fingerprints and the
|
|
79
|
+
`path` module); `toPosixPath()` converts a temp directory or a
|
|
80
|
+
`fileURLToPath()` result to that form when asserting on one. On the compiler
|
|
81
|
+
side that representation lives in
|
|
82
|
+
[src/canonical.ts](../../src/canonical.ts) (`ARTIFACT_PATH_SEPARATOR`,
|
|
83
|
+
`ARTIFACT_LINE_ENDING`, `artifactPath()`), mirrored by `XT_ARTIFACT_PATH_SEPARATOR` in
|
|
84
|
+
[runtime/rt.h](../../runtime/rt.h) — do not spell `"/"` or `"\n"` in code
|
|
85
|
+
that emits an artifact.
|
|
86
|
+
- **Native output stays native.** Diagnostics print the path the driver
|
|
87
|
+
resolved, so a Windows diagnostic contains `\`; stack frames are part of the
|
|
88
|
+
emitted artifact and use the canonical `/`. Assert both structurally
|
|
89
|
+
(`toContain("helper.ts:1:")`, `includes("at inner")`) or against a
|
|
90
|
+
`node:path`-built value, never against a hardcoded `/` or `\`.
|
|
91
|
+
|
|
92
|
+
Do not normalise arbitrary program output: a backslash there can be an escape
|
|
93
|
+
sequence, JSON, or a Windows path the program printed on purpose. A genuinely
|
|
94
|
+
platform-specific feature (drive letters, `os.platform()`, timers, fonts) is
|
|
95
|
+
gated with `it.runIf(...)`/`it.skipIf(...)` so the skip is visible instead of
|
|
96
|
+
being hidden by a broad string replacement.
|
|
97
|
+
|
|
98
|
+
`tests/platform.test.ts` enforces both ends: the `.gitattributes` policy and an
|
|
99
|
+
LF working tree. If it reports CRLF on a Windows checkout, renormalise once —
|
|
100
|
+
**only in a clean checkout**, because `git checkout -- .` discards local edits:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
git stash # or commit your work first
|
|
104
|
+
git add --renormalize .
|
|
105
|
+
git checkout -- .
|
|
106
|
+
git stash pop
|
|
107
|
+
```
|
|
108
|
+
|
|
52
109
|
## Two invariants you must not break
|
|
53
110
|
|
|
54
111
|
### 1. The self-hosting fixpoint
|
package/doc/ai/extensions.md
CHANGED
|
@@ -68,8 +68,12 @@ import { createWindow, run } from "gui";
|
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
It is a self-contained GPU-accelerated renderer (own HTML parser, CSS cascade,
|
|
71
|
-
layout and compositor) — not a system WebView.
|
|
72
|
-
|
|
71
|
+
layout and compositor) — not a system WebView. The compiler side also inlines
|
|
72
|
+
local `<link rel="stylesheet">` files (and their `@import`s) into `<style>`
|
|
73
|
+
blocks, because the runtime parser only reads inline `<style>`; and it rewrites
|
|
74
|
+
a bundled three.js module's `WebGLRenderer` to use the real WebGL 2 backend:
|
|
75
|
+
only its shader unroller is patched, and no Canvas2D fallback is bundled. It
|
|
76
|
+
ships as a per-platform prebuilt `gui.a`/`gui.lib` because it is C++. `<img>` decodes through the engine
|
|
73
77
|
itself; `<video>`/`<audio>` do **not** work with `gui` alone — they need the
|
|
74
78
|
separate [`media`](#media--videoaudio-decoding) extension. `<canvas>` is
|
|
75
79
|
supported too: `getContext("2d")` returns a context whose fills, paths,
|
|
@@ -79,19 +83,40 @@ handles expose `canvas` drawing plus `width`/`height`. CSS
|
|
|
79
83
|
`transform`/`transform-origin` work as paint-time effects, so a box (and the
|
|
80
84
|
text, images and children in it) can be translated, scaled and rotated without
|
|
81
85
|
reflowing anything — animate it per frame from `requestAnimationFrame` or with
|
|
82
|
-
`transition: transform` (see `examples/gui/pelican-svg`).
|
|
86
|
+
`transition: transform` (see `examples/gui/pelican-svg`). The CSS subset also
|
|
87
|
+
covers `@media`, `::before`/`::after` generated content, multi-layer linear/radial
|
|
88
|
+
backgrounds, `text-shadow`, `clip-path` and `filter` colour/shadow effects;
|
|
89
|
+
`backdrop-filter` and true group blur are documented approximations or
|
|
90
|
+
unsupported. If the archive is
|
|
83
91
|
missing for your platform, the build fails with an actionable message; design
|
|
84
92
|
and roadmap live in [../gui.md](../gui.md) (overview; the engine is documented by
|
|
85
93
|
function under [`doc/gui/`](../gui/)), and the scripting surface in
|
|
86
94
|
[../gui-scripts.md](../gui-scripts.md). See
|
|
87
95
|
[../gui/canvas.md](../gui/canvas.md) for the canvas API and its limits.
|
|
88
96
|
|
|
97
|
+
Pages written for the browser also get the browser globals they reach for —
|
|
98
|
+
`window`/`self`, `document`, `navigator`, `location`, `localStorage`,
|
|
99
|
+
`requestAnimationFrame`, `matchMedia`, `getComputedStyle`, `alert`/`prompt`,
|
|
100
|
+
`escape`, the `Event` family and a Web Audio *surface* (`AudioContext` with
|
|
101
|
+
nodes, params and buffers, but no mixer) — plus a frame pump that starts at
|
|
102
|
+
`loadHTML` and re-arms only while animation-frame callbacks remain, so a page
|
|
103
|
+
that never calls `run()` still paints and then exits. **WebGL 1.0 and 2.0 are implemented**: `canvas.getContext("webgl")` /
|
|
104
|
+
`"webgl2"` return a GPU context whose GLSL ES shaders are compiled to SPIR-V by
|
|
105
|
+
a bundled glslang — consumed by Vulkan, or cross-compiled to MSL by bundled
|
|
106
|
+
SPIRV-Cross on Metal — and drawn through SDL_GPU; the page composites the colour
|
|
107
|
+
texture without a CPU readback, and WebGL 2 adds VAOs, instancing, integer
|
|
108
|
+
attributes, sampler objects, `texStorage2D` and buffer copies (see
|
|
109
|
+
[../gui/webgl.md](../gui/webgl.md)). WebXR, `<video>`/`<audio>` without
|
|
110
|
+
`media`, `fetch` and streaming are **not** implemented:
|
|
111
|
+
`typeof` answers `"undefined"` so a page takes its own fallback branch. See
|
|
112
|
+
[../gui/api.md](../gui/api.md#browser-globals).
|
|
113
|
+
|
|
89
114
|
### `media` — video/audio decoding
|
|
90
115
|
|
|
91
116
|
Enable with `--ext media` **together with** `gui` (`--ext gui,media`; the
|
|
92
117
|
registry rejects `media` on its own). It links a separate FFmpeg-backed
|
|
93
|
-
`media.a`, so adding `<video>`/`<audio>` playback does not make a
|
|
94
|
-
binary any larger.
|
|
118
|
+
`media.a`/`media.lib`, so adding `<video>`/`<audio>` playback does not make a
|
|
119
|
+
GUI-only binary any larger.
|
|
95
120
|
|
|
96
121
|
The DOM API is the same as for any HTML media element: `play()` / `pause()` /
|
|
97
122
|
`load()`, the `paused` / `ended` / `duration` / `currentTime` / `volume` /
|
|
@@ -101,8 +126,14 @@ The DOM API is the same as for any HTML media element: `play()` / `pause()` /
|
|
|
101
126
|
elements and CSS (see `examples/gui/media.ts`). Video frames and audio PCM are
|
|
102
127
|
decoded on the main thread; video goes through the image texture path. Without
|
|
103
128
|
the extension, opening a media source fails and fires `error` (the element and
|
|
104
|
-
its API still exist). The archive is
|
|
105
|
-
|
|
129
|
+
its API still exist). The archive is built for every host: POSIX produces
|
|
130
|
+
`media.a`, while Windows produces `media.lib` from FFmpeg compiled with the
|
|
131
|
+
MSVC-targeting `clang-cl`, so it links with `gui.lib`. Building it on Windows
|
|
132
|
+
needs a POSIX shell (Git for Windows' bundled bash) and a native GNU make
|
|
133
|
+
(Chocolatey `make`, or `xbintsc_MAKE`). See
|
|
134
|
+
[../gui/build.md](../gui/build.md). Without the archive, or on a host where
|
|
135
|
+
`npm run media` has not run, media elements report `error`; see
|
|
136
|
+
[../gui/known-issues.md](../gui/known-issues.md).
|
|
106
137
|
|
|
107
138
|
## Third-party npm packages
|
|
108
139
|
|
|
@@ -47,25 +47,25 @@ Canonical detail (always current, much longer):
|
|
|
47
47
|
| Comma operator, `void` | ✅ | |
|
|
48
48
|
| `new.target` | 🚫 | parsed, then rejected with a clear `UnsupportedFeature` |
|
|
49
49
|
| `import.meta` | ✅ | `url`, `dirname`, `filename` (resolved from the executable path) |
|
|
50
|
-
| `super` |
|
|
50
|
+
| `super` | ✅ | `super()` and `super.x` resolve from the class being defined, so any inheritance depth works |
|
|
51
51
|
|
|
52
52
|
## Functions, classes, objects
|
|
53
53
|
|
|
54
54
|
| Feature | Status | Notes |
|
|
55
55
|
| --- | --- | --- |
|
|
56
|
-
| Closures (capture by reference through boxes) | ✅ | one ABI for direct and closure calls |
|
|
56
|
+
| Closures (capture by reference through boxes) | ✅ | one ABI for direct and closure calls; function *declarations* capture too, so a named function can read and update outer state |
|
|
57
57
|
| `this`, method calls, arrow lexical `this` | ✅ | arrow functions get their own `arguments`, unlike JS |
|
|
58
58
|
| `call` / `apply` / `bind`, `fn.name` / `fn.length` | ✅ | a bound closure does not track partial-argument `length` |
|
|
59
59
|
| First-class built-in methods (`arr.map` as a value) | ✅ | exposed as *unbound* method values; a detached call throws like JS |
|
|
60
60
|
| `fn.toString()` | ⚠️ | returns `function name() { [native code] }`, not the source text |
|
|
61
|
-
| Classes: fields, methods, statics, getters/setters, `extends`/`super`, `instanceof` | ✅ | |
|
|
61
|
+
| Classes: fields, methods, statics, `static { ... }` blocks, getters/setters, `extends`/`super`, `instanceof` | ✅ | a static block is compiled as a static method called at class-definition time |
|
|
62
62
|
| Constructor parameter properties `constructor(public x: T)` | ✅ | |
|
|
63
63
|
| `#private` fields / methods / statics | ⚠️ | stored under a literal `#x` key; no access enforcement; parent/child name collisions may alias |
|
|
64
64
|
| `enum` / `const enum` | ✅ | forward + reverse mapping |
|
|
65
65
|
| `private` / `protected` / `public` / `readonly` / `abstract` / `implements` | — | erased, no access control |
|
|
66
66
|
| Generators `function*`, `yield`, `yield*` | ✅ | sync and `async function*`; `for await...of` and `Symbol.asyncIterator` |
|
|
67
67
|
| `arguments` object | ✅ | implicit; arrows see their own parameters |
|
|
68
|
-
| Argument-count validation |
|
|
68
|
+
| Argument-count validation | ⚠️ | direct calls to locally visible functions / `const` arrows are checked (`TS4004`); methods, imports, spread arguments and reassigned bindings are not. `--no-check` disables |
|
|
69
69
|
|
|
70
70
|
## Async, Promises, event loop
|
|
71
71
|
|
|
@@ -80,21 +80,28 @@ Canonical detail (always current, much longer):
|
|
|
80
80
|
| Worker threads | 🚫 | workers are child processes |
|
|
81
81
|
| `async` generators | ✅ | suspend at `await` and `yield`; every `.next()` returns a promise; `for await...of` supported |
|
|
82
82
|
|
|
83
|
-
## Types:
|
|
83
|
+
## Types: structurally checked, then erased
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
The default [semantic checker](../implemented/checker.md) resolves a small
|
|
86
|
+
structural subset of TypeScript types and checks it; code generation then
|
|
87
|
+
erases all type syntax. The checker catches:
|
|
87
88
|
|
|
88
89
|
| Construct | Status |
|
|
89
90
|
| --- | --- |
|
|
90
|
-
| Type annotations,
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
| Type annotations, interfaces, type aliases, object/array/function types | ✅ parsed and structurally checked, then erased |
|
|
92
|
+
| Assignability of initializers, assignments, returns and arguments | ✅ definite mismatches only (`TS4001`); no full inference |
|
|
93
|
+
| Property existence on `const` literals / class instances / interfaces | ✅ checked by default; dynamic shapes are left alone (`TS4003`) |
|
|
94
|
+
| Calling a definitely non-callable value | ✅ (`TS4002`) |
|
|
95
|
+
| Unresolved names (`TS3002`), same-scope redeclarations (`TS3001`), call arity (`TS4004`) | ✅ checked by default; `--no-check` disables everything |
|
|
96
|
+
| Simple generics (`T`, `T[]`, explicit type arguments) | ✅ inferred at the call site |
|
|
97
|
+
| Flow narrowing (`typeof`, `!== null`, `instanceof`, truthiness) | ✅ inside `if`/`else` and conditional expressions |
|
|
98
|
+
| Generic constraints, mapped/conditional types, overloads, full inference | 🚫 resolve to `any` |
|
|
99
|
+
| Strict-null and excess-property checks | 🚫 |
|
|
100
|
+
| `as`, `satisfies`, non-null `!` | — erased assertions, not validated |
|
|
101
|
+
|
|
102
|
+
`const x: number = "hello"` is now a compile error (`TS4001`). The checker is
|
|
103
|
+
deliberately conservative: anything it cannot model is `any`, so an unsupported
|
|
104
|
+
construct can hide a bug but never reject working code.
|
|
98
105
|
|
|
99
106
|
## Standard library
|
|
100
107
|
|
|
@@ -104,7 +111,9 @@ typed arrays, `String.prototype.match`/`split`/`replace` with capture groups,
|
|
|
104
111
|
immutable array helpers (`toReversed`, `toSorted`, `toSpliced`, `with`), global
|
|
105
112
|
URI functions, first-class built-in constructors (`const A = Array; new A(...)`,
|
|
106
113
|
`A.isArray`, `x instanceof A`) and `Object.prototype`
|
|
107
|
-
(`Object.getPrototypeOf({}) === Object.prototype`).
|
|
114
|
+
(`Object.getPrototypeOf({}) === Object.prototype`). `Math` is a first-class
|
|
115
|
+
object as well as a namespace (`const cos = Math.cos`, `const { sqrt, PI } =
|
|
116
|
+
Math`), and `Object.defineProperties` installs several descriptors at once.
|
|
108
117
|
|
|
109
118
|
| Missing or different | Status |
|
|
110
119
|
| --- | --- |
|
|
@@ -102,11 +102,13 @@ stderr — read the stderr, not just the first line. Frequent causes:
|
|
|
102
102
|
`xbintsc doctor` shows the compiler and its target; prefer the LLVM bundled
|
|
103
103
|
with Visual Studio, which locates the SDK itself. If your installation still
|
|
104
104
|
needs the environment imported, run from an **x64 Native Tools Command Prompt
|
|
105
|
-
for VS 2022** (or **ARM64 Native Tools** on Windows on ARM), or import
|
|
106
|
-
|
|
105
|
+
for VS 2022** (or **ARM64 Native Tools** on Windows on ARM), or import the
|
|
106
|
+
same Visual Studio setup CI uses:
|
|
107
107
|
```powershell
|
|
108
|
-
|
|
108
|
+
pwsh -File scripts/setup-vs-toolchain.ps1
|
|
109
109
|
```
|
|
110
|
+
That imports `vcvarsall` and pins `xbintsc_CLANG` to the LLVM bundled with
|
|
111
|
+
Visual Studio. Invoking `vcvarsall.bat x64` directly also works.
|
|
110
112
|
- the linker is wrong on Linux — set `xbintsc_CLANG` and/or pass
|
|
111
113
|
`xbintsc_LINKER_ARGS=-fuse-ld=lld`;
|
|
112
114
|
- `No C compiler found. Set xbintsc_CLANG to a clang binary.` — no clang on
|
|
@@ -120,11 +122,13 @@ described in [../gui.md](../gui.md).
|
|
|
120
122
|
|
|
121
123
|
### `media native library not found at …`
|
|
122
124
|
|
|
123
|
-
`<video>`/`<audio>` playback needs the optional `media` archive (`media.a
|
|
124
|
-
built separately with `npm run media`. Build it, or
|
|
125
|
-
GUI-only build still links and media elements simply fire
|
|
126
|
-
extension also requires `gui`,
|
|
127
|
-
|
|
125
|
+
`<video>`/`<audio>` playback needs the optional `media` archive (`media.a`, or
|
|
126
|
+
`media.lib` on Windows), built separately with `npm run media`. Build it, or
|
|
127
|
+
drop `--ext media`; a GUI-only build still links and media elements simply fire
|
|
128
|
+
`error`. The `media` extension also requires `gui`, and `--ext media` alone is
|
|
129
|
+
rejected with the flags to pass. On Windows the FFmpeg build additionally needs
|
|
130
|
+
a POSIX shell (Git for Windows' bash) and a native GNU make (Chocolatey `make`,
|
|
131
|
+
or `xbintsc_MAKE`). The script names whichever is missing. See
|
|
128
132
|
[../gui/build.md](../gui/build.md).
|
|
129
133
|
|
|
130
134
|
### `Icon file not found` / icon tools missing
|
package/doc/ai/zh-CN/README.md
CHANGED
|
@@ -15,6 +15,7 @@ source.ts --词法分析--> tokens --语法分析--> AST --绑定--> 绑定后
|
|
|
15
15
|
| 页面 | 什么时候读 |
|
|
16
16
|
| --- | --- |
|
|
17
17
|
| [build-recipe.md](./build-recipe.md) | 要编译或运行一个程序,需要确切的命令形状 |
|
|
18
|
+
| [../../npm-package.md](../../npm-package.md) | 要通过 npm 在 Node 项目或 CI 中安装并构建 |
|
|
18
19
|
| [cli.md](./cli.md) | 需要完整参数表、项目配置或编程 API |
|
|
19
20
|
| [language-support.md](./language-support.md) | 必须确认某个语法/API 是否存在,或是否与 Node 一致 |
|
|
20
21
|
| [extensions.md](./extensions.md) | 需要 `fs`/`http`/…、GUI,或 C++/Rust 库 |
|
|
@@ -27,9 +28,11 @@ source.ts --词法分析--> tokens --语法分析--> AST --绑定--> 绑定后
|
|
|
27
28
|
|
|
28
29
|
1. **只有 TypeScript 的一个子集能编译。** 不支持的语法会被直接拒绝,而不是
|
|
29
30
|
近似实现。动手写大段代码之前先确认。
|
|
30
|
-
2.
|
|
31
|
-
非空断言 `!`
|
|
32
|
-
|
|
31
|
+
2. **类型先做结构化检查,然后擦除。** 类型注解、接口、泛型、`as`/`satisfies`、
|
|
32
|
+
非空断言 `!` 在运行时没有任何作用。默认检查器会解析一个小型结构化子集,
|
|
33
|
+
拒绝确定不匹配(`const x: number = "hello"`)、已知形状上的缺失属性以及
|
|
34
|
+
对不可调用值的调用(`--no-check` 可关闭)。模型叫不出名字的东西都是 `any`;
|
|
35
|
+
没有完整推断与 strict-null 模式。
|
|
33
36
|
3. **Node 兼容是可选且不完整的。** Node 内置模块由 `node` 扩展提供(`--ext node`);
|
|
34
37
|
`node_modules` 里的 npm 包在构建期解析并打包(ESM 和 CommonJS 都支持);
|
|
35
38
|
运行时没有包查找,循环依赖会被拒绝。
|
|
@@ -51,7 +54,9 @@ xbintsc doctor
|
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
在源码检出里,把 `xbintsc` 换成 `npx tsx src/cli/main.ts`(或
|
|
54
|
-
`npm run xbintsc --`)。发布压缩包里的二进制不需要 Node.js
|
|
57
|
+
`npm run xbintsc --`)。发布压缩包里的二进制不需要 Node.js。如果是通过 npm
|
|
58
|
+
安装的,请在命令前加 `npx`(例如 `npx xbintsc build app.ts`);见
|
|
59
|
+
[../../npm-package.md](../../npm-package.md)。
|
|
55
60
|
|
|
56
61
|
下一步:要命令就[build-recipe.md](./build-recipe.md),要写正经程序就先看
|
|
57
62
|
[language-support.md](./language-support.md)。
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
| 场景 | 调用方式 |
|
|
9
9
|
| --- | --- |
|
|
10
10
|
| 已发布的独立压缩包 | `xbintsc …`(`bin/xbintsc[.exe]` 在 `PATH` 上) |
|
|
11
|
+
| 已安装的 npm 包(Node 22+) | `npx xbintsc …`;见 [npm-package.md](../../npm-package.md) |
|
|
11
12
|
| 源码检出,已编译 | `node dist/src/cli/main.js …` |
|
|
12
13
|
| 源码检出,直接跑 TypeScript | `npx tsx src/cli/main.ts …` |
|
|
13
14
|
| 源码检出,npm 脚本 | `npm run xbintsc -- …` |
|
package/doc/ai/zh-CN/cli.md
CHANGED
|
@@ -11,13 +11,21 @@
|
|
|
11
11
|
| `xbintsc run <file.ts> [-- args]` | 编译成可执行文件并运行 | 需要(且只支持 `--emit exe`) |
|
|
12
12
|
| `xbintsc watch <file.ts>` | 源码树变化时自动重新构建(Ctrl+C 退出) | 需要 |
|
|
13
13
|
| `xbintsc emit <file.ts>` | 把 LLVM IR 打到 stdout,不写文件 | 不需要 |
|
|
14
|
-
| `xbintsc check <file.ts>` |
|
|
14
|
+
| `xbintsc check <file.ts>` | 前端检查(语法、导入、语义检查、支持的子集),不写文件 | 不需要 |
|
|
15
15
|
| `xbintsc doctor` | 报告解析到的工具链、运行时与图标工具 | 仅在探测时需要 |
|
|
16
16
|
| `xbintsc version` | 打印版本 | 不需要 |
|
|
17
17
|
| `xbintsc help` | 打印帮助文本 | 不需要 |
|
|
18
18
|
|
|
19
|
-
`check`
|
|
20
|
-
|
|
19
|
+
`check` 不是完整的类型检查器:类型注解在检查后会被擦除,所以通过 `check` 的程序仍可能在运行时出错。
|
|
20
|
+
它能发现语法错误、无法解析的导入、超出支持子集的写法,以及语义检查器的诊断:
|
|
21
|
+
未定义名(TS3002)、同作用域重复声明(TS3001)、实参个数不匹配(TS4004)、
|
|
22
|
+
已知形状上的缺失属性(TS4003)、确定的可赋值性错误(TS4001)与对不可调用值的调用(TS4002)。
|
|
23
|
+
这使它适合作为提交前或编辑器的快速门禁。`--no-check` 可以跳过语义检查部分;
|
|
24
|
+
详见[语义检查](../implemented/checker.md)。
|
|
25
|
+
|
|
26
|
+
语义检查默认对**所有**命令开启(`build`、`run`、`emit`、`watch` 与 `check`)。
|
|
27
|
+
该开关是增量缓存 key 的一部分,所以 `--no-check` 的产物不会与已检查的产物互相复用。
|
|
28
|
+
错误在 clang 运行之前报告,这正是 `xbintsc check` 在编辑器或 pre-commit 钩子里便宜的原因。
|
|
21
29
|
|
|
22
30
|
任何命令加 `--help` 都会打印帮助并返回 0。未知命令会打印错误与帮助文本,返回 1。
|
|
23
31
|
|
|
@@ -44,6 +52,8 @@
|
|
|
44
52
|
--verbose 打印进度信息
|
|
45
53
|
--time 打印各构建阶段耗时
|
|
46
54
|
--debug 生成调试信息(DWARF/CodeView)并保留帧指针
|
|
55
|
+
--check 运行语义检查(默认)
|
|
56
|
+
--no-check 跳过语义检查,只擦除类型语法
|
|
47
57
|
--lto 程序与运行时编译为 LTO bitcode,并用 lld 链接
|
|
48
58
|
--pgo-generate [dir] 构建插桩二进制,把 profile 写入 dir
|
|
49
59
|
--pgo-use [dir] 使用 --pgo-generate 收集的 profile 重新构建
|
|
@@ -33,9 +33,9 @@ npm test # 单元测试 + 端到端测试
|
|
|
33
33
|
| `npm run coverage:runtime` | C 运行时(`runtime/`)的 LLVM 覆盖率 |
|
|
34
34
|
| `npm run bench` | 构建并计时固定基准套件(可与 Node 对比) |
|
|
35
35
|
|
|
36
|
-
单元测试在 `tests/` 下按模块一个目录(`lexer`、`parser`、`binder`、`
|
|
37
|
-
`driver`、`extensions`、`cli`、`e2e
|
|
38
|
-
|
|
36
|
+
单元测试在 `tests/` 下按模块一个目录(`lexer`、`parser`、`binder`、`checker`、
|
|
37
|
+
`codegen`、`driver`、`extensions`、`cli`、`conformance`、`e2e`),与源码树镜像对应。
|
|
38
|
+
边界用例放在它覆盖的模块旁边。
|
|
39
39
|
|
|
40
40
|
`tests/e2e/` 会编译真实程序并运行产出的二进制,其中包含一个**差分测试框架**
|
|
41
41
|
(`tests/e2e/differential-*.test.ts`):把同一份源码分别交给 xbintsc 和 Node 执行,
|
|
@@ -44,6 +44,52 @@ npm test # 单元测试 + 端到端测试
|
|
|
44
44
|
([tests/helpers.ts](../../../tests/helpers.ts) 里的 `hasClang()`)——不要把这种跳过
|
|
45
45
|
变成静默通过。
|
|
46
46
|
|
|
47
|
+
`tests/conformance/` 是“支持子集”的可执行定义,运行固定版本 test262 中的原始
|
|
48
|
+
文件(见 [`tests/conformance/test262/SOURCE.md`](../../../tests/conformance/test262/SOURCE.md))。
|
|
49
|
+
功能可用时,复制一个覆盖该功能的 test262 用例并登记为受支持;记录边界时,
|
|
50
|
+
固定一个 xbintsc 仍会拒绝的合法 test262 用例及其诊断码。然后运行
|
|
51
|
+
`npm run docs:matrix` 重新生成[支持矩阵](../../support-matrix.md),提交的表格
|
|
52
|
+
过期时测试会失败。
|
|
53
|
+
|
|
54
|
+
### 保持测试跨平台
|
|
55
|
+
|
|
56
|
+
测试套件在 Linux、macOS 和 Windows(x64 与 arm64)上原生运行,因此在一个平台通过的
|
|
57
|
+
用例必须在所有平台通过。三条规则覆盖了编译器有意保留的全部差异:
|
|
58
|
+
|
|
59
|
+
- **文本统一 LF。** `.gitattributes` 保证所有文本文件以 LF 检出,
|
|
60
|
+
`.editorconfig` 让编辑器默认写入 LF。读取仓库文件一律
|
|
61
|
+
走 [tests/platform.ts](../../../tests/platform.ts) 的 `readTextFile()`——它也会
|
|
62
|
+
归一化陈旧的 CRLF 检出;不要用裸的 `readFileSync(..., "utf8")` 去比对生成文档。
|
|
63
|
+
`runProgram()` 也会归一化捕获到的 stdout/stderr,子进程带出的 CRLF 不会让比较失败;
|
|
64
|
+
需要逐字节断言的用例传 `raw: true`(UTF-8 输出测试就是这么做的)。
|
|
65
|
+
- **路径要构造,不要手写。** 原生期望值用 `node:path`(`join`、`resolve`、
|
|
66
|
+
`relative`)构造。编译器在其与宿主无关的产物(LLVM IR、缓存清单、指纹、
|
|
67
|
+
`path` 模块)里统一输出 `/`;断言这类值时用 `toPosixPath()` 把临时目录或
|
|
68
|
+
`fileURLToPath()` 的结果转成该形式。编译器侧的唯一来源是
|
|
69
|
+
[src/canonical.ts](../../../src/canonical.ts)(`ARTIFACT_PATH_SEPARATOR`、
|
|
70
|
+
`ARTIFACT_LINE_ENDING`、`artifactPath()`),运行时对应
|
|
71
|
+
[runtime/rt.h](../../../runtime/rt.h) 的 `XT_ARTIFACT_PATH_SEPARATOR`——生成产物的代码
|
|
72
|
+
不要直接写 `"/"` 或 `"\n"`。
|
|
73
|
+
- **原生输出保持原生。** 诊断按驱动解析到的路径打印,因此 Windows 上含 `\`;
|
|
74
|
+
堆栈帧属于生成产物,统一用 `/`。两者都用结构性断言
|
|
75
|
+
(`toContain("helper.ts:1:")`、`includes("at inner")`)或与 `node:path`
|
|
76
|
+
构造的值比较,不要写死 `/` 或 `\`。
|
|
77
|
+
|
|
78
|
+
不要归一化任意程序输出:其中的反斜杠可能是转义序列、JSON,或程序有意打印的 Windows
|
|
79
|
+
路径。真正与平台相关的特性(盘符、`os.platform()`、定时器、字体)用
|
|
80
|
+
`it.runIf(...)`/`it.skipIf(...)` 显式跳过,而不是用大范围字符串替换掩盖。
|
|
81
|
+
|
|
82
|
+
`tests/platform.test.ts` 同时守住两端:`.gitattributes` 策略与工作区的 LF 状态。
|
|
83
|
+
Windows 检出报告 CRLF 时,重新归一化一次——**只对干净的工作区执行**,因为
|
|
84
|
+
`git checkout -- .` 会丢弃本地改动:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
git stash # 或先提交
|
|
88
|
+
git add --renormalize .
|
|
89
|
+
git checkout -- .
|
|
90
|
+
git stash pop
|
|
91
|
+
```
|
|
92
|
+
|
|
47
93
|
## 两条不能破坏的不变量
|
|
48
94
|
|
|
49
95
|
### 1. 自举不动点
|
|
@@ -66,7 +66,11 @@ import { createWindow, run } from "gui";
|
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
它是自带渲染引擎的 GPU 加速实现(自己的 HTML 解析器、CSS 级联、布局与合成器),不是
|
|
69
|
-
系统 WebView
|
|
69
|
+
系统 WebView。编译器一侧还会把本地 `<link rel="stylesheet">` 及其 `@import` 内联为
|
|
70
|
+
`<style>` 块(运行时解析器只读取内联 `<style>`);并让随包引入的 Three.js 的
|
|
71
|
+
`WebGLRenderer` 先探测 WebGL 上下文:引擎有上下文时使用 Three.js 自己的渲染器,
|
|
72
|
+
直接使用真实的 WebGL 2 后端(只修补其着色器循环展开,不再打包 Canvas2D 回退)。
|
|
73
|
+
`<img>` 由引擎自身解码;而 `<video>`/`<audio>` 在只启用 `gui` 时**不可用**
|
|
70
74
|
——它们需要单独的 [`media`](#media--视频音频解码) 扩展。也支持 `<canvas>`:
|
|
71
75
|
`getContext("2d")` 返回的上下文,其填充、路径、
|
|
72
76
|
渐变、文本与 `drawImage` 由自研 CPU 光栅器处理(另有线段端点/连接、虚线描边、
|
|
@@ -74,16 +78,34 @@ import { createWindow, run } from "gui";
|
|
|
74
78
|
`transform`/`transform-origin` 作为绘制期效果可用,因此一个盒子(以及其中的文本、
|
|
75
79
|
图像与子元素)可以被平移、缩放与旋转而不触发任何重排——可以用
|
|
76
80
|
`requestAnimationFrame` 逐帧驱动,或写成 `transition: transform`(见
|
|
77
|
-
`examples/gui/pelican-svg
|
|
81
|
+
`examples/gui/pelican-svg`)。CSS 子集还覆盖 `@media`、`::before`/`::after`
|
|
82
|
+
生成内容、线性/径向多层背景、`text-shadow`、`clip-path` 与 `filter`
|
|
83
|
+
颜色/阴影效果;`backdrop-filter` 与真正的组模糊是有文档说明的近似或未支持。
|
|
84
|
+
因为主体是 C++,它以各平台预编译的 `gui.a`/`gui.lib` 形式分发。如果该
|
|
78
85
|
平台的归档不存在,构建会以明确的提示失败;设计与路线图见 [../../zh-CN/gui.md](../../zh-CN/gui.md)(总览;引擎按功能拆分在 [`doc/zh-CN/gui/`](../../zh-CN/gui/) 下),
|
|
79
86
|
脚本接口见 [../../zh-CN/gui-scripts.md](../../zh-CN/gui-scripts.md)。Canvas API
|
|
80
87
|
及其限制见 [../../zh-CN/gui/canvas.md](../../zh-CN/gui/canvas.md)。
|
|
81
88
|
|
|
89
|
+
为浏览器编写的页面还能直接使用它们依赖的浏览器全局 —— `window`/`self`、`document`、
|
|
90
|
+
`navigator`、`location`、`localStorage`、`requestAnimationFrame`、`matchMedia`、
|
|
91
|
+
`getComputedStyle`、`alert`/`prompt`、`escape`、`Event` 家族,以及一层 Web Audio
|
|
92
|
+
**接口**(`AudioContext` 及其节点、参数与缓冲区,但没有混音后端)—— 另外还有帧泵:
|
|
93
|
+
它在 `loadHTML` 时启动,仅在仍有动画帧回调时重新排程,因此从不调用 `run()` 的页面
|
|
94
|
+
也能绘制并最终退出。**WebGL 1.0 与 2.0 已实现**:`canvas.getContext("webgl")` /
|
|
95
|
+
`"webgl2"` 返回 GPU 上下文,其 GLSL ES 着色器由内置 glslang 编译为 SPIR-V
|
|
96
|
+
(Vulkan 直接消费,Metal 上由内置 SPIRV-Cross 转成 MSL),
|
|
97
|
+
并通过 SDL_GPU 绘制;页面直接合成颜色纹理而无须 CPU 读回,WebGL 2 还增加
|
|
98
|
+
VAO、实例化、整数属性、采样器对象、`texStorage2D` 与缓冲拷贝(见
|
|
99
|
+
[../../zh-CN/gui/webgl.md](../../zh-CN/gui/webgl.md))。WebXR、未启用
|
|
100
|
+
`media` 时的 `<video>`/`<audio>`、`fetch` 与流式接口**尚未实现**:`typeof` 会回答
|
|
101
|
+
`"undefined"`,让页面走自己的降级分支。
|
|
102
|
+
见 [../../zh-CN/gui/api.md](../../zh-CN/gui/api.md)。
|
|
103
|
+
|
|
82
104
|
### `media` —— 视频/音频解码
|
|
83
105
|
|
|
84
106
|
用 `--ext media` **与 `gui` 一起**开启(`--ext gui,media`;注册表会拒绝单独启用
|
|
85
|
-
`media`)。它链接单独的 FFmpeg 后端 `media.a`,因此加入
|
|
86
|
-
|
|
107
|
+
`media`)。它链接单独的 FFmpeg 后端 `media.a`/`media.lib`,因此加入
|
|
108
|
+
`<video>`/`<audio>` 播放不会让只做界面的二进制变大。
|
|
87
109
|
|
|
88
110
|
DOM API 与普通 HTML 媒体元素一致:`play()` / `pause()` / `load()`,以及
|
|
89
111
|
`paused` / `ended` / `duration` / `currentTime` / `volume` / `muted` / `loop` /
|
|
@@ -91,8 +113,13 @@ DOM API 与普通 HTML 媒体元素一致:`play()` / `pause()` / `load()`,
|
|
|
91
113
|
`loadedmetadata`/`play`/`pause`/`ended`/`timeupdate`/`error` 事件。没有内置
|
|
92
114
|
控件——用元素和 CSS 自绘控件(见 `examples/gui/media.ts`)。视频帧与音频 PCM
|
|
93
115
|
都在主线程解码;视频走图像纹理路径。没有该扩展时,打开媒体源会失败并触发
|
|
94
|
-
`error`(元素与 API
|
|
95
|
-
|
|
116
|
+
`error`(元素与 API 仍然存在)。归档会为每个宿主平台构建:POSIX 产出
|
|
117
|
+
`media.a`,Windows 则用面向 MSVC 的 `clang-cl` 编译 FFmpeg 并产出 `media.lib`,
|
|
118
|
+
因此可与 `gui.lib` 链接。Windows 上构建它需要 POSIX shell(Git for Windows
|
|
119
|
+
自带的 bash)与原生 GNU make(Chocolatey `make`,或 `xbintsc_MAKE`)。见
|
|
120
|
+
[../../zh-CN/gui/build.md](../../zh-CN/gui/build.md)。
|
|
121
|
+
没有归档、或宿主上还没运行 `npm run media` 时,媒体元素会触发 `error`;见
|
|
122
|
+
[../../zh-CN/gui/known-issues.md](../../zh-CN/gui/known-issues.md)。
|
|
96
123
|
|
|
97
124
|
## 第三方 npm 包
|
|
98
125
|
|
|
@@ -44,25 +44,25 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
44
44
|
| 逗号运算符、`void` | ✅ | |
|
|
45
45
|
| `new.target` | 🚫 | 能解析,但会给出明确的 `UnsupportedFeature` |
|
|
46
46
|
| `import.meta` | ✅ | `url`、`dirname`、`filename`(由可执行文件路径解析) |
|
|
47
|
-
| `super` |
|
|
47
|
+
| `super` | ✅ | `super()` 与 `super.x` 由当前定义的类解析,任意继承深度都正确 |
|
|
48
48
|
|
|
49
49
|
## 函数、类与对象
|
|
50
50
|
|
|
51
51
|
| 特性 | 状态 | 说明 |
|
|
52
52
|
| --- | --- | --- |
|
|
53
|
-
| 闭包(通过 box 按引用捕获) | ✅ | 直接调用与闭包调用共用一条 ABI |
|
|
53
|
+
| 闭包(通过 box 按引用捕获) | ✅ | 直接调用与闭包调用共用一条 ABI;函数**声明**同样会捕获,因此具名函数能读写外层状态 |
|
|
54
54
|
| `this`、方法调用、箭头函数词法 `this` | ✅ | 与 JS 不同:箭头函数有自己的 `arguments` |
|
|
55
55
|
| `call`/`apply`/`bind`、`fn.name`/`fn.length` | ✅ | bind 出的闭包不跟踪部分应用后的 `length` |
|
|
56
56
|
| 一等内置方法(把 `arr.map` 当值用) | ✅ | 暴露为*未绑定*方法值;脱离接收者调用时与 JS 一样抛错 |
|
|
57
57
|
| `fn.toString()` | ⚠️ | 返回 `function name() { [native code] }`,不是源码 |
|
|
58
|
-
|
|
|
58
|
+
| 类:字段、方法、静态成员、`static { ... }` 静态块、getter/setter、`extends`/`super`、`instanceof` | ✅ | 静态块编译为一个静态方法,在类定义时调用 |
|
|
59
59
|
| 构造器参数属性 `constructor(public x: T)` | ✅ | |
|
|
60
60
|
| `#private` 字段/方法/静态成员 | ⚠️ | 以字面量 `#x` 键存储;不做访问控制;父子类同名可能互相覆盖 |
|
|
61
61
|
| `enum`/`const enum` | ✅ | 正向 + 反向映射 |
|
|
62
62
|
| `private`/`protected`/`public`/`readonly`/`abstract`/`implements` | — | 被擦除,无访问控制 |
|
|
63
63
|
| 生成器 `function*`、`yield`、`yield*` | ✅ | 同步与 `async function*`;支持 `for await...of` 与 `Symbol.asyncIterator` |
|
|
64
64
|
| `arguments` 对象 | ✅ | 隐式提供;箭头函数看到的是自己的参数 |
|
|
65
|
-
| 参数个数校验 |
|
|
65
|
+
| 参数个数校验 | ⚠️ | 对本地可见函数 / `const` 箭头函数的直接调用会检查(`TS4004`);方法、导入、展开实参与重新赋值后的绑定不检查。`--no-check` 可关闭 |
|
|
66
66
|
|
|
67
67
|
## 异步、Promise 与事件循环
|
|
68
68
|
|
|
@@ -77,20 +77,27 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
77
77
|
| worker 线程 | 🚫 | worker 是子进程 |
|
|
78
78
|
| `async` 生成器 | ✅ | 可在 `await` 与 `yield` 处挂起;每次 `.next()` 返回 Promise;支持 `for await...of` |
|
|
79
79
|
|
|
80
|
-
##
|
|
80
|
+
## 类型:结构化检查后擦除
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
默认开启的[语义检查](../implemented/checker.md)会解析一个小型结构化 TypeScript
|
|
83
|
+
类型子集并检查;代码生成阶段仍然擦除所有类型语法。检查器覆盖:
|
|
83
84
|
|
|
84
85
|
| 构造 | 状态 |
|
|
85
86
|
| --- | --- |
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
| `
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
| 类型注解、接口、类型别名、对象/数组/函数类型 | ✅ 解析并结构化检查,然后擦除 |
|
|
88
|
+
| 初始化、赋值、返回值与实参的可赋值性 | ✅ 只报确定不匹配(`TS4001`);没有完整推断 |
|
|
89
|
+
| `const` 字面量 / 类实例 / 接口上的属性是否存在 | ✅ 默认检查;动态形状会放过(`TS4003`) |
|
|
90
|
+
| 调用确定不可调用的值 | ✅(`TS4002`) |
|
|
91
|
+
| 未定义名(`TS3002`)、同作用域重复声明(`TS3001`)、实参个数(`TS4004`) | ✅ 默认检查;`--no-check` 可全部关闭 |
|
|
92
|
+
| 简单泛型(`T`、`T[]`、显式类型实参) | ✅ 在调用处推断 |
|
|
93
|
+
| 流收窄(`typeof`、`!== null`、`instanceof`、真值判断) | ✅ 在 `if`/`else` 与条件表达式内 |
|
|
94
|
+
| 泛型约束、映射/条件类型、重载、完整推断 | 🚫 解析为 `any` |
|
|
95
|
+
| strict-null 与多余属性检查 | 🚫 |
|
|
96
|
+
| `as`、`satisfies`、非空断言 `!` | — 被擦除的断言,不做校验 |
|
|
97
|
+
|
|
98
|
+
`const x: number = "hello"` 现在会报编译错误(`TS4001`)。检查器刻意保守:
|
|
99
|
+
模型叫不出名字的东西都是 `any`,因此不支持的语法最多隐藏一个 bug,
|
|
100
|
+
绝不会拒绝能正常工作的代码。
|
|
94
101
|
|
|
95
102
|
## 标准库
|
|
96
103
|
|
|
@@ -100,6 +107,8 @@ xbintsc 编译 TypeScript 的一个**实用子集**。本页用来判断你能
|
|
|
100
107
|
(`toReversed`、`toSorted`、`toSpliced`、`with`)、全局 URI 函数、
|
|
101
108
|
一等公民内建构造器(`const A = Array; new A(...)`、`A.isArray`、`x instanceof A`)
|
|
102
109
|
与 `Object.prototype`(`Object.getPrototypeOf({}) === Object.prototype`)。
|
|
110
|
+
`Math` 既是命名空间也是一等对象(`const cos = Math.cos`、`const { sqrt, PI } = Math`),
|
|
111
|
+
`Object.defineProperties` 可一次安装多个属性描述符。
|
|
103
112
|
|
|
104
113
|
| 缺失或行为不同 | 状态 |
|
|
105
114
|
| --- | --- |
|