xbintsc 0.6.28 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (540) hide show
  1. package/dist/src/ast/common.d.ts +10 -0
  2. package/dist/src/binder/declarations.d.ts +1 -0
  3. package/dist/src/binder/declarations.js +37 -0
  4. package/dist/src/binder/declarations.js.map +1 -1
  5. package/dist/src/binder/references.js +12 -0
  6. package/dist/src/binder/references.js.map +1 -1
  7. package/dist/src/checker/globals.js +1 -0
  8. package/dist/src/checker/globals.js.map +1 -1
  9. package/dist/src/checker/source.js +4 -0
  10. package/dist/src/checker/source.js.map +1 -1
  11. package/dist/src/checker/type-system.d.ts +5 -0
  12. package/dist/src/checker/type-system.js +22 -3
  13. package/dist/src/checker/type-system.js.map +1 -1
  14. package/dist/src/cli/help.d.ts +1 -1
  15. package/dist/src/cli/main.js +15 -3
  16. package/dist/src/cli/main.js.map +1 -1
  17. package/dist/src/codegen/generator/calls/access.js +29 -11
  18. package/dist/src/codegen/generator/calls/access.js.map +1 -1
  19. package/dist/src/codegen/generator/calls/element-inline.d.ts +42 -0
  20. package/dist/src/codegen/generator/calls/element-inline.js +388 -0
  21. package/dist/src/codegen/generator/calls/element-inline.js.map +1 -0
  22. package/dist/src/codegen/generator/calls/invocation.js +95 -1
  23. package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
  24. package/dist/src/codegen/generator/calls/super.js +3 -4
  25. package/dist/src/codegen/generator/calls/super.js.map +1 -1
  26. package/dist/src/codegen/generator/calls/unwrap.d.ts +18 -0
  27. package/dist/src/codegen/generator/calls/unwrap.js +45 -0
  28. package/dist/src/codegen/generator/calls/unwrap.js.map +1 -0
  29. package/dist/src/codegen/generator/calls.d.ts +3 -1
  30. package/dist/src/codegen/generator/calls.js +3 -1
  31. package/dist/src/codegen/generator/calls.js.map +1 -1
  32. package/dist/src/codegen/generator/debug.js +20 -3
  33. package/dist/src/codegen/generator/debug.js.map +1 -1
  34. package/dist/src/codegen/generator/expressions/assignment.js +24 -2
  35. package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
  36. package/dist/src/codegen/generator/expressions/global-values.d.ts +19 -0
  37. package/dist/src/codegen/generator/expressions/global-values.js +49 -0
  38. package/dist/src/codegen/generator/expressions/global-values.js.map +1 -0
  39. package/dist/src/codegen/generator/expressions/module-values.d.ts +6 -0
  40. package/dist/src/codegen/generator/expressions/module-values.js +51 -17
  41. package/dist/src/codegen/generator/expressions/module-values.js.map +1 -1
  42. package/dist/src/codegen/generator/expressions/primary.d.ts +0 -2
  43. package/dist/src/codegen/generator/expressions/primary.js +13 -29
  44. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  45. package/dist/src/codegen/generator/expressions.d.ts +2 -1
  46. package/dist/src/codegen/generator/expressions.js +2 -1
  47. package/dist/src/codegen/generator/expressions.js.map +1 -1
  48. package/dist/src/codegen/generator/generator.js +4 -0
  49. package/dist/src/codegen/generator/generator.js.map +1 -1
  50. package/dist/src/codegen/generator/layout.d.ts +65 -0
  51. package/dist/src/codegen/generator/layout.js +50 -0
  52. package/dist/src/codegen/generator/layout.js.map +1 -0
  53. package/dist/src/codegen/generator/lookup-tables.d.ts +22 -0
  54. package/dist/src/codegen/generator/lookup-tables.js +48 -0
  55. package/dist/src/codegen/generator/lookup-tables.js.map +1 -0
  56. package/dist/src/codegen/generator/module.js +38 -7
  57. package/dist/src/codegen/generator/module.js.map +1 -1
  58. package/dist/src/codegen/generator/state.js +21 -0
  59. package/dist/src/codegen/generator/state.js.map +1 -1
  60. package/dist/src/codegen/generator/tables.d.ts +2 -6
  61. package/dist/src/codegen/generator/tables.js +18 -12
  62. package/dist/src/codegen/generator/tables.js.map +1 -1
  63. package/dist/src/diagnostics/diagnostic.js +1 -1
  64. package/dist/src/diagnostics/diagnostic.js.map +1 -1
  65. package/dist/src/diagnostics/source-text.d.ts +37 -9
  66. package/dist/src/diagnostics/source-text.js +124 -23
  67. package/dist/src/diagnostics/source-text.js.map +1 -1
  68. package/dist/src/diagnostics/source.d.ts +16 -6
  69. package/dist/src/diagnostics/source.js +25 -4
  70. package/dist/src/diagnostics/source.js.map +1 -1
  71. package/dist/src/driver/build-key.d.ts +14 -0
  72. package/dist/src/driver/build-key.js +6 -1
  73. package/dist/src/driver/build-key.js.map +1 -1
  74. package/dist/src/driver/bundler/commonjs.d.ts +9 -2
  75. package/dist/src/driver/bundler/commonjs.js +11 -4
  76. package/dist/src/driver/bundler/commonjs.js.map +1 -1
  77. package/dist/src/driver/bundler/concatenate.d.ts +20 -0
  78. package/dist/src/driver/bundler/concatenate.js +79 -8
  79. package/dist/src/driver/bundler/concatenate.js.map +1 -1
  80. package/dist/src/driver/bundler/deferred.d.ts +29 -1
  81. package/dist/src/driver/bundler/deferred.js +114 -5
  82. package/dist/src/driver/bundler/deferred.js.map +1 -1
  83. package/dist/src/driver/bundler/dynamic-import.d.ts +6 -0
  84. package/dist/src/driver/bundler/dynamic-import.js +59 -3
  85. package/dist/src/driver/bundler/dynamic-import.js.map +1 -1
  86. package/dist/src/driver/bundler/graph.d.ts +13 -0
  87. package/dist/src/driver/bundler/graph.js +4 -4
  88. package/dist/src/driver/bundler/graph.js.map +1 -1
  89. package/dist/src/driver/bundler/merge.js +43 -13
  90. package/dist/src/driver/bundler/merge.js.map +1 -1
  91. package/dist/src/driver/bundler/namespace-object.d.ts +11 -0
  92. package/dist/src/driver/bundler/namespace-object.js +32 -0
  93. package/dist/src/driver/bundler/namespace-object.js.map +1 -1
  94. package/dist/src/driver/bundler/reexport-resolution.js +11 -2
  95. package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
  96. package/dist/src/driver/bundler/symbols.d.ts +4 -0
  97. package/dist/src/driver/bundler/symbols.js +14 -1
  98. package/dist/src/driver/bundler/symbols.js.map +1 -1
  99. package/dist/src/driver/compiler.js +13 -3
  100. package/dist/src/driver/compiler.js.map +1 -1
  101. package/dist/src/driver/config.d.ts +1 -1
  102. package/dist/src/driver/frontend.js +3 -4
  103. package/dist/src/driver/frontend.js.map +1 -1
  104. package/dist/src/driver/options.d.ts +1 -4
  105. package/dist/src/driver/runtime-lib.d.ts +27 -0
  106. package/dist/src/driver/runtime-lib.js +78 -2
  107. package/dist/src/driver/runtime-lib.js.map +1 -1
  108. package/dist/src/driver/runtime-objects.d.ts +1 -1
  109. package/dist/src/driver/runtime-objects.js +28 -5
  110. package/dist/src/driver/runtime-objects.js.map +1 -1
  111. package/dist/src/driver/toolchain.js +28 -5
  112. package/dist/src/driver/toolchain.js.map +1 -1
  113. package/dist/src/driver/version.d.ts +1 -1
  114. package/dist/src/driver/version.js +1 -1
  115. package/dist/src/driver/version.js.map +1 -1
  116. package/dist/src/extensions/gui/html.js +42 -10
  117. package/dist/src/extensions/gui/html.js.map +1 -1
  118. package/dist/src/extensions/gui/index.js +48 -0
  119. package/dist/src/extensions/gui/index.js.map +1 -1
  120. package/dist/src/extensions/node/buffer/index.d.ts +5 -4
  121. package/dist/src/extensions/node/buffer/index.js +5 -4
  122. package/dist/src/extensions/node/buffer/index.js.map +1 -1
  123. package/dist/src/extensions/node/events/index.js +8 -1
  124. package/dist/src/extensions/node/events/index.js.map +1 -1
  125. package/dist/src/extensions/node/fs/callbacks.d.ts +9 -0
  126. package/dist/src/extensions/node/fs/callbacks.js +42 -0
  127. package/dist/src/extensions/node/fs/callbacks.js.map +1 -0
  128. package/dist/src/extensions/node/fs/index.d.ts +2 -3
  129. package/dist/src/extensions/node/fs/index.js +11 -4
  130. package/dist/src/extensions/node/fs/index.js.map +1 -1
  131. package/dist/src/extensions/node/process/index.d.ts +10 -3
  132. package/dist/src/extensions/node/process/index.js +30 -5
  133. package/dist/src/extensions/node/process/index.js.map +1 -1
  134. package/dist/src/extensions/registry.d.ts +27 -0
  135. package/dist/src/extensions/registry.js +13 -4
  136. package/dist/src/extensions/registry.js.map +1 -1
  137. package/dist/src/lexer/scanner.d.ts +7 -1
  138. package/dist/src/lexer/scanner.js +15 -0
  139. package/dist/src/lexer/scanner.js.map +1 -1
  140. package/dist/src/parser/context.d.ts +10 -0
  141. package/dist/src/parser/context.js +42 -3
  142. package/dist/src/parser/context.js.map +1 -1
  143. package/dist/src/parser/expressions.js +2 -2
  144. package/dist/src/parser/expressions.js.map +1 -1
  145. package/dist/src/parser/helpers.d.ts +8 -0
  146. package/dist/src/parser/helpers.js +21 -0
  147. package/dist/src/parser/helpers.js.map +1 -1
  148. package/dist/src/parser/literals.js +6 -2
  149. package/dist/src/parser/literals.js.map +1 -1
  150. package/dist/tests/binder/binder.test.js +43 -0
  151. package/dist/tests/binder/binder.test.js.map +1 -1
  152. package/dist/tests/cli/main.test.js +9 -0
  153. package/dist/tests/cli/main.test.js.map +1 -1
  154. package/dist/tests/codegen/element-layout.test.d.ts +19 -0
  155. package/dist/tests/codegen/element-layout.test.js +80 -0
  156. package/dist/tests/codegen/element-layout.test.js.map +1 -0
  157. package/dist/tests/codegen/expressions.test.js +25 -0
  158. package/dist/tests/codegen/expressions.test.js.map +1 -1
  159. package/dist/tests/codegen/llvm.test.js +28 -0
  160. package/dist/tests/codegen/llvm.test.js.map +1 -1
  161. package/dist/tests/diagnostics/diagnostic.test.js +9 -0
  162. package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
  163. package/dist/tests/diagnostics/source-text.test.d.ts +1 -0
  164. package/dist/tests/diagnostics/source-text.test.js +50 -0
  165. package/dist/tests/diagnostics/source-text.test.js.map +1 -0
  166. package/dist/tests/diagnostics/source.test.js +17 -0
  167. package/dist/tests/diagnostics/source.test.js.map +1 -1
  168. package/dist/tests/driver/build-key.test.d.ts +1 -0
  169. package/dist/tests/driver/build-key.test.js +49 -0
  170. package/dist/tests/driver/build-key.test.js.map +1 -0
  171. package/dist/tests/driver/bundler-resolve.test.js +12 -0
  172. package/dist/tests/driver/bundler-resolve.test.js.map +1 -1
  173. package/dist/tests/driver/commonjs-prelude.test.d.ts +11 -0
  174. package/dist/tests/driver/commonjs-prelude.test.js +69 -0
  175. package/dist/tests/driver/commonjs-prelude.test.js.map +1 -0
  176. package/dist/tests/driver/compiler.test.js +42 -1
  177. package/dist/tests/driver/compiler.test.js.map +1 -1
  178. package/dist/tests/driver/html-deferred-cycles.test.d.ts +10 -0
  179. package/dist/tests/driver/html-deferred-cycles.test.js +75 -0
  180. package/dist/tests/driver/html-deferred-cycles.test.js.map +1 -0
  181. package/dist/tests/driver/namespace-type-exports.test.d.ts +9 -0
  182. package/dist/tests/driver/namespace-type-exports.test.js +59 -0
  183. package/dist/tests/driver/namespace-type-exports.test.js.map +1 -0
  184. package/dist/tests/driver/runtime-lib.test.js +49 -1
  185. package/dist/tests/driver/runtime-lib.test.js.map +1 -1
  186. package/dist/tests/driver/toolchain.test.js +8 -1
  187. package/dist/tests/driver/toolchain.test.js.map +1 -1
  188. package/dist/tests/driver/usage.test.js +2 -1
  189. package/dist/tests/driver/usage.test.js.map +1 -1
  190. package/dist/tests/e2e/async-await.test.js +16 -0
  191. package/dist/tests/e2e/async-await.test.js.map +1 -1
  192. package/dist/tests/e2e/compile-basics.test.js +53 -0
  193. package/dist/tests/e2e/compile-basics.test.js.map +1 -1
  194. package/dist/tests/e2e/compile-builtins.test.js +29 -0
  195. package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
  196. package/dist/tests/e2e/compile-deferred-marker.test.d.ts +14 -0
  197. package/dist/tests/e2e/compile-deferred-marker.test.js +68 -0
  198. package/dist/tests/e2e/compile-deferred-marker.test.js.map +1 -0
  199. package/dist/tests/e2e/compile-deferred-reexport.test.d.ts +12 -0
  200. package/dist/tests/e2e/compile-deferred-reexport.test.js +89 -0
  201. package/dist/tests/e2e/compile-deferred-reexport.test.js.map +1 -0
  202. package/dist/tests/e2e/compile-error-module.test.d.ts +9 -0
  203. package/dist/tests/e2e/compile-error-module.test.js +29 -0
  204. package/dist/tests/e2e/compile-error-module.test.js.map +1 -0
  205. package/dist/tests/e2e/compile-gc-promises.test.d.ts +11 -0
  206. package/dist/tests/e2e/compile-gc-promises.test.js +52 -0
  207. package/dist/tests/e2e/compile-gc-promises.test.js.map +1 -0
  208. package/dist/tests/e2e/compile-modules.test.js +53 -0
  209. package/dist/tests/e2e/compile-modules.test.js.map +1 -1
  210. package/dist/tests/e2e/compile-node-fs-callbacks.test.d.ts +6 -0
  211. package/dist/tests/e2e/compile-node-fs-callbacks.test.js +46 -0
  212. package/dist/tests/e2e/compile-node-fs-callbacks.test.js.map +1 -0
  213. package/dist/tests/e2e/compile-node-inheritance.test.d.ts +6 -0
  214. package/dist/tests/e2e/compile-node-inheritance.test.js +48 -0
  215. package/dist/tests/e2e/compile-node-inheritance.test.js.map +1 -0
  216. package/dist/tests/e2e/compile-node-require.test.d.ts +9 -0
  217. package/dist/tests/e2e/compile-node-require.test.js +29 -0
  218. package/dist/tests/e2e/compile-node-require.test.js.map +1 -0
  219. package/dist/tests/e2e/compile-node-stats.test.d.ts +8 -0
  220. package/dist/tests/e2e/compile-node-stats.test.js +26 -0
  221. package/dist/tests/e2e/compile-node-stats.test.js.map +1 -0
  222. package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
  223. package/dist/tests/e2e/compile-prototype-chain.test.d.ts +8 -0
  224. package/dist/tests/e2e/compile-prototype-chain.test.js +24 -0
  225. package/dist/tests/e2e/compile-prototype-chain.test.js.map +1 -0
  226. package/dist/tests/e2e/compile-proxy.test.d.ts +6 -0
  227. package/dist/tests/e2e/compile-proxy.test.js +66 -0
  228. package/dist/tests/e2e/compile-proxy.test.js.map +1 -0
  229. package/dist/tests/e2e/compile-web-globals.test.d.ts +6 -0
  230. package/dist/tests/e2e/compile-web-globals.test.js +94 -0
  231. package/dist/tests/e2e/compile-web-globals.test.js.map +1 -0
  232. package/dist/tests/e2e/differential-language.test.js +25 -0
  233. package/dist/tests/e2e/differential-language.test.js.map +1 -1
  234. package/dist/tests/e2e/differential-values.test.js +59 -0
  235. package/dist/tests/e2e/differential-values.test.js.map +1 -1
  236. package/dist/tests/e2e/fetch.test.js +1 -1
  237. package/dist/tests/e2e/gc.test.js +22 -0
  238. package/dist/tests/e2e/gc.test.js.map +1 -1
  239. package/dist/tests/e2e/gui-audio-extra.test.d.ts +12 -0
  240. package/dist/tests/e2e/gui-audio-extra.test.js +185 -0
  241. package/dist/tests/e2e/gui-audio-extra.test.js.map +1 -0
  242. package/dist/tests/e2e/gui-browser.test.js +35 -2
  243. package/dist/tests/e2e/gui-browser.test.js.map +1 -1
  244. package/dist/tests/e2e/gui-dom.test.js +88 -0
  245. package/dist/tests/e2e/gui-dom.test.js.map +1 -1
  246. package/dist/tests/e2e/gui-script-import-order.test.js +24 -0
  247. package/dist/tests/e2e/gui-script-import-order.test.js.map +1 -1
  248. package/dist/tests/e2e/gui-webgl-declarations.test.d.ts +13 -0
  249. package/dist/tests/e2e/gui-webgl-declarations.test.js +136 -0
  250. package/dist/tests/e2e/gui-webgl-declarations.test.js.map +1 -0
  251. package/dist/tests/e2e/gui-webgl-texture-units.test.d.ts +12 -0
  252. package/dist/tests/e2e/gui-webgl-texture-units.test.js +86 -0
  253. package/dist/tests/e2e/gui-webgl-texture-units.test.js.map +1 -0
  254. package/dist/tests/e2e/gui-webgl2-blit.test.js +6 -2
  255. package/dist/tests/e2e/gui-webgl2-blit.test.js.map +1 -1
  256. package/dist/tests/e2e/gui-webgl2-msaa-float.test.d.ts +12 -0
  257. package/dist/tests/e2e/gui-webgl2-msaa-float.test.js +157 -0
  258. package/dist/tests/e2e/gui-webgl2-msaa-float.test.js.map +1 -0
  259. package/dist/tests/e2e/gui-webgl2-msaa.test.d.ts +10 -0
  260. package/dist/tests/e2e/gui-webgl2-msaa.test.js +344 -0
  261. package/dist/tests/e2e/gui-webgl2-msaa.test.js.map +1 -0
  262. package/dist/tests/e2e/gui-webgl2-target-orientation.test.d.ts +15 -0
  263. package/dist/tests/e2e/gui-webgl2-target-orientation.test.js +287 -0
  264. package/dist/tests/e2e/gui-webgl2-target-orientation.test.js.map +1 -0
  265. package/dist/tests/e2e/gui-webgl2.test.js +59 -1
  266. package/dist/tests/e2e/gui-webgl2.test.js.map +1 -1
  267. package/dist/tests/e2e/hang-watchdog.test.d.ts +10 -0
  268. package/dist/tests/e2e/hang-watchdog.test.js +50 -0
  269. package/dist/tests/e2e/hang-watchdog.test.js.map +1 -0
  270. package/dist/tests/e2e/json-stringify-to-json.test.d.ts +10 -0
  271. package/dist/tests/e2e/json-stringify-to-json.test.js +61 -0
  272. package/dist/tests/e2e/json-stringify-to-json.test.js.map +1 -0
  273. package/dist/tests/e2e/method-call-cache.test.d.ts +5 -0
  274. package/dist/tests/e2e/method-call-cache.test.js +65 -0
  275. package/dist/tests/e2e/method-call-cache.test.js.map +1 -0
  276. package/dist/tests/e2e/node-process.test.d.ts +7 -0
  277. package/dist/tests/e2e/node-process.test.js +50 -0
  278. package/dist/tests/e2e/node-process.test.js.map +1 -0
  279. package/dist/tests/e2e/performance-now.test.d.ts +9 -0
  280. package/dist/tests/e2e/performance-now.test.js +36 -0
  281. package/dist/tests/e2e/performance-now.test.js.map +1 -0
  282. package/dist/tests/e2e/property-ic.test.js +33 -0
  283. package/dist/tests/e2e/property-ic.test.js.map +1 -1
  284. package/dist/tests/e2e/runtime-coverage-buffer.test.js +31 -0
  285. package/dist/tests/e2e/runtime-coverage-buffer.test.js.map +1 -1
  286. package/dist/tests/e2e/shape-interning.test.d.ts +16 -0
  287. package/dist/tests/e2e/shape-interning.test.js +55 -0
  288. package/dist/tests/e2e/shape-interning.test.js.map +1 -0
  289. package/dist/tests/e2e/string-utf16.test.js +9 -0
  290. package/dist/tests/e2e/string-utf16.test.js.map +1 -1
  291. package/dist/tests/e2e/typed-array-views.test.js +26 -0
  292. package/dist/tests/e2e/typed-array-views.test.js.map +1 -1
  293. package/dist/tests/e2e/url-search-params.test.js +19 -0
  294. package/dist/tests/e2e/url-search-params.test.js.map +1 -1
  295. package/dist/tests/e2e/web-streams.test.js +44 -29
  296. package/dist/tests/e2e/web-streams.test.js.map +1 -1
  297. package/dist/tests/extensions/gui.test.js +16 -1
  298. package/dist/tests/extensions/gui.test.js.map +1 -1
  299. package/dist/tests/helpers.js +1 -0
  300. package/dist/tests/helpers.js.map +1 -1
  301. package/dist/tests/parser/expressions.test.js +36 -0
  302. package/dist/tests/parser/expressions.test.js.map +1 -1
  303. package/dist/tests/parser/literals.test.js +19 -0
  304. package/dist/tests/parser/literals.test.js.map +1 -1
  305. package/dist/tests/parser/statements.test.js +13 -0
  306. package/dist/tests/parser/statements.test.js.map +1 -1
  307. package/doc/ai/cli.md +1 -0
  308. package/doc/ai/contributing.md +8 -5
  309. package/doc/ai/extensions.md +12 -3
  310. package/doc/ai/language-support.md +2 -1
  311. package/doc/ai/troubleshooting.md +14 -0
  312. package/doc/ai/zh-CN/cli.md +1 -0
  313. package/doc/ai/zh-CN/contributing.md +6 -3
  314. package/doc/ai/zh-CN/extensions.md +10 -2
  315. package/doc/ai/zh-CN/language-support.md +2 -1
  316. package/doc/ai/zh-CN/troubleshooting.md +12 -0
  317. package/doc/gui/api.md +26 -4
  318. package/doc/gui/dom.md +8 -0
  319. package/doc/gui/known-issues.md +35 -6
  320. package/doc/gui/runtime.md +16 -1
  321. package/doc/gui/webgl.md +97 -26
  322. package/doc/gui-scripts.md +2 -1
  323. package/doc/gui.md +8 -5
  324. package/doc/implemented/binder.md +2 -1
  325. package/doc/implemented/checker.md +14 -0
  326. package/doc/implemented/codegen.md +7 -0
  327. package/doc/implemented/lexer.md +1 -1
  328. package/doc/implemented/modules.md +23 -1
  329. package/doc/implemented/node/buffer.md +18 -5
  330. package/doc/implemented/node/fs.md +22 -1
  331. package/doc/implemented/node/process.md +65 -5
  332. package/doc/implemented/node.md +7 -1
  333. package/doc/implemented/operators.md +3 -1
  334. package/doc/implemented/parser.md +3 -2
  335. package/doc/implemented/runtime-core.md +13 -2
  336. package/doc/implemented/stdlib.md +79 -4
  337. package/doc/implemented/typed-arrays.md +18 -2
  338. package/doc/unimplemented/classes.md +1 -0
  339. package/doc/unimplemented/modules.md +1 -0
  340. package/doc/unimplemented/stdlib.md +2 -1
  341. package/doc/xbintsc.config.schema.json +5 -0
  342. package/doc/zh-CN/gui/api.md +19 -5
  343. package/doc/zh-CN/gui/dom.md +6 -0
  344. package/doc/zh-CN/gui/known-issues.md +24 -5
  345. package/doc/zh-CN/gui/runtime.md +13 -1
  346. package/doc/zh-CN/gui/webgl.md +20 -7
  347. package/doc/zh-CN/gui-scripts.md +2 -1
  348. package/doc/zh-CN/gui.md +4 -1
  349. package/doc/zh-CN/implemented/binder.md +2 -1
  350. package/doc/zh-CN/implemented/checker.md +10 -0
  351. package/doc/zh-CN/implemented/codegen.md +7 -0
  352. package/doc/zh-CN/implemented/lexer.md +1 -1
  353. package/doc/zh-CN/implemented/modules.md +17 -1
  354. package/doc/zh-CN/implemented/node/buffer.md +3 -1
  355. package/doc/zh-CN/implemented/node/fs.md +19 -1
  356. package/doc/zh-CN/implemented/node/process.md +59 -5
  357. package/doc/zh-CN/implemented/node.md +1 -1
  358. package/doc/zh-CN/implemented/operators.md +2 -1
  359. package/doc/zh-CN/implemented/parser.md +3 -2
  360. package/doc/zh-CN/implemented/runtime-core.md +10 -2
  361. package/doc/zh-CN/implemented/stdlib.md +64 -4
  362. package/doc/zh-CN/implemented/typed-arrays.md +14 -2
  363. package/doc/zh-CN/unimplemented/classes.md +1 -0
  364. package/doc/zh-CN/unimplemented/modules.md +1 -0
  365. package/doc/zh-CN/unimplemented/stdlib.md +2 -1
  366. package/package.json +7 -7
  367. package/runtime/ext_gui/audio.cpp +39 -3
  368. package/runtime/ext_gui/audio_extra.cpp +353 -0
  369. package/runtime/ext_gui/audio_extra.h +47 -0
  370. package/runtime/ext_gui/audio_fft.h +76 -0
  371. package/runtime/ext_gui/audio_internal.h +21 -0
  372. package/runtime/ext_gui/audio_mixer.cpp +46 -1
  373. package/runtime/ext_gui/audio_mixer.h +89 -1
  374. package/runtime/ext_gui/audio_mixer_extra.cpp +126 -0
  375. package/runtime/ext_gui/audio_nodes.cpp +242 -0
  376. package/runtime/ext_gui/audio_nodes_internal.h +81 -0
  377. package/runtime/ext_gui/audio_nodes_spatial.cpp +375 -0
  378. package/runtime/ext_gui/browser.cpp +9 -0
  379. package/runtime/ext_gui/browser_screen.cpp +73 -0
  380. package/runtime/ext_gui/dom_api_canvas.cpp +9 -1
  381. package/runtime/ext_gui/dom_api_internal.h +3 -0
  382. package/runtime/ext_gui/dom_api_node.cpp +21 -0
  383. package/runtime/ext_gui/dom_api_node_read.cpp +29 -0
  384. package/runtime/ext_gui/dom_api_proto.cpp +3 -0
  385. package/runtime/ext_gui/dom_api_webgl2.cpp +16 -11
  386. package/runtime/ext_gui/dom_api_webgl2_msaa.cpp +64 -0
  387. package/runtime/ext_gui/dom_api_webgl_compressed.cpp +2 -2
  388. package/runtime/ext_gui/dom_api_webgl_framebuffer.cpp +68 -11
  389. package/runtime/ext_gui/dom_api_webgl_methods.h +3 -0
  390. package/runtime/ext_gui/dom_api_webgl_state.cpp +4 -2
  391. package/runtime/ext_gui/dom_api_webgl_texture.cpp +6 -6
  392. package/runtime/ext_gui/gui.cpp +6 -1
  393. package/runtime/ext_gui/gui_engine.h +2 -0
  394. package/runtime/ext_gui/gui_events.cpp +13 -8
  395. package/runtime/ext_gui/gui_webgl.cpp +3 -2
  396. package/runtime/ext_gui/style_ua.cpp +4 -0
  397. package/runtime/ext_gui/warnings.cpp +1 -1
  398. package/runtime/ext_gui/webgl.h +102 -7
  399. package/runtime/ext_gui/webgl_api.h +3 -2
  400. package/runtime/ext_gui/webgl_blit.cpp +109 -15
  401. package/runtime/ext_gui/webgl_blit_color.cpp +264 -0
  402. package/runtime/ext_gui/webgl_blit_depth.cpp +26 -8
  403. package/runtime/ext_gui/webgl_buffer.cpp +20 -170
  404. package/runtime/ext_gui/webgl_context.cpp +117 -169
  405. package/runtime/ext_gui/webgl_draw.cpp +116 -5
  406. package/runtime/ext_gui/webgl_draw_buffers.cpp +21 -6
  407. package/runtime/ext_gui/webgl_draw_setup.cpp +1 -0
  408. package/runtime/ext_gui/webgl_draw_state.h +2 -0
  409. package/runtime/ext_gui/webgl_feature.cpp +2 -2
  410. package/runtime/ext_gui/webgl_feature.h +4 -3
  411. package/runtime/ext_gui/webgl_framebuffer.cpp +346 -0
  412. package/runtime/ext_gui/webgl_glsl_rewrite.cpp +78 -47
  413. package/runtime/ext_gui/webgl_objects.h +16 -2
  414. package/runtime/ext_gui/webgl_pipeline.cpp +1 -1
  415. package/runtime/ext_gui/webgl_state.cpp +45 -36
  416. package/runtime/ext_gui/webgl_targets.cpp +440 -0
  417. package/runtime/ext_gui/webgl_texture.cpp +81 -25
  418. package/runtime/ext_gui/window.cpp +8 -0
  419. package/runtime/ext_node/buffer/buffer.c +5 -4
  420. package/runtime/ext_node/buffer/parts/byte-access.inc +115 -11
  421. package/runtime/ext_node/buffer/parts/prototype.inc +4 -1
  422. package/runtime/ext_node/events/events.c +9 -0
  423. package/runtime/ext_node/fs/callbacks.c +138 -0
  424. package/runtime/ext_node/fs/fs_ops.c +28 -15
  425. package/runtime/ext_node/module/module.c +18 -9
  426. package/runtime/ext_node/process/process.c +117 -32
  427. package/runtime/ext_node/process/streams.c +370 -0
  428. package/runtime/ext_node/process/streams.h +20 -0
  429. package/runtime/rt.h +63 -27
  430. package/runtime/rt_binary.h +44 -0
  431. package/runtime/rt_internal.h +61 -69
  432. package/runtime/rt_object.h +83 -0
  433. package/runtime/rt_profile.h +45 -0
  434. package/runtime/xt_alloc.c +154 -181
  435. package/runtime/xt_array_buffer.c +99 -71
  436. package/runtime/xt_async_io.c +3 -0
  437. package/runtime/xt_builtins.c +29 -24
  438. package/runtime/xt_constructors.c +102 -2
  439. package/runtime/xt_containers/access.inc +125 -12
  440. package/runtime/xt_containers/arrays.inc +2 -1
  441. package/runtime/xt_containers/cstr_cache.inc +56 -0
  442. package/runtime/xt_containers/function_prototypes.inc +58 -0
  443. package/runtime/xt_containers/method_cache.inc +121 -0
  444. package/runtime/xt_containers/object_keys.inc +58 -0
  445. package/runtime/xt_containers/objects.inc +59 -75
  446. package/runtime/xt_containers/shapes.inc +153 -8
  447. package/runtime/xt_containers.c +5 -0
  448. package/runtime/xt_exit.c +34 -0
  449. package/runtime/xt_fetch/headers.inc +1 -0
  450. package/runtime/xt_fetch/response.inc +28 -8
  451. package/runtime/xt_fetch/webapi.inc +82 -0
  452. package/runtime/xt_fetch.c +5 -0
  453. package/runtime/xt_gc_release.c +70 -0
  454. package/runtime/xt_gc_stack.c +83 -0
  455. package/runtime/xt_gc_verify.c +136 -0
  456. package/runtime/xt_intl.c +224 -0
  457. package/runtime/xt_io/console.inc +66 -0
  458. package/runtime/xt_io/exception.inc +66 -1
  459. package/runtime/xt_io/watchdog.inc +101 -0
  460. package/runtime/xt_io.c +1 -0
  461. package/runtime/xt_loop.c +23 -3
  462. package/runtime/xt_module_values.c +82 -0
  463. package/runtime/xt_pool.c +151 -0
  464. package/runtime/xt_profile.c +126 -0
  465. package/runtime/xt_proxy.c +140 -0
  466. package/runtime/xt_stdlib/dispatch.inc +104 -9
  467. package/runtime/xt_stdlib/math.inc +272 -57
  468. package/runtime/xt_stdlib2/date.inc +7 -1
  469. package/runtime/xt_stdlib2/json.inc +28 -0
  470. package/runtime/xt_stdlib2/json_stringify.inc +71 -55
  471. package/runtime/xt_stdlib2/regexp-match.inc +17 -0
  472. package/runtime/xt_storage/indexed_db.c +4 -1
  473. package/runtime/xt_structured_clone.c +2 -1
  474. package/runtime/xt_typed_array/construction.inc +10 -0
  475. package/runtime/xt_typed_array/elements.inc +43 -23
  476. package/runtime/xt_url.c +50 -0
  477. package/runtime/xt_values/constructors.inc +4 -1
  478. package/runtime/xt_values/strings.inc +3 -1
  479. package/runtime/xt_web.h +27 -0
  480. package/runtime/xt_web_abort.c +373 -0
  481. package/scripts/build-runtime.ts +8 -0
  482. package/src/ast/common.ts +10 -0
  483. package/src/binder/declarations.ts +34 -0
  484. package/src/binder/references.ts +12 -0
  485. package/src/checker/globals.ts +1 -0
  486. package/src/checker/source.ts +3 -0
  487. package/src/checker/type-system.ts +23 -3
  488. package/src/cli/main.ts +14 -3
  489. package/src/codegen/generator/calls/access.ts +28 -10
  490. package/src/codegen/generator/calls/element-inline.ts +433 -0
  491. package/src/codegen/generator/calls/invocation.ts +99 -1
  492. package/src/codegen/generator/calls/super.ts +5 -4
  493. package/src/codegen/generator/calls/unwrap.ts +47 -0
  494. package/src/codegen/generator/calls.ts +5 -0
  495. package/src/codegen/generator/debug.ts +21 -3
  496. package/src/codegen/generator/expressions/assignment.ts +26 -2
  497. package/src/codegen/generator/expressions/global-values.ts +57 -0
  498. package/src/codegen/generator/expressions/module-values.ts +57 -19
  499. package/src/codegen/generator/expressions/primary.ts +13 -36
  500. package/src/codegen/generator/expressions.ts +3 -0
  501. package/src/codegen/generator/generator.ts +4 -0
  502. package/src/codegen/generator/layout.ts +54 -0
  503. package/src/codegen/generator/lookup-tables.ts +63 -0
  504. package/src/codegen/generator/module.ts +38 -7
  505. package/src/codegen/generator/state.ts +22 -0
  506. package/src/codegen/generator/tables.ts +18 -12
  507. package/src/diagnostics/diagnostic.ts +1 -1
  508. package/src/diagnostics/source-text.ts +118 -22
  509. package/src/diagnostics/source.ts +29 -7
  510. package/src/driver/build-key.ts +21 -1
  511. package/src/driver/bundler/commonjs.ts +12 -5
  512. package/src/driver/bundler/concatenate.ts +96 -12
  513. package/src/driver/bundler/deferred.ts +122 -6
  514. package/src/driver/bundler/dynamic-import.ts +75 -2
  515. package/src/driver/bundler/graph.ts +4 -4
  516. package/src/driver/bundler/merge.ts +42 -9
  517. package/src/driver/bundler/namespace-object.ts +44 -0
  518. package/src/driver/bundler/reexport-resolution.ts +14 -2
  519. package/src/driver/bundler/symbols.ts +17 -0
  520. package/src/driver/compiler.ts +14 -3
  521. package/src/driver/config.ts +1 -1
  522. package/src/driver/frontend.ts +3 -4
  523. package/src/driver/options.ts +1 -4
  524. package/src/driver/runtime-lib.ts +87 -2
  525. package/src/driver/runtime-objects.ts +28 -5
  526. package/src/driver/toolchain.ts +28 -5
  527. package/src/driver/version.ts +1 -1
  528. package/src/extensions/gui/html.ts +41 -11
  529. package/src/extensions/gui/index.ts +50 -1
  530. package/src/extensions/node/buffer/index.ts +5 -4
  531. package/src/extensions/node/events/index.ts +8 -1
  532. package/src/extensions/node/fs/callbacks.ts +45 -0
  533. package/src/extensions/node/fs/index.ts +11 -4
  534. package/src/extensions/node/process/index.ts +30 -5
  535. package/src/extensions/registry.ts +41 -4
  536. package/src/lexer/scanner.ts +16 -1
  537. package/src/parser/context.ts +39 -3
  538. package/src/parser/expressions.ts +2 -2
  539. package/src/parser/helpers.ts +22 -0
  540. package/src/parser/literals.ts +6 -2
@@ -8,6 +8,8 @@
8
8
 
9
9
  import {
10
10
  SyntaxKind,
11
+ type CallExpression,
12
+ type Identifier,
11
13
  type ObjectLiteralExpression,
12
14
  type PropertyAssignment,
13
15
  type Statement,
@@ -16,6 +18,39 @@ import {
16
18
  } from "../../ast/nodes.js";
17
19
  import type { ModuleRecord } from "./types.js";
18
20
 
21
+ /**
22
+ * Lower a *deferred* module's `export * as ns from "./dep"` to
23
+ * `const <final> = __xt_deferred_<dep>()`.
24
+ *
25
+ * The dependency's export names only exist inside its own wrapper function, so
26
+ * an object literal of final names would reference names that are not in scope
27
+ * (TS3002) or be `undefined` at run time. The wrapper returns the dependency's
28
+ * exports object, which is what the namespace export needs, and calling it also
29
+ * initialises the dependency first.
30
+ */
31
+ export function deferredNamespaceToStatement(
32
+ statement: Statement,
33
+ finalName: string,
34
+ wrapperName: string,
35
+ ): Statement {
36
+ const callee: Identifier = {
37
+ kind: SyntaxKind.Identifier,
38
+ text: wrapperName,
39
+ start: statement.start,
40
+ end: statement.start,
41
+ };
42
+ const initializer: CallExpression = {
43
+ kind: SyntaxKind.CallExpression,
44
+ expression: callee,
45
+ arguments: [],
46
+ typeArguments: [],
47
+ optional: false,
48
+ start: statement.start,
49
+ end: statement.end,
50
+ };
51
+ return variableStatement(statement, finalName, initializer);
52
+ }
53
+
19
54
  /** Lower `import * as ns from "./mod"` to `const m0_ns = { ...exports }`. */
20
55
  export function namespaceImportToStatement(
21
56
  statement: Statement,
@@ -38,6 +73,15 @@ export function namespaceImportToStatement(
38
73
  start: statement.start,
39
74
  end: statement.end,
40
75
  };
76
+ return variableStatement(statement, finalName, initializer);
77
+ }
78
+
79
+ /** `const <finalName> = <initializer>` at the statement's offsets. */
80
+ function variableStatement(
81
+ statement: Statement,
82
+ finalName: string,
83
+ initializer: ObjectLiteralExpression | CallExpression,
84
+ ): Statement {
41
85
  const declaration: VariableDeclaration = {
42
86
  kind: SyntaxKind.VariableDeclaration,
43
87
  name: { kind: SyntaxKind.Identifier, text: finalName, start: statement.start, end: statement.start },
@@ -24,7 +24,8 @@ import {
24
24
  type Statement,
25
25
  } from "../../ast/nodes.js";
26
26
  import type { ModuleRecord } from "./types.js";
27
- import { namespaceImportToStatement } from "./namespace-object.js";
27
+ import { deferredNamespaceToStatement, namespaceImportToStatement } from "./namespace-object.js";
28
+ import { deferredWrapperName } from "./deferred.js";
28
29
 
29
30
  export function resolveReexports(
30
31
  records: ModuleRecord[],
@@ -63,6 +64,8 @@ export function resolveReexports(
63
64
  }
64
65
  } else if (!clause) {
65
66
  for (const [name, value] of dependency.exports) {
67
+ // `export *` re-exports named exports only, never `default`.
68
+ if (name === "default") continue;
66
69
  if (record.exports.get(name) !== value) {
67
70
  record.exports.set(name, value);
68
71
  changed = true;
@@ -82,9 +85,18 @@ export function resolveReexports(
82
85
  const nsName = (declaration.exportClause as { name: Identifier }).name.text;
83
86
  const dependency = dependencyOf(record, declaration.moduleSpecifier.value);
84
87
  if (dependency) {
88
+ /* Both deferred: the dependency's final names live inside its
89
+ * wrapper, so read its exports object instead of building one. */
90
+ const deferred = deferredModules.has(record.path) && deferredModules.has(dependency.path);
85
91
  namespaceStatements.set(
86
92
  statement,
87
- namespaceImportToStatement(statement, `${record.prefix}${nsName}`, dependency),
93
+ deferred
94
+ ? deferredNamespaceToStatement(
95
+ statement,
96
+ `${record.prefix}${nsName}`,
97
+ deferredWrapperName(dependency),
98
+ )
99
+ : namespaceImportToStatement(statement, `${record.prefix}${nsName}`, dependency),
88
100
  );
89
101
  }
90
102
  }
@@ -36,6 +36,23 @@ export function declarationName(node: Node): Identifier | undefined {
36
36
  }
37
37
  }
38
38
 
39
+ /** True when every declaration of this symbol is erased before codegen: an
40
+ * interface, a type alias, or an ambient `declare`. Such a symbol has no
41
+ * runtime slot, so a module namespace object must not reference it. */
42
+ export function isTypeOnlySymbol(symbol: SymbolInfo): boolean {
43
+ return symbol.declarations.length > 0 && symbol.declarations.every(isErasedDeclaration);
44
+ }
45
+
46
+ function isErasedDeclaration(node: Node): boolean {
47
+ if (
48
+ node.kind === SyntaxKind.InterfaceDeclaration ||
49
+ node.kind === SyntaxKind.TypeAliasDeclaration
50
+ ) {
51
+ return true;
52
+ }
53
+ return hasModifier(node, ModifierKind.Declare);
54
+ }
55
+
39
56
  /** Rewrite a symbol's declaration and every reference to `finalName`. */
40
57
  export function renameSymbol(symbol: SymbolInfo, finalName: string): void {
41
58
  for (const declaration of symbol.declarations) {
@@ -182,10 +182,20 @@ export function build(entryPath: string, options: BuildOptions = {}): BuildResul
182
182
  const storage = resolveStorage(options.storage);
183
183
 
184
184
  const runtimeDir = findRuntimeDir();
185
+ /* The toolchain is part of the cache key, so it has to be resolved before
186
+ * the freshness check. `emit: "ir"` is front-end only and must keep working
187
+ * without clang, so it is the one build that does not resolve one. */
188
+ const toolchain: Pick<ResolvedToolchain, "clang" | "linkerArgs" | "env" | "sdkRoot"> | undefined =
189
+ emit === "ir"
190
+ ? undefined
191
+ : options.clang
192
+ ? { clang: options.clang, linkerArgs: [], env: {} }
193
+ : resolveToolchain(runner);
185
194
  const cacheKey = buildCacheKey({
186
195
  sourceText: parsed.cacheText,
187
196
  emit,
188
197
  optimize,
198
+ arch: process.arch,
189
199
  registry,
190
200
  runtimeDir,
191
201
  icon,
@@ -197,6 +207,7 @@ export function build(entryPath: string, options: BuildOptions = {}): BuildResul
197
207
  pgo,
198
208
  pgoDir,
199
209
  features: linkFeatures.map((feature) => feature.name),
210
+ ...(toolchain === undefined ? {} : { toolchain }),
200
211
  });
201
212
 
202
213
  // A `.app` bundle is deterministic from the output path and name, so it can be
@@ -255,10 +266,10 @@ export function build(entryPath: string, options: BuildOptions = {}): BuildResul
255
266
  }
256
267
 
257
268
  // -- toolchain -----------------------------------------------------------
269
+ if (toolchain === undefined) {
270
+ throw new Error("xbintsc: internal error: no toolchain resolved for a linked build");
271
+ }
258
272
  const clangStarted = Date.now();
259
- const toolchain: Pick<ResolvedToolchain, "clang" | "linkerArgs" | "env" | "sdkRoot"> = options.clang
260
- ? { clang: options.clang, linkerArgs: [], env: {} }
261
- : resolveToolchain(runner);
262
273
  const clang = toolchain.clang;
263
274
  if (pgo === "use") {
264
275
  try {
@@ -59,7 +59,7 @@ export interface ProjectConfig {
59
59
  readonly features?: readonly string[];
60
60
  /** Optional link features to keep out even when auto-detection finds a use. */
61
61
  readonly noFeatures?: readonly string[];
62
- /** Bare module specifiers mapped to local replacement files. */
62
+ /** Exact module specifiers mapped to local replacement files. */
63
63
  readonly moduleOverrides?: Readonly<Record<string, string>>;
64
64
  readonly force?: boolean;
65
65
  readonly app?: AppConfig;
@@ -7,11 +7,10 @@
7
7
  * `run` and `build`.
8
8
  */
9
9
 
10
- import { readFileSync } from "node:fs";
11
10
  import { resolve } from "node:path";
12
11
  import { DiagnosticBag } from "../diagnostics/diagnostic.js";
13
12
  import { SourceFile } from "../diagnostics/source.js";
14
- import { sourceTextBytes } from "../diagnostics/source-text.js";
13
+ import { readSourceText, sourceTextBytes } from "../diagnostics/source-text.js";
15
14
  import { Parser } from "../parser/parser.js";
16
15
  import { generate } from "../codegen/llvm.js";
17
16
  import { SyntaxKind, type SourceFileNode } from "../ast/nodes.js";
@@ -63,7 +62,7 @@ export function parseEntry(
63
62
  moduleOverrides?: Readonly<Record<string, string>>,
64
63
  ): ParsedEntry {
65
64
  const absoluteEntry = resolve(entryPath);
66
- const sourceText = sourceTextBytes(readFileSync(absoluteEntry, "utf8"));
65
+ const sourceText = readSourceText(absoluteEntry);
67
66
  const file = new SourceFile(absoluteEntry, sourceText);
68
67
  const parser = new Parser(file, diagnostics);
69
68
  let sourceFile = parser.parseSourceFile();
@@ -92,7 +91,7 @@ export function compileString(
92
91
  extensions?: ExtensionRegistry,
93
92
  options: FrontendOptions = {},
94
93
  ): CompileStringResult {
95
- const file = new SourceFile(fileName, source);
94
+ const file = new SourceFile(fileName, sourceTextBytes(source));
96
95
  const diagnostics = new DiagnosticBag();
97
96
  const parser = new Parser(file, diagnostics);
98
97
  const sourceFile = parser.parseSourceFile();
@@ -71,10 +71,7 @@ export interface BuildOptions {
71
71
  readonly features?: readonly string[];
72
72
  /** Optional link features to keep out even when the scan detects a use. */
73
73
  readonly noFeatures?: readonly string[];
74
- /**
75
- * Bare module specifiers mapped to local replacement files. A specifier in
76
- * this map resolves to its file (an absolute path) before `node_modules`.
77
- */
74
+ /** Specifiers mapped to local replacement files, checked before `node_modules`. */
78
75
  readonly moduleOverrides?: Readonly<Record<string, string>>;
79
76
  }
80
77
 
@@ -19,8 +19,9 @@
19
19
  * dependency.
20
20
  */
21
21
 
22
- import { existsSync, readdirSync } from "node:fs";
23
- import { dirname, join } from "node:path";
22
+ import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
23
+ import { dirname, join, relative, sep } from "node:path";
24
+ import { hashParts } from "./cache.js";
24
25
  import { findRuntimeDir, platformSlug } from "./paths.js";
25
26
 
26
27
  /** Archive suffixes, in the order a name is probed. */
@@ -94,3 +95,87 @@ export function findRuntimeLibrary(
94
95
  }
95
96
  return undefined;
96
97
  }
98
+
99
+
100
+ /** Name of the file recording which sources an archive was built from. */
101
+ export const RUNTIME_STAMP_FILE = "runtime-stamp.json";
102
+
103
+ /** Source files that make up the runtime archives (the archives' own folder is
104
+ * skipped: it holds the `.a`/`.lib` outputs and the stamp). */
105
+ function runtimeSourceFiles(runtimeDir: string): string[] {
106
+ const files: string[] = [];
107
+ const walk = (dir: string): void => {
108
+ let entries: string[];
109
+ try {
110
+ entries = readdirSync(dir);
111
+ } catch {
112
+ return;
113
+ }
114
+ for (const name of entries.sort()) {
115
+ const full = join(dir, name);
116
+ if (statSync(full).isDirectory()) {
117
+ if (name === "lib") continue;
118
+ walk(full);
119
+ } else if (/\.(c|h|inc)$/.test(name)) {
120
+ files.push(full);
121
+ }
122
+ }
123
+ };
124
+ walk(runtimeDir);
125
+ return files;
126
+ }
127
+
128
+ /**
129
+ * Fingerprint of the C runtime sources an archive is compiled from.
130
+ *
131
+ * A prebuilt `core`/`ext_<name>` archive is only usable when it was built from
132
+ * exactly these sources: the driver compares the archive's stamp with this
133
+ * value and compiles from source when they differ. Without the stamp a stale
134
+ * archive links silently whenever every symbol it needs still exists — the
135
+ * program then runs the *old* runtime, which is very hard to diagnose.
136
+ */
137
+ export function runtimeSourceFingerprint(runtimeDir: string, compilerVersion: string, flags: readonly string[]): string {
138
+ const parts: string[] = ["runtime-archive", compilerVersion, process.platform, process.arch, [...flags].join(" ")];
139
+ for (const file of runtimeSourceFiles(runtimeDir)) {
140
+ parts.push(relative(runtimeDir, file).split(sep).join("/"), readFileSync(file, "utf8"));
141
+ }
142
+ return hashParts(parts);
143
+ }
144
+
145
+ /** The recorded fingerprint of the archives in `dir`, if any. */
146
+ export function readRuntimeStamp(dir: string): string | undefined {
147
+ try {
148
+ const parsed: unknown = JSON.parse(readFileSync(join(dir, RUNTIME_STAMP_FILE), "utf8"));
149
+ if (typeof parsed !== "object" || parsed === null) return undefined;
150
+ const fingerprint = (parsed as { fingerprint?: unknown }).fingerprint;
151
+ return typeof fingerprint === "string" ? fingerprint : undefined;
152
+ } catch {
153
+ return undefined;
154
+ }
155
+ }
156
+
157
+ /** Record the fingerprint next to the archives a build just produced. */
158
+ export function writeRuntimeStamp(dir: string, fingerprint: string, compilerVersion: string): void {
159
+ writeFileSync(
160
+ join(dir, RUNTIME_STAMP_FILE),
161
+ `${JSON.stringify({ compilerVersion, fingerprint }, null, "\t")}\n`,
162
+ "utf8",
163
+ );
164
+ }
165
+
166
+ /**
167
+ * A prebuilt archive, but only when it was built from the sources now on disk.
168
+ *
169
+ * Returns `undefined` for a missing archive *and* for a stale one, so the caller
170
+ * falls back to compiling the runtime; `stale` tells the two apart for the
171
+ * message.
172
+ */
173
+ export function freshRuntimeLibrary(
174
+ name: string,
175
+ dirs: readonly string[],
176
+ fingerprint: string,
177
+ ): { path?: string; stale?: string } {
178
+ const path = findRuntimeLibrary(name, dirs);
179
+ if (!path) return {};
180
+ return readRuntimeStamp(dirname(path)) === fingerprint ? { path } : { stale: path };
181
+ }
@@ -11,13 +11,14 @@ import { basename, join, resolve, sep } from "node:path";
11
11
  import type { ExtensionRegistry } from "../extensions/registry.js";
12
12
  import type { ResolvedLinkFeature } from "./link-features.js";
13
13
  import { hashParts } from "./cache.js";
14
- import { findRuntimeLibrary } from "./runtime-lib.js";
14
+ import { freshRuntimeLibrary, runtimeLibDirs, runtimeSourceFingerprint } from "./runtime-lib.js";
15
15
  import { compileC, optimizationFlags, RUNTIME_CFLAGS, sysrootFlags, type PgoMode, type Runner } from "./toolchain.js";
16
16
  import { COMPILER_VERSION } from "./version.js";
17
17
 
18
18
  /** Core runtime translation units (each compiled and cached independently). */
19
19
  export const RUNTIME_SOURCES = [
20
20
  "xt_alloc.c",
21
+ "xt_gc_stack.c",
21
22
  "xt_values.c",
22
23
  "xt_bigint.c",
23
24
  "xt_containers.c",
@@ -31,14 +32,22 @@ export const RUNTIME_SOURCES = [
31
32
  "xt_async.c",
32
33
  "xt_loop.c",
33
34
  "xt_async_io.c",
35
+ "xt_exit.c",
36
+ "xt_intl.c",
34
37
  "xt_generator.c",
35
38
  "xt_coroutine.c",
36
39
  "xt_fetch.c",
40
+ "xt_web_abort.c",
41
+ "xt_proxy.c",
42
+ "xt_gc_verify.c",
37
43
  "xt_symbol.c",
38
44
  "xt_builtins.c",
39
45
  "xt_constructors.c",
40
46
  "xt_structured_clone.c",
41
47
  "xt_performance.c",
48
+ "xt_profile.c",
49
+ "xt_pool.c",
50
+ "xt_gc_release.c",
42
51
  "xt_random.c",
43
52
  "xt_crypto.c",
44
53
  "xt_text_codec.c",
@@ -154,7 +163,17 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
154
163
  };
155
164
 
156
165
  const runtimeInclude = [runtimeDir];
157
- const coreArchive = preferPrebuilt ? findRuntimeLibrary("core", options.runtimeLibDirs) : undefined;
166
+ /* A shipped archive is only used when it was built from the sources on disk;
167
+ * a stale one links silently and the program runs an old runtime. */
168
+ const fingerprint = runtimeSourceFingerprint(runtimeDir, COMPILER_VERSION, RUNTIME_CFLAGS);
169
+ const staleArchives: string[] = [];
170
+ const prebuilt = (name: string): string | undefined => {
171
+ if (!preferPrebuilt) return undefined;
172
+ const found = freshRuntimeLibrary(name, options.runtimeLibDirs ?? runtimeLibDirs(), fingerprint);
173
+ if (found.stale !== undefined) staleArchives.push(found.stale);
174
+ return found.path;
175
+ };
176
+ const coreArchive = prebuilt("core");
158
177
  const runtimeObjects = coreArchive
159
178
  ? [coreArchive]
160
179
  : RUNTIME_SOURCES.map((source) => compileOne(join(runtimeDir, source), basename(source, ".c"), runtimeInclude));
@@ -167,9 +186,7 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
167
186
  for (const extension of registry.all()) {
168
187
  const sources = extension.runtimeSources ? extension.runtimeSources() : [];
169
188
  if (sources.length === 0) continue;
170
- const archive = preferPrebuilt
171
- ? findRuntimeLibrary(`ext_${extension.name}`, options.runtimeLibDirs)
172
- : undefined;
189
+ const archive = prebuilt(`ext_${extension.name}`);
173
190
  if (archive) {
174
191
  extensionObjects.push(archive);
175
192
  prebuiltArchives.push(archive);
@@ -184,6 +201,12 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
184
201
  );
185
202
  }
186
203
  }
204
+ if (staleArchives.length > 0) {
205
+ /* Once per process: the archives stay stale until `npm run runtime` . */
206
+ process.stderr.write(
207
+ "xbintsc: prebuilt runtime archive is stale (the runtime sources changed); compiling the C runtime from source\n",
208
+ );
209
+ }
187
210
  // A native archive may be shared by several manifests; link each once.
188
211
  const featureObjects: string[] = [];
189
212
  for (const feature of options.features ?? []) {
@@ -34,14 +34,37 @@ export const realRunner: Runner = {
34
34
  };
35
35
  if (options.env) spawnOptions.env = Object.assign({}, process.env, options.env);
36
36
  const result = spawnSync(command, [...args], spawnOptions);
37
- return {
38
- status: result.status ?? (result.error ? 1 : 0),
39
- stdout: result.stdout?.toString() ?? "",
40
- stderr: result.stderr?.toString() ?? (result.error ? String(result.error.message) : ""),
41
- };
37
+ const stdout = result.stdout?.toString() ?? "";
38
+ const baseStderr = result.stderr?.toString() ?? "";
39
+ /* `status === null` is never success: the child either failed to start
40
+ * (`error`) or was terminated by a signal. Treating the signal case as 0
41
+ * made a killed clang look like a successful compile and let `build`
42
+ * record a missing/truncated artifact. */
43
+ if (result.error) {
44
+ const detail = result.error.message;
45
+ return {
46
+ status: result.status ?? 1,
47
+ stdout,
48
+ stderr: appendLine(baseStderr, detail),
49
+ };
50
+ }
51
+ if (result.status === null) {
52
+ return {
53
+ status: 1,
54
+ stdout,
55
+ stderr: appendLine(baseStderr, `terminated by signal ${result.signal ?? "unknown"}`),
56
+ };
57
+ }
58
+ return { status: result.status, stdout, stderr: baseStderr };
42
59
  },
43
60
  };
44
61
 
62
+ /** Append `line` to `text` without losing an existing final newline. */
63
+ function appendLine(text: string, line: string): string {
64
+ if (text.length === 0) return line;
65
+ return text.endsWith("\n") ? `${text}${line}` : `${text}\n${line}`;
66
+ }
67
+
45
68
  export class ToolchainError extends Error {
46
69
  readonly command: string;
47
70
  readonly status: number;
@@ -9,4 +9,4 @@
9
9
  * `main`/`master` only (see `.githooks/pre-commit`), so feature branches never
10
10
  * change this line and merging two of them cannot conflict here.
11
11
  */
12
- export const COMPILER_VERSION = "0.6.28";
12
+ export const COMPILER_VERSION = "0.7.6";
@@ -24,7 +24,7 @@
24
24
  * "eager" execution point), i.e. every script is effectively `defer`red.
25
25
  */
26
26
 
27
- import { existsSync, readFileSync } from "node:fs";
27
+ import { existsSync } from "node:fs";
28
28
  import { dirname, relative, resolve } from "node:path";
29
29
  import {
30
30
  ModifierKind,
@@ -37,6 +37,7 @@ import {
37
37
  } from "../../ast/nodes.js";
38
38
  import { DiagnosticBag } from "../../diagnostics/diagnostic.js";
39
39
  import { SourceFile } from "../../diagnostics/source.js";
40
+ import { readSourceText } from "../../diagnostics/source-text.js";
40
41
  import { Parser } from "../../parser/parser.js";
41
42
  import { artifactPath } from "../../canonical.js";
42
43
  import { hashString } from "../../driver/cache.js";
@@ -81,6 +82,22 @@ function isExecutable(type: string | undefined, lang: string | undefined): boole
81
82
  }
82
83
  }
83
84
 
85
+ /**
86
+ * Whether an executable `<script>` is plain JavaScript rather than TypeScript.
87
+ *
88
+ * A browser page's script is JavaScript by default; only `lang="ts"` or a
89
+ * TypeScript MIME type opts into type checking. Untyped scripts skip the
90
+ * checker's inference (see `isPlainJavaScriptNode`), which is what keeps
91
+ * minified bundles — `Game.foo = …` installed after the literal, a closure
92
+ * variable initialized to `null`, calls that rely on default parameters — from
93
+ * failing on heuristics that a real browser never applies.
94
+ */
95
+ function isPlainScript(type: string | undefined, lang: string | undefined): boolean {
96
+ if (lang !== undefined && /^(ts|tsx|typescript)$/i.test(lang)) return false;
97
+ if (type === undefined) return true;
98
+ return !/^(text\/typescript|application\/typescript)$/i.test(type);
99
+ }
100
+
84
101
  /** Rewrite a relative import specifier so it resolves from the HTML file. */
85
102
  function rewriteSpecifier(htmlPath: string, scriptPath: string, specifier: string): string {
86
103
  if (!specifier.startsWith(".")) return specifier;
@@ -274,8 +291,9 @@ export function loadHtmlAsset(path: string, source: string): AssetLoadResult {
274
291
  const page = new SourceFile(path, source).text;
275
292
  /* `file` is set for an external `<script src>`: its body keeps that file as
276
293
  * the origin of every node, so a `.js` script stays untyped and diagnostics
277
- * name the script, not the HTML page. */
278
- const scripts: Array<{ id: string; body: string; prelude: string[]; file?: string }> = [];
294
+ * name the script, not the HTML page. `untyped` marks an inline body that is
295
+ * JavaScript (the default) rather than `lang="ts"`. */
296
+ const scripts: Array<{ id: string; body: string; prelude: string[]; file?: string; untyped?: boolean }> = [];
279
297
  const imports: string[] = [];
280
298
  const lazyImports: string[] = [];
281
299
  const importedText = new Set<string>();
@@ -301,12 +319,18 @@ export function loadHtmlAsset(path: string, source: string): AssetLoadResult {
301
319
  bound.add(name);
302
320
  }
303
321
  };
304
- const register = (compiled: CompiledModule, file?: string): string => {
322
+ const register = (compiled: CompiledModule, options?: { file?: string; untyped?: boolean }): string => {
305
323
  /* Hash the wrapped body, prelude included: the engine keys the registry by
306
324
  * id, so two scripts with the same statements but different deferred
307
325
  * imports must not collapse into one entry. */
308
326
  const id = hashString([...compiled.prelude, compiled.body].join("\n"));
309
- scripts.push({ id, body: compiled.body, prelude: compiled.prelude, ...(file ? { file } : {}) });
327
+ scripts.push({
328
+ id,
329
+ body: compiled.body,
330
+ prelude: compiled.prelude,
331
+ ...(options?.file ? { file: options.file } : {}),
332
+ ...(options?.untyped ? { untyped: true } : {}),
333
+ });
310
334
  return id;
311
335
  };
312
336
 
@@ -314,7 +338,9 @@ export function loadHtmlAsset(path: string, source: string): AssetLoadResult {
314
338
  * would be dropped at runtime. Inline it (and its `@import`s) now. */
315
339
  const styles = inlineStylesheets(path, page);
316
340
  const html = styles.html.replace(SCRIPT_RE, (match, attributes: string, inlineBody: string) => {
317
- if (!isExecutable(attribute(attributes, "type"), attribute(attributes, "lang"))) return match;
341
+ const lang = attribute(attributes, "lang");
342
+ const type = attribute(attributes, "type");
343
+ if (!isExecutable(type, lang)) return match;
318
344
  const src = attribute(attributes, "src");
319
345
 
320
346
  if (src !== undefined && !URL_SPEC.test(src) && !src.startsWith("//")) {
@@ -322,9 +348,9 @@ export function loadHtmlAsset(path: string, source: string): AssetLoadResult {
322
348
  if (!existsSync(scriptPath)) {
323
349
  throw new Error(`gui: <script src="${src}"> not found (looked for ${scriptPath})`);
324
350
  }
325
- const compiled = compileModuleSource(path, scriptPath, readFileSync(scriptPath, "utf8"), scripts.length);
351
+ const compiled = compileModuleSource(path, scriptPath, readSourceText(scriptPath), scripts.length);
326
352
  hoistImports(compiled, `<script src="${src}">`, `alias it in ${scriptPath}`);
327
- const id = register(compiled, scriptPath);
353
+ const id = register(compiled, { file: scriptPath });
328
354
  return `<script data-xt-id="${id}"></script>`;
329
355
  }
330
356
 
@@ -339,7 +365,7 @@ export function loadHtmlAsset(path: string, source: string): AssetLoadResult {
339
365
  * where codegen cannot link its binding (TS5001). */
340
366
  const compiled = compileModuleSource(path, path, inlineBody, scripts.length);
341
367
  hoistImports(compiled, "inline <script>", "alias it");
342
- const id = register(compiled);
368
+ const id = register(compiled, { untyped: isPlainScript(type, lang) });
343
369
  return `<script data-xt-id="${id}"></script>`;
344
370
  });
345
371
 
@@ -348,14 +374,18 @@ export function loadHtmlAsset(path: string, source: string): AssetLoadResult {
348
374
  /* Offset of the next part once joined with "\n", so a body's span in the
349
375
  * generated module can be reported back as the file it was copied from. */
350
376
  let offset = parts.reduce((total, part) => total + part.length + 1, 0);
351
- for (const { id, body, prelude, file } of scripts) {
377
+ for (const { id, body, prelude, file, untyped } of scripts) {
352
378
  const header = `function __xt_script_${id}(window: any, document: any): void {\n`;
353
379
  const preludeText = prelude.length > 0 ? `${prelude.join("\n")}\n` : "";
354
380
  const part =
355
381
  `${header}${preludeText}${body}\n}\n` + `__registerScript(${JSON.stringify(id)}, __xt_script_${id});`;
382
+ const bodyStart = offset + header.length + preludeText.length;
356
383
  if (file !== undefined) {
357
- const bodyStart = offset + header.length + preludeText.length;
358
384
  sourceRanges.push({ start: bodyStart, end: bodyStart + body.length, file });
385
+ } else if (untyped) {
386
+ /* An inline JavaScript body: its origin is the page itself, and the
387
+ * checker must treat it as untyped JavaScript, not as TypeScript. */
388
+ sourceRanges.push({ start: bodyStart, end: bodyStart + body.length, file: path, untyped: true });
359
389
  }
360
390
  parts.push(part);
361
391
  offset += part.length + 1;
@@ -66,6 +66,12 @@ const hostTypes = [
66
66
  "HTMLImageElement",
67
67
  "HTMLVideoElement",
68
68
  "HTMLAudioElement",
69
+ /* Media-source and offline-rendering types. `VideoFrame` is a real
70
+ * constructor value so `frame instanceof VideoFrame` is a safe `false`
71
+ * instead of a `TypeError`; `OfflineAudioContext` renders through the same
72
+ * mixer as `AudioContext`. */
73
+ "VideoFrame",
74
+ "OfflineAudioContext",
69
75
  "HTMLElement",
70
76
  "Element",
71
77
  "Node",
@@ -145,7 +151,7 @@ const hostTypes = [
145
151
  "GPUDeviceLostInfo",
146
152
  ] as const;
147
153
 
148
- const browserGlobals: Record<string, { symbol: string; argument?: string }> = {
154
+ const browserGlobals: Record<string, { symbol: string; argument?: string; member?: string }> = {
149
155
  window: { symbol: "xt_browser_window" },
150
156
  self: { symbol: "xt_browser_window" },
151
157
  document: { symbol: "xt_browser_document" },
@@ -154,8 +160,51 @@ const browserGlobals: Record<string, { symbol: string; argument?: string }> = {
154
160
  * by the SQLite `storage` link feature, so a page reaches them through core
155
161
  * rather than the engine's in-memory `window.localStorage` store. */
156
162
  __THREE_DEVTOOLS__: { symbol: "xt_browser_missing" },
163
+ /* Half-precision typed arrays exist in very new engines only, and the
164
+ * runtime has no 16-bit float element type. Answering `undefined` keeps
165
+ * feature probes (`typeof Float16Array < "u"`) on their fallback path instead
166
+ * of handing back a constructor that cannot hold data. */
167
+ Float16Array: { symbol: "xt_browser_missing" },
157
168
  createImageBitmap: { symbol: "xt_browser_create_image_bitmap" },
158
169
  };
170
+
171
+ /**
172
+ * Window members that a browser also exposes as bare globals.
173
+ *
174
+ * In a browser the global scope *is* the window, so `innerWidth`,
175
+ * `location.reload()` and `addEventListener("resize", …)` work without a
176
+ * `window.` prefix — pages and libraries (three.js probes `innerWidth`) rely on
177
+ * that. xbintsc has no global object here, so each name is declared as a member
178
+ * read of the window value: the read lowers to `xt_get(window, name)` and a
179
+ * call to `xt_call_method(window, name, …)`, which keeps getter-backed members
180
+ * live instead of capturing a value at startup.
181
+ */
182
+ const windowGlobals: readonly string[] = [
183
+ "innerWidth",
184
+ "innerHeight",
185
+ "outerWidth",
186
+ "outerHeight",
187
+ "devicePixelRatio",
188
+ "location",
189
+ "screen",
190
+ "scrollX",
191
+ "scrollY",
192
+ "addEventListener",
193
+ "removeEventListener",
194
+ "dispatchEvent",
195
+ "setTimeout",
196
+ "clearTimeout",
197
+ "setInterval",
198
+ "clearInterval",
199
+ "queueMicrotask",
200
+ "focus",
201
+ "blur",
202
+ "scrollTo",
203
+ "scrollBy",
204
+ ];
205
+ for (const member of windowGlobals) {
206
+ browserGlobals[member] = { symbol: "xt_browser_window", member };
207
+ }
159
208
  for (const type of hostTypes) {
160
209
  browserGlobals[type] = { symbol: "xt_browser_type", argument: type };
161
210
  }