xbintsc 0.6.18 → 0.6.22

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 (464) hide show
  1. package/dist/src/ast/common.d.ts +2 -2
  2. package/dist/src/ast/declarations.d.ts +2 -0
  3. package/dist/src/ast/expressions.d.ts +5 -0
  4. package/dist/src/ast/kinds.d.ts +2 -0
  5. package/dist/src/ast/kinds.js +2 -0
  6. package/dist/src/ast/kinds.js.map +1 -1
  7. package/dist/src/ast/types.d.ts +2 -0
  8. package/dist/src/binder/binder.d.ts +6 -0
  9. package/dist/src/binder/binder.js +13 -0
  10. package/dist/src/binder/binder.js.map +1 -1
  11. package/dist/src/binder/references.js +9 -2
  12. package/dist/src/binder/references.js.map +1 -1
  13. package/dist/src/checker/assignability.js +11 -3
  14. package/dist/src/checker/assignability.js.map +1 -1
  15. package/dist/src/checker/calls.js +4 -0
  16. package/dist/src/checker/calls.js.map +1 -1
  17. package/dist/src/checker/flow.js +16 -12
  18. package/dist/src/checker/flow.js.map +1 -1
  19. package/dist/src/checker/globals.js +3 -1
  20. package/dist/src/checker/globals.js.map +1 -1
  21. package/dist/src/checker/type-system.js +1 -0
  22. package/dist/src/checker/type-system.js.map +1 -1
  23. package/dist/src/checker/typecheck.js +8 -1
  24. package/dist/src/checker/typecheck.js.map +1 -1
  25. package/dist/src/cli/help.d.ts +1 -1
  26. package/dist/src/cli/main.js +4 -0
  27. package/dist/src/cli/main.js.map +1 -1
  28. package/dist/src/codegen/generator/calls/access.js +3 -1
  29. package/dist/src/codegen/generator/calls/access.js.map +1 -1
  30. package/dist/src/codegen/generator/calls/invocation.js +8 -4
  31. package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
  32. package/dist/src/codegen/generator/context.js +3 -3
  33. package/dist/src/codegen/generator/context.js.map +1 -1
  34. package/dist/src/codegen/generator/expressions/assignment.js +1 -0
  35. package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
  36. package/dist/src/codegen/generator/expressions/module-values.d.ts +21 -0
  37. package/dist/src/codegen/generator/expressions/module-values.js +84 -0
  38. package/dist/src/codegen/generator/expressions/module-values.js.map +1 -0
  39. package/dist/src/codegen/generator/expressions/primary.js +38 -6
  40. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  41. package/dist/src/codegen/generator/expressions.d.ts +2 -1
  42. package/dist/src/codegen/generator/expressions.js +2 -1
  43. package/dist/src/codegen/generator/expressions.js.map +1 -1
  44. package/dist/src/codegen/generator/module.js +16 -6
  45. package/dist/src/codegen/generator/module.js.map +1 -1
  46. package/dist/src/codegen/generator/state.js +6 -0
  47. package/dist/src/codegen/generator/state.js.map +1 -1
  48. package/dist/src/codegen/generator/statements/dispatch.js +10 -0
  49. package/dist/src/codegen/generator/statements/dispatch.js.map +1 -1
  50. package/dist/src/codegen/generator/tables.d.ts +7 -0
  51. package/dist/src/codegen/generator/tables.js +26 -0
  52. package/dist/src/codegen/generator/tables.js.map +1 -1
  53. package/dist/src/driver/build-key.d.ts +3 -0
  54. package/dist/src/driver/build-key.js +3 -1
  55. package/dist/src/driver/build-key.js.map +1 -1
  56. package/dist/src/driver/bundler/commonjs.js +9 -5
  57. package/dist/src/driver/bundler/commonjs.js.map +1 -1
  58. package/dist/src/driver/bundler/deferred.d.ts +1 -1
  59. package/dist/src/driver/bundler/deferred.js +2 -2
  60. package/dist/src/driver/bundler/deferred.js.map +1 -1
  61. package/dist/src/driver/bundler/dynamic-import.d.ts +30 -0
  62. package/dist/src/driver/bundler/dynamic-import.js +123 -0
  63. package/dist/src/driver/bundler/dynamic-import.js.map +1 -0
  64. package/dist/src/driver/bundler/graph.d.ts +1 -1
  65. package/dist/src/driver/bundler/graph.js +30 -12
  66. package/dist/src/driver/bundler/graph.js.map +1 -1
  67. package/dist/src/driver/bundler/merge.d.ts +1 -1
  68. package/dist/src/driver/bundler/merge.js +37 -55
  69. package/dist/src/driver/bundler/merge.js.map +1 -1
  70. package/dist/src/driver/bundler/namespace-import.d.ts +7 -0
  71. package/dist/src/driver/bundler/namespace-import.js +46 -0
  72. package/dist/src/driver/bundler/namespace-import.js.map +1 -0
  73. package/dist/src/driver/bundler/reexport-fixup.d.ts +14 -0
  74. package/dist/src/driver/bundler/reexport-fixup.js +92 -0
  75. package/dist/src/driver/bundler/reexport-fixup.js.map +1 -0
  76. package/dist/src/driver/bundler/resolve.d.ts +6 -5
  77. package/dist/src/driver/bundler/resolve.js +52 -6
  78. package/dist/src/driver/bundler/resolve.js.map +1 -1
  79. package/dist/src/driver/bundler/symbols.d.ts +4 -0
  80. package/dist/src/driver/bundler/symbols.js +12 -0
  81. package/dist/src/driver/bundler/symbols.js.map +1 -1
  82. package/dist/src/driver/bundler/types.d.ts +1 -0
  83. package/dist/src/driver/compiler.js +12 -1
  84. package/dist/src/driver/compiler.js.map +1 -1
  85. package/dist/src/driver/config.d.ts +14 -0
  86. package/dist/src/driver/config.js +40 -0
  87. package/dist/src/driver/config.js.map +1 -1
  88. package/dist/src/driver/frontend.d.ts +3 -1
  89. package/dist/src/driver/frontend.js +5 -4
  90. package/dist/src/driver/frontend.js.map +1 -1
  91. package/dist/src/driver/index.d.ts +2 -1
  92. package/dist/src/driver/index.js +1 -0
  93. package/dist/src/driver/index.js.map +1 -1
  94. package/dist/src/driver/options.d.ts +13 -1
  95. package/dist/src/driver/runtime-objects.d.ts +1 -1
  96. package/dist/src/driver/runtime-objects.js +2 -0
  97. package/dist/src/driver/runtime-objects.js.map +1 -1
  98. package/dist/src/driver/storage.d.ts +34 -0
  99. package/dist/src/driver/storage.js +67 -0
  100. package/dist/src/driver/storage.js.map +1 -0
  101. package/dist/src/driver/version.d.ts +1 -1
  102. package/dist/src/driver/version.js +1 -1
  103. package/dist/src/extensions/gui/features.d.ts +1 -1
  104. package/dist/src/extensions/gui/features.js +2 -2
  105. package/dist/src/extensions/gui/features.js.map +1 -1
  106. package/dist/src/extensions/gui/index.js +3 -1
  107. package/dist/src/extensions/gui/index.js.map +1 -1
  108. package/dist/src/extensions/node/async-hooks/index.d.ts +6 -0
  109. package/dist/src/extensions/node/async-hooks/index.js +19 -0
  110. package/dist/src/extensions/node/async-hooks/index.js.map +1 -0
  111. package/dist/src/extensions/node/buffer/index.js +2 -0
  112. package/dist/src/extensions/node/buffer/index.js.map +1 -1
  113. package/dist/src/extensions/node/child_process/index.js +10 -1
  114. package/dist/src/extensions/node/child_process/index.js.map +1 -1
  115. package/dist/src/extensions/node/console/index.d.ts +6 -0
  116. package/dist/src/extensions/node/console/index.js +34 -0
  117. package/dist/src/extensions/node/console/index.js.map +1 -0
  118. package/dist/src/extensions/node/constants/index.d.ts +6 -0
  119. package/dist/src/extensions/node/constants/index.js +27 -0
  120. package/dist/src/extensions/node/constants/index.js.map +1 -0
  121. package/dist/src/extensions/node/diagnostics-channel/index.d.ts +5 -0
  122. package/dist/src/extensions/node/diagnostics-channel/index.js +16 -0
  123. package/dist/src/extensions/node/diagnostics-channel/index.js.map +1 -0
  124. package/dist/src/extensions/node/dns/index.d.ts +5 -0
  125. package/dist/src/extensions/node/dns/index.js +14 -0
  126. package/dist/src/extensions/node/dns/index.js.map +1 -0
  127. package/dist/src/extensions/node/events/index.js +1 -0
  128. package/dist/src/extensions/node/events/index.js.map +1 -1
  129. package/dist/src/extensions/node/http/index.js +5 -1
  130. package/dist/src/extensions/node/http/index.js.map +1 -1
  131. package/dist/src/extensions/node/http2/index.d.ts +5 -0
  132. package/dist/src/extensions/node/http2/index.js +16 -0
  133. package/dist/src/extensions/node/http2/index.js.map +1 -0
  134. package/dist/src/extensions/node/index.js +36 -0
  135. package/dist/src/extensions/node/index.js.map +1 -1
  136. package/dist/src/extensions/node/module/index.d.ts +5 -0
  137. package/dist/src/extensions/node/module/index.js +15 -0
  138. package/dist/src/extensions/node/module/index.js.map +1 -0
  139. package/dist/src/extensions/node/os/index.js +4 -1
  140. package/dist/src/extensions/node/os/index.js.map +1 -1
  141. package/dist/src/extensions/node/path/index.js +9 -1
  142. package/dist/src/extensions/node/path/index.js.map +1 -1
  143. package/dist/src/extensions/node/perf_hooks/index.d.ts +6 -0
  144. package/dist/src/extensions/node/perf_hooks/index.js +15 -0
  145. package/dist/src/extensions/node/perf_hooks/index.js.map +1 -0
  146. package/dist/src/extensions/node/readline-promises/index.d.ts +5 -0
  147. package/dist/src/extensions/node/readline-promises/index.js +14 -0
  148. package/dist/src/extensions/node/readline-promises/index.js.map +1 -0
  149. package/dist/src/extensions/node/sqlite/index.d.ts +6 -0
  150. package/dist/src/extensions/node/sqlite/index.js +16 -0
  151. package/dist/src/extensions/node/sqlite/index.js.map +1 -0
  152. package/dist/src/extensions/node/stream/index.js +2 -0
  153. package/dist/src/extensions/node/stream/index.js.map +1 -1
  154. package/dist/src/extensions/node/stream-web/index.d.ts +5 -0
  155. package/dist/src/extensions/node/stream-web/index.js +17 -0
  156. package/dist/src/extensions/node/stream-web/index.js.map +1 -0
  157. package/dist/src/extensions/node/string-decoder/index.d.ts +5 -0
  158. package/dist/src/extensions/node/string-decoder/index.js +14 -0
  159. package/dist/src/extensions/node/string-decoder/index.js.map +1 -0
  160. package/dist/src/extensions/node/timers/index.d.ts +6 -0
  161. package/dist/src/extensions/node/timers/index.js +20 -0
  162. package/dist/src/extensions/node/timers/index.js.map +1 -0
  163. package/dist/src/extensions/node/timers-promises/index.d.ts +5 -0
  164. package/dist/src/extensions/node/timers-promises/index.js +15 -0
  165. package/dist/src/extensions/node/timers-promises/index.js.map +1 -0
  166. package/dist/src/extensions/node/tls/index.d.ts +5 -0
  167. package/dist/src/extensions/node/tls/index.js +16 -0
  168. package/dist/src/extensions/node/tls/index.js.map +1 -0
  169. package/dist/src/extensions/node/tty/index.d.ts +5 -0
  170. package/dist/src/extensions/node/tty/index.js +14 -0
  171. package/dist/src/extensions/node/tty/index.js.map +1 -0
  172. package/dist/src/extensions/node/url/index.js +1 -0
  173. package/dist/src/extensions/node/url/index.js.map +1 -1
  174. package/dist/src/extensions/node/util/index.js +15 -1
  175. package/dist/src/extensions/node/util/index.js.map +1 -1
  176. package/dist/src/extensions/node/util-types/index.d.ts +6 -0
  177. package/dist/src/extensions/node/util-types/index.js +26 -0
  178. package/dist/src/extensions/node/util-types/index.js.map +1 -0
  179. package/dist/src/extensions/node/worker_threads/index.js +1 -0
  180. package/dist/src/extensions/node/worker_threads/index.js.map +1 -1
  181. package/dist/src/extensions/node/zlib/compression.d.ts +10 -0
  182. package/dist/src/extensions/node/zlib/compression.js +44 -0
  183. package/dist/src/extensions/node/zlib/compression.js.map +1 -0
  184. package/dist/src/extensions/node/zlib/index.d.ts +5 -2
  185. package/dist/src/extensions/node/zlib/index.js +21 -2
  186. package/dist/src/extensions/node/zlib/index.js.map +1 -1
  187. package/dist/src/extensions/registry.d.ts +4 -1
  188. package/dist/src/extensions/registry.js +8 -2
  189. package/dist/src/extensions/registry.js.map +1 -1
  190. package/dist/src/extensions/storage.d.ts +22 -0
  191. package/dist/src/extensions/storage.js +50 -0
  192. package/dist/src/extensions/storage.js.map +1 -0
  193. package/dist/src/lexer/scanner/punctuation.js +8 -2
  194. package/dist/src/lexer/scanner/punctuation.js.map +1 -1
  195. package/dist/src/lexer/scanner/regex.d.ts +3 -1
  196. package/dist/src/lexer/scanner/regex.js +32 -22
  197. package/dist/src/lexer/scanner/regex.js.map +1 -1
  198. package/dist/src/lexer/scanner.d.ts +2 -0
  199. package/dist/src/lexer/scanner.js +8 -0
  200. package/dist/src/lexer/scanner.js.map +1 -1
  201. package/dist/src/lexer/token.d.ts +1 -0
  202. package/dist/src/lexer/token.js +2 -0
  203. package/dist/src/lexer/token.js.map +1 -1
  204. package/dist/src/parser/declarations/classes.js +7 -0
  205. package/dist/src/parser/declarations/classes.js.map +1 -1
  206. package/dist/src/parser/declarations/functions.js +8 -2
  207. package/dist/src/parser/declarations/functions.js.map +1 -1
  208. package/dist/src/parser/expressions.d.ts +2 -2
  209. package/dist/src/parser/expressions.js +32 -17
  210. package/dist/src/parser/expressions.js.map +1 -1
  211. package/dist/src/parser/helpers.js +1 -0
  212. package/dist/src/parser/helpers.js.map +1 -1
  213. package/dist/src/parser/literals.js +27 -0
  214. package/dist/src/parser/literals.js.map +1 -1
  215. package/dist/src/parser/statements.js +3 -0
  216. package/dist/src/parser/statements.js.map +1 -1
  217. package/dist/src/parser/types.js +106 -45
  218. package/dist/src/parser/types.js.map +1 -1
  219. package/dist/tests/binder/binder.test.js +8 -1
  220. package/dist/tests/binder/binder.test.js.map +1 -1
  221. package/dist/tests/checker/checker.test.js +63 -0
  222. package/dist/tests/checker/checker.test.js.map +1 -1
  223. package/dist/tests/codegen/expressions.test.js +8 -0
  224. package/dist/tests/codegen/expressions.test.js.map +1 -1
  225. package/dist/tests/conformance/test262/manifest.js +9 -10
  226. package/dist/tests/conformance/test262/manifest.js.map +1 -1
  227. package/dist/tests/driver/bundler-resolve.test.js +22 -0
  228. package/dist/tests/driver/bundler-resolve.test.js.map +1 -1
  229. package/dist/tests/driver/config.test.js +46 -0
  230. package/dist/tests/driver/config.test.js.map +1 -1
  231. package/dist/tests/driver/deferred-reexport.test.d.ts +9 -0
  232. package/dist/tests/driver/deferred-reexport.test.js +62 -0
  233. package/dist/tests/driver/deferred-reexport.test.js.map +1 -0
  234. package/dist/tests/driver/link-features.test.js +4 -2
  235. package/dist/tests/driver/link-features.test.js.map +1 -1
  236. package/dist/tests/driver/modules.test.js +110 -11
  237. package/dist/tests/driver/modules.test.js.map +1 -1
  238. package/dist/tests/driver/storage.test.d.ts +1 -0
  239. package/dist/tests/driver/storage.test.js +29 -0
  240. package/dist/tests/driver/storage.test.js.map +1 -0
  241. package/dist/tests/e2e/compile-basics.test.js +11 -0
  242. package/dist/tests/e2e/compile-basics.test.js.map +1 -1
  243. package/dist/tests/e2e/compile-modules.test.js +40 -0
  244. package/dist/tests/e2e/compile-modules.test.js.map +1 -1
  245. package/dist/tests/e2e/compile-node.test.js +49 -0
  246. package/dist/tests/e2e/compile-node.test.js.map +1 -1
  247. package/dist/tests/e2e/compile-objects-classes.test.js +32 -0
  248. package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
  249. package/dist/tests/e2e/node-modules.test.js +174 -0
  250. package/dist/tests/e2e/node-modules.test.js.map +1 -1
  251. package/dist/tests/e2e/npm-modules.test.js +8 -0
  252. package/dist/tests/e2e/npm-modules.test.js.map +1 -1
  253. package/dist/tests/e2e/storage.test.d.ts +7 -0
  254. package/dist/tests/e2e/storage.test.js +86 -0
  255. package/dist/tests/e2e/storage.test.js.map +1 -0
  256. package/dist/tests/e2e/weak-collections.test.js +12 -0
  257. package/dist/tests/e2e/weak-collections.test.js.map +1 -1
  258. package/dist/tests/extensions/gui-features.test.js +1 -1
  259. package/dist/tests/extensions/gui-features.test.js.map +1 -1
  260. package/dist/tests/extensions/storage.test.d.ts +1 -0
  261. package/dist/tests/extensions/storage.test.js +50 -0
  262. package/dist/tests/extensions/storage.test.js.map +1 -0
  263. package/dist/tests/lexer/scanner.test.js +17 -0
  264. package/dist/tests/lexer/scanner.test.js.map +1 -1
  265. package/dist/tests/parser/declarations.test.js +24 -0
  266. package/dist/tests/parser/declarations.test.js.map +1 -1
  267. package/dist/tests/parser/expressions.test.js +34 -7
  268. package/dist/tests/parser/expressions.test.js.map +1 -1
  269. package/dist/tests/parser/literals.test.js +15 -0
  270. package/dist/tests/parser/literals.test.js.map +1 -1
  271. package/dist/tests/parser/types.test.js +26 -0
  272. package/dist/tests/parser/types.test.js.map +1 -1
  273. package/doc/ai/cli.md +2 -0
  274. package/doc/ai/extensions.md +26 -0
  275. package/doc/ai/language-support.md +4 -2
  276. package/doc/ai/zh-CN/cli.md +2 -0
  277. package/doc/ai/zh-CN/extensions.md +23 -0
  278. package/doc/ai/zh-CN/language-support.md +4 -2
  279. package/doc/gui/build.md +3 -3
  280. package/doc/gui/media.md +4 -4
  281. package/doc/gui.md +2 -2
  282. package/doc/implemented/extensions.md +1 -1
  283. package/doc/implemented/node/buffer.md +2 -0
  284. package/doc/implemented/node/child-process.md +29 -6
  285. package/doc/implemented/node/http.md +2 -0
  286. package/doc/implemented/node/os.md +1 -0
  287. package/doc/implemented/node/path.md +3 -0
  288. package/doc/implemented/node/stream.md +3 -0
  289. package/doc/implemented/node/util.md +1 -0
  290. package/doc/implemented/node/zlib.md +12 -1
  291. package/doc/implemented/node.md +8 -1
  292. package/doc/implemented/storage.md +64 -0
  293. package/doc/implemented/wasm.md +22 -0
  294. package/doc/implemented.md +3 -0
  295. package/doc/support-matrix.md +3 -3
  296. package/doc/unimplemented/node/modules.md +4 -3
  297. package/doc/unimplemented/stdlib.md +1 -0
  298. package/doc/unimplemented/wasm.md +15 -0
  299. package/doc/unimplemented.md +1 -0
  300. package/doc/xbintsc.config.schema.json +16 -1
  301. package/doc/zh-CN/gui/build.md +3 -3
  302. package/doc/zh-CN/gui/media.md +3 -3
  303. package/doc/zh-CN/gui.md +2 -2
  304. package/doc/zh-CN/implemented/extensions.md +1 -1
  305. package/doc/zh-CN/implemented/node/child-process.md +27 -5
  306. package/doc/zh-CN/implemented/node.md +1 -1
  307. package/doc/zh-CN/implemented/storage.md +51 -0
  308. package/doc/zh-CN/implemented/wasm.md +20 -0
  309. package/doc/zh-CN/implemented.md +3 -0
  310. package/doc/zh-CN/support-matrix.md +3 -3
  311. package/doc/zh-CN/unimplemented/node/modules.md +3 -2
  312. package/doc/zh-CN/unimplemented/stdlib.md +1 -0
  313. package/doc/zh-CN/unimplemented/wasm.md +14 -0
  314. package/doc/zh-CN/unimplemented.md +1 -0
  315. package/package.json +7 -7
  316. package/runtime/ext_gui/dom_api_form.cpp +10 -0
  317. package/runtime/ext_gui/gui_media.cpp +1 -1
  318. package/runtime/ext_gui/media.cpp +1 -1
  319. package/runtime/ext_gui/media_api.h +2 -2
  320. package/runtime/ext_node/async_hooks/async_hooks.c +59 -0
  321. package/runtime/ext_node/buffer/parts/static-api.inc +39 -0
  322. package/runtime/ext_node/child_process/spawn.c +201 -0
  323. package/runtime/ext_node/child_process/spawn.h +56 -0
  324. package/runtime/ext_node/child_process/spawn_posix.c +206 -0
  325. package/runtime/ext_node/child_process/spawn_win.c +276 -0
  326. package/runtime/ext_node/console/console.c +67 -0
  327. package/runtime/ext_node/constants/constants.c +72 -0
  328. package/runtime/ext_node/diagnostics_channel/diagnostics_channel.c +61 -0
  329. package/runtime/ext_node/dns/dns.c +77 -0
  330. package/runtime/ext_node/events/events.c +7 -0
  331. package/runtime/ext_node/http/http.c +38 -0
  332. package/runtime/ext_node/http2/http2.c +26 -0
  333. package/runtime/ext_node/module/module.c +31 -0
  334. package/runtime/ext_node/os/os.c +42 -0
  335. package/runtime/ext_node/path/path.c +93 -0
  336. package/runtime/ext_node/perf_hooks/perf_hooks.c +22 -0
  337. package/runtime/ext_node/readline_promises/readline_promises.c +59 -0
  338. package/runtime/ext_node/sqlite/sqlite.c +24 -0
  339. package/runtime/ext_node/stream/stream.c +19 -1
  340. package/runtime/ext_node/stream_web/stream_web.c +22 -0
  341. package/runtime/ext_node/string_decoder/string_decoder.c +31 -0
  342. package/runtime/ext_node/timers_promises/timers_promises.c +58 -0
  343. package/runtime/ext_node/tls/tls.c +26 -0
  344. package/runtime/ext_node/tty/tty.c +18 -0
  345. package/runtime/ext_node/util/util.c +84 -0
  346. package/runtime/ext_node/worker_threads/worker_threads.c +8 -0
  347. package/runtime/ext_node/zlib/miniz/compression_bridge.c +43 -0
  348. package/runtime/ext_node/zlib/miniz/miniz.c +646 -0
  349. package/runtime/ext_node/zlib/miniz/miniz.h +615 -0
  350. package/runtime/ext_node/zlib/miniz/miniz_common.h +89 -0
  351. package/runtime/ext_node/zlib/miniz/miniz_export.h +4 -0
  352. package/runtime/ext_node/zlib/miniz/miniz_tdef.c +1653 -0
  353. package/runtime/ext_node/zlib/miniz/miniz_tdef.h +206 -0
  354. package/runtime/ext_node/zlib/miniz/miniz_tinfl.c +778 -0
  355. package/runtime/ext_node/zlib/miniz/miniz_tinfl.h +150 -0
  356. package/runtime/ext_node/zlib/miniz/miniz_zip.h +454 -0
  357. package/runtime/ext_node/zlib/zlib.c +194 -0
  358. package/runtime/xt_builtins.c +1 -0
  359. package/runtime/xt_constructors.c +5 -0
  360. package/runtime/xt_module_values.c +29 -0
  361. package/runtime/xt_storage/indexed_db.c +408 -0
  362. package/runtime/xt_storage/indexed_db_internal.h +26 -0
  363. package/runtime/xt_storage/indexed_db_store.c +305 -0
  364. package/runtime/xt_storage/sqlite3/sqlite3.c +271131 -0
  365. package/runtime/xt_storage/sqlite3/sqlite3.h +14447 -0
  366. package/runtime/xt_storage/storage.c +209 -0
  367. package/runtime/xt_storage/storage_internal.h +66 -0
  368. package/runtime/xt_weak.c +43 -0
  369. package/runtime/xt_webassembly.c +53 -0
  370. package/scripts/build-gui.ts +1 -1
  371. package/scripts/build-media.ts +2 -2
  372. package/scripts/check-file-length.ts +14 -0
  373. package/src/ast/common.ts +2 -0
  374. package/src/ast/declarations.ts +2 -0
  375. package/src/ast/expressions.ts +6 -0
  376. package/src/ast/kinds.ts +2 -0
  377. package/src/ast/types.ts +2 -0
  378. package/src/binder/binder.ts +13 -0
  379. package/src/binder/references.ts +9 -2
  380. package/src/checker/assignability.ts +12 -2
  381. package/src/checker/calls.ts +3 -0
  382. package/src/checker/flow.ts +13 -9
  383. package/src/checker/globals.ts +3 -0
  384. package/src/checker/type-system.ts +1 -0
  385. package/src/checker/typecheck.ts +8 -1
  386. package/src/cli/main.ts +4 -0
  387. package/src/codegen/generator/calls/access.ts +4 -1
  388. package/src/codegen/generator/calls/invocation.ts +8 -4
  389. package/src/codegen/generator/context.ts +5 -3
  390. package/src/codegen/generator/expressions/assignment.ts +1 -0
  391. package/src/codegen/generator/expressions/module-values.ts +105 -0
  392. package/src/codegen/generator/expressions/primary.ts +35 -5
  393. package/src/codegen/generator/expressions.ts +3 -0
  394. package/src/codegen/generator/module.ts +16 -5
  395. package/src/codegen/generator/state.ts +6 -0
  396. package/src/codegen/generator/statements/dispatch.ts +9 -0
  397. package/src/codegen/generator/tables.ts +27 -0
  398. package/src/driver/build-key.ts +6 -1
  399. package/src/driver/bundler/commonjs.ts +18 -5
  400. package/src/driver/bundler/deferred.ts +2 -1
  401. package/src/driver/bundler/dynamic-import.ts +135 -0
  402. package/src/driver/bundler/graph.ts +34 -19
  403. package/src/driver/bundler/merge.ts +38 -64
  404. package/src/driver/bundler/namespace-import.ts +59 -0
  405. package/src/driver/bundler/reexport-fixup.ts +102 -0
  406. package/src/driver/bundler/resolve.ts +49 -5
  407. package/src/driver/bundler/symbols.ts +13 -0
  408. package/src/driver/bundler/types.ts +1 -0
  409. package/src/driver/compiler.ts +14 -1
  410. package/src/driver/config.ts +55 -0
  411. package/src/driver/frontend.ts +13 -8
  412. package/src/driver/index.ts +8 -0
  413. package/src/driver/options.ts +13 -1
  414. package/src/driver/runtime-objects.ts +2 -0
  415. package/src/driver/storage.ts +84 -0
  416. package/src/driver/version.ts +1 -1
  417. package/src/extensions/gui/features.ts +2 -2
  418. package/src/extensions/gui/index.ts +3 -1
  419. package/src/extensions/node/async-hooks/index.ts +23 -0
  420. package/src/extensions/node/buffer/index.ts +2 -0
  421. package/src/extensions/node/child_process/index.ts +13 -1
  422. package/src/extensions/node/console/index.ts +44 -0
  423. package/src/extensions/node/constants/index.ts +34 -0
  424. package/src/extensions/node/diagnostics-channel/index.ts +20 -0
  425. package/src/extensions/node/dns/index.ts +18 -0
  426. package/src/extensions/node/events/index.ts +1 -0
  427. package/src/extensions/node/http/index.ts +5 -3
  428. package/src/extensions/node/http2/index.ts +20 -0
  429. package/src/extensions/node/index.ts +36 -0
  430. package/src/extensions/node/module/index.ts +19 -0
  431. package/src/extensions/node/os/index.ts +4 -3
  432. package/src/extensions/node/path/index.ts +9 -3
  433. package/src/extensions/node/perf_hooks/index.ts +19 -0
  434. package/src/extensions/node/readline-promises/index.ts +18 -0
  435. package/src/extensions/node/sqlite/index.ts +20 -0
  436. package/src/extensions/node/stream/index.ts +3 -0
  437. package/src/extensions/node/stream-web/index.ts +21 -0
  438. package/src/extensions/node/string-decoder/index.ts +18 -0
  439. package/src/extensions/node/timers/index.ts +27 -0
  440. package/src/extensions/node/timers-promises/index.ts +19 -0
  441. package/src/extensions/node/tls/index.ts +20 -0
  442. package/src/extensions/node/tty/index.ts +18 -0
  443. package/src/extensions/node/url/index.ts +1 -0
  444. package/src/extensions/node/util/index.ts +15 -3
  445. package/src/extensions/node/util-types/index.ts +33 -0
  446. package/src/extensions/node/worker_threads/index.ts +1 -0
  447. package/src/extensions/node/zlib/compression.ts +48 -0
  448. package/src/extensions/node/zlib/index.ts +23 -2
  449. package/src/extensions/registry.ts +8 -2
  450. package/src/extensions/storage.ts +57 -0
  451. package/src/lexer/scanner/punctuation.ts +7 -1
  452. package/src/lexer/scanner/regex.ts +31 -22
  453. package/src/lexer/scanner.ts +7 -0
  454. package/src/lexer/token.ts +2 -0
  455. package/src/parser/declarations/classes.ts +7 -0
  456. package/src/parser/declarations/functions.ts +9 -3
  457. package/src/parser/expressions.ts +29 -20
  458. package/src/parser/helpers.ts +1 -0
  459. package/src/parser/literals.ts +28 -0
  460. package/src/parser/statements.ts +3 -0
  461. package/src/parser/types.ts +106 -43
  462. /package/runtime/{ext_media → xt_media}/decode_audio.cpp +0 -0
  463. /package/runtime/{ext_media → xt_media}/media.cpp +0 -0
  464. /package/runtime/{ext_media → xt_media}/media_bridge.c +0 -0
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Node.js `diagnostics_channel` module for xbintsc.
3
+ *
4
+ * `channel(name)` / `tracingChannel(name)` return a channel object with the
5
+ * standard surface (`subscribe` / `unsubscribe` / `publish` / `hasSubscribers`).
6
+ * There is no real tracing backend, so subscriptions are dropped and publish is
7
+ * a no-op returning false.
8
+ */
9
+
10
+ #include "../node_common.h"
11
+
12
+ static xt_value channel_subscribe(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
13
+ (void)thisValue;
14
+ (void)env;
15
+ (void)argc;
16
+ (void)argv;
17
+ return XT_UNDEFINED;
18
+ }
19
+
20
+ static xt_value channel_unsubscribe(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
21
+ (void)thisValue;
22
+ (void)env;
23
+ (void)argc;
24
+ (void)argv;
25
+ return XT_FALSE;
26
+ }
27
+
28
+ static xt_value channel_publish(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
29
+ (void)thisValue;
30
+ (void)env;
31
+ (void)argc;
32
+ (void)argv;
33
+ return XT_FALSE;
34
+ }
35
+
36
+ static xt_value channel_has_subscribers(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
37
+ (void)thisValue;
38
+ (void)env;
39
+ (void)argc;
40
+ (void)argv;
41
+ return XT_FALSE;
42
+ }
43
+
44
+ static xt_value diagnostics_channel_object(void) {
45
+ xt_value channel = xt_object_new();
46
+ xt_node_set(channel, "subscribe", xt_closure_new((void *)channel_subscribe, 0, NULL));
47
+ xt_node_set(channel, "unsubscribe", xt_closure_new((void *)channel_unsubscribe, 0, NULL));
48
+ xt_node_set(channel, "publish", xt_closure_new((void *)channel_publish, 0, NULL));
49
+ xt_node_set(channel, "hasSubscribers", xt_closure_new((void *)channel_has_subscribers, 0, NULL));
50
+ return channel;
51
+ }
52
+
53
+ xt_value xt_diagnostics_channel_static(xt_value name, int32_t argc, xt_value *argv) {
54
+ (void)argc;
55
+ (void)argv;
56
+ const char *fn = xt_string_data(name);
57
+ if (fn && (strcmp(fn, "channel") == 0 || strcmp(fn, "tracingChannel") == 0)) {
58
+ return diagnostics_channel_object();
59
+ }
60
+ return XT_UNDEFINED;
61
+ }
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Node.js `dns` module for xbintsc.
3
+ *
4
+ * `lookup(hostname[, options], callback)` resolves synchronously through
5
+ * `getaddrinfo` and calls the callback with the resulting address records
6
+ * (each `{ address, family }`). This is enough for the common
7
+ * `lookup(host, { all: true }, cb)` style used by HTTP clients.
8
+ */
9
+
10
+ #include "../node_common.h"
11
+
12
+ #include <string.h>
13
+
14
+ #if defined(_WIN32)
15
+ #include <winsock2.h>
16
+ #include <ws2tcpip.h>
17
+ #else
18
+ #include <arpa/inet.h>
19
+ #include <netdb.h>
20
+ #include <netinet/in.h>
21
+ #include <sys/socket.h>
22
+ #endif
23
+
24
+ xt_value xt_dns_lookup(int32_t argc, xt_value *argv) {
25
+ const char *hostname = argc > 0 ? xt_string_data(xt_to_string(argv[0])) : NULL;
26
+ xt_value cb = xt_arg(argc, argv, argc - 1);
27
+
28
+ if (!hostname || hostname[0] == '\0') {
29
+ if (XT_IS_FUNCTION(cb)) {
30
+ xt_value error = xt_error_from_message("Error: getaddrinfo ENOTFOUND");
31
+ xt_closure_call(cb, 1, &error);
32
+ }
33
+ return XT_UNDEFINED;
34
+ }
35
+
36
+ struct addrinfo hints;
37
+ struct addrinfo *result = NULL;
38
+ memset(&hints, 0, sizeof(hints));
39
+ hints.ai_family = AF_UNSPEC;
40
+ hints.ai_socktype = SOCK_STREAM;
41
+
42
+ if (getaddrinfo(hostname, NULL, &hints, &result) != 0 || result == NULL) {
43
+ if (XT_IS_FUNCTION(cb)) {
44
+ xt_value error = xt_error_from_message("Error: getaddrinfo ENOTFOUND");
45
+ xt_closure_call(cb, 1, &error);
46
+ }
47
+ return XT_UNDEFINED;
48
+ }
49
+
50
+ xt_value addresses = xt_array_new(0, NULL);
51
+ for (struct addrinfo *ai = result; ai != NULL; ai = ai->ai_next) {
52
+ char buffer[64] = {0};
53
+ int family;
54
+ if (ai->ai_family == AF_INET) {
55
+ struct sockaddr_in *ipv4 = (struct sockaddr_in *)ai->ai_addr;
56
+ inet_ntop(AF_INET, &ipv4->sin_addr, buffer, sizeof(buffer));
57
+ family = 4;
58
+ } else if (ai->ai_family == AF_INET6) {
59
+ struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)ai->ai_addr;
60
+ inet_ntop(AF_INET6, &ipv6->sin6_addr, buffer, sizeof(buffer));
61
+ family = 6;
62
+ } else {
63
+ continue;
64
+ }
65
+ xt_value record = xt_object_new();
66
+ xt_node_set(record, "address", xt_string_from_cstr(buffer));
67
+ xt_node_set(record, "family", xt_number((double)family));
68
+ xt_array_push(addresses, record);
69
+ }
70
+ freeaddrinfo(result);
71
+
72
+ if (XT_IS_FUNCTION(cb)) {
73
+ xt_value args[2] = { XT_NULL, addresses };
74
+ xt_closure_call(cb, 2, args);
75
+ }
76
+ return XT_UNDEFINED;
77
+ }
@@ -263,6 +263,13 @@ xt_value xt_events_static(xt_value name, int32_t argc, xt_value *argv) {
263
263
  return xt_undefined();
264
264
  }
265
265
 
266
+ /* `events.defaultMaxListeners` read as a value: the default is 10. */
267
+ xt_value xt_events_default_max_listeners(int32_t argc, xt_value *argv) {
268
+ (void)argc;
269
+ (void)argv;
270
+ return xt_number(10);
271
+ }
272
+
266
273
  /* -- prototype ------------------------------------------------------------ */
267
274
 
268
275
  static xt_value xt_events_proto(void) {
@@ -33,3 +33,41 @@ static xt_value xt_http_client_finish(xt_value thisValue, xt_value env, int32_t
33
33
  #include "parts/server.inc"
34
34
  #include "parts/client.inc"
35
35
  #include "parts/prototypes.inc"
36
+
37
+ /* `http.IncomingMessage`: a constructor identity used by consumers that check
38
+ * `stream.constructor === IncomingMessage` to recognise a Node response. */
39
+ xt_value xt_http_incoming_message_ctor(int32_t argc, xt_value *argv) {
40
+ (void)argc;
41
+ (void)argv;
42
+ return xt_object_new();
43
+ }
44
+
45
+ /* `http.STATUS_CODES`: numeric code (as a string key) -> reason phrase. */
46
+ xt_value xt_http_status_codes_value(int32_t argc, xt_value *argv) {
47
+ (void)argc;
48
+ (void)argv;
49
+ static const struct {
50
+ const char *code;
51
+ const char *message;
52
+ } codes[] = {
53
+ {"100", "Continue"}, {"101", "Switching Protocols"},
54
+ {"200", "OK"}, {"201", "Created"}, {"202", "Accepted"}, {"204", "No Content"},
55
+ {"206", "Partial Content"},
56
+ {"300", "Multiple Choices"}, {"301", "Moved Permanently"}, {"302", "Found"},
57
+ {"304", "Not Modified"}, {"307", "Temporary Redirect"}, {"308", "Permanent Redirect"},
58
+ {"400", "Bad Request"}, {"401", "Unauthorized"}, {"403", "Forbidden"},
59
+ {"404", "Not Found"}, {"405", "Method Not Allowed"}, {"406", "Not Acceptable"},
60
+ {"408", "Request Timeout"}, {"409", "Conflict"}, {"410", "Gone"},
61
+ {"413", "Payload Too Large"}, {"414", "URI Too Long"}, {"415", "Unsupported Media Type"},
62
+ {"416", "Range Not Satisfiable"}, {"418", "I'm a Teapot"}, {"422", "Unprocessable Entity"},
63
+ {"425", "Too Early"}, {"426", "Upgrade Required"}, {"428", "Precondition Required"},
64
+ {"429", "Too Many Requests"}, {"431", "Request Header Fields Too Large"},
65
+ {"500", "Internal Server Error"}, {"501", "Not Implemented"}, {"502", "Bad Gateway"},
66
+ {"503", "Service Unavailable"}, {"504", "Gateway Timeout"}, {"505", "HTTP Version Not Supported"},
67
+ };
68
+ xt_value object = xt_object_new();
69
+ for (size_t i = 0; i < sizeof(codes) / sizeof(codes[0]); i++) {
70
+ xt_node_set(object, codes[i].code, xt_string_from_cstr(codes[i].message));
71
+ }
72
+ return object;
73
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Node.js `http2` module for xbintsc — a stub (HTTP/2 is not implemented).
3
+ */
4
+
5
+ #include "../node_common.h"
6
+
7
+ xt_value xt_http2_connect(int32_t argc, xt_value *argv) {
8
+ (void)argc;
9
+ (void)argv;
10
+ xt_throw(xt_error_from_message("Error: node:http2 is not supported in compiled binaries"));
11
+ return XT_UNDEFINED;
12
+ }
13
+
14
+ xt_value xt_http2_create_server(int32_t argc, xt_value *argv) {
15
+ (void)argc;
16
+ (void)argv;
17
+ xt_throw(xt_error_from_message("Error: node:http2 is not supported in compiled binaries"));
18
+ return XT_UNDEFINED;
19
+ }
20
+
21
+ xt_value xt_http2_create_secure_server(int32_t argc, xt_value *argv) {
22
+ (void)argc;
23
+ (void)argv;
24
+ xt_throw(xt_error_from_message("Error: node:http2 is not supported in compiled binaries"));
25
+ return XT_UNDEFINED;
26
+ }
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Node.js `module` module for xbintsc: `createRequire` and `isBuiltin`.
3
+ *
4
+ * A compiled binary has no runtime module loader, so `createRequire` returns a
5
+ * function that throws a clear error when called. `isBuiltin` reports whether a
6
+ * specifier is a known Node built-in, but since the binary already bundles
7
+ * every reachable module, it conservatively returns false.
8
+ */
9
+
10
+ #include "../node_common.h"
11
+
12
+ static xt_value module_require_stub(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
13
+ (void)thisValue;
14
+ (void)env;
15
+ (void)argc;
16
+ (void)argv;
17
+ xt_throw(xt_error_from_message("Error: require() is not supported in compiled binaries"));
18
+ return XT_UNDEFINED;
19
+ }
20
+
21
+ xt_value xt_module_create_require(int32_t argc, xt_value *argv) {
22
+ (void)argc;
23
+ (void)argv;
24
+ return xt_closure_new((void *)module_require_stub, 0, NULL);
25
+ }
26
+
27
+ xt_value xt_module_is_builtin(int32_t argc, xt_value *argv) {
28
+ (void)argc;
29
+ (void)argv;
30
+ return XT_FALSE;
31
+ }
@@ -174,3 +174,45 @@ xt_value xt_os_static(xt_value name, int32_t argc, xt_value *argv) {
174
174
  }
175
175
  return xt_undefined();
176
176
  }
177
+
178
+ /* `os.constants`: the errno and signal values programs read to map exit codes
179
+ * and file errors. POSIX numbering is used, matching Node on the Unix hosts. */
180
+ xt_value xt_os_constants_value(int32_t argc, xt_value *argv) {
181
+ (void)argc;
182
+ (void)argv;
183
+ xt_value object = xt_object_new();
184
+ xt_value errnoValues = xt_object_new();
185
+ const int errnos[][2] = {
186
+ { 1, 1 }, { 2, 2 }, { 9, 9 }, { 13, 13 }, { 17, 17 }, { 20, 20 },
187
+ { 21, 21 }, { 28, 28 }, { 32, 32 }, { 39, 39 }, { 48, 48 },
188
+ };
189
+ static const char *errnoNames[] = {
190
+ "EPERM", "ENOENT", "EBADF", "EACCES", "EEXIST", "ENOTDIR",
191
+ "EISDIR", "ENOSPC", "EPIPE", "ENOTEMPTY", "EADDRINUSE",
192
+ };
193
+ for (size_t i = 0; i < sizeof(errnos) / sizeof(errnos[0]); i++) {
194
+ xt_object_set(errnoValues, xt_string_from_cstr(errnoNames[i]), xt_number((double)errnos[i][1]));
195
+ }
196
+ xt_object_set(object, xt_string_from_cstr("errno"), errnoValues);
197
+
198
+ xt_value signals = xt_object_new();
199
+ const int signalNumbers[][2] = {
200
+ { 1, 1 }, { 2, 2 }, { 3, 3 }, { 4, 4 }, { 6, 6 }, { 7, 7 }, { 8, 8 },
201
+ { 9, 9 }, { 10, 10 }, { 11, 11 }, { 12, 12 }, { 13, 13 }, { 14, 14 },
202
+ { 15, 15 }, { 17, 17 }, { 18, 18 }, { 19, 19 }, { 20, 20 }, { 21, 21 },
203
+ { 22, 22 }, { 23, 23 }, { 24, 24 }, { 25, 25 }, { 26, 26 }, { 27, 27 },
204
+ { 28, 28 }, { 29, 29 }, { 31, 31 },
205
+ };
206
+ static const char *signalNames[] = {
207
+ "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGABRT", "SIGBUS", "SIGFPE",
208
+ "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM",
209
+ "SIGTERM", "SIGCHLD", "SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN",
210
+ "SIGTTOU", "SIGURG", "SIGXCPU", "SIGXFSZ", "SIGVTALRM", "SIGPROF",
211
+ "SIGWINCH", "SIGIO", "SIGSYS",
212
+ };
213
+ for (size_t i = 0; i < sizeof(signalNumbers) / sizeof(signalNumbers[0]); i++) {
214
+ xt_object_set(signals, xt_string_from_cstr(signalNames[i]), xt_number((double)signalNumbers[i][1]));
215
+ }
216
+ xt_object_set(object, xt_string_from_cstr("signals"), signals);
217
+ return object;
218
+ }
@@ -347,6 +347,35 @@ static xt_value xt_path_relative(const char *from, const char *to) {
347
347
  /* Dispatch */
348
348
  /* ------------------------------------------------------------------------- */
349
349
 
350
+ /** `path.parse(path)` -> `{ root, dir, base, ext, name }`. */
351
+ static xt_value xt_path_parse(const char *path) {
352
+ xt_value result = xt_object_new();
353
+ size_t root = xt_path_root_len(path);
354
+ char rootBuffer[4] = {0};
355
+ if (root > 0 && root < sizeof(rootBuffer)) {
356
+ memcpy(rootBuffer, path, root);
357
+ rootBuffer[root] = '\0';
358
+ }
359
+ xt_object_set(result, xt_string_from_cstr("root"), xt_string_from_cstr(rootBuffer));
360
+
361
+ xt_value dir = xt_path_dirname(path);
362
+ xt_object_set(result, xt_string_from_cstr("dir"), dir);
363
+ xt_value base = xt_path_basename(path, NULL);
364
+ xt_object_set(result, xt_string_from_cstr("base"), base);
365
+ xt_value ext = xt_path_extname(path);
366
+ xt_object_set(result, xt_string_from_cstr("ext"), ext);
367
+
368
+ const char *baseText = xt_string_data(base);
369
+ const char *extText = xt_string_data(ext);
370
+ size_t baseLength = strlen(baseText);
371
+ size_t extLength = strlen(extText);
372
+ xt_value name = (extLength > 0 && baseLength > extLength)
373
+ ? xt_string_new(baseText, baseLength - extLength)
374
+ : base;
375
+ xt_object_set(result, xt_string_from_cstr("name"), name);
376
+ return result;
377
+ }
378
+
350
379
  xt_value xt_path_static(xt_value name, int32_t argc, xt_value *argv) {
351
380
  const char *method = xt_string_data(name);
352
381
  if (!method) return xt_undefined();
@@ -381,5 +410,69 @@ xt_value xt_path_static(xt_value name, int32_t argc, xt_value *argv) {
381
410
  const char *to = argc > 1 ? xt_string_data(xt_to_string(argv[1])) : "";
382
411
  return xt_path_relative(from ? from : "", to ? to : "");
383
412
  }
413
+ if (strcmp(method, "toNamespacedPath") == 0) {
414
+ /* Namespaced paths only matter on Windows, where the C path module keeps
415
+ * POSIX semantics, so the path is already valid as-is. */
416
+ return argc > 0 ? xt_to_string(argv[0]) : xt_string_from_cstr("");
417
+ }
418
+ if (strcmp(method, "parse") == 0) {
419
+ const char *path = argc > 0 ? xt_string_data(xt_to_string(argv[0])) : "";
420
+ return xt_path_parse(path ? path : "");
421
+ }
384
422
  return xt_undefined();
385
423
  }
424
+
425
+ /* `path.sep` / `path.delimiter` read as values: the C path module always uses
426
+ * POSIX separators, which Windows accepts everywhere (see the header note). */
427
+ xt_value xt_path_sep_value(int32_t argc, xt_value *argv) {
428
+ (void)argc;
429
+ (void)argv;
430
+ return xt_string_from_cstr("/");
431
+ }
432
+
433
+ xt_value xt_path_delimiter_value(int32_t argc, xt_value *argv) {
434
+ (void)argc;
435
+ (void)argv;
436
+ return xt_string_from_cstr(":");
437
+ }
438
+
439
+ /* `path.posix` / `path.win32`: namespace objects whose methods dispatch to the
440
+ * same `xt_path_static` table, with the method name captured in the closure
441
+ * environment. xbintsc's path model uses POSIX separators on every platform,
442
+ * so the two names expose the same API for now (Windows-only code paths use it
443
+ * for their own comparisons). */
444
+ static xt_value xt_path_api_method(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
445
+ (void)thisValue;
446
+ return xt_path_static(xt_closure_env(env, 0), argc, argv);
447
+ }
448
+
449
+ static void xt_path_install_method(xt_value api, const char *method) {
450
+ xt_value captured[1] = { xt_string_from_cstr(method) };
451
+ xt_object_set(api, xt_string_from_cstr(method), xt_closure_new((void *)xt_path_api_method, 1, captured));
452
+ }
453
+
454
+ static xt_value xt_path_api_object(void) {
455
+ xt_value api = xt_object_new();
456
+ static const char *methods[] = {
457
+ "join", "resolve", "isAbsolute", "normalize", "dirname",
458
+ "basename", "extname", "relative", "toNamespacedPath", "parse",
459
+ };
460
+ for (size_t i = 0; i < sizeof(methods) / sizeof(methods[0]); i++) {
461
+ xt_path_install_method(api, methods[i]);
462
+ }
463
+ xt_object_set(api, xt_string_from_cstr("sep"), xt_string_from_cstr("/"));
464
+ xt_object_set(api, xt_string_from_cstr("delimiter"), xt_string_from_cstr(":"));
465
+ return api;
466
+ }
467
+
468
+ xt_value xt_path_posix_value(int32_t argc, xt_value *argv) {
469
+ (void)argc;
470
+ (void)argv;
471
+ return xt_path_api_object();
472
+ }
473
+
474
+ xt_value xt_path_win32_value(int32_t argc, xt_value *argv) {
475
+ (void)argc;
476
+ (void)argv;
477
+ return xt_path_api_object();
478
+ }
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Node.js `perf_hooks` module for xbintsc: the `performance` object.
3
+ */
4
+
5
+ #include "../node_common.h"
6
+
7
+ static xt_value perf_now(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
8
+ (void)thisValue;
9
+ (void)env;
10
+ (void)argc;
11
+ (void)argv;
12
+ return xt_number(xt_monotonic_ms());
13
+ }
14
+
15
+ xt_value xt_perf_hooks_performance_value(int32_t argc, xt_value *argv) {
16
+ (void)argc;
17
+ (void)argv;
18
+ xt_value object = xt_object_new();
19
+ xt_node_set(object, "now", xt_closure_new((void *)perf_now, 0, NULL));
20
+ xt_node_set(object, "timeOrigin", xt_number(0));
21
+ return object;
22
+ }
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Node.js `readline/promises` module for xbintsc.
3
+ *
4
+ * `createInterface` wraps the callback-based `readline` interface and exposes
5
+ * `question(query)` as a promise, plus the delegated `on`/`off`/`close`.
6
+ */
7
+
8
+ #include "../node_common.h"
9
+
10
+ xt_value xt_readline_create_interface(int32_t argc, xt_value *argv);
11
+
12
+ static xt_value rl_promises_question_cb(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
13
+ (void)thisValue;
14
+ xt_value resolve = xt_closure_env(env, 0);
15
+ xt_value answer = xt_arg(argc, argv, 0);
16
+ if (XT_IS_FUNCTION(resolve)) xt_closure_call(resolve, 1, &answer);
17
+ return XT_UNDEFINED;
18
+ }
19
+
20
+ static xt_value rl_promises_question_executor(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
21
+ (void)thisValue;
22
+ xt_value base = xt_closure_env(env, 0);
23
+ xt_value query = xt_closure_env(env, 1);
24
+ xt_value resolve = xt_arg(argc, argv, 0);
25
+ xt_value cbEnv[1] = { resolve };
26
+ xt_value cb = xt_closure_new((void *)rl_promises_question_cb, 1, cbEnv);
27
+ xt_value question = xt_object_get_cstr(base, "question");
28
+ if (XT_IS_FUNCTION(question)) {
29
+ xt_value args[2] = { query, cb };
30
+ xt_call_with_this(question, base, 2, args);
31
+ }
32
+ return XT_UNDEFINED;
33
+ }
34
+
35
+ static xt_value rl_promises_question(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
36
+ (void)thisValue;
37
+ xt_value base = xt_closure_env(env, 0);
38
+ xt_value query = xt_arg(argc, argv, 0);
39
+ xt_value executorEnv[2] = { base, query };
40
+ xt_value executor = xt_closure_new((void *)rl_promises_question_executor, 2, executorEnv);
41
+ xt_value ctorArgs[1] = { executor };
42
+ return xt_promise_ctor(1, ctorArgs);
43
+ }
44
+
45
+ xt_value xt_readline_promises_create_interface(int32_t argc, xt_value *argv) {
46
+ xt_value base = xt_readline_create_interface(argc, argv);
47
+ xt_value iface = xt_object_new();
48
+
49
+ xt_value on = xt_object_get_cstr(base, "on");
50
+ xt_value off = xt_object_get_cstr(base, "off");
51
+ xt_value close = xt_object_get_cstr(base, "close");
52
+ if (XT_IS_FUNCTION(on)) xt_node_set(iface, "on", on);
53
+ if (XT_IS_FUNCTION(off)) xt_node_set(iface, "off", off);
54
+ if (XT_IS_FUNCTION(close)) xt_node_set(iface, "close", close);
55
+
56
+ xt_value env[1] = { base };
57
+ xt_node_set(iface, "question", xt_closure_new((void *)rl_promises_question, 1, env));
58
+ return iface;
59
+ }
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Node.js `sqlite` module for xbintsc.
3
+ *
4
+ * SQLite is not linked, so `DatabaseSync` / `StatementSync` throw when
5
+ * constructed. undici's `SqliteCacheStore` only touches `node:sqlite` lazily
6
+ * and documents a constructor throw when the API is unavailable, so this keeps
7
+ * the module importable without pulling in a SQLite library.
8
+ */
9
+
10
+ #include "../node_common.h"
11
+
12
+ xt_value xt_sqlite_database_sync_ctor(int32_t argc, xt_value *argv) {
13
+ (void)argc;
14
+ (void)argv;
15
+ xt_throw(xt_error_from_message("Error: node:sqlite is not supported in compiled binaries"));
16
+ return XT_UNDEFINED;
17
+ }
18
+
19
+ xt_value xt_sqlite_statement_sync_ctor(int32_t argc, xt_value *argv) {
20
+ (void)argc;
21
+ (void)argv;
22
+ xt_throw(xt_error_from_message("Error: node:sqlite is not supported in compiled binaries"));
23
+ return XT_UNDEFINED;
24
+ }
@@ -27,6 +27,9 @@ static xt_value xt_stream_new(xt_stream_kind kind) {
27
27
  return stream;
28
28
  }
29
29
 
30
+ /* A fresh Readable stream for a host producer (e.g. child_process spawn). */
31
+ xt_value xt_stream_new_readable(void) { return xt_stream_new(XT_STREAM_READABLE); }
32
+
30
33
  static int xt_stream_kind_of(xt_value stream) {
31
34
  return (int)xt_to_number(xt_object_get_cstr(stream, "__kind"));
32
35
  }
@@ -47,7 +50,7 @@ static int xt_stream_has_data_listener(xt_value stream) {
47
50
 
48
51
  /* -- readable surface ----------------------------------------------------- */
49
52
 
50
- static xt_value xt_stream_deliver(xt_value stream, xt_value chunk) {
53
+ xt_value xt_stream_deliver(xt_value stream, xt_value chunk) {
51
54
  if (xt_stream_has_data_listener(stream)) {
52
55
  xt_node_emit1(stream, "data", chunk);
53
56
  } else {
@@ -358,6 +361,21 @@ xt_value xt_stream_static(xt_value name, int32_t argc, xt_value *argv) {
358
361
  xt_node_emit0(stream, "end");
359
362
  return stream;
360
363
  }
364
+ if (strcmp(fn, "isReadable") == 0) {
365
+ /* A Duplex/Transform/PassThrough is also readable; only a pure Writable is not. */
366
+ return xt_bool(xt_stream_kind_of(xt_arg(argc, argv, 0)) != XT_STREAM_WRITABLE);
367
+ }
368
+ if (strcmp(fn, "isErrored") == 0 || strcmp(fn, "isDisturbed") == 0) {
369
+ /* The synchronous stream model does not track these states. */
370
+ return XT_FALSE;
371
+ }
372
+ if (strcmp(fn, "finished") == 0 || strcmp(fn, "pipeline") == 0) {
373
+ /* Streams deliver synchronously, so the operation is already complete: call
374
+ * the trailing callback with no error. */
375
+ xt_value cb = xt_arg(argc, argv, argc - 1);
376
+ if (XT_IS_FUNCTION(cb)) xt_closure_call(cb, 0, NULL);
377
+ return XT_UNDEFINED;
378
+ }
361
379
  return xt_undefined();
362
380
  }
363
381
 
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Node.js `stream/web` module for xbintsc.
3
+ *
4
+ * WHATWG streams are not implemented. `ReadableStreamTee` is exported as
5
+ * `undefined` so the `ReadableStreamTee?.(...) ?? body.stream.tee()` pattern in
6
+ * undici falls back to the body's own `tee`; the stream constructors throw.
7
+ */
8
+
9
+ #include "../node_common.h"
10
+
11
+ xt_value xt_stream_web_tee(int32_t argc, xt_value *argv) {
12
+ (void)argc;
13
+ (void)argv;
14
+ return XT_UNDEFINED;
15
+ }
16
+
17
+ xt_value xt_stream_web_unsupported_ctor(int32_t argc, xt_value *argv) {
18
+ (void)argc;
19
+ (void)argv;
20
+ xt_throw(xt_error_from_message("Error: node:stream/web is not supported in compiled binaries"));
21
+ return XT_UNDEFINED;
22
+ }
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Node.js `string_decoder` module for xbintsc.
3
+ *
4
+ * `StringDecoder` decodes Buffer chunks to a UTF-8 string. Incomplete multi-byte
5
+ * sequences across chunk boundaries are currently passed through unchanged (the
6
+ * module does not yet buffer a split character across `write` calls).
7
+ */
8
+
9
+ #include "../node_common.h"
10
+
11
+ int xt_node_is_buffer(xt_value value);
12
+ unsigned char *xt_node_buffer_bytes(xt_value value, size_t *outLength);
13
+
14
+ static xt_value string_decoder_decode(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
15
+ (void)thisValue;
16
+ (void)env;
17
+ xt_value input = xt_arg(argc, argv, 0);
18
+ if (!xt_node_is_buffer(input)) return xt_string_from_cstr("");
19
+ size_t length = 0;
20
+ unsigned char *bytes = xt_node_buffer_bytes(input, &length);
21
+ return xt_string_new((const char *)bytes, length);
22
+ }
23
+
24
+ xt_value xt_string_decoder_ctor(int32_t argc, xt_value *argv) {
25
+ (void)argc;
26
+ (void)argv;
27
+ xt_value decoder = xt_object_new();
28
+ xt_node_set(decoder, "write", xt_closure_new((void *)string_decoder_decode, 0, NULL));
29
+ xt_node_set(decoder, "end", xt_closure_new((void *)string_decoder_decode, 0, NULL));
30
+ return decoder;
31
+ }
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Node.js `timers/promises` module for xbintsc.
3
+ *
4
+ * `setTimeout(ms[, value])` and `setImmediate([value])` return promises that
5
+ * settle through the core event loop's timers/immediates.
6
+ */
7
+
8
+ #include "../node_common.h"
9
+
10
+ static xt_value timers_promises_resolve(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
11
+ (void)thisValue;
12
+ (void)argc;
13
+ (void)argv;
14
+ xt_value resolve = xt_closure_env(env, 0);
15
+ xt_value value = xt_closure_env(env, 1);
16
+ if (XT_IS_FUNCTION(resolve)) xt_closure_call(resolve, 1, &value);
17
+ return XT_UNDEFINED;
18
+ }
19
+
20
+ static xt_value timers_promises_timeout_executor(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
21
+ (void)thisValue;
22
+ xt_value resolve = xt_arg(argc, argv, 0);
23
+ xt_value value = xt_closure_env(env, 0);
24
+ double ms = xt_to_number(xt_closure_env(env, 1));
25
+ xt_value callbackEnv[2] = { resolve, value };
26
+ xt_value callback = xt_closure_new((void *)timers_promises_resolve, 2, callbackEnv);
27
+ xt_value timeoutArgs[2] = { callback, xt_number(ms) };
28
+ xt_set_timeout(2, timeoutArgs);
29
+ return XT_UNDEFINED;
30
+ }
31
+
32
+ xt_value xt_timers_promises_set_timeout(int32_t argc, xt_value *argv) {
33
+ double ms = argc > 0 ? xt_to_number(argv[0]) : 0;
34
+ xt_value value = argc > 1 ? argv[1] : XT_UNDEFINED;
35
+ xt_value env[2] = { value, xt_number(ms) };
36
+ xt_value executor = xt_closure_new((void *)timers_promises_timeout_executor, 2, env);
37
+ xt_value ctorArgs[1] = { executor };
38
+ return xt_promise_ctor(1, ctorArgs);
39
+ }
40
+
41
+ static xt_value timers_promises_immediate_executor(xt_value thisValue, xt_value env, int32_t argc, xt_value *argv) {
42
+ (void)thisValue;
43
+ xt_value resolve = xt_arg(argc, argv, 0);
44
+ xt_value value = xt_closure_env(env, 0);
45
+ xt_value callbackEnv[2] = { resolve, value };
46
+ xt_value callback = xt_closure_new((void *)timers_promises_resolve, 2, callbackEnv);
47
+ xt_value immediateArgs[1] = { callback };
48
+ xt_set_immediate(1, immediateArgs);
49
+ return XT_UNDEFINED;
50
+ }
51
+
52
+ xt_value xt_timers_promises_set_immediate(int32_t argc, xt_value *argv) {
53
+ xt_value value = argc > 0 ? argv[0] : XT_UNDEFINED;
54
+ xt_value env[1] = { value };
55
+ xt_value executor = xt_closure_new((void *)timers_promises_immediate_executor, 1, env);
56
+ xt_value ctorArgs[1] = { executor };
57
+ return xt_promise_ctor(1, ctorArgs);
58
+ }