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
@@ -5,6 +5,19 @@
5
5
 
6
6
  ## Known issues
7
7
 
8
+ - **Web Audio has no `MediaStream`/capture pipeline, and two node behaviours are
9
+ approximations.** `createMediaElementSource` and `createMediaStreamSource`
10
+ return valid, *silent* nodes: the engine has no microphone/camera capture and
11
+ does not route a media element's own playback through the graph, so a page
12
+ that feeds either into a graph gets silence instead of an error.
13
+ `WaveShaperNode.oversample` averages the curve at 2 or 4 sub-sample points
14
+ rather than band-limiting the input, which softens but does not remove the
15
+ aliasing a hard curve introduces. `PannerNode.panningModel = "HRTF"` is
16
+ accepted but uses the equal-power path — no HRIR data set is shipped, so the
17
+ result is a stereo pan with distance/cone attenuation, not a binaural filter.
18
+ `ConvolverNode` normalizes by energy (the response is scaled so a white-noise
19
+ input keeps its level); it is close to, but not bit-identical with, the
20
+ browser's normalization.
8
21
  - **WebGL 1.0 and 2.0 run on the GPU, with a subset of each.**
9
22
  `canvas.getContext("webgl")` / `"webgl2"` return real GPU contexts (see
10
23
  [WebGL](./webgl.md)): GLSL ES shaders are translated to SPIR-V by the bundled
@@ -13,15 +26,31 @@
13
26
  colour texture that the page composites without a readback. WebGL 2 adds VAOs,
14
27
  instancing, integer attributes, sampler objects, `texStorage2D`, buffer copies,
15
28
  uniform blocks, cube/3D/array textures, float/depth/compressed textures,
16
- multiple render targets and scissored clears. `blitFramebuffer` copies colour
17
- and depth; transform feedback, MSAA and stencil blits are not implemented
18
- (SDL_GPU has no transform-feedback stage, its Metal multisample resolve is
19
- unreliable, and a stencil attachment is not sampleable). On an SDL_GPU backend
20
- that accepts neither SPIR-V nor MSL (Direct3D 12, which would need DXIL) both
29
+ multiple render targets, scissored clears and 4× multisample antialiasing on
30
+ Vulkan. `blitFramebuffer` copies colour and depth and resolves a multisampled
31
+ colour source; transform feedback and stencil or multisampled-depth blits are
32
+ not implemented (SDL_GPU has no transform-feedback stage, cannot resolve
33
+ depth, and cannot sample a stencil attachment). On an SDL_GPU backend that
34
+ accepts neither SPIR-V nor MSL (Direct3D 12, which would need DXIL) both
21
35
  context kinds are `null`. The `.js` asset loader now patches only three.js's
22
36
  shader unroller; `WebGLRenderer` runs on the real backend and there is no
23
37
  Canvas2D fallback. Shadow maps (comparative `sampler2DShadow` targeting depth
24
38
  textures), cube textures/environment maps and HDR render targets are supported.
39
+ - **MSAA is enabled on Vulkan and Metal, and it changes what may be blitted
40
+ where.** The `antialias` attribute defaults to true; a supported context gets
41
+ a 4× drawing buffer that resolves into the composited colour texture at the
42
+ end of every render pass, so `getParameter(SAMPLES)` is 4 and a partially
43
+ covered edge pixel is a blend. A device without 4× colour and depth support
44
+ keeps the single-sampled path (`antialias` false, `MAX_SAMPLES` 0, and
45
+ multisample storage requests degrade to single-sampled renderbuffers/textures
46
+ with `SAMPLES` 0). As in a browser,
47
+ `blitFramebuffer` into the antialiased
48
+ default framebuffer is `INVALID_OPERATION`: request
49
+ `getContext("webgl2", { antialias: false })` when the page resolves its own
50
+ offscreen target to the canvas. A multisampled colour source resolves only
51
+ with identical source/destination rectangles, an identical format and
52
+ `NEAREST`; multisampled depth attachments render (depth testing works per
53
+ sample) but cannot be resolved through SDL_GPU.
25
54
  - **Comparative samplers can miscompile on Intel Macs.** On an Intel GPU (seen
26
55
  on Intel Iris Plus Graphics with macOS 26), the Metal shader compiler drops a
27
56
  fragment function that calls `sample_compare`: the draw produces no pixels at
@@ -199,4 +228,4 @@
199
228
  unusable on **SDL 3.2.10**: its D3D12 backend rejects any graphics pipeline
200
229
  whose shaders declare a uniform buffer, and the engine passes the viewport that
201
230
  way. This does not affect Windows in practice because SDL_GPU selects Vulkan
202
- there; re-check after an SDL upgrade if the D3D12 path is ever forced.
231
+ there; re-check after an SDL upgrade if the D3D12 path is ever forced.
@@ -55,6 +55,16 @@ that case with a single 16 ms `xt_set_timeout` tick:
55
55
  queued animation-frame callbacks before layout, so a page can stop itself),
56
56
  - it re-arms **only while callbacks remain**, so an idle page lets the event
57
57
  loop drain and the process exit — the browser-tab lifecycle;
58
+ - **every** request restarts it, including one made through the *window
59
+ method* (`window.requestAnimationFrame` / `self.requestAnimationFrame`), not
60
+ just the bare global. three.js's `setAnimationLoop` asks through `self` long
61
+ after its boot, when the pump had already drained; missing that left the
62
+ renderer without a next frame, so a game page froze on its last presented
63
+ image (the Saltline page sat on "准备就绪" forever while its DOM said the boot
64
+ overlay was hidden — the hide was queued, the frame that would have painted it
65
+ never ran);
66
+ - the callback receives a `DOMHighResTimeStamp` on the same clock as
67
+ `performance.now()`, not `SDL_GetTicks()` (machine uptime);
58
68
  - it schedules the next tick for *frame start + 16 ms*, not 16 ms after the
59
69
  frame finished: the frame's own duration is not added to the interval, so a
60
70
  10 ms frame runs at a 16 ms period instead of 26 ms, and a page slower than
@@ -63,7 +73,12 @@ that case with a single 16 ms `xt_set_timeout` tick:
63
73
  - it stands aside while `xt_gui_run_active()` is set (the program called
64
74
  `run()`), so the same window is not rendered twice per tick;
65
75
  - `XT_GUI_AUTOCLOSE_MS=n` makes the pump quit after `n` milliseconds, which is
66
- how the tests run a page that never closes itself.
76
+ how the tests run a page that never closes itself;
77
+ - `XT_GUI_TRACE=1` prints the WebGL resolve/blit/render-pass sequence (including
78
+ the last draws of a submitted command buffer) to stderr, and
79
+ `XT_GUI_VK_DEBUG=1` asks SDL for a debug GPU device so the Vulkan backend
80
+ enables the Khronos validation layers — the two switches used to locate the
81
+ half-float resolve that lost the device.
67
82
 
68
83
  This keeps network I/O, timers and `await` working inside a GUI program.
69
84
 
package/doc/gui/webgl.md CHANGED
@@ -34,7 +34,9 @@ reports the type as well.
34
34
  - Each context owns one offscreen `R8G8B8A8_UNORM` colour texture (the drawing
35
35
  buffer) and a `D32_FLOAT` depth texture, sized from the canvas's `width` /
36
36
  `height` attributes. `canvas.width = …` recreates them and discards the
37
- contents, like the DOM rule.
37
+ contents, like the DOM rule. With MSAA the draws go into a 4× colour texture
38
+ and every render pass resolves it into the colour texture the page composites
39
+ (see [Multisample antialiasing](#multisample-antialiasing-msaa)).
38
40
  - The context records into its own SDL_GPU command buffer. `clear`/`draw*`
39
41
  keep a render pass open; only a buffer/texture upload or a framebuffer
40
42
  change ends it and starts a new pass with `LOAD`, so the drawing buffer
@@ -44,8 +46,20 @@ reports the type as well.
44
46
  WebGL command buffer. The image pipeline then samples the colour texture as
45
47
  an ordinary `PaintImage`, with no CPU copy.
46
48
  - WebGL's origin is bottom-left while SDL_GPU render targets are top-left, so
47
- the framebuffer is stored top-down: `viewport`/`scissor` are converted,
48
- `readPixels` flips rows back, and the compositor sees an upright texture.
49
+ the two framebuffer kinds are stored differently. The default drawing buffer
50
+ is **top-down**, the way the compositor presents it (texture row 0 is the
51
+ image's top): its `viewport`/`scissor` are converted, `readPixels` reverses
52
+ rows and a draw uses a positive-height, y-flipped viewport. A user framebuffer
53
+ is **bottom-up**, the way a texture is sampled (`v = 0` is its bottom row), so
54
+ `viewport`/`scissor`/`readPixels` map GL rows straight through and a draw
55
+ flips the viewport with a negative height. That flip also mirrors the winding
56
+ the rasteriser sees, so the GL front-face comparison is flipped for a
57
+ bottom-up target (and is part of the pipeline key, so the two orientations
58
+ keep distinct pipelines). A render target therefore samples back in WebGL's
59
+ orientation, and a depth texture (shadow map) matches the projection that
60
+ wrote it. `blitFramebuffer` between the two kinds cannot use
61
+ `SDL_BlitGPUTexture` (its copy cannot reverse rows), so it draws a sampling
62
+ pass instead; a blit between two targets of the same kind keeps the GPU blit.
49
63
  - A fixed-function state change (`blendFunc`, `depthFunc`, `cullFace`,
50
64
  `colorMask`, …) changes which `SDL_GPUGraphicsPipeline` is needed, so
51
65
  pipelines are created lazily and cached on the program. The key is the
@@ -62,6 +76,51 @@ reports the type as well.
62
76
  steady state: two draws with the same layout and different buffers create no
63
77
  pipeline after the first frame.
64
78
 
79
+ ## Multisample antialiasing (MSAA)
80
+
81
+ `getContext("webgl2")` — and `getContext("webgl")` — honour the `antialias`
82
+ context-creation attribute, which defaults to `true` like WebGL's. On a
83
+ supported backend the drawing buffer is **4× multisampled**:
84
+
85
+ - `getContextAttributes().antialias` reports `true`, `getParameter(SAMPLES)`
86
+ reports `4`, `SAMPLE_BUFFERS` reports `1` and `MAX_SAMPLES` reports `4` for the
87
+ default framebuffer. `getContext("webgl2", { antialias: false })` keeps the
88
+ single-sampled path (`SAMPLES`/`SAMPLE_BUFFERS` report `0`).
89
+ - Draws render into a multisampled colour texture with a matching 4× depth
90
+ texture. Every `end` of a render pass resolves the colour target into the
91
+ single-sampled texture the page composites, so the compositor, `readPixels` and
92
+ `blitFramebuffer` all see the resolved image without an extra call.
93
+ - A scissored `clear` draws a textured quad into the multisampled target
94
+ (`SDL_BlitGPUTexture` cannot target one); the quad's edges fall on pixel
95
+ boundaries, so every pixel inside the scissor rectangle gets full coverage.
96
+ - `renderbufferStorageMultisample(target, samples, internalformat, width,
97
+ height)` allocates a 4× colour or depth(-stencil) renderbuffer;
98
+ `texStorage2DMultisample`/`texImage2DMultisample` do the same for a texture.
99
+ Attaching one to a framebuffer makes it a render target, and
100
+ `checkFramebufferStatus` reports `FRAMEBUFFER_INCOMPLETE_MULTISAMPLE` when the
101
+ attached colour and depth buffers disagree on the sample count.
102
+ - `blitFramebuffer` resolves a multisampled source into a single-sampled
103
+ destination when the source and destination rectangles and colour formats are
104
+ identical and the filter is `NEAREST` — the ES 3.0 resolve rules. The resolve
105
+ of a half-float (or float) colour target is a **sampling pass**, not
106
+ `SDL_BlitGPUTexture`: SDL_GPU's blit is `vkCmdBlitImage`, and Vulkan does not
107
+ require 16F/32F images to support blit source/destination, so the invalid
108
+ command lost the Vulkan device on a three.js `samples > 0` render target.
109
+ A sampling pass copies every colour format (the full-rectangle resolve
110
+ three.js performs maps exactly). Blitting into a multisampled draw framebuffer
111
+ is `INVALID_OPERATION`, and `readPixels` from a multisampled user framebuffer
112
+ is `INVALID_OPERATION` too (resolve it first).
113
+
114
+ Both backends that can run WebGL enable MSAA: Vulkan (Windows/Linux) and Metal
115
+ (macOS) resolve the 4× drawing buffer, including scissored clears and instanced
116
+ draws. A device that cannot sample 4× RGBA8 and depth keeps the single-sampled
117
+ path: `antialias` reports `false`, `MAX_SAMPLES` is `0`, and
118
+ `renderbufferStorageMultisample` / `texStorage2DMultisample` degrade to
119
+ single-sampled storage (`RENDERBUFFER_SAMPLES` reports `0`) so a page that still
120
+ asks for MSAA keeps a working attachment. Depth and stencil attachments cannot
121
+ be resolved through SDL_GPU, so a multisampled depth blit is accepted and leaves
122
+ the destination depth untouched (stencil bits were already unsupported).
123
+
65
124
  ## Shaders: GLSL ES to SPIR-V (and on to MSL)
66
125
 
67
126
  SDL_GPU cannot compile GLSL at run time, and each backend consumes its own
@@ -107,11 +166,13 @@ The translator (`runtime/ext_gui/webgl_glsl*.cpp`) handles GLSL ES 1.00 and
107
166
 
108
167
  Non-sampler uniforms are merged across both stages and emitted as one block in
109
168
  each stage (set 1 for the vertex shader, set 3 for the fragment shader), which
110
- matches SDL_GPU's Vulkan descriptor layout. On Metal the same declarations
111
- become `[[buffer(0)]]` and `[[texture(N)]]`/`[[sampler(N)]]`, the slots SDL_GPU's
112
- Metal backend binds. `uniformMatrix4fv` writes column-major floats into the
113
- reflected offsets; `uniform1i` on a sampler stores the texture unit. The block
114
- is pushed with the dynamic uniform-buffer API on every draw.
169
+ matches SDL_GPU's Vulkan descriptor layout. A declaration that names several
170
+ variables (`uniform sampler2D a, b;`, `uniform vec3 tint, fill;`) is rewritten
171
+ one declarator at a time: each sampler gets its own binding, because a GLSL
172
+ declaration shares one `layout(...)` across all of its declarators, and each
173
+ non-sampler becomes its own block member. `uniformMatrix4fv` writes column-major
174
+ floats into the reflected offsets; `uniform1i` on a sampler stores the texture
175
+ unit. The block is pushed with the dynamic uniform-buffer API on every draw.
115
176
 
116
177
  Limits of the translator: struct-typed uniforms, user uniform blocks, uniform
117
178
  arrays whose size is not resolved by the preprocessor, and a sampler array
@@ -198,11 +259,12 @@ available from GLSL ES 3.00, which is what the instanced example uses.
198
259
  (`FRAMEBUFFER`/`READ_FRAMEBUFFER`/`DRAW_FRAMEBUFFER`),
199
260
  `framebufferTexture2D` (`COLOR_ATTACHMENT0`, `DEPTH_ATTACHMENT`,
200
261
  `DEPTH_STENCIL_ATTACHMENT`), `checkFramebufferStatus`, `createRenderbuffer`,
201
- `bindRenderbuffer`, `renderbufferStorage` (depth or depth-stencil),
202
- `framebufferRenderbuffer`, `delete*`, and `blitFramebuffer` (colour through
203
- SDL's blit; depth through a sampling pass that writes `gl_FragDepth`; stencil
204
- bits are accepted but not copied). This is enough for render-to-texture,
205
- shadow maps and post-processing passes.
262
+ `bindRenderbuffer`, `renderbufferStorage` (colour, depth or depth-stencil),
263
+ `renderbufferStorageMultisample`, `framebufferRenderbuffer`, `delete*`, and
264
+ `blitFramebuffer` (colour through SDL's blit, or a resolve for a multisampled
265
+ source; depth through a sampling pass that writes `gl_FragDepth`; stencil bits
266
+ are accepted but not copied). This is enough for render-to-texture,
267
+ multisampled render targets, shadow maps and post-processing passes.
206
268
  - **State**: `enable`/`disable`/`isEnabled` for `BLEND`, `DEPTH_TEST`,
207
269
  `CULL_FACE`, `SCISSOR_TEST` and `STENCIL_TEST`,
208
270
  `clearColor`/`clearDepth`/`clearStencil`, `clear` (with `SCISSOR_TEST` it
@@ -218,8 +280,10 @@ available from GLSL ES 3.00, which is what the instanced example uses.
218
280
  pair that differs uses the front value.
219
281
  - **Readback**: `readPixels` (RGBA/UNSIGNED_BYTE) from the default framebuffer
220
282
  or a bound RGBA8 framebuffer; a float/depth attachment is sampled into an
221
- RGBA8 target first. It blocks until the GPU finishes; use it for tests and
222
- screenshots, not per frame.
283
+ RGBA8 target first, and the default framebuffer's multisampled colour target
284
+ is resolved into the readable texture automatically. Reading a multisampled
285
+ user framebuffer directly is `INVALID_OPERATION`. It blocks until the GPU
286
+ finishes; use it for tests and screenshots, not per frame.
223
287
 
224
288
  WebGL 2 adds:
225
289
 
@@ -272,11 +336,12 @@ backend's `[0, 1]` clip space rather than GL's `[-1, 1] → [0, 1]` remap:
272
336
  ## Not implemented
273
337
 
274
338
  Transform feedback (the entry points are no-ops: SDL_GPU has no transform
275
- feedback stage) and MSAA/sample buffers (SDL_GPU 3.2 can resolve multisampled
276
- colour targets, but its Metal resolve returns undefined pixels with scissor
277
- tests and instanced draws, so contexts stay single-sampled and `SAMPLE_BUFFERS`
278
- reports 0). `blitFramebuffer` copies colour and depth; stencil bits are accepted
279
- but not copied because SDL_GPU cannot sample a stencil attachment.
339
+ feedback stage) and multisampled *depth/stencil* resolves (SDL_GPU can resolve
340
+ colour targets only, so a multisample depth blit leaves the destination depth
341
+ untouched). `blitFramebuffer` copies colour and depth; stencil bits are accepted
342
+ but not copied because SDL_GPU cannot sample a stencil attachment. Shaders
343
+ cannot sample a multisampled texture (`sampler2DMS`): reading one requires a
344
+ resolve through `blitFramebuffer`.
280
345
 
281
346
  Shader limitations that remain: struct-typed uniforms and user uniform blocks
282
347
  are flattened, but built-in interface blocks (`gl_PerVertex` redeclarations) are
@@ -331,6 +396,11 @@ SPIRV-Cross, nor any `webgl_*` member (see [Link features](./build.md#link-featu
331
396
  colour attachments and reads each back.
332
397
  - `tests/e2e/gui-webgl2-ubo.test.ts` binds a std140 block, updates its members
333
398
  and verifies the drawn colour.
399
+ - `tests/e2e/gui-webgl2-msaa.test.ts` checks the antialiased default drawing
400
+ buffer (a partially covered edge pixel resolves to a blend), resolves a
401
+ multisampled renderbuffer and `texStorage2DMultisample` texture through
402
+ `blitFramebuffer`, reports `FRAMEBUFFER_INCOMPLETE_MULTISAMPLE` for mismatched
403
+ attachments and rejects `readPixels` from a multisampled framebuffer.
334
404
  - `examples/gui/webgl-cube` is a spinning, lit, textured cube; it runs in a
335
405
  browser unchanged and is covered by
336
406
  `tests/e2e/gui-example-webgl.test.ts`.
@@ -358,9 +428,10 @@ Canvas2D fallback is bundled any more**. Verified with three.js r160 through SDL
358
428
  `Sprite`, `Line`, `Points` and `InstancedMesh`.
359
429
 
360
430
  Features outside this engine's subset still cannot be emulated: transform
361
- feedback and MSAA. Depth textures, float render targets and compressed textures
362
- are available, and comparative `sampler2DShadow` sampling is translated, so
363
- three.js shadow maps can use the hardware depth compare on both backends (see
364
- [known issues](./known-issues.md) for an Intel-Mac driver caveat). A
365
- scene that needs transform feedback or MSAA will not render correctly;
366
- everything the previous Canvas2D fallback could show now goes through the GPU.
431
+ feedback and multisampled depth resolves. Depth textures, float render targets
432
+ and compressed textures are available, MSAA colour resolves run on Vulkan and
433
+ Metal, and comparative `sampler2DShadow` sampling is translated, so three.js
434
+ shadow maps can use the hardware depth compare on both backends (see
435
+ [known issues](./known-issues.md) for an Intel-Mac driver caveat). A scene that
436
+ needs transform feedback will not render correctly; everything the previous
437
+ Canvas2D fallback could show now goes through the GPU.
@@ -64,7 +64,8 @@ run scripts is to **compile them ahead of time**.
64
64
  | 1 | **No page JS engine.** Behaviour is native TS. `<script>` bodies are *AOT-compiled* to native code by xbintsc and invoked through `xt_call_with_this` — there is still no interpreter. |
65
65
  | 8 | **Scripts are compile-time assets.** The HTML asset loader transforms inline `<script>` bodies into compiled modules and replaces them with `data-xt-id` markers; the runtime only *invokes* already-compiled functions. |
66
66
  | 9 | **The DOM is owned by the engine; handles are engine objects.** Handles use the same shared-prototype object model as window handles; hidden fields carry a window reference, a document generation and a node index. |
67
- | 10 | **`window`/`document` are injected as parameters**, not globals, so no global-object machinery is added to the compiler. |
67
+ | 10 | **`window`/`document` are injected as parameters**, not globals, so no global-object machinery is added to the compiler. The *window members* a browser also exposes as bare globals (`innerWidth`, `location`, `addEventListener`, `screen`, …) are declared by the extension as member reads of the window value, so `innerWidth` lowers to `xt_get(window, "innerWidth")` and stays live. |
68
+ | 11 | **A `<script>` is JavaScript unless it says `lang="ts"`.** That is the browser rule, and it is also what keeps a minified bundle (or any plain JS page) out of the type checker, whose inference is only sound for code that was written with annotations. Names and redeclarations are still checked, because code generation needs them. |
68
69
 
69
70
  ## Architecture
70
71
 
package/doc/gui.md CHANGED
@@ -352,12 +352,15 @@ engine were Rust.
352
352
  the WebGL 1 one, with the WebGL 2 constants and methods.
353
353
  - GLSL ES 3.00 sources (`#version 300 es`, `in`/`out`, named fragment
354
354
  outputs, `gl_InstanceID`) compile through the same rewriter.
355
- - Vertex-array objects save/restore the attribute table, instanced draws use
356
- SDL's per-instance input rate, and sampler objects override a texture
357
- unit's filter/wrap state. `texStorage2D`, `copyBufferSubData`,
355
+ - `texStorage2D`, `copyBufferSubData`,
358
356
  `getBufferSubData` and `clearBuffer*` are implemented; query/fence/UBO and
359
- transform-feedback entry points exist and degrade gracefully. See
360
- [WebGL](./gui/webgl.md); e2e in `tests/e2e/gui-webgl2.test.ts` and
357
+ transform-feedback entry points exist and degrade gracefully.
358
+ - Vulkan and Metal contexts are 4× multisampled when the `antialias`
359
+ attribute (default true) allows it: every pass resolves the drawing buffer
360
+ into the composited texture, `renderbufferStorageMultisample`/
361
+ `texStorage2DMultisample` allocate multisampled render targets, and
362
+ `blitFramebuffer` resolves colour. See [WebGL](./gui/webgl.md); e2e in
363
+ `tests/e2e/gui-webgl2.test.ts` and
361
364
  `tests/e2e/gui-example-webgl2.test.ts`, demo in
362
365
  `examples/gui/webgl2-cubes`.
363
366
  19. **M19 — decorative CSS** ✅
@@ -6,7 +6,8 @@ Location: `src/binder/binder.ts`
6
6
 
7
7
  - Scope kinds: module, function, block, `for`, `catch`
8
8
  - Symbol kinds: `var` / `let` / `const` / `function` / `parameter` / `class` / `interface` / `type` / `enum` / `import` / `namespace`
9
- - `var` and function declarations hoist to the function scope; `let` / `const` stay block-scoped
9
+ - `var` and function declarations hoist to the function scope; `let` / `const` stay block-scoped. A `var` written inside a nested block or in a `for` head reuses that one hoisted symbol, so `{ var x = 1 }` is visible (and assignable) after the block
10
+ - A destructuring *parameter* pre-declares its names and then binds the default values nested inside the pattern, so `({ a = () => 1 }) => a()` gets a function of its own
10
11
  - A `switch` body is one shared block scope: the declarations of every `case` / `default` clause are pre-declared before any clause is bound
11
12
  - A `static { ... }` class block is bound as a hidden static function of the class (see [Classes](../unimplemented/classes.md))
12
13
  - Identifier → declaration resolution; unresolved identifier collection (`CannotFindName`)
@@ -29,6 +29,11 @@ else as `any`:
29
29
  - classes: instance fields, methods, accessors, parameter properties,
30
30
  `this.x = ...` members and local ancestor classes. Static members are not
31
31
  instance members;
32
+ - declaration visibility: interfaces, type aliases and classes declared at
33
+ module top level are visible to the whole bundle, while one declared *inside a
34
+ function body* only counts in the file that declares it. Bundled dependencies
35
+ are full of function-local classes (`babel.cjs` has its own `class Token`), and
36
+ those must not capture a type name the importing file meant;
32
37
  - arrays, tuples, function types, object literals and `new LocalClass()`;
33
38
  - simple generics: a type parameter is `any` at its declaration, and a call
34
39
  infers it from an argument (`T`, `T[]`, `Array<T>`) or takes it from an
@@ -100,6 +105,15 @@ other control flow does not.
100
105
  - Bundled sources under `node_modules` are not checked at all: the checker is a
101
106
  gate for the code you wrote, and failing on a dependency's internals would
102
107
  make the default-on checker unusable with packages.
108
+ - Plain JavaScript sources are not type-checked either (TypeScript only reports
109
+ on them with `checkJs`): an external `.js`/`.mjs`/`.cjs`/`.jsx` script, and an
110
+ inline `<script>` body in an HTML page that does not say `lang="ts"`. Names
111
+ are still resolved and redeclarations are still reported — both are needed for
112
+ code generation — but no type, arity or property diagnostic is produced. That
113
+ is the browser rule as well: a page's script is JavaScript unless it opts in,
114
+ and minified bundles legitimately install methods on a state object after its
115
+ literal, initialize a "call it later" variable with `null`, and call functions
116
+ through default parameters.
103
117
 
104
118
  ## Behaviour without the checker
105
119
 
@@ -7,6 +7,11 @@ Location: `src/codegen/llvm.ts`
7
7
  - Emits LLVM IR text (`.ll`); no custom register allocation (relies on `alloca` + mem2reg).
8
8
  - Statement / block boundary values live in `alloca`; conditionals and short-circuits materialize into temporary slots instead of `phi`.
9
9
  - Property reads are inline-cached per source site: each access owns a zeroed `[2 x i64]` global (`@ic.N`) passed to `xt_get_ic`. Ordinary objects carry an interned hidden-class shape (`xt_shape`, a `(parent, key)` transition tree) and the cache stores `(shape, property index)`, so a hit is a shape-pointer compare plus one key check instead of a linear property scan. Inserts/deletes and integer-key reordering rebuild or transition the shape, which invalidates stale caches; arrays, functions and containers fall back to `xt_get`.
10
+ - Property **writes** get the same per-site cache: each `obj.name = value` owns a `[2 x i64]` global (`@st.N`) passed to `xt_set_ic`. A hit compares the receiver's shape and the slot's key and writes the value field; a miss goes through `xt_set` (new property, delete, accessor, frozen object, host view, array, typed array) and refills the cache when the key ended up as an own data property. That removes the own-property scan, the inherited-setter walk and the typed-array kind probe from every hot store.
11
+ - `Math.<fn>(...)` with a fixed arity lowers to a direct runtime entry (`xt_math1_floor`, `xt_math2_imul`, `xt_math0_random`, …) instead of `xt_math_call(name, argc, argv)`: the name and arity are known at compile time, so the arguments are passed in registers and the runtime skips the name dispatch and the argument array. Any other shape (a spread argument, a wrong argument count, `min`/`max`, a first-class `Math` alias) keeps `xt_math_call`, which dispatches on the first byte of the name instead of a linear `strcmp` chain.
12
+ - Shape transitions are interned by the key's **text**, not by the address of the string that holds it: `xt_shape_transition` hashes the string bytes and compares keys by value. A key built at run time — a typed array's `byteLength`, a DOM handle's `length`, `obj["k" + i]` — is a fresh string with the same bytes, so pointer-keyed interning created a new shape on every insert; past the 16K limit each new object then had no shape at all, which silently disabled both inline caches for the rest of the program (a 1.4 MB bundled page interned 260 000+ transitions and spent about a minute in level setup). The table has 4096 buckets and interns up to 262 144 transitions; `XT_SHAPE_TRACE=1` reports the count as it grows, so a page that outgrows it is visible instead of merely slow.
13
+ - Element access `obj[key]` is inlined into the IR (`calls/element-inline.ts`) instead of being a runtime call. The emitted fast path guards the key to a canonical array index (integral, `0 .. 2^32-2` — `ta[1.5]` and `ta[-1]` stay ordinary property accesses), then loads the live `length`/`items` (or a typed-array view's `view_bytes`/kind) straight out of the container header and does the element load/store itself; strings, `Map`s, host views, out-of-range indices and the integer typed-array *stores* (which need `ToUintN`/`ToIntN` wrapping) branch to `xt_get_element` / `xt_set_element`, so semantics stay exactly the runtime's. The field offsets live in `layout.ts` and are checked against `runtime/rt_object.h` by `tests/codegen/element-layout.test.ts`. Without this, every element access was a call clang could not inline (no LTO), which cost geometry code ~50x a plain array on typed arrays.
14
+ - Method calls obj.name(...) carry a three-word monomorphic inline cache (@mt.N) passed to xt_call_method_ic: a hit compares the receiver''s prototype value and the holder''s shape, re-reads the cached property slot and calls its *current* value with his, so a reassigned/deleted/added method is still observed; anything else (built-ins, Map/Set, host views, deep prototype chains, getters, a non-function value) takes the full xt_call_method dispatch. That removed the per-call resolution walk from numeric code, which was ~26x a V8 call.
10
15
  - Numeric operators keep the inline two-double fast path; operands that are numeric literals skip their tag check. Conditions whose expression is a comparison, `in`, `instanceof` or `!` are already boolean tags, so codegen emits `icmp eq i64 value, XT_TRUE` instead of calling `xt_truthy` (this removes the call from the hot loop condition).
11
16
  - Control flow: `if` / `while` / `do` / `for` / `for...of` / `for...in`, `switch`, `try/catch/finally`, `break` / `continue` / `return`.
12
17
  - `for...of` and spread iterate arrays, strings, typed arrays, `Map`, `Set`, generators and any object exposing `[Symbol.iterator]()` through `xt_iter_open` → `xt_iter_has` / `xt_iter_value` (`Map` yields `[key, value]` pairs); a non-iterable throws `TypeError`. Arrays also expose a stable `Array.prototype[Symbol.iterator]`; calling it returns an iterator object with `next()` that is itself iterable.
@@ -32,3 +37,5 @@ Location: `src/codegen/llvm.ts`
32
37
  - Builtin calls: `console.log` / `info` / `warn` / `error`, `Math.*`, `Object.*`, array / string methods, global functions, extension builtins (uniform `(argc, argv)` ABI).
33
38
  - `main` entry point (returns 0, calls the module function, then drains microtasks and runs the event loop until no timers or descriptors remain).
34
39
  - Unsupported nodes uniformly report `UnsupportedFeature`; they never crash.
40
+
41
+
@@ -16,7 +16,7 @@ Location: `src/lexer/scanner.ts`, `src/lexer/token.ts`
16
16
  - Single / double quotes
17
17
  - Escapes: `\n \t \r \b \f \0 \\ \' \"`, `\xHH`, `\uHHHH`, `\u{...}`
18
18
  - Template literals (lexer level): no-substitution templates, `TemplateHead`, `TemplateMiddle`, `TemplateTail`, with `${}` and escapes.
19
- - Regex literal scanning (`/pattern/flags`), distinguishing division `/`.
19
+ - Regex literal scanning (`/pattern/flags`), distinguishing division `/`. The scanner decides from the previous token, which cannot be right everywhere (`for (;;) /re/.test(x)` looks like a division); the parser keeps a regex fallback that re-reads the raw source, so a mis-scan only has to stay silent.
20
20
  - Private identifiers `#name`.
21
21
  - Comments: line `//` and block `/* */` (with unterminated diagnostics).
22
22
  - Newline and whitespace tracking (for ASI), BOM / CRLF normalization (`SourceFile`).
@@ -8,7 +8,7 @@ Location: `src/parser/parser.ts` (syntax), `src/driver/modules.ts` (bundling),
8
8
  ## Syntax
9
9
 
10
10
  - `import default, { named } from "..."`, `import * as ns from "..."` (namespace imports of relative modules are lowered to a synthetic object literal; extension modules such as `path` are also supported), `import "./side-effect"`, `import type`
11
- - `export default`, `export { a as b }`, `export *`, `export =`
11
+ - `export default`, `export { a as b }`, `export *`, `export * as ns from "..."`, `export =`
12
12
  - Import attributes (`with` / `assert`)
13
13
 
14
14
  ## Runtime semantics
@@ -32,13 +32,35 @@ Location: `src/parser/parser.ts` (syntax), `src/driver/modules.ts` (bundling),
32
32
  stripped, so a bare or `node:` specifier links like any ordinary module import.
33
33
  - Modules also reachable through a normal (non-marker) import stay eager and get
34
34
  a thin wrapper over their already-initialised exports.
35
+ - Two triggers share that machinery. An HTML page's `<script src>` (or inline
36
+ script) imports are marked with `__xt_deferred_module`, and the generated
37
+ script calls the marker when the engine runs it after `loadHTML`; a literal
38
+ `import("…")` calls the same wrapper at the import site. Both evaluate the
39
+ module once (`__xt_defer` memoises by module id) and both see identical
40
+ wrapper semantics — hoisted functions, `export * as` bindings and cycles
41
+ behave the same in either. Both calls end up in the same runtime helper
42
+ (`xt_defer_module`, the bundler emits it as a bare global call), so the only
43
+ difference is *who* triggers the evaluation; the engine decides the moment for
44
+ a script, the program for `import("…")`.
35
45
  - The wrapper body is synchronous: top-level `await` inside a deferred script
36
46
  module is not supported.
47
+ - Function declarations and the bindings of simple top-level `const`/`let`/`var`
48
+ declarations are *hoisted* out of the wrapper, and a wrapper assigns their
49
+ values in source order. That is what lets a module cycle call a dependency's
50
+ function before either body has run (an import of such a function refers to it
51
+ directly instead of copying it into an alias). Modules with destructuring, a
52
+ `class` or an `enum` at the top level keep every declaration inside the
53
+ wrapper, so a cycle that calls *their* functions still sees `undefined`.
37
54
 
38
55
  ## import.meta
39
56
 
40
57
  - `import.meta.url` / `.dirname` / `.filename`, resolved from the running executable's path.
41
58
 
59
+ ## Dynamic `import()`
60
+
61
+ - A *literal* specifier is a static edge: the module is bundled and the call resolves to its namespace object.
62
+ - A *computed* specifier cannot be loaded at run time (a compiled binary has no module loader), but the modules linked into the build are known: `import(<expression>)` resolves to the namespace of any enabled extension module, accepting both its bare and its `node:`-prefixed name — `const fs = await import("node:" + "fs")`. Any other specifier rejects with an error that names it.
63
+
42
64
  ## Extension modules
43
65
 
44
66
  - Extension modules (such as `fs`) are importable by bare or `node:`-prefixed specifier and resolve to their runtime entries; see [Extensions](./extensions.md).
@@ -4,11 +4,17 @@
4
4
 
5
5
  Location: `src/extensions/node/buffer/index.ts`, `runtime/ext_node/buffer/buffer.c`
6
6
 
7
- xbintsc has no native binary value type, so `Buffer` is represented as a
8
- **plain object**: each byte is a numeric property `"0".."n-1"`, plus a `length`
9
- property, sharing the `xt_buffer_proto()` prototype that provides instance
10
- methods. `xt_node_is_buffer` / `xt_node_buffer_bytes` let other modules access
11
- bytes across modules.
7
+ xbintsc has no native binary value type, so a `Buffer` is an ordinary object
8
+ that keeps its bytes in an `ArrayBuffer` under a private symbol, plus a
9
+ `length` property, sharing the `xt_buffer_proto()` prototype that provides
10
+ instance methods. Dynamic-property hooks answer `buf[i]` and `buf[i] = 65` from
11
+ that store, so index access behaves like a real Buffer while the bytes stay out
12
+ of the property table: building one is a single bulk copy instead of one
13
+ property insert per byte (which was quadratic and stalled on multi-kilobyte
14
+ decodes). `xt_node_is_buffer` / `xt_node_buffer_bytes` let other modules access
15
+ bytes across modules; `xt_node_buffer_bytes` copies through
16
+ `xt_array_buffer_copy_bytes_out`, so the fs module does not pay one lookup per
17
+ byte.
12
18
 
13
19
  | Static method | Notes |
14
20
  | --- | --- |
@@ -24,6 +30,13 @@ bytes across modules.
24
30
 
25
31
  Instance methods: `toString([encoding])`, `toJSON()`, `slice(start, end)`, `subarray(...)`, `equals(other)`, `compare(other)`, `copy(target[, targetStart, sourceStart, sourceEnd])`, `write(string[, offset[, length[, encoding]]])`, `fill(value)`, `reverse()`, `indexOf(value)`, `lastIndexOf(value)`, `includes(value)`, `keys()`, `values()`, plus `readUInt8/UInt16LE/UInt16BE/UInt32LE/UInt32BE`, `writeUInt8/UInt16LE/UInt16BE/UInt32LE/UInt32BE`.
26
32
 
33
+ Index access works through the object hooks: `buf[0]` reads a byte, `buf[0] =
34
+ 65` writes one (out-of-range writes are dropped and cannot grow the buffer),
35
+ `0 in buf` is true inside the range, and `Object.keys(buf)` lists the indices
36
+ after the real properties. The store is an `ArrayBuffer`, so each byte costs
37
+ one `xt_value` slot (the representation `ArrayBuffer` already uses) in exchange
38
+ for garbage collection without a finalizer.
39
+
27
40
  ```ts
28
41
  const buf = Buffer.from("hello");
29
42
  console.log(buf.toString(), buf.length); // hello 5
@@ -4,6 +4,27 @@
4
4
 
5
5
  Location: `src/extensions/node/fs/*.ts`, `runtime/ext_node/fs/*.c`
6
6
 
7
+ ## Callback forms
8
+
9
+ Every operation below also has Node's callback form, running on the
10
+ asynchronous I/O pool: `readFile(path[, options], callback)`,
11
+ `writeFile`, `appendFile`, `stat`, `lstat`, `statfs`, `realpath`, `access`,
12
+ `mkdir`, `mkdtemp`, `readdir`, `rm`, `rmdir`, `unlink`, `rename`, `copyFile`,
13
+ `cp`, `open`, `chmod`, `lchmod`, `chown`, `lchown`, `truncate`, `utimes`,
14
+ `lutimes`, `link`, `symlink`, `readlink`, `opendir` and `glob`. The callback
15
+ receives `(error, value)` — `error` is `null` on success and a Node-shaped
16
+ `Error` (`code`, `errno`, `syscall`, `path`) on failure. `exists(path, cb)` is
17
+ the exception: `cb(boolean)` with no error argument.
18
+
19
+ ```ts
20
+ import { readFile } from "node:fs";
21
+
22
+ readFile("package.json", "utf8", (error, text) => {
23
+ if (error) throw error;
24
+ console.log(text.length);
25
+ });
26
+ ```
27
+
7
28
  ## Available functions (imported from `fs`)
8
29
 
9
30
  | Imported function | Runtime symbol | Notes |
@@ -22,7 +43,7 @@ Location: `src/extensions/node/fs/*.ts`, `runtime/ext_node/fs/*.c`
22
43
  | `copyFileSync(src, dest[, flags])` | `xt_node_copy_file` | copy a file; honours `COPYFILE_EXCL` |
23
44
  | `cpSync(src, dest[, options])` | `xt_node_cp` | recursive copy; `recursive`, `force`, `errorOnExist`, `dereference`, `preserveTimestamps` |
24
45
  | `realpathSync(path)` | `xt_node_realpath` | resolve to an absolute path |
25
- | `statSync(path)` | `xt_node_stat` | file metadata object (follows symlinks) |
46
+ | `statSync(path)` | `xt_node_stat` | file metadata object (follows symlinks); `mtime` / `atime` / `ctime` / `birthtime` are `Date`s, with the matching `*Ms` numbers |
26
47
  | `lstatSync(path)` | `xt_node_lstat` | file metadata object (does not follow symlinks) |
27
48
  | `statfsSync(path)` | `xt_node_statfs` | filesystem statistics (`bsize`, `blocks`, `bfree`, …) |
28
49
  | `accessSync(path[, mode])` | `xt_node_access` | check accessibility |
@@ -2,22 +2,82 @@
2
2
 
3
3
  > Part of [Node extension: implemented](../node.md) · [简体中文](../../zh-CN/implemented/node/process.md)
4
4
 
5
- Location: `src/extensions/node/process/index.ts`, `runtime/ext_node/process/process.c`
5
+ Location: `src/extensions/node/process/index.ts`, `runtime/ext_node/process/process.c`,
6
+ `runtime/ext_node/process/streams.c`
6
7
 
7
- Method calls lower to `xt_process_call(<name>, argc, argv)`, property access to `xt_process_get(<name>)`.
8
- Import the object (`import process from "process"`) to reach these.
8
+ Method calls lower to `xt_process_call(<name>, argc, argv)`, property reads to
9
+ `xt_process_get(<name>)` and property writes to `xt_process_set(<name>, value)`
10
+ (see `NAMESPACE_STATICS` / `NAMESPACE_PROPERTIES` / `NAMESPACE_PROPERTY_SETTERS`
11
+ in `src/codegen/generator/tables.ts`). Import the object
12
+ (`import process from "process"`) to reach these.
9
13
 
10
14
  | Method / property | Notes |
11
15
  | --- | --- |
12
16
  | `process.cwd()` | current working directory |
13
- | `process.exit([code])` | exit the process |
17
+ | `process.exit([code])` | run the "exit" listeners, then exit with `code` |
14
18
  | `process.uptime()` | process uptime (seconds) |
15
19
  | `process.hrtime()` | `[seconds, nanoseconds]` array |
16
20
  | `process.getuid()` | user ID (returns 0 on Windows) |
21
+ | `process.on` / `once` / `addListener` / `prependListener` | register an event listener |
22
+ | `process.off` / `removeListener` / `removeAllListeners` | remove listeners |
23
+ | `process.emit(event, ...args)` | fire an event by hand |
24
+ | `process.nextTick(fn, ...args)` | queue on the microtask queue |
25
+ | `process.exitCode` | read **and** write; becomes the program's exit status |
26
+ | `process.versions` | `{ node: "0.0.0" }` — no `bun` key, so `process.versions.bun` is `undefined` |
17
27
  | `process.platform` / `process.arch` | platform / architecture |
18
28
  | `process.pid` / `process.ppid` | process ID / parent process ID |
19
29
  | `process.argv` | argument array (`argv[0]` is the executable) |
20
30
  | `process.env` | environment variable object |
21
- | `process.version` / `process.title` | placeholder strings |
31
+ | `process.execPath` | path of the running binary |
32
+ | `process.version` / `process.title` | placeholder version string / writable title |
33
+ | `process.stdin` / `process.stdout` / `process.stderr` | standard streams, see below |
22
34
 
23
35
  > `argv` is captured by the generated `main` via `xt_set_program_args` and provided to the runtime.
36
+
37
+ ## Termination and the exit status
38
+
39
+ The generated `main` ends with `xt_finish()`: it runs the "exit" listeners once
40
+ and returns the status the program asked for, so `process.exitCode = 1` and
41
+ `process.exit(1)` both reach the parent process. `process.exit(code)` runs the
42
+ listeners before leaving, which means a listener sees the final code as its
43
+ argument.
44
+
45
+ ## Standard streams
46
+
47
+ `process.stdout` and `process.stderr` are cached EventEmitter objects with
48
+ `write(text)`, `end()`, `destroy()`, `fd`, `isTTY`, `columns` and `rows`.
49
+ `columns`/`rows` come from the console window (Windows) or `TIOCGWINSZ` (POSIX),
50
+ falling back to `COLUMNS`/`LINES` and then 80x24; they are read once when the
51
+ object is created.
52
+
53
+ `process.stdin` is a cached EventEmitter:
54
+
55
+ | Member | Notes |
56
+ | --- | --- |
57
+ | `on("data", fn)` / `once` / `off` | attaching a "data" listener switches the stream to flowing mode |
58
+ | `resume()` / `pause()` | start or stop the read loop |
59
+ | `setEncoding(name)` | records `encoding`; chunks are always UTF-8 strings |
60
+ | `setRawMode(bool)` | console/terminal raw mode, see below |
61
+ | `destroy()` | stops reading |
62
+ | `isTTY` / `isRaw` / `fd` / `readable` | stream state |
63
+
64
+ A blocking read runs on the async I/O worker pool (the reactor's `select(2)`
65
+ cannot watch a console or a pipe on Windows), and its completion — which runs on
66
+ the main thread — decodes the bytes and emits `data` with a string chunk of at
67
+ most 4096 bytes. End of input emits `end` and then `close`.
68
+
69
+ Raw mode flips the console into `ENABLE_VIRTUAL_TERMINAL_INPUT` (Windows) or a
70
+ `termios` raw mode (POSIX) so a TUI receives escape sequences per keystroke
71
+ instead of line-buffered text. An `atexit` handler restores the previous mode, so
72
+ a program that exits without calling `setRawMode(false)` leaves the terminal
73
+ usable.
74
+
75
+ Known limits:
76
+
77
+ - No `resize` events: `stdout.on("resize", fn)` registers but never fires.
78
+ - No signal events: `process.on("SIGINT", fn)` never fires. In raw mode the
79
+ terminal delivers Ctrl+C as input (`"\u0003"`), which is what a TUI wants; a
80
+ line-buffered program terminates through the OS default.
81
+ - Chunks are strings, not `Buffer`s, and there is no `read(size)` pull API.
82
+ - `process.on` listeners are stored on the emitter object; `prependListener`
83
+ appends like `on` (order is registration order).
@@ -23,7 +23,7 @@ work on another. Missing or different behaviour is recorded under
23
23
  | `path` | [path](./node/path.md) | `path.<name>(...)` namespace calls |
24
24
  | `os` | [os](./node/os.md) | `os.<name>(...)` namespace calls |
25
25
  | `process` | [process](./node/process.md) | object: methods and properties |
26
- | `buffer` | [buffer](./node/buffer.md) | `Buffer` represented as a plain object |
26
+ | `buffer` | [buffer](./node/buffer.md) | `Buffer` keeps its bytes in an `ArrayBuffer` store, not in properties |
27
27
  | `stream` | [stream](./node/stream.md) | `Readable` / `Writable` / `Duplex` / `Transform` / `PassThrough` |
28
28
  | `stream/promises` | [stream/promises](./node/stream-promises.md) | `pipeline` only |
29
29
  | `stream/web` | [stream/web](./node/stream-web.md) | WHATWG streams, re-exported from the core runtime |
@@ -51,6 +51,12 @@ Additional small modules are provided with their core surface: `timers`
51
51
  (`StringDecoder`), `diagnostics_channel` (`channel`/`tracingChannel`), and
52
52
  `util/types` (the type predicates).
53
53
 
54
+ `createRequire(url)` returns a `require` that resolves the modules linked into
55
+ the binary: `require("fs")` / `require("node:fs")` answer the same namespace a
56
+ static import would. A specifier that names nothing linked (an arbitrary file or
57
+ an npm package the program never imported) throws — a compiled binary has no
58
+ module loader.
59
+
54
60
  `tls` and `http2` are implemented as optional **link features** backed by the
55
61
  vendored mbedTLS and nghttp2 libraries: `npm run tls` fetches and builds
56
62
  `runtime/lib/<os>-<arch>/{tls,nghttp2}.{a,lib}`, and the driver links them only