@alloy-js/core 0.23.0-dev.1 → 0.23.0-dev.11

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 (337) hide show
  1. package/CHANGELOG.md +0 -22
  2. package/dist/devtools/index.html +80 -0
  3. package/dist/src/binder.d.ts +2 -0
  4. package/dist/src/binder.d.ts.map +1 -1
  5. package/dist/src/binder.js +60 -12
  6. package/dist/src/binder.js.map +1 -1
  7. package/dist/src/components/AccessExpression.d.ts +78 -0
  8. package/dist/src/components/AccessExpression.d.ts.map +1 -0
  9. package/dist/src/components/AccessExpression.js +218 -0
  10. package/dist/src/components/AccessExpression.js.map +1 -0
  11. package/dist/src/components/AccessExpression.test.d.ts +2 -0
  12. package/dist/src/components/AccessExpression.test.d.ts.map +1 -0
  13. package/dist/src/components/AccessExpression.test.js +137 -0
  14. package/dist/src/components/AccessExpression.test.js.map +1 -0
  15. package/dist/src/components/AppendFile.d.ts.map +1 -1
  16. package/dist/src/components/AppendFile.js +14 -3
  17. package/dist/src/components/AppendFile.js.map +1 -1
  18. package/dist/src/components/Block.js +1 -1
  19. package/dist/src/components/Block.js.map +1 -1
  20. package/dist/src/components/Declaration.d.ts.map +1 -1
  21. package/dist/src/components/Declaration.js +2 -1
  22. package/dist/src/components/Declaration.js.map +1 -1
  23. package/dist/src/components/For.d.ts.map +1 -1
  24. package/dist/src/components/For.js +1 -1
  25. package/dist/src/components/For.js.map +1 -1
  26. package/dist/src/components/List.d.ts.map +1 -1
  27. package/dist/src/components/List.js +1 -1
  28. package/dist/src/components/List.js.map +1 -1
  29. package/dist/src/components/Prose.js +2 -2
  30. package/dist/src/components/Prose.js.map +1 -1
  31. package/dist/src/components/Scope.d.ts.map +1 -1
  32. package/dist/src/components/Scope.js +6 -1
  33. package/dist/src/components/Scope.js.map +1 -1
  34. package/dist/src/components/SourceDirectory.d.ts.map +1 -1
  35. package/dist/src/components/SourceDirectory.js +1 -2
  36. package/dist/src/components/SourceDirectory.js.map +1 -1
  37. package/dist/src/components/Switch.d.ts.map +1 -1
  38. package/dist/src/components/Switch.js +1 -1
  39. package/dist/src/components/Switch.js.map +1 -1
  40. package/dist/src/components/TemplateFile.d.ts.map +1 -1
  41. package/dist/src/components/TemplateFile.js +18 -3
  42. package/dist/src/components/TemplateFile.js.map +1 -1
  43. package/dist/src/components/index.d.ts +1 -0
  44. package/dist/src/components/index.d.ts.map +1 -1
  45. package/dist/src/components/index.js +1 -0
  46. package/dist/src/components/index.js.map +1 -1
  47. package/dist/src/content-slot.d.ts.map +1 -1
  48. package/dist/src/content-slot.js +7 -6
  49. package/dist/src/content-slot.js.map +1 -1
  50. package/dist/src/context.d.ts.map +1 -1
  51. package/dist/src/context.js +10 -3
  52. package/dist/src/context.js.map +1 -1
  53. package/dist/src/debug/cli.d.ts +6 -0
  54. package/dist/src/debug/cli.d.ts.map +1 -0
  55. package/dist/src/{debug.js → debug/cli.js} +79 -82
  56. package/dist/src/debug/cli.js.map +1 -0
  57. package/dist/src/debug/diagnostics.test.d.ts +2 -0
  58. package/dist/src/debug/diagnostics.test.d.ts.map +1 -0
  59. package/dist/src/debug/diagnostics.test.js +46 -0
  60. package/dist/src/debug/diagnostics.test.js.map +1 -0
  61. package/dist/src/debug/effects.d.ts +81 -0
  62. package/dist/src/debug/effects.d.ts.map +1 -0
  63. package/dist/src/debug/effects.js +358 -0
  64. package/dist/src/debug/effects.js.map +1 -0
  65. package/dist/src/debug/effects.test.d.ts +2 -0
  66. package/dist/src/debug/effects.test.d.ts.map +1 -0
  67. package/dist/src/debug/effects.test.js +256 -0
  68. package/dist/src/debug/effects.test.js.map +1 -0
  69. package/dist/src/debug/files.d.ts +14 -0
  70. package/dist/src/debug/files.d.ts.map +1 -0
  71. package/dist/src/debug/files.js +29 -0
  72. package/dist/src/debug/files.js.map +1 -0
  73. package/dist/src/debug/files.test.d.ts +2 -0
  74. package/dist/src/debug/files.test.d.ts.map +1 -0
  75. package/dist/src/debug/files.test.js +66 -0
  76. package/dist/src/debug/files.test.js.map +1 -0
  77. package/dist/src/debug/index.d.ts +63 -0
  78. package/dist/src/debug/index.d.ts.map +1 -0
  79. package/dist/src/debug/index.js +71 -0
  80. package/dist/src/debug/index.js.map +1 -0
  81. package/dist/src/debug/message-format.test.d.ts +2 -0
  82. package/dist/src/debug/message-format.test.d.ts.map +1 -0
  83. package/dist/src/debug/message-format.test.js +700 -0
  84. package/dist/src/debug/message-format.test.js.map +1 -0
  85. package/dist/src/debug/render-tree-orphans.test.d.ts +2 -0
  86. package/dist/src/debug/render-tree-orphans.test.d.ts.map +1 -0
  87. package/dist/src/debug/render-tree-orphans.test.js +297 -0
  88. package/dist/src/debug/render-tree-orphans.test.js.map +1 -0
  89. package/dist/src/debug/render.d.ts +57 -0
  90. package/dist/src/debug/render.d.ts.map +1 -0
  91. package/dist/src/debug/render.js +472 -0
  92. package/dist/src/debug/render.js.map +1 -0
  93. package/dist/src/debug/render.test.d.ts +2 -0
  94. package/dist/src/debug/render.test.d.ts.map +1 -0
  95. package/dist/src/debug/render.test.js +291 -0
  96. package/dist/src/debug/render.test.js.map +1 -0
  97. package/dist/src/debug/serialize.d.ts +9 -0
  98. package/dist/src/debug/serialize.d.ts.map +1 -0
  99. package/dist/src/debug/serialize.js +70 -0
  100. package/dist/src/debug/serialize.js.map +1 -0
  101. package/dist/src/debug/symbols.d.ts +16 -0
  102. package/dist/src/debug/symbols.d.ts.map +1 -0
  103. package/dist/src/debug/symbols.js +196 -0
  104. package/dist/src/debug/symbols.js.map +1 -0
  105. package/dist/src/debug/symbols.test.d.ts +2 -0
  106. package/dist/src/debug/symbols.test.d.ts.map +1 -0
  107. package/dist/src/debug/symbols.test.js +93 -0
  108. package/dist/src/debug/symbols.test.js.map +1 -0
  109. package/dist/src/debug/trace-writer.d.ts +55 -0
  110. package/dist/src/debug/trace-writer.d.ts.map +1 -0
  111. package/dist/src/debug/trace-writer.js +658 -0
  112. package/dist/src/debug/trace-writer.js.map +1 -0
  113. package/dist/src/debug/trace.d.ts +342 -0
  114. package/dist/src/debug/trace.d.ts.map +1 -0
  115. package/dist/src/debug/trace.js +446 -0
  116. package/dist/src/debug/trace.js.map +1 -0
  117. package/dist/src/devtools/devtools-protocol.d.ts +389 -0
  118. package/dist/src/devtools/devtools-protocol.d.ts.map +1 -0
  119. package/dist/src/devtools/devtools-protocol.js +2 -0
  120. package/dist/src/devtools/devtools-protocol.js.map +1 -0
  121. package/dist/src/devtools/devtools-server.browser.d.ts +23 -0
  122. package/dist/src/devtools/devtools-server.browser.d.ts.map +1 -0
  123. package/dist/src/devtools/devtools-server.browser.js +33 -0
  124. package/dist/src/devtools/devtools-server.browser.js.map +1 -0
  125. package/dist/src/devtools/devtools-server.d.ts +66 -0
  126. package/dist/src/devtools/devtools-server.d.ts.map +1 -0
  127. package/dist/src/devtools/devtools-server.js +444 -0
  128. package/dist/src/devtools/devtools-server.js.map +1 -0
  129. package/dist/src/devtools/devtools-transport.d.ts +23 -0
  130. package/dist/src/devtools/devtools-transport.d.ts.map +1 -0
  131. package/dist/src/devtools/devtools-transport.js +114 -0
  132. package/dist/src/devtools/devtools-transport.js.map +1 -0
  133. package/dist/src/devtools-entry.browser.d.ts +4 -0
  134. package/dist/src/devtools-entry.browser.d.ts.map +1 -0
  135. package/dist/src/devtools-entry.browser.js +2 -0
  136. package/dist/src/devtools-entry.browser.js.map +1 -0
  137. package/dist/src/devtools-entry.d.ts +4 -0
  138. package/dist/src/devtools-entry.d.ts.map +1 -0
  139. package/dist/src/devtools-entry.js +2 -0
  140. package/dist/src/devtools-entry.js.map +1 -0
  141. package/dist/src/diagnostics.d.ts +34 -0
  142. package/dist/src/diagnostics.d.ts.map +1 -0
  143. package/dist/src/diagnostics.js +89 -0
  144. package/dist/src/diagnostics.js.map +1 -0
  145. package/dist/src/index.d.ts +3 -2
  146. package/dist/src/index.d.ts.map +1 -1
  147. package/dist/src/index.js +3 -2
  148. package/dist/src/index.js.map +1 -1
  149. package/dist/src/print-hook.d.ts +14 -0
  150. package/dist/src/print-hook.d.ts.map +1 -0
  151. package/dist/src/print-hook.js +10 -0
  152. package/dist/src/print-hook.js.map +1 -0
  153. package/dist/src/reactive-union-set.d.ts.map +1 -1
  154. package/dist/src/reactive-union-set.js +28 -3
  155. package/dist/src/reactive-union-set.js.map +1 -1
  156. package/dist/src/reactivity.d.ts +60 -7
  157. package/dist/src/reactivity.d.ts.map +1 -1
  158. package/dist/src/reactivity.js +308 -39
  159. package/dist/src/reactivity.js.map +1 -1
  160. package/dist/src/render-stack.d.ts +18 -1
  161. package/dist/src/render-stack.d.ts.map +1 -1
  162. package/dist/src/render-stack.js +61 -1
  163. package/dist/src/render-stack.js.map +1 -1
  164. package/dist/src/render.d.ts +8 -15
  165. package/dist/src/render.d.ts.map +1 -1
  166. package/dist/src/render.js +424 -109
  167. package/dist/src/render.js.map +1 -1
  168. package/dist/src/resource.d.ts.map +1 -1
  169. package/dist/src/resource.js +5 -0
  170. package/dist/src/resource.js.map +1 -1
  171. package/dist/src/scheduler.d.ts +13 -0
  172. package/dist/src/scheduler.d.ts.map +1 -1
  173. package/dist/src/scheduler.js +150 -13
  174. package/dist/src/scheduler.js.map +1 -1
  175. package/dist/src/symbols/basic-symbol.d.ts.map +1 -1
  176. package/dist/src/symbols/basic-symbol.js +6 -1
  177. package/dist/src/symbols/basic-symbol.js.map +1 -1
  178. package/dist/src/symbols/decl.d.ts.map +1 -1
  179. package/dist/src/symbols/decl.js +5 -1
  180. package/dist/src/symbols/decl.js.map +1 -1
  181. package/dist/src/symbols/output-scope.d.ts +2 -1
  182. package/dist/src/symbols/output-scope.d.ts.map +1 -1
  183. package/dist/src/symbols/output-scope.js +13 -8
  184. package/dist/src/symbols/output-scope.js.map +1 -1
  185. package/dist/src/symbols/output-symbol.d.ts +1 -0
  186. package/dist/src/symbols/output-symbol.d.ts.map +1 -1
  187. package/dist/src/symbols/output-symbol.js +25 -8
  188. package/dist/src/symbols/output-symbol.js.map +1 -1
  189. package/dist/src/symbols/symbol-flow.d.ts.map +1 -1
  190. package/dist/src/symbols/symbol-flow.js +24 -8
  191. package/dist/src/symbols/symbol-flow.js.map +1 -1
  192. package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
  193. package/dist/src/symbols/symbol-slot.js +15 -0
  194. package/dist/src/symbols/symbol-slot.js.map +1 -1
  195. package/dist/src/symbols/symbol-slot.test.d.ts +2 -0
  196. package/dist/src/symbols/symbol-slot.test.d.ts.map +1 -0
  197. package/dist/src/symbols/symbol-slot.test.js +35 -0
  198. package/dist/src/symbols/symbol-slot.test.js.map +1 -0
  199. package/dist/src/symbols/symbol-table.d.ts.map +1 -1
  200. package/dist/src/symbols/symbol-table.js +6 -5
  201. package/dist/src/symbols/symbol-table.js.map +1 -1
  202. package/dist/src/trace.d.ts +2 -0
  203. package/dist/src/trace.d.ts.map +1 -0
  204. package/dist/src/trace.js +2 -0
  205. package/dist/src/trace.js.map +1 -0
  206. package/dist/src/tracer.d.ts +2 -228
  207. package/dist/src/tracer.d.ts.map +1 -1
  208. package/dist/src/tracer.js +5 -298
  209. package/dist/src/tracer.js.map +1 -1
  210. package/dist/src/utils.d.ts.map +1 -1
  211. package/dist/src/utils.js +17 -9
  212. package/dist/src/utils.js.map +1 -1
  213. package/dist/test/components/append-file.test.d.ts.map +1 -1
  214. package/dist/test/components/append-file.test.js +18 -10
  215. package/dist/test/components/append-file.test.js.map +1 -1
  216. package/dist/test/components/template-file.test.d.ts.map +1 -1
  217. package/dist/test/components/template-file.test.js +6 -4
  218. package/dist/test/components/template-file.test.js.map +1 -1
  219. package/dist/test/lazy-isempty.test.d.ts +2 -0
  220. package/dist/test/lazy-isempty.test.d.ts.map +1 -0
  221. package/dist/test/lazy-isempty.test.js +89 -0
  222. package/dist/test/lazy-isempty.test.js.map +1 -0
  223. package/dist/test/reactive-union-set-disposers.test.d.ts +2 -0
  224. package/dist/test/reactive-union-set-disposers.test.d.ts.map +1 -0
  225. package/dist/test/reactive-union-set-disposers.test.js +98 -0
  226. package/dist/test/reactive-union-set-disposers.test.js.map +1 -0
  227. package/dist/test/reactivity/shallow-reactive.test.d.ts +2 -0
  228. package/dist/test/reactivity/shallow-reactive.test.d.ts.map +1 -0
  229. package/dist/test/reactivity/shallow-reactive.test.js +52 -0
  230. package/dist/test/reactivity/shallow-reactive.test.js.map +1 -0
  231. package/dist/test/rendering/basic.test.js +3 -0
  232. package/dist/test/rendering/basic.test.js.map +1 -1
  233. package/dist/test/rendering/print-render-stack.test.d.ts.map +1 -1
  234. package/dist/test/rendering/print-render-stack.test.js +91 -98
  235. package/dist/test/rendering/print-render-stack.test.js.map +1 -1
  236. package/dist/test/scheduler-extended.test.d.ts +2 -0
  237. package/dist/test/scheduler-extended.test.d.ts.map +1 -0
  238. package/dist/test/scheduler-extended.test.js +96 -0
  239. package/dist/test/scheduler-extended.test.js.map +1 -0
  240. package/dist/test/scheduler.test.d.ts +2 -0
  241. package/dist/test/scheduler.test.d.ts.map +1 -0
  242. package/dist/test/scheduler.test.js +46 -0
  243. package/dist/test/scheduler.test.js.map +1 -0
  244. package/dist/testing/create-test-wrapper.d.ts +1 -1
  245. package/dist/testing/create-test-wrapper.d.ts.map +1 -1
  246. package/dist/testing/create-test-wrapper.js +1 -1
  247. package/dist/testing/create-test-wrapper.js.map +1 -1
  248. package/dist/testing/devtools-utils.d.ts +35 -0
  249. package/dist/testing/devtools-utils.d.ts.map +1 -0
  250. package/dist/testing/devtools-utils.js +162 -0
  251. package/dist/testing/devtools-utils.js.map +1 -0
  252. package/dist/testing/extend-expect.d.ts.map +1 -1
  253. package/dist/testing/extend-expect.js +63 -1
  254. package/dist/testing/extend-expect.js.map +1 -1
  255. package/dist/testing/render.d.ts +2 -2
  256. package/dist/testing/render.d.ts.map +1 -1
  257. package/dist/testing/render.js +2 -2
  258. package/dist/testing/render.js.map +1 -1
  259. package/dist/tsconfig.tsbuildinfo +1 -1
  260. package/package.json +21 -7
  261. package/scripts/copy-devtools-ui.mjs +26 -0
  262. package/src/binder.ts +117 -53
  263. package/src/components/AccessExpression.test.tsx +132 -0
  264. package/src/components/AccessExpression.tsx +344 -0
  265. package/src/components/AppendFile.tsx +14 -9
  266. package/src/components/Block.tsx +1 -1
  267. package/src/components/Declaration.tsx +2 -1
  268. package/src/components/For.tsx +14 -10
  269. package/src/components/List.tsx +7 -4
  270. package/src/components/Prose.tsx +1 -1
  271. package/src/components/Scope.tsx +6 -1
  272. package/src/components/SourceDirectory.tsx +1 -2
  273. package/src/components/Switch.tsx +11 -7
  274. package/src/components/TemplateFile.tsx +18 -9
  275. package/src/components/index.tsx +1 -0
  276. package/src/content-slot.tsx +7 -7
  277. package/src/context.ts +17 -6
  278. package/src/{debug.ts → debug/cli.ts} +114 -125
  279. package/src/debug/diagnostics.test.tsx +56 -0
  280. package/src/debug/effects.test.tsx +301 -0
  281. package/src/debug/effects.ts +531 -0
  282. package/src/debug/files.test.tsx +76 -0
  283. package/src/debug/files.ts +40 -0
  284. package/src/debug/index.ts +132 -0
  285. package/src/debug/message-format.test.tsx +759 -0
  286. package/src/debug/render-tree-orphans.test.tsx +344 -0
  287. package/src/debug/render.test.tsx +357 -0
  288. package/src/debug/render.ts +698 -0
  289. package/src/debug/serialize.ts +85 -0
  290. package/src/debug/symbols.test.tsx +105 -0
  291. package/src/debug/symbols.ts +322 -0
  292. package/src/debug/trace-writer.ts +969 -0
  293. package/src/debug/trace.ts +309 -0
  294. package/src/devtools/devtools-protocol.ts +497 -0
  295. package/src/devtools/devtools-server.browser.ts +62 -0
  296. package/src/devtools/devtools-server.ts +468 -0
  297. package/src/devtools/devtools-transport.ts +154 -0
  298. package/src/devtools-entry.browser.ts +48 -0
  299. package/src/devtools-entry.ts +48 -0
  300. package/src/diagnostics.ts +150 -0
  301. package/src/index.ts +2 -7
  302. package/src/print-hook.ts +22 -0
  303. package/src/reactive-union-set.ts +85 -44
  304. package/src/reactivity.ts +396 -58
  305. package/src/render-stack.ts +73 -1
  306. package/src/render.ts +544 -161
  307. package/src/resource.ts +28 -19
  308. package/src/scheduler.ts +209 -14
  309. package/src/symbols/basic-symbol.ts +6 -1
  310. package/src/symbols/decl.ts +5 -1
  311. package/src/symbols/output-scope.ts +21 -13
  312. package/src/symbols/output-symbol.ts +34 -14
  313. package/src/symbols/symbol-flow.ts +76 -39
  314. package/src/symbols/symbol-slot.test.tsx +41 -0
  315. package/src/symbols/symbol-slot.tsx +47 -20
  316. package/src/symbols/symbol-table.ts +6 -10
  317. package/src/trace.ts +1 -0
  318. package/src/tracer.ts +13 -242
  319. package/src/utils.tsx +31 -21
  320. package/temp/api.json +5700 -3015
  321. package/test/components/append-file.test.tsx +36 -29
  322. package/test/components/template-file.test.tsx +11 -11
  323. package/test/lazy-isempty.test.tsx +106 -0
  324. package/test/reactive-union-set-disposers.test.tsx +112 -0
  325. package/test/reactivity/shallow-reactive.test.tsx +56 -0
  326. package/test/rendering/basic.test.tsx +4 -0
  327. package/test/rendering/print-render-stack.test.tsx +52 -43
  328. package/test/scheduler-extended.test.tsx +122 -0
  329. package/test/scheduler.test.tsx +50 -0
  330. package/testing/create-test-wrapper.tsx +1 -1
  331. package/testing/devtools-utils.ts +245 -0
  332. package/testing/extend-expect.ts +89 -0
  333. package/testing/render.ts +2 -2
  334. package/testing/vitest.d.ts +9 -0
  335. package/dist/src/debug.d.ts +0 -14
  336. package/dist/src/debug.d.ts.map +0 -1
  337. package/dist/src/debug.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ import { shallowRef } from "@vue/reactivity";
2
+ import { expect, it } from "vitest";
3
+ import { renderTree } from "../render.js";
4
+ import { flushJobs } from "../scheduler.js";
5
+ import { BasicSymbol } from "./basic-symbol.js";
6
+ import { emitSymbol } from "./symbol-flow.js";
7
+ import { createSymbolSlot } from "./symbol-slot.jsx";
8
+
9
+ it("captures firstSymbol", async () => {
10
+ const Slot = createSymbolSlot();
11
+
12
+ renderTree(
13
+ <Slot>
14
+ {() => {
15
+ emitSymbol(new BasicSymbol("a", undefined));
16
+ }}
17
+ </Slot>,
18
+ );
19
+ await flushJobs();
20
+ expect(Slot.firstSymbol.value).toBeDefined();
21
+ expect(Slot.firstSymbol.value!.name).toBe("a");
22
+ });
23
+
24
+ it("captures firstSymbol when emitting a ref to a symbol", async () => {
25
+ const Slot = createSymbolSlot();
26
+ const symref = shallowRef<BasicSymbol | undefined>();
27
+
28
+ renderTree(
29
+ <Slot>
30
+ {() => {
31
+ emitSymbol(symref);
32
+ }}
33
+ </Slot>,
34
+ );
35
+ await flushJobs();
36
+ expect(Slot.firstSymbol.value).toBeUndefined();
37
+ symref.value = new BasicSymbol("a", undefined);
38
+ await flushJobs();
39
+ expect(Slot.firstSymbol.value).toBeDefined();
40
+ expect(Slot.firstSymbol.value!.name).toBe("a");
41
+ });
@@ -50,36 +50,63 @@ export function createSymbolSlot(): SymbolSlot {
50
50
  Object.defineProperty(SymbolSlot, "firstSymbol", {
51
51
  get() {
52
52
  const ref = shallowRef();
53
- effect(() => {
54
- ref.value = symbolSlotRef.value?.values().next().value;
55
- });
53
+ effect(
54
+ () => {
55
+ ref.value = symbolSlotRef.value?.values().next().value;
56
+ },
57
+ undefined,
58
+ {
59
+ debug: {
60
+ name: "symbolSlot:firstSymbol",
61
+ type: "symbol",
62
+ },
63
+ },
64
+ );
56
65
  return ref;
57
66
  },
58
67
  });
59
68
 
60
69
  SymbolSlot.copyMembersTo = (baseSymbol: OutputSymbol) => {
61
- effect(() => {
62
- if (!symbolSlotRef.value) {
63
- return;
64
- }
70
+ effect(
71
+ () => {
72
+ if (!symbolSlotRef.value) {
73
+ return;
74
+ }
65
75
 
66
- for (const symbol of symbolSlotRef.value) {
67
- symbol.copyMembersTo(baseSymbol);
68
- }
69
- });
76
+ for (const symbol of symbolSlotRef.value) {
77
+ symbol.copyMembersTo(baseSymbol);
78
+ }
79
+ },
80
+ undefined,
81
+ {
82
+ debug: {
83
+ name: "symbolSlot:copyMembers",
84
+ type: "symbol",
85
+ },
86
+ },
87
+ );
70
88
  };
71
89
 
72
90
  SymbolSlot.moveMembersTo = (baseSymbol: OutputSymbol) => {
73
- effect(() => {
74
- if (!symbolSlotRef.value) {
75
- return;
76
- }
77
- for (const symbol of symbolSlotRef.value) {
78
- if (symbol.isTransient) {
79
- symbol.moveMembersTo(baseSymbol);
91
+ effect(
92
+ () => {
93
+ if (!symbolSlotRef.value) {
94
+ return;
80
95
  }
81
- }
82
- });
96
+ for (const symbol of symbolSlotRef.value) {
97
+ if (symbol.isTransient) {
98
+ symbol.moveMembersTo(baseSymbol);
99
+ }
100
+ }
101
+ },
102
+ undefined,
103
+ {
104
+ debug: {
105
+ name: "symbolSlot:moveMembers",
106
+ type: "symbol",
107
+ },
108
+ },
109
+ );
83
110
  };
84
111
 
85
112
  return SymbolSlot as any;
@@ -1,13 +1,9 @@
1
1
  import type { Binder, NameConflictResolver } from "../binder.js";
2
+ import { debug, TracePhase } from "../debug/index.js";
2
3
  import { ReactiveUnionSet } from "../reactive-union-set.js";
3
4
  import { Refkey } from "../refkey.js";
4
5
  import { queueJob } from "../scheduler.js";
5
- import {
6
- formatSymbolName,
7
- formatSymbolTableName,
8
- trace,
9
- TracePhase,
10
- } from "../tracer.js";
6
+ import { formatSymbolName, formatSymbolTableName } from "../tracer.js";
11
7
  import { OutputSpace } from "./output-space.js";
12
8
  import type { OutputSymbol } from "./output-symbol.js";
13
9
 
@@ -65,7 +61,7 @@ export abstract class SymbolTable extends ReactiveUnionSet<OutputSymbol> {
65
61
  ) {
66
62
  super({
67
63
  onAdd: (symbol) => {
68
- trace(
64
+ debug.trace(
69
65
  TracePhase.symbol.addToScope,
70
66
  () =>
71
67
  `${formatSymbolName(symbol)} added to ${formatSymbolTableName(this)}`,
@@ -78,7 +74,7 @@ export abstract class SymbolTable extends ReactiveUnionSet<OutputSymbol> {
78
74
  return symbol;
79
75
  },
80
76
  onDelete: (symbol) => {
81
- trace(
77
+ debug.trace(
82
78
  TracePhase.symbol.removeFromScope,
83
79
  () =>
84
80
  `${formatSymbolName(symbol)} removed from ${formatSymbolTableName(this)}`,
@@ -97,7 +93,7 @@ export abstract class SymbolTable extends ReactiveUnionSet<OutputSymbol> {
97
93
  }
98
94
 
99
95
  moveTo(target: SymbolTable): void {
100
- trace(
96
+ debug.trace(
101
97
  TracePhase.scope.moveSymbols,
102
98
  () =>
103
99
  `${formatSymbolTableName(this)} -> ${formatSymbolTableName(target)}`,
@@ -117,7 +113,7 @@ export abstract class SymbolTable extends ReactiveUnionSet<OutputSymbol> {
117
113
  createRefkeys?(sourceSymbol: OutputSymbol): Refkey[];
118
114
  } = {},
119
115
  ): void {
120
- trace(
116
+ debug.trace(
121
117
  TracePhase.scope.copySymbols,
122
118
  () =>
123
119
  `${formatSymbolTableName(this)} copied to ${formatSymbolTableName(target)}`,
package/src/trace.ts ADDED
@@ -0,0 +1 @@
1
+ // Legacy module removed in favor of ./debug.ts.
package/src/tracer.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import { effect } from "@vue/reactivity";
2
+ import {
3
+ debug,
4
+ isConsoleTraceEnabled,
5
+ type TracePhaseInfo,
6
+ } from "./debug/index.js";
7
+ import { colorText, parseBreakOnIds } from "./debug/trace.js";
2
8
  import { untrack } from "./reactivity.js";
3
9
  import { inspectRefkey, type Refkey } from "./refkey.js";
4
10
  import { scheduler } from "./scheduler.js";
@@ -10,203 +16,16 @@ import type {
10
16
  import { type OutputSymbol } from "./symbols/output-symbol.js";
11
17
  import { SymbolTable } from "./symbols/symbol-table.js";
12
18
 
13
- // enable tracing for specific phases using a comma separated list of
14
- // dotted identifiers, e.g. `scope.update,symbol.create`.
15
- const traceEnv = process.env.ALLOY_TRACE ?? "";
16
- const tracePhases = new Set<string>(
17
- traceEnv === "" ? [] : traceEnv.split(",").map((t) => t.trim()),
18
- );
19
-
20
- if (tracePhases.size > 0) {
21
- // eslint-disable-next-line no-console
22
- console.log(
23
- "Tracing enabled for phases:",
24
- Array.from(tracePhases).join(", "),
25
- );
26
- }
27
-
28
- const debuggerIdsEnv = process.env.ALLOY_BREAK_ON_DID ?? "";
29
- const dids = new Set<number>();
30
-
31
- debuggerIdsEnv.split(",").forEach((id) => {
32
- const num = parseInt(id, 10);
33
- if (!isNaN(num)) {
34
- dids.add(num);
35
- }
36
- });
37
- export const TracePhase = {
38
- scope: {
39
- update: {
40
- area: "scope",
41
- subarea: "update",
42
- bg: { r: 0, g: 255, b: 100 },
43
- },
44
- create: {
45
- area: "scope",
46
- subarea: "create",
47
- bg: { r: 0, g: 150, b: 100 },
48
- },
49
- copySymbols: {
50
- area: "scope",
51
- subarea: "copySymbols",
52
- bg: { r: 0, g: 100, b: 100 },
53
- },
54
- moveSymbols: {
55
- area: "scope",
56
- subarea: "moveSymbols",
57
- bg: { r: 0, g: 100, b: 100 },
58
- },
59
- },
60
- symbol: {
61
- update: {
62
- area: "symbol",
63
- subarea: "update",
64
- bg: { r: 0, g: 0, b: 255 },
65
- },
66
- resolve: {
67
- area: "symbol",
68
- subarea: "resolve",
69
- bg: { r: 0, g: 0, b: 200 },
70
- },
71
- create: {
72
- area: "symbol",
73
- subarea: "create",
74
- bg: { r: 0, g: 0, b: 150 },
75
- },
76
- flow: {
77
- area: "symbol",
78
- subarea: "flow",
79
- bg: { r: 0, g: 0, b: 100 },
80
- },
81
- addToScope: {
82
- area: "symbol",
83
- subarea: "addToScope",
84
- bg: { r: 0, g: 0, b: 50 },
85
- },
86
- instantiate: {
87
- area: "symbol",
88
- subarea: "instantiate",
89
- bg: { r: 0, g: 0, b: 25 },
90
- },
91
- clone: {
92
- area: "symbol",
93
- subarea: "clone",
94
- bg: { r: 0, g: 0, b: 25 },
95
- },
96
- delete: {
97
- area: "symbol",
98
- subarea: "delete",
99
- bg: { r: 100, g: 0, b: 100 },
100
- },
101
- removeFromScope: {
102
- area: "symbol",
103
- subarea: "removeFromScope",
104
- bg: { r: 50, g: 0, b: 50 },
105
- },
106
- },
107
- resolve: {
108
- success: {
109
- area: "resolve",
110
- subarea: "success",
111
- bg: { r: 0, g: 255, b: 0 },
112
- },
113
- pending: {
114
- area: "resolve",
115
- subarea: "pending",
116
- bg: { r: 255, g: 255, b: 0 },
117
- },
118
- failure: {
119
- area: "resolve",
120
- subarea: "failure",
121
- bg: { r: 100, g: 50, b: 50 },
122
- },
123
- },
124
- effect: {
125
- schedule: {
126
- area: "effect",
127
- subarea: "schedule",
128
- bg: { r: 100, g: 100, b: 0 },
129
- },
130
- track: {
131
- area: "effect",
132
- subarea: "track",
133
- bg: { r: 75, g: 75, b: 0 },
134
- },
135
- trigger: {
136
- area: "effect",
137
- subarea: "trigger",
138
- bg: { r: 50, g: 50, b: 0 },
139
- },
140
- },
141
- render: {
142
- worker: {
143
- area: "render",
144
- subarea: "worker",
145
- bg: { r: 100, g: 50, b: 0 },
146
- },
147
- appendChild: {
148
- area: "render",
149
- subarea: "appendChild",
150
- bg: { r: 100, g: 50, b: 0 },
151
- },
152
- renderEffect: {
153
- area: "render",
154
- subarea: "render effect",
155
- bg: { r: 100, g: 50, b: 0 },
156
- },
157
- },
158
- } as const;
159
-
160
- interface TracePhase extends TextFormat {
161
- area: string;
162
- subarea: string;
163
- }
19
+ const dids = parseBreakOnIds();
164
20
 
165
21
  let triggerCount = 0;
166
22
 
167
- function shouldTrace(phase: TracePhase) {
168
- return (
169
- tracePhases.has(phase.area) ||
170
- tracePhases.has(phase.area + "." + phase.subarea)
171
- );
172
- }
173
- export function trace(
174
- phase: TracePhase,
175
- cb: () => string,
176
- triggerIds: Set<number> = new Set(),
177
- ) {
178
- if (!shouldTrace(phase)) {
23
+ export function traceEffect(phase: TracePhaseInfo, cb: () => string) {
24
+ if (
25
+ !isConsoleTraceEnabled(phase.area) &&
26
+ !isConsoleTraceEnabled(phase.area + "." + phase.subarea)
27
+ )
179
28
  return;
180
- }
181
- if (triggerIds.size === 0) {
182
- // not an effect trace.
183
- const id = triggerCount++;
184
- triggerIds.add(id);
185
-
186
- if (dids.has(id)) {
187
- // eslint-disable-next-line no-debugger
188
- debugger;
189
- }
190
- }
191
-
192
- const areaTag = ` ${phase.area + ":" + phase.subarea} `;
193
- // eslint-disable-next-line no-console
194
- console.log(
195
- colorText(areaTag, { ...phase, bold: true }) +
196
- " " +
197
- colorText("[" + [...triggerIds].join(",") + "]", {
198
- fg: { r: 50, g: 50, b: 50 },
199
- }) +
200
- " " +
201
- untrack(cb) +
202
- "\n",
203
- );
204
- }
205
-
206
- export function traceEffect(phase: TracePhase, cb: () => string) {
207
- if (!shouldTrace(phase)) {
208
- return;
209
- }
210
29
  let first = true;
211
30
  const triggerIds = new Set<number>();
212
31
 
@@ -218,7 +37,7 @@ export function traceEffect(phase: TracePhase, cb: () => string) {
218
37
  first = false;
219
38
  return;
220
39
  }
221
- trace(phase, cb, triggerIds);
40
+ debug.trace(phase, cb, triggerIds);
222
41
  triggerIds.clear();
223
42
  },
224
43
  {
@@ -235,54 +54,6 @@ export function traceEffect(phase: TracePhase, cb: () => string) {
235
54
  );
236
55
  }
237
56
 
238
- interface Color {
239
- r: number;
240
- g: number;
241
- b: number;
242
- }
243
-
244
- /** Descriptor for how to format the text */
245
- interface TextFormat {
246
- fg?: Color; // optional foreground color
247
- bg?: Color; // optional background color
248
- bold?: boolean; // optional bold flag
249
- }
250
-
251
- /**
252
- * Wraps `text` in ANSI escape codes according to the given format.
253
- *
254
- * @param text The string to format.
255
- * @param fmt Optional formatting descriptor.
256
- * @returns The text wrapped in ANSI codes (or unmodified if no styles given).
257
- */
258
- function colorText(text: string, fmt?: TextFormat): string {
259
- if (!fmt) return text;
260
-
261
- const codes: string[] = [];
262
-
263
- if (fmt.bold) {
264
- codes.push("1"); // ANSI code for bold
265
- }
266
-
267
- if (fmt.fg) {
268
- const { r, g, b } = fmt.fg;
269
- codes.push(`38;2;${r};${g};${b}`);
270
- }
271
-
272
- if (fmt.bg) {
273
- const { r, g, b } = fmt.bg;
274
- codes.push(`48;2;${r};${g};${b}`);
275
- }
276
-
277
- if (codes.length === 0) {
278
- return text;
279
- }
280
-
281
- const prefix = `\x1b[${codes.join(";")}m`;
282
- const reset = `\x1b[0m`;
283
- return `${prefix}${text}${reset}`;
284
- }
285
-
286
57
  /**
287
58
  * Format a symbol name with its ID in a blue-green color
288
59
  * @param symbol The symbol to format
package/src/utils.tsx CHANGED
@@ -1,13 +1,15 @@
1
- import { ref, Ref, toRaw } from "@vue/reactivity";
1
+ import { Ref, toRaw } from "@vue/reactivity";
2
2
  import { BaseListProps } from "./components/List.jsx";
3
3
  import {
4
4
  createCustomContext,
5
5
  CustomContext,
6
6
  Disposable,
7
7
  effect,
8
+ ensureIsEmpty,
8
9
  getContext,
9
10
  memo,
10
11
  onCleanup,
12
+ ref,
11
13
  root,
12
14
  untrack,
13
15
  } from "./reactivity.js";
@@ -128,14 +130,16 @@ export function mapJoin<T, U, V>(
128
130
  }
129
131
  return slot;
130
132
  }
131
- const firstNonEmptyIndex = ref(-1);
132
- const lastNonEmptyIndex = ref(-1);
133
+ const firstNonEmptyIndex = ref(-1, { isInfrastructure: true });
134
+ const lastNonEmptyIndex = ref(-1, { isInfrastructure: true });
133
135
  const mapped: Children[] = [];
134
136
  let enderMemo: (() => Children) | undefined;
135
137
 
136
138
  // Creates a ref placeholder that stores the joiner node for a boundary.
137
139
  function createJoinerRef(): Ref<Children | undefined> {
138
- return ref<unknown>(undefined) as Ref<Children | undefined>;
140
+ return ref<unknown>(undefined, { isInfrastructure: true }) as Ref<
141
+ Children | undefined
142
+ >;
139
143
  }
140
144
 
141
145
  // Makes sure we have a joiner ref at the requested boundary index.
@@ -278,9 +282,6 @@ export function mapJoin<T, U, V>(
278
282
  }
279
283
 
280
284
  const context = getContext();
281
- if (context) {
282
- context.isEmpty ??= ref(true);
283
- }
284
285
  // this is important to access here in reactive context so we are
285
286
  // notified of new items from reactives.
286
287
  const itemsLen = items.length;
@@ -326,23 +327,32 @@ export function mapJoin<T, U, V>(
326
327
  mapped[startIndex * 2] = createCustomContext((cb) => {
327
328
  return root((disposer) => {
328
329
  const nestedContext = getContext()!;
329
- const isEmptyFlag = nestedContext.isEmpty!;
330
+ const isEmptyFlag = ensureIsEmpty(nestedContext);
330
331
 
331
332
  slot.disposer = disposer;
332
333
  disposer();
333
- effect((prev?: boolean) => {
334
- const isEmpty = isEmptyFlag.value;
335
- return untrack(() => {
336
- if (slot.isEmpty.value !== isEmpty) {
337
- slot.isEmpty.value = isEmpty;
338
- }
339
- const wasEmpty = prev ?? true;
340
-
341
- applyEmptyStateChange(cleanupIndex, isEmpty, wasEmpty);
342
-
343
- return isEmpty;
344
- });
345
- });
334
+ effect(
335
+ (prev?: boolean) => {
336
+ const isEmpty = isEmptyFlag.value;
337
+ return untrack(() => {
338
+ if (slot.isEmpty.value !== isEmpty) {
339
+ slot.isEmpty.value = isEmpty;
340
+ }
341
+ const wasEmpty = prev ?? true;
342
+
343
+ applyEmptyStateChange(cleanupIndex, isEmpty, wasEmpty);
344
+
345
+ return isEmpty;
346
+ });
347
+ },
348
+ undefined,
349
+ {
350
+ debug: {
351
+ name: `list:slotEmpty:${cleanupIndex}`,
352
+ type: "list",
353
+ },
354
+ },
355
+ );
346
356
  cb(mapper(items[cleanupIndex], cleanupIndex));
347
357
  });
348
358
  });