@alloy-js/core 0.16.0 → 0.18.0-dev.2

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 (249) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/binder.d.ts +19 -235
  3. package/dist/src/binder.d.ts.map +1 -1
  4. package/dist/src/binder.js +85 -386
  5. package/dist/src/code.d.ts +1 -1
  6. package/dist/src/code.d.ts.map +1 -1
  7. package/dist/src/components/Block.d.ts +1 -1
  8. package/dist/src/components/Block.d.ts.map +1 -1
  9. package/dist/src/components/Block.js +3 -1
  10. package/dist/src/components/Declaration.d.ts +2 -2
  11. package/dist/src/components/Declaration.d.ts.map +1 -1
  12. package/dist/src/components/Declaration.js +6 -5
  13. package/dist/src/components/For.d.ts +1 -1
  14. package/dist/src/components/For.d.ts.map +1 -1
  15. package/dist/src/components/For.js +1 -1
  16. package/dist/src/components/Indent.d.ts +1 -1
  17. package/dist/src/components/Indent.d.ts.map +1 -1
  18. package/dist/src/components/List.d.ts +1 -1
  19. package/dist/src/components/List.d.ts.map +1 -1
  20. package/dist/src/components/List.js +3 -1
  21. package/dist/src/components/MemberDeclaration.d.ts +3 -3
  22. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  23. package/dist/src/components/MemberDeclaration.js +4 -4
  24. package/dist/src/components/MemberScope.d.ts +2 -2
  25. package/dist/src/components/MemberScope.d.ts.map +1 -1
  26. package/dist/src/components/MemberScope.js +0 -2
  27. package/dist/src/components/Output.d.ts +1 -1
  28. package/dist/src/components/Output.d.ts.map +1 -1
  29. package/dist/src/components/Output.js +1 -1
  30. package/dist/src/components/Prose.d.ts +1 -1
  31. package/dist/src/components/Prose.d.ts.map +1 -1
  32. package/dist/src/components/ReferenceOrContent.d.ts +1 -1
  33. package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
  34. package/dist/src/components/Scope.d.ts +2 -2
  35. package/dist/src/components/Scope.d.ts.map +1 -1
  36. package/dist/src/components/Scope.js +3 -6
  37. package/dist/src/components/Show.d.ts +1 -1
  38. package/dist/src/components/Show.d.ts.map +1 -1
  39. package/dist/src/components/SourceDirectory.d.ts +1 -1
  40. package/dist/src/components/SourceDirectory.d.ts.map +1 -1
  41. package/dist/src/components/SourceDirectory.js +1 -1
  42. package/dist/src/components/SourceFile.d.ts +1 -1
  43. package/dist/src/components/SourceFile.d.ts.map +1 -1
  44. package/dist/src/components/SourceFile.js +1 -1
  45. package/dist/src/components/StatementList.d.ts +1 -1
  46. package/dist/src/components/StatementList.d.ts.map +1 -1
  47. package/dist/src/components/StatementList.js +1 -1
  48. package/dist/src/components/Switch.d.ts +2 -2
  49. package/dist/src/components/Switch.d.ts.map +1 -1
  50. package/dist/src/components/Switch.js +2 -1
  51. package/dist/src/components/Wrap.d.ts +1 -1
  52. package/dist/src/components/Wrap.d.ts.map +1 -1
  53. package/dist/src/context/assignment.d.ts +1 -1
  54. package/dist/src/context/assignment.d.ts.map +1 -1
  55. package/dist/src/context/binder.d.ts +3 -3
  56. package/dist/src/context/binder.d.ts.map +1 -1
  57. package/dist/src/context/declaration.d.ts +1 -1
  58. package/dist/src/context/declaration.d.ts.map +1 -1
  59. package/dist/src/context/member-declaration.d.ts +1 -1
  60. package/dist/src/context/member-declaration.d.ts.map +1 -1
  61. package/dist/src/context/member-declaration.js +0 -1
  62. package/dist/src/context/member-scope.d.ts +1 -1
  63. package/dist/src/context/member-scope.d.ts.map +1 -1
  64. package/dist/src/context/name-policy.d.ts +1 -1
  65. package/dist/src/context/name-policy.d.ts.map +1 -1
  66. package/dist/src/context/scope.d.ts +1 -1
  67. package/dist/src/context/scope.d.ts.map +1 -1
  68. package/dist/src/context/source-directory.d.ts +1 -1
  69. package/dist/src/context/source-directory.d.ts.map +1 -1
  70. package/dist/src/context/source-file.d.ts +2 -2
  71. package/dist/src/context/source-file.d.ts.map +1 -1
  72. package/dist/src/context.d.ts +2 -2
  73. package/dist/src/context.d.ts.map +1 -1
  74. package/dist/src/context.js +1 -1
  75. package/dist/src/debug.d.ts +1 -0
  76. package/dist/src/debug.d.ts.map +1 -1
  77. package/dist/src/debug.js +4 -1
  78. package/dist/src/index.d.ts +8 -2
  79. package/dist/src/index.d.ts.map +1 -1
  80. package/dist/src/index.js +8 -2
  81. package/dist/src/jsx-runtime.d.ts +4 -272
  82. package/dist/src/jsx-runtime.d.ts.map +1 -1
  83. package/dist/src/jsx-runtime.js +3 -315
  84. package/dist/src/props-combinators.d.ts +19 -0
  85. package/dist/src/props-combinators.d.ts.map +1 -0
  86. package/dist/src/props-combinators.js +108 -0
  87. package/dist/src/reactive-union-set.d.ts +29 -0
  88. package/dist/src/reactive-union-set.d.ts.map +1 -0
  89. package/dist/src/reactive-union-set.js +183 -0
  90. package/dist/src/reactivity.d.ts +75 -0
  91. package/dist/src/reactivity.d.ts.map +1 -0
  92. package/dist/src/reactivity.js +141 -0
  93. package/dist/src/refkey.d.ts +36 -0
  94. package/dist/src/refkey.d.ts.map +1 -1
  95. package/dist/src/refkey.js +40 -0
  96. package/dist/src/render.d.ts +5 -1
  97. package/dist/src/render.d.ts.map +1 -1
  98. package/dist/src/render.js +68 -15
  99. package/dist/src/runtime/component.d.ts +24 -0
  100. package/dist/src/runtime/component.d.ts.map +1 -0
  101. package/dist/src/runtime/component.js +19 -0
  102. package/dist/src/runtime/intrinsic.d.ts +168 -0
  103. package/dist/src/runtime/intrinsic.d.ts.map +1 -0
  104. package/dist/src/runtime/intrinsic.js +11 -0
  105. package/dist/src/scheduler.d.ts +2 -2
  106. package/dist/src/scheduler.d.ts.map +1 -1
  107. package/dist/src/scheduler.js +27 -6
  108. package/dist/src/slot.d.ts +2 -2
  109. package/dist/src/slot.d.ts.map +1 -1
  110. package/dist/src/slot.js +1 -1
  111. package/dist/src/stc.d.ts +1 -1
  112. package/dist/src/stc.d.ts.map +1 -1
  113. package/dist/src/sti.d.ts +7 -6
  114. package/dist/src/sti.d.ts.map +1 -1
  115. package/dist/src/sti.js +1 -1
  116. package/dist/src/symbols/flags.d.ts +70 -0
  117. package/dist/src/symbols/flags.d.ts.map +1 -0
  118. package/dist/src/symbols/flags.js +72 -0
  119. package/dist/src/symbols/index.d.ts +7 -0
  120. package/dist/src/symbols/index.d.ts.map +1 -0
  121. package/dist/src/symbols/index.js +6 -0
  122. package/dist/src/symbols/output-scope.d.ts +94 -0
  123. package/dist/src/symbols/output-scope.d.ts.map +1 -0
  124. package/dist/src/symbols/output-scope.js +222 -0
  125. package/dist/src/symbols/output-symbol.d.ts +89 -0
  126. package/dist/src/symbols/output-symbol.d.ts.map +1 -0
  127. package/dist/src/symbols/output-symbol.js +333 -0
  128. package/dist/src/symbols/symbol-flow.d.ts +13 -0
  129. package/dist/src/symbols/symbol-flow.d.ts.map +1 -0
  130. package/dist/src/symbols/symbol-flow.js +74 -0
  131. package/dist/src/symbols/symbol-slot.d.ts +12 -0
  132. package/dist/src/symbols/symbol-slot.d.ts.map +1 -0
  133. package/dist/src/symbols/symbol-slot.js +36 -0
  134. package/dist/src/symbols/symbol-table.d.ts +14 -0
  135. package/dist/src/symbols/symbol-table.d.ts.map +1 -0
  136. package/dist/src/symbols/symbol-table.js +42 -0
  137. package/dist/src/tap.d.ts +3 -2
  138. package/dist/src/tap.d.ts.map +1 -1
  139. package/dist/src/tracer.d.ts +238 -0
  140. package/dist/src/tracer.d.ts.map +1 -0
  141. package/dist/src/tracer.js +496 -0
  142. package/dist/src/tsdoc-metadata.json +1 -1
  143. package/dist/src/utils.d.ts +4 -3
  144. package/dist/src/utils.d.ts.map +1 -1
  145. package/dist/src/utils.js +2 -1
  146. package/dist/test/components/slot.test.js +5 -7
  147. package/dist/test/props-with-defaults.test.js +1 -1
  148. package/dist/test/reactive-union-set.test.d.ts +2 -0
  149. package/dist/test/reactive-union-set.test.d.ts.map +1 -0
  150. package/dist/test/reactive-union-set.test.js +170 -0
  151. package/dist/test/reactivity/cleanup.test.js +2 -1
  152. package/dist/test/reactivity/memo.test.js +1 -1
  153. package/dist/test/reactivity/untrack.test.js +1 -1
  154. package/dist/test/rendering/memoization.test.js +2 -1
  155. package/dist/test/split-props.test.js +1 -1
  156. package/dist/test/symbols/output-scope.test.d.ts +2 -0
  157. package/dist/test/symbols/output-scope.test.d.ts.map +1 -0
  158. package/dist/test/symbols/output-scope.test.js +343 -0
  159. package/dist/test/symbols/output-symbol.test.d.ts +2 -0
  160. package/dist/test/symbols/output-symbol.test.d.ts.map +1 -0
  161. package/dist/test/symbols/output-symbol.test.js +447 -0
  162. package/dist/test/symbols/resolution.test.d.ts +2 -0
  163. package/dist/test/symbols/resolution.test.d.ts.map +1 -0
  164. package/dist/test/symbols/resolution.test.js +141 -0
  165. package/dist/test/symbols/utils.d.ts +25 -0
  166. package/dist/test/symbols/utils.d.ts.map +1 -0
  167. package/dist/test/symbols/utils.js +47 -0
  168. package/dist/testing/extend-expect.d.ts +15 -0
  169. package/dist/testing/extend-expect.d.ts.map +1 -1
  170. package/dist/testing/extend-expect.js +2 -1
  171. package/dist/testing/render.d.ts +1 -1
  172. package/dist/testing/render.d.ts.map +1 -1
  173. package/dist/tsconfig.tsbuildinfo +1 -1
  174. package/package.json +28 -24
  175. package/src/binder.ts +146 -672
  176. package/src/code.ts +1 -1
  177. package/src/components/Block.tsx +4 -1
  178. package/src/components/Declaration.tsx +8 -7
  179. package/src/components/For.tsx +2 -1
  180. package/src/components/Indent.tsx +1 -1
  181. package/src/components/List.tsx +3 -1
  182. package/src/components/MemberDeclaration.tsx +7 -6
  183. package/src/components/MemberScope.tsx +2 -5
  184. package/src/components/Output.tsx +2 -1
  185. package/src/components/Prose.tsx +1 -1
  186. package/src/components/ReferenceOrContent.tsx +1 -1
  187. package/src/components/Scope.tsx +3 -7
  188. package/src/components/Show.tsx +1 -1
  189. package/src/components/SourceDirectory.tsx +2 -1
  190. package/src/components/SourceFile.tsx +2 -1
  191. package/src/components/StatementList.tsx +2 -1
  192. package/src/components/Switch.tsx +2 -1
  193. package/src/components/Wrap.tsx +1 -1
  194. package/src/context/assignment.ts +1 -1
  195. package/src/context/binder.ts +3 -3
  196. package/src/context/declaration.ts +1 -1
  197. package/src/context/member-declaration.ts +1 -1
  198. package/src/context/member-scope.ts +1 -1
  199. package/src/context/name-policy.ts +1 -1
  200. package/src/context/scope.ts +1 -1
  201. package/src/context/source-directory.ts +1 -1
  202. package/src/context/source-file.ts +2 -2
  203. package/src/context.ts +3 -7
  204. package/src/debug.ts +5 -1
  205. package/src/index.ts +15 -1
  206. package/src/jsx-runtime.ts +15 -674
  207. package/src/props-combinators.ts +148 -0
  208. package/src/reactive-union-set.ts +238 -0
  209. package/src/reactivity.ts +230 -0
  210. package/src/refkey.ts +40 -0
  211. package/src/render.ts +97 -26
  212. package/src/runtime/component.ts +67 -0
  213. package/src/runtime/intrinsic.ts +199 -0
  214. package/src/scheduler.ts +31 -6
  215. package/src/slot.ts +3 -4
  216. package/src/stc.ts +2 -2
  217. package/src/sti.ts +11 -11
  218. package/src/symbols/flags.ts +82 -0
  219. package/src/symbols/index.ts +6 -0
  220. package/src/symbols/output-scope.ts +296 -0
  221. package/src/symbols/output-symbol.ts +459 -0
  222. package/src/symbols/symbol-flow.ts +100 -0
  223. package/src/symbols/symbol-slot.tsx +48 -0
  224. package/src/symbols/symbol-table.ts +72 -0
  225. package/src/tap.ts +3 -2
  226. package/src/tracer.ts +474 -0
  227. package/src/utils.tsx +7 -5
  228. package/temp/api.json +7446 -5133
  229. package/test/components/slot.test.tsx +8 -11
  230. package/test/props-with-defaults.test.ts +1 -1
  231. package/test/reactive-union-set.test.tsx +191 -0
  232. package/test/reactivity/cleanup.test.tsx +2 -1
  233. package/test/reactivity/memo.test.tsx +1 -1
  234. package/test/reactivity/untrack.test.ts +1 -1
  235. package/test/rendering/basic.test.tsx +1 -1
  236. package/test/rendering/memoization.test.tsx +1 -1
  237. package/test/split-props.test.ts +1 -1
  238. package/test/symbols/output-scope.test.ts +300 -0
  239. package/test/symbols/output-symbol.test.ts +456 -0
  240. package/test/symbols/resolution.test.ts +170 -0
  241. package/test/symbols/utils.ts +93 -0
  242. package/test/utils.test.tsx +1 -1
  243. package/testing/extend-expect.ts +16 -0
  244. package/testing/render.ts +1 -2
  245. package/LICENSE +0 -7
  246. package/dist/test/symbols.test.d.ts +0 -2
  247. package/dist/test/symbols.test.d.ts.map +0 -1
  248. package/dist/test/symbols.test.js +0 -884
  249. package/test/symbols.test.ts +0 -1006
@@ -0,0 +1,496 @@
1
+ import { effect } from "@vue/reactivity";
2
+ import { untrack } from "./reactivity.js";
3
+ import { scheduler } from "./scheduler.js";
4
+ import { OutputScopeFlags, OutputSymbolFlags } from "./symbols/flags.js";
5
+ // enable tracing for specific phases using a comma separated list of
6
+ // dotted identifiers, e.g. `scope.update,symbol.create`.
7
+ const traceEnv = process.env.ALLOY_TRACE ?? "";
8
+ const tracePhases = new Set(traceEnv === "" ? [] : traceEnv.split(",").map(t => t.trim()));
9
+ if (tracePhases.size > 0) {
10
+ // eslint-disable-next-line no-console
11
+ console.log("Tracing enabled for phases:", Array.from(tracePhases).join(", "));
12
+ }
13
+ const debuggerIdsEnv = process.env.ALLOY_BREAK_ON_DID ?? "";
14
+ const dids = new Set();
15
+ debuggerIdsEnv.split(",").forEach(id => {
16
+ const num = parseInt(id, 10);
17
+ if (!isNaN(num)) {
18
+ dids.add(num);
19
+ }
20
+ });
21
+ export const TracePhase = {
22
+ scope: {
23
+ update: {
24
+ area: "scope",
25
+ subarea: "update",
26
+ bg: {
27
+ r: 0,
28
+ g: 255,
29
+ b: 100
30
+ }
31
+ },
32
+ create: {
33
+ area: "scope",
34
+ subarea: "create",
35
+ bg: {
36
+ r: 0,
37
+ g: 150,
38
+ b: 100
39
+ }
40
+ },
41
+ copySymbols: {
42
+ area: "scope",
43
+ subarea: "copySymbols",
44
+ bg: {
45
+ r: 0,
46
+ g: 100,
47
+ b: 100
48
+ }
49
+ }
50
+ },
51
+ symbol: {
52
+ update: {
53
+ area: "symbol",
54
+ subarea: "update",
55
+ bg: {
56
+ r: 0,
57
+ g: 0,
58
+ b: 255
59
+ }
60
+ },
61
+ resolve: {
62
+ area: "symbol",
63
+ subarea: "resolve",
64
+ bg: {
65
+ r: 0,
66
+ g: 0,
67
+ b: 200
68
+ }
69
+ },
70
+ create: {
71
+ area: "symbol",
72
+ subarea: "create",
73
+ bg: {
74
+ r: 0,
75
+ g: 0,
76
+ b: 150
77
+ }
78
+ },
79
+ flow: {
80
+ area: "symbol",
81
+ subarea: "flow",
82
+ bg: {
83
+ r: 0,
84
+ g: 0,
85
+ b: 100
86
+ }
87
+ },
88
+ addToScope: {
89
+ area: "symbol",
90
+ subarea: "addToScope",
91
+ bg: {
92
+ r: 0,
93
+ g: 0,
94
+ b: 50
95
+ }
96
+ },
97
+ instantiate: {
98
+ area: "symbol",
99
+ subarea: "instantiate",
100
+ bg: {
101
+ r: 0,
102
+ g: 0,
103
+ b: 25
104
+ }
105
+ },
106
+ clone: {
107
+ area: "symbol",
108
+ subarea: "clone",
109
+ bg: {
110
+ r: 0,
111
+ g: 0,
112
+ b: 25
113
+ }
114
+ },
115
+ delete: {
116
+ area: "symbol",
117
+ subarea: "delete",
118
+ bg: {
119
+ r: 100,
120
+ g: 0,
121
+ b: 100
122
+ }
123
+ },
124
+ removeFromScope: {
125
+ area: "symbol",
126
+ subarea: "removeFromScope",
127
+ bg: {
128
+ r: 50,
129
+ g: 0,
130
+ b: 50
131
+ }
132
+ }
133
+ },
134
+ resolve: {
135
+ success: {
136
+ area: "resolve",
137
+ subarea: "success",
138
+ bg: {
139
+ r: 0,
140
+ g: 255,
141
+ b: 0
142
+ }
143
+ },
144
+ pending: {
145
+ area: "resolve",
146
+ subarea: "pending",
147
+ bg: {
148
+ r: 255,
149
+ g: 255,
150
+ b: 0
151
+ }
152
+ },
153
+ failure: {
154
+ area: "resolve",
155
+ subarea: "failure",
156
+ bg: {
157
+ r: 100,
158
+ g: 50,
159
+ b: 50
160
+ }
161
+ }
162
+ },
163
+ effect: {
164
+ schedule: {
165
+ area: "effect",
166
+ subarea: "schedule",
167
+ bg: {
168
+ r: 100,
169
+ g: 100,
170
+ b: 0
171
+ }
172
+ },
173
+ track: {
174
+ area: "effect",
175
+ subarea: "track",
176
+ bg: {
177
+ r: 75,
178
+ g: 75,
179
+ b: 0
180
+ }
181
+ },
182
+ trigger: {
183
+ area: "effect",
184
+ subarea: "trigger",
185
+ bg: {
186
+ r: 50,
187
+ g: 50,
188
+ b: 0
189
+ }
190
+ }
191
+ },
192
+ render: {
193
+ worker: {
194
+ area: "render",
195
+ subarea: "worker",
196
+ bg: {
197
+ r: 100,
198
+ g: 50,
199
+ b: 0
200
+ }
201
+ },
202
+ appendChild: {
203
+ area: "render",
204
+ subarea: "appendChild",
205
+ bg: {
206
+ r: 100,
207
+ g: 50,
208
+ b: 0
209
+ }
210
+ },
211
+ renderEffect: {
212
+ area: "render",
213
+ subarea: "render effect",
214
+ bg: {
215
+ r: 100,
216
+ g: 50,
217
+ b: 0
218
+ }
219
+ }
220
+ }
221
+ };
222
+ let triggerCount = 0;
223
+ function shouldTrace(phase) {
224
+ return tracePhases.has(phase.area) || tracePhases.has(phase.area + "." + phase.subarea);
225
+ }
226
+ export function trace(phase, cb, triggerIds = new Set()) {
227
+ if (!shouldTrace(phase)) {
228
+ return;
229
+ }
230
+ if (triggerIds.size === 0) {
231
+ // not an effect trace.
232
+ const id = triggerCount++;
233
+ triggerIds.add(id);
234
+ if (dids.has(id)) {
235
+ // eslint-disable-next-line no-debugger
236
+ debugger;
237
+ }
238
+ }
239
+ const areaTag = ` ${phase.area + ":" + phase.subarea} `;
240
+ // eslint-disable-next-line no-console
241
+ console.log(colorText(areaTag, {
242
+ ...phase,
243
+ bold: true
244
+ }) + " " + colorText("[" + [...triggerIds].join(",") + "]", {
245
+ fg: {
246
+ r: 50,
247
+ g: 50,
248
+ b: 50
249
+ }
250
+ }) + " " + cb() + "\n");
251
+ }
252
+ export function traceEffect(phase, cb) {
253
+ if (!shouldTrace(phase)) {
254
+ return;
255
+ }
256
+ let first = true;
257
+ const triggerIds = new Set();
258
+ const runner = effect(() => {
259
+ if (first) {
260
+ // just track what we need, don't log.
261
+ cb();
262
+ first = false;
263
+ return;
264
+ }
265
+ trace(phase, cb, triggerIds);
266
+ triggerIds.clear();
267
+ }, {
268
+ scheduler: scheduler(() => runner, true),
269
+ onTrigger(event) {
270
+ const id = triggerCount++;
271
+ if (dids.has(id)) {
272
+ // eslint-disable-next-line no-debugger
273
+ debugger;
274
+ }
275
+ triggerIds.add(id);
276
+ }
277
+ });
278
+ }
279
+
280
+ /** Descriptor for how to format the text */
281
+
282
+ /**
283
+ * Wraps `text` in ANSI escape codes according to the given format.
284
+ *
285
+ * @param text The string to format.
286
+ * @param fmt Optional formatting descriptor.
287
+ * @returns The text wrapped in ANSI codes (or unmodified if no styles given).
288
+ */
289
+ function colorText(text, fmt) {
290
+ if (!fmt) return text;
291
+ const codes = [];
292
+ if (fmt.bold) {
293
+ codes.push("1"); // ANSI code for bold
294
+ }
295
+ if (fmt.fg) {
296
+ const {
297
+ r,
298
+ g,
299
+ b
300
+ } = fmt.fg;
301
+ codes.push(`38;2;${r};${g};${b}`);
302
+ }
303
+ if (fmt.bg) {
304
+ const {
305
+ r,
306
+ g,
307
+ b
308
+ } = fmt.bg;
309
+ codes.push(`48;2;${r};${g};${b}`);
310
+ }
311
+ if (codes.length === 0) {
312
+ return text;
313
+ }
314
+ const prefix = `\x1b[${codes.join(";")}m`;
315
+ const reset = `\x1b[0m`;
316
+ return `${prefix}${text}${reset}`;
317
+ }
318
+
319
+ /**
320
+ * Format flag values in a concise way, showing only the flags that are set
321
+ * @param flags The numeric flags value to format
322
+ * @param flagEnum The enum containing flag definitions
323
+ * @returns An array of flag names that are set
324
+ */
325
+ function formatFlags(flags, flagEnum) {
326
+ return Object.entries(flagEnum).filter(([name, value]) => typeof value === "number" && value !== 0 && (flags & value) === value).map(([name]) => name);
327
+ }
328
+
329
+ /**
330
+ * Format a symbol name with its ID in a blue-green color
331
+ * @param symbol The symbol to format
332
+ * @returns A formatted string representation of the symbol name with ID
333
+ */
334
+ export function formatSymbolName(symbol) {
335
+ return colorText(`Symbol ${symbol.name}[${symbol.id}]`, {
336
+ fg: {
337
+ r: 0,
338
+ b: 150,
339
+ g: 100
340
+ }
341
+ });
342
+ }
343
+
344
+ /**
345
+ * Format the symbols in a member scope, showing their names and IDs
346
+ * @param scope The member scope containing the symbols to format
347
+ * @returns A formatted string representation of the member scope symbols
348
+ */
349
+ function formatMemberScopeSymbols(scope) {
350
+ if (!scope || scope.symbols.size === 0) {
351
+ return "none";
352
+ }
353
+ return Array.from(scope.symbols).map(symbol => formatSymbolName(symbol)).join(", ");
354
+ }
355
+ export function formatSymbol(symbol) {
356
+ // Base display with name and ID
357
+ let result = formatSymbolName(symbol);
358
+
359
+ // Add details on subsequent lines
360
+ const details = [];
361
+ if (!symbol.binder) {
362
+ details.push(colorText(" !UNBOUND", {
363
+ fg: {
364
+ r: 255,
365
+ g: 0,
366
+ b: 0
367
+ }
368
+ }));
369
+ }
370
+
371
+ // Show only enabled flags
372
+ const flagsInfo = formatFlags(symbol.flags, OutputSymbolFlags);
373
+ if (flagsInfo.length > 0) {
374
+ details.push(` flags: ${flagsInfo.join(", ")}`);
375
+ }
376
+
377
+ // Show scope info with formatted name
378
+ if (symbol.scope) {
379
+ details.push(untrack(() => ` scope: ${formatScopeName(symbol.scope)}`));
380
+ }
381
+
382
+ // Show member scopes if present
383
+ if (symbol.instanceMemberScope) {
384
+ untrack(() => {
385
+ const memberCount = symbol.instanceMemberScope.symbols.size;
386
+ details.push(` instance members: ${memberCount} - ${formatMemberScopeSymbols(symbol.instanceMemberScope)}`);
387
+ });
388
+ }
389
+ if (symbol.staticMemberScope) {
390
+ untrack(() => {
391
+ const memberCount = symbol.staticMemberScope.symbols.size;
392
+ details.push(` static members: ${memberCount} - ${formatMemberScopeSymbols(symbol.staticMemberScope)}`);
393
+ });
394
+ }
395
+
396
+ // Show all refkeys with proper formatting
397
+ if (symbol.refkeys && symbol.refkeys.length > 0) {
398
+ details.push(` refkeys: ${formatRefkeys(symbol.refkeys)}`);
399
+ }
400
+ if (details.length > 0) {
401
+ result += "\n" + details.join("\n");
402
+ }
403
+ return result;
404
+ }
405
+ export function formatScopeName(scope) {
406
+ let text = colorText(`${scope.name}[${scope.id}]`, {
407
+ fg: {
408
+ r: 0,
409
+ g: 150,
410
+ b: 50
411
+ }
412
+ });
413
+ if (scope.owner) {
414
+ text += untrack(() => ` of ${formatSymbolName(scope.owner)}`);
415
+ }
416
+ return text;
417
+ }
418
+
419
+ /**
420
+ * Format an OutputScope for display, showing information in a concise format
421
+ * @param scope The scope to format
422
+ * @returns A formatted string representation of the scope
423
+ */
424
+ export function formatScope(scope) {
425
+ if (!scope) {
426
+ return "!Undefined scope!";
427
+ }
428
+ // Base display with name
429
+ let result = colorText(`Scope ${formatScopeName(scope)}`, {
430
+ fg: {
431
+ r: 0,
432
+ b: 200,
433
+ g: 100
434
+ }
435
+ });
436
+
437
+ // Add details on subsequent lines
438
+ const details = [];
439
+ if (!scope.binder) {
440
+ details.push(colorText(" !UNBOUND", {
441
+ fg: {
442
+ r: 255,
443
+ g: 0,
444
+ b: 0
445
+ }
446
+ }));
447
+ }
448
+ // Show only enabled flags
449
+ const flagsInfo = formatFlags(scope.flags, OutputScopeFlags);
450
+ if (flagsInfo.length > 0) {
451
+ details.push(` flags: ${flagsInfo.join(", ")}`);
452
+ }
453
+
454
+ // Show symbol count
455
+ const symbolCount = scope.symbols.size;
456
+ if (symbolCount > 0) {
457
+ details.push(` symbols: ${symbolCount}`);
458
+ }
459
+
460
+ // Show parent scope if present
461
+ if (scope.parent) {
462
+ details.push(` parent: ${formatScopeName(scope.parent)}`);
463
+ }
464
+
465
+ // Show owner if present (for member scopes)
466
+ if (scope.owner) {
467
+ details.push(` owner: ${formatSymbolName(scope.owner)}`);
468
+ }
469
+
470
+ // Show child scopes if present
471
+ if (scope.children && scope.children.size > 0) {
472
+ details.push(` children: ${scope.children.size}`);
473
+ }
474
+ if (details.length > 0) {
475
+ result += "\n" + details.join("\n");
476
+ }
477
+ return result;
478
+ }
479
+ export function formatRefkeys(refkeys) {
480
+ if (!refkeys) {
481
+ return "";
482
+ }
483
+ if (Array.isArray(refkeys)) {
484
+ return refkeys.map(formatRefkey).join(", ");
485
+ }
486
+ return formatRefkey(refkeys);
487
+ }
488
+ function formatRefkey(refkey) {
489
+ return colorText(`refkey[${refkey.key}]`, {
490
+ fg: {
491
+ r: 150,
492
+ g: 0,
493
+ b: 0
494
+ }
495
+ });
496
+ }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.12"
8
+ "packageVersion": "7.52.8"
9
9
  }
10
10
  ]
11
11
  }
@@ -1,6 +1,7 @@
1
- import { Children, ComponentCreator, CustomContext } from "./jsx-runtime.js";
2
1
  import { BaseListProps } from "./components/List.jsx";
2
+ import { CustomContext } from "./reactivity.js";
3
3
  import { OutputDirectory, OutputFile } from "./render.js";
4
+ import { Children, ComponentCreator } from "./runtime/component.js";
4
5
  export interface JoinOptions {
5
6
  /**
6
7
  * The string to place between each element.
@@ -60,8 +61,8 @@ export interface ChildrenOptions {
60
61
  */
61
62
  export declare function children(fn: () => Children, options?: ChildrenOptions): () => Children;
62
63
  export declare function childrenArray(fn: () => Children, options?: ChildrenOptions): Children[];
63
- export declare function findKeyedChild(children: Children[], tag: symbol): ComponentCreator<import("@alloy-js/core/jsx-runtime").Props> | null;
64
- export declare function findKeyedChildren(children: Children[], tag: symbol): ComponentCreator<import("@alloy-js/core/jsx-runtime").Props>[];
64
+ export declare function findKeyedChild(children: Children[], tag: symbol): ComponentCreator<import("./runtime/component.js").Props> | null;
65
+ export declare function findKeyedChildren(children: Children[], tag: symbol): ComponentCreator<import("./runtime/component.js").Props>[];
65
66
  export declare function findUnkeyedChildren(children: Children[]): Children[];
66
67
  export declare function isKeyedChild(child: Children): child is ComponentCreator;
67
68
  /**
@@ -1 +1 @@
1
- {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OAAO,GAAE,eAAoB,GAC5B,MAAM,QAAQ,CAsBhB;AAED,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,QAAQ,EAClB,OAAO,CAAC,EAAE,eAAe,GACxB,QAAQ,EAAE,CASZ;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,mEAQ/D;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,8DAQlE;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAEvD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,IAAI,gBAAgB,CAEvE;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,cAAc,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;IACjD,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,aAAa,QAUvB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CAuC5E"}
package/dist/src/utils.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
2
  import { toRaw } from "@vue/reactivity";
3
- import { createCustomContext, isComponentCreator, memo, onCleanup, root, untrack } from "./jsx-runtime.js";
3
+ import { createCustomContext, memo, onCleanup, root, untrack } from "./reactivity.js";
4
4
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
5
 
6
+ import { isComponentCreator } from "./runtime/component.js";
6
7
  const defaultJoinOptions = {
7
8
  joiner: "\n",
8
9
  ender: false
@@ -5,6 +5,7 @@ import { SourceFile } from "../../src/components/SourceFile.js";
5
5
  import { Declaration, Name, refkey, Scope, useBinder } from "../../src/index.js";
6
6
  import { render } from "../../src/render.js";
7
7
  import { defineSlot, rename, replace } from "../../src/slot.js";
8
+ import { OutputSymbol } from "../../src/symbols/output-symbol.js";
8
9
  import "../../testing/extend-expect.js";
9
10
  it("works with string keys", () => {
10
11
  const FunctionSlot = defineSlot(query => query.name);
@@ -44,9 +45,8 @@ it("works with symbols", () => {
44
45
  });
45
46
  function MyFunctionComponent(props) {
46
47
  const binder = useBinder();
47
- const sym = binder.createSymbol({
48
- name: props.name,
49
- refkey: refkey()
48
+ const sym = new OutputSymbol(props.name, {
49
+ refkeys: refkey()
50
50
  });
51
51
  const FunctionSlotInstance = FunctionSlot.create(sym, {
52
52
  ...props,
@@ -92,10 +92,8 @@ it("can rename", () => {
92
92
  return binder.resolveFQN(query.fqn);
93
93
  });
94
94
  function MyFunctionComponent(props) {
95
- const binder = useBinder();
96
- const sym = binder.createSymbol({
97
- name: props.name,
98
- refkey: refkey()
95
+ const sym = new OutputSymbol(props.name, {
96
+ refkeys: refkey()
99
97
  });
100
98
  const FunctionSlotInstance = FunctionSlot.create(sym, {
101
99
  ...props,
@@ -1,6 +1,6 @@
1
1
  import { effect, reactive } from "@vue/reactivity";
2
2
  import { expect, it, vi } from "vitest";
3
- import { defaultProps } from "../src/jsx-runtime.js";
3
+ import { defaultProps } from "../src/props-combinators.js";
4
4
  it("applies defaults to regular object props", () => {
5
5
  const props = {
6
6
  a: 1,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=reactive-union-set.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive-union-set.test.d.ts","sourceRoot":"","sources":["../../test/reactive-union-set.test.tsx"],"names":[],"mappings":""}