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
|
@@ -30,7 +30,8 @@ Location: `src/codegen/llvm.ts` (`BINARY_RUNTIME`, `emitPrefix`, `emitPostfix`,
|
|
|
30
30
|
|
|
31
31
|
## Other expression operators
|
|
32
32
|
|
|
33
|
-
- Comma expression `,`
|
|
33
|
+
- Comma expression `,` (lowers to a `SequenceExpression`: every operand is
|
|
34
|
+
evaluated left to right and the value of the last one is the result)
|
|
34
35
|
- `in` operator (`key in obj`, mapped to `xt_in`)
|
|
35
36
|
- `delete obj.key` / `delete obj[key]` (mapped to `xt_delete`)
|
|
36
37
|
- `instanceof` (mapped to `xt_instance_of`, walking the prototype chain)
|
|
@@ -10,7 +10,7 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
|
|
|
10
10
|
|
|
11
11
|
- Variable declarations: `var` / `let` / `const`, with multiple declarators `const a = 1, b = 2;`
|
|
12
12
|
- Function declarations, function expressions and methods, including the `async` modifier, generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`) and async generators (`async function*`, `for await...of`)
|
|
13
|
-
- `class` declarations / class expressions (constructor, fields, methods, `static`, `extends`)
|
|
13
|
+
- `class` declarations / class expressions (constructor, fields, methods, `static`, `static { ... }` blocks, `extends`)
|
|
14
14
|
- `if` / `else`
|
|
15
15
|
- `while`, `do...while`
|
|
16
16
|
- `for` (init, condition and increment may all be omitted)
|
|
@@ -27,8 +27,9 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
|
|
|
27
27
|
- All common operators with precedence / associativity (see [Operators](./operators.md))
|
|
28
28
|
- Assignment expressions and all compound assignments (see [Operators](./operators.md))
|
|
29
29
|
- Conditional (ternary) expressions `a ? b : c`
|
|
30
|
+
- Comma / sequence expressions `a, b, c` (in `for` headers, parenthesized groups and expression statements)
|
|
30
31
|
- Arrow functions `() => expr` / `() => { ... }` (including type parameters and return type annotations)
|
|
31
|
-
- Function expressions `function () {}` and named function expressions `function g() {}`
|
|
32
|
+
- Function expressions `function () {}` and named function expressions `function g() {}` (also `async function` expressions)
|
|
32
33
|
- Call expressions `f(...)`, member access `a.b`, element access `a[i]`
|
|
33
34
|
- Array literals `[1, 2]`, sparse array elision, spread `[...a]` (also over strings, `Map` and `Set`)
|
|
34
35
|
- Object literals `{ a: 1 }`, shorthand properties `{ a }`, method shorthand `{ m() {} }`, getter / setter shorthand `{ get x() {} }` / `{ set x(v) {} }`, computed keys `{ [expr]: 1 }`, object spread `{ ...obj }`
|
|
@@ -21,8 +21,15 @@ source.ts
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
- Front end, back end, runtime and extensions are fully decoupled.
|
|
24
|
-
- The flow is orchestrated by `src/driver/compiler.ts`: `read → parse → bind → IR → object file → link`. The front end lives in `src/driver/frontend.ts`, the cache key in `src/driver/build-key.ts`, runtime compilation in `src/driver/runtime-objects.ts`, and platform artifacts in `src/driver/app-artifacts.ts`.
|
|
24
|
+
- The flow is orchestrated by `src/driver/compiler.ts`: `read → parse → bind → check → IR → object file → link`. The front end lives in `src/driver/frontend.ts`, the cache key in `src/driver/build-key.ts`, runtime compilation in `src/driver/runtime-objects.ts`, and platform artifacts in `src/driver/app-artifacts.ts`.
|
|
25
|
+
- The [semantic checker](./checker.md) (`src/checker/`) runs between binding and code generation unless `--no-check` is passed. It combines inference-free checks (unresolved names, redeclarations, call arity) with a small structural type model (definite assignability, property shapes, simple generics and flow narrowing); the type syntax itself is still erased afterwards.
|
|
25
26
|
- **Self-hosting**: `xbintsc` compiles its own front end. Building `src/cli/main.ts`
|
|
26
27
|
with the compiler yields a working `xbintsc` binary, and that binary rebuilds
|
|
27
28
|
itself with byte-identical LLVM IR (source ≡ generation 1 ≡ generation 2 ≡
|
|
28
29
|
generation 3). The runtime is still hand-written C.
|
|
30
|
+
- **Canonical artifacts**: anything byte-compared uses one encoding on every
|
|
31
|
+
host. `src/canonical.ts` defines the IR/debug/fingerprint path separator (`/`)
|
|
32
|
+
and line ending (LF), with `artifactPath()` for native paths entering an
|
|
33
|
+
artifact; the runtime uses `XT_ARTIFACT_PATH_SEPARATOR` (`runtime/rt.h`) when it renders
|
|
34
|
+
`path` results and `file://` URLs. User-facing native paths — diagnostics,
|
|
35
|
+
`import.meta.filename`, `process.cwd()` — keep the host separator, like Node.
|
|
@@ -15,7 +15,7 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
15
15
|
## Objects
|
|
16
16
|
|
|
17
17
|
- `Object.keys` / `values` / `entries` / `assign` / `getOwnPropertyNames` / `groupBy`, object spread `{...obj}`.
|
|
18
|
-
- `Object.defineProperty` / `getOwnPropertyDescriptor(s)` — data and accessor descriptors; the attribute flags are reported but not enforced on later writes/enumeration.
|
|
18
|
+
- `Object.defineProperty` / `defineProperties` / `getOwnPropertyDescriptor(s)` — data and accessor descriptors, one at a time or in bulk; the attribute flags are reported but not enforced on later writes/enumeration.
|
|
19
19
|
- `Object.freeze` / `is_frozen` / `from_entries`, `Object.getPrototypeOf`.
|
|
20
20
|
- `Object.prototype`: `hasOwnProperty` / `toString` / `valueOf` / `isPrototypeOf` / `propertyIsEnumerable` / `__proto__`; `Object.getPrototypeOf({}) === Object.prototype`.
|
|
21
21
|
- First-class built-in constructors (`const A = Array`, `new A(...)`, `A.isArray`, `x instanceof A`) are covered in [Codegen](./codegen.md#llvm-ir-code-generation-codegen).
|
|
@@ -32,6 +32,7 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
|
|
|
32
32
|
- Number formatting and coercion match Node: `toFixed` / `toPrecision` / `toExponential`, hex / octal / binary parsing, and the full `+` / relational `ToPrimitive` rules. These are covered by the differential tests.
|
|
33
33
|
- `BigInt` literals and values: arbitrary precision arithmetic, bitwise and shift operators, comparisons, `toString(radix)`, `BigInt()`, `BigInt.asIntN` / `BigInt.asUintN`.
|
|
34
34
|
- `Math`: the full function set and constants.
|
|
35
|
+
- `Math` is also a first-class object: `const cos = Math.cos`, `[1, 2].map(Math.max)` and `const { sqrt, PI } = Math` read members as values (`xt_math_object()` caches one native closure per function, so reads stay cheap).
|
|
35
36
|
- `Number` statics and `Number()` conversion; `parseInt` / `parseFloat` / `isNaN` / `isFinite`.
|
|
36
37
|
|
|
37
38
|
## JSON
|
package/doc/implemented/tests.md
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
> Part of [Implemented syntax and features](../implemented.md) · [简体中文](../zh-CN/implemented/tests.md)
|
|
4
4
|
|
|
5
|
-
Location: `tests/` (`lexer` / `parser` / `binder` / `codegen` / `driver` / `extensions` / `cli` / `e2e`)
|
|
5
|
+
Location: `tests/` (`lexer` / `parser` / `binder` / `checker` / `codegen` / `driver` / `extensions` / `cli` / `conformance` / `e2e`)
|
|
6
6
|
|
|
7
7
|
- Per-module unit tests mirror the source tree.
|
|
8
8
|
- `tests/e2e/` compiles real programs and runs the resulting binaries. When `clang` is absent the suite skips itself automatically; it is not a silent pass.
|
|
9
9
|
- `tests/e2e/differential-*.test.ts` runs the same source through both `xbintsc` and Node and compares output byte-for-byte. When semantics change, add a differential case instead of a hand-written expected string.
|
|
10
|
+
- `tests/conformance/` is the executable definition of the supported subset: it runs a pinned, vendored subset of [test262](https://github.com/tc39/test262) (unmodified files under `tests/conformance/test262/cases/`), compiling and executing each supported case. Unsupported cases are valid JavaScript that xbintsc still rejects, pinned with the diagnostic code it produces. [`doc/support-matrix.md`](../support-matrix.md) is generated from the same catalogue (`npm run docs:matrix`), and a test fails when the committed table is stale. See [`tests/conformance/test262/SOURCE.md`](../../tests/conformance/test262/SOURCE.md) for the pinned commit and the harness adaptation.
|
|
11
|
+
- `tests/checker/` pins the checker: unresolved names, same-scope redeclarations, call arity, structural assignability, property shapes and the narrowings that must stay legal.
|
|
10
12
|
- Feature pages in this directory record the supported behaviour; the tests are the executable form of that contract. See [Contributing](../ai/contributing.md) for the gate (`npm run typecheck && npm run lint && npm test`).
|
package/doc/implemented.md
CHANGED
|
@@ -22,6 +22,7 @@ small file instead of a single monolithic document.
|
|
|
22
22
|
- [Lexer](./implemented/lexer.md) — tokens, literals, keywords, lexical diagnostics
|
|
23
23
|
- [Parser](./implemented/parser.md) — statements, expressions, type syntax, ASI
|
|
24
24
|
- [Name binding and scopes](./implemented/binder.md) — scopes, symbols, closure capture
|
|
25
|
+
- [Semantic checker](./implemented/checker.md) — opt-out names, redeclarations and call arity
|
|
25
26
|
|
|
26
27
|
### Semantics and code generation
|
|
27
28
|
|
|
@@ -58,6 +59,7 @@ same file.
|
|
|
58
59
|
| tokenizer, literals, keywords | [Lexer](./implemented/lexer.md) |
|
|
59
60
|
| statement/expression/type syntax | [Parser](./implemented/parser.md) |
|
|
60
61
|
| scopes, symbols, captures | [Name binding](./implemented/binder.md) |
|
|
62
|
+
| checker diagnostics (names, redeclarations, arity) | [Semantic checker](./implemented/checker.md) |
|
|
61
63
|
| operators, assignment lowering | [Operators](./implemented/operators.md) |
|
|
62
64
|
| value representation, function ABI | [Value model](./implemented/value-model.md) |
|
|
63
65
|
| control flow, expression lowering, classes, `main` | [Codegen](./implemented/codegen.md) |
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
# Using xbintsc from npm
|
|
2
|
+
|
|
3
|
+
> Language: **English** | [简体中文](./zh-CN/npm-package.md)
|
|
4
|
+
|
|
5
|
+
`xbintsc` is published on npm as a Node package. Install it in any Node project
|
|
6
|
+
to compile that project's TypeScript into a standalone native binary — no source
|
|
7
|
+
checkout, no downloaded release archive, and no global install required.
|
|
8
|
+
|
|
9
|
+
This page is the consumer guide for the npm package. For the compiler's flags
|
|
10
|
+
and config fields see [the CLI reference](./ai/cli.md); for the platform
|
|
11
|
+
toolchain see [requirements](./requirements.md).
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install --save-dev --save-exact xbintsc
|
|
17
|
+
npx xbintsc doctor # "status : ok" means clang is usable
|
|
18
|
+
npx xbintsc build src/main.ts --out build
|
|
19
|
+
./build/main # .\build\main.exe on Windows
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The rest of this page explains the requirements, the first-build cost, CI and
|
|
23
|
+
the differences from a normal Node build.
|
|
24
|
+
|
|
25
|
+
## For AI agents
|
|
26
|
+
|
|
27
|
+
If you are an agent asked to build a project that already depends on `xbintsc`:
|
|
28
|
+
|
|
29
|
+
1. Run `npx xbintsc doctor`. If it exits non-zero, report the toolchain problem;
|
|
30
|
+
do not edit the program to work around a missing or old clang.
|
|
31
|
+
2. Find the entry file: `entry` in `xbintsc.config.json`, a package script that
|
|
32
|
+
invokes `xbintsc`, or the project's main TypeScript file (often
|
|
33
|
+
`src/main.ts`). When a config exists, `npx xbintsc build` needs no arguments.
|
|
34
|
+
3. Build with `npx xbintsc build <entry> --out build`. If the program imports
|
|
35
|
+
Node built-ins, add `--ext node`; the diagnostic names the missing extension.
|
|
36
|
+
4. Run the artifact (`./build/<name>`, `.exe` on Windows) and report its path.
|
|
37
|
+
5. If the build reports unsupported syntax, read the installed subset guide at
|
|
38
|
+
`node_modules/xbintsc/doc/ai/language-support.md`; do not assume
|
|
39
|
+
Node-compatible TypeScript. The first build also compiles the C runtime, so
|
|
40
|
+
allow more time than for an incremental build.
|
|
41
|
+
|
|
42
|
+
Do not run `npm install` inside `node_modules/xbintsc`, and do not substitute
|
|
43
|
+
`tsc`/`esbuild` for xbintsc: the native artifact must come from `npx xbintsc`.
|
|
44
|
+
`xbintsc` does not read `tsconfig.json`; use relative imports or package imports.
|
|
45
|
+
|
|
46
|
+
## What the npm package is
|
|
47
|
+
|
|
48
|
+
The package contains:
|
|
49
|
+
|
|
50
|
+
- the compiler CLI (`bin/xbintsc.js` plus the compiled JavaScript in `dist/`);
|
|
51
|
+
- the C runtime **sources** (`runtime/`), including the `node` extension sources;
|
|
52
|
+
- the project config schema and documentation.
|
|
53
|
+
|
|
54
|
+
It runs the compiler through Node.js. The binary it produces is still
|
|
55
|
+
standalone: it does not embed Node, V8 or a TypeScript compiler.
|
|
56
|
+
|
|
57
|
+
The package does **not** contain:
|
|
58
|
+
|
|
59
|
+
- a C compiler — you need clang 16+ on the machine that builds;
|
|
60
|
+
- prebuilt runtime archives (`runtime/lib/<os>-<arch>/core.a`). The driver
|
|
61
|
+
compiles the C runtime from the shipped sources on first use and caches the
|
|
62
|
+
objects, so the first build is slower (see [the cache](#the-first-build-and-the-cache));
|
|
63
|
+
- the GUI/media native archives (`gui.a`, `media.a`). If you need `--ext gui` or
|
|
64
|
+
`--ext media`, use a Linux/macOS release archive or build those archives from
|
|
65
|
+
a source checkout.
|
|
66
|
+
|
|
67
|
+
## Requirements
|
|
68
|
+
|
|
69
|
+
| Requirement | Why |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| Node.js **22+** | Runs the compiler itself. The produced binary does not need Node. |
|
|
72
|
+
| clang / LLVM **16+** | xbintsc emits LLVM IR and asks clang to compile and link it. |
|
|
73
|
+
| The platform linker / SDK | macOS: Xcode Command Line Tools. Linux: clang + lld. Windows: LLVM + the Visual Studio C++ build tools (MSVC ABI). |
|
|
74
|
+
|
|
75
|
+
Check them before the first build:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
node --version # v22.x or newer
|
|
79
|
+
npx xbintsc doctor # "status : ok" means the toolchain is usable
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`doctor` also reports the resolved compiler, runtime directory and runtime
|
|
83
|
+
library directory. On Windows, if the resolved clang cannot find the MSVC/SDK
|
|
84
|
+
headers by itself, run the build from an **x64 Native Tools Command Prompt for
|
|
85
|
+
VS 2022** (or **ARM64 Native Tools** on Windows on ARM). On distributions
|
|
86
|
+
whose default `clang` is older than 16 (for example Ubuntu 22.04 or Debian 12),
|
|
87
|
+
install a newer LLVM from its LLVM package repository and point
|
|
88
|
+
`xbintsc_CLANG` at that binary. Full per-platform instructions are in
|
|
89
|
+
[requirements](./requirements.md).
|
|
90
|
+
|
|
91
|
+
## Install it in the project
|
|
92
|
+
|
|
93
|
+
Install it as a development dependency in the Node project that will run the
|
|
94
|
+
build:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install --save-dev --save-exact xbintsc
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`--save-exact` pins the compiler version in `package.json`; the lockfile pins it
|
|
101
|
+
for everyone else. Pinning matters because the compiler version is part of the
|
|
102
|
+
incremental-cache key and a newer compiler can produce a different binary.
|
|
103
|
+
|
|
104
|
+
The equivalent commands for other package managers are `pnpm add -D xbintsc`
|
|
105
|
+
and `yarn add -D xbintsc`. The rest of this page uses npm and `npx`.
|
|
106
|
+
|
|
107
|
+
Verify the local install:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npx xbintsc version
|
|
111
|
+
npx xbintsc doctor
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`npx` prefers `node_modules/.bin/xbintsc`. If the project has no local install,
|
|
115
|
+
`npx` may download the latest version instead — convenient for a one-off, but
|
|
116
|
+
not reproducible. In CI, either install the dependency first or use
|
|
117
|
+
`npx --no-install xbintsc …` so a missing install fails instead of silently
|
|
118
|
+
fetching a different compiler.
|
|
119
|
+
|
|
120
|
+
### One-off run without adding a dependency
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx --yes xbintsc@latest build src/main.ts --out build
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Replace `latest` with an exact version if the artifact must be reproducible.
|
|
127
|
+
This downloads the package into npm's `_npx` cache, which is why a project
|
|
128
|
+
dependency is preferred for regular builds.
|
|
129
|
+
|
|
130
|
+
### Global install (not recommended)
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm install --global xbintsc
|
|
134
|
+
xbintsc build src/main.ts --out build
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
A global install is fine for experiments, but every project then shares whichever
|
|
138
|
+
version happens to be global. A project devDependency keeps builds reproducible.
|
|
139
|
+
|
|
140
|
+
## A complete minimal project
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
my-app/
|
|
144
|
+
├── package.json
|
|
145
|
+
├── xbintsc.config.json
|
|
146
|
+
└── src/
|
|
147
|
+
└── main.ts
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`src/main.ts`:
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
const greeting: string = "Hello from xbintsc";
|
|
154
|
+
console.log(greeting);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`xbintsc.config.json`:
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"entry": "src/main.ts",
|
|
162
|
+
"outDir": "build"
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Add a build script to `package.json` — npm puts `node_modules/.bin` on `PATH`,
|
|
167
|
+
so the script can call `xbintsc` directly:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"scripts": {
|
|
172
|
+
"build:native": "xbintsc build"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Then:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npm install --save-dev --save-exact xbintsc
|
|
181
|
+
npm run build:native
|
|
182
|
+
./build/main # .\build\main.exe on Windows
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Expected output (the first build also compiles the C runtime):
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
xbintsc: wrote /absolute/path/my-app/build/main
|
|
189
|
+
Hello from xbintsc
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`xbintsc build` with no positional entry reads `entry` from
|
|
193
|
+
`xbintsc.config.json`, which is why the script stays short. Without a config,
|
|
194
|
+
pass the file explicitly: `xbintsc build src/main.ts --out build`.
|
|
195
|
+
|
|
196
|
+
## The first build and the cache
|
|
197
|
+
|
|
198
|
+
The runtime objects are cached by source/header content hash. The default cache
|
|
199
|
+
is `.xbintsc/` **in the directory you run the command from** (not necessarily
|
|
200
|
+
next to the config file); set `xbintsc_CACHE_DIR` to put it elsewhere.
|
|
201
|
+
|
|
202
|
+
Because the npm package ships the runtime as C sources but not as a prebuilt
|
|
203
|
+
`core.a`, the first build compiles each runtime translation unit. Expect that
|
|
204
|
+
build to take noticeably longer than the ones after it. `--time` shows where the
|
|
205
|
+
time went:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
npx xbintsc build src/main.ts --out build --time
|
|
209
|
+
# xbintsc: timing (frontend 4ms, codegen 7ms, clang 1089ms, runtime 37770ms, link 1966ms)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Later builds reuse the objects and the incremental build record:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
npx xbintsc build src/main.ts --out build
|
|
216
|
+
# xbintsc: wrote /absolute/path/build/main (cached)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Practical consequences:
|
|
220
|
+
|
|
221
|
+
- add `.xbintsc/` to `.gitignore`;
|
|
222
|
+
- keep `.xbintsc/` between CI runs (or point `xbintsc_CACHE_DIR` at a persistent
|
|
223
|
+
directory) to avoid paying the runtime-compile cost every time;
|
|
224
|
+
- deleting `.xbintsc/` is safe — the next build recreates it;
|
|
225
|
+
- `--force` ignores the build freshness record, but cached runtime objects are
|
|
226
|
+
still reused. Delete `.xbintsc/` if you want to force a full C rebuild.
|
|
227
|
+
|
|
228
|
+
## Commands you will use
|
|
229
|
+
|
|
230
|
+
All commands below assume a local install, so `npx` finds it.
|
|
231
|
+
|
|
232
|
+
| Job | Command |
|
|
233
|
+
| --- | --- |
|
|
234
|
+
| Build an executable | `npx xbintsc build src/main.ts --out build` |
|
|
235
|
+
| Choose the exact output path | `npx xbintsc build src/main.ts -o dist/app` |
|
|
236
|
+
| Compile and run immediately | `npx xbintsc run src/main.ts -- --flag value` |
|
|
237
|
+
| Pass arguments to the program | Put them after `--`; they are not compiler flags |
|
|
238
|
+
| Check without linking (no clang) | `npx xbintsc check src/main.ts` |
|
|
239
|
+
| Print LLVM IR (no clang) | `npx xbintsc emit src/main.ts > main.ll` |
|
|
240
|
+
| Emit an object file | `npx xbintsc build src/main.ts --emit obj --out build` |
|
|
241
|
+
| Optimize | `npx xbintsc build src/main.ts -O3 --out build` |
|
|
242
|
+
| Use Node built-ins | `npx xbintsc build src/main.ts --ext node --out build` |
|
|
243
|
+
| Rebuild on change | `npx xbintsc watch src/main.ts` |
|
|
244
|
+
| Inspect the toolchain | `npx xbintsc doctor` |
|
|
245
|
+
| Read the exact help text | `npx xbintsc help` |
|
|
246
|
+
|
|
247
|
+
`--out <dir>` is a directory: the output keeps the entry file's base name.
|
|
248
|
+
`-o <path>` is the exact output path. Optimization defaults to `-O2`.
|
|
249
|
+
|
|
250
|
+
The full flag list, project config fields and environment variables are in
|
|
251
|
+
[the CLI reference](./ai/cli.md).
|
|
252
|
+
|
|
253
|
+
## Node built-ins and npm dependencies in the compiled program
|
|
254
|
+
|
|
255
|
+
Installing `xbintsc` from npm does **not** make the compiled program run on
|
|
256
|
+
Node. The output is a standalone native binary, so two rules apply:
|
|
257
|
+
|
|
258
|
+
1. **Node built-ins are opt-in.** An import such as `node:fs` or `fs` needs the
|
|
259
|
+
`node` extension:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
npx xbintsc build src/main.ts --ext node --out build
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
or, permanently, in `xbintsc.config.json`:
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"entry": "src/main.ts",
|
|
270
|
+
"outDir": "build",
|
|
271
|
+
"extensions": ["node"]
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
2. **Third-party npm packages are bundled at build time.** A bare import is
|
|
276
|
+
resolved from the project's `node_modules` and its source is merged into the
|
|
277
|
+
binary. There is no runtime package lookup. ESM and CommonJS packages are
|
|
278
|
+
supported; circular dependencies, dynamic `require(<expression>)` and
|
|
279
|
+
packages that rely on Node globals such as `__dirname` are not.
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
npm install ms
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import ms from "ms";
|
|
287
|
+
console.log(ms(60000));
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
For the complete rules and limitations see
|
|
291
|
+
[extensions](./ai/extensions.md#third-party-npm-packages).
|
|
292
|
+
|
|
293
|
+
## Build from a Node script
|
|
294
|
+
|
|
295
|
+
The package is ESM-only and exposes a programmatic API, which is useful when
|
|
296
|
+
another Node build script needs to produce the binary:
|
|
297
|
+
|
|
298
|
+
```js
|
|
299
|
+
// scripts/build-native.mjs
|
|
300
|
+
import { build } from "xbintsc";
|
|
301
|
+
|
|
302
|
+
const result = build("src/main.ts", { outDir: "build", optimize: "2" });
|
|
303
|
+
if (result.diagnostics.some((diagnostic) => diagnostic.category === "error")) {
|
|
304
|
+
process.exitCode = 1;
|
|
305
|
+
} else {
|
|
306
|
+
console.log(`wrote ${result.outputPath}${result.cached ? " (cached)" : ""}`);
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Run it with `node scripts/build-native.mjs` (or a `package.json` script). Notes:
|
|
311
|
+
|
|
312
|
+
- use `.mjs` or `"type": "module"`, because `require("xbintsc")` is not
|
|
313
|
+
exported and fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`;
|
|
314
|
+
- `build` returns `{ outputPath, irPath?, cached, diagnostics, … }` and reports
|
|
315
|
+
source errors through `diagnostics`; it **throws** `ToolchainError` when clang
|
|
316
|
+
itself fails;
|
|
317
|
+
- `compileString(source)` is a pure IR-generation call that needs no clang;
|
|
318
|
+
- the subpath `xbintsc/driver` exposes the driver internals (cache, toolchain,
|
|
319
|
+
config, icons, macOS bundle helpers).
|
|
320
|
+
|
|
321
|
+
The full API surface is documented in [the CLI reference](./ai/cli.md#programmatic-api).
|
|
322
|
+
|
|
323
|
+
## Use it in CI
|
|
324
|
+
|
|
325
|
+
A GitHub Actions job that publishes the Linux binary can look like this:
|
|
326
|
+
|
|
327
|
+
```yaml
|
|
328
|
+
name: native
|
|
329
|
+
on: [push]
|
|
330
|
+
jobs:
|
|
331
|
+
build:
|
|
332
|
+
runs-on: ubuntu-24.04
|
|
333
|
+
steps:
|
|
334
|
+
- uses: actions/checkout@v4
|
|
335
|
+
- uses: actions/setup-node@v4
|
|
336
|
+
with:
|
|
337
|
+
node-version: 22
|
|
338
|
+
cache: npm
|
|
339
|
+
- run: sudo apt-get update && sudo apt-get install -y clang lld
|
|
340
|
+
- run: npm ci
|
|
341
|
+
- run: npx xbintsc doctor
|
|
342
|
+
- uses: actions/cache@v4
|
|
343
|
+
with:
|
|
344
|
+
path: .xbintsc
|
|
345
|
+
key: xbintsc-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
|
|
346
|
+
- run: npx xbintsc build src/main.ts --out build
|
|
347
|
+
- uses: actions/upload-artifact@v4
|
|
348
|
+
with:
|
|
349
|
+
name: my-app-linux-x64
|
|
350
|
+
path: build/main
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
- `npm ci` installs devDependencies by default, so `xbintsc` is present. If your
|
|
354
|
+
pipeline uses `npm ci --omit=dev`, build before pruning or move `xbintsc` to
|
|
355
|
+
`dependencies`.
|
|
356
|
+
- The `.xbintsc` cache key includes the lockfile, which pins the compiler
|
|
357
|
+
version; object names inside the cache are content hashes, so an old cache
|
|
358
|
+
cannot poison a new build.
|
|
359
|
+
- xbintsc builds for the **host** platform. It is not a cross-compiler: use a CI
|
|
360
|
+
matrix (one job per OS/arch) to produce artifacts for several platforms.
|
|
361
|
+
- macOS runners already have Xcode Command Line Tools; Windows runners need the
|
|
362
|
+
Visual Studio C++ build tools (MSVC + its bundled LLVM), and the binary is
|
|
363
|
+
`build\main.exe`. In a source checkout,
|
|
364
|
+
`pwsh -File scripts/setup-vs-toolchain.ps1` imports that toolchain explicitly.
|
|
365
|
+
|
|
366
|
+
## npm package or release archive?
|
|
367
|
+
|
|
368
|
+
| | npm package (`xbintsc`) | Prebuilt release archive |
|
|
369
|
+
| --- | --- | --- |
|
|
370
|
+
| Needs Node.js | Yes, 22+ | No |
|
|
371
|
+
| First build | Compiles the C runtime from source | Links the prebuilt runtime |
|
|
372
|
+
| GUI / media extensions | Not included | Included in Linux/macOS and Windows x64 archives |
|
|
373
|
+
| Installation | `npm install` + lockfile / provenance | Download, verify `.sha256`, unpack |
|
|
374
|
+
| Programmatic API | Yes | No (CLI only) |
|
|
375
|
+
| Cross-compiles | No — host only | No — host only |
|
|
376
|
+
| Best for | Node projects and CI, familiar npm workflow | Machines without Node, fastest first build, GUI apps |
|
|
377
|
+
|
|
378
|
+
If you only need the core runtime and the `node` extension, the npm package is
|
|
379
|
+
the most convenient option. If you need the fastest possible cold build or the
|
|
380
|
+
GUI/media archives, use a release archive (or build from source for
|
|
381
|
+
development).
|
|
382
|
+
|
|
383
|
+
## Things that differ from a regular Node build
|
|
384
|
+
|
|
385
|
+
- **`tsconfig.json` is not read.** xbintsc has its own `xbintsc.config.json` for
|
|
386
|
+
the entry file, output directory and build flags. TypeScript `paths` aliases
|
|
387
|
+
and other `tsconfig.json` settings are not applied; use relative imports or
|
|
388
|
+
real package imports.
|
|
389
|
+
- **The project's `package.json` `"type"` does not change the source dialect.**
|
|
390
|
+
Write ESM `import`/`export`; `require()` in your own source is rejected.
|
|
391
|
+
- **Types are checked, then erased.** The default checker catches definite
|
|
392
|
+
mismatches, but there is no full type inference or strict-null mode. Use
|
|
393
|
+
`--no-check` only when you need to skip the semantic check.
|
|
394
|
+
- **Only a subset of TypeScript compiles.** Unsupported syntax fails with a
|
|
395
|
+
diagnostic instead of being approximated. See
|
|
396
|
+
[language support](./ai/language-support.md).
|
|
397
|
+
- **The produced binary is platform- and architecture-specific.** Build it on
|
|
398
|
+
the platform you will run it on.
|
|
399
|
+
|
|
400
|
+
## Troubleshooting
|
|
401
|
+
|
|
402
|
+
Diagnostic hints end with a repository-relative path such as
|
|
403
|
+
`doc/ai/troubleshooting.md`. In a project that installed xbintsc from npm, read
|
|
404
|
+
the same file under `node_modules/xbintsc/doc/ai/`.
|
|
405
|
+
|
|
406
|
+
| Symptom | Cause / fix |
|
|
407
|
+
| --- | --- |
|
|
408
|
+
| `npx xbintsc` uses an unexpected version | Run `npx --no-install xbintsc version` and `npm ls xbintsc`; pin the version in `package.json` and use `npm ci` in CI. |
|
|
409
|
+
| `requires Node.js 22` / engine error | Upgrade Node; the compiler uses modern Node APIs. |
|
|
410
|
+
| `No C compiler found` or `requires clang 16 or newer` | Install clang 16+ and run `npx xbintsc doctor`; set `xbintsc_CLANG` to a specific clang if needed. |
|
|
411
|
+
| The first build takes a long time | Expected: the runtime C sources are compiled and cached. Later builds reuse `.xbintsc/`; `--time` confirms. Use a release archive if cold builds must be fast. |
|
|
412
|
+
| Permission errors writing `.xbintsc/` | Set `xbintsc_CACHE_DIR` to a writable directory, or run from a writable working directory. |
|
|
413
|
+
| `module 'fs' is provided by the 'node' extension` | Add `--ext node`, or `"extensions": ["node"]` in the config. |
|
|
414
|
+
| `GUI native library not found` / `media native library not found` | The npm package does not ship `gui.a`/`gui.lib` or `media.a`/`media.lib`; use a Linux/macOS/Windows x64 release archive or build them from a source checkout. |
|
|
415
|
+
| `require("xbintsc")` fails | The package is ESM-only; use `import` (or dynamic `import()`). |
|
|
416
|
+
| Windows link errors about missing MSVC libraries | Run from a Native Tools prompt, install the VS C++ build tools, and check `npx xbintsc doctor`. |
|
|
417
|
+
| `npm ci --omit=dev` then the build cannot find `xbintsc` | Install devDependencies for the build stage, or move `xbintsc` to `dependencies`. |
|
|
418
|
+
|
|
419
|
+
More error messages and their fixes: [troubleshooting](./ai/troubleshooting.md).
|
package/doc/requirements.md
CHANGED
|
@@ -10,7 +10,10 @@ no requirements on any platform.
|
|
|
10
10
|
| Requirement | Minimum | Notes |
|
|
11
11
|
| --- | --- | --- |
|
|
12
12
|
| clang / LLVM | **16** | The emitted IR uses opaque pointers, which LLVM 16 made the only pointer representation. |
|
|
13
|
-
| Node.js | **22** |
|
|
13
|
+
| Node.js | **22** | Required to run the compiler from npm or from source; released binaries are standalone and need no Node. |
|
|
14
|
+
|
|
15
|
+
Installing the compiler from npm instead of using a release archive? Node.js 22+
|
|
16
|
+
then runs the compiler itself; see [Using xbintsc from npm](./npm-package.md).
|
|
14
17
|
|
|
15
18
|
clang 15 and older fail on the first string literal in any program, with:
|
|
16
19
|
|
|
@@ -121,22 +124,26 @@ Verify with `clang --version`. If xbintsc uses the wrong linker, set
|
|
|
121
124
|
`xbintsc_CLANG` to the clang you want and/or pass extra flags through
|
|
122
125
|
`xbintsc_LINKER_ARGS` (for example `-fuse-ld=lld`).
|
|
123
126
|
|
|
124
|
-
## Windows — install the MSVC C++ build tools (
|
|
127
|
+
## Windows — install the MSVC C++ build tools (with LLVM)
|
|
125
128
|
|
|
126
|
-
xbintsc targets the **MSVC ABI** on Windows.
|
|
127
|
-
|
|
129
|
+
xbintsc targets the **MSVC ABI** on Windows. One `winget` command installs the
|
|
130
|
+
Visual Studio C++ workload, MSBuild and the Clang component that the local build
|
|
131
|
+
scripts and CI use:
|
|
128
132
|
|
|
129
133
|
```powershell
|
|
130
|
-
winget install -e --id LLVM.LLVM
|
|
131
134
|
winget install -e --id Microsoft.VisualStudio.2022.BuildTools `
|
|
132
|
-
--override "--quiet --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
|
|
135
|
+
--override "--quiet --wait --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --includeRecommended"
|
|
133
136
|
```
|
|
134
137
|
|
|
135
138
|
The LLVM bundled with Visual Studio 2022
|
|
136
|
-
(`VC\Tools\Llvm\x64\bin\clang.exe`, version 19.1.5 in current installs) is
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
(`VC\Tools\Llvm\x64\bin\clang.exe`, version 19.1.5 in current installs) is what
|
|
140
|
+
`scripts/setup-vs-toolchain.ps1` selects. A standalone LLVM also works for
|
|
141
|
+
`xbintsc` itself (`winget install -e --id LLVM.LLVM`), but the GUI/media archive
|
|
142
|
+
builds and the CI setup use the Visual Studio one so one toolchain produces the
|
|
143
|
+
runtime, the archives and the final binary. Either way the compiler must target
|
|
144
|
+
the MSVC ABI (`Target: *-windows-msvc`): clang built for another Windows ABI
|
|
145
|
+
cannot link with the MSVC runtime, so `xbintsc` rejects it with an explicit
|
|
146
|
+
error.
|
|
140
147
|
|
|
141
148
|
A developer prompt is normally **not** required: `xbintsc` resolves the Visual
|
|
142
149
|
Studio LLVM by absolute path, and that clang locates the MSVC/SDK headers,
|
|
@@ -148,6 +155,11 @@ imported, run the build from an **x64 Native Tools Command Prompt for VS 2022**
|
|
|
148
155
|
& "$env:ProgramFiles\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
|
|
149
156
|
```
|
|
150
157
|
|
|
158
|
+
In a source checkout, `pwsh -File scripts/setup-vs-toolchain.ps1` does the same
|
|
159
|
+
and also pins `xbintsc_CLANG` to the LLVM bundled with that Visual Studio
|
|
160
|
+
installation. CI calls the same script, so a local build, the release archives
|
|
161
|
+
and CI use one Visual Studio toolchain.
|
|
162
|
+
|
|
151
163
|
Verify with `xbintsc doctor` (or `clang --version`); the report names the
|
|
152
164
|
resolved compiler, its version and its target.
|
|
153
165
|
|