xbintsc 0.7.0 → 0.7.7

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 (351) hide show
  1. package/dist/src/ast/common.d.ts +10 -0
  2. package/dist/src/binder/references.js +13 -7
  3. package/dist/src/binder/references.js.map +1 -1
  4. package/dist/src/checker/source.js +4 -0
  5. package/dist/src/checker/source.js.map +1 -1
  6. package/dist/src/cli/help.d.ts +1 -1
  7. package/dist/src/cli/main.js +15 -3
  8. package/dist/src/cli/main.js.map +1 -1
  9. package/dist/src/codegen/generator/calls/access.js +4 -11
  10. package/dist/src/codegen/generator/calls/access.js.map +1 -1
  11. package/dist/src/codegen/generator/calls/element-inline.d.ts +42 -0
  12. package/dist/src/codegen/generator/calls/element-inline.js +388 -0
  13. package/dist/src/codegen/generator/calls/element-inline.js.map +1 -0
  14. package/dist/src/codegen/generator/calls/invocation.js +82 -1
  15. package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
  16. package/dist/src/codegen/generator/calls.d.ts +3 -1
  17. package/dist/src/codegen/generator/calls.js +3 -1
  18. package/dist/src/codegen/generator/calls.js.map +1 -1
  19. package/dist/src/codegen/generator/debug.js +20 -3
  20. package/dist/src/codegen/generator/debug.js.map +1 -1
  21. package/dist/src/codegen/generator/expressions/assignment.js +10 -2
  22. package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
  23. package/dist/src/codegen/generator/expressions/global-values.d.ts +19 -0
  24. package/dist/src/codegen/generator/expressions/global-values.js +49 -0
  25. package/dist/src/codegen/generator/expressions/global-values.js.map +1 -0
  26. package/dist/src/codegen/generator/expressions/primary.d.ts +0 -2
  27. package/dist/src/codegen/generator/expressions/primary.js +4 -24
  28. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  29. package/dist/src/codegen/generator/expressions.d.ts +2 -1
  30. package/dist/src/codegen/generator/expressions.js +2 -1
  31. package/dist/src/codegen/generator/expressions.js.map +1 -1
  32. package/dist/src/codegen/generator/layout.d.ts +65 -0
  33. package/dist/src/codegen/generator/layout.js +50 -0
  34. package/dist/src/codegen/generator/layout.js.map +1 -0
  35. package/dist/src/codegen/generator/state.js +4 -0
  36. package/dist/src/codegen/generator/state.js.map +1 -1
  37. package/dist/src/diagnostics/diagnostic.js +1 -1
  38. package/dist/src/diagnostics/diagnostic.js.map +1 -1
  39. package/dist/src/diagnostics/source-text.d.ts +37 -9
  40. package/dist/src/diagnostics/source-text.js +124 -23
  41. package/dist/src/diagnostics/source-text.js.map +1 -1
  42. package/dist/src/diagnostics/source.d.ts +16 -6
  43. package/dist/src/diagnostics/source.js +25 -4
  44. package/dist/src/diagnostics/source.js.map +1 -1
  45. package/dist/src/driver/build-key.d.ts +14 -0
  46. package/dist/src/driver/build-key.js +6 -1
  47. package/dist/src/driver/build-key.js.map +1 -1
  48. package/dist/src/driver/bundler/concatenate.js +11 -4
  49. package/dist/src/driver/bundler/concatenate.js.map +1 -1
  50. package/dist/src/driver/bundler/graph.js +2 -2
  51. package/dist/src/driver/bundler/graph.js.map +1 -1
  52. package/dist/src/driver/bundler/merge.js +11 -5
  53. package/dist/src/driver/bundler/merge.js.map +1 -1
  54. package/dist/src/driver/bundler/reexport-resolution.js +3 -0
  55. package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
  56. package/dist/src/driver/compiler.js +13 -3
  57. package/dist/src/driver/compiler.js.map +1 -1
  58. package/dist/src/driver/frontend.js +3 -4
  59. package/dist/src/driver/frontend.js.map +1 -1
  60. package/dist/src/driver/runtime-objects.d.ts +1 -1
  61. package/dist/src/driver/runtime-objects.js +4 -0
  62. package/dist/src/driver/runtime-objects.js.map +1 -1
  63. package/dist/src/driver/toolchain.js +28 -5
  64. package/dist/src/driver/toolchain.js.map +1 -1
  65. package/dist/src/driver/version.d.ts +1 -1
  66. package/dist/src/driver/version.js +1 -1
  67. package/dist/src/extensions/gui/html.js +42 -10
  68. package/dist/src/extensions/gui/html.js.map +1 -1
  69. package/dist/src/extensions/gui/index.js +53 -0
  70. package/dist/src/extensions/gui/index.js.map +1 -1
  71. package/dist/src/extensions/registry.d.ts +20 -0
  72. package/dist/src/extensions/registry.js.map +1 -1
  73. package/dist/src/parser/expressions.js +2 -2
  74. package/dist/src/parser/expressions.js.map +1 -1
  75. package/dist/src/parser/helpers.d.ts +8 -0
  76. package/dist/src/parser/helpers.js +21 -0
  77. package/dist/src/parser/helpers.js.map +1 -1
  78. package/dist/tests/binder/binder.test.js +26 -4
  79. package/dist/tests/binder/binder.test.js.map +1 -1
  80. package/dist/tests/checker/checker.test.js +16 -0
  81. package/dist/tests/checker/checker.test.js.map +1 -1
  82. package/dist/tests/cli/main.test.js +9 -0
  83. package/dist/tests/cli/main.test.js.map +1 -1
  84. package/dist/tests/codegen/element-layout.test.d.ts +19 -0
  85. package/dist/tests/codegen/element-layout.test.js +80 -0
  86. package/dist/tests/codegen/element-layout.test.js.map +1 -0
  87. package/dist/tests/codegen/expressions.test.js +25 -0
  88. package/dist/tests/codegen/expressions.test.js.map +1 -1
  89. package/dist/tests/codegen/llvm.test.js +13 -0
  90. package/dist/tests/codegen/llvm.test.js.map +1 -1
  91. package/dist/tests/diagnostics/diagnostic.test.js +9 -0
  92. package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
  93. package/dist/tests/diagnostics/source-text.test.d.ts +1 -0
  94. package/dist/tests/diagnostics/source-text.test.js +50 -0
  95. package/dist/tests/diagnostics/source-text.test.js.map +1 -0
  96. package/dist/tests/diagnostics/source.test.js +17 -0
  97. package/dist/tests/diagnostics/source.test.js.map +1 -1
  98. package/dist/tests/driver/build-key.test.d.ts +1 -0
  99. package/dist/tests/driver/build-key.test.js +49 -0
  100. package/dist/tests/driver/build-key.test.js.map +1 -0
  101. package/dist/tests/driver/toolchain.test.js +8 -1
  102. package/dist/tests/driver/toolchain.test.js.map +1 -1
  103. package/dist/tests/driver/usage.test.js +2 -1
  104. package/dist/tests/driver/usage.test.js.map +1 -1
  105. package/dist/tests/e2e/async-await.test.js +16 -0
  106. package/dist/tests/e2e/async-await.test.js.map +1 -1
  107. package/dist/tests/e2e/compile-builtins.test.js +29 -0
  108. package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
  109. package/dist/tests/e2e/compile-modules.test.js +13 -0
  110. package/dist/tests/e2e/compile-modules.test.js.map +1 -1
  111. package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
  112. package/dist/tests/e2e/compile-prototype-chain.test.d.ts +8 -0
  113. package/dist/tests/e2e/compile-prototype-chain.test.js +24 -0
  114. package/dist/tests/e2e/compile-prototype-chain.test.js.map +1 -0
  115. package/dist/tests/e2e/differential-language.test.js +25 -0
  116. package/dist/tests/e2e/differential-language.test.js.map +1 -1
  117. package/dist/tests/e2e/differential-values.test.js +59 -0
  118. package/dist/tests/e2e/differential-values.test.js.map +1 -1
  119. package/dist/tests/e2e/gc.test.js +22 -0
  120. package/dist/tests/e2e/gc.test.js.map +1 -1
  121. package/dist/tests/e2e/gui-audio-extra.test.d.ts +12 -0
  122. package/dist/tests/e2e/gui-audio-extra.test.js +185 -0
  123. package/dist/tests/e2e/gui-audio-extra.test.js.map +1 -0
  124. package/dist/tests/e2e/gui-browser.test.js +66 -2
  125. package/dist/tests/e2e/gui-browser.test.js.map +1 -1
  126. package/dist/tests/e2e/gui-dom.test.js +88 -0
  127. package/dist/tests/e2e/gui-dom.test.js.map +1 -1
  128. package/dist/tests/e2e/gui-events.test.js +89 -0
  129. package/dist/tests/e2e/gui-events.test.js.map +1 -1
  130. package/dist/tests/e2e/gui-webgl-declarations.test.d.ts +13 -0
  131. package/dist/tests/e2e/gui-webgl-declarations.test.js +136 -0
  132. package/dist/tests/e2e/gui-webgl-declarations.test.js.map +1 -0
  133. package/dist/tests/e2e/gui-webgl-texture-units.test.d.ts +12 -0
  134. package/dist/tests/e2e/gui-webgl-texture-units.test.js +86 -0
  135. package/dist/tests/e2e/gui-webgl-texture-units.test.js.map +1 -0
  136. package/dist/tests/e2e/gui-webgl2-anisotropy.test.d.ts +10 -0
  137. package/dist/tests/e2e/gui-webgl2-anisotropy.test.js +105 -0
  138. package/dist/tests/e2e/gui-webgl2-anisotropy.test.js.map +1 -0
  139. package/dist/tests/e2e/gui-webgl2-blit.test.js +6 -2
  140. package/dist/tests/e2e/gui-webgl2-blit.test.js.map +1 -1
  141. package/dist/tests/e2e/gui-webgl2-msaa-float.test.d.ts +12 -0
  142. package/dist/tests/e2e/gui-webgl2-msaa-float.test.js +157 -0
  143. package/dist/tests/e2e/gui-webgl2-msaa-float.test.js.map +1 -0
  144. package/dist/tests/e2e/gui-webgl2-msaa.test.d.ts +10 -0
  145. package/dist/tests/e2e/gui-webgl2-msaa.test.js +344 -0
  146. package/dist/tests/e2e/gui-webgl2-msaa.test.js.map +1 -0
  147. package/dist/tests/e2e/gui-webgl2-sampler-array.test.d.ts +11 -0
  148. package/dist/tests/e2e/gui-webgl2-sampler-array.test.js +117 -0
  149. package/dist/tests/e2e/gui-webgl2-sampler-array.test.js.map +1 -0
  150. package/dist/tests/e2e/gui-webgl2-target-orientation.test.d.ts +15 -0
  151. package/dist/tests/e2e/gui-webgl2-target-orientation.test.js +287 -0
  152. package/dist/tests/e2e/gui-webgl2-target-orientation.test.js.map +1 -0
  153. package/dist/tests/e2e/gui-webgl2.test.js +59 -1
  154. package/dist/tests/e2e/gui-webgl2.test.js.map +1 -1
  155. package/dist/tests/e2e/hang-watchdog.test.d.ts +10 -0
  156. package/dist/tests/e2e/hang-watchdog.test.js +50 -0
  157. package/dist/tests/e2e/hang-watchdog.test.js.map +1 -0
  158. package/dist/tests/e2e/method-call-cache.test.d.ts +5 -0
  159. package/dist/tests/e2e/method-call-cache.test.js +65 -0
  160. package/dist/tests/e2e/method-call-cache.test.js.map +1 -0
  161. package/dist/tests/e2e/performance-now.test.d.ts +9 -0
  162. package/dist/tests/e2e/performance-now.test.js +36 -0
  163. package/dist/tests/e2e/performance-now.test.js.map +1 -0
  164. package/dist/tests/e2e/property-ic.test.js +33 -0
  165. package/dist/tests/e2e/property-ic.test.js.map +1 -1
  166. package/dist/tests/e2e/shape-interning.test.d.ts +16 -0
  167. package/dist/tests/e2e/shape-interning.test.js +55 -0
  168. package/dist/tests/e2e/shape-interning.test.js.map +1 -0
  169. package/dist/tests/e2e/string-utf16.test.js +9 -0
  170. package/dist/tests/e2e/string-utf16.test.js.map +1 -1
  171. package/dist/tests/e2e/typed-array-views.test.js +26 -0
  172. package/dist/tests/e2e/typed-array-views.test.js.map +1 -1
  173. package/dist/tests/e2e/url-search-params.test.js +19 -0
  174. package/dist/tests/e2e/url-search-params.test.js.map +1 -1
  175. package/dist/tests/extensions/gui.test.js +16 -1
  176. package/dist/tests/extensions/gui.test.js.map +1 -1
  177. package/dist/tests/helpers.js +1 -0
  178. package/dist/tests/helpers.js.map +1 -1
  179. package/dist/tests/parser/expressions.test.js +36 -0
  180. package/dist/tests/parser/expressions.test.js.map +1 -1
  181. package/doc/ai/contributing.md +8 -5
  182. package/doc/ai/extensions.md +12 -3
  183. package/doc/ai/language-support.md +2 -1
  184. package/doc/ai/troubleshooting.md +14 -0
  185. package/doc/ai/zh-CN/contributing.md +6 -3
  186. package/doc/ai/zh-CN/extensions.md +10 -2
  187. package/doc/ai/zh-CN/language-support.md +2 -1
  188. package/doc/ai/zh-CN/troubleshooting.md +12 -0
  189. package/doc/gui/api.md +35 -4
  190. package/doc/gui/dom.md +8 -0
  191. package/doc/gui/input.md +8 -0
  192. package/doc/gui/known-issues.md +43 -6
  193. package/doc/gui/runtime.md +16 -1
  194. package/doc/gui/webgl.md +97 -26
  195. package/doc/gui-scripts.md +2 -1
  196. package/doc/gui.md +8 -5
  197. package/doc/implemented/binder.md +1 -1
  198. package/doc/implemented/checker.md +9 -0
  199. package/doc/implemented/codegen.md +7 -0
  200. package/doc/implemented/parser.md +2 -1
  201. package/doc/implemented/runtime-core.md +9 -2
  202. package/doc/implemented/stdlib.md +10 -2
  203. package/doc/implemented/typed-arrays.md +18 -2
  204. package/doc/zh-CN/gui/api.md +27 -5
  205. package/doc/zh-CN/gui/dom.md +6 -0
  206. package/doc/zh-CN/gui/input.md +7 -0
  207. package/doc/zh-CN/gui/known-issues.md +30 -5
  208. package/doc/zh-CN/gui/runtime.md +13 -1
  209. package/doc/zh-CN/gui/webgl.md +20 -7
  210. package/doc/zh-CN/gui-scripts.md +2 -1
  211. package/doc/zh-CN/gui.md +4 -1
  212. package/doc/zh-CN/implemented/binder.md +1 -1
  213. package/doc/zh-CN/implemented/checker.md +7 -0
  214. package/doc/zh-CN/implemented/codegen.md +7 -0
  215. package/doc/zh-CN/implemented/parser.md +2 -1
  216. package/doc/zh-CN/implemented/runtime-core.md +9 -2
  217. package/doc/zh-CN/implemented/stdlib.md +6 -2
  218. package/doc/zh-CN/implemented/typed-arrays.md +14 -2
  219. package/package.json +7 -7
  220. package/runtime/ext_gui/audio.cpp +39 -3
  221. package/runtime/ext_gui/audio_extra.cpp +353 -0
  222. package/runtime/ext_gui/audio_extra.h +47 -0
  223. package/runtime/ext_gui/audio_fft.h +76 -0
  224. package/runtime/ext_gui/audio_internal.h +21 -0
  225. package/runtime/ext_gui/audio_mixer.cpp +46 -1
  226. package/runtime/ext_gui/audio_mixer.h +89 -1
  227. package/runtime/ext_gui/audio_mixer_extra.cpp +126 -0
  228. package/runtime/ext_gui/audio_nodes.cpp +242 -0
  229. package/runtime/ext_gui/audio_nodes_internal.h +81 -0
  230. package/runtime/ext_gui/audio_nodes_spatial.cpp +375 -0
  231. package/runtime/ext_gui/browser.cpp +11 -0
  232. package/runtime/ext_gui/browser_screen.cpp +73 -0
  233. package/runtime/ext_gui/dom_api.cpp +4 -0
  234. package/runtime/ext_gui/dom_api_canvas.cpp +9 -1
  235. package/runtime/ext_gui/dom_api_events.cpp +2 -1
  236. package/runtime/ext_gui/dom_api_internal.h +11 -0
  237. package/runtime/ext_gui/dom_api_mutation.cpp +49 -0
  238. package/runtime/ext_gui/dom_api_node.cpp +21 -0
  239. package/runtime/ext_gui/dom_api_node_read.cpp +29 -0
  240. package/runtime/ext_gui/dom_api_proto.cpp +6 -0
  241. package/runtime/ext_gui/dom_api_webgl2.cpp +16 -11
  242. package/runtime/ext_gui/dom_api_webgl2_msaa.cpp +64 -0
  243. package/runtime/ext_gui/dom_api_webgl_compressed.cpp +2 -2
  244. package/runtime/ext_gui/dom_api_webgl_framebuffer.cpp +68 -11
  245. package/runtime/ext_gui/dom_api_webgl_methods.h +3 -0
  246. package/runtime/ext_gui/dom_api_webgl_state.cpp +11 -2
  247. package/runtime/ext_gui/dom_api_webgl_texture.cpp +6 -6
  248. package/runtime/ext_gui/gui.cpp +8 -1
  249. package/runtime/ext_gui/gui_engine.h +20 -2
  250. package/runtime/ext_gui/gui_events.cpp +31 -126
  251. package/runtime/ext_gui/gui_input.cpp +148 -0
  252. package/runtime/ext_gui/gui_webgl.cpp +3 -2
  253. package/runtime/ext_gui/pointer_lock.cpp +137 -0
  254. package/runtime/ext_gui/style_ua.cpp +4 -0
  255. package/runtime/ext_gui/warnings.cpp +1 -1
  256. package/runtime/ext_gui/webgl.h +102 -7
  257. package/runtime/ext_gui/webgl_api.h +3 -2
  258. package/runtime/ext_gui/webgl_blit.cpp +109 -15
  259. package/runtime/ext_gui/webgl_blit_color.cpp +264 -0
  260. package/runtime/ext_gui/webgl_blit_depth.cpp +26 -8
  261. package/runtime/ext_gui/webgl_buffer.cpp +26 -170
  262. package/runtime/ext_gui/webgl_context.cpp +119 -169
  263. package/runtime/ext_gui/webgl_draw.cpp +116 -5
  264. package/runtime/ext_gui/webgl_draw_buffers.cpp +21 -6
  265. package/runtime/ext_gui/webgl_draw_setup.cpp +1 -0
  266. package/runtime/ext_gui/webgl_draw_state.h +2 -0
  267. package/runtime/ext_gui/webgl_feature.cpp +2 -2
  268. package/runtime/ext_gui/webgl_feature.h +4 -3
  269. package/runtime/ext_gui/webgl_framebuffer.cpp +346 -0
  270. package/runtime/ext_gui/webgl_glsl.h +4 -0
  271. package/runtime/ext_gui/webgl_glsl_rewrite.cpp +78 -47
  272. package/runtime/ext_gui/webgl_glsl_scan.cpp +14 -0
  273. package/runtime/ext_gui/webgl_objects.h +18 -2
  274. package/runtime/ext_gui/webgl_pipeline.cpp +1 -1
  275. package/runtime/ext_gui/webgl_shader.cpp +1 -1
  276. package/runtime/ext_gui/webgl_state.cpp +45 -36
  277. package/runtime/ext_gui/webgl_targets.cpp +440 -0
  278. package/runtime/ext_gui/webgl_texture.cpp +81 -25
  279. package/runtime/ext_gui/window.cpp +11 -83
  280. package/runtime/ext_gui/window_diagnostics.cpp +94 -1
  281. package/runtime/rt.h +27 -27
  282. package/runtime/rt_binary.h +44 -0
  283. package/runtime/rt_internal.h +52 -60
  284. package/runtime/rt_object.h +83 -0
  285. package/runtime/rt_profile.h +45 -0
  286. package/runtime/xt_alloc.c +88 -133
  287. package/runtime/xt_array_buffer.c +99 -71
  288. package/runtime/xt_builtins.c +3 -1
  289. package/runtime/xt_constructors.c +1 -0
  290. package/runtime/xt_containers/access.inc +96 -11
  291. package/runtime/xt_containers/arrays.inc +2 -1
  292. package/runtime/xt_containers/cstr_cache.inc +56 -0
  293. package/runtime/xt_containers/method_cache.inc +121 -0
  294. package/runtime/xt_containers/object_keys.inc +58 -0
  295. package/runtime/xt_containers/objects.inc +47 -79
  296. package/runtime/xt_containers/shapes.inc +153 -8
  297. package/runtime/xt_containers.c +4 -0
  298. package/runtime/xt_gc_release.c +70 -0
  299. package/runtime/xt_gc_stack.c +83 -0
  300. package/runtime/xt_gc_verify.c +1 -0
  301. package/runtime/xt_io/console.inc +66 -0
  302. package/runtime/xt_io/exception.inc +32 -6
  303. package/runtime/xt_io/watchdog.inc +101 -0
  304. package/runtime/xt_io.c +1 -0
  305. package/runtime/xt_loop.c +23 -3
  306. package/runtime/xt_pool.c +151 -0
  307. package/runtime/xt_profile.c +126 -0
  308. package/runtime/xt_stdlib/dispatch.inc +7 -1
  309. package/runtime/xt_stdlib/math.inc +272 -57
  310. package/runtime/xt_stdlib2/json_stringify.inc +1 -2
  311. package/runtime/xt_stdlib2/regexp-match.inc +17 -0
  312. package/runtime/xt_storage/indexed_db.c +4 -1
  313. package/runtime/xt_structured_clone.c +2 -1
  314. package/runtime/xt_typed_array/construction.inc +10 -0
  315. package/runtime/xt_typed_array/elements.inc +43 -23
  316. package/runtime/xt_url.c +50 -0
  317. package/runtime/xt_values/constructors.inc +4 -1
  318. package/runtime/xt_values/strings.inc +3 -1
  319. package/src/ast/common.ts +10 -0
  320. package/src/binder/references.ts +13 -7
  321. package/src/checker/source.ts +3 -0
  322. package/src/cli/main.ts +14 -3
  323. package/src/codegen/generator/calls/access.ts +5 -10
  324. package/src/codegen/generator/calls/element-inline.ts +433 -0
  325. package/src/codegen/generator/calls/invocation.ts +87 -1
  326. package/src/codegen/generator/calls.ts +5 -0
  327. package/src/codegen/generator/debug.ts +21 -3
  328. package/src/codegen/generator/expressions/assignment.ts +11 -2
  329. package/src/codegen/generator/expressions/global-values.ts +57 -0
  330. package/src/codegen/generator/expressions/primary.ts +4 -27
  331. package/src/codegen/generator/expressions.ts +3 -0
  332. package/src/codegen/generator/layout.ts +54 -0
  333. package/src/codegen/generator/state.ts +5 -0
  334. package/src/diagnostics/diagnostic.ts +1 -1
  335. package/src/diagnostics/source-text.ts +118 -22
  336. package/src/diagnostics/source.ts +29 -7
  337. package/src/driver/build-key.ts +21 -1
  338. package/src/driver/bundler/concatenate.ts +12 -5
  339. package/src/driver/bundler/graph.ts +2 -2
  340. package/src/driver/bundler/merge.ts +11 -4
  341. package/src/driver/bundler/reexport-resolution.ts +2 -0
  342. package/src/driver/compiler.ts +14 -3
  343. package/src/driver/frontend.ts +3 -4
  344. package/src/driver/runtime-objects.ts +4 -0
  345. package/src/driver/toolchain.ts +28 -5
  346. package/src/driver/version.ts +1 -1
  347. package/src/extensions/gui/html.ts +41 -11
  348. package/src/extensions/gui/index.ts +55 -1
  349. package/src/extensions/registry.ts +20 -0
  350. package/src/parser/expressions.ts +2 -2
  351. package/src/parser/helpers.ts +22 -0
package/doc/gui/api.md CHANGED
@@ -49,6 +49,13 @@ and hit testing follow it), and `scrollX` / `scrollY` / `pageXOffset` /
49
49
  `compositionstart` / `compositionupdate` / `compositionend`, `beforeinput`,
50
50
  `input`, `change`, `submit` and `reset`.
51
51
 
52
+ Pointer Lock is implemented through SDL's relative mouse mode:
53
+ `element.requestPointerLock()` returns a promise that resolves once the lock is
54
+ active (and `pointerlockchange` has fired), `document.pointerLockElement` is the
55
+ locked element, `document.exitPointerLock()` releases it, and a request the host
56
+ cannot honour rejects and fires `pointerlockerror`. `Escape` and losing window
57
+ focus release the lock.
58
+
52
59
  Exceptions thrown by code the engine invokes (an element or window listener, a
53
60
  timer, an animation frame, a media event) are page errors, not process
54
61
  termination: the engine catches them at its callback boundary and mirrors the
@@ -105,16 +112,19 @@ requestAnimationFrame(frame);
105
112
  | --- | --- |
106
113
  | `window`, `self` | the most recently opened window handle (one is opened implicitly if the program has not created one yet), so `window.innerWidth`, `window.addEventListener`, `window.setTimeout`, `window.localStorage`, `window.location`, `window.devicePixelRatio` and `window.matchMedia` all work |
107
114
  | `document` | that window's document handle |
115
+ | bare window members | a browser's global scope *is* the window, so `innerWidth`, `innerHeight`, `outerWidth`, `outerHeight`, `devicePixelRatio`, `location`, `screen`, `scrollX`/`scrollY`, `addEventListener`/`removeEventListener`/`dispatchEvent`, `setTimeout`/`clearTimeout`/`setInterval`/`clearInterval`, `queueMicrotask`, `focus`/`blur`, `scrollTo`/`scrollBy` resolve without the `window.` prefix. Each is a live member read of the window (`xt_get(window, name)`; a call goes through `xt_call_method`), so `innerWidth` tracks resizes and `location.href` stays the real object. `screen` describes the display (`width`/`height`/`availWidth`/`availHeight`/`colorDepth`/`pixelDepth`/`orientation`), not the window |
108
116
  | `navigator` | `userAgent` (a desktop Chrome string ending in `xbintsc`), `platform`, `vendor`, `language(s)`, `hardwareConcurrency`, `maxTouchPoints`, `onLine`, `vibrate()` |
109
117
  | `localStorage` | an in-memory `getItem` / `setItem` / `removeItem` / `clear` / `key` / `length` store |
110
118
  | `AudioContext`, `webkitAudioContext` | a Web Audio graph with a real mixer and decoder (see below) |
111
119
  | `fetch(input, init)` | the core runtime's HTTP/1.1 client, available to GUI programs too: `http://` and `https://` (the latter links the optional `tls` feature), plus local `file://` and relative paths; responses are buffered. See [Implemented fetch](../implemented/fetch.md). |
112
120
  | `Event`, `CustomEvent`, `ProgressEvent`, `MouseEvent`, `KeyboardEvent`, `PointerEvent`, `WheelEvent`, `FocusEvent`, `InputEvent`, `SubmitEvent` | event constructors; the `init` argument is kept as given (`detail`, `composed`, mouse/keyboard fields, …) |
113
121
  | `AbortController`, `AbortSignal` | a real controller/signal pair for `{ signal }` listener removal, with `abort()`, `aborted`, `reason`, `onabort` and `throwIfAborted()` |
122
+ | `MutationObserver` | a real constructor whose observers are **inert**: `observe(target, options)`, `disconnect()` and `takeRecords()` (always `[]`) exist, but no record is ever queued and the callback never fires. Bundlers install one unconditionally — Vite's `modulepreload` polyfill calls `new MutationObserver(…).observe(document, …)` before the page runs — so the name and the methods have to exist or the whole script aborts with a `TypeError` (see [Known issues](./known-issues.md)) |
114
123
  | `HTMLCanvasElement`, `HTMLImageElement`, `WebGLRenderingContext`, `WebGL2RenderingContext`, `WebGLBuffer`/`WebGLTexture`/`WebGLShader`/`WebGLProgram`/`WebGLFramebuffer`/`WebGLRenderbuffer`/`WebGLUniformLocation`/`WebGLActiveInfo`/`WebGLVertexArrayObject`/`WebGLSampler`/`WebGLQuery`/`WebGLSync`/`WebGLTransformFeedback` | real constructor values. `canvas.getContext("webgl")` and `getContext("webgl2")` return GPU contexts (see [WebGL](./webgl.md)). |
115
124
  | `ImageBitmap`, `createImageBitmap(source)` | immutable bitmaps backed by decoded pixels (`<img>`, `<canvas>`, `<video>` frames, `OffscreenCanvas` and `ImageData` shapes); the promise resolves immediately and `texImage2D` accepts the result |
116
125
  | `OffscreenCanvas` | a real 2D offscreen bitmap with `getContext("2d")`, `width`/`height`, `transferToImageBitmap()` and `convertToBlob()`; `canvas.transferControlToOffscreen()` hands an element's bitmap over (see [Canvas](./canvas.md)). There is no offscreen WebGL context. |
117
126
  | `ImageData`, `XRWebGL*`, `Request`, `Headers`, `Response`, `DOMParser` | `typeof` probes answer `"undefined"` (no XR, DOM parser or streaming backend), which lets a page take its "unsupported" branch instead of calling a no-op stub. `fetch` still works and resolves with a response-shaped object, but there is no `Response` constructor and `response.arrayBuffer()` currently returns a byte array rather than an `ArrayBuffer`; `ReadableStream` and the other Web Streams classes come from the core runtime. Three.js pages use its real renderer on this backend (see [Known issues](./known-issues.md)). |
127
+ | `VideoFrame`, `OfflineAudioContext`, `Float16Array` | what a media/three.js feature probe expects. `VideoFrame` is a real constructor value, so `frame instanceof VideoFrame` is a safe `false` instead of a `TypeError`; `OfflineAudioContext` constructs an object but has no offline renderer behind it (a page that renders audio offline still needs `AudioContext`); `Float16Array` is `undefined`, so `typeof Float16Array < "u"` takes the fallback path (there is no 16-bit float element type). |
118
128
  | `requestAnimationFrame` / `cancelAnimationFrame` | queued on the window's frame list; see [Runtime integration](./runtime.md) |
119
129
  | `alert` / `confirm` / `prompt`, `matchMedia`, `getComputedStyle`, `escape` | host implementations. `matchMedia` returns a **live** list (cached per query): `matches` is re-evaluated on resize and `change` listeners fire when it flips. `confirm`/`prompt` use a native dialog only with `XT_GUI_DIALOGS=1`; otherwise they report the message on stderr and return the documented default (Annex B `escape` encodes per UTF-16 code unit, matching `decodeURIComponent(escape(bytes))`) |
120
130
 
@@ -136,12 +146,32 @@ Implemented nodes: `createGain`, `createOscillator` (sine, square, sawtooth,
136
146
  triangle), `createBufferSource` (buffer, loop, loopStart/loopEnd,
137
147
  playbackRate/detune), `createBiquadFilter` (lowpass, highpass, bandpass,
138
148
  lowshelf, highshelf, peaking, notch, allpass), `createDynamicsCompressor`,
139
- `createStereoPanner`, `createConstantSource` and `createDelay(maxDelayTime)`.
149
+ `createStereoPanner`, `createConstantSource`, `createDelay(maxDelayTime)`,
150
+ `createWaveShaper` (`curve`, `oversample`), `createConvolver` (`buffer`,
151
+ `normalize`), `createAnalyser` (`fftSize`, `frequencyBinCount`,
152
+ `smoothingTimeConstant`, `minDecibels`/`maxDecibels` and the four
153
+ `get…Data` methods), `createPanner` (`positionX/Y/Z` and `orientationX/Y/Z` as
154
+ AudioParams, the distance/cone properties, `setPosition`/`setOrientation`),
155
+ `createMediaElementSource` and `createMediaStreamSource`, plus
156
+ `context.listener` with its nine AudioParams.
140
157
  `connect` returns the destination so chains chain (`src.connect(gain).connect(ctx.destination)`),
141
158
  `disconnect()` / `disconnect(target)` update the native graph, and `start(when, offset, duration)` /
142
159
  `stop(when)` are honoured on the graph's clock. Nodes outside this list
143
- (`createAnalyser`, `createConvolver`, `createWaveShaper`, `createChannelSplitter`,
144
- `createPeriodicWave`, …) are not provided, so their methods are simply absent.
160
+ (`createChannelSplitter`, `createChannelMerger`, `createPeriodicWave`,
161
+ `createIIRFilter`, `createScriptProcessor`, …) are not provided, so their
162
+ methods are simply absent.
163
+
164
+ The convolver is a **partitioned FFT** convolution (128-frame partitions, 256-point
165
+ transforms) so a reverb impulse response of a second or two stays affordable;
166
+ `normalize` (the default) scales the response so a white-noise input keeps its
167
+ level. A 1.4 s response costs about 10 % of realtime, a 2.2 s one about 18 %.
168
+ The analyser applies the spec's Blackman window and decibel mapping, and keeps
169
+ `smoothingTimeConstant` as a moving average across calls. The panner uses
170
+ equal-power panning against `context.listener` plus the linear/inverse/exponential
171
+ distance models and the cone attenuation; `panningModel = "HRTF"` is accepted but
172
+ runs the same equal-power path (no HRIR data set is shipped). The two media
173
+ sources are valid nodes with no signal — the engine has no media-capture or
174
+ element-audio pipeline, so they are silent rather than absent.
145
175
 
146
176
  Every `AudioParam` has a live `value` plus `setValueAtTime` /
147
177
  `linearRampToValueAtTime` / `exponentialRampToValueAtTime` / `setTargetAtTime` /
@@ -194,6 +224,7 @@ bubbles from the focused element or `<body>`, before the window listeners run.
194
224
  | Field | Events | Meaning |
195
225
  | --- | --- | --- |
196
226
  | `x`, `y` / `clientX`, `clientY` | pointer, wheel | viewport-relative logical pixels |
227
+ | `movementX`, `movementY` | pointer | raw motion since the previous event (pointer-lock aiming); `0` on button events |
197
228
  | `button` | pointer | `0` left, `1` middle, `2` right (`-1` for move) |
198
229
  | `clicks` | pointer | click count reported by the OS |
199
230
  | `deltaX`, `deltaY` | wheel | scroll amount (`deltaY` positive = down) |
@@ -276,4 +307,4 @@ afterwards for debugging.
276
307
  Multiple windows fall out of the object model: `createWindow` returns a native
277
308
  object handle; each handle owns its own `SDL_Window`/GPU surface and its own DOM
278
309
  tree. `run()` drives one shared main loop that ticks every window and exits when
279
- the last one closes.
310
+ the last one closes.
package/doc/gui/dom.md CHANGED
@@ -175,8 +175,16 @@ inner.addEventListener("click", (e) => console.log(e.target.id, e.currentTarget.
175
175
  inner.click(); // synthesise a click at the element
176
176
  console.log(box.offsetWidth, box.offsetHeight); // rounded border box
177
177
  console.log(box.contains(inner)); // descendant test
178
+ console.log(inner.closest("button, .card") != null); // nearest self/ancestor match
178
179
  ```
179
180
 
181
+ `element.hidden` is a reflected boolean attribute: assigning `true` sets the
182
+ `hidden` attribute (so `hidden === true` and `getAttribute("hidden") === ""`),
183
+ assigning anything falsy removes it. The UA stylesheet treats `[hidden]` as
184
+ `display: none`, exactly like a browser — an author rule that sets `display`
185
+ still wins, which is why pages usually pair `hidden` with a class that animates
186
+ `opacity` out first.
187
+
180
188
  ### Style properties, dataset, computed style and geometry
181
189
 
182
190
  The inline `style` object is a CSSOM declaration block. Named access reads and
package/doc/gui/input.md CHANGED
@@ -14,6 +14,14 @@ follows the artwork, not the box flow left behind.
14
14
  - SDL pointer/wheel/key events are routed to the owning window, hit tested, and
15
15
  delivered to the handlers registered with `on`. `mousedown` also moves focus
16
16
  and places the caret in a text field.
17
+ - Pointer Lock is the browser API: `element.requestPointerLock()` (a promise),
18
+ `document.pointerLockElement`, `document.exitPointerLock()` and the
19
+ `pointerlockchange` / `pointerlockerror` events on `document` and `window`.
20
+ While locked, SDL runs in relative mouse mode (the cursor is hidden and
21
+ captured): `mousemove` targets the locked element, skips hit testing and
22
+ `:hover`, and carries the raw delta in `movementX`/`movementY`, so a
23
+ first-person game aims from `e.movementX` instead of the cursor position.
24
+ `Escape` and losing window focus release the lock, as in a browser.
17
25
  - Keyboard events also follow the DOM path: the target is the focused element (or
18
26
  `<body>` when nothing is focused), the event bubbles through its ancestors to
19
27
  `document`, and finally reaches `window` listeners. This is what lets a page
@@ -5,6 +5,27 @@
5
5
 
6
6
  ## Known issues
7
7
 
8
+ - **`MutationObserver` exists but is inert.** The constructor and `observe` /
9
+ `disconnect` / `takeRecords` are real, yet the engine queues no mutation
10
+ records and never calls the callback, so code that *waits* for records
11
+ (lazy hydration keyed on inserted nodes, `innerHTML` post-processing, …) gets
12
+ nothing. The shape still matters: bundlers install an observer
13
+ unconditionally — Vite's `modulepreload` polyfill runs
14
+ `new MutationObserver(…).observe(document, …)` as the page starts — and a
15
+ `TypeError` there aborts the whole script, which is why the name must resolve.
16
+ - **Web Audio has no `MediaStream`/capture pipeline, and two node behaviours are
17
+ approximations.** `createMediaElementSource` and `createMediaStreamSource`
18
+ return valid, *silent* nodes: the engine has no microphone/camera capture and
19
+ does not route a media element's own playback through the graph, so a page
20
+ that feeds either into a graph gets silence instead of an error.
21
+ `WaveShaperNode.oversample` averages the curve at 2 or 4 sub-sample points
22
+ rather than band-limiting the input, which softens but does not remove the
23
+ aliasing a hard curve introduces. `PannerNode.panningModel = "HRTF"` is
24
+ accepted but uses the equal-power path — no HRIR data set is shipped, so the
25
+ result is a stereo pan with distance/cone attenuation, not a binaural filter.
26
+ `ConvolverNode` normalizes by energy (the response is scaled so a white-noise
27
+ input keeps its level); it is close to, but not bit-identical with, the
28
+ browser's normalization.
8
29
  - **WebGL 1.0 and 2.0 run on the GPU, with a subset of each.**
9
30
  `canvas.getContext("webgl")` / `"webgl2"` return real GPU contexts (see
10
31
  [WebGL](./webgl.md)): GLSL ES shaders are translated to SPIR-V by the bundled
@@ -13,15 +34,31 @@
13
34
  colour texture that the page composites without a readback. WebGL 2 adds VAOs,
14
35
  instancing, integer attributes, sampler objects, `texStorage2D`, buffer copies,
15
36
  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
37
+ multiple render targets, scissored clears and 4× multisample antialiasing on
38
+ Vulkan. `blitFramebuffer` copies colour and depth and resolves a multisampled
39
+ colour source; transform feedback and stencil or multisampled-depth blits are
40
+ not implemented (SDL_GPU has no transform-feedback stage, cannot resolve
41
+ depth, and cannot sample a stencil attachment). On an SDL_GPU backend that
42
+ accepts neither SPIR-V nor MSL (Direct3D 12, which would need DXIL) both
21
43
  context kinds are `null`. The `.js` asset loader now patches only three.js's
22
44
  shader unroller; `WebGLRenderer` runs on the real backend and there is no
23
45
  Canvas2D fallback. Shadow maps (comparative `sampler2DShadow` targeting depth
24
46
  textures), cube textures/environment maps and HDR render targets are supported.
47
+ - **MSAA is enabled on Vulkan and Metal, and it changes what may be blitted
48
+ where.** The `antialias` attribute defaults to true; a supported context gets
49
+ a 4× drawing buffer that resolves into the composited colour texture at the
50
+ end of every render pass, so `getParameter(SAMPLES)` is 4 and a partially
51
+ covered edge pixel is a blend. A device without 4× colour and depth support
52
+ keeps the single-sampled path (`antialias` false, `MAX_SAMPLES` 0, and
53
+ multisample storage requests degrade to single-sampled renderbuffers/textures
54
+ with `SAMPLES` 0). As in a browser,
55
+ `blitFramebuffer` into the antialiased
56
+ default framebuffer is `INVALID_OPERATION`: request
57
+ `getContext("webgl2", { antialias: false })` when the page resolves its own
58
+ offscreen target to the canvas. A multisampled colour source resolves only
59
+ with identical source/destination rectangles, an identical format and
60
+ `NEAREST`; multisampled depth attachments render (depth testing works per
61
+ sample) but cannot be resolved through SDL_GPU.
25
62
  - **Comparative samplers can miscompile on Intel Macs.** On an Intel GPU (seen
26
63
  on Intel Iris Plus Graphics with macOS 26), the Metal shader compiler drops a
27
64
  fragment function that calls `sample_compare`: the draw produces no pixels at
@@ -199,4 +236,4 @@
199
236
  unusable on **SDL 3.2.10**: its D3D12 backend rejects any graphics pipeline
200
237
  whose shaders declare a uniform buffer, and the engine passes the viewport that
201
238
  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.
239
+ 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** ✅
@@ -8,7 +8,7 @@ Location: `src/binder/binder.ts`
8
8
  - Symbol kinds: `var` / `let` / `const` / `function` / `parameter` / `class` / `interface` / `type` / `enum` / `import` / `namespace`
9
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
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
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
+ - A `switch` body is a block scope of its own (a child of the enclosing one) shared by every `case` / `default` clause: their declarations are pre-declared before any clause is bound, so a clause-level `let` / `const` shadows an outer binding instead of colliding with it (`function f(t) { switch (…) { case 1: let t = 0 } }` is legal)
12
12
  - A `static { ... }` class block is bound as a hidden static function of the class (see [Classes](../unimplemented/classes.md))
13
13
  - Identifier → declaration resolution; unresolved identifier collection (`CannotFindName`)
14
14
  - Closure capture analysis: outer variables referenced by an inner function are marked `captured` / `boxed`, and capture indices are threaded through intermediate closures
@@ -105,6 +105,15 @@ other control flow does not.
105
105
  - Bundled sources under `node_modules` are not checked at all: the checker is a
106
106
  gate for the code you wrote, and failing on a dependency's internals would
107
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.
108
117
 
109
118
  ## Behaviour without the checker
110
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
+
@@ -9,7 +9,7 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
9
9
  ## Statements
10
10
 
11
11
  - Variable declarations: `var` / `let` / `const`, with multiple declarators `const a = 1, b = 2;`
12
- - Function declarations, function expressions and methods, including the `async` modifier, generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`) and async generators (`async function*`, `for await...of`)
12
+ - Function declarations, function expressions and methods, including the `async` modifier, generators (`function*`, `yield`, `yield*`, `.next`/`.throw`/`.return`) and async generators (`async function*`, `for await...of`). A `yield` with no operand is an expression too: `yield` followed by `,`, a closing bracket/brace/paren, `;` or a line break yields `undefined`, which is how a minified generator is written (`yield, doThing(), yield`)
13
13
  - `class` declarations / class expressions (constructor, fields, methods, `static`, `static { ... }` blocks, `extends`)
14
14
  - `if` / `else`
15
15
  - `while`, `do...while`
@@ -57,3 +57,4 @@ Module syntax (`import` / `export`, import attributes) and the driver-level bund
57
57
  ## ASI
58
58
 
59
59
  - Automatic Semicolon Insertion, based on `precededByLineBreak` / `}` / EOF.
60
+
@@ -16,10 +16,15 @@ standard-library surface have their own pages:
16
16
  - [Async, promises and generators](./async.md)
17
17
  - [fetch](./fetch.md)
18
18
 
19
- - Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan). Collection is deferred while a bundle's module bodies run (`xt_gc_begin_startup` raises the threshold to 512 MiB until `xt_gc_end_startup`): a large module graph is built entirely inside one generated function, and collecting in the middle of it has corrupted live objects. `XT_GC_THRESHOLD` still overrides both values. Two environment switches exist for this class of bug: `XT_GC_VERIFY=1` re-scans
19
+ - Allocator: non-moving mark-sweep collector behind `xt_alloc` (explicit roots, subsystem root providers and a conservative C-stack scan). Collection is deferred while a bundle's module bodies run (`xt_gc_begin_startup` raises the threshold to 512 MiB until `xt_gc_end_startup`): a large module graph is built entirely inside one generated function, and collecting in the middle of it has corrupted live objects. `XT_GC_THRESHOLD` still overrides both values. The next threshold is **4×** the surviving heap: an interactive scene keeps a large live set for minutes, and at 2× a three.js page collected once every ~1.2 s; 4× halves the number of stop-the-world pauses while the threshold still follows (and shrinks with) the live set, so it cannot ratchet upwards. `XT_GC_TRACE=1` prints each collection's heap, allocation and live-kind counts plus its `took <ms>` broken into table/mark/sweep phases. Two environment switches exist for this class of bug: `XT_GC_VERIFY=1` re-scans
20
20
  every marked object's payload before the sweep and prints any block it
21
21
  references that stayed unmarked (a tracer or root gap), and the crash report
22
22
  names a fault address that falls inside a block the collector freed. I/O worker threads allocate result values but never collect (`xt_gc_worker_thread`): the collector scans the main stack region and is not thread-safe, and a block born during a collection is marked so the sweep keeps it.
23
+ - Small-block allocation: blocks up to 2 KiB (most objects, closures, strings, and the property/array buffers behind them) come from per-size-class free lists carved out of 1 MiB slabs instead of `malloc`/`calloc`; the collector returns a block to its class, so a steady state reuses memory and object-heavy scene code stops paying a C allocator round trip per object. Large blocks keep `malloc`/`free`, I/O workers keep `calloc` (the pool is main-thread only), and a pooled block is marked by `XT_GC_POOLED` so the sweep releases it correctly.
24
+ - Tracing is **precise** for the kinds a program allocates in bulk: an `xt_object` marks its prototype, error stack and each property's key/value/getter/setter, an array its items and `extra`, a function its name bag, prototype and environment, and maps/sets/regexps their element arrays. Only the exotic kinds (iterators, symbols) still use the conservative payload scan. `xt_gc_mark_value` rejects every number with one tag compare, so marking a 400k-object scene does not spend its time in five `XT_IS_*` branches per property slot.
25
+ - The C-string property lookups behind the host bindings (`xt_object_get_cstr(w, "__xt_gl_context")`, the typed-array helpers, the runtime's own helpers) intern the key contents in a small, GC-rooted table instead of allocating an `xt_string` per call. This was the dominant allocation source for a WebGL page: the Saltline boot made ~24M such calls, and after the table the same run makes ~165k calls and allocates ~192k strings in total, roughly two orders of magnitude less garbage for the collector to sweep.
26
+ - Time: `performance.now()` returns milliseconds since the **program's** time origin, like a browser's navigation start or Node's process start, not the raw monotonic counter (on Windows the QPC counts from machine boot, so a process started six days into an uptime used to report six days on its first call). `xt_time_init()` snapshots the origin from the generated `main`, and animation-frame callbacks receive the same clock.
27
+ - Profiling: `XT_PROFILE=1` counts entries to the hottest runtime helpers (allocation, collection, property get/set, method dispatch, closure calls, array element reads, typed-array reads/writes, `Math` dispatch) and prints them to stderr at exit. It also breaks allocations down by object kind and lists the twenty most frequent C-string property names, which attributes allocation pressure to a helper or a key without a sampling profiler. The counters cost one branch when enabled and nothing when unset; pair them with a microbenchmark of the same helper to attribute time.
23
28
  - Value construction: `xt_undefined/xt_null/xt_bool/xt_number/xt_string_new/xt_string_from_cstr`.
24
29
  - Type conversion: `xt_truthy`, `xt_to_number`, `xt_to_string`, `xt_typeof`.
25
30
  - Arithmetic: `add/sub/mul/div/mod/pow/neg/pos`.
@@ -31,6 +36,8 @@ names a fault address that falls inside a block the collector freed. I/O worker
31
36
  - Operator helpers: `xt_in` (`in`), `xt_delete` (`delete`), `xt_rest_args` (rest parameters / `arguments`).
32
37
  - Box: `box_new/get/set` (for closure-captured variables).
33
38
  - Functions and closures: `arg`, `closure_new/call/env/arity`.
34
- - Exceptions: `xt_try_enter` / `xt_try_exception` / `xt_try_leave` maintain the `_setjmp` frame stack; `xt_throw` long-jumps to the nearest `try` when a frame exists, otherwise prints `Uncaught ...` and exits. A promise rejection nobody observes is fatal too: `xt_promise_report_unhandled` runs once the event loop drains, prints `Unhandled promise rejection` plus the reason and exits with status 1 (see [Async](./async.md)). Codegen also maintains a shadow call stack (function name, source file and line) that `Error.stack` captures (see [Standard library](./stdlib.md)), and a fatal-signal handler dumps the same frames on a native crash. While a bundle's module bodies run, the stack names the module being initialised (` module: <path>` above the frames): every module shares one generated function, so its frames alone all carry the entry file's coordinates. `--debug` additionally emits `!DICompileUnit` / `!DISubprogram` / `!DILocation` metadata and compiles with `-g -fno-omit-frame-pointer`, so gdb/lldb/WinDbg map instructions back to source lines.
39
+ - Exceptions: `xt_try_enter` / `xt_try_exception` / `xt_try_leave` maintain the `_setjmp` frame stack; `xt_throw` long-jumps to the nearest `try` when a frame exists, otherwise prints `Uncaught ...` and exits. A promise rejection nobody observes is fatal too: `xt_promise_report_unhandled` runs once the event loop drains, prints `Unhandled promise rejection` plus the reason and exits with status 1 (see [Async](./async.md)). Codegen also maintains a shadow call stack (function name, source file and line) that `Error.stack` captures (see [Standard library](./stdlib.md)), and a fatal-signal handler dumps the same frames on a native crash. While a bundle's module bodies run, the stack names the module being initialised (` module: <path>` above the frames): every module shares one generated function, so its frames alone all carry the entry file's coordinates. Setting `XT_STACK_WATCHDOG_MS=<n>` starts a sampler thread that prints those frames whenever no function has been entered or left for *n* milliseconds, turning a silent hang (an unexpected infinite loop, a blocking host call) into a source location; the thread is not started when the variable is unset. `--debug` additionally emits `!DICompileUnit` / `!DISubprogram` / `!DILocation` metadata and compiles with `-g -fno-omit-frame-pointer`, so gdb/lldb/WinDbg map instructions back to source lines. `!DILocation` has a 16-bit `column` field, so a column from a minified bundle (they run to hundreds of thousands) is clamped to 65535 instead of making clang reject the module; the line is clamped to the 24-bit limit for the same reason.
35
40
  - Typed pointers that the collector follows from inside a struct (a promise's reaction list, an active coroutine frame, a string's rope children) are validated against the heap table before marking, so a stale one is skipped instead of dereferenced (`XT_GC_VERIFY=1` reports it).
41
+ - A lazily built value (`Function.prototype[Symbol.hasInstance]`, a prototype cache, `console`, `JSON`, a symbol registry) registers its static slot as a root **before** the allocations that build the value. A static is outside the conservative stack scan, so a collection between storing the value and registering the slot sweeps an object the program still holds; the stale slot then marks a freed block, which on Windows (where the compiler kept no stack copy) corrupted the small-block free list and crashed the next `xt_pool_alloc`.
36
42
  - Objects / functions: `xt_object` with a prototype chain, `xt_function` with a property bag (static members and `prototype`); `xt_new` (instantiation), `xt_instance_of` (prototype chain), `xt_object_freeze/is_frozen/from_entries`; `xt_constructors.c` holds the first-class constructor cache, constructor prototypes and static-value dispatch.
43
+
@@ -56,7 +56,9 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
56
56
 
57
57
  - Number formatting and coercion match Node: `toFixed` / `toPrecision` / `toExponential`, hex / octal / binary parsing, and the full `+` / relational `ToPrimitive` rules. These are covered by the differential tests.
58
58
  - `BigInt` literals and values: arbitrary precision arithmetic, bitwise and shift operators, comparisons, `toString(radix)`, `BigInt()`, `BigInt.asIntN` / `BigInt.asUintN`.
59
- - `Math`: the full function set and constants.
59
+ - `Math`: the full function set and constants. `Math.hypot(...values)` accepts any number of arguments (ECMA-262 21.3.2.18): every argument participates, a `NaN` wins and the sum is scaled by the largest magnitude so `hypot(1e308, 1e308)` does not overflow.
60
+ - `Math.cbrt` uses the runtime's own fdlibm implementation (the version V8 ships) rather than the host libm, whose low bits vary: glibc computes `Math.cbrt(27)` as `3.0000000000000004`. Results are therefore bit-identical with Node on every host.
61
+ - `Math` call sites dispatch on the first byte of the member name before comparing the full name, so `Math.imul` / `floor` / `exp` in a numeric loop no longer pay for a linear `strcmp` chain (procedural texture and geometry code calls them hundreds of millions of times; removing the chain halved level setup on a bundled three.js page).
60
62
  - `Math` is also a first-class object: `const cos = Math.cos`, `[1, 2].map(Math.max)` and `const { sqrt, PI } = Math` read members as values (`xt_math_object()` caches one native closure per function, so reads stay cheap).
61
63
  - `Number` statics and `Number()` conversion; `parseInt` / `parseFloat` / `isNaN` / `isFinite`.
62
64
 
@@ -75,6 +77,7 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
75
77
 
76
78
  - `RegExp` uses the runtime's self-contained POSIX-ERE-compatible matcher (`regcomp` / `regexec` style) on every host, so results do not depend on the platform's libc. Capture groups are exposed through `exec` / `match` / `replace` / `split` / `search`.
77
79
  - Quantifiers include `*`, `+`, `?` and the counted forms `{n}`, `{n,}` and `{n,m}` (with a lazy `?` suffix). Malformed brace groups such as `{x}` and `{,2}` stay literal, as in JavaScript; an inverted range such as `{2,1}` is also treated as literal instead of being rejected.
80
+ - A JavaScript pattern is translated for the matcher first (`\d`/`\w`/`\s` → classes, `(?:` → a capturing group, control-character escapes → literals). Any other escape is a **literal character** and keeps its backslash, so `\[`, `\]`, `\(`, `\.`, `\+` match those characters and do not start syntax: `"x[ i ]y".replace(/\[\s*i\s*\]/g, …)` behaves like Node. three.js's `unrollLoops` depends on exactly that shape.
78
81
  - Matching is byte-oriented and `/g` / `/y` `lastIndex` is not honoured — see [Runtime deviations](../unimplemented/deviations.md).
79
82
 
80
83
  ## Symbol
@@ -101,7 +104,11 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
101
104
 
102
105
  ## URLSearchParams
103
106
 
104
- - `URLSearchParams` is implemented in `runtime/xt_url.c`.
107
+ - `URLSearchParams` is implemented in `runtime/xt_url.c`. It is iterable
108
+ (`[Symbol.iterator]`, so `[...params]`, `for (const [k, v] of params)` and
109
+ `Object.fromEntries(params)` work), and `Object.fromEntries` consumes any
110
+ iterable — an array of pairs, a `Map`, a `URLSearchParams` or a generator —
111
+ rather than only an array.
105
112
 
106
113
  ## Errors
107
114
 
@@ -112,6 +119,7 @@ own pages: [Collections](./collections.md), [Typed arrays and binary data](./typ
112
119
  ## console
113
120
 
114
121
  - `xt_print` / `xt_println` / `xt_console_log` / `info` / `warn` / `error`; `info` / `log` go to stdout, `warn` / `error` to stderr.
122
+ - `console` is a first-class object as well as a namespace: `const log = console.log`, `const { warn } = console`, `console.error.bind(console)` and `console.error = ...` all work, because reading `console` produces a cached object whose methods are ordinary functions (`xt_console_object`). Call sites stay direct (`console.log(...)` lowers to the runtime symbol), so the object costs nothing until a program uses it as a value.
115
123
  - Node-style inspection: arrays `[ a, b ]`, objects `{ k: v }`, UTF-8-aware, with circular references marked.
116
124
  - `dir` / `trace` / `assert` / `count` / `countReset` / `group` / `groupEnd` / `table` / `time` / `timeEnd` / `timeLog`.
117
125