@alloy-js/core 0.24.0-dev.2 → 0.24.0-dev.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (506) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/dev/src/components/AccessExpression.test.js +1 -1
  3. package/dist/dev/src/components/AccessExpression.test.js.map +1 -1
  4. package/dist/dev/src/components/Output.js +3 -2
  5. package/dist/dev/src/components/Output.js.map +1 -1
  6. package/dist/dev/src/components/SourceFile.js.map +1 -1
  7. package/dist/dev/src/content-slot.test.js +1 -1
  8. package/dist/dev/src/content-slot.test.js.map +1 -1
  9. package/dist/dev/src/context.js +30 -3
  10. package/dist/dev/src/context.js.map +1 -1
  11. package/dist/dev/src/debug/diagnostics.test.js +1 -1
  12. package/dist/dev/src/debug/diagnostics.test.js.map +1 -1
  13. package/dist/dev/src/debug/effects.test.js +1 -1
  14. package/dist/dev/src/debug/effects.test.js.map +1 -1
  15. package/dist/dev/src/debug/file-streaming.js +103 -0
  16. package/dist/dev/src/debug/file-streaming.js.map +1 -0
  17. package/dist/dev/src/debug/files.test.js +4 -5
  18. package/dist/dev/src/debug/files.test.js.map +1 -1
  19. package/dist/dev/src/debug/index.js +4 -6
  20. package/dist/dev/src/debug/index.js.map +1 -1
  21. package/dist/dev/src/debug/message-format.test.js +50 -52
  22. package/dist/dev/src/debug/message-format.test.js.map +1 -1
  23. package/dist/dev/src/debug/render-tree-orphans.test.js +13 -23
  24. package/dist/dev/src/debug/render-tree-orphans.test.js.map +1 -1
  25. package/dist/dev/src/debug/render.js +529 -352
  26. package/dist/dev/src/debug/render.js.map +1 -1
  27. package/dist/dev/src/debug/render.test.js +171 -92
  28. package/dist/dev/src/debug/render.test.js.map +1 -1
  29. package/dist/dev/src/debug/trace-writer.js +127 -15
  30. package/dist/dev/src/debug/trace-writer.js.map +1 -1
  31. package/dist/dev/src/debug/trace.js +0 -36
  32. package/dist/dev/src/debug/trace.js.map +1 -1
  33. package/dist/dev/src/devtools/devtools-server.js +55 -32
  34. package/dist/dev/src/devtools/devtools-server.js.map +1 -1
  35. package/dist/dev/src/devtools-entry.browser.js.map +1 -1
  36. package/dist/dev/src/devtools-entry.js.map +1 -1
  37. package/dist/dev/src/diagnostics.js +19 -1
  38. package/dist/dev/src/diagnostics.js.map +1 -1
  39. package/dist/dev/src/index.js +5 -2
  40. package/dist/dev/src/index.js.map +1 -1
  41. package/dist/dev/src/jsx-runtime.js +14 -8
  42. package/dist/dev/src/jsx-runtime.js.map +1 -1
  43. package/dist/dev/src/output-types.js +2 -0
  44. package/dist/dev/src/output-types.js.map +1 -0
  45. package/dist/dev/src/reactivity.js +155 -13
  46. package/dist/dev/src/reactivity.js.map +1 -1
  47. package/dist/dev/src/render/get-string-width.js +61 -0
  48. package/dist/dev/src/render/get-string-width.js.map +1 -0
  49. package/dist/dev/src/render/index.js +2 -0
  50. package/dist/dev/src/render/index.js.map +1 -0
  51. package/dist/dev/src/render/node-context.js +7 -0
  52. package/dist/dev/src/render/node-context.js.map +1 -0
  53. package/dist/dev/src/render/node.js +386 -0
  54. package/dist/dev/src/render/node.js.map +1 -0
  55. package/dist/dev/src/render/printer-support.js +180 -0
  56. package/dist/dev/src/render/printer-support.js.map +1 -0
  57. package/dist/dev/src/render/printer.js +797 -0
  58. package/dist/dev/src/render/printer.js.map +1 -0
  59. package/dist/dev/src/render-error.js +79 -0
  60. package/dist/dev/src/render-error.js.map +1 -0
  61. package/dist/dev/src/render-output.js +209 -0
  62. package/dist/dev/src/render-output.js.map +1 -0
  63. package/dist/dev/src/runtime/create-intrinsic.js +53 -0
  64. package/dist/dev/src/runtime/create-intrinsic.js.map +1 -0
  65. package/dist/dev/src/runtime/fragment.js +21 -0
  66. package/dist/dev/src/runtime/fragment.js.map +1 -0
  67. package/dist/dev/src/runtime/index.js +13 -0
  68. package/dist/dev/src/runtime/index.js.map +1 -0
  69. package/dist/dev/src/runtime/insert.js +453 -0
  70. package/dist/dev/src/runtime/insert.js.map +1 -0
  71. package/dist/dev/src/runtime/intrinsic.js +1 -11
  72. package/dist/dev/src/runtime/intrinsic.js.map +1 -1
  73. package/dist/dev/src/scheduler.js +38 -14
  74. package/dist/dev/src/scheduler.js.map +1 -1
  75. package/dist/dev/src/stc.js +2 -0
  76. package/dist/dev/src/stc.js.map +1 -1
  77. package/dist/dev/src/sti.js +1 -1
  78. package/dist/dev/src/sti.js.map +1 -1
  79. package/dist/dev/src/symbols/symbol-slot.test.js +1 -1
  80. package/dist/dev/src/symbols/symbol-slot.test.js.map +1 -1
  81. package/dist/dev/src/test-render.js +78 -0
  82. package/dist/dev/src/test-render.js.map +1 -0
  83. package/dist/dev/src/utils.js +47 -35
  84. package/dist/dev/src/utils.js.map +1 -1
  85. package/dist/dev/test/babel-e2e.test.js +218 -0
  86. package/dist/dev/test/babel-e2e.test.js.map +1 -0
  87. package/dist/dev/test/components/block.test.js +1 -1
  88. package/dist/dev/test/components/block.test.js.map +1 -1
  89. package/dist/dev/test/components/copy-file.test.js +7 -7
  90. package/dist/dev/test/components/copy-file.test.js.map +1 -1
  91. package/dist/dev/test/components/update-file.test.js +1 -1
  92. package/dist/dev/test/components/update-file.test.js.map +1 -1
  93. package/dist/dev/test/components/wrap.test.js +1 -1
  94. package/dist/dev/test/components/wrap.test.js.map +1 -1
  95. package/dist/dev/test/control-flow/match.test.js +1 -1
  96. package/dist/dev/test/control-flow/match.test.js.map +1 -1
  97. package/dist/dev/test/control-flow/show.test.js +1 -1
  98. package/dist/dev/test/control-flow/show.test.js.map +1 -1
  99. package/dist/dev/test/lazy-isempty.test.js +6 -6
  100. package/dist/dev/test/lazy-isempty.test.js.map +1 -1
  101. package/dist/dev/test/node.test.js +80 -0
  102. package/dist/dev/test/node.test.js.map +1 -0
  103. package/dist/dev/test/output-e2e.test.js +194 -0
  104. package/dist/dev/test/output-e2e.test.js.map +1 -0
  105. package/dist/dev/test/reactivity/circular-reactives.test.js +1 -1
  106. package/dist/dev/test/reactivity/circular-reactives.test.js.map +1 -1
  107. package/dist/dev/test/reactivity/cleanup.test.js +1 -1
  108. package/dist/dev/test/reactivity/cleanup.test.js.map +1 -1
  109. package/dist/dev/test/rendering/memoization.test.js +6 -1
  110. package/dist/dev/test/rendering/memoization.test.js.map +1 -1
  111. package/dist/dev/test/rendering/render-output-diagnostics.test.js +102 -0
  112. package/dist/dev/test/rendering/render-output-diagnostics.test.js.map +1 -0
  113. package/dist/dev/test/runtime.test.js +385 -0
  114. package/dist/dev/test/runtime.test.js.map +1 -0
  115. package/dist/dev/test/tree-test-utils.js +16 -0
  116. package/dist/dev/test/tree-test-utils.js.map +1 -0
  117. package/dist/dev/test/utils.test.js +1 -1
  118. package/dist/dev/test/utils.test.js.map +1 -1
  119. package/dist/dev/testing/devtools-utils.js +1 -1
  120. package/dist/dev/testing/devtools-utils.js.map +1 -1
  121. package/dist/dev/testing/extend-expect.js +7 -33
  122. package/dist/dev/testing/extend-expect.js.map +1 -1
  123. package/dist/dev/testing/render.js +7 -17
  124. package/dist/dev/testing/render.js.map +1 -1
  125. package/dist/devtools/index.html +17 -17
  126. package/dist/src/components/AccessExpression.test.js +1 -1
  127. package/dist/src/components/AccessExpression.test.js.map +1 -1
  128. package/dist/src/components/Output.d.ts +1 -1
  129. package/dist/src/components/Output.d.ts.map +1 -1
  130. package/dist/src/components/Output.js +2 -1
  131. package/dist/src/components/Output.js.map +1 -1
  132. package/dist/src/components/ReferenceOrContent.d.ts +1 -1
  133. package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
  134. package/dist/src/components/SourceFile.d.ts +1 -1
  135. package/dist/src/components/SourceFile.d.ts.map +1 -1
  136. package/dist/src/components/SourceFile.js.map +1 -1
  137. package/dist/src/content-slot.test.js +1 -1
  138. package/dist/src/content-slot.test.js.map +1 -1
  139. package/dist/src/context/format-options.d.ts +1 -1
  140. package/dist/src/context/format-options.d.ts.map +1 -1
  141. package/dist/src/context.d.ts +9 -1
  142. package/dist/src/context.d.ts.map +1 -1
  143. package/dist/src/context.js +30 -3
  144. package/dist/src/context.js.map +1 -1
  145. package/dist/src/debug/diagnostics.test.js +1 -1
  146. package/dist/src/debug/diagnostics.test.js.map +1 -1
  147. package/dist/src/debug/effects.test.js +1 -1
  148. package/dist/src/debug/effects.test.js.map +1 -1
  149. package/dist/src/debug/file-streaming.d.ts +22 -0
  150. package/dist/src/debug/file-streaming.d.ts.map +1 -0
  151. package/dist/src/debug/file-streaming.js +103 -0
  152. package/dist/src/debug/file-streaming.js.map +1 -0
  153. package/dist/src/debug/files.test.js +4 -5
  154. package/dist/src/debug/files.test.js.map +1 -1
  155. package/dist/src/debug/index.d.ts +5 -7
  156. package/dist/src/debug/index.d.ts.map +1 -1
  157. package/dist/src/debug/index.js +4 -6
  158. package/dist/src/debug/index.js.map +1 -1
  159. package/dist/src/debug/message-format.test.js +16 -18
  160. package/dist/src/debug/message-format.test.js.map +1 -1
  161. package/dist/src/debug/render-tree-orphans.test.js +8 -18
  162. package/dist/src/debug/render-tree-orphans.test.js.map +1 -1
  163. package/dist/src/debug/render.d.ts +71 -21
  164. package/dist/src/debug/render.d.ts.map +1 -1
  165. package/dist/src/debug/render.js +529 -352
  166. package/dist/src/debug/render.js.map +1 -1
  167. package/dist/src/debug/render.test.js +137 -74
  168. package/dist/src/debug/render.test.js.map +1 -1
  169. package/dist/src/debug/trace-writer.d.ts +6 -1
  170. package/dist/src/debug/trace-writer.d.ts.map +1 -1
  171. package/dist/src/debug/trace-writer.js +127 -15
  172. package/dist/src/debug/trace-writer.js.map +1 -1
  173. package/dist/src/debug/trace.d.ts +0 -36
  174. package/dist/src/debug/trace.d.ts.map +1 -1
  175. package/dist/src/debug/trace.js +0 -36
  176. package/dist/src/debug/trace.js.map +1 -1
  177. package/dist/src/devtools/devtools-protocol.d.ts +34 -1
  178. package/dist/src/devtools/devtools-protocol.d.ts.map +1 -1
  179. package/dist/src/devtools/devtools-server.d.ts.map +1 -1
  180. package/dist/src/devtools/devtools-server.js +55 -32
  181. package/dist/src/devtools/devtools-server.js.map +1 -1
  182. package/dist/src/devtools-entry.browser.d.ts +1 -1
  183. package/dist/src/devtools-entry.browser.d.ts.map +1 -1
  184. package/dist/src/devtools-entry.browser.js.map +1 -1
  185. package/dist/src/devtools-entry.d.ts +1 -1
  186. package/dist/src/devtools-entry.d.ts.map +1 -1
  187. package/dist/src/devtools-entry.js.map +1 -1
  188. package/dist/src/diagnostics.d.ts +4 -0
  189. package/dist/src/diagnostics.d.ts.map +1 -1
  190. package/dist/src/diagnostics.js +19 -1
  191. package/dist/src/diagnostics.js.map +1 -1
  192. package/dist/src/index.d.ts +5 -2
  193. package/dist/src/index.d.ts.map +1 -1
  194. package/dist/src/index.js +5 -2
  195. package/dist/src/index.js.map +1 -1
  196. package/dist/src/jsx-runtime.d.ts +13 -4
  197. package/dist/src/jsx-runtime.d.ts.map +1 -1
  198. package/dist/src/jsx-runtime.js +14 -8
  199. package/dist/src/jsx-runtime.js.map +1 -1
  200. package/dist/src/output-types.d.ts +40 -0
  201. package/dist/src/output-types.d.ts.map +1 -0
  202. package/dist/src/output-types.js +2 -0
  203. package/dist/src/output-types.js.map +1 -0
  204. package/dist/src/reactivity.d.ts +49 -18
  205. package/dist/src/reactivity.d.ts.map +1 -1
  206. package/dist/src/reactivity.js +155 -13
  207. package/dist/src/reactivity.js.map +1 -1
  208. package/dist/src/render/get-string-width.d.ts +19 -0
  209. package/dist/src/render/get-string-width.d.ts.map +1 -0
  210. package/dist/src/render/get-string-width.js +61 -0
  211. package/dist/src/render/get-string-width.js.map +1 -0
  212. package/dist/src/render/index.d.ts +2 -0
  213. package/dist/src/render/index.d.ts.map +1 -0
  214. package/dist/src/render/index.js +2 -0
  215. package/dist/src/render/index.js.map +1 -0
  216. package/dist/src/render/node-context.d.ts +5 -0
  217. package/dist/src/render/node-context.d.ts.map +1 -0
  218. package/dist/src/render/node-context.js +7 -0
  219. package/dist/src/render/node-context.js.map +1 -0
  220. package/dist/src/render/node.d.ts +146 -0
  221. package/dist/src/render/node.d.ts.map +1 -0
  222. package/dist/src/render/node.js +386 -0
  223. package/dist/src/render/node.js.map +1 -0
  224. package/dist/src/render/printer-support.d.ts +50 -0
  225. package/dist/src/render/printer-support.d.ts.map +1 -0
  226. package/dist/src/render/printer-support.js +180 -0
  227. package/dist/src/render/printer-support.js.map +1 -0
  228. package/dist/src/render/printer.d.ts +35 -0
  229. package/dist/src/render/printer.d.ts.map +1 -0
  230. package/dist/src/render/printer.js +797 -0
  231. package/dist/src/render/printer.js.map +1 -0
  232. package/dist/src/render-error.d.ts +4 -0
  233. package/dist/src/render-error.d.ts.map +1 -0
  234. package/dist/src/render-error.js +79 -0
  235. package/dist/src/render-error.js.map +1 -0
  236. package/dist/src/render-output.d.ts +42 -0
  237. package/dist/src/render-output.d.ts.map +1 -0
  238. package/dist/src/render-output.js +209 -0
  239. package/dist/src/render-output.js.map +1 -0
  240. package/dist/src/runtime/component.d.ts +2 -2
  241. package/dist/src/runtime/component.d.ts.map +1 -1
  242. package/dist/src/runtime/create-intrinsic.d.ts +28 -0
  243. package/dist/src/runtime/create-intrinsic.d.ts.map +1 -0
  244. package/dist/src/runtime/create-intrinsic.js +53 -0
  245. package/dist/src/runtime/create-intrinsic.js.map +1 -0
  246. package/dist/src/runtime/fragment.d.ts +16 -0
  247. package/dist/src/runtime/fragment.d.ts.map +1 -0
  248. package/dist/src/runtime/fragment.js +21 -0
  249. package/dist/src/runtime/fragment.js.map +1 -0
  250. package/dist/src/runtime/index.d.ts +12 -0
  251. package/dist/src/runtime/index.d.ts.map +1 -0
  252. package/dist/src/runtime/index.js +13 -0
  253. package/dist/src/runtime/index.js.map +1 -0
  254. package/dist/src/runtime/insert.d.ts +29 -0
  255. package/dist/src/runtime/insert.d.ts.map +1 -0
  256. package/dist/src/runtime/insert.js +453 -0
  257. package/dist/src/runtime/insert.js.map +1 -0
  258. package/dist/src/runtime/intrinsic.d.ts +12 -29
  259. package/dist/src/runtime/intrinsic.d.ts.map +1 -1
  260. package/dist/src/runtime/intrinsic.js +1 -11
  261. package/dist/src/runtime/intrinsic.js.map +1 -1
  262. package/dist/src/scheduler.d.ts.map +1 -1
  263. package/dist/src/scheduler.js +38 -14
  264. package/dist/src/scheduler.js.map +1 -1
  265. package/dist/src/stc.d.ts.map +1 -1
  266. package/dist/src/stc.js +2 -0
  267. package/dist/src/stc.js.map +1 -1
  268. package/dist/src/sti.d.ts +7 -6
  269. package/dist/src/sti.d.ts.map +1 -1
  270. package/dist/src/sti.js +1 -1
  271. package/dist/src/sti.js.map +1 -1
  272. package/dist/src/symbols/symbol-slot.test.js +1 -1
  273. package/dist/src/symbols/symbol-slot.test.js.map +1 -1
  274. package/dist/src/test-render.d.ts +31 -0
  275. package/dist/src/test-render.d.ts.map +1 -0
  276. package/dist/src/test-render.js +78 -0
  277. package/dist/src/test-render.js.map +1 -0
  278. package/dist/src/utils.d.ts +1 -1
  279. package/dist/src/utils.d.ts.map +1 -1
  280. package/dist/src/utils.js +40 -28
  281. package/dist/src/utils.js.map +1 -1
  282. package/dist/src/write-output.d.ts +1 -1
  283. package/dist/src/write-output.d.ts.map +1 -1
  284. package/dist/test/babel-e2e.test.d.ts +13 -0
  285. package/dist/test/babel-e2e.test.d.ts.map +1 -0
  286. package/dist/test/babel-e2e.test.js +218 -0
  287. package/dist/test/babel-e2e.test.js.map +1 -0
  288. package/dist/test/components/block.test.js +1 -1
  289. package/dist/test/components/block.test.js.map +1 -1
  290. package/dist/test/components/copy-file.test.d.ts.map +1 -1
  291. package/dist/test/components/copy-file.test.js +1 -1
  292. package/dist/test/components/copy-file.test.js.map +1 -1
  293. package/dist/test/components/update-file.test.js +1 -1
  294. package/dist/test/components/update-file.test.js.map +1 -1
  295. package/dist/test/components/wrap.test.js +1 -1
  296. package/dist/test/components/wrap.test.js.map +1 -1
  297. package/dist/test/control-flow/match.test.js +1 -1
  298. package/dist/test/control-flow/match.test.js.map +1 -1
  299. package/dist/test/control-flow/show.test.js +1 -1
  300. package/dist/test/control-flow/show.test.js.map +1 -1
  301. package/dist/test/lazy-isempty.test.js +6 -6
  302. package/dist/test/lazy-isempty.test.js.map +1 -1
  303. package/dist/test/node.test.d.ts +2 -0
  304. package/dist/test/node.test.d.ts.map +1 -0
  305. package/dist/test/node.test.js +80 -0
  306. package/dist/test/node.test.js.map +1 -0
  307. package/dist/test/output-e2e.test.d.ts +13 -0
  308. package/dist/test/output-e2e.test.d.ts.map +1 -0
  309. package/dist/test/output-e2e.test.js +194 -0
  310. package/dist/test/output-e2e.test.js.map +1 -0
  311. package/dist/test/reactivity/circular-reactives.test.js +1 -1
  312. package/dist/test/reactivity/circular-reactives.test.js.map +1 -1
  313. package/dist/test/reactivity/cleanup.test.js +1 -1
  314. package/dist/test/reactivity/cleanup.test.js.map +1 -1
  315. package/dist/test/rendering/memoization.test.js +6 -1
  316. package/dist/test/rendering/memoization.test.js.map +1 -1
  317. package/dist/test/rendering/render-output-diagnostics.test.d.ts +2 -0
  318. package/dist/test/rendering/render-output-diagnostics.test.d.ts.map +1 -0
  319. package/dist/test/rendering/render-output-diagnostics.test.js +82 -0
  320. package/dist/test/rendering/render-output-diagnostics.test.js.map +1 -0
  321. package/dist/test/runtime.test.d.ts +11 -0
  322. package/dist/test/runtime.test.d.ts.map +1 -0
  323. package/dist/test/runtime.test.js +385 -0
  324. package/dist/test/runtime.test.js.map +1 -0
  325. package/dist/test/tree-test-utils.d.ts +3 -0
  326. package/dist/test/tree-test-utils.d.ts.map +1 -0
  327. package/dist/test/tree-test-utils.js +16 -0
  328. package/dist/test/tree-test-utils.js.map +1 -0
  329. package/dist/test/utils.test.js +1 -1
  330. package/dist/test/utils.test.js.map +1 -1
  331. package/dist/testing/devtools-utils.d.ts.map +1 -1
  332. package/dist/testing/devtools-utils.js +1 -1
  333. package/dist/testing/devtools-utils.js.map +1 -1
  334. package/dist/testing/extend-expect.d.ts.map +1 -1
  335. package/dist/testing/extend-expect.js +7 -33
  336. package/dist/testing/extend-expect.js.map +1 -1
  337. package/dist/testing/render.d.ts +7 -9
  338. package/dist/testing/render.d.ts.map +1 -1
  339. package/dist/testing/render.js +7 -17
  340. package/dist/testing/render.js.map +1 -1
  341. package/dist/tsconfig.tsbuildinfo +1 -1
  342. package/docs/api/components/Output.md +0 -3
  343. package/docs/api/components/SourceFile.md +0 -3
  344. package/docs/api/functions/createComment.md +18 -0
  345. package/docs/api/functions/createElement.md +19 -0
  346. package/docs/api/functions/createFragment.md +17 -0
  347. package/docs/api/functions/createTextNode.md +18 -0
  348. package/docs/api/functions/emitDiagnosticForTree.md +19 -0
  349. package/docs/api/functions/ensureIsEmpty.md +1 -1
  350. package/docs/api/functions/getContextForNode.md +18 -0
  351. package/docs/api/functions/getContextForRenderNode.md +4 -4
  352. package/docs/api/functions/getDiagnosticsForTree.md +7 -5
  353. package/docs/api/functions/getRegisteredDiagnosticsForTree.md +18 -0
  354. package/docs/api/functions/index.md +17 -12
  355. package/docs/api/functions/isCustomContext.md +4 -4
  356. package/docs/api/functions/notifyContentState.md +6 -0
  357. package/docs/api/functions/printTree.md +6 -16
  358. package/docs/api/functions/registerDiagnosticsForTree.md +19 -0
  359. package/docs/api/functions/render.md +1 -2
  360. package/docs/api/functions/renderAsync.md +1 -2
  361. package/docs/api/functions/renderTree.md +8 -5
  362. package/docs/api/functions/reportDiagnosticsForTree.md +18 -0
  363. package/docs/api/functions/runInContext.md +28 -0
  364. package/docs/api/functions/sourceFilesForTree.md +6 -16
  365. package/docs/api/index.md +3 -3
  366. package/docs/api/testing/functions/index.md +1 -1
  367. package/docs/api/testing/functions/renderToString.md +1 -1
  368. package/docs/api/types/AlloyNode.md +22 -0
  369. package/docs/api/types/Child.md +1 -1
  370. package/docs/api/types/CommentNode.md +15 -0
  371. package/docs/api/types/Context.md +13 -15
  372. package/docs/api/types/ElementNode.md +18 -0
  373. package/docs/api/types/FragmentNode.md +12 -0
  374. package/docs/api/types/Insertable.md +7 -0
  375. package/docs/api/types/NodeType.md +5 -0
  376. package/docs/api/types/OutputDirectory.md +0 -50
  377. package/docs/api/types/PrintTreeOptions.md +0 -1
  378. package/docs/api/types/RenderTreeOptions.md +7 -0
  379. package/docs/api/types/StiComponentCreator.md +4 -4
  380. package/docs/api/types/StiSignature.md +1 -1
  381. package/docs/api/types/TextNode.md +16 -0
  382. package/docs/api/types/index.md +10 -28
  383. package/docs/api/variables/COMMENT_NODE.md +5 -0
  384. package/docs/api/variables/ELEMENT_NODE.md +11 -0
  385. package/docs/api/variables/FRAGMENT_NODE.md +5 -0
  386. package/docs/api/variables/TEXT_NODE.md +5 -0
  387. package/docs/api/variables/index.md +4 -2
  388. package/docs/formatting.md +1 -1
  389. package/docs/rendering.md +4 -4
  390. package/package.json +6 -6
  391. package/src/components/AccessExpression.test.tsx +1 -1
  392. package/src/components/Output.tsx +2 -1
  393. package/src/components/SourceFile.tsx +1 -1
  394. package/src/content-slot.test.tsx +1 -1
  395. package/src/context/format-options.ts +1 -1
  396. package/src/context.ts +37 -4
  397. package/src/debug/diagnostics.test.tsx +1 -1
  398. package/src/debug/effects.test.tsx +1 -1
  399. package/src/debug/file-streaming.ts +115 -0
  400. package/src/debug/files.test.tsx +15 -11
  401. package/src/debug/index.ts +11 -11
  402. package/src/debug/message-format.test.tsx +32 -19
  403. package/src/debug/render-tree-orphans.test.tsx +10 -19
  404. package/src/debug/render.test.tsx +206 -78
  405. package/src/debug/render.ts +642 -495
  406. package/src/debug/trace-writer.ts +168 -14
  407. package/src/debug/trace.ts +0 -20
  408. package/src/devtools/devtools-protocol.ts +43 -0
  409. package/src/devtools/devtools-server.ts +57 -32
  410. package/src/devtools-entry.browser.ts +5 -0
  411. package/src/devtools-entry.ts +5 -0
  412. package/src/diagnostics.ts +31 -0
  413. package/src/index.ts +66 -2
  414. package/src/jsx-runtime.ts +16 -14
  415. package/src/output-types.ts +47 -0
  416. package/src/reactivity.ts +186 -40
  417. package/src/render/get-string-width.ts +201 -0
  418. package/src/render/index.ts +1 -0
  419. package/src/render/node-context.ts +14 -0
  420. package/src/render/node.ts +442 -0
  421. package/src/render/printer-support.ts +209 -0
  422. package/src/render/printer.ts +817 -0
  423. package/src/render-error.ts +98 -0
  424. package/src/render-output.ts +243 -0
  425. package/src/runtime/component.ts +2 -2
  426. package/src/runtime/create-intrinsic.ts +56 -0
  427. package/src/runtime/fragment.ts +22 -0
  428. package/src/runtime/index.ts +12 -0
  429. package/src/runtime/insert.ts +569 -0
  430. package/src/runtime/intrinsic.ts +14 -70
  431. package/src/scheduler.ts +40 -25
  432. package/src/stc.ts +3 -0
  433. package/src/sti.ts +17 -20
  434. package/src/symbols/symbol-slot.test.tsx +1 -1
  435. package/src/test-render.ts +103 -0
  436. package/src/utils.tsx +55 -37
  437. package/src/write-output.ts +1 -1
  438. package/temp/api-testing.json +390 -14
  439. package/temp/api.json +4320 -4144
  440. package/test/babel-e2e.test.ts +224 -0
  441. package/test/components/block.test.tsx +1 -1
  442. package/test/components/copy-file.test.tsx +2 -1
  443. package/test/components/update-file.test.tsx +1 -1
  444. package/test/components/wrap.test.tsx +1 -1
  445. package/test/control-flow/match.test.tsx +1 -1
  446. package/test/control-flow/show.test.tsx +1 -1
  447. package/test/lazy-isempty.test.tsx +6 -6
  448. package/test/node.test.ts +90 -0
  449. package/test/output-e2e.test.ts +198 -0
  450. package/test/reactivity/circular-reactives.test.tsx +1 -1
  451. package/test/reactivity/cleanup.test.tsx +1 -1
  452. package/test/rendering/memoization.test.tsx +6 -1
  453. package/test/rendering/render-output-diagnostics.test.tsx +120 -0
  454. package/test/runtime.test.ts +448 -0
  455. package/test/tree-test-utils.ts +23 -0
  456. package/test/utils.test.tsx +1 -1
  457. package/testing/devtools-utils.ts +2 -0
  458. package/testing/extend-expect.ts +8 -46
  459. package/testing/render.ts +17 -21
  460. package/dist/dev/src/print-hook.js +0 -10
  461. package/dist/dev/src/print-hook.js.map +0 -1
  462. package/dist/dev/src/render.js +0 -872
  463. package/dist/dev/src/render.js.map +0 -1
  464. package/dist/src/print-hook.d.ts +0 -14
  465. package/dist/src/print-hook.d.ts.map +0 -1
  466. package/dist/src/print-hook.js +0 -10
  467. package/dist/src/print-hook.js.map +0 -1
  468. package/dist/src/render.d.ts +0 -155
  469. package/dist/src/render.d.ts.map +0 -1
  470. package/dist/src/render.js +0 -872
  471. package/dist/src/render.js.map +0 -1
  472. package/docs/api/functions/createIntrinsic.md +0 -19
  473. package/docs/api/functions/createRenderTreeHook.md +0 -19
  474. package/docs/api/functions/getElementCache.md +0 -17
  475. package/docs/api/functions/isIntrinsicElement.md +0 -18
  476. package/docs/api/functions/isPrintHook.md +0 -18
  477. package/docs/api/types/AlignIntrinsicElement.md +0 -5
  478. package/docs/api/types/BrIntrinsicElement.md +0 -5
  479. package/docs/api/types/BreakParentIntrinsicElement.md +0 -5
  480. package/docs/api/types/DedentIntrinsicElement.md +0 -5
  481. package/docs/api/types/DedentToRootIntrinsicElement.md +0 -5
  482. package/docs/api/types/ElementCache.md +0 -5
  483. package/docs/api/types/ElementCacheKey.md +0 -5
  484. package/docs/api/types/FillIntrinsicElement.md +0 -5
  485. package/docs/api/types/GroupIntrinsicElement.md +0 -5
  486. package/docs/api/types/HardlineIntrinsicElement.md +0 -5
  487. package/docs/api/types/HbrIntrinsicElement.md +0 -5
  488. package/docs/api/types/IfBreakIntrinsicElement.md +0 -5
  489. package/docs/api/types/IndentIfBreakIntrinsicElement.md +0 -5
  490. package/docs/api/types/IndentIntrinsicElement.md +0 -5
  491. package/docs/api/types/IntrinsicElement.md +0 -5
  492. package/docs/api/types/IntrinsicElementBase.md +0 -9
  493. package/docs/api/types/LbrIntrinsicElement.md +0 -5
  494. package/docs/api/types/LineIntrinsicElement.md +0 -5
  495. package/docs/api/types/LineSuffixBoundaryIntrinsicElement.md +0 -5
  496. package/docs/api/types/LineSuffixIntrinsicElement.md +0 -5
  497. package/docs/api/types/LiterallineIntrinsicElement.md +0 -5
  498. package/docs/api/types/MarkAsRootIntrinsicElement.md +0 -5
  499. package/docs/api/types/PrintHook.md +0 -10
  500. package/docs/api/types/RenderedTextTree.md +0 -5
  501. package/docs/api/types/SbrIntrinsicElement.md +0 -5
  502. package/docs/api/types/SoftlineIntrinsicElement.md +0 -5
  503. package/docs/api/variables/intrinsicElementKey.md +0 -5
  504. package/docs/api/variables/printHookTag.md +0 -7
  505. package/src/print-hook.ts +0 -22
  506. package/src/render.ts +0 -1154
package/src/index.ts CHANGED
@@ -25,11 +25,69 @@ export * from "./context/index.js";
25
25
  export * from "./diagnostics.js";
26
26
  export * from "./library-symbol-reference.js";
27
27
  export * from "./name-policy.js";
28
+ export * from "./output-types.js";
28
29
  export * from "./props-combinators.js";
29
30
  export * from "./reactive-union-set.js";
30
- export * from "./reactivity.js";
31
+ export {
32
+ computed,
33
+ createCustomContext,
34
+ effect,
35
+ ensureIsEmpty,
36
+ findCurrentEffectId,
37
+ formatReactivePropertyLabel,
38
+ getContext,
39
+ getEffectDebugId,
40
+ getReactiveCreationLocation,
41
+ isCustomContext,
42
+ memo,
43
+ nextReactiveId,
44
+ notifyContentState,
45
+ onCleanup,
46
+ reactivePropertyRefId,
47
+ ref,
48
+ refId,
49
+ resetRefIdCounter,
50
+ root,
51
+ runInContext,
52
+ shallowReactive,
53
+ shallowRef,
54
+ toRef,
55
+ toRefs,
56
+ untrack,
57
+ type Context,
58
+ type CustomContext,
59
+ type CustomContextChildrenCallback,
60
+ type Disposable,
61
+ type EffectDebugOptions,
62
+ type EffectOptions,
63
+ type RootOptions,
64
+ } from "./reactivity.js";
31
65
  export * from "./refkey.js";
32
- export * from "./render.js";
66
+
67
+ export {
68
+ getContextForNode,
69
+ getContextForRenderNode,
70
+ render,
71
+ renderAsync,
72
+ sourceFilesForTree,
73
+ } from "./render-output.js";
74
+ export {
75
+ AlloyNode,
76
+ COMMENT_NODE,
77
+ CommentNode,
78
+ ELEMENT_NODE,
79
+ ElementNode,
80
+ FRAGMENT_NODE,
81
+ FragmentNode,
82
+ TEXT_NODE,
83
+ TextNode,
84
+ createComment,
85
+ createElement,
86
+ createFragment,
87
+ createTextNode,
88
+ type Insertable,
89
+ type NodeType,
90
+ } from "./render/node.js";
33
91
  export * from "./resource.js";
34
92
  export * from "./runtime/component.js";
35
93
  export * from "./runtime/intrinsic.js";
@@ -38,6 +96,12 @@ export * from "./sti.js";
38
96
  export * from "./symbols/index.js";
39
97
  export * from "./symbols/symbol-flow.js";
40
98
  export * from "./tap.js";
99
+ export {
100
+ getDiagnosticsForTree,
101
+ printTree,
102
+ renderTree,
103
+ type RenderTreeOptions,
104
+ } from "./test-render.js";
41
105
  export * from "./utils.js";
42
106
  export * from "./write-output.js";
43
107
  import "./debug/index.js";
@@ -1,24 +1,26 @@
1
- // Much of the implementations in this file are inspired by vuerx-js
2
- // See: https://github.com/ryansolid/vuerx-jsx.
1
+ /**
2
+ * JSX runtime.
3
+ *
4
+ * Imported by code compiled with `@alloy-js/babel-preset` (which sets the
5
+ * babel plugin's `moduleName` to `@alloy-js/core/jsx-runtime`). The
6
+ * auto-imported runtime helpers (`createComponent`, `createIntrinsic`,
7
+ * `memo`, `mergeProps`) resolve here, plus the `Children` type for
8
+ * manual imports.
9
+ */
10
+
3
11
  import type {
4
12
  Children,
5
13
  Component,
6
14
  ComponentDefinition,
7
15
  IntrinsicElements as CoreIntrinsicElements,
8
16
  } from "@alloy-js/core";
9
- import { createComponent } from "@alloy-js/core";
10
- export {
11
- createComponent,
12
- createIntrinsic,
13
- memo,
14
- mergeProps,
15
- type Children,
16
- } from "@alloy-js/core";
17
+ import { createComponent } from "./runtime/component.js";
18
+ export type { Children } from "@alloy-js/core";
19
+ export { mergeProps } from "./props-combinators.js";
20
+ export { memo } from "./reactivity.js";
21
+ export { createComponent } from "./runtime/component.js";
22
+ export { createIntrinsic } from "./runtime/create-intrinsic.js";
17
23
 
18
- /**
19
- * This namespace is predominantly for interop with React tooling in VSCode
20
- * and controls the type of JSX elements, components, and the like.
21
- */
22
24
  // eslint-disable-next-line @typescript-eslint/no-namespace
23
25
  export namespace JSX {
24
26
  export type IntrinsicElements = CoreIntrinsicElements;
@@ -0,0 +1,47 @@
1
+ export interface OutputDirectory {
2
+ kind: "directory";
3
+ /** Full path from the output root, e.g. `"generated-client/src"`. Do not prepend parent directory paths when walking the tree. */
4
+ path: string;
5
+ contents: (OutputDirectory | OutputFile)[];
6
+ }
7
+
8
+ export interface OutputFileBase {
9
+ kind: "file";
10
+ /** Full path from the output root, e.g. `"generated-client/src/models.ext"`. Do not prepend parent directory paths when walking the tree. */
11
+ path: string;
12
+ }
13
+
14
+ export interface CopyOutputFile extends OutputFileBase {
15
+ sourcePath: string;
16
+ }
17
+
18
+ export interface ContentOutputFile extends OutputFileBase {
19
+ contents: string;
20
+ filetype: string;
21
+ }
22
+
23
+ export type OutputFile = ContentOutputFile | CopyOutputFile;
24
+
25
+ export interface PrintTreeOptions {
26
+ /**
27
+ * The number of characters the printer will wrap on. Defaults to 100
28
+ * characters.
29
+ */
30
+ printWidth?: number;
31
+
32
+ /**
33
+ * Whether to use tabs instead of spaces for indentation. Defaults to false.
34
+ */
35
+ useTabs?: boolean;
36
+
37
+ /**
38
+ * The number of spaces to use for indentation. Defaults to 2 spaces.
39
+ */
40
+ tabWidth?: number;
41
+
42
+ /**
43
+ * If files should end with a final new line.
44
+ * @default true
45
+ */
46
+ insertFinalNewLine?: boolean;
47
+ }
package/src/reactivity.ts CHANGED
@@ -15,7 +15,6 @@ import {
15
15
  toRefs as vueToRefs,
16
16
  } from "@vue/reactivity";
17
17
  import { captureSourceLocation, debug, isDebugEnabled } from "./debug/index.js";
18
- import { RenderedTextTree } from "./render.js";
19
18
  import { Children, ComponentCreator } from "./runtime/component.js";
20
19
  import { scheduler, setLastTriggerRef } from "./scheduler.js";
21
20
  import type { OutputSymbol } from "./symbols/output-symbol.js";
@@ -27,18 +26,6 @@ if ((globalThis as any).__ALLOY__) {
27
26
  }
28
27
  (globalThis as any).__ALLOY__ = true;
29
28
 
30
- export function getElementCache() {
31
- const ctx = getContext()!;
32
- return (ctx.elementCache ??= new Map());
33
- }
34
-
35
- export type ElementCacheKey =
36
- | ComponentCreator
37
- | (() => unknown)
38
- | CustomContext;
39
-
40
- export type ElementCache = Map<ElementCacheKey, RenderedTextTree>;
41
-
42
29
  export interface Disposable {
43
30
  (): void;
44
31
  }
@@ -57,11 +44,6 @@ export interface Context {
57
44
  // store random info about the node
58
45
  meta?: Record<string, any>;
59
46
 
60
- /**
61
- * A cache of RenderTextTree nodes created within this context,
62
- * indexed by the component or function which created them.
63
- */
64
- elementCache?: ElementCache;
65
47
  /**
66
48
  * When this context was created by a component, this will
67
49
  * be the component that created it.
@@ -86,25 +68,32 @@ export interface Context {
86
68
 
87
69
  /**
88
70
  * A ref that indicates whether the component is empty.
89
- * Only allocated when reactively observed (ContentSlot, mapJoin).
71
+ * Only allocated when reactively observed (e.g. by `ContentSlot`).
72
+ * mapJoin uses an internal empty-change callback instead.
90
73
  */
91
74
  isEmpty?: Ref<boolean>;
92
75
 
93
76
  /**
94
- * Cheap boolean tracking the last propagated empty state.
95
- * Used by notifyContentState() for early-return optimization
96
- * without requiring a reactive ref on every context.
77
+ * Whether this context is a root context
97
78
  */
98
- _lastEmpty: boolean;
79
+ isRoot: boolean;
80
+ }
99
81
 
82
+ interface InternalContext extends Context {
83
+ owner: InternalContext | null;
100
84
  /**
101
- * Whether this context is a root context
85
+ * Internal single-subscriber callback fired synchronously by
86
+ * notifyContentState on every empty/non-empty transition.
102
87
  */
103
- isRoot: boolean;
88
+ onEmptyChange?: (isEmpty: boolean) => void;
89
+ /**
90
+ * Cheap boolean tracking the last propagated empty state.
91
+ */
92
+ lastEmpty: boolean;
104
93
  }
105
94
 
106
- let globalContext: Context | null = null;
107
- export function getContext() {
95
+ let globalContext: InternalContext | null = null;
96
+ export function getContext(): Context | null {
108
97
  return globalContext;
109
98
  }
110
99
 
@@ -128,7 +117,8 @@ function resolveOwnerEffectContextId(context: Context): number | null {
128
117
  /**
129
118
  * Ensure that a context has an isEmpty ref, creating one if needed.
130
119
  * Only call this when you need to reactively observe isEmpty (e.g.,
131
- * ContentSlot, mapJoin). Most contexts don't need an isEmpty ref.
120
+ * `ContentSlot`). `mapJoin` does not call this — it uses an internal
121
+ * empty-change callback directly so most slots never allocate a Ref at all.
132
122
  */
133
123
  export function ensureIsEmpty(context: Context): Ref<boolean> {
134
124
  context.isEmpty ??= ref(context.childrenWithContent === 0, {
@@ -137,19 +127,100 @@ export function ensureIsEmpty(context: Context): Ref<boolean> {
137
127
  return context.isEmpty;
138
128
  }
139
129
 
130
+ /**
131
+ * Increment the current context's `childrenWithContent` counter. Caller
132
+ * should follow with {@link notifyContentState} so that observers
133
+ * (`ContentSlot.isEmpty`, etc.) and ancestor counters stay in sync.
134
+ */
135
+ export function contentAdded() {
136
+ const context = globalContext;
137
+ if (context) context.childrenWithContent++;
138
+ }
139
+
140
+ /**
141
+ * Decrement the current context's `childrenWithContent` counter (clamped
142
+ * at zero). Pair with {@link notifyContentState} to propagate.
143
+ */
144
+ export function contentRemoved() {
145
+ const context = globalContext;
146
+ if (context && context.childrenWithContent > 0) {
147
+ context.childrenWithContent--;
148
+ }
149
+ }
150
+
151
+ export function setContextEmptyChangeListener(
152
+ context: Context,
153
+ listener: ((isEmpty: boolean) => void) | undefined,
154
+ ): void {
155
+ (context as InternalContext).onEmptyChange = listener;
156
+ }
157
+
158
+ /**
159
+ * Reconcile the current context's last-empty flag and `isEmpty` ref
160
+ * with its current `childrenWithContent` count, propagating changes up
161
+ * the owner chain.
162
+ *
163
+ * Call after mutating `childrenWithContent`. Safe to call when there is no
164
+ * active context — it just no-ops.
165
+ *
166
+ * On every transition, both write the (lazily-allocated) `isEmpty` Ref
167
+ * (if present) AND invoke the internal empty-change callback (if present).
168
+ * Order is ref-first so external observers see the new Ref value
169
+ * before any internal mapJoin bookkeeping mutates dependent Refs.
170
+ */
171
+ export function notifyContentState() {
172
+ const startContext = globalContext;
173
+ if (!startContext) return;
174
+
175
+ untrack(() => {
176
+ if (startContext.childrenWithContent === 0) {
177
+ if (startContext.lastEmpty) return;
178
+ startContext.lastEmpty = true;
179
+ if (startContext.isEmpty) startContext.isEmpty.value = true;
180
+ startContext.onEmptyChange?.(true);
181
+
182
+ let current = startContext.owner;
183
+ while (current) {
184
+ if (current.childrenWithContent === 0) break;
185
+ current.childrenWithContent--;
186
+ if (current.childrenWithContent > 0) break;
187
+ current.lastEmpty = true;
188
+ if (current.isEmpty) current.isEmpty.value = true;
189
+ current.onEmptyChange?.(true);
190
+ current = current.owner;
191
+ }
192
+ } else {
193
+ if (!startContext.lastEmpty) return;
194
+ startContext.lastEmpty = false;
195
+ if (startContext.isEmpty) startContext.isEmpty.value = false;
196
+ startContext.onEmptyChange?.(false);
197
+
198
+ let current = startContext.owner;
199
+ while (current) {
200
+ current.childrenWithContent++;
201
+ if (current.childrenWithContent > 1) break;
202
+ current.lastEmpty = false;
203
+ if (current.isEmpty) current.isEmpty.value = false;
204
+ current.onEmptyChange?.(false);
205
+ current = current.owner;
206
+ }
207
+ }
208
+ });
209
+ }
210
+
140
211
  export interface RootOptions {
141
212
  componentOwner?: ComponentCreator<any>;
142
213
  }
143
214
 
144
215
  export function root<T>(fn: (d: Disposable) => T, options?: RootOptions): T {
145
- const context: Context = {
216
+ const context: InternalContext = {
146
217
  id: contextIdCounter++,
147
218
  componentOwner: options?.componentOwner,
148
219
  owner: globalContext,
149
220
  takesSymbols: false,
150
221
  takenSymbols: undefined,
151
222
  childrenWithContent: 0,
152
- _lastEmpty: true,
223
+ lastEmpty: true,
153
224
  isRoot: true,
154
225
  };
155
226
 
@@ -216,10 +287,11 @@ export function findCurrentEffectId(): number | undefined {
216
287
  * ```
217
288
  */
218
289
  export function memo<T>(fn: () => T, equal?: boolean, name?: string): () => T {
219
- const memoLabel = name ? `memo:${name}` : "memo";
220
- const o = shallowRef<T>(undefined as T, {
221
- label: memoLabel,
222
- });
290
+ const dbg = isDebugEnabled();
291
+ const o =
292
+ dbg ?
293
+ shallowRef<T>(undefined as T, { label: name ? `memo:${name}` : "memo" })
294
+ : shallowRef<T>(undefined as T);
223
295
  effect(
224
296
  (prev) => {
225
297
  const res = fn();
@@ -228,9 +300,7 @@ export function memo<T>(fn: () => T, equal?: boolean, name?: string): () => T {
228
300
  return res;
229
301
  },
230
302
  undefined as T,
231
- {
232
- debug: { name: name ? `memo:${name}` : "memo" },
233
- },
303
+ dbg ? { debug: { name: name ? `memo:${name}` : "memo" } } : undefined,
234
304
  );
235
305
  const getter = (() => o.value as T) as () => T;
236
306
  if (name) {
@@ -244,13 +314,13 @@ export function effect<T>(
244
314
  current?: T,
245
315
  options?: EffectOptions,
246
316
  ) {
247
- const context: Context = {
317
+ const context: InternalContext = {
248
318
  id: contextIdCounter++,
249
319
  owner: globalContext,
250
320
  takesSymbols: false,
251
321
  takenSymbols: undefined,
252
322
  childrenWithContent: 0,
253
- _lastEmpty: true,
323
+ lastEmpty: true,
254
324
  isRoot: false,
255
325
  };
256
326
 
@@ -401,6 +471,82 @@ export function effect<T>(
401
471
  }
402
472
  }
403
473
 
474
+ /**
475
+ * Run `fn` in a fresh child Context (just like {@link effect}) but **without**
476
+ * a tracking ReactiveEffect wrapper. Use this when the caller knows the body
477
+ * does not establish reactive subscriptions at its top level (e.g. it wraps
478
+ * its only reactive reads in `untrack()` or function children) — typically
479
+ * for component-invocation plumbing where the outer "effect" never re-fires.
480
+ *
481
+ * Compared to {@link effect}:
482
+ * - No `vueEffect` allocation, no scheduler binding.
483
+ * - The body runs synchronously to completion exactly once.
484
+ * - Disposables registered via `onCleanup` inside `fn` (or its descendants)
485
+ * are still registered on the new context, and disposed via the parent
486
+ * context's cleanup chain.
487
+ *
488
+ * Returns the value returned by `fn`.
489
+ */
490
+ export function runInContext<T>(fn: () => T): T {
491
+ const context: InternalContext = {
492
+ id: contextIdCounter++,
493
+ owner: globalContext,
494
+ takesSymbols: false,
495
+ takenSymbols: undefined,
496
+ childrenWithContent: 0,
497
+ lastEmpty: true,
498
+ isRoot: false,
499
+ };
500
+
501
+ // Hook this context's disposables into the parent's cleanup chain so
502
+ // when the parent disposes, our disposables run too.
503
+ onCleanup(() => {
504
+ const d = context.disposables;
505
+ context.disposables = undefined;
506
+ if (d) {
507
+ for (let k = 0, len = d.length; k < len; k++) untrack(d[k]);
508
+ }
509
+ });
510
+
511
+ const oldContext = globalContext;
512
+ globalContext = context;
513
+ try {
514
+ return fn();
515
+ } finally {
516
+ globalContext = oldContext;
517
+ }
518
+ }
519
+
520
+ export function runInContextWithDisposer<T>(fn: (dispose: Disposable) => T): T {
521
+ const context: InternalContext = {
522
+ id: contextIdCounter++,
523
+ owner: globalContext,
524
+ takesSymbols: false,
525
+ takenSymbols: undefined,
526
+ childrenWithContent: 0,
527
+ lastEmpty: true,
528
+ isRoot: false,
529
+ };
530
+
531
+ const dispose = () => {
532
+ const d = context.disposables;
533
+ context.disposables = undefined;
534
+ if (d) {
535
+ for (let k = 0, len = d.length; k < len; k++) untrack(d[k]);
536
+ }
537
+ };
538
+
539
+ onCleanup(dispose);
540
+
541
+ const oldContext = globalContext;
542
+ globalContext = context;
543
+ try {
544
+ return fn(dispose);
545
+ } finally {
546
+ globalContext = oldContext;
547
+ }
548
+ }
549
+
404
550
  /**
405
551
  * Register a cleanup function which is called when the current reactive scope
406
552
  * is recalculated or disposed. This is useful to clean up any side effects
@@ -448,7 +594,7 @@ export function createCustomContext(
448
594
  };
449
595
  }
450
596
 
451
- export function isCustomContext(child: Children): child is CustomContext {
597
+ export function isCustomContext(child: unknown): child is CustomContext {
452
598
  return (
453
599
  typeof child === "object" &&
454
600
  child !== null &&