@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
package/src/tracer.ts ADDED
@@ -0,0 +1,474 @@
1
+ import { effect, ReactiveEffectRunner } from "@vue/reactivity";
2
+ import { untrack } from "./reactivity.js";
3
+ import type { Refkey } from "./refkey.js";
4
+ import { scheduler } from "./scheduler.js";
5
+ import { OutputScopeFlags, OutputSymbolFlags } from "./symbols/flags.js";
6
+ import { type OutputScope } from "./symbols/output-scope.js";
7
+ import { type OutputSymbol } from "./symbols/output-symbol.js";
8
+
9
+ // enable tracing for specific phases using a comma separated list of
10
+ // dotted identifiers, e.g. `scope.update,symbol.create`.
11
+ const traceEnv = process.env.ALLOY_TRACE ?? "";
12
+ const tracePhases = new Set<string>(
13
+ traceEnv === "" ? [] : traceEnv.split(",").map((t) => t.trim()),
14
+ );
15
+
16
+ if (tracePhases.size > 0) {
17
+ // eslint-disable-next-line no-console
18
+ console.log(
19
+ "Tracing enabled for phases:",
20
+ Array.from(tracePhases).join(", "),
21
+ );
22
+ }
23
+
24
+ const debuggerIdsEnv = process.env.ALLOY_BREAK_ON_DID ?? "";
25
+ const dids = new Set<number>();
26
+
27
+ debuggerIdsEnv.split(",").forEach((id) => {
28
+ const num = parseInt(id, 10);
29
+ if (!isNaN(num)) {
30
+ dids.add(num);
31
+ }
32
+ });
33
+ export const TracePhase = {
34
+ scope: {
35
+ update: {
36
+ area: "scope",
37
+ subarea: "update",
38
+ bg: { r: 0, g: 255, b: 100 },
39
+ },
40
+ create: {
41
+ area: "scope",
42
+ subarea: "create",
43
+ bg: { r: 0, g: 150, b: 100 },
44
+ },
45
+ copySymbols: {
46
+ area: "scope",
47
+ subarea: "copySymbols",
48
+ bg: { r: 0, g: 100, b: 100 },
49
+ },
50
+ },
51
+ symbol: {
52
+ update: {
53
+ area: "symbol",
54
+ subarea: "update",
55
+ bg: { r: 0, g: 0, b: 255 },
56
+ },
57
+ resolve: {
58
+ area: "symbol",
59
+ subarea: "resolve",
60
+ bg: { r: 0, g: 0, b: 200 },
61
+ },
62
+ create: {
63
+ area: "symbol",
64
+ subarea: "create",
65
+ bg: { r: 0, g: 0, b: 150 },
66
+ },
67
+ flow: {
68
+ area: "symbol",
69
+ subarea: "flow",
70
+ bg: { r: 0, g: 0, b: 100 },
71
+ },
72
+ addToScope: {
73
+ area: "symbol",
74
+ subarea: "addToScope",
75
+ bg: { r: 0, g: 0, b: 50 },
76
+ },
77
+ instantiate: {
78
+ area: "symbol",
79
+ subarea: "instantiate",
80
+ bg: { r: 0, g: 0, b: 25 },
81
+ },
82
+ clone: {
83
+ area: "symbol",
84
+ subarea: "clone",
85
+ bg: { r: 0, g: 0, b: 25 },
86
+ },
87
+ delete: {
88
+ area: "symbol",
89
+ subarea: "delete",
90
+ bg: { r: 100, g: 0, b: 100 },
91
+ },
92
+ removeFromScope: {
93
+ area: "symbol",
94
+ subarea: "removeFromScope",
95
+ bg: { r: 50, g: 0, b: 50 },
96
+ },
97
+ },
98
+ resolve: {
99
+ success: {
100
+ area: "resolve",
101
+ subarea: "success",
102
+ bg: { r: 0, g: 255, b: 0 },
103
+ },
104
+ pending: {
105
+ area: "resolve",
106
+ subarea: "pending",
107
+ bg: { r: 255, g: 255, b: 0 },
108
+ },
109
+ failure: {
110
+ area: "resolve",
111
+ subarea: "failure",
112
+ bg: { r: 100, g: 50, b: 50 },
113
+ },
114
+ },
115
+ effect: {
116
+ schedule: {
117
+ area: "effect",
118
+ subarea: "schedule",
119
+ bg: { r: 100, g: 100, b: 0 },
120
+ },
121
+ track: {
122
+ area: "effect",
123
+ subarea: "track",
124
+ bg: { r: 75, g: 75, b: 0 },
125
+ },
126
+ trigger: {
127
+ area: "effect",
128
+ subarea: "trigger",
129
+ bg: { r: 50, g: 50, b: 0 },
130
+ },
131
+ },
132
+ render: {
133
+ worker: {
134
+ area: "render",
135
+ subarea: "worker",
136
+ bg: { r: 100, g: 50, b: 0 },
137
+ },
138
+ appendChild: {
139
+ area: "render",
140
+ subarea: "appendChild",
141
+ bg: { r: 100, g: 50, b: 0 },
142
+ },
143
+ renderEffect: {
144
+ area: "render",
145
+ subarea: "render effect",
146
+ bg: { r: 100, g: 50, b: 0 },
147
+ },
148
+ },
149
+ } as const;
150
+
151
+ interface TracePhase extends TextFormat {
152
+ area: string;
153
+ subarea: string;
154
+ }
155
+
156
+ let triggerCount = 0;
157
+
158
+ function shouldTrace(phase: TracePhase) {
159
+ return (
160
+ tracePhases.has(phase.area) ||
161
+ tracePhases.has(phase.area + "." + phase.subarea)
162
+ );
163
+ }
164
+ export function trace(
165
+ phase: TracePhase,
166
+ cb: () => string,
167
+ triggerIds: Set<number> = new Set(),
168
+ ) {
169
+ if (!shouldTrace(phase)) {
170
+ return;
171
+ }
172
+ if (triggerIds.size === 0) {
173
+ // not an effect trace.
174
+ const id = triggerCount++;
175
+ triggerIds.add(id);
176
+
177
+ if (dids.has(id)) {
178
+ // eslint-disable-next-line no-debugger
179
+ debugger;
180
+ }
181
+ }
182
+
183
+ const areaTag = ` ${phase.area + ":" + phase.subarea} `;
184
+ // eslint-disable-next-line no-console
185
+ console.log(
186
+ colorText(areaTag, { ...phase, bold: true }) +
187
+ " " +
188
+ colorText("[" + [...triggerIds].join(",") + "]", {
189
+ fg: { r: 50, g: 50, b: 50 },
190
+ }) +
191
+ " " +
192
+ cb() +
193
+ "\n",
194
+ );
195
+ }
196
+
197
+ export function traceEffect(phase: TracePhase, cb: () => string) {
198
+ if (!shouldTrace(phase)) {
199
+ return;
200
+ }
201
+ let first = true;
202
+ const triggerIds = new Set<number>();
203
+
204
+ const runner: ReactiveEffectRunner<void> = effect(
205
+ () => {
206
+ if (first) {
207
+ // just track what we need, don't log.
208
+ cb();
209
+ first = false;
210
+ return;
211
+ }
212
+ trace(phase, cb, triggerIds);
213
+ triggerIds.clear();
214
+ },
215
+ {
216
+ scheduler: scheduler(() => runner, true),
217
+ onTrigger(event) {
218
+ const id = triggerCount++;
219
+ if (dids.has(id)) {
220
+ // eslint-disable-next-line no-debugger
221
+ debugger;
222
+ }
223
+ triggerIds.add(id);
224
+ },
225
+ },
226
+ );
227
+ }
228
+
229
+ interface Color {
230
+ r: number;
231
+ g: number;
232
+ b: number;
233
+ }
234
+
235
+ /** Descriptor for how to format the text */
236
+ interface TextFormat {
237
+ fg?: Color; // optional foreground color
238
+ bg?: Color; // optional background color
239
+ bold?: boolean; // optional bold flag
240
+ }
241
+
242
+ /**
243
+ * Wraps `text` in ANSI escape codes according to the given format.
244
+ *
245
+ * @param text The string to format.
246
+ * @param fmt Optional formatting descriptor.
247
+ * @returns The text wrapped in ANSI codes (or unmodified if no styles given).
248
+ */
249
+ function colorText(text: string, fmt?: TextFormat): string {
250
+ if (!fmt) return text;
251
+
252
+ const codes: string[] = [];
253
+
254
+ if (fmt.bold) {
255
+ codes.push("1"); // ANSI code for bold
256
+ }
257
+
258
+ if (fmt.fg) {
259
+ const { r, g, b } = fmt.fg;
260
+ codes.push(`38;2;${r};${g};${b}`);
261
+ }
262
+
263
+ if (fmt.bg) {
264
+ const { r, g, b } = fmt.bg;
265
+ codes.push(`48;2;${r};${g};${b}`);
266
+ }
267
+
268
+ if (codes.length === 0) {
269
+ return text;
270
+ }
271
+
272
+ const prefix = `\x1b[${codes.join(";")}m`;
273
+ const reset = `\x1b[0m`;
274
+ return `${prefix}${text}${reset}`;
275
+ }
276
+
277
+ /**
278
+ * Format flag values in a concise way, showing only the flags that are set
279
+ * @param flags The numeric flags value to format
280
+ * @param flagEnum The enum containing flag definitions
281
+ * @returns An array of flag names that are set
282
+ */
283
+ function formatFlags<T extends Record<string, string | number>>(
284
+ flags: number,
285
+ flagEnum: T,
286
+ ): string[] {
287
+ return Object.entries(flagEnum)
288
+ .filter(
289
+ ([name, value]) =>
290
+ typeof value === "number" && value !== 0 && (flags & value) === value,
291
+ )
292
+ .map(([name]) => name);
293
+ }
294
+
295
+ /**
296
+ * Format a symbol name with its ID in a blue-green color
297
+ * @param symbol The symbol to format
298
+ * @returns A formatted string representation of the symbol name with ID
299
+ */
300
+ export function formatSymbolName(symbol: OutputSymbol): string {
301
+ return colorText(`Symbol ${symbol.name}[${symbol.id}]`, {
302
+ fg: {
303
+ r: 0,
304
+ b: 150,
305
+ g: 100,
306
+ },
307
+ });
308
+ }
309
+
310
+ /**
311
+ * Format the symbols in a member scope, showing their names and IDs
312
+ * @param scope The member scope containing the symbols to format
313
+ * @returns A formatted string representation of the member scope symbols
314
+ */
315
+ function formatMemberScopeSymbols(scope: OutputScope): string {
316
+ if (!scope || scope.symbols.size === 0) {
317
+ return "none";
318
+ }
319
+
320
+ return Array.from(scope.symbols)
321
+ .map((symbol) => formatSymbolName(symbol))
322
+ .join(", ");
323
+ }
324
+
325
+ export function formatSymbol(symbol: OutputSymbol): string {
326
+ // Base display with name and ID
327
+ let result = formatSymbolName(symbol);
328
+
329
+ // Add details on subsequent lines
330
+ const details: string[] = [];
331
+
332
+ if (!symbol.binder) {
333
+ details.push(colorText(" !UNBOUND", { fg: { r: 255, g: 0, b: 0 } }));
334
+ }
335
+
336
+ // Show only enabled flags
337
+ const flagsInfo = formatFlags(symbol.flags, OutputSymbolFlags);
338
+
339
+ if (flagsInfo.length > 0) {
340
+ details.push(` flags: ${flagsInfo.join(", ")}`);
341
+ }
342
+
343
+ // Show scope info with formatted name
344
+ if (symbol.scope) {
345
+ details.push(untrack(() => ` scope: ${formatScopeName(symbol.scope)}`));
346
+ }
347
+
348
+ // Show member scopes if present
349
+ if (symbol.instanceMemberScope) {
350
+ untrack(() => {
351
+ const memberCount = symbol.instanceMemberScope!.symbols.size;
352
+ details.push(
353
+ ` instance members: ${memberCount} - ${formatMemberScopeSymbols(symbol.instanceMemberScope!)}`,
354
+ );
355
+ });
356
+ }
357
+
358
+ if (symbol.staticMemberScope) {
359
+ untrack(() => {
360
+ const memberCount = symbol.staticMemberScope!.symbols.size;
361
+ details.push(
362
+ ` static members: ${memberCount} - ${formatMemberScopeSymbols(symbol.staticMemberScope!)}`,
363
+ );
364
+ });
365
+ }
366
+
367
+ // Show all refkeys with proper formatting
368
+ if (symbol.refkeys && symbol.refkeys.length > 0) {
369
+ details.push(` refkeys: ${formatRefkeys(symbol.refkeys)}`);
370
+ }
371
+
372
+ if (details.length > 0) {
373
+ result += "\n" + details.join("\n");
374
+ }
375
+
376
+ return result;
377
+ }
378
+
379
+ export function formatScopeName(scope: OutputScope): string {
380
+ let text = colorText(`${scope.name}[${scope.id}]`, {
381
+ fg: {
382
+ r: 0,
383
+ g: 150,
384
+ b: 50,
385
+ },
386
+ });
387
+
388
+ if (scope.owner) {
389
+ text += untrack(() => ` of ${formatSymbolName(scope.owner!)}`);
390
+ }
391
+
392
+ return text;
393
+ }
394
+
395
+ /**
396
+ * Format an OutputScope for display, showing information in a concise format
397
+ * @param scope The scope to format
398
+ * @returns A formatted string representation of the scope
399
+ */
400
+ export function formatScope(scope: OutputSymbol["scope"]): string {
401
+ if (!scope) {
402
+ return "!Undefined scope!";
403
+ }
404
+ // Base display with name
405
+ let result = colorText(`Scope ${formatScopeName(scope)}`, {
406
+ fg: {
407
+ r: 0,
408
+ b: 200,
409
+ g: 100,
410
+ },
411
+ });
412
+
413
+ // Add details on subsequent lines
414
+ const details: string[] = [];
415
+
416
+ if (!scope.binder) {
417
+ details.push(colorText(" !UNBOUND", { fg: { r: 255, g: 0, b: 0 } }));
418
+ }
419
+ // Show only enabled flags
420
+ const flagsInfo = formatFlags(scope.flags, OutputScopeFlags);
421
+
422
+ if (flagsInfo.length > 0) {
423
+ details.push(` flags: ${flagsInfo.join(", ")}`);
424
+ }
425
+
426
+ // Show symbol count
427
+ const symbolCount = scope.symbols.size;
428
+ if (symbolCount > 0) {
429
+ details.push(` symbols: ${symbolCount}`);
430
+ }
431
+
432
+ // Show parent scope if present
433
+ if (scope.parent) {
434
+ details.push(` parent: ${formatScopeName(scope.parent)}`);
435
+ }
436
+
437
+ // Show owner if present (for member scopes)
438
+ if (scope.owner) {
439
+ details.push(` owner: ${formatSymbolName(scope.owner)}`);
440
+ }
441
+
442
+ // Show child scopes if present
443
+ if (scope.children && scope.children.size > 0) {
444
+ details.push(` children: ${scope.children.size}`);
445
+ }
446
+
447
+ if (details.length > 0) {
448
+ result += "\n" + details.join("\n");
449
+ }
450
+
451
+ return result;
452
+ }
453
+
454
+ export function formatRefkeys(refkeys: Refkey[] | Refkey | undefined) {
455
+ if (!refkeys) {
456
+ return "";
457
+ }
458
+
459
+ if (Array.isArray(refkeys)) {
460
+ return refkeys.map(formatRefkey).join(", ");
461
+ }
462
+
463
+ return formatRefkey(refkeys);
464
+ }
465
+
466
+ function formatRefkey(refkey: Refkey): string {
467
+ return colorText(`refkey[${refkey.key}]`, {
468
+ fg: {
469
+ r: 150,
470
+ g: 0,
471
+ b: 0,
472
+ },
473
+ });
474
+ }
package/src/utils.tsx CHANGED
@@ -1,19 +1,21 @@
1
1
  import { toRaw } from "@vue/reactivity";
2
+ import { BaseListProps } from "./components/List.jsx";
2
3
  import {
3
- Children,
4
- ComponentCreator,
5
4
  createCustomContext,
6
5
  CustomContext,
7
6
  Disposable,
8
- isComponentCreator,
9
7
  memo,
10
8
  onCleanup,
11
9
  root,
12
10
  untrack,
13
- } from "./jsx-runtime.js";
11
+ } from "./reactivity.js";
14
12
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
- import { BaseListProps } from "./components/List.jsx";
16
13
  import { OutputDirectory, OutputFile, render } from "./render.js";
14
+ import {
15
+ Children,
16
+ ComponentCreator,
17
+ isComponentCreator,
18
+ } from "./runtime/component.js";
17
19
 
18
20
  export interface JoinOptions {
19
21
  /**