@alloy-js/core 0.15.0 → 0.17.0

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