xbintsc 0.5.6 → 0.5.21

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 (490) hide show
  1. package/AGENTS.md +20 -10
  2. package/README.md +8 -7
  3. package/README.zh-CN.md +6 -6
  4. package/dist/src/binder/declarations.js +14 -3
  5. package/dist/src/binder/declarations.js.map +1 -1
  6. package/dist/src/cli/hints.js +7 -1
  7. package/dist/src/cli/hints.js.map +1 -1
  8. package/dist/src/cli/main.js +115 -15
  9. package/dist/src/cli/main.js.map +1 -1
  10. package/dist/src/cli/watch.d.ts +25 -0
  11. package/dist/src/cli/watch.js +93 -0
  12. package/dist/src/cli/watch.js.map +1 -0
  13. package/dist/src/codegen/generator/calls/access.js +11 -2
  14. package/dist/src/codegen/generator/calls/access.js.map +1 -1
  15. package/dist/src/codegen/generator/calls/closures.js +12 -4
  16. package/dist/src/codegen/generator/calls/closures.js.map +1 -1
  17. package/dist/src/codegen/generator/context.d.ts +8 -0
  18. package/dist/src/codegen/generator/context.js +22 -3
  19. package/dist/src/codegen/generator/context.js.map +1 -1
  20. package/dist/src/codegen/generator/expressions/operators.js +17 -15
  21. package/dist/src/codegen/generator/expressions/operators.js.map +1 -1
  22. package/dist/src/codegen/generator/expressions/primary.js +5 -0
  23. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  24. package/dist/src/codegen/generator/module.js +0 -7
  25. package/dist/src/codegen/generator/module.js.map +1 -1
  26. package/dist/src/codegen/generator/numeric.d.ts +6 -3
  27. package/dist/src/codegen/generator/numeric.js +54 -11
  28. package/dist/src/codegen/generator/numeric.js.map +1 -1
  29. package/dist/src/codegen/generator/state.js +23 -0
  30. package/dist/src/codegen/generator/state.js.map +1 -1
  31. package/dist/src/codegen/generator/statements/control-flow.js +1 -4
  32. package/dist/src/codegen/generator/statements/control-flow.js.map +1 -1
  33. package/dist/src/codegen/generator/statements/loops.js +48 -16
  34. package/dist/src/codegen/generator/statements/loops.js.map +1 -1
  35. package/dist/src/codegen/generator/tables.js +26 -1
  36. package/dist/src/codegen/generator/tables.js.map +1 -1
  37. package/dist/src/diagnostics/diagnostic.d.ts +3 -1
  38. package/dist/src/diagnostics/diagnostic.js +23 -3
  39. package/dist/src/diagnostics/diagnostic.js.map +1 -1
  40. package/dist/src/driver/app-artifacts.d.ts +42 -0
  41. package/dist/src/driver/app-artifacts.js +53 -0
  42. package/dist/src/driver/app-artifacts.js.map +1 -0
  43. package/dist/src/driver/build-key.d.ts +29 -0
  44. package/dist/src/driver/build-key.js +35 -0
  45. package/dist/src/driver/build-key.js.map +1 -0
  46. package/dist/src/driver/bundler/graph.js +61 -12
  47. package/dist/src/driver/bundler/graph.js.map +1 -1
  48. package/dist/src/driver/bundler/merge.js +7 -1
  49. package/dist/src/driver/bundler/merge.js.map +1 -1
  50. package/dist/src/driver/compiler.d.ts +10 -67
  51. package/dist/src/driver/compiler.js +95 -234
  52. package/dist/src/driver/compiler.js.map +1 -1
  53. package/dist/src/driver/config.d.ts +3 -0
  54. package/dist/src/driver/config.js +8 -0
  55. package/dist/src/driver/config.js.map +1 -1
  56. package/dist/src/driver/frontend.d.ts +37 -0
  57. package/dist/src/driver/frontend.js +92 -0
  58. package/dist/src/driver/frontend.js.map +1 -0
  59. package/dist/src/driver/index.d.ts +1 -1
  60. package/dist/src/driver/index.js.map +1 -1
  61. package/dist/src/driver/options.d.ts +64 -0
  62. package/dist/src/driver/options.js +9 -0
  63. package/dist/src/driver/options.js.map +1 -0
  64. package/dist/src/driver/runtime-objects.d.ts +38 -0
  65. package/dist/src/driver/runtime-objects.js +112 -0
  66. package/dist/src/driver/runtime-objects.js.map +1 -0
  67. package/dist/src/driver/toolchain-provider.d.ts +4 -0
  68. package/dist/src/driver/toolchain-provider.js +4 -0
  69. package/dist/src/driver/toolchain-provider.js.map +1 -1
  70. package/dist/src/driver/toolchain.d.ts +32 -1
  71. package/dist/src/driver/toolchain.js +115 -11
  72. package/dist/src/driver/toolchain.js.map +1 -1
  73. package/dist/src/driver/version.d.ts +12 -0
  74. package/dist/src/driver/version.js +13 -0
  75. package/dist/src/driver/version.js.map +1 -0
  76. package/dist/src/driver/win-icon.d.ts +7 -9
  77. package/dist/src/driver/win-icon.js +37 -35
  78. package/dist/src/driver/win-icon.js.map +1 -1
  79. package/dist/src/extensions/node/fs/index.d.ts +4 -3
  80. package/dist/src/extensions/node/fs/index.js +12 -3
  81. package/dist/src/extensions/node/fs/index.js.map +1 -1
  82. package/dist/src/extensions/node/fs-promises/index.d.ts +5 -5
  83. package/dist/src/extensions/node/fs-promises/index.js +15 -6
  84. package/dist/src/extensions/node/fs-promises/index.js.map +1 -1
  85. package/dist/src/parser/declarations/classes.js +5 -0
  86. package/dist/src/parser/declarations/classes.js.map +1 -1
  87. package/dist/src/parser/declarations/functions.js +13 -1
  88. package/dist/src/parser/declarations/functions.js.map +1 -1
  89. package/dist/src/parser/modules.js +8 -3
  90. package/dist/src/parser/modules.js.map +1 -1
  91. package/dist/src/parser/parser.d.ts +1 -0
  92. package/dist/src/parser/parser.js +23 -0
  93. package/dist/src/parser/parser.js.map +1 -1
  94. package/dist/tests/cli/check.test.d.ts +6 -0
  95. package/dist/tests/cli/check.test.js +68 -0
  96. package/dist/tests/cli/check.test.js.map +1 -0
  97. package/dist/tests/cli/main.test.js +19 -0
  98. package/dist/tests/cli/main.test.js.map +1 -1
  99. package/dist/tests/cli/watch.test.d.ts +6 -0
  100. package/dist/tests/cli/watch.test.js +72 -0
  101. package/dist/tests/cli/watch.test.js.map +1 -0
  102. package/dist/tests/codegen/expressions.test.js +15 -3
  103. package/dist/tests/codegen/expressions.test.js.map +1 -1
  104. package/dist/tests/codegen/llvm.test.js +16 -0
  105. package/dist/tests/codegen/llvm.test.js.map +1 -1
  106. package/dist/tests/diagnostics/diagnostic.test.js +8 -0
  107. package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
  108. package/dist/tests/docs/structure.test.d.ts +1 -0
  109. package/dist/tests/docs/structure.test.js +92 -0
  110. package/dist/tests/docs/structure.test.js.map +1 -0
  111. package/dist/tests/driver/compiler.test.js +6 -0
  112. package/dist/tests/driver/compiler.test.js.map +1 -1
  113. package/dist/tests/driver/config.test.js +9 -0
  114. package/dist/tests/driver/config.test.js.map +1 -1
  115. package/dist/tests/driver/icon.test.js +19 -32
  116. package/dist/tests/driver/icon.test.js.map +1 -1
  117. package/dist/tests/driver/invalid-input.test.d.ts +10 -0
  118. package/dist/tests/driver/invalid-input.test.js +29 -0
  119. package/dist/tests/driver/invalid-input.test.js.map +1 -0
  120. package/dist/tests/driver/modules.test.js +42 -3
  121. package/dist/tests/driver/modules.test.js.map +1 -1
  122. package/dist/tests/driver/toolchain-provider.test.js +27 -1
  123. package/dist/tests/driver/toolchain-provider.test.js.map +1 -1
  124. package/dist/tests/driver/toolchain.test.js +60 -2
  125. package/dist/tests/driver/toolchain.test.js.map +1 -1
  126. package/dist/tests/e2e/array-buffer.test.d.ts +5 -0
  127. package/dist/tests/e2e/array-buffer.test.js +38 -0
  128. package/dist/tests/e2e/array-buffer.test.js.map +1 -0
  129. package/dist/tests/e2e/array-from-iterables.test.d.ts +7 -0
  130. package/dist/tests/e2e/array-from-iterables.test.js +34 -0
  131. package/dist/tests/e2e/array-from-iterables.test.js.map +1 -0
  132. package/dist/tests/e2e/array-symbol-iterator.test.d.ts +8 -0
  133. package/dist/tests/e2e/array-symbol-iterator.test.js +42 -0
  134. package/dist/tests/e2e/array-symbol-iterator.test.js.map +1 -0
  135. package/dist/tests/e2e/async-await.test.js +1 -1
  136. package/dist/tests/e2e/async-fs.test.d.ts +9 -0
  137. package/dist/tests/e2e/async-fs.test.js +119 -0
  138. package/dist/tests/e2e/async-fs.test.js.map +1 -0
  139. package/dist/tests/e2e/async-generators.test.d.ts +1 -0
  140. package/dist/tests/e2e/async-generators.test.js +154 -0
  141. package/dist/tests/e2e/async-generators.test.js.map +1 -0
  142. package/dist/tests/e2e/await-ordering.test.d.ts +5 -0
  143. package/dist/tests/e2e/await-ordering.test.js +37 -0
  144. package/dist/tests/e2e/await-ordering.test.js.map +1 -0
  145. package/dist/tests/e2e/compile-builtins.test.js +1 -1
  146. package/dist/tests/e2e/compile-modules.test.js +7 -0
  147. package/dist/tests/e2e/compile-modules.test.js.map +1 -1
  148. package/dist/tests/e2e/date-parse.test.d.ts +8 -0
  149. package/dist/tests/e2e/date-parse.test.js +38 -0
  150. package/dist/tests/e2e/date-parse.test.js.map +1 -0
  151. package/dist/tests/e2e/default-anonymous-exports.test.d.ts +7 -0
  152. package/dist/tests/e2e/default-anonymous-exports.test.js +23 -0
  153. package/dist/tests/e2e/default-anonymous-exports.test.js.map +1 -0
  154. package/dist/tests/e2e/fetch.test.js +24 -0
  155. package/dist/tests/e2e/fetch.test.js.map +1 -1
  156. package/dist/tests/e2e/globals-microtask.test.d.ts +9 -0
  157. package/dist/tests/e2e/globals-microtask.test.js +37 -0
  158. package/dist/tests/e2e/globals-microtask.test.js.map +1 -0
  159. package/dist/tests/e2e/gui-inline-svg.test.d.ts +11 -0
  160. package/dist/tests/e2e/gui-inline-svg.test.js +160 -0
  161. package/dist/tests/e2e/gui-inline-svg.test.js.map +1 -0
  162. package/dist/tests/e2e/gui-media.test.js +8 -1
  163. package/dist/tests/e2e/gui-media.test.js.map +1 -1
  164. package/dist/tests/e2e/inspect-builtins.test.d.ts +10 -0
  165. package/dist/tests/e2e/inspect-builtins.test.js +43 -0
  166. package/dist/tests/e2e/inspect-builtins.test.js.map +1 -0
  167. package/dist/tests/e2e/json-builtin-objects.test.d.ts +9 -0
  168. package/dist/tests/e2e/json-builtin-objects.test.js +23 -0
  169. package/dist/tests/e2e/json-builtin-objects.test.js.map +1 -0
  170. package/dist/tests/e2e/json-circular.test.d.ts +6 -0
  171. package/dist/tests/e2e/json-circular.test.js +43 -0
  172. package/dist/tests/e2e/json-circular.test.js.map +1 -0
  173. package/dist/tests/e2e/json-parse-reviver.test.d.ts +6 -0
  174. package/dist/tests/e2e/json-parse-reviver.test.js +29 -0
  175. package/dist/tests/e2e/json-parse-reviver.test.js.map +1 -0
  176. package/dist/tests/e2e/json-stringify-replacer.test.d.ts +6 -0
  177. package/dist/tests/e2e/json-stringify-replacer.test.js +27 -0
  178. package/dist/tests/e2e/json-stringify-replacer.test.js.map +1 -0
  179. package/dist/tests/e2e/json-stringify-space.test.d.ts +6 -0
  180. package/dist/tests/e2e/json-stringify-space.test.js +23 -0
  181. package/dist/tests/e2e/json-stringify-space.test.js.map +1 -0
  182. package/dist/tests/e2e/method-dispatch-errors.test.d.ts +9 -0
  183. package/dist/tests/e2e/method-dispatch-errors.test.js +38 -0
  184. package/dist/tests/e2e/method-dispatch-errors.test.js.map +1 -0
  185. package/dist/tests/e2e/native-extensions.test.js +1 -1
  186. package/dist/tests/e2e/native-extensions.test.js.map +1 -1
  187. package/dist/tests/e2e/promise-with-resolvers.test.d.ts +5 -0
  188. package/dist/tests/e2e/promise-with-resolvers.test.js +20 -0
  189. package/dist/tests/e2e/promise-with-resolvers.test.js.map +1 -0
  190. package/dist/tests/e2e/property-descriptors.test.d.ts +5 -0
  191. package/dist/tests/e2e/property-descriptors.test.js +25 -0
  192. package/dist/tests/e2e/property-descriptors.test.js.map +1 -0
  193. package/dist/tests/e2e/property-ic.test.d.ts +1 -0
  194. package/dist/tests/e2e/property-ic.test.js +55 -0
  195. package/dist/tests/e2e/property-ic.test.js.map +1 -0
  196. package/dist/tests/e2e/runtime-errors.test.d.ts +10 -0
  197. package/dist/tests/e2e/runtime-errors.test.js +52 -0
  198. package/dist/tests/e2e/runtime-errors.test.js.map +1 -0
  199. package/dist/tests/e2e/structured-clone.test.d.ts +6 -0
  200. package/dist/tests/e2e/structured-clone.test.js +49 -0
  201. package/dist/tests/e2e/structured-clone.test.js.map +1 -0
  202. package/dist/tests/e2e/text-codec.test.d.ts +6 -0
  203. package/dist/tests/e2e/text-codec.test.js +24 -0
  204. package/dist/tests/e2e/text-codec.test.js.map +1 -0
  205. package/dist/tests/e2e/typed-array-views.test.d.ts +6 -0
  206. package/dist/tests/e2e/typed-array-views.test.js +39 -0
  207. package/dist/tests/e2e/typed-array-views.test.js.map +1 -0
  208. package/dist/tests/e2e/url-search-params.test.d.ts +5 -0
  209. package/dist/tests/e2e/url-search-params.test.js +30 -0
  210. package/dist/tests/e2e/url-search-params.test.js.map +1 -0
  211. package/dist/tests/e2e/weak-collections.test.d.ts +1 -0
  212. package/dist/tests/e2e/weak-collections.test.js +88 -0
  213. package/dist/tests/e2e/weak-collections.test.js.map +1 -0
  214. package/dist/tests/parser/declarations.test.js +12 -0
  215. package/dist/tests/parser/declarations.test.js.map +1 -1
  216. package/dist/tests/parser/module-syntax.test.js +9 -0
  217. package/dist/tests/parser/module-syntax.test.js.map +1 -1
  218. package/dist/tests/parser/parser.test.js +7 -0
  219. package/dist/tests/parser/parser.test.js.map +1 -1
  220. package/dist/tests/version.test.js +5 -1
  221. package/dist/tests/version.test.js.map +1 -1
  222. package/doc/ai/README.md +4 -3
  223. package/doc/ai/cli.md +41 -0
  224. package/doc/ai/contributing.md +20 -16
  225. package/doc/ai/extensions.md +13 -10
  226. package/doc/ai/language-support.md +19 -14
  227. package/doc/ai/troubleshooting.md +11 -9
  228. package/doc/ai/zh-CN/README.md +3 -2
  229. package/doc/ai/zh-CN/cli.md +35 -0
  230. package/doc/ai/zh-CN/contributing.md +16 -15
  231. package/doc/ai/zh-CN/extensions.md +12 -9
  232. package/doc/ai/zh-CN/language-support.md +19 -15
  233. package/doc/ai/zh-CN/troubleshooting.md +9 -8
  234. package/doc/gui/api.md +8 -0
  235. package/doc/gui/build.md +13 -4
  236. package/doc/gui/known-issues.md +19 -14
  237. package/doc/gui/media.md +32 -3
  238. package/doc/gui/rendering.md +3 -1
  239. package/doc/gui.md +28 -5
  240. package/doc/icon.md +5 -4
  241. package/doc/implemented/async.md +51 -0
  242. package/doc/implemented/binder.md +13 -0
  243. package/doc/implemented/cli.md +47 -0
  244. package/doc/implemented/codegen.md +33 -0
  245. package/doc/implemented/collections.md +26 -0
  246. package/doc/implemented/driver.md +19 -0
  247. package/doc/implemented/extensions.md +19 -0
  248. package/doc/implemented/fetch.md +44 -0
  249. package/doc/implemented/lexer.md +23 -0
  250. package/doc/implemented/modules.md +28 -0
  251. package/doc/implemented/node/assert.md +17 -0
  252. package/doc/implemented/node/buffer.md +29 -0
  253. package/doc/implemented/node/child-process.md +29 -0
  254. package/doc/implemented/node/crypto.md +9 -0
  255. package/doc/implemented/node/dgram.md +15 -0
  256. package/doc/implemented/node/events.md +37 -0
  257. package/doc/implemented/node/fs-promises.md +49 -0
  258. package/doc/implemented/node/fs.md +112 -0
  259. package/doc/implemented/node/http.md +21 -0
  260. package/doc/implemented/node/net.md +17 -0
  261. package/doc/implemented/node/os.md +22 -0
  262. package/doc/implemented/node/path.md +33 -0
  263. package/doc/implemented/node/process.md +23 -0
  264. package/doc/implemented/node/querystring.md +20 -0
  265. package/doc/implemented/node/stream-promises.md +8 -0
  266. package/doc/implemented/node/stream.md +19 -0
  267. package/doc/implemented/node/test.md +10 -0
  268. package/doc/implemented/node/url.md +8 -0
  269. package/doc/implemented/node/util.md +25 -0
  270. package/doc/implemented/node/worker-threads.md +10 -0
  271. package/doc/implemented/node/zlib.md +8 -0
  272. package/doc/implemented/node.md +48 -0
  273. package/doc/implemented/operators.md +38 -0
  274. package/doc/implemented/parser.md +58 -0
  275. package/doc/implemented/pipeline.md +28 -0
  276. package/doc/implemented/runtime-core.md +32 -0
  277. package/doc/implemented/stdlib.md +78 -0
  278. package/doc/implemented/strings.md +27 -0
  279. package/doc/implemented/tests.md +10 -0
  280. package/doc/implemented/typed-arrays.md +26 -0
  281. package/doc/implemented/value-model.md +18 -0
  282. package/doc/implemented.md +54 -355
  283. package/doc/node-implemented.md +3 -585
  284. package/doc/node-unimplemented.md +3 -164
  285. package/doc/requirements.md +23 -8
  286. package/doc/unimplemented/classes.md +22 -0
  287. package/doc/unimplemented/deviations.md +27 -0
  288. package/doc/unimplemented/expressions.md +26 -0
  289. package/doc/unimplemented/functions.md +21 -0
  290. package/doc/unimplemented/modules.md +22 -0
  291. package/doc/unimplemented/node/async.md +20 -0
  292. package/doc/unimplemented/node/bun.md +9 -0
  293. package/doc/unimplemented/node/fs-promises.md +20 -0
  294. package/doc/unimplemented/node/fs.md +30 -0
  295. package/doc/unimplemented/node/globals.md +23 -0
  296. package/doc/unimplemented/node/modules.md +21 -0
  297. package/doc/unimplemented/node.md +21 -0
  298. package/doc/unimplemented/statements.md +18 -0
  299. package/doc/unimplemented/stdlib.md +54 -0
  300. package/doc/unimplemented/toolchain.md +14 -0
  301. package/doc/unimplemented/types.md +12 -0
  302. package/doc/unimplemented.md +18 -275
  303. package/doc/xbintsc.config.schema.json +12 -0
  304. package/doc/zh-CN/gui/api.md +7 -0
  305. package/doc/zh-CN/gui/build.md +11 -3
  306. package/doc/zh-CN/gui/known-issues.md +17 -11
  307. package/doc/zh-CN/gui/media.md +26 -2
  308. package/doc/zh-CN/gui/rendering.md +2 -1
  309. package/doc/zh-CN/gui.md +21 -3
  310. package/doc/zh-CN/icon.md +5 -4
  311. package/doc/zh-CN/implemented/async.md +49 -0
  312. package/doc/zh-CN/implemented/binder.md +13 -0
  313. package/doc/zh-CN/implemented/cli.md +46 -0
  314. package/doc/zh-CN/implemented/codegen.md +33 -0
  315. package/doc/zh-CN/implemented/collections.md +26 -0
  316. package/doc/zh-CN/implemented/driver.md +19 -0
  317. package/doc/zh-CN/implemented/extensions.md +19 -0
  318. package/doc/zh-CN/implemented/fetch.md +31 -0
  319. package/doc/zh-CN/implemented/lexer.md +23 -0
  320. package/doc/zh-CN/implemented/modules.md +28 -0
  321. package/doc/zh-CN/implemented/node/assert.md +17 -0
  322. package/doc/zh-CN/implemented/node/buffer.md +25 -0
  323. package/doc/zh-CN/implemented/node/child-process.md +27 -0
  324. package/doc/zh-CN/implemented/node/crypto.md +9 -0
  325. package/doc/zh-CN/implemented/node/dgram.md +15 -0
  326. package/doc/zh-CN/implemented/node/events.md +36 -0
  327. package/doc/zh-CN/implemented/node/fs-promises.md +30 -0
  328. package/doc/zh-CN/implemented/node/fs.md +105 -0
  329. package/doc/zh-CN/implemented/node/http.md +17 -0
  330. package/doc/zh-CN/implemented/node/net.md +17 -0
  331. package/doc/zh-CN/implemented/node/os.md +21 -0
  332. package/doc/zh-CN/implemented/node/path.md +26 -0
  333. package/doc/zh-CN/implemented/node/process.md +23 -0
  334. package/doc/zh-CN/implemented/node/querystring.md +20 -0
  335. package/doc/zh-CN/implemented/node/stream-promises.md +8 -0
  336. package/doc/zh-CN/implemented/node/stream.md +15 -0
  337. package/doc/zh-CN/implemented/node/test.md +10 -0
  338. package/doc/zh-CN/implemented/node/url.md +8 -0
  339. package/doc/zh-CN/implemented/node/util.md +25 -0
  340. package/doc/zh-CN/implemented/node/worker-threads.md +9 -0
  341. package/doc/zh-CN/implemented/node/zlib.md +8 -0
  342. package/doc/zh-CN/implemented/node.md +45 -0
  343. package/doc/zh-CN/implemented/operators.md +38 -0
  344. package/doc/zh-CN/implemented/parser.md +58 -0
  345. package/doc/zh-CN/implemented/pipeline.md +25 -0
  346. package/doc/zh-CN/implemented/runtime-core.md +31 -0
  347. package/doc/zh-CN/implemented/stdlib.md +76 -0
  348. package/doc/zh-CN/implemented/strings.md +27 -0
  349. package/doc/zh-CN/implemented/tests.md +10 -0
  350. package/doc/zh-CN/implemented/typed-arrays.md +26 -0
  351. package/doc/zh-CN/implemented/value-model.md +18 -0
  352. package/doc/zh-CN/implemented.md +50 -350
  353. package/doc/zh-CN/node-implemented.md +4 -531
  354. package/doc/zh-CN/node-unimplemented.md +4 -139
  355. package/doc/zh-CN/plan-require-node-modules.md +4 -4
  356. package/doc/zh-CN/requirements.md +20 -6
  357. package/doc/zh-CN/unimplemented/classes.md +22 -0
  358. package/doc/zh-CN/unimplemented/deviations.md +24 -0
  359. package/doc/zh-CN/unimplemented/expressions.md +24 -0
  360. package/doc/zh-CN/unimplemented/functions.md +21 -0
  361. package/doc/zh-CN/unimplemented/modules.md +19 -0
  362. package/doc/zh-CN/unimplemented/node/async.md +20 -0
  363. package/doc/zh-CN/unimplemented/node/bun.md +8 -0
  364. package/doc/zh-CN/unimplemented/node/fs-promises.md +12 -0
  365. package/doc/zh-CN/unimplemented/node/fs.md +24 -0
  366. package/doc/zh-CN/unimplemented/node/globals.md +14 -0
  367. package/doc/zh-CN/unimplemented/node/modules.md +15 -0
  368. package/doc/zh-CN/unimplemented/node.md +18 -0
  369. package/doc/zh-CN/unimplemented/statements.md +15 -0
  370. package/doc/zh-CN/unimplemented/stdlib.md +54 -0
  371. package/doc/zh-CN/unimplemented/toolchain.md +14 -0
  372. package/doc/zh-CN/unimplemented/types.md +11 -0
  373. package/doc/zh-CN/unimplemented.md +14 -237
  374. package/llms.txt +32 -4
  375. package/package.json +1 -1
  376. package/runtime/ext_gui/inline_svg.cpp +219 -0
  377. package/runtime/ext_gui/inline_svg.h +41 -0
  378. package/runtime/ext_gui/layout.cpp +18 -0
  379. package/runtime/ext_gui/layout.h +7 -0
  380. package/runtime/ext_gui/layout_flow.cpp +4 -3
  381. package/runtime/ext_gui/paint.cpp +14 -0
  382. package/runtime/ext_gui/paint.h +5 -1
  383. package/runtime/ext_gui/renderer_image.cpp +53 -25
  384. package/runtime/ext_gui/renderer_shaders.h +2 -2
  385. package/runtime/ext_gui/stb_image.h +1 -17
  386. package/runtime/ext_gui/style_ua.cpp +3 -0
  387. package/runtime/ext_gui/svg.cpp +122 -39
  388. package/runtime/ext_gui/svg.h +14 -3
  389. package/runtime/ext_gui/window.cpp +28 -0
  390. package/runtime/ext_node/child_process/child_process.c +173 -73
  391. package/runtime/ext_node/fs/async_api.c +314 -0
  392. package/runtime/ext_node/fs/async_complete.c +99 -0
  393. package/runtime/ext_node/fs/async_fh.c +206 -0
  394. package/runtime/ext_node/fs/async_job.c +81 -0
  395. package/runtime/ext_node/fs/async_job.h +132 -0
  396. package/runtime/ext_node/fs/async_worker.c +534 -0
  397. package/runtime/ext_node/fs/async_worker_dir.c +439 -0
  398. package/runtime/ext_node/fs/async_worker_dir.h +33 -0
  399. package/runtime/ext_node/fs/async_worker_fd.c +74 -0
  400. package/runtime/ext_node/fs/dir.c +60 -15
  401. package/runtime/ext_node/fs/fs_common.h +9 -0
  402. package/runtime/ext_node/fs/fs_ops.c +18 -29
  403. package/runtime/ext_node/fs/parts/builtins.inc +34 -0
  404. package/runtime/ext_node/fs/parts/platform.inc +66 -0
  405. package/runtime/ext_node/fs/promises.c +44 -234
  406. package/runtime/rt.h +15 -0
  407. package/runtime/rt_internal.h +108 -0
  408. package/runtime/xt_alloc.c +43 -7
  409. package/runtime/xt_array_buffer.c +284 -0
  410. package/runtime/xt_async.c +46 -21
  411. package/runtime/xt_async_io.c +333 -0
  412. package/runtime/xt_async_io.h +47 -0
  413. package/runtime/xt_bigint/helpers.inc +3 -3
  414. package/runtime/xt_builtins.c +21 -17
  415. package/runtime/xt_constructors.c +12 -2
  416. package/runtime/xt_containers/access.inc +148 -3
  417. package/runtime/xt_containers/objects.inc +26 -2
  418. package/runtime/xt_containers/shapes.inc +71 -0
  419. package/runtime/xt_containers.c +1 -0
  420. package/runtime/xt_coroutine.c +17 -0
  421. package/runtime/xt_fetch/async.inc +295 -0
  422. package/runtime/xt_fetch/request.inc +6 -183
  423. package/runtime/xt_fetch/socket.inc +5 -4
  424. package/runtime/xt_fetch.c +6 -4
  425. package/runtime/xt_generator.c +299 -10
  426. package/runtime/xt_io/inspect.inc +112 -0
  427. package/runtime/xt_loop.c +79 -7
  428. package/runtime/xt_performance.c +37 -0
  429. package/runtime/xt_promise.c +63 -1
  430. package/runtime/xt_stdlib/arrays.inc +1 -1
  431. package/runtime/xt_stdlib/dispatch.inc +46 -11
  432. package/runtime/xt_stdlib/strings.inc +1 -1
  433. package/runtime/xt_stdlib2/array-statics.inc +25 -0
  434. package/runtime/xt_stdlib2/arrays.inc +5 -3
  435. package/runtime/xt_stdlib2/container.inc +5 -0
  436. package/runtime/xt_stdlib2/date.inc +111 -3
  437. package/runtime/xt_stdlib2/error.inc +24 -0
  438. package/runtime/xt_stdlib2/json.inc +310 -19
  439. package/runtime/xt_stdlib2/number-string-statics.inc +1 -1
  440. package/runtime/xt_stdlib2/objects.inc +122 -0
  441. package/runtime/xt_stdlib2/set.inc +1 -1
  442. package/runtime/xt_structured_clone.c +159 -0
  443. package/runtime/xt_symbol.c +2 -2
  444. package/runtime/xt_text_codec.c +69 -0
  445. package/runtime/xt_typed_array/construction.inc +35 -5
  446. package/runtime/xt_typed_array/elements.inc +159 -0
  447. package/runtime/xt_typed_array/methods.inc +21 -5
  448. package/runtime/xt_typed_array.c +7 -10
  449. package/runtime/xt_url.c +375 -0
  450. package/runtime/xt_values/arithmetic.inc +2 -2
  451. package/runtime/xt_values/conversions.inc +1 -1
  452. package/runtime/xt_weak.c +281 -0
  453. package/scripts/build-gui.ts +133 -60
  454. package/scripts/check-version.ts +3 -3
  455. package/src/binder/declarations.ts +14 -3
  456. package/src/cli/hints.ts +8 -1
  457. package/src/cli/main.ts +119 -18
  458. package/src/cli/watch.ts +101 -0
  459. package/src/codegen/generator/calls/access.ts +10 -2
  460. package/src/codegen/generator/calls/closures.ts +12 -4
  461. package/src/codegen/generator/context.ts +23 -3
  462. package/src/codegen/generator/expressions/operators.ts +27 -13
  463. package/src/codegen/generator/expressions/primary.ts +4 -0
  464. package/src/codegen/generator/module.ts +0 -7
  465. package/src/codegen/generator/numeric.ts +85 -11
  466. package/src/codegen/generator/state.ts +23 -0
  467. package/src/codegen/generator/statements/control-flow.ts +1 -4
  468. package/src/codegen/generator/statements/loops.ts +50 -16
  469. package/src/codegen/generator/tables.ts +26 -1
  470. package/src/diagnostics/diagnostic.ts +23 -3
  471. package/src/driver/app-artifacts.ts +77 -0
  472. package/src/driver/build-key.ts +55 -0
  473. package/src/driver/bundler/graph.ts +63 -13
  474. package/src/driver/bundler/merge.ts +4 -1
  475. package/src/driver/compiler.ts +94 -328
  476. package/src/driver/config.ts +11 -0
  477. package/src/driver/frontend.ts +120 -0
  478. package/src/driver/index.ts +0 -1
  479. package/src/driver/options.ts +70 -0
  480. package/src/driver/runtime-objects.ts +134 -0
  481. package/src/driver/toolchain-provider.ts +4 -0
  482. package/src/driver/toolchain.ts +154 -10
  483. package/src/driver/version.ts +12 -0
  484. package/src/driver/win-icon.ts +36 -36
  485. package/src/extensions/node/fs/index.ts +12 -3
  486. package/src/extensions/node/fs-promises/index.ts +15 -6
  487. package/src/parser/declarations/classes.ts +4 -0
  488. package/src/parser/declarations/functions.ts +12 -1
  489. package/src/parser/modules.ts +8 -4
  490. package/src/parser/parser.ts +28 -0
@@ -7,9 +7,13 @@ describe("compiler version", () => {
7
7
  expect(COMPILER_VERSION).toBe(packageJson.version);
8
8
  });
9
9
  it("is part of the incremental cache key", () => {
10
- const source = readFileSync(new URL("../src/driver/compiler.ts", import.meta.url), "utf8");
10
+ const source = readFileSync(new URL("../src/driver/build-key.ts", import.meta.url), "utf8");
11
11
  expect(source).toMatch(/hashParts\(\[\s*COMPILER_VERSION,/);
12
12
  });
13
+ it("keeps the version declaration out of compiler.ts", () => {
14
+ const source = readFileSync(new URL("../src/driver/compiler.ts", import.meta.url), "utf8");
15
+ expect(source).not.toMatch(/export const COMPILER_VERSION =/);
16
+ });
13
17
  it("is printed by `xbintsc version`", async () => {
14
18
  const { run } = await import("../src/cli/main.js");
15
19
  const lines = [];
@@ -1 +1 @@
1
- {"version":3,"file":"version.test.js","sourceRoot":"","sources":["../../tests/version.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAC3C,CAAC;AAEzB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,GAAG,CAAC,2BAA2B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QAC3F,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACnD,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE;YAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;SACnC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"version.test.js","sourceRoot":"","sources":["../../tests/version.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAC3C,CAAC;AAEzB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QAC5F,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,GAAG,CAAC,2BAA2B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QAC3F,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACnD,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE;YAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAClC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;SACnC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/doc/ai/README.md CHANGED
@@ -33,9 +33,10 @@ the rules for changing the compiler.
33
33
  2. **Types are erased, never checked.** Annotations, interfaces, generics,
34
34
  `as`/`satisfies` and non-null `!` have no runtime effect, and no type checker
35
35
  runs. Only real runtime behaviour matters.
36
- 3. **Node compatibility is opt-in and incomplete.** Node modules come from the
37
- `node` extension (`--ext node`); bare third-party npm imports are not
38
- supported.
36
+ 3. **Node compatibility is opt-in and incomplete.** Node built-ins come from the
37
+ `node` extension (`--ext node`). Packages under `node_modules` are resolved
38
+ and bundled at build time (ESM and CommonJS); there is no runtime package
39
+ lookup and circular dependencies are rejected.
39
40
 
40
41
  ## Choose your command
41
42
 
package/doc/ai/cli.md CHANGED
@@ -10,14 +10,26 @@ the help text leaves implicit.
10
10
  | --- | --- | --- |
11
11
  | `xbintsc build <file.ts>` | Compile to `exe` (default), `obj` or `ir` | yes, except `--emit ir` |
12
12
  | `xbintsc run <file.ts> [-- args]` | Compile to an executable and execute it | yes (`--emit exe` only) |
13
+ | `xbintsc watch <file.ts>` | Rebuild whenever the source tree changes (Ctrl+C to stop) | yes |
13
14
  | `xbintsc emit <file.ts>` | Print LLVM IR to stdout, write nothing | no |
15
+ | `xbintsc check <file.ts>` | Front-end check (syntax, imports, supported subset); writes nothing | no |
14
16
  | `xbintsc doctor` | Report the resolved toolchain, runtime and icon tools | only for the probe |
15
17
  | `xbintsc version` | Print the version | no |
16
18
  | `xbintsc help` | Print the help text | no |
17
19
 
20
+ `check` is not a type checker: annotations are erased, so a program that passes
21
+ `check` can still fail at runtime. It catches syntax errors, unresolved imports
22
+ and constructs outside the supported subset, which makes it a fast pre-commit
23
+ or editor gate.
24
+
18
25
  Any command also accepts `--help`, which prints the help text and exits 0. An
19
26
  unknown command prints an error plus the help text and exits 1.
20
27
 
28
+ `watch` polls the entry file's directory (build output, `dist`, `coverage` and
29
+ `node_modules` are ignored) and re-runs `build` on every change. It accepts the
30
+ same options as `build`; package sources under `node_modules` are not watched,
31
+ so restart it after installing a dependency.
32
+
21
33
  ## Options
22
34
 
23
35
  ```
@@ -38,8 +50,33 @@ unknown command prints an error plus the help text and exits 1.
38
50
  --verbose Print progress information
39
51
  --time Print per-phase build timings
40
52
  --debug Emit debug info (DWARF/CodeView) and keep frame pointers
53
+ --lto Compile program and runtime to LTO bitcode; link with lld
54
+ --pgo-generate [dir] Build an instrumented binary writing profiles to dir
55
+ --pgo-use [dir] Build with the profiles collected from --pgo-generate
56
+ --json Print diagnostics as a JSON array on stdout
57
+ ```
58
+
59
+ ### LTO and PGO
60
+
61
+ `--lto` compiles the generated IR and the C runtime to LLVM bitcode (`-flto`)
62
+ and links with lld (`-fuse-ld=lld`), so LLVM can optimize across the
63
+ language/runtime boundary. lld must be installed alongside clang.
64
+
65
+ PGO is a two-build workflow:
66
+
67
+ ```bash
68
+ xbintsc build app.ts --pgo-generate=profiles # instrumented binary
69
+ ./build/app # run a representative workload
70
+ xbintsc build app.ts --pgo-use=profiles # optimized rebuild
41
71
  ```
42
72
 
73
+ `--pgo-use` merges the `.profraw` files with `llvm-profdata` (the copy next to
74
+ clang is preferred; override with `xbintsc_LLVM_PROFDATA`) and passes
75
+ `-fprofile-use=<dir>` to clang. The profile directory defaults to
76
+ `<outDir>/pgo`. LTO and PGO can be combined. A `--pgo-use` build is never served
77
+ from the incremental cache, because the profile data can change independently
78
+ of the source.
79
+
43
80
  Parsing details that occasionally surprise:
44
81
 
45
82
  - `--flag=value` and `--flag value` are both accepted.
@@ -67,6 +104,9 @@ matching field. `--no-config` skips discovery entirely.
67
104
  | `outDir` | string | Output directory (default `build/`) |
68
105
  | `output` | string | Explicit output path, overriding `outDir` |
69
106
  | `optimize` | `"0"|"1"|"2"|"3"` | Optimization level |
107
+ | `lto` | boolean | Compile program and runtime to LTO bitcode and link with lld |
108
+ | `pgo` | `"generate"|"use"` | Profile-guided optimization stage |
109
+ | `pgoDir` | string | Profile directory (default `<outDir>/pgo`) |
70
110
  | `extensions` | string[] | Bundled extensions to enable, e.g. `["node"]` |
71
111
  | `extNative` | string[] | Native extension manifest paths |
72
112
  | `force` | boolean | Ignore the incremental cache |
@@ -82,6 +122,7 @@ unreadable or malformed config fails the build with `invalid JSON` or
82
122
  | --- | --- |
83
123
  | `xbintsc_CLANG` | Use this clang instead of resolving one from `PATH` |
84
124
  | `xbintsc_LINKER_ARGS` | Extra linker flags (e.g. `-fuse-ld=lld`) |
125
+ | `xbintsc_LLVM_PROFDATA` | `llvm-profdata` used to merge PGO `.profraw` files |
85
126
  | `xbintsc_CACHE_DIR` | Object-cache directory (default: `.xbintsc`) |
86
127
  | `xbintsc_PREFER_PREBUILT` | `0` forces the runtime to be compiled from source |
87
128
  | `xbintsc_BINARY` | Native compiler binary the `bin/` launcher should run |
@@ -18,16 +18,12 @@ toolchain is required for anything that links a binary (see
18
18
  [troubleshooting.md](./troubleshooting.md)). `xbintsc emit` needs neither clang
19
19
  nor the runtime library, which makes it the fastest inner loop.
20
20
 
21
- Optional but recommended — install the repository hook:
22
-
23
- ```bash
24
- git config core.hooksPath .githooks
25
- ```
26
-
27
- `.githooks/pre-commit` **bumps the patch version on every commit** and folds
28
- `package.json` + `package-lock.json` into that commit (`npm version patch
29
- --no-git-tag-version`). Expect a version bump in your commits; do not countermand
30
- it. Release tags are created by `release.yml`, never by the hook.
21
+ Optional: install the repository hook with `git config core.hooksPath .githooks`.
22
+ It bumps the patch version **only on `main`/`master`** — `package.json`,
23
+ `package-lock.json` and `src/driver/version.ts` together. Feature branches never
24
+ touch those files, which is what keeps two feature branches from conflicting on
25
+ the version lines; do not bump the version on a feature branch. Release tags are
26
+ created by `release.yml`, never by the hook.
31
27
 
32
28
  ## The test suites
33
29
 
@@ -80,7 +76,7 @@ mean the same thing in every generation. A compiled string stores UTF-8 bytes
80
76
  but indexes them in UTF-16 code units, so the self-hosted `readFileSync`
81
77
  (`--ext node`) hands the scanner a byte string (one byte per code unit, all
82
78
  `<= 0xFF`), while Node hands it the same file already decoded — read source
83
- files through `decodeUtf8` ([src/diagnostics/utf8.ts](../../src/diagnostics/utf8.ts))
79
+ files through `sourceTextBytes` ([src/diagnostics/source-text.ts](../../src/diagnostics/source-text.ts))
84
80
  and never assume a code unit is a byte or a character. Getting this wrong shows
85
81
  up as a non-ASCII literal (`—` in a hint string) coming out re-encoded in
86
82
  `gen2.ll`, which is why the emitted IR is compared byte-for-byte rather than
@@ -114,7 +110,8 @@ diff scratch/ref.ll scratch/gen2.ll
114
110
  therefore never allocate per access.
115
111
  - The GC is a non-moving mark-sweep collector: new heap objects go through
116
112
  `xt_alloc`, and a value must be reachable from an explicit root slot, a
117
- registered root provider (the event loop, the microtask queue) or the
113
+ registered root provider (the event loop, the microtask queue, the async I/O
114
+ job roots) or the
118
115
  conservative C-stack scan while it is live. A value held only in a C local that
119
116
  is not on the scanned stack is a bug.
120
117
 
@@ -131,7 +128,7 @@ npm run runtime:clean # drop build/runtime-obj and runtime/lib
131
128
  ```
132
129
 
133
130
  Add a new C file only together with the place that lists the runtime sources
134
- (`RUNTIME_SOURCES` in [../../src/driver/compiler.ts](../../src/driver/compiler.ts)),
131
+ (`RUNTIME_SOURCES` in [../../src/driver/runtime-objects.ts](../../src/driver/runtime-objects.ts)),
135
132
  because that list decides what gets compiled and linked. Extension C sources are
136
133
  declared by the extension itself.
137
134
 
@@ -177,13 +174,20 @@ A feature is not done until the docs match:
177
174
 
178
175
  | Document | Update when |
179
176
  | --- | --- |
180
- | [../implemented.md](../implemented.md) | a feature starts working |
181
- | [../unimplemented.md](../unimplemented.md) | a limitation appears or is lifted |
182
- | [../node-implemented.md](../node-implemented.md) / [../node-unimplemented.md](../node-unimplemented.md) | Node module coverage changes |
177
+ | [../implemented/](../implemented/) — the page that owns the feature | a feature starts working |
178
+ | [../unimplemented/](../unimplemented/) — the page that owns the limitation | a limitation appears or is lifted |
179
+ | [../implemented.md](../implemented.md) / [../unimplemented.md](../unimplemented.md) | a whole new page is added (link it from the index) |
180
+ | [../implemented/node.md](../implemented/node.md) / [../unimplemented/node.md](../unimplemented/node.md) | Node module coverage changes |
183
181
  | [language-support.md](./language-support.md) | the AI-facing summary of the above changes |
184
182
  | [../requirements.md](../requirements.md) | the toolchain or platform requirements change |
185
183
  | [cli.md](./cli.md) | a flag, config field or environment variable changes |
186
184
 
185
+ Each feature area owns one small page, so a feature branch edits the page for
186
+ its area (and the page's Chinese translation) instead of a monolith. The index
187
+ page's "Where does a change belong?" table maps a change to its page. A test
188
+ (`tests/docs/structure.test.ts`) checks that every English page has a Chinese
189
+ counterpart and is linked from its index.
190
+
187
191
  Keep the Chinese translation (`doc/zh-CN/`, `doc/ai/zh-CN/`) in step with the
188
192
  English source; a half-translated page is worse than none because it silently
189
193
  goes stale.
@@ -36,7 +36,7 @@ resolve to the same implementation.
36
36
  | Module | Notes |
37
37
  | --- | --- |
38
38
  | `fs` | **synchronous API only** (`readFileSync`, `writeFileSync`, …); `fs/promises` is separate |
39
- | `fs/promises` | promise-based file APIs |
39
+ | `fs/promises` | promise-based file APIs; the blocking I/O runs on the async I/O worker pool and settles on the reactor |
40
40
  | `path` | also hooks namespace dispatch, so `path.join(...)` works |
41
41
  | `os` | |
42
42
  | `process` | `process.cwd()`, `argv`, `env`, …; namespace dispatch too |
@@ -50,12 +50,13 @@ resolve to the same implementation.
50
50
  | `util`, `querystring`, `url`, `assert`, `test`, `zlib` | |
51
51
 
52
52
  Coverage per module (exact functions and options) is in
53
- [../node-implemented.md](../node-implemented.md); what is missing is in
54
- [../node-unimplemented.md](../node-unimplemented.md).
53
+ [../implemented/node.md](../implemented/node.md); what is missing is in
54
+ [../unimplemented/node.md](../unimplemented/node.md).
55
55
 
56
56
  Remember the runtime model before building on `net`/`http`: the event loop runs
57
- **after** the program body, but `async`/`await` now suspends on pending promises,
58
- so a promise settled from a socket callback can be awaited. See
57
+ **after** the program body, but `async`/`await` suspends on pending promises, so a
58
+ promise settled from a socket callback, a timer or an offloaded file/HTTP job can
59
+ be awaited. `net.connect` itself is still blocking. See
59
60
  [language-support.md](./language-support.md).
60
61
 
61
62
  ### `gui` — HTML/CSS window
@@ -93,9 +94,11 @@ its limits.
93
94
  ## Third-party npm packages
94
95
 
95
96
  Bare specifiers that no enabled extension claims are looked up in `node_modules`
96
- and bundled **as source**. A package that is not plain ESM TypeScript/JavaScript
97
- — or that relies on CommonJS, `require`, `__dirname`, or circular dependencies —
98
- will not work. `require()` is rejected with a hint to convert to `import`.
97
+ and bundled **as source**, including CommonJS packages (the bundler gives them a
98
+ synthetic `module`/`exports` and lowers their `require` calls). What does not
99
+ work: dynamic `require(<expression>)`, packages that depend on Node globals such
100
+ as `__dirname`, and circular dependencies. `require()` in your own source is
101
+ rejected with a hint to convert to `import`.
99
102
 
100
103
  Practical consequence: for a Node program, enabling `--ext node` is usually the
101
104
  right answer; reach for an npm dependency only when you must.
@@ -141,8 +144,8 @@ they wrap the argument and value helpers. Key ABI facts: values are 64-bit
141
144
  NaN-boxed words; strings are **not** NUL-terminated, so pair `xt_string_data`
142
145
  with `xt_string_length_value`; the runtime never moves or frees memory it handed
143
146
  out. Build with the same clang/ABI that xbintsc resolves (`xbintsc doctor`
144
- prints it), and on Windows build inside an **x64/ARM64 Native Tools Command
145
- Prompt**.
147
+ prints it). On Windows that must be an MSVC-targeting clang — normally the LLVM
148
+ bundled with Visual Studio; a developer prompt is not required.
146
149
 
147
150
  Working projects to copy: [`examples/extensions/cpp`](../../examples/extensions/cpp)
148
151
  and [`examples/extensions/rust`](../../examples/extensions/rust); the full guide
@@ -6,8 +6,8 @@ what you can write; follow the links for exact wording.
6
6
  Canonical detail (always current, much longer):
7
7
 
8
8
  - [../implemented.md](../implemented.md) — everything that works, by compiler stage
9
- - [../unimplemented.md](../unimplemented.md) — unsupported syntax, deviations, quick reference
10
- - [../node-implemented.md](../node-implemented.md) / [../node-unimplemented.md](../node-unimplemented.md) — the Node extension
9
+ - [../unimplemented.md](../unimplemented.md) — unsupported syntax and deviations, one page per area
10
+ - [../implemented/node.md](../implemented/node.md) / [../unimplemented/node.md](../unimplemented/node.md) — the Node extension
11
11
 
12
12
  > Chinese: [../zh-CN/implemented.md](../zh-CN/implemented.md), [../zh-CN/unimplemented.md](../zh-CN/unimplemented.md)
13
13
 
@@ -63,7 +63,7 @@ Canonical detail (always current, much longer):
63
63
  | `#private` fields / methods / statics | ⚠️ | stored under a literal `#x` key; no access enforcement; parent/child name collisions may alias |
64
64
  | `enum` / `const enum` | ✅ | forward + reverse mapping |
65
65
  | `private` / `protected` / `public` / `readonly` / `abstract` / `implements` | — | erased, no access control |
66
- | Generators `function*`, `yield`, `yield*` | ✅ | `async` generators are not supported |
66
+ | Generators `function*`, `yield`, `yield*` | ✅ | sync and `async function*`; `for await...of` and `Symbol.asyncIterator` |
67
67
  | `arguments` object | ✅ | implicit; arrows see their own parameters |
68
68
  | Argument-count validation | 🚫 | never checked, though `fn.length` reports declared arity |
69
69
 
@@ -71,11 +71,14 @@ Canonical detail (always current, much longer):
71
71
 
72
72
  | Feature | Status | Notes |
73
73
  | --- | --- | --- |
74
- | `async` / `await`, `Promise`, `Promise.all` | ✅ | real suspension: an `async` body runs on a stackful coroutine, and awaiting a **pending** promise pauses it until the promise settles. Awaiting an already-settled value still continues synchronously |
74
+ | `async` / `await`, `Promise`, `Promise.all` | ✅ | real suspension: an `async` body runs on a stackful coroutine, and awaiting a **pending** promise pauses it until the promise settles. Every `await` yields once, so a settled value or non-promise is queued as a microtask like Node |
75
75
  | `setTimeout` and callbacks | ✅ | timers run on the core event loop; `await new Promise(r => setTimeout(r, ms))` works |
76
+ | `queueMicrotask` / `setImmediate` / `performance.now` | ✅ | microtasks share the promise FIFO queue; `setImmediate` is a zero-delay timer with numeric ids; `performance.now` is monotonic fractional milliseconds |
76
77
  | Sockets / servers (`http`, `net`, `dgram`) | ✅ | callbacks run on the event loop and can settle a promise you await (`net` / `http` examples included in the tests) |
77
- | `fs/promises` | ⚠️ | awaitable, but each call performs its I/O synchronously before settling, so it does not yield while the I/O runs |
78
- | `async` generators, worker threads | 🚫 | `async function*` is rejected; workers are child processes |
78
+ | `fs/promises` | ✅ | file, directory and `FileHandle` operations run on the async I/O worker pool and settle on the reactor, so timers and sockets keep running while they wait |
79
+ | Global `fetch` | ✅ | HTTP/1.1 client whose connect/send/receive runs on the same worker pool; `await fetch(...)` yields and redirects are followed on the reactor. `http://` only (no TLS) and the body is buffered before resolving |
80
+ | Worker threads | 🚫 | workers are child processes |
81
+ | `async` generators | ✅ | suspend at `await` and `yield`; every `.next()` returns a promise; `for await...of` supported |
79
82
 
80
83
  ## Types: parsed, then erased
81
84
 
@@ -95,7 +98,7 @@ behaviour is checked. Write the runtime code you mean.
95
98
 
96
99
  ## Standard library
97
100
 
98
- Implemented: `Math`, `JSON`, `Date`, `RegExp`, `Map`, `Set`, `WeakMap`/`WeakSet`,
101
+ Implemented: `Math`, `JSON`, `Date`, `RegExp`, `Map`, `Set`, `WeakMap`/`WeakSet`/`WeakRef`,
99
102
  `Symbol`, `Error` family, `BigInt`, `Array`/`String`/`Number`/`Object` methods,
100
103
  typed arrays, `String.prototype.match`/`split`/`replace` with capture groups,
101
104
  immutable array helpers (`toReversed`, `toSorted`, `toSpliced`, `with`), global
@@ -105,12 +108,13 @@ URI functions, first-class built-in constructors (`const A = Array; new A(...)`,
105
108
 
106
109
  | Missing or different | Status |
107
110
  | --- | --- |
108
- | `String.prototype.normalize`, `structuredClone` | 🚫 |
111
+ | `String.prototype.normalize` | 🚫 |
112
+ | `structuredClone` | ✅ arrays, objects, Map, Set, Date, RegExp and typed arrays |
109
113
  | `Error.stack` capture | ⚠️ function-level frames (name/file/line), no columns; generator bodies are omitted |
110
114
  | Global RegExp `lastIndex` | ⚠️ `test`/`exec` ignore it for `/g` and `/y` |
111
115
  | Sparse array holes, array out-of-bounds | ⚠️ holes are not tracked distinctly; out-of-bounds reads give `undefined` |
112
116
 
113
- See section 3 of [../unimplemented.md](../unimplemented.md) for the full list.
117
+ See [Unimplemented: standard library](../unimplemented/stdlib.md) for the full list.
114
118
 
115
119
  ## Modules
116
120
 
@@ -120,9 +124,9 @@ See section 3 of [../unimplemented.md](../unimplemented.md) for the full list.
120
124
  | Relative multi-file bundling | ✅ | a `./helper.js` specifier resolves to `helper.ts` |
121
125
  | `import * as ns`, default and named imports | ✅ | |
122
126
  | Node built-in modules | ✅ | only with `--ext node` — see [extensions.md](./extensions.md) |
123
- | Bare third-party npm packages | 🚫 | `node_modules` ESM packages are bundled as source only when no extension claims the specifier |
124
- | `require()` / CommonJS | 🚫 | rejected with a hint to use `import` |
125
- | Circular dependencies | 🚫 | |
127
+ | Bare third-party npm packages | ⚠️ | resolved from `node_modules` and bundled as source (ESM and CommonJS); no runtime lookup, circular dependencies rejected |
128
+ | `require()` / CommonJS | ⚠️ | rejected in your own source with a hint to use `import`; CommonJS packages inside `node_modules` are bundled |
129
+ | Circular dependencies | 🚫 | value imports only; `import type` / `export type` are erased and never form an edge |
126
130
  | Live bindings | ⚠️ | imports and namespace members are snapshots |
127
131
  | `__dirname`, `__filename` | 🚫 | use `import.meta.dirname` / `import.meta.filename` |
128
132
 
@@ -134,13 +138,14 @@ See section 3 of [../unimplemented.md](../unimplemented.md) for the full list.
134
138
  | RegExp Unicode matching | ⚠️ the engine is byte-oriented: a literal `中` still matches, but `.` and character classes consume one byte per repetition, and `\d`/`\w` stay ASCII. Match offsets (`match.index`, `search`, replacement callbacks) are reported in UTF-16 code units |
135
139
  | Number formatting and coercion | ✅ matches Node (`toFixed`, `toPrecision`, hex/octal/binary parsing) |
136
140
  | `BigInt` | ✅ implemented |
137
- | Garbage collection | ✅ non-moving mark-sweep; explicit roots plus a conservative C-stack scan; single-threaded and stop-the-world; no weak references |
141
+ | Garbage collection | ✅ non-moving mark-sweep; explicit roots plus a conservative C-stack scan; single-threaded and stop-the-world. WeakMap/WeakSet keys use an ephemeron fixed point and WeakRef targets are cleared when unreachable; a stale conservative stack word can delay clearing |
138
142
  | Threads | 🚫 single-threaded; `worker_threads` exists in the Node extension only |
139
143
 
140
144
  ## Platform
141
145
 
142
146
  Builds target macOS, Linux and Windows on x64 and arm64. On Windows the target
143
- is the **MSVC ABI**, so clang needs the MSVC/SDK environment — see
147
+ is the **MSVC ABI**, so the compiler must be an MSVC-targeting clang (the LLVM
148
+ bundled with Visual Studio works) — see
144
149
  [../requirements.md](../requirements.md). clang **16 or newer** is required.
145
150
 
146
151
  ## Before you write a large program
@@ -47,12 +47,12 @@ it in `xbintsc.config.json` so it is always on:
47
47
  xbintsc run app.ts --ext node
48
48
  ```
49
49
 
50
- ### `module '<pkg>' is not supported: xbintsc can import built-in platform modules, relative '.ts' files and ESM packages under node_modules; CommonJS packages are not supported`
50
+ ### `module '<pkg>' is not supported: expected a Node built-in (with --ext node), a relative .ts/.js file, or a package in node_modules`
51
51
 
52
- A bare third-party import that nothing can link. Either the package is CommonJS
53
- (unsupported), or it is an ESM package that failed to bundle. Prefer a Node
54
- built-in from the `node` extension; see [extensions.md](./extensions.md) for
55
- what can actually be bundled.
52
+ A bare import that neither the enabled extensions nor `node_modules` resolved.
53
+ Check the package name and its `exports`/`main` map, or use a Node built-in from
54
+ the `node` extension; see [extensions.md](./extensions.md) for what can be
55
+ bundled.
56
56
 
57
57
  ### ``CommonJS `require()` is not supported``
58
58
 
@@ -98,8 +98,10 @@ clang itself failed. The thrown message includes the full clang command and its
98
98
  stderr — read the stderr, not just the first line. Frequent causes:
99
99
 
100
100
  - the toolchain is too old (see above);
101
- - on Windows, clang cannot find the MSVC/SDK headers or libraries because the
102
- environment was not imported. Run from an **x64 Native Tools Command Prompt
101
+ - on Windows, the resolved clang cannot find the MSVC/SDK headers or libraries.
102
+ `xbintsc doctor` shows the compiler and its target; prefer the LLVM bundled
103
+ with Visual Studio, which locates the SDK itself. If your installation still
104
+ needs the environment imported, run from an **x64 Native Tools Command Prompt
103
105
  for VS 2022** (or **ARM64 Native Tools** on Windows on ARM), or import it
104
106
  first:
105
107
  ```powershell
@@ -119,8 +121,8 @@ described in [../gui.md](../gui.md).
119
121
  ### `Icon file not found` / icon tools missing
120
122
 
121
123
  `--icon`/`app.icon` paths resolve against the config file's directory. On
122
- Windows, embedding a PE icon needs `llvm-rc` or `windres`; `doctor` reports which
123
- one was found, and a missing one is only fatal when an icon was requested.
124
+ Windows, embedding a PE icon needs `llvm-rc` (ships with LLVM); `doctor` reports
125
+ the resolved tool, and a missing one is only fatal when an icon was requested.
124
126
 
125
127
  ## Reading a stack trace
126
128
 
@@ -30,8 +30,9 @@ source.ts --词法分析--> tokens --语法分析--> AST --绑定--> 绑定后
30
30
  2. **类型全部被擦除,从不做类型检查。** 类型注解、接口、泛型、`as`/`satisfies`、
31
31
  非空断言 `!` 在运行时没有任何作用,也没有类型检查器会跑。只有真实的运行时
32
32
  行为才算数。
33
- 3. **Node 兼容是可选且不完整的。** Node 模块由 `node` 扩展提供(`--ext node`);
34
- 不支持直接 import 第三方 npm 包。
33
+ 3. **Node 兼容是可选且不完整的。** Node 内置模块由 `node` 扩展提供(`--ext node`);
34
+ `node_modules` 里的 npm 包在构建期解析并打包(ESM 和 CommonJS 都支持);
35
+ 运行时没有包查找,循环依赖会被拒绝。
35
36
 
36
37
  ## 选一条命令
37
38
 
@@ -9,13 +9,22 @@
9
9
  | --- | --- | --- |
10
10
  | `xbintsc build <file.ts>` | 编译为 `exe`(默认)、`obj` 或 `ir` | 需要,`--emit ir` 除外 |
11
11
  | `xbintsc run <file.ts> [-- args]` | 编译成可执行文件并运行 | 需要(且只支持 `--emit exe`) |
12
+ | `xbintsc watch <file.ts>` | 源码树变化时自动重新构建(Ctrl+C 退出) | 需要 |
12
13
  | `xbintsc emit <file.ts>` | 把 LLVM IR 打到 stdout,不写文件 | 不需要 |
14
+ | `xbintsc check <file.ts>` | 前端检查(语法、导入、支持的子集),不写文件 | 不需要 |
13
15
  | `xbintsc doctor` | 报告解析到的工具链、运行时与图标工具 | 仅在探测时需要 |
14
16
  | `xbintsc version` | 打印版本 | 不需要 |
15
17
  | `xbintsc help` | 打印帮助文本 | 不需要 |
16
18
 
19
+ `check` 不是类型检查器:类型注解会被擦除,所以通过 `check` 的程序仍可能在运行时出错。
20
+ 它能发现语法错误、无法解析的导入以及超出支持子集的写法,适合作为提交前或编辑器的快速门禁。
21
+
17
22
  任何命令加 `--help` 都会打印帮助并返回 0。未知命令会打印错误与帮助文本,返回 1。
18
23
 
24
+ `watch` 轮询入口文件所在目录(忽略 build 输出、`dist`、`coverage` 与 `node_modules`),
25
+ 每次变化后重新执行 `build`;它接受与 `build` 相同的参数。`node_modules` 里的包源码
26
+ 不会被监视,安装依赖后请重启 watch。
27
+
19
28
  ## 参数
20
29
 
21
30
  ```
@@ -35,8 +44,30 @@
35
44
  --verbose 打印进度信息
36
45
  --time 打印各构建阶段耗时
37
46
  --debug 生成调试信息(DWARF/CodeView)并保留帧指针
47
+ --lto 程序与运行时编译为 LTO bitcode,并用 lld 链接
48
+ --pgo-generate [dir] 构建插桩二进制,把 profile 写入 dir
49
+ --pgo-use [dir] 使用 --pgo-generate 收集的 profile 重新构建
50
+ --json 把诊断以 JSON 数组打到 stdout
51
+ ```
52
+
53
+ ### LTO 与 PGO
54
+
55
+ `--lto` 把生成的 IR 与 C 运行时都编译为 LLVM bitcode(`-flto`),并用 lld
56
+ (`-fuse-ld=lld`)链接,让 LLVM 能跨语言/运行时边界优化。需要安装 lld。
57
+
58
+ PGO 是两次构建的流程:
59
+
60
+ ```bash
61
+ xbintsc build app.ts --pgo-generate=profiles # 插桩二进制
62
+ ./build/app # 运行代表性负载
63
+ xbintsc build app.ts --pgo-use=profiles # 使用 profile 重新构建
38
64
  ```
39
65
 
66
+ `--pgo-use` 会用 `llvm-profdata` 合并 `.profraw`(优先 clang 旁边的副本,可用
67
+ `xbintsc_LLVM_PROFDATA` 覆盖),并向 clang 传 `-fprofile-use=<dir>`。profile 目录默认
68
+ 为 `<outDir>/pgo`。LTO 与 PGO 可以同时使用。`--pgo-use` 构建不会命中增量缓存,因为
69
+ profile 数据可能独立于源码变化。
70
+
40
71
  少数容易踩的解析细节:
41
72
 
42
73
  - `--flag=value` 与 `--flag value` 都支持。
@@ -56,6 +87,9 @@
56
87
  | `outDir` | string | 输出目录(默认 `build/`) |
57
88
  | `output` | string | 显式输出路径,覆盖 `outDir` |
58
89
  | `optimize` | `"0"|"1"|"2"|"3"` | 优化级别 |
90
+ | `lto` | boolean | 程序与运行时编译为 LTO bitcode,并用 lld 链接 |
91
+ | `pgo` | `"generate"|"use"` | 按 profile 优化的阶段 |
92
+ | `pgoDir` | string | Profile 目录(默认 `<outDir>/pgo`) |
59
93
  | `extensions` | string[] | 开启的内置扩展,如 `["node"]` |
60
94
  | `extNative` | string[] | 原生扩展清单路径 |
61
95
  | `force` | boolean | 忽略增量缓存 |
@@ -70,6 +104,7 @@ JSON schema:[xbintsc.config.schema.json](../../xbintsc.config.schema.json)。
70
104
  | --- | --- |
71
105
  | `xbintsc_CLANG` | 指定 clang,替代从 `PATH` 解析 |
72
106
  | `xbintsc_LINKER_ARGS` | 额外链接参数(如 `-fuse-ld=lld`) |
107
+ | `xbintsc_LLVM_PROFDATA` | 合并 PGO `.profraw` 所用的 `llvm-profdata` |
73
108
  | `xbintsc_CACHE_DIR` | 对象缓存目录(默认 `.xbintsc`) |
74
109
  | `xbintsc_PREFER_PREBUILT` | `0` 强制从源码编译运行时 |
75
110
  | `xbintsc_BINARY` | `bin/` 启动器应运行的原生编译器二进制 |
@@ -16,15 +16,11 @@ npm test # 单元测试 + 端到端测试
16
16
  (见 [troubleshooting.md](./troubleshooting.md))。`xbintsc emit` 既不需要 clang 也不需要
17
17
  运行时库,因此它是最快的内循环。
18
18
 
19
- 可选但推荐——安装仓库钩子:
20
-
21
- ```bash
22
- git config core.hooksPath .githooks
23
- ```
24
-
25
- `.githooks/pre-commit` **会在每次提交时把补丁版本号 +1**,并把 `package.json` 与
26
- `package-lock.json` 一起折进该提交(`npm version patch --no-git-tag-version`)。请预期
27
- 你的提交里会带版本号变更,不要对抗它。发布标签由 `release.yml` 创建,钩子从不打标签。
19
+ 可选:安装仓库钩子 `git config core.hooksPath .githooks`。它只在
20
+ `main`/`master` 上把补丁版本号 +1(同时更新 `package.json`、
21
+ `package-lock.json` 与 `src/driver/version.ts`)。功能分支从不改动这些文件,
22
+ 这正是两个功能分支不会在版本行上冲突的原因;不要在功能分支上改版本号。
23
+ 发布标签由 `release.yml` 创建,钩子从不打标签。
28
24
 
29
25
  ## 测试套件
30
26
 
@@ -70,7 +66,7 @@ gen2 --emit--> gen3.ll # 必须等于 ref.ll
70
66
  第二个推论是字符串模型:编译器自身源码文本在各代中必须含义一致。编译后的字符串以 UTF-8
71
67
  存储,但索引按 UTF-16 码元进行,所以自举后的 `readFileSync`(`--ext node`)交给扫描器的是
72
68
  字节串(一个码元一个字节,全部 `<= 0xFF`),而 Node 交给它的是同一个文件已解码后的文本——
73
- 读取源码文件一律走 `decodeUtf8`([src/diagnostics/utf8.ts](../../../src/diagnostics/utf8.ts)),
69
+ 读取源码文件一律走 `sourceTextBytes`([src/diagnostics/source-text.ts](../../../src/diagnostics/source-text.ts)),
74
70
  不要假设一个码元就是一个字节或一个字符。弄错的表现是:`gen2.ll` 里非 ASCII 字面量(比如提示语里的 `—`)
75
71
  被重新编码,这也正是这里逐字节比较 IR 而不是逐行比较的原因。
76
72
 
@@ -97,7 +93,7 @@ diff scratch/ref.ll scratch/gen2.ll
97
93
  - 字符串字面量会被驻留:每个不同字面量只在 `main` 中创建一次,存入 GC 根全局,
98
94
  每次使用只做一次 load;属性名因此不再逐次分配。
99
95
  - GC 是非移动标记清扫:新堆对象走 `xt_alloc`;值存活期间必须能从显式根槽、已注册的
100
- 根提供者(事件循环、微任务队列)或 C 栈保守扫描到达。只存在于未被扫描的 C 局部
96
+ 根提供者(事件循环、微任务队列、异步 I/O job 根)或 C 栈保守扫描到达。只存在于未被扫描的 C 局部
101
97
  变量里的值就是 bug。
102
98
 
103
99
  ## 修改运行时
@@ -111,7 +107,7 @@ npm run runtime # tsx scripts/build-runtime.ts -> runtime/lib/<os>-<a
111
107
  npm run runtime:clean # 删除 build/runtime-obj 与 runtime/lib
112
108
  ```
113
109
 
114
- 新增 C 文件时必须同时更新列出运行时源文件的地方([../../../src/driver/compiler.ts](../../../src/driver/compiler.ts)
110
+ 新增 C 文件时必须同时更新列出运行时源文件的地方([../../../src/driver/runtime-objects.ts](../../../src/driver/runtime-objects.ts)
115
111
  里的 `RUNTIME_SOURCES`),因为那份列表决定什么会被编译和链接。扩展的 C 源由扩展自己声明。
116
112
 
117
113
  ## 新增或扩展一个扩展
@@ -153,13 +149,18 @@ src/extensions/node/fs/index.ts runtime/ext_node/fs/read_file.c
153
149
 
154
150
  | 文档 | 何时更新 |
155
151
  | --- | --- |
156
- | [../../zh-CN/implemented.md](../../zh-CN/implemented.md) | 某特性开始可用 |
157
- | [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) | 出现或解除了某个限制 |
158
- | [../../zh-CN/node-implemented.md](../../zh-CN/node-implemented.md) / [../../zh-CN/node-unimplemented.md](../../zh-CN/node-unimplemented.md) | Node 模块覆盖变化 |
152
+ | [../../zh-CN/implemented/](../../zh-CN/implemented/) 中拥有该功能的页面 | 某特性开始可用 |
153
+ | [../../zh-CN/unimplemented/](../../zh-CN/unimplemented/) 中拥有该限制的页面 | 出现或解除了某个限制 |
154
+ | [../../zh-CN/implemented.md](../../zh-CN/implemented.md) / [../../zh-CN/unimplemented.md](../../zh-CN/unimplemented.md) | 新增整页时(在索引里加链接) |
155
+ | [../../zh-CN/implemented/node.md](../../zh-CN/implemented/node.md) / [../../zh-CN/unimplemented/node.md](../../zh-CN/unimplemented/node.md) | Node 模块覆盖变化 |
159
156
  | [language-support.md](./language-support.md) | 上述内容的 AI 摘要变化 |
160
157
  | [../../zh-CN/requirements.md](../../zh-CN/requirements.md) | 工具链或平台要求变化 |
161
158
  | [cli.md](./cli.md) | 参数、配置字段或环境变量变化 |
162
159
 
160
+ 每个功能域只拥有一个小页面,因此功能分支改自己领域的页面(以及它的中文翻译),
161
+ 而不是一份大文档。索引页的「改动应该写在哪一页?」表把改动映射到页面。
162
+ `tests/docs/structure.test.ts` 会检查每个英文页面都有中文对应页,且都被索引链接。
163
+
163
164
  中文翻译(`doc/zh-CN/`、`doc/ai/zh-CN/`)要与英文源同步;半翻译的页面比没有更糟,因为
164
165
  它会静默过期。
165
166
 
@@ -35,7 +35,7 @@ xbintsc run app.ts --ext node
35
35
  | 模块 | 说明 |
36
36
  | --- | --- |
37
37
  | `fs` | **仅同步 API**(`readFileSync`、`writeFileSync` 等);`fs/promises` 是独立模块 |
38
- | `fs/promises` | 基于 Promise 的文件 API |
38
+ | `fs/promises` | 基于 Promise 的文件 API;阻塞 I/O 跑在异步 I/O 线程池上并在 reactor 上 settle |
39
39
  | `path` | 同时接入命名空间分发,`path.join(...)` 可用 |
40
40
  | `os` | |
41
41
  | `process` | `process.cwd()`、`argv`、`env` 等;也接入命名空间分发 |
@@ -49,12 +49,13 @@ xbintsc run app.ts --ext node
49
49
  | `util`、`querystring`、`url`、`assert`、`test`、`zlib` | |
50
50
 
51
51
  各模块的具体覆盖(确切函数与选项)见
52
- [../../zh-CN/node-implemented.md](../../zh-CN/node-implemented.md),缺失项见
53
- [../../zh-CN/node-unimplemented.md](../../zh-CN/node-unimplemented.md)。
52
+ [../../zh-CN/implemented/node.md](../../zh-CN/implemented/node.md),缺失项见
53
+ [../../zh-CN/unimplemented/node.md](../../zh-CN/unimplemented/node.md)。
54
54
 
55
55
  在 `net`/`http` 上搭东西之前,先记住运行时模型:事件循环在**程序主体之后**才运行,
56
- 但 `async`/`await` 现在会在 pending Promise 上挂起,因此由套接字回调 settle 的 Promise
57
- 可以被 await。见 [language-support.md](./language-support.md)。
56
+ 但 `async`/`await` 会在 pending Promise 上挂起,因此由套接字回调、定时器或 offload 的
57
+ 文件/HTTP job settle 的 Promise 都可以 await。`net.connect` 本身仍是阻塞的。见
58
+ [language-support.md](./language-support.md)。
58
59
 
59
60
  ### `gui` —— HTML/CSS 窗口
60
61
 
@@ -82,9 +83,10 @@ Windows 唯一不支持的:Windows 的 `gui.a` 不构建 FFmpeg,媒体槽位
82
83
 
83
84
  ## 第三方 npm 包
84
85
 
85
- 没有被已启用扩展认领的裸说明符,会在 `node_modules` 里查找并**作为源码**打包。不是
86
- 纯 ESM TypeScript/JavaScript 的包——或依赖 CommonJS、`require`、`__dirname`、循环
87
- 依赖的包——都不会工作。`require()` 会被拒绝并提示改用 `import`。
86
+ 没有被已启用扩展认领的裸说明符,会在 `node_modules` 里查找并**作为源码**打包,
87
+ CommonJS 包也在支持范围内(打包器会给它合成 `module`/`exports`,并降级其中的
88
+ `require` 调用)。不支持的场景:动态 `require(<表达式>)`、依赖 `__dirname` 等 Node
89
+ 全局变量的包,以及循环依赖。自己源码里的 `require()` 会被拒绝并提示改用 `import`。
88
90
 
89
91
  实践结论:写 Node 程序时,正确做法通常就是开 `--ext node`;只有确实必要时才去依赖
90
92
  npm 包。
@@ -127,7 +129,8 @@ xbintsc build demo.ts --ext-native a.json,b.json # 多个
127
129
  与值的辅助函数。关键 ABI 事实:值是 64 位 NaN-boxed 字;字符串**不**以 NUL 结尾,
128
130
  所以要把 `xt_string_data` 与 `xt_string_length_value` 配对使用;运行时交给你的内存
129
131
  不会被移动或释放。请使用与 xbintsc 解析到的同一个 clang/ABI 构建(`xbintsc doctor`
130
- 会打印它);在 Windows 上要在 **x64/ARM64 Native Tools 命令提示符**里构建。
132
+ 会打印它)。Windows 上必须是面向 MSVC 的 clang,通常就是 Visual Studio 自带的
133
+ LLVM;不需要开发者命令提示符。
131
134
 
132
135
  可直接照抄的工程:[`examples/extensions/cpp`](../../../examples/extensions/cpp) 与
133
136
  [`examples/extensions/rust`](../../../examples/extensions/rust);完整指南见