@alloy-js/typescript 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 (136) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/src/builtins/node.d.ts +9 -41
  3. package/dist/src/builtins/node.d.ts.map +1 -1
  4. package/dist/src/components/ArrowFunction.d.ts +3 -3
  5. package/dist/src/components/BarrelFile.d.ts +1 -1
  6. package/dist/src/components/BarrelFile.d.ts.map +1 -1
  7. package/dist/src/components/BlockScope.d.ts +1 -1
  8. package/dist/src/components/BlockScope.d.ts.map +1 -1
  9. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  10. package/dist/src/components/ClassDeclaration.js +5 -7
  11. package/dist/src/components/Declaration.d.ts.map +1 -1
  12. package/dist/src/components/Declaration.js +3 -4
  13. package/dist/src/components/EnumDeclaration.d.ts +1 -1
  14. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  15. package/dist/src/components/EnumDeclaration.js +3 -4
  16. package/dist/src/components/EnumMember.d.ts.map +1 -1
  17. package/dist/src/components/EnumMember.js +3 -4
  18. package/dist/src/components/FunctionBase.d.ts +4 -4
  19. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  20. package/dist/src/components/FunctionBase.js +15 -10
  21. package/dist/src/components/FunctionDeclaration.d.ts +3 -3
  22. package/dist/src/components/FunctionExpression.d.ts +3 -3
  23. package/dist/src/components/FunctionType.d.ts +2 -2
  24. package/dist/src/components/ImportStatement.d.ts +1 -1
  25. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  26. package/dist/src/components/Interface.js +1 -1
  27. package/dist/src/components/InterfaceMethod.d.ts +2 -2
  28. package/dist/src/components/MemberDeclaration.d.ts +1 -1
  29. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  30. package/dist/src/components/MemberDeclaration.js +4 -4
  31. package/dist/src/components/MemberExpression.d.ts +27 -5
  32. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  33. package/dist/src/components/MemberExpression.js +327 -89
  34. package/dist/src/components/NewExpression.d.ts +5 -0
  35. package/dist/src/components/NewExpression.d.ts.map +1 -0
  36. package/dist/src/components/NewExpression.js +12 -0
  37. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  38. package/dist/src/components/ObjectExpression.js +14 -15
  39. package/dist/src/components/PackageDirectory.d.ts.map +1 -1
  40. package/dist/src/components/PackageDirectory.js +3 -3
  41. package/dist/src/components/PackageJson.d.ts +1 -1
  42. package/dist/src/components/PackageJson.d.ts.map +1 -1
  43. package/dist/src/components/PropertyName.d.ts +1 -1
  44. package/dist/src/components/PropertyName.d.ts.map +1 -1
  45. package/dist/src/components/Reference.d.ts +1 -1
  46. package/dist/src/components/Reference.d.ts.map +1 -1
  47. package/dist/src/components/Reference.js +5 -1
  48. package/dist/src/components/SourceFile.d.ts.map +1 -1
  49. package/dist/src/components/SourceFile.js +3 -3
  50. package/dist/src/components/TsConfigJson.d.ts +1 -1
  51. package/dist/src/components/TsConfigJson.d.ts.map +1 -1
  52. package/dist/src/components/TypeDeclaration.d.ts +1 -1
  53. package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
  54. package/dist/src/components/VarDeclaration.d.ts.map +1 -1
  55. package/dist/src/components/VarDeclaration.js +30 -10
  56. package/dist/src/components/index.d.ts +1 -1
  57. package/dist/src/components/index.d.ts.map +1 -1
  58. package/dist/src/components/index.js +1 -1
  59. package/dist/src/components/stc/index.d.ts +45 -44
  60. package/dist/src/components/stc/index.d.ts.map +1 -1
  61. package/dist/src/components/stc/index.js +46 -45
  62. package/dist/src/create-package.d.ts +62 -18
  63. package/dist/src/create-package.d.ts.map +1 -1
  64. package/dist/src/create-package.js +153 -15
  65. package/dist/src/source-directory-data.d.ts.map +1 -1
  66. package/dist/src/source-directory-data.js +2 -2
  67. package/dist/src/symbols/reference.d.ts +2 -1
  68. package/dist/src/symbols/reference.d.ts.map +1 -1
  69. package/dist/src/symbols/reference.js +3 -4
  70. package/dist/src/symbols/scopes.d.ts +1 -4
  71. package/dist/src/symbols/scopes.d.ts.map +1 -1
  72. package/dist/src/symbols/ts-member-scope.d.ts +4 -6
  73. package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
  74. package/dist/src/symbols/ts-member-scope.js +8 -10
  75. package/dist/src/symbols/ts-module-scope.d.ts +8 -11
  76. package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
  77. package/dist/src/symbols/ts-module-scope.js +47 -40
  78. package/dist/src/symbols/ts-output-symbol.d.ts +23 -16
  79. package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
  80. package/dist/src/symbols/ts-output-symbol.js +88 -27
  81. package/dist/src/symbols/ts-package-scope.d.ts +18 -14
  82. package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
  83. package/dist/src/symbols/ts-package-scope.js +78 -27
  84. package/dist/test/class.test.js +2 -1
  85. package/dist/test/externals.test.js +87 -2
  86. package/dist/test/function-declaration.test.js +74 -3
  87. package/dist/test/member-expression.test.js +391 -5
  88. package/dist/test/new-expression.test.d.ts +2 -0
  89. package/dist/test/new-expression.test.d.ts.map +1 -0
  90. package/dist/test/new-expression.test.js +62 -0
  91. package/dist/test/var-declaration.test.d.ts.map +1 -1
  92. package/dist/test/var-declaration.test.js +145 -2
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/package.json +4 -4
  95. package/src/components/ClassDeclaration.tsx +5 -7
  96. package/src/components/Declaration.tsx +3 -8
  97. package/src/components/EnumDeclaration.tsx +3 -4
  98. package/src/components/EnumMember.tsx +3 -4
  99. package/src/components/FunctionBase.tsx +25 -18
  100. package/src/components/ImportStatement.tsx +0 -1
  101. package/src/components/Interface.tsx +1 -1
  102. package/src/components/MemberDeclaration.tsx +5 -8
  103. package/src/components/MemberExpression.tsx +416 -103
  104. package/src/components/NewExpression.tsx +25 -0
  105. package/src/components/ObjectExpression.tsx +18 -16
  106. package/src/components/PackageDirectory.tsx +2 -10
  107. package/src/components/Reference.tsx +4 -2
  108. package/src/components/SourceFile.tsx +2 -5
  109. package/src/components/VarDeclaration.tsx +34 -11
  110. package/src/components/index.ts +1 -1
  111. package/src/components/stc/index.ts +46 -45
  112. package/src/create-package.ts +274 -35
  113. package/src/source-directory-data.ts +2 -2
  114. package/src/symbols/reference.ts +10 -5
  115. package/src/symbols/scopes.ts +1 -6
  116. package/src/symbols/ts-member-scope.ts +8 -23
  117. package/src/symbols/ts-module-scope.ts +58 -62
  118. package/src/symbols/ts-output-symbol.ts +108 -50
  119. package/src/symbols/ts-package-scope.ts +71 -53
  120. package/temp/api.json +1665 -1733
  121. package/test/class.test.tsx +2 -1
  122. package/test/externals.test.tsx +99 -1
  123. package/test/function-declaration.test.tsx +75 -2
  124. package/test/member-expression.test.tsx +312 -8
  125. package/test/new-expression.test.tsx +42 -0
  126. package/test/values.test.tsx +1 -0
  127. package/test/var-declaration.test.tsx +101 -1
  128. package/tsdoc-metadata.json +1 -1
  129. package/dist/src/components/MemberChainExpression.d.ts +0 -11
  130. package/dist/src/components/MemberChainExpression.d.ts.map +0 -1
  131. package/dist/src/components/MemberChainExpression.js +0 -98
  132. package/dist/test/member-chain.test.d.ts +0 -2
  133. package/dist/test/member-chain.test.d.ts.map +0 -1
  134. package/dist/test/member-chain.test.js +0 -141
  135. package/src/components/MemberChainExpression.tsx +0 -91
  136. package/test/member-chain.test.tsx +0 -124
@@ -1,5 +1,5 @@
1
1
  import { createIntrinsic as _$createIntrinsic, memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { childrenArray, computed, For, isComponentCreator, ref, toRef, useBinder } from "@alloy-js/core";
2
+ import { childrenArray, computed, For, isComponentCreator, reactive, ref, Show, takeSymbols, useBinder } from "@alloy-js/core";
3
3
  import { TSSymbolFlags } from "../symbols/ts-output-symbol.js";
4
4
  import { isValidJSIdentifier } from "../utils.js";
5
5
  /**
@@ -7,12 +7,18 @@ import { isValidJSIdentifier } from "../utils.js";
7
7
  * the following:
8
8
  *
9
9
  * * **id**: The identifier for the member expression part
10
- * * **refkey**: A refkey for a symbol whose name becomes the identifier
10
+ * * **refkey**: a refkey for a symbol whose name becomes the identifier
11
11
  * * **symbol**: a symbol whose name becomes the identifier part
12
12
  * * **args**: create a method call with the given args
13
+ * * **children**: arbitrary contents for the identifier part.
14
+ *
15
+ * Each part can have a nullish prop, which indicates that the part may be null
16
+ * or undefined.
13
17
  *
14
- * Additionally, a part can be `nullish`, which means subsequent parts
15
- * will use the appropriate conditional access operator e.g. `?.`.
18
+ * Each part can also have a quoteId prop, which indicates that the identifier
19
+ * of the part should be quoted (i.e. `["foo"]` instead of `.foo`). This is only
20
+ * necessary when providing the children prop, otherwise it is determined
21
+ * automatically.
16
22
  *
17
23
  * @example
18
24
  *
@@ -22,6 +28,7 @@ import { isValidJSIdentifier } from "../utils.js";
22
28
  * <MemberExpression.Part refkey={rk} nullish />
23
29
  * <MemberExpression.Part symbol={sym} />
24
30
  * <MemberExpression.Part args={["hello", "world"]} />
31
+ * <MemberExpression.Part>SomeValue</MemberExpression.Part>
25
32
  * </MemberExpression>
26
33
  * ```
27
34
  *
@@ -29,119 +36,330 @@ import { isValidJSIdentifier } from "../utils.js";
29
36
  * with a name of "prop2", this will render:
30
37
  *
31
38
  * ```ts
32
- * base.prop1?.prop2("hello", "world")
39
+ * base.prop1?.prop2("hello", "world").SomeValue
33
40
  * ```
34
41
  */
35
42
  export function MemberExpression(props) {
36
43
  const children = flattenMemberExpression(childrenArray(() => props.children));
44
+ const parts = childrenToPartDescriptors(children);
45
+ // any symbols emitted from the children won't be relevant to
46
+ // parent scopes. TODO: emit the proper symbol if we know it?
47
+ takeSymbols();
48
+ if (parts.length === 0) {
49
+ return [];
50
+ }
51
+ const isCallChain = computed(() => {
52
+ let callCount = 0;
53
+ for (const part of parts) {
54
+ if (part.args !== undefined) callCount++;
55
+ }
56
+ return callCount > 1;
57
+ });
58
+
59
+ // construct a member expression from the parts. When a part is nullish,
60
+ // and there is a subsequent part, we use `?.` instead of `.`. accessStyle determines
61
+ // whether we use dot or bracket notation.
62
+
63
+ return computed(() => {
64
+ return isCallChain.value ? formatCallChain(parts) : formatNonCallChain(parts);
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Build part descriptors from the children of a MemberExpression.
70
+ */
71
+ function childrenToPartDescriptors(children) {
37
72
  const parts = [];
38
73
  for (const child of children) {
39
74
  if (!isComponentCreator(child, MemberExpression.Part)) {
40
75
  // we ignore non-parts
41
76
  continue;
42
77
  }
43
- const partProps = child.props;
44
- const part = {
45
- base: "",
46
- accessStyle: ref("dot"),
47
- nullish: ref(!!partProps.nullish)
48
- };
49
- if (partProps.id) {
50
- part.base = partProps.id;
51
- part.accessStyle.value = accessStyleForMemberName(partProps.id);
52
- } else if (partProps.refkey) {
53
- const binder = useBinder();
54
- const symbolRef = binder.getSymbolForRefkey(partProps.refkey);
55
- part.base = computed(() => {
56
- if (symbolRef.value) {
57
- part.nullish.value = !!(symbolRef.value.tsFlags & TSSymbolFlags.Nullish);
58
- part.accessStyle.value = accessStyleForMemberName(symbolRef.value.name);
59
- return symbolRef.value.name;
60
- } else {
61
- return "<unresolved symbol>";
62
- }
63
- });
64
- } else if (partProps.symbol) {
65
- part.nullish.value = !!(partProps.symbol.tsFlags & TSSymbolFlags.Nullish);
66
- part.accessStyle = computed(() => {
67
- return accessStyleForMemberName(partProps.symbol.name);
68
- });
69
- part.base = toRef(partProps.symbol, "name");
70
- } else if (partProps.args) {
71
- part.args = partProps.args;
72
- }
73
- parts.push(part);
78
+ parts.push(createPartDescriptorFromProps(child.props, child === children[0]));
74
79
  }
75
- if (parts.length === 0) {
76
- return [];
80
+ return parts;
81
+ }
82
+ const exclusiveParts = ["children", "args", "refkey", "symbol", "id"];
83
+ /**
84
+ * Creates a reactive part descriptor from the given part props.
85
+ *
86
+ * @param partProps The props for the part.
87
+ * @param first Whether this is the first part in the expression. Refkeys are
88
+ * handled specially for the first part.
89
+ */
90
+ function createPartDescriptorFromProps(partProps, first) {
91
+ const foundProps = exclusiveParts.filter(key => {
92
+ return key in partProps;
93
+ });
94
+ if (foundProps.length > 1) {
95
+ throw new Error(`Only one of ${foundProps.join(", ")} can be used for a MemberExpression part at a time`);
77
96
  }
97
+ const symbolSource = computed(() => {
98
+ if (partProps.refkey) {
99
+ return getSymbolForRefkey(partProps.refkey).value;
100
+ } else if (partProps.symbol) {
101
+ return partProps.symbol;
102
+ } else {
103
+ return undefined;
104
+ }
105
+ });
106
+ const part = {
107
+ id: computed(() => {
108
+ if (partProps.args) {
109
+ return undefined;
110
+ } else if (partProps.children !== undefined) {
111
+ return partProps.children;
112
+ } else if (first && partProps.refkey) {
113
+ return partProps.refkey;
114
+ } else if (partProps.id !== undefined) {
115
+ return isNumericIdentifier(partProps.id) ? partProps.id : escapeId(partProps.id);
116
+ } else if (partProps.index !== undefined) {
117
+ return partProps.index;
118
+ } else if (symbolSource.value) {
119
+ return escapeId(symbolSource.value.name);
120
+ } else {
121
+ return "<unresolved symbol>";
122
+ }
123
+ }),
124
+ accessStyle: computed(() => {
125
+ if (partProps.children !== undefined) {
126
+ if (typeof partProps.children === "string") {
127
+ return partProps.quoteId ? "bracket" : accessStyleForMemberName(partProps.children);
128
+ }
129
+ return "bracket";
130
+ } else if (partProps.args) {
131
+ // not used
132
+ return "dot";
133
+ } else if (partProps.quoteId) {
134
+ return "bracket";
135
+ } else if (partProps.id !== undefined) {
136
+ return isNumericIdentifier(partProps.id) ? "bracket" : accessStyleForMemberName(partProps.id);
137
+ } else if (partProps.index !== undefined) {
138
+ return "bracket";
139
+ } else if (symbolSource.value) {
140
+ return accessStyleForMemberName(symbolSource.value.name);
141
+ } else {
142
+ return "dot";
143
+ }
144
+ }),
145
+ quoteId: computed(() => {
146
+ if (partProps.quoteId) {
147
+ return partProps.quoteId;
148
+ } else if (partProps.id !== undefined) {
149
+ return isNumericIdentifier(partProps.id) ? false : !isValidJSIdentifier(partProps.id);
150
+ } else if (symbolSource.value) {
151
+ return !isValidJSIdentifier(symbolSource.value.name);
152
+ } else {
153
+ return false;
154
+ }
155
+ }),
156
+ nullish: computed(() => {
157
+ if (partProps.nullish) {
158
+ return partProps.nullish;
159
+ }
160
+ if (symbolSource.value) {
161
+ return isNullish(symbolSource.value);
162
+ }
163
+ return false;
164
+ }),
165
+ args: ref(partProps.args === true ? [] : partProps.args)
166
+ };
167
+ return reactive(part);
168
+ }
78
169
 
79
- // construct a member expression from the parts. When a part is nullish,
80
- // and there is a subsequent part, we use `?.` instead of `.`. accessStyle determines
81
- // whether we use dot or bracket notation.
170
+ /**
171
+ * replaces quotes with escaped quotes
172
+ */
173
+ function escapeId(id) {
174
+ return id.replace(/"/g, '\\"');
175
+ }
82
176
 
83
- const result = computed(() => {
177
+ /**
178
+ * Convert a refkey to a symbol ref using the current binder.
179
+ */
180
+ function getSymbolForRefkey(refkey) {
181
+ const binder = useBinder();
182
+ return binder.getSymbolForRefkey(refkey);
183
+ }
184
+
185
+ /**
186
+ * Check if the given symbol is nullish.
187
+ */
188
+ function isNullish(symbol) {
189
+ return !!(symbol.tsFlags & TSSymbolFlags.Nullish);
190
+ }
191
+
192
+ /**
193
+ * Formatting of call chains (i.e. member expressions which have more than one
194
+ * call in them). The general approach is that line breaks occur after each
195
+ * call, and there is only one call per line. When there are non-call elements,
196
+ * they occur prior to the call part. The first part of the member expression
197
+ * contains all but the last non-call part.
198
+ *
199
+ * The following is an example of proper formatting:
200
+ *
201
+ * ```ts
202
+ * z.dummy // all but the last non-call part for the first element
203
+ * .object({ // the first call part with line break after
204
+ * a: 1,
205
+ * })
206
+ * .dummy.partial() // the next call part with non-call parts before it
207
+ * ```
208
+ */
209
+ function formatCallChain(parts) {
210
+ return computed(() => {
211
+ const expression = [];
212
+
213
+ // break the expression into parts.
214
+ const chunks = [];
215
+
216
+ // the first part is all the non-call parts
217
+ let partIndex = 0;
218
+ function pushPart() {
219
+ const part = parts[partIndex];
220
+ if (!part) throw new Error("No part to push");
221
+ chunks.at(-1).push(part);
222
+ partIndex++;
223
+ }
224
+ function pushChunk() {
225
+ chunks.push([]);
226
+ }
227
+
228
+ // For the first chunk, take all the non-call parts except the last one
229
+ // and put them in a chunk.
230
+ pushChunk();
231
+ while (partIndex < parts.length && (partIndex === parts.length - 1 || chunks.at(-1).length === 0 || parts[partIndex + 1].args === undefined)) {
232
+ pushPart();
233
+ if (chunks.at(-1).at(-1).args !== undefined) {
234
+ // the first segment always ends after we see a call
235
+ // if we happen to take one
236
+ break;
237
+ }
238
+ }
239
+
240
+ // then for all remaining parts, collect all the non-call parts and end with
241
+ // a call chunk
242
+ while (partIndex < parts.length) {
243
+ pushChunk();
244
+ while (partIndex < parts.length && !parts[partIndex].args) {
245
+ pushPart();
246
+ }
247
+ while (partIndex < parts.length && parts[partIndex].args) {
248
+ pushPart();
249
+ }
250
+ }
251
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
252
+ const chunk = chunks[chunkIndex];
253
+ const chunkExpression = [];
254
+ for (let partIndex = 0; partIndex < chunk.length; partIndex++) {
255
+ if (chunkIndex === 0 && partIndex === 0) {
256
+ // first part is just gonna be the id
257
+ const firstPart = isIdPartDescriptor(chunk[0]) ? chunk[0].id : chunk[0].index;
258
+ chunkExpression.push(firstPart);
259
+ continue;
260
+ }
261
+ const part = chunk[partIndex];
262
+ const prevPart = partIndex === 0 ? chunks[chunkIndex - 1].at(-1) : chunk[partIndex - 1];
263
+ if (part.args !== undefined) {
264
+ // For parts with only args (no name), append function call directly with appropriate nullish operator
265
+ chunkExpression.push(formatCallExpr(prevPart, part));
266
+ } else if (part.accessStyle === "dot") {
267
+ chunkExpression.push(formatDotAccess(prevPart, part));
268
+ } else {
269
+ // bracket notation - don't include the dot
270
+ chunkExpression.push(formatArrayAccess(prevPart, part));
271
+ }
272
+ }
273
+ expression.push(chunkIndex === 0 ? chunkExpression : [_$createIntrinsic("sbr", {}), chunkExpression]);
274
+ }
275
+ return _$createIntrinsic("group", {
276
+ get children() {
277
+ return _$createIntrinsic("indent", {
278
+ children: expression
279
+ });
280
+ }
281
+ });
282
+ });
283
+ }
284
+ function formatNonCallChain(parts) {
285
+ return computed(() => {
84
286
  const expression = [];
85
287
  for (let i = 0; i < parts.length; i++) {
86
288
  const part = parts[i];
87
- const base = typeof part.base === "string" ? part.base : part.base.value;
88
- const hasName = base !== "";
289
+ const base = isIdPartDescriptor(part) ? part.id : part.index;
89
290
  if (i === 0) {
90
291
  expression.push(base);
91
292
  } else {
92
293
  // Determine if we should use nullish operator from previous part
93
294
  const prevPart = parts[i - 1];
94
- const isNullish = prevPart.nullish.value;
95
-
96
- // Handle parts with name vs. parts with only args differently
97
- if (hasName) {
98
- // Apply dot or bracket notation based on accessStyle for named parts
99
- if (part.accessStyle.value === "dot") {
100
- expression.push(_$createIntrinsic("group", {
101
- get children() {
102
- return _$createIntrinsic("indent", {
103
- get children() {
104
- return [_$createIntrinsic("sbr", {}), isNullish ? "?." : ".", base];
105
- }
106
- });
107
- }
108
- }));
109
- } else {
110
- // bracket notation - don't include the dot
111
- expression.push(_$createIntrinsic("group", {
112
- get children() {
113
- return [isNullish ? "?." : "", "[", _$createIntrinsic("indent", {
114
- get children() {
115
- return [_$createIntrinsic("sbr", {}), _$memo(() => JSON.stringify(base))];
116
- }
117
- }), _$createIntrinsic("sbr", {}), "]"];
118
- }
119
- }));
120
- }
121
- } else if (part.args !== undefined) {
295
+ if (part.args !== undefined) {
122
296
  // For parts with only args (no name), append function call directly with appropriate nullish operator
123
- expression.push(_$createIntrinsic("group", {
297
+ expression.push(formatCallExpr(prevPart, part));
298
+ } else if (part.accessStyle === "dot") {
299
+ expression.push(formatDotAccess(prevPart, part));
300
+ } else {
301
+ // bracket notation - don't include the dot
302
+ expression.push(formatArrayAccess(prevPart, part));
303
+ }
304
+ }
305
+ }
306
+ return expression;
307
+ });
308
+ }
309
+ function formatArrayAccess(prevPart, part) {
310
+ return _$createIntrinsic("group", {
311
+ get children() {
312
+ return [_$memo(() => prevPart.nullish ? "?." : ""), "[", _$createIntrinsic("indent", {
313
+ get children() {
314
+ return [_$createIntrinsic("sbr", {}), _$memo(() => part.quoteId && '"'), _$memo(() => isIdPartDescriptor(part) ? part.id : part.index), _$memo(() => part.quoteId && '"')];
315
+ }
316
+ }), _$createIntrinsic("sbr", {}), "]"];
317
+ }
318
+ });
319
+ }
320
+ function formatDotAccess(prevPart, part) {
321
+ return _$createIntrinsic("group", {
322
+ get children() {
323
+ return _$createIntrinsic("indent", {
324
+ get children() {
325
+ return [_$createIntrinsic("sbr", {}), _$memo(() => prevPart.nullish ? "?." : "."), _$memo(() => isIdPartDescriptor(part) ? part.id : part.index)];
326
+ }
327
+ });
328
+ }
329
+ });
330
+ }
331
+ function formatCallExpr(prevPart, part) {
332
+ const args = computed(() => {
333
+ return typeof part.args === "boolean" ? [] : part.args ?? [];
334
+ });
335
+ return _$createIntrinsic("group", {
336
+ get children() {
337
+ return [_$memo(() => prevPart.nullish ? "?." : ""), "(", _$createComponent(Show, {
338
+ get when() {
339
+ return args.value.length <= 1;
340
+ },
341
+ get children() {
342
+ return args.value[0];
343
+ }
344
+ }), _$createComponent(Show, {
345
+ get when() {
346
+ return args.value.length > 1;
347
+ },
348
+ get children() {
349
+ return [_$createIntrinsic("indent", {
124
350
  get children() {
125
- return [isNullish ? "?." : "", _$createIntrinsic("group", {
126
- get children() {
127
- return ["(", _$createComponent(For, {
128
- get each() {
129
- return typeof part.args === "boolean" ? [] : part.args ?? [];
130
- },
131
- comma: true,
132
- line: true,
133
- children: arg => arg
134
- }), ")"];
135
- }
351
+ return [_$createIntrinsic("sbr", {}), _$createComponent(For, {
352
+ each: args,
353
+ comma: true,
354
+ line: true,
355
+ children: arg => arg
136
356
  })];
137
357
  }
138
- }));
358
+ }), _$createIntrinsic("sbr", {})];
139
359
  }
140
- }
360
+ }), ")"];
141
361
  }
142
- return expression;
143
362
  });
144
- return [_$memo(() => result.value)];
145
363
  }
146
364
  function accessStyleForMemberName(name) {
147
365
  if (isValidJSIdentifier(name)) {
@@ -168,10 +386,30 @@ function flattenMemberExpression(children) {
168
386
  * * **refkey**: A refkey for a symbol whose name becomes the identifier
169
387
  * * **symbol**: a symbol whose name becomes the identifier part
170
388
  * * **args**: create a method call with the given args
389
+ * * **children**: arbitrary contents for the identifier part.
390
+ *
391
+ * Each part can have a nullish prop, which indicates that the part may be null
392
+ * or undefined.
393
+ *
394
+ * Each part can also have a quoteId prop, which indicates that the identifier
395
+ * of the part should be quoted (i.e. `["foo"]` instead of `.foo`). This is only
396
+ * necessary when providing the children prop, otherwise it is determined
397
+ * automatically.
171
398
  */
172
399
  MemberExpression.Part = function (props) {
173
400
  /**
174
401
  * This component does nothing except hold props which are retrieved by
175
402
  * the `MemberExpression` component.
176
403
  */
177
- };
404
+ };
405
+
406
+ /**
407
+ * Check if the given id is a numeric identifier.
408
+ *
409
+ */
410
+ function isNumericIdentifier(id) {
411
+ return typeof id === "number";
412
+ }
413
+ function isIdPartDescriptor(part) {
414
+ return "id" in part;
415
+ }
@@ -0,0 +1,5 @@
1
+ import { FunctionCallExpressionProps } from "./FunctionCallExpression.jsx";
2
+ export interface NewExpressionProps extends FunctionCallExpressionProps {
3
+ }
4
+ export declare function NewExpression(props: NewExpressionProps): import("@alloy-js/core/jsx-runtime").Children;
5
+ //# sourceMappingURL=NewExpression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NewExpression.d.ts","sourceRoot":"","sources":["../../../src/components/NewExpression.tsx"],"names":[],"mappings":"AAMA,OAAO,EAEL,2BAA2B,EAC5B,MAAM,8BAA8B,CAAC;AAEtC,MAAM,WAAW,kBAAmB,SAAQ,2BAA2B;CAAG;AAE1E,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,iDAWtD"}
@@ -0,0 +1,12 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { emitSymbol, instantiateTakenMembersTo as instantiateTakenSymbolsTo, OutputSymbolFlags } from "@alloy-js/core";
3
+ import { TSOutputSymbol } from "../symbols/ts-output-symbol.js";
4
+ import { FunctionCallExpression } from "./FunctionCallExpression.js";
5
+ export function NewExpression(props) {
6
+ const sym = new TSOutputSymbol("", {
7
+ flags: OutputSymbolFlags.Transient
8
+ });
9
+ instantiateTakenSymbolsTo(sym);
10
+ emitSymbol(sym);
11
+ return ["new ", _$createComponent(FunctionCallExpression, props)];
12
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectExpression.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectExpression.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,EAQR,MAAM,EAGP,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EACJ,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACnB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YA0D5D;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YA0CxD;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,YAYpE"}
1
+ {"version":3,"file":"ObjectExpression.d.ts","sourceRoot":"","sources":["../../../src/components/ObjectExpression.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,EASR,MAAM,EAGP,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EACJ,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACnB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YAuD5D;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YA8CxD;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,YAYpE"}
@@ -1,14 +1,14 @@
1
1
  import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
- import { AssignmentContext, Block, computed, createAssignmentContext, For, getAssignmentSymbol, Match, MemberScope, OutputSymbolFlags, Switch, Wrap } from "@alloy-js/core";
2
+ import { AssignmentContext, Block, computed, createAssignmentContext, emitSymbol, For, Match, MemberScope, moveTakenMembersTo, OutputSymbolFlags, Switch, takeSymbols } from "@alloy-js/core";
3
3
  import { useTSNamePolicy } from "../name-policy.js";
4
- import { createTSSymbol } from "../symbols/index.js";
4
+ import { TSOutputSymbol } from "../symbols/ts-output-symbol.js";
5
5
  import { PropertyName } from "./PropertyName.js";
6
6
  import { ValueExpression } from "./ValueExpression.js";
7
7
  export function ObjectExpression(props) {
8
- const assignmentSymbol = getAssignmentSymbol();
9
- if (assignmentSymbol) {
10
- assignmentSymbol.binder.addStaticMembersToSymbol(assignmentSymbol);
11
- }
8
+ const symbol = new TSOutputSymbol("", {
9
+ flags: OutputSymbolFlags.StaticMemberContainer | OutputSymbolFlags.Transient
10
+ });
11
+ emitSymbol(symbol);
12
12
  const jsValueProperties = computed(() => {
13
13
  const jsValue = props.jsValue;
14
14
  let properties;
@@ -35,12 +35,8 @@ export function ObjectExpression(props) {
35
35
  get children() {
36
36
  return _$createIntrinsic("group", {
37
37
  get children() {
38
- return _$createComponent(Wrap, {
39
- when: !!assignmentSymbol,
40
- "with": MemberScope,
41
- props: {
42
- owner: assignmentSymbol
43
- },
38
+ return _$createComponent(MemberScope, {
39
+ owner: symbol,
44
40
  get children() {
45
41
  return _$createComponent(Block, {
46
42
  get children() {
@@ -81,11 +77,14 @@ export function ObjectProperty(props) {
81
77
  }
82
78
  let sym = undefined;
83
79
  if (props.refkey && props.name) {
84
- sym = createTSSymbol({
85
- name: props.name,
86
- refkey: props.refkey,
80
+ sym = new TSOutputSymbol(props.name, {
81
+ refkeys: props.refkey,
87
82
  flags: OutputSymbolFlags.StaticMember
88
83
  });
84
+ moveTakenMembersTo(sym);
85
+ } else {
86
+ // noop
87
+ takeSymbols();
89
88
  }
90
89
  let value;
91
90
  if (props.value) {
@@ -1 +1 @@
1
- {"version":3,"file":"PackageDirectory.d.ts","sourceRoot":"","sources":["../../../src/components/PackageDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAEhB,GAAG,EASJ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAwB,cAAc,EAAE,MAAM,qBAAqB,C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AAM,KAAK,MAAM,CAAC,CAAC;CAC9C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YA8B5D"}
@@ -1,7 +1,7 @@
1
1
  import { memo as _$memo, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { createNamedContext, Scope, shallowRef, SourceDirectory, SourceDirectoryContext, splitProps, useBinder, useContext, useScope } from "@alloy-js/core";
2
+ import { createNamedContext, Scope, shallowRef, SourceDirectory, SourceDirectoryContext, splitProps, useContext } from "@alloy-js/core";
3
3
  import { join } from "pathe";
4
- import { createTSPackageScope } from "../symbols/index.js";
4
+ import { TSPackageScope } from "../symbols/index.js";
5
5
  import { modulePath } from "../utils.js";
6
6
  import { PackageJsonFile } from "./PackageJson.js";
7
7
  import { TSConfigJson } from "./TsConfigJson.js";
@@ -44,7 +44,7 @@ function createPackageContext(name, version, path) {
44
44
  const parentDir = useContext(SourceDirectoryContext);
45
45
  // todo: this can probably just use context.
46
46
  const fullPath = parentDir ? join(parentDir.path, path) : path;
47
- const scope = createTSPackageScope(useBinder(), useScope(), name, version, fullPath);
47
+ const scope = new TSPackageScope(name, version, fullPath);
48
48
  return {
49
49
  scope,
50
50
  outFileMapper: shallowRef(path => modulePath(path))
@@ -51,5 +51,5 @@ export interface PackageExports {
51
51
  * <PackageJsonFile name="my-package" version="1.0.0" />
52
52
  * ```
53
53
  */
54
- export declare function PackageJsonFile(props: PackageJsonFileProps): import("@alloy-js/core").Children;
54
+ export declare function PackageJsonFile(props: PackageJsonFileProps): import("@alloy-js/core/jsx-runtime").Children;
55
55
  //# sourceMappingURL=PackageJson.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PackageJson.d.ts","sourceRoot":"","sources":["../../../src/components/PackageJson.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,oBAAoB;IACnC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,iCAAiC;IACjC,OAAO,EAAE,MAAM,C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AM,CAAC;IAEb,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAEhB,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAEpD,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,gEAAgE;IAChE,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAE7B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtC,6CAA6C;IAC7C,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IAEtC,2CAA2C;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEzC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC;CAChD;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,gBAAgB,CAAC;AAEnD,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,iDA4D1D"}
@@ -15,5 +15,5 @@ export interface PropertyNameProps {
15
15
  * is provided, it will be used as the property name. Otherwise, the name will be
16
16
  * taken from the {@link (MemberDeclarationContext:variable)}.
17
17
  */
18
- export declare function PropertyName(props: PropertyNameProps): import("@alloy-js/core").Children;
18
+ export declare function PropertyName(props: PropertyNameProps): import("@alloy-js/core/jsx-runtime").Children;
19
19
  //# sourceMappingURL=PropertyName.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyName.d.ts","sourceRoot":"","sources":["../../../src/components/PropertyName.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qCAkBpD"}
1
+ {"version":3,"file":"PropertyName.d.ts","sourceRoot":"","sources":["../../../src/components/PropertyName.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,iDAkBpD"}
@@ -9,5 +9,5 @@ export interface ReferenceProps {
9
9
  */
10
10
  type?: boolean;
11
11
  }
12
- export declare function Reference({ refkey, type }: ReferenceProps): import("@alloy-js/core").Children;
12
+ export declare function Reference({ refkey, type }: ReferenceProps): import("@alloy-js/core/jsx-runtime").Children;
13
13
  //# sourceMappingURL=Reference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../../../src/components/Reference.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,cAAc,qCAKzD"}
1
+ {"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../../../src/components/Reference.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI9D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,cAAc,iDAOzD"}
@@ -1,3 +1,5 @@
1
+ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { computed, emitSymbol } from "@alloy-js/core";
1
3
  import { isTypeRefContext } from "../context/type-ref-context.js";
2
4
  import { ref } from "../symbols/index.js";
3
5
  export function Reference({
@@ -8,5 +10,7 @@ export function Reference({
8
10
  const reference = ref(refkey, {
9
11
  type: type ?? inTypeRef
10
12
  });
11
- return [reference];
13
+ const symbolRef = computed(() => reference()[1]);
14
+ emitSymbol(symbolRef);
15
+ return [_$memo(() => reference()[0])];
12
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EASjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD,OAAO,EAAuB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzE,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB,CACX,CAAC;AAExD,wBAAgB,aAAa,sBAE5B;AACD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,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