@xlr-lib/xlr-converters 0.1.1--canary.9.190

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 (38) hide show
  1. package/bin/run +8 -0
  2. package/dist/cjs/index.cjs +1736 -0
  3. package/dist/cjs/index.cjs.map +1 -0
  4. package/dist/index.legacy-esm.js +1703 -0
  5. package/dist/index.mjs +1703 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +35 -0
  8. package/src/__tests__/__snapshots__/annotations.test.ts.snap +22 -0
  9. package/src/__tests__/__snapshots__/common-to-ts.test.ts.snap +50 -0
  10. package/src/__tests__/__snapshots__/export-to-ts.test.ts.snap +30 -0
  11. package/src/__tests__/__snapshots__/player.test.ts.snap +8024 -0
  12. package/src/__tests__/__snapshots__/ts-to-common.test.ts.snap +1657 -0
  13. package/src/__tests__/annotations.test.ts +40 -0
  14. package/src/__tests__/common-to-ts.test.ts +356 -0
  15. package/src/__tests__/documentation.test.ts +116 -0
  16. package/src/__tests__/export-to-ts.test.ts +68 -0
  17. package/src/__tests__/heritage-additional-properties.test.ts +119 -0
  18. package/src/__tests__/player.test.ts +866 -0
  19. package/src/__tests__/ts-to-common.test.ts +776 -0
  20. package/src/__tests__/ts-utils.test.ts +383 -0
  21. package/src/helpers/converter.ts +44 -0
  22. package/src/helpers/writeManifest.ts +45 -0
  23. package/src/index.ts +7 -0
  24. package/src/ts/annotations.ts +237 -0
  25. package/src/ts/documentation.ts +243 -0
  26. package/src/ts/ts-to-xlr.ts +1245 -0
  27. package/src/ts/ts-utils.ts +247 -0
  28. package/src/ts/xlr-to-ts.ts +636 -0
  29. package/src/types.ts +15 -0
  30. package/types/helpers/converter.d.ts +5 -0
  31. package/types/helpers/writeManifest.d.ts +3 -0
  32. package/types/index.d.ts +8 -0
  33. package/types/ts/annotations.d.ts +7 -0
  34. package/types/ts/documentation.d.ts +14 -0
  35. package/types/ts/ts-to-xlr.d.ts +56 -0
  36. package/types/ts/ts-utils.d.ts +68 -0
  37. package/types/ts/xlr-to-ts.d.ts +45 -0
  38. package/types/types.d.ts +8 -0
@@ -0,0 +1,1703 @@
1
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/ts/ts-to-xlr.ts
2
+ import ts3 from "typescript";
3
+
4
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/ts/ts-utils.ts
5
+ import ts from "typescript";
6
+ function isOptionalProperty(node) {
7
+ return node.questionToken?.kind === ts.SyntaxKind.QuestionToken;
8
+ }
9
+ function isGenericInterfaceDeclaration(node) {
10
+ const length = node.typeParameters?.length;
11
+ return length ? length > 0 : false;
12
+ }
13
+ function isGenericTypeDeclaration(node) {
14
+ const length = node.typeParameters?.length;
15
+ return length ? length > 0 : false;
16
+ }
17
+ function isTypeReferenceGeneric(node, typeChecker) {
18
+ const symbol = typeChecker.getSymbolAtLocation(node.typeName);
19
+ if (symbol && symbol.declarations) {
20
+ return symbol.declarations[0].kind === ts.SyntaxKind.TypeParameter;
21
+ }
22
+ return false;
23
+ }
24
+ function isTopLevelDeclaration(node) {
25
+ return node.kind === ts.SyntaxKind.InterfaceDeclaration || node.kind === ts.SyntaxKind.TypeAliasDeclaration;
26
+ }
27
+ function isTopLevelNode(node) {
28
+ return node.kind === ts.SyntaxKind.InterfaceDeclaration || node.kind === ts.SyntaxKind.TypeAliasDeclaration || node.kind === ts.SyntaxKind.VariableStatement;
29
+ }
30
+ function tsStripOptionalType(node) {
31
+ return ts.isOptionalTypeNode(node) ? node.type : node;
32
+ }
33
+ function isExportedDeclaration(node) {
34
+ const modifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : void 0;
35
+ if (modifiers) {
36
+ return modifiers.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
37
+ }
38
+ return false;
39
+ }
40
+ function isNodeExported(node) {
41
+ return (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) !== 0 || !!node.parent && node.parent.kind === ts.SyntaxKind.SourceFile;
42
+ }
43
+ function getReferencedType(node, typeChecker) {
44
+ let symbol = typeChecker.getSymbolAtLocation(node.typeName);
45
+ if (symbol && (symbol.flags & ts.SymbolFlags.Alias) === ts.SymbolFlags.Alias) {
46
+ symbol = typeChecker.getAliasedSymbol(symbol);
47
+ }
48
+ const varDecl = symbol?.declarations?.[0];
49
+ if (varDecl && (ts.isInterfaceDeclaration(varDecl) || ts.isTypeAliasDeclaration(varDecl))) {
50
+ return { declaration: varDecl, exported: isNodeExported(varDecl) };
51
+ }
52
+ }
53
+ function isTypeScriptLibType(node, typeChecker) {
54
+ let symbol = typeChecker.getSymbolAtLocation(node.typeName);
55
+ if (!symbol) return false;
56
+ if ((symbol.flags & ts.SymbolFlags.Alias) === ts.SymbolFlags.Alias) {
57
+ symbol = typeChecker.getAliasedSymbol(symbol);
58
+ }
59
+ const declarations = symbol.getDeclarations();
60
+ if (!declarations || declarations.length === 0) return false;
61
+ return declarations.some((decl) => {
62
+ const sourceFile = decl.getSourceFile();
63
+ if (!sourceFile) return false;
64
+ const filePath = sourceFile.fileName;
65
+ return filePath.includes("/typescript/lib/") || filePath.includes("\\typescript\\lib\\") || filePath.endsWith(".d.ts") && filePath.includes("lib.");
66
+ });
67
+ }
68
+ function getStringLiteralsFromUnion(node) {
69
+ if (ts.isUnionTypeNode(node)) {
70
+ return new Set(
71
+ node.types.map((type) => {
72
+ if (ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal)) {
73
+ return type.literal.text;
74
+ }
75
+ return "";
76
+ })
77
+ );
78
+ }
79
+ if (ts.isLiteralTypeNode(node) && ts.isStringLiteral(node.literal)) {
80
+ return /* @__PURE__ */ new Set([node.literal.text]);
81
+ }
82
+ return /* @__PURE__ */ new Set();
83
+ }
84
+ function buildTemplateRegex(node, typeChecker) {
85
+ let regex = node.head.text;
86
+ node.templateSpans.forEach((span) => {
87
+ let type = span.type.kind;
88
+ if (ts.isTypeReferenceNode(span.type)) {
89
+ let symbol = typeChecker.getSymbolAtLocation(
90
+ span.type.typeName
91
+ );
92
+ if (symbol && (symbol.flags & ts.SymbolFlags.Alias) === ts.SymbolFlags.Alias) {
93
+ symbol = typeChecker.getAliasedSymbol(symbol);
94
+ }
95
+ type = (symbol?.declarations?.[0]).type.kind;
96
+ }
97
+ if (type === ts.SyntaxKind.StringKeyword) {
98
+ regex += ".*";
99
+ } else if (type === ts.SyntaxKind.NumberKeyword) {
100
+ regex += "[0-9]*";
101
+ } else if (type === ts.SyntaxKind.BooleanKeyword) {
102
+ regex += "true|false";
103
+ }
104
+ regex += span.literal.text;
105
+ });
106
+ return regex;
107
+ }
108
+ function isExportedModuleDeclaration(node) {
109
+ return isExportedDeclaration(node) && ts.isModuleDeclaration(node);
110
+ }
111
+
112
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/ts/annotations.ts
113
+ import ts2 from "typescript";
114
+ function extractDescription(text) {
115
+ if (!text) {
116
+ return {};
117
+ }
118
+ return { description: text };
119
+ }
120
+ function parentIsNonObjectPath(node) {
121
+ return node.parent && (ts2.isArrayTypeNode(node.parent) || ts2.isTupleTypeNode(node.parent) || ts2.isOptionalTypeNode(node.parent) || ts2.isRestTypeNode(node.parent) || ts2.isUnionTypeNode(node.parent));
122
+ }
123
+ function recurseTypeChain(node, child) {
124
+ if (!node) {
125
+ return [];
126
+ }
127
+ if (ts2.isArrayTypeNode(node) && node.parent && ts2.isRestTypeNode(node.parent)) {
128
+ return recurseTypeChain(node.parent, node);
129
+ }
130
+ if (ts2.isRestTypeNode(node)) {
131
+ return recurseTypeChain(node.parent, node);
132
+ }
133
+ if (ts2.isOptionalTypeNode(node)) {
134
+ return recurseTypeChain(node.parent, node);
135
+ }
136
+ if (ts2.isUnionTypeNode(node)) {
137
+ return recurseTypeChain(node.parent, node);
138
+ }
139
+ if (ts2.isParenthesizedTypeNode(node)) {
140
+ return recurseTypeChain(node.parent, node);
141
+ }
142
+ if (ts2.isTypeLiteralNode(node)) {
143
+ return recurseTypeChain(node.parent, node);
144
+ }
145
+ if (ts2.isArrayTypeNode(node)) {
146
+ return ["[]", ...recurseTypeChain(node.parent, node)];
147
+ }
148
+ if (ts2.isTupleTypeNode(node)) {
149
+ const pos = node.elements.indexOf(child);
150
+ return [
151
+ ...pos === -1 ? [] : [`${pos}`],
152
+ ...recurseTypeChain(node.parent, node)
153
+ ];
154
+ }
155
+ if (ts2.isTypeAliasDeclaration(node) || ts2.isInterfaceDeclaration(node) || ts2.isPropertySignature(node)) {
156
+ return [node.name.getText(), ...recurseTypeChain(node.parent, node)];
157
+ }
158
+ if (parentIsNonObjectPath(node)) {
159
+ return recurseTypeChain(node.parent, node);
160
+ }
161
+ return [];
162
+ }
163
+ function extractTitle(node) {
164
+ const typeNames = recurseTypeChain(node, void 0).reverse().join(".");
165
+ if (!typeNames.length) {
166
+ return {};
167
+ }
168
+ return { title: typeNames };
169
+ }
170
+ function stringifyDoc(docString) {
171
+ if (typeof docString === "undefined" || typeof docString === "string") {
172
+ return docString;
173
+ }
174
+ return docString.map(({ text }) => text).join(" ");
175
+ }
176
+ function extractTags(tags) {
177
+ const descriptions = [];
178
+ const examples = [];
179
+ const _default = [];
180
+ const see = [];
181
+ const meta = {};
182
+ const extractSee = (tag) => {
183
+ return `${tag.tagName ? `${tag.tagName?.getText()} ` : ""}${stringifyDoc(tag.comment)?.trim() ?? ""}`;
184
+ };
185
+ tags.forEach((tag) => {
186
+ if (!tag.comment) {
187
+ return;
188
+ }
189
+ if (tag.tagName.text === "example") {
190
+ examples.push(stringifyDoc(tag.comment)?.trim() ?? "");
191
+ } else if (tag.tagName.text === "default") {
192
+ _default.push(stringifyDoc(tag.comment)?.trim() ?? "");
193
+ } else if (tag.tagName.text === "see") {
194
+ see.push(extractSee(tag));
195
+ } else if (tag.tagName.text === "meta") {
196
+ const [key, value] = tag.comment.toString().split(/:(.*)/);
197
+ meta[key] = value?.trim() ?? "";
198
+ } else {
199
+ const text = stringifyDoc(tag.comment)?.trim() ?? "";
200
+ descriptions.push(`@${tag.tagName.text} ${text}`);
201
+ }
202
+ });
203
+ return {
204
+ ...descriptions.length === 0 ? {} : { description: descriptions.join("\n") },
205
+ ...examples.length === 0 ? {} : { examples },
206
+ ..._default.length === 0 ? {} : { default: _default.join("\n") },
207
+ ...see.length === 0 ? {} : { see },
208
+ ...meta && Object.keys(meta).length === 0 ? {} : { meta }
209
+ };
210
+ }
211
+ function join(t, separator = "\n") {
212
+ const unique = new Set(t).values();
213
+ return Array.from(unique).filter((s) => s !== void 0).join(separator).trim();
214
+ }
215
+ function mergeAnnotations(nodes) {
216
+ const name = nodes.find((n) => n.name)?.name;
217
+ const title = join(
218
+ nodes.map((n) => n.title),
219
+ ", "
220
+ );
221
+ const description = join(nodes.map((n) => n.description));
222
+ const _default = join(nodes.map((n) => n.default));
223
+ const comment = join(nodes.map((n) => n.comment));
224
+ const examples = join(
225
+ nodes.map(
226
+ (n) => Array.isArray(n.examples) ? join(n.examples) : n.examples
227
+ )
228
+ );
229
+ const see = join(
230
+ nodes.map((n) => Array.isArray(n.see) ? join(n.see) : n.see)
231
+ );
232
+ const meta = nodes.find((n) => n.meta)?.meta;
233
+ return {
234
+ ...name ? { name } : {},
235
+ ...title ? { title } : {},
236
+ ...description ? { description } : {},
237
+ ...examples ? { examples } : {},
238
+ ..._default ? { default: _default } : {},
239
+ ...see ? { see } : {},
240
+ ...comment ? { comment } : {},
241
+ ...meta ? { meta } : {}
242
+ };
243
+ }
244
+ function decorateNode(node) {
245
+ const { jsDoc } = node;
246
+ const titleAnnotation = extractTitle(node);
247
+ if (jsDoc && jsDoc.length) {
248
+ const first = jsDoc[0];
249
+ return mergeAnnotations([
250
+ extractDescription(stringifyDoc(first.comment)),
251
+ titleAnnotation,
252
+ extractTags(first.tags ?? [])
253
+ ]);
254
+ }
255
+ return titleAnnotation;
256
+ }
257
+
258
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/ts/ts-to-xlr.ts
259
+ import {
260
+ fillInGenerics,
261
+ isNonNullable,
262
+ applyPartialOrRequiredToNodeType,
263
+ applyPickOrOmitToNodeType,
264
+ applyExcludeToNodeType,
265
+ isGenericNodeType,
266
+ resolveConditional,
267
+ isPrimitiveTypeNode
268
+ } from "@xlr-lib/xlr-utils";
269
+
270
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/types.ts
271
+ var ConversionError = class _ConversionError extends Error {
272
+ constructor(msg) {
273
+ super(msg);
274
+ Object.setPrototypeOf(this, _ConversionError.prototype);
275
+ }
276
+ toString() {
277
+ return `Conversion Error: ${this.message}`;
278
+ }
279
+ };
280
+
281
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/ts/ts-to-xlr.ts
282
+ function isMappedTypeNode(x) {
283
+ return ["Pick", "Omit", "Required", "Partial", "Exclude"].includes(x);
284
+ }
285
+ function getPropertyNameText(name) {
286
+ if (ts3.isIdentifier(name) || ts3.isStringLiteral(name) || ts3.isNumericLiteral(name)) {
287
+ return name.text;
288
+ }
289
+ return name.getText();
290
+ }
291
+ var AnyTypeNode = {
292
+ type: "any"
293
+ };
294
+ var TsConverter = class {
295
+ context;
296
+ constructor(typeChecker, customPrimitives) {
297
+ this.context = {
298
+ customPrimitives: customPrimitives ?? [],
299
+ typeChecker,
300
+ throwError: (message) => {
301
+ throw new ConversionError(message);
302
+ },
303
+ cache: {
304
+ convertedNodes: /* @__PURE__ */ new Map(),
305
+ convertedTemplates: /* @__PURE__ */ new Map()
306
+ }
307
+ };
308
+ }
309
+ /** Converts all exported objects to a XLR representation */
310
+ convertSourceFile(sourceFile) {
311
+ const declarations = sourceFile.statements.filter(isTopLevelNode);
312
+ const namespacedTypes = sourceFile.statements.filter((s) => isExportedModuleDeclaration(s)).flatMap((module) => {
313
+ if (module.body && ts3.isModuleBlock(module.body)) {
314
+ const nameSpaceName = module.name.text;
315
+ return module.body.statements.filter(isExportedDeclaration).filter(isTopLevelNode).map((statement) => {
316
+ const convertedNode = this.convertTopLevelNode(statement);
317
+ return {
318
+ ...convertedNode,
319
+ name: `${nameSpaceName}.${convertedNode.name}`
320
+ };
321
+ });
322
+ }
323
+ return [];
324
+ });
325
+ const types = declarations.filter((declaration) => isExportedDeclaration(declaration)).map((statement) => this.convertTopLevelNode(statement)).filter((v) => !!v);
326
+ types.push(...namespacedTypes);
327
+ return {
328
+ data: { version: 1, types },
329
+ convertedTypes: types.map(({ name }) => name)
330
+ };
331
+ }
332
+ convertTopLevelNode(node) {
333
+ const sourceFile = node.parent;
334
+ const { fileName } = sourceFile;
335
+ if (ts3.isVariableStatement(node)) {
336
+ return {
337
+ source: fileName,
338
+ ...this.convertVariable(node)
339
+ };
340
+ }
341
+ return {
342
+ source: fileName,
343
+ ...this.convertDeclaration(node)
344
+ };
345
+ }
346
+ /** Converts a single type/interface declaration to XLRs */
347
+ convertDeclaration(node) {
348
+ if (ts3.isTypeAliasDeclaration(node)) {
349
+ let genericTokens;
350
+ if (isGenericTypeDeclaration(node)) {
351
+ genericTokens = this.generateGenerics(node.typeParameters);
352
+ }
353
+ return {
354
+ name: node.name.getText(),
355
+ ...this.convertTsTypeNode(node.type) ?? AnyTypeNode,
356
+ ...decorateNode(node),
357
+ genericTokens
358
+ };
359
+ }
360
+ if (ts3.isInterfaceDeclaration(node)) {
361
+ let genericTokens;
362
+ if (isGenericInterfaceDeclaration(node)) {
363
+ genericTokens = this.generateGenerics(node.typeParameters);
364
+ }
365
+ const baseObject = {
366
+ name: node.name.getText(),
367
+ type: "object",
368
+ ...this.tsObjectMembersToProperties(node),
369
+ ...decorateNode(node),
370
+ genericTokens
371
+ };
372
+ if (node.heritageClauses) {
373
+ return this.handleHeritageClauses(
374
+ node.heritageClauses,
375
+ baseObject,
376
+ this.context.typeChecker
377
+ );
378
+ }
379
+ return baseObject;
380
+ }
381
+ this.context.throwError(
382
+ `Error: type node is not an Interface or a Type, can't convert as Declaration`
383
+ );
384
+ }
385
+ convertVariable(node) {
386
+ const variableDeclarations = node.declarationList.declarations;
387
+ if (variableDeclarations.length === 1) {
388
+ const variable = variableDeclarations[0];
389
+ if (variable.initializer) {
390
+ let resultingNode;
391
+ if (variable.type && ts3.isTypeReferenceNode(variable.type) && ts3.isIdentifier(variable.type.typeName) && this.context.customPrimitives.includes(variable.type.typeName.text)) {
392
+ resultingNode = this.makeBasicRefNode(variable.type);
393
+ } else if (ts3.isCallExpression(variable.initializer) || ts3.isArrowFunction(variable.initializer)) {
394
+ resultingNode = this.resolveFunctionCall(
395
+ variable.initializer,
396
+ node.parent
397
+ );
398
+ } else {
399
+ resultingNode = this.tsLiteralToType(variable.initializer);
400
+ }
401
+ if (resultingNode.type === "function" || resultingNode.type === "ref") {
402
+ resultingNode = { ...resultingNode, name: variable.name.getText() };
403
+ }
404
+ return {
405
+ name: variable.name.getText(),
406
+ ...resultingNode
407
+ };
408
+ }
409
+ }
410
+ this.context.throwError(
411
+ `Error: Multi-variable declaration on line ${node.pos} is not supported for conversion`
412
+ );
413
+ }
414
+ /** Converts an arbitrary ts.TypeNode to XLRs */
415
+ convertTsTypeNode(node) {
416
+ if (this.context.cache.convertedNodes.has(node)) {
417
+ const cachedType = this.context.cache.convertedNodes.get(
418
+ node
419
+ );
420
+ return JSON.parse(JSON.stringify(cachedType));
421
+ }
422
+ const convertedNode = this.tsNodeToType(node);
423
+ this.context.cache.convertedNodes.set(node, convertedNode);
424
+ return convertedNode;
425
+ }
426
+ /** Should not be called directly unless you want to bypass the cache, use `convertTsTypeNode` */
427
+ tsNodeToType(node) {
428
+ if (ts3.isUnionTypeNode(node)) {
429
+ return {
430
+ type: "or",
431
+ or: node.types.map((child) => this.convertTsTypeNode(child)).filter(isNonNullable),
432
+ ...decorateNode(node)
433
+ };
434
+ }
435
+ if (ts3.isIntersectionTypeNode(node)) {
436
+ return {
437
+ type: "and",
438
+ and: node.types.map((child) => this.convertTsTypeNode(child)).filter(isNonNullable),
439
+ ...decorateNode(node)
440
+ };
441
+ }
442
+ if (ts3.isParenthesizedTypeNode(node)) {
443
+ const children = [];
444
+ node.forEachChild((child) => {
445
+ children.push(child);
446
+ });
447
+ if (children[0]?.kind === ts3.SyntaxKind.OpenParenToken) {
448
+ children.shift();
449
+ }
450
+ if (children[children.length - 1]?.kind === ts3.SyntaxKind.CloseParenToken) {
451
+ children.pop();
452
+ }
453
+ const element = children[0];
454
+ if (children.length !== 1 || !ts3.isTypeNode(element)) {
455
+ this.context.throwError(
456
+ `Parenthesis type not understood. Length ${children.length}, Is Type Node: ${ts3.SyntaxKind[element.kind]}`
457
+ );
458
+ }
459
+ return this.convertTsTypeNode(element);
460
+ }
461
+ if (node.kind === ts3.SyntaxKind.AnyKeyword) {
462
+ return { type: "any", ...decorateNode(node) };
463
+ }
464
+ if (node.kind === ts3.SyntaxKind.UnknownKeyword) {
465
+ return { type: "unknown", ...decorateNode(node) };
466
+ }
467
+ if (node.kind === ts3.SyntaxKind.StringKeyword) {
468
+ return { type: "string", ...decorateNode(node) };
469
+ }
470
+ if (node.kind === ts3.SyntaxKind.NumberKeyword) {
471
+ return { type: "number", ...decorateNode(node) };
472
+ }
473
+ if (node.kind === ts3.SyntaxKind.BooleanKeyword) {
474
+ return { type: "boolean", ...decorateNode(node) };
475
+ }
476
+ if (node.kind === ts3.SyntaxKind.UndefinedKeyword) {
477
+ return { type: "undefined", ...decorateNode(node) };
478
+ }
479
+ if (node.kind === ts3.SyntaxKind.NeverKeyword) {
480
+ return { type: "never", ...decorateNode(node) };
481
+ }
482
+ if (node.kind === ts3.SyntaxKind.ObjectKeyword) {
483
+ return {
484
+ type: "object",
485
+ properties: {},
486
+ additionalProperties: AnyTypeNode,
487
+ ...decorateNode(node)
488
+ };
489
+ }
490
+ if (node.kind === ts3.SyntaxKind.VoidKeyword) {
491
+ return {
492
+ type: "void",
493
+ ...decorateNode(node)
494
+ };
495
+ }
496
+ if (ts3.isTemplateLiteralTypeNode(node)) {
497
+ let format;
498
+ if (this.context.cache.convertedTemplates.has(node)) {
499
+ format = this.context.cache.convertedTemplates.get(node);
500
+ } else {
501
+ format = buildTemplateRegex(node, this.context.typeChecker);
502
+ this.context.cache.convertedTemplates.set(node, format);
503
+ }
504
+ return {
505
+ type: "template",
506
+ format
507
+ };
508
+ }
509
+ if (ts3.isArrayTypeNode(node)) {
510
+ return {
511
+ type: "array",
512
+ elementType: this.convertTsTypeNode(node.elementType) ?? AnyTypeNode,
513
+ ...decorateNode(node)
514
+ };
515
+ }
516
+ if (ts3.isConditionalTypeNode(node)) {
517
+ const xlrNode = {
518
+ type: "conditional",
519
+ check: {
520
+ left: this.convertTsTypeNode(node.checkType),
521
+ right: this.convertTsTypeNode(node.extendsType)
522
+ },
523
+ value: {
524
+ true: this.convertTsTypeNode(node.trueType),
525
+ false: this.convertTsTypeNode(node.falseType)
526
+ }
527
+ };
528
+ if (isPrimitiveTypeNode(xlrNode.check.left) && isPrimitiveTypeNode(xlrNode.check.right)) {
529
+ return resolveConditional(xlrNode);
530
+ } else {
531
+ return xlrNode;
532
+ }
533
+ }
534
+ if (ts3.isTypeReferenceNode(node)) {
535
+ return this.resolveRefNode(node);
536
+ }
537
+ if (ts3.isTupleTypeNode(node)) {
538
+ return {
539
+ type: "tuple",
540
+ ...this.tsTupleToType(node),
541
+ ...decorateNode(node)
542
+ };
543
+ }
544
+ if (ts3.isLiteralTypeNode(node)) {
545
+ return this.tsLiteralToType(node.literal);
546
+ }
547
+ if (ts3.isTypeLiteralNode(node)) {
548
+ return {
549
+ type: "object",
550
+ ...this.tsObjectMembersToProperties(node),
551
+ ...decorateNode(node)
552
+ };
553
+ }
554
+ if (ts3.isFunctionTypeNode(node) || ts3.isFunctionDeclaration(node) || ts3.isArrowFunction(node)) {
555
+ const parameters = node.parameters.map(
556
+ (param) => {
557
+ let typeNode;
558
+ if (param.type) {
559
+ typeNode = this.convertTsTypeNode(param.type);
560
+ }
561
+ return {
562
+ name: param.name.getText(),
563
+ type: typeNode ?? AnyTypeNode,
564
+ optional: param.questionToken ? true : void 0,
565
+ default: param.initializer ? this.convertTsTypeNode(
566
+ param.initializer
567
+ ) : void 0
568
+ };
569
+ }
570
+ );
571
+ let returnType;
572
+ if (node.type !== void 0) {
573
+ returnType = this.convertTsTypeNode(node.type);
574
+ }
575
+ return {
576
+ type: "function",
577
+ parameters,
578
+ returnType,
579
+ ...decorateNode(node)
580
+ };
581
+ }
582
+ if (ts3.isIndexedAccessTypeNode(node)) {
583
+ if (ts3.isTypeReferenceNode(node.objectType) && ts3.isLiteralTypeNode(node.indexType)) {
584
+ const baseObject = this.convertTsTypeNode(node.objectType);
585
+ const accessor = node.indexType.literal.getText().replace(/["']/g, "");
586
+ if (!baseObject) {
587
+ this.context.throwError(
588
+ `Error: Couldn't resolve index access on property ${accessor} on type ${node.objectType.typeName.getText()}`
589
+ );
590
+ } else if (baseObject.type === "object") {
591
+ if (Object.keys(baseObject.properties ?? {}).includes(accessor)) {
592
+ return baseObject.properties[accessor].node;
593
+ }
594
+ if (baseObject.additionalProperties) {
595
+ return baseObject.additionalProperties;
596
+ }
597
+ } else if (baseObject.type === "ref") {
598
+ return { ...baseObject, property: accessor };
599
+ } else {
600
+ this.context.throwError(
601
+ `Error: Index access on non object/ref type ${baseObject.type}`
602
+ );
603
+ }
604
+ }
605
+ let queryNode = node.objectType;
606
+ if (ts3.isParenthesizedTypeNode(node.objectType)) {
607
+ queryNode = node.objectType.type;
608
+ }
609
+ if (ts3.isTypeQueryNode(queryNode)) {
610
+ const elements = this.tsNodeToType(node.objectType);
611
+ return {
612
+ type: "or",
613
+ or: [...elements.elementTypes.map((element) => element.type)]
614
+ };
615
+ }
616
+ const effectiveType = this.context.typeChecker.getTypeAtLocation(node);
617
+ const syntheticType = this.context.typeChecker.typeToTypeNode(
618
+ effectiveType,
619
+ node,
620
+ ts3.NodeBuilderFlags.NoTruncation
621
+ );
622
+ if (syntheticType) {
623
+ return this.tsNodeToType(syntheticType);
624
+ }
625
+ this.context.throwError(
626
+ `Error: could not solve IndexedAccessType: ${node.getFullText()}`
627
+ );
628
+ }
629
+ if (ts3.isTypeQueryNode(node)) {
630
+ const effectiveType = this.context.typeChecker.getTypeAtLocation(node);
631
+ const syntheticType = this.context.typeChecker.typeToTypeNode(
632
+ effectiveType,
633
+ node,
634
+ ts3.NodeBuilderFlags.NoTruncation
635
+ );
636
+ if (syntheticType) {
637
+ return this.tsNodeToType(syntheticType);
638
+ }
639
+ this.context.throwError(
640
+ `Error: could not synthesize type for ${node.getText()}`
641
+ );
642
+ }
643
+ if (ts3.isTypeOperatorNode(node)) {
644
+ return this.tsNodeToType(node.type);
645
+ }
646
+ this.context.throwError(
647
+ `Unimplemented type ${ts3.SyntaxKind[node.kind]} at ${node.getText()}`
648
+ );
649
+ }
650
+ tsLiteralToType(node) {
651
+ if (ts3.isAsExpression(node)) {
652
+ return this.tsLiteralToType(node.expression);
653
+ }
654
+ if (ts3.isNumericLiteral(node)) {
655
+ return {
656
+ type: "number",
657
+ const: Number(node.text),
658
+ ...decorateNode(node)
659
+ };
660
+ }
661
+ if (ts3.isStringLiteral(node)) {
662
+ return {
663
+ type: "string",
664
+ const: node.text,
665
+ ...decorateNode(node)
666
+ };
667
+ }
668
+ if (node.kind === ts3.SyntaxKind.TrueKeyword) {
669
+ return {
670
+ type: "boolean",
671
+ const: true,
672
+ ...decorateNode(node)
673
+ };
674
+ }
675
+ if (node.kind === ts3.SyntaxKind.FalseKeyword) {
676
+ return {
677
+ type: "boolean",
678
+ const: false,
679
+ ...decorateNode(node)
680
+ };
681
+ }
682
+ if (node.kind === ts3.SyntaxKind.NullKeyword) {
683
+ return { type: "null", ...decorateNode(node) };
684
+ }
685
+ if (ts3.isPrefixUnaryExpression(node)) {
686
+ this.context.throwError("Prefix unary expressions not supported");
687
+ }
688
+ if (ts3.isArrayLiteralExpression(node)) {
689
+ const arrayElements = [];
690
+ node.elements.forEach((element) => {
691
+ if (ts3.isSpreadElement(element)) {
692
+ const arrayReference = this.resolveLiteralReference(
693
+ element.expression
694
+ );
695
+ arrayElements.push(...arrayReference.const ?? []);
696
+ } else {
697
+ arrayElements.push(this.tsLiteralToType(element));
698
+ }
699
+ });
700
+ return {
701
+ type: "array",
702
+ elementType: { type: "any" },
703
+ const: arrayElements
704
+ };
705
+ }
706
+ if (ts3.isObjectLiteralExpression(node)) {
707
+ const ret = {
708
+ type: "object",
709
+ properties: {},
710
+ additionalProperties: false
711
+ };
712
+ node.properties.forEach((property) => {
713
+ if (ts3.isPropertyAssignment(property) && property.name) {
714
+ const propertyName = getPropertyNameText(property.name);
715
+ ret.properties[propertyName] = {
716
+ required: true,
717
+ node: this.tsLiteralToType(property.initializer)
718
+ };
719
+ } else if (ts3.isSpreadAssignment(property)) {
720
+ const spreadValue = this.resolveLiteralReference(
721
+ property.expression
722
+ );
723
+ ret.properties = {
724
+ ...ret.properties,
725
+ ...spreadValue.properties
726
+ };
727
+ }
728
+ });
729
+ return ret;
730
+ }
731
+ if (ts3.isIdentifier(node)) {
732
+ return this.resolveLiteralReference(node);
733
+ }
734
+ this.context.throwError(
735
+ `Literal type not understood ${ts3.SyntaxKind[node.kind]} at ${node.getText()}`
736
+ );
737
+ }
738
+ resolveLiteralReference(expression) {
739
+ if (ts3.isIdentifier(expression)) {
740
+ const symbol = this.context.typeChecker.getSymbolAtLocation(expression);
741
+ let expressionReference = symbol?.declarations?.[0];
742
+ if (symbol && expressionReference && ts3.isImportSpecifier(expressionReference)) {
743
+ const referencedDeclaration = this.context.typeChecker.getAliasedSymbol(symbol);
744
+ expressionReference = referencedDeclaration.declarations?.[0];
745
+ }
746
+ if (expressionReference && ts3.isVariableDeclaration(expressionReference) && expressionReference.initializer) {
747
+ return this.convertVariable(
748
+ expressionReference.parent.parent
749
+ );
750
+ }
751
+ this.context.throwError(
752
+ `Error: Can't resolve non-variable declaration ${expressionReference?.getText()}`
753
+ );
754
+ }
755
+ this.context.throwError(
756
+ `Error: Can't resolve non-identifier reference in literal ${expression.getText()}`
757
+ );
758
+ }
759
+ resolveFunctionCall(functionCall, document) {
760
+ if (ts3.isArrowFunction(functionCall)) {
761
+ const declaredReturnType = functionCall.parent.type;
762
+ if (declaredReturnType) {
763
+ return this.tsNodeToType(declaredReturnType);
764
+ }
765
+ }
766
+ const functionReturnType = this.context.typeChecker.getTypeAtLocation(functionCall);
767
+ let syntheticNode = this.context.typeChecker.typeToTypeNode(
768
+ functionReturnType,
769
+ document,
770
+ void 0
771
+ );
772
+ if (ts3.isArrowFunction(functionCall)) {
773
+ const syntheticWithParameters = {
774
+ ...syntheticNode,
775
+ parameters: functionCall.parameters
776
+ };
777
+ syntheticNode = syntheticWithParameters;
778
+ }
779
+ if (syntheticNode) {
780
+ if (ts3.isTypeReferenceNode(syntheticNode) && ts3.isIdentifier(syntheticNode.typeName)) {
781
+ const { typeName } = syntheticNode;
782
+ if (this.context.customPrimitives.includes(typeName.text)) {
783
+ return this.makeBasicRefNode(syntheticNode);
784
+ }
785
+ const declarationSymbol = typeName.symbol;
786
+ if (declarationSymbol && declarationSymbol.declarations?.[0]) {
787
+ const declaration = declarationSymbol.declarations[0];
788
+ if (ts3.isTypeAliasDeclaration(declaration) || ts3.isInterfaceDeclaration(declaration)) {
789
+ return this.convertDeclaration(declaration);
790
+ }
791
+ }
792
+ this.context.throwError(
793
+ `Error: could not get referenced type ${syntheticNode.getText()}`
794
+ );
795
+ }
796
+ return this.tsNodeToType(syntheticNode);
797
+ }
798
+ this.context.throwError(
799
+ `Error: could not determine effective return type of ${functionCall.getText()}`
800
+ );
801
+ }
802
+ tsObjectMembersToProperties(node) {
803
+ const ret = {
804
+ properties: {},
805
+ additionalProperties: false
806
+ };
807
+ node.members.forEach((member) => {
808
+ if (ts3.isPropertySignature(member) && member.type) {
809
+ const name = getPropertyNameText(member.name);
810
+ ret.properties[name] = {
811
+ required: !isOptionalProperty(member),
812
+ node: {
813
+ ...this.convertTsTypeNode(member.type) ?? AnyTypeNode,
814
+ ...decorateNode(member)
815
+ }
816
+ };
817
+ } else if (ts3.isIndexSignatureDeclaration(member)) {
818
+ const param = member.parameters[0];
819
+ if (param.type?.kind !== ts3.SyntaxKind.StringKeyword) {
820
+ this.context.throwError(
821
+ "Will not convert non-string index signature"
822
+ );
823
+ }
824
+ ret.additionalProperties = this.convertTsTypeNode(member.type) ?? AnyTypeNode;
825
+ }
826
+ });
827
+ return ret;
828
+ }
829
+ tsTupleToType(node) {
830
+ if (node.elements.length === 0) {
831
+ return { elementTypes: [], additionalItems: false, minItems: 0 };
832
+ }
833
+ const hasRest = ts3.isRestTypeNode(node.elements[node.elements.length - 1]);
834
+ const [elements, rest] = hasRest ? [
835
+ node.elements.slice(0, node.elements.length - 1),
836
+ node.elements[node.elements.length - 1]
837
+ ] : [[...node.elements], void 0];
838
+ const elementTypes = elements.map((element) => {
839
+ if (ts3.isNamedTupleMember(element)) {
840
+ let typeNode;
841
+ if (element.type) {
842
+ typeNode = this.convertTsTypeNode(element.type);
843
+ }
844
+ return {
845
+ name: element.name.text,
846
+ type: typeNode ?? AnyTypeNode,
847
+ optional: element.questionToken ? true : void 0
848
+ };
849
+ }
850
+ return {
851
+ type: this.convertTsTypeNode(tsStripOptionalType(element)),
852
+ optional: ts3.isOptionalTypeNode(element)
853
+ };
854
+ });
855
+ const additionalItems = rest ? this.convertTsTypeNode(rest.type.elementType) ?? AnyTypeNode : false;
856
+ const firstOptional = elementTypes.findIndex(
857
+ (element) => element.optional === true
858
+ );
859
+ const minItems = firstOptional === -1 ? elements.length : firstOptional;
860
+ return {
861
+ elementTypes,
862
+ ...additionalItems && additionalItems.type === "any" ? { additionalItems: AnyTypeNode } : { additionalItems },
863
+ minItems
864
+ };
865
+ }
866
+ handleHeritageClauses(clauses, baseObject, typeChecker) {
867
+ let newProperties = {};
868
+ const additionalPropertiesCollector = [];
869
+ let extendsType;
870
+ clauses.forEach((heritageClause) => {
871
+ heritageClause.types.forEach((parent) => {
872
+ let typeToApply;
873
+ const typeName = parent.expression.getText();
874
+ if (isMappedTypeNode(typeName)) {
875
+ typeToApply = this.makeMappedType(typeName, parent);
876
+ } else {
877
+ const parentType = typeChecker.getTypeAtLocation(parent);
878
+ const parentSymbol = parentType.symbol;
879
+ const parentDeclarations = parentSymbol?.declarations;
880
+ if (!parentDeclarations?.[0]) {
881
+ this.context.throwError(
882
+ `Error: Unable to get underlying interface for extending class ${parent.getFullText()}`
883
+ );
884
+ }
885
+ let parentInterface;
886
+ if (ts3.isTypeLiteralNode(parentDeclarations?.[0]) && ts3.isTypeAliasDeclaration(parentDeclarations?.[0].parent)) {
887
+ parentInterface = parentDeclarations?.[0].parent;
888
+ } else {
889
+ parentInterface = parentDeclarations?.[0];
890
+ }
891
+ if (this.context.customPrimitives.includes(parentInterface.name.text)) {
892
+ extendsType = this.makeBasicRefNode(parent);
893
+ return;
894
+ }
895
+ typeToApply = this.convertDeclaration(parentInterface);
896
+ if (typeToApply.extends) {
897
+ extendsType = typeToApply.extends;
898
+ }
899
+ if (parentInterface.typeParameters && parent.typeArguments) {
900
+ typeToApply = this.resolveGenerics(
901
+ typeToApply,
902
+ parentInterface.typeParameters,
903
+ parent.typeArguments
904
+ );
905
+ } else if (isGenericNodeType(baseObject)) {
906
+ baseObject.genericTokens.push(
907
+ ...typeToApply.genericTokens ?? []
908
+ );
909
+ }
910
+ }
911
+ newProperties = {
912
+ ...newProperties,
913
+ ...typeToApply.properties
914
+ };
915
+ if (typeToApply.additionalProperties) {
916
+ additionalPropertiesCollector.push(typeToApply.additionalProperties);
917
+ }
918
+ });
919
+ });
920
+ let additionalProperties = false;
921
+ if (baseObject.additionalProperties) {
922
+ if (additionalPropertiesCollector.length === 0) {
923
+ additionalProperties = baseObject.additionalProperties;
924
+ } else {
925
+ additionalPropertiesCollector.push(baseObject.additionalProperties);
926
+ additionalProperties = additionalPropertiesCollector.length === 1 ? additionalPropertiesCollector[0] : {
927
+ type: "or",
928
+ or: additionalPropertiesCollector
929
+ };
930
+ }
931
+ } else if (additionalPropertiesCollector.length === 1) {
932
+ additionalProperties = additionalPropertiesCollector[0];
933
+ } else if (additionalPropertiesCollector.length >= 1) {
934
+ additionalProperties = {
935
+ type: "or",
936
+ or: additionalPropertiesCollector
937
+ };
938
+ }
939
+ return {
940
+ ...baseObject,
941
+ ...extendsType ? { extends: extendsType } : {},
942
+ properties: { ...newProperties, ...baseObject.properties },
943
+ additionalProperties
944
+ };
945
+ }
946
+ resolveGenerics(baseInterface, typeParameters, typeArguments) {
947
+ if (typeArguments && typeArguments.length === 0) return baseInterface;
948
+ const genericMap = /* @__PURE__ */ new Map();
949
+ typeParameters.forEach((tp, i) => {
950
+ let typeToProcess;
951
+ if (typeArguments && i < typeArguments.length) {
952
+ typeToProcess = typeArguments[i];
953
+ } else if (tp.default) {
954
+ typeToProcess = tp.default;
955
+ } else {
956
+ typeToProcess = ts3.factory.createKeywordTypeNode(
957
+ ts3.SyntaxKind.AnyKeyword
958
+ );
959
+ }
960
+ const processedNodeType = this.convertTsTypeNode(typeToProcess);
961
+ if (processedNodeType) {
962
+ genericMap.set(tp.name.getText(), processedNodeType);
963
+ }
964
+ });
965
+ return fillInGenerics(baseInterface, genericMap);
966
+ }
967
+ generateGenerics(params) {
968
+ const genericArray = [];
969
+ params?.forEach((param) => {
970
+ const serializedObject = {
971
+ symbol: param.name.text
972
+ };
973
+ if (param.constraint) {
974
+ serializedObject.constraints = this.convertTsTypeNode(param.constraint);
975
+ } else {
976
+ serializedObject.constraints = AnyTypeNode;
977
+ }
978
+ if (param.default) {
979
+ serializedObject.default = this.convertTsTypeNode(param.default);
980
+ } else {
981
+ serializedObject.default = AnyTypeNode;
982
+ }
983
+ genericArray.push(serializedObject);
984
+ });
985
+ return genericArray;
986
+ }
987
+ resolveRefNode(node) {
988
+ let refName;
989
+ let namespace;
990
+ if (node.typeName.kind === ts3.SyntaxKind.QualifiedName) {
991
+ namespace = node.typeName.left.getText();
992
+ refName = node.typeName.right.getText();
993
+ } else {
994
+ refName = node.typeName.text;
995
+ }
996
+ if (isTypeReferenceGeneric(node, this.context.typeChecker)) {
997
+ if (ts3.isIndexedAccessTypeNode(node.parent)) {
998
+ const genericSymbol = this.context.typeChecker.getSymbolAtLocation(
999
+ node.typeName
1000
+ );
1001
+ const typeParameters = this.generateGenerics(
1002
+ genericSymbol?.declarations
1003
+ );
1004
+ const typeParameter = typeParameters[0];
1005
+ if (typeParameter) {
1006
+ if (typeParameter.constraints) {
1007
+ return typeParameter.constraints;
1008
+ }
1009
+ if (typeParameter.default) {
1010
+ return typeParameter.default;
1011
+ }
1012
+ }
1013
+ return AnyTypeNode;
1014
+ }
1015
+ return { type: "ref", ref: node.getText(), ...decorateNode(node) };
1016
+ }
1017
+ if (refName === "Array") {
1018
+ const typeArgs = node.typeArguments;
1019
+ return {
1020
+ type: "array",
1021
+ elementType: typeArgs ? this.convertTsTypeNode(typeArgs[0]) ?? AnyTypeNode : AnyTypeNode,
1022
+ ...decorateNode(node)
1023
+ };
1024
+ }
1025
+ if (refName === "Record") {
1026
+ const indexType = node.typeArguments?.[0];
1027
+ const valueType = node.typeArguments?.[1];
1028
+ return {
1029
+ type: "record",
1030
+ keyType: this.convertTsTypeNode(indexType) ?? AnyTypeNode,
1031
+ valueType: this.convertTsTypeNode(valueType) ?? AnyTypeNode,
1032
+ ...decorateNode(node)
1033
+ };
1034
+ }
1035
+ if (isMappedTypeNode(refName)) {
1036
+ return this.makeMappedType(refName, node);
1037
+ }
1038
+ if (isTypeScriptLibType(node, this.context.typeChecker)) {
1039
+ return this.makeBasicRefNode(node);
1040
+ }
1041
+ if (!this.context.customPrimitives.includes(refName)) {
1042
+ const typeInfo = getReferencedType(node, this.context.typeChecker);
1043
+ if (typeInfo) {
1044
+ const convertedType = this.convertTopLevelNode(typeInfo.declaration);
1045
+ const genericParams = typeInfo.declaration.typeParameters;
1046
+ const genericArgs = node.typeArguments;
1047
+ if (convertedType && genericParams && genericArgs) {
1048
+ const resolvedType = this.resolveGenerics(
1049
+ convertedType,
1050
+ genericParams,
1051
+ genericArgs
1052
+ );
1053
+ if ("name" in resolvedType && genericArgs.length > 0) {
1054
+ const argsText = Array.from(genericArgs).map((arg) => arg.getText()).join(", ");
1055
+ const baseName = namespace ? `${namespace}.${refName}` : refName;
1056
+ return { ...resolvedType, name: `${baseName}<${argsText}>` };
1057
+ }
1058
+ if (namespace && "name" in resolvedType) {
1059
+ return { ...resolvedType, name: `${namespace}.${refName}` };
1060
+ }
1061
+ return resolvedType;
1062
+ }
1063
+ if (convertedType) {
1064
+ if (namespace && "name" in convertedType) {
1065
+ return { ...convertedType, name: `${namespace}.${refName}` };
1066
+ }
1067
+ return convertedType;
1068
+ }
1069
+ }
1070
+ this.context.throwError(
1071
+ `Can't find referenced type ${refName}, is it available in the current package or node_modules?`
1072
+ );
1073
+ }
1074
+ return this.makeBasicRefNode(node);
1075
+ }
1076
+ makeMappedType(refName, node) {
1077
+ if (refName === "Pick" || refName === "Omit" || refName === "Exclude") {
1078
+ const baseType = node.typeArguments?.[0];
1079
+ const modifiers = node.typeArguments?.[1];
1080
+ const baseObj = this.convertTsTypeNode(baseType);
1081
+ if (refName === "Exclude") {
1082
+ if (baseObj.type === "or") {
1083
+ return applyExcludeToNodeType(
1084
+ baseObj,
1085
+ this.convertTsTypeNode(modifiers)
1086
+ );
1087
+ }
1088
+ throw new ConversionError(
1089
+ "Error: Can't solve Exclude type on non-union node"
1090
+ );
1091
+ } else {
1092
+ return applyPickOrOmitToNodeType(
1093
+ baseObj,
1094
+ refName,
1095
+ getStringLiteralsFromUnion(modifiers)
1096
+ );
1097
+ }
1098
+ }
1099
+ if (refName === "Partial" || refName === "Required") {
1100
+ const baseType = node.typeArguments?.[0];
1101
+ const baseObj = this.convertTsTypeNode(baseType);
1102
+ const modifier = refName !== "Partial";
1103
+ return applyPartialOrRequiredToNodeType(baseObj, modifier);
1104
+ }
1105
+ this.context.throwError(`Can't convert non-MappedType ${refName}`);
1106
+ }
1107
+ makeBasicRefNode(node) {
1108
+ const genericArgs = [];
1109
+ if (node.typeArguments) {
1110
+ node.typeArguments.forEach((typeArg) => {
1111
+ let convertedNode;
1112
+ if (isTopLevelDeclaration(typeArg)) {
1113
+ convertedNode = this.convertDeclaration(typeArg);
1114
+ } else {
1115
+ convertedNode = this.convertTsTypeNode(typeArg);
1116
+ }
1117
+ if (convertedNode) {
1118
+ genericArgs.push(convertedNode);
1119
+ } else {
1120
+ this.context.throwError(
1121
+ `Conversion Error: Couldn't convert type argument in type ${node.getText()}`
1122
+ );
1123
+ }
1124
+ });
1125
+ }
1126
+ let ref;
1127
+ if (ts3.isTypeReferenceNode(node)) {
1128
+ if (node.typeName.kind === ts3.SyntaxKind.QualifiedName) {
1129
+ ref = `${node.typeName.left.getText()}.${node.typeName.right.getText()}`;
1130
+ } else if (node.pos === -1 && ts3.isIdentifier(node.typeName)) {
1131
+ ref = node.typeName.text;
1132
+ } else {
1133
+ ref = node.getText();
1134
+ }
1135
+ } else {
1136
+ ref = node.getText();
1137
+ }
1138
+ return {
1139
+ type: "ref",
1140
+ ref,
1141
+ ...decorateNode(node),
1142
+ genericArguments: genericArgs.length > 0 ? genericArgs : void 0
1143
+ };
1144
+ }
1145
+ };
1146
+
1147
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/ts/xlr-to-ts.ts
1148
+ import { isGenericNamedType, isPrimitiveTypeNode as isPrimitiveTypeNode2 } from "@xlr-lib/xlr-utils";
1149
+ import ts4 from "typescript";
1150
+ var templateTokenize = /(?=true\|false|\.\*|\[0-9]\*)/gm;
1151
+ var tokenSplit = /(?<=true\|false|\.\*|\[0-9]\*)/gm;
1152
+ var TSWriter = class {
1153
+ context;
1154
+ importSet;
1155
+ additionalTypes;
1156
+ constructor(factory) {
1157
+ this.context = {
1158
+ factory: factory ?? ts4.factory,
1159
+ throwError: (message) => {
1160
+ throw new ConversionError(message);
1161
+ }
1162
+ };
1163
+ this.importSet = /* @__PURE__ */ new Set();
1164
+ this.additionalTypes = /* @__PURE__ */ new Map();
1165
+ }
1166
+ convertNamedType(type) {
1167
+ this.importSet.clear();
1168
+ this.additionalTypes.clear();
1169
+ const finalNode = this.convertNamedTypeNode(type);
1170
+ const referencedTypes = this.importSet.size > 0 ? this.importSet : void 0;
1171
+ const additionalTypes = this.additionalTypes.size > 0 ? this.additionalTypes : void 0;
1172
+ return {
1173
+ type: this.makeAnnotations(finalNode, type),
1174
+ referencedTypes,
1175
+ additionalTypes
1176
+ };
1177
+ }
1178
+ convertNamedTypeNode(type) {
1179
+ const typeName = type.name;
1180
+ const tsNode = this.convertTypeNode(type);
1181
+ let customPrimitiveHeritageClass;
1182
+ if (type.type === "object" && type.extends) {
1183
+ const refName = type.extends.ref.split("<")[0];
1184
+ customPrimitiveHeritageClass = [
1185
+ this.context.factory.createHeritageClause(
1186
+ ts4.SyntaxKind.ExtendsKeyword,
1187
+ [
1188
+ this.context.factory.createExpressionWithTypeArguments(
1189
+ this.context.factory.createIdentifier(refName),
1190
+ type.extends.genericArguments ? type.extends.genericArguments.map(
1191
+ (node) => this.convertTypeNode(node)
1192
+ ) : void 0
1193
+ )
1194
+ ]
1195
+ )
1196
+ ];
1197
+ }
1198
+ let generics;
1199
+ if (isGenericNamedType(type)) {
1200
+ generics = this.createTypeParameters(type);
1201
+ type.genericTokens.forEach((token) => {
1202
+ if (this.importSet.has(token.symbol)) {
1203
+ this.importSet.delete(token.symbol);
1204
+ }
1205
+ });
1206
+ }
1207
+ let finalNode;
1208
+ if (ts4.isTypeLiteralNode(tsNode)) {
1209
+ finalNode = this.makeInterfaceDeclaration(
1210
+ typeName,
1211
+ tsNode.members,
1212
+ generics,
1213
+ customPrimitiveHeritageClass
1214
+ );
1215
+ } else {
1216
+ finalNode = this.makeTypeDeclaration(typeName, tsNode, generics);
1217
+ }
1218
+ return finalNode;
1219
+ }
1220
+ convertTypeNode(type) {
1221
+ if (type.type === "object") {
1222
+ return this.createObjectNode(type);
1223
+ }
1224
+ if (type.type === "and") {
1225
+ return this.context.factory.createIntersectionTypeNode(
1226
+ type.and.map((element) => {
1227
+ return this.convertTypeNode(element);
1228
+ })
1229
+ );
1230
+ }
1231
+ if (type.type === "or") {
1232
+ return this.context.factory.createUnionTypeNode(
1233
+ type.or.map((element) => {
1234
+ return this.convertTypeNode(element);
1235
+ })
1236
+ );
1237
+ }
1238
+ if (type.type === "array") {
1239
+ if (type.const) {
1240
+ return this.context.factory.createTupleTypeNode(
1241
+ type.const.map(
1242
+ (element) => this.convertTypeNode(element)
1243
+ )
1244
+ );
1245
+ }
1246
+ return this.context.factory.createTypeReferenceNode(
1247
+ this.context.factory.createIdentifier("Array"),
1248
+ [this.convertTypeNode(type.elementType)]
1249
+ );
1250
+ }
1251
+ if (isPrimitiveTypeNode2(type)) {
1252
+ return this.createPrimitiveNode(type);
1253
+ }
1254
+ if (type.type === "conditional") {
1255
+ return this.createConditionalTypeNode(type);
1256
+ }
1257
+ if (type.type === "function") {
1258
+ return this.createFunctionDeclarationNode(type);
1259
+ }
1260
+ if (type.type === "record") {
1261
+ return this.createRecordNode(type);
1262
+ }
1263
+ if (type.type === "ref") {
1264
+ return this.createRefNode(type);
1265
+ }
1266
+ if (type.type === "template") {
1267
+ return this.createTemplateLiteral(type);
1268
+ }
1269
+ if (type.type === "tuple") {
1270
+ return this.createTupleNode(type);
1271
+ }
1272
+ this.context.throwError(
1273
+ `Unable to convert node type: ${type.type}`
1274
+ );
1275
+ }
1276
+ createRefNode(xlrNode) {
1277
+ const typeArgs = [];
1278
+ if (xlrNode.genericArguments) {
1279
+ xlrNode.genericArguments.forEach((genericArg) => {
1280
+ if (genericArg.name) {
1281
+ const additionalType = this.convertNamedTypeNode(
1282
+ genericArg
1283
+ );
1284
+ this.additionalTypes.set(genericArg.name, additionalType);
1285
+ } else if (genericArg.type === "and") {
1286
+ genericArg.and.forEach((type) => {
1287
+ if (type.name) {
1288
+ const additionalType = this.convertNamedTypeNode(
1289
+ type
1290
+ );
1291
+ this.additionalTypes.set(type.name, additionalType);
1292
+ }
1293
+ });
1294
+ } else if (genericArg.type === "or") {
1295
+ genericArg.or.forEach((type) => {
1296
+ if (type.name) {
1297
+ const additionalType = this.convertNamedTypeNode(
1298
+ type
1299
+ );
1300
+ this.additionalTypes.set(type.name, additionalType);
1301
+ }
1302
+ });
1303
+ } else {
1304
+ typeArgs.push(this.convertTypeNode(genericArg));
1305
+ }
1306
+ });
1307
+ }
1308
+ const importName = xlrNode.ref.split("<")[0];
1309
+ this.importSet.add(importName);
1310
+ return this.context.factory.createTypeReferenceNode(importName, typeArgs);
1311
+ }
1312
+ createPrimitiveNode(xlrNode) {
1313
+ if ((xlrNode.type === "string" || xlrNode.type === "boolean" || xlrNode.type === "number") && xlrNode.const || xlrNode.type === "null") {
1314
+ return this.context.factory.createLiteralTypeNode(
1315
+ this.createLiteralTypeNode(xlrNode)
1316
+ );
1317
+ }
1318
+ switch (xlrNode.type) {
1319
+ case "string":
1320
+ return this.context.factory.createKeywordTypeNode(
1321
+ ts4.SyntaxKind.StringKeyword
1322
+ );
1323
+ case "number":
1324
+ return this.context.factory.createKeywordTypeNode(
1325
+ ts4.SyntaxKind.NumberKeyword
1326
+ );
1327
+ case "boolean":
1328
+ return this.context.factory.createKeywordTypeNode(
1329
+ ts4.SyntaxKind.BooleanKeyword
1330
+ );
1331
+ case "any":
1332
+ return this.context.factory.createKeywordTypeNode(
1333
+ ts4.SyntaxKind.AnyKeyword
1334
+ );
1335
+ case "unknown":
1336
+ return this.context.factory.createKeywordTypeNode(
1337
+ ts4.SyntaxKind.UnknownKeyword
1338
+ );
1339
+ case "never":
1340
+ return this.context.factory.createKeywordTypeNode(
1341
+ ts4.SyntaxKind.NeverKeyword
1342
+ );
1343
+ case "undefined":
1344
+ return this.context.factory.createKeywordTypeNode(
1345
+ ts4.SyntaxKind.UndefinedKeyword
1346
+ );
1347
+ case "void":
1348
+ return this.context.factory.createKeywordTypeNode(
1349
+ ts4.SyntaxKind.VoidKeyword
1350
+ );
1351
+ default:
1352
+ this.context.throwError(
1353
+ `Unknown primitive type ${xlrNode.type}`
1354
+ );
1355
+ }
1356
+ }
1357
+ createLiteralTypeNode(xlrNode) {
1358
+ if (xlrNode.type === "boolean") {
1359
+ return xlrNode.const ? this.context.factory.createTrue() : this.context.factory.createFalse();
1360
+ }
1361
+ if (xlrNode.type === "number") {
1362
+ return xlrNode.const ? this.context.factory.createNumericLiteral(xlrNode.const) : this.context.throwError(
1363
+ "Can't make literal type out of non constant number"
1364
+ );
1365
+ }
1366
+ if (xlrNode.type === "string") {
1367
+ return xlrNode.const ? this.context.factory.createStringLiteral(xlrNode.const, true) : this.context.throwError(
1368
+ "Can't make literal type out of non constant string"
1369
+ );
1370
+ }
1371
+ if (xlrNode.type === "null") {
1372
+ return this.context.factory.createNull();
1373
+ }
1374
+ this.context.throwError(`Can't make literal out of type ${xlrNode.type}`);
1375
+ }
1376
+ createTupleNode(xlrNode) {
1377
+ return this.context.factory.createTupleTypeNode(
1378
+ xlrNode.elementTypes.map((e) => {
1379
+ if (e.name) {
1380
+ return this.context.factory.createNamedTupleMember(
1381
+ void 0,
1382
+ this.context.factory.createIdentifier(e.name),
1383
+ e.optional ? this.context.factory.createToken(ts4.SyntaxKind.QuestionToken) : void 0,
1384
+ this.convertTypeNode(e.type)
1385
+ );
1386
+ }
1387
+ return this.convertTypeNode(e.type);
1388
+ })
1389
+ );
1390
+ }
1391
+ createFunctionDeclarationNode(xlrNode) {
1392
+ return this.context.factory.createFunctionTypeNode(
1393
+ void 0,
1394
+ xlrNode.parameters.map((e) => {
1395
+ return this.context.factory.createParameterDeclaration(
1396
+ void 0,
1397
+ void 0,
1398
+ e.name,
1399
+ e.optional ? this.context.factory.createToken(ts4.SyntaxKind.QuestionToken) : void 0,
1400
+ this.convertTypeNode(e.type),
1401
+ e.default ? this.createLiteralTypeNode(e.default) : void 0
1402
+ );
1403
+ }),
1404
+ xlrNode.returnType ? this.convertTypeNode(xlrNode.returnType) : this.context.factory.createToken(ts4.SyntaxKind.VoidKeyword)
1405
+ );
1406
+ }
1407
+ createRecordNode(xlrNode) {
1408
+ const keyType = this.convertTypeNode(xlrNode.keyType);
1409
+ const valueType = this.convertTypeNode(xlrNode.valueType);
1410
+ return this.context.factory.createTypeReferenceNode(
1411
+ this.context.factory.createIdentifier("Record"),
1412
+ [keyType, valueType]
1413
+ );
1414
+ }
1415
+ createConditionalTypeNode(xlrNode) {
1416
+ const leftCheck = this.convertTypeNode(xlrNode.check.left);
1417
+ const rightCheck = this.convertTypeNode(xlrNode.check.right);
1418
+ const trueValue = this.convertTypeNode(xlrNode.value.true);
1419
+ const falseValue = this.convertTypeNode(xlrNode.value.false);
1420
+ return this.context.factory.createConditionalTypeNode(
1421
+ leftCheck,
1422
+ rightCheck,
1423
+ trueValue,
1424
+ falseValue
1425
+ );
1426
+ }
1427
+ createObjectNode(xlrNode) {
1428
+ const { properties, additionalProperties = false } = xlrNode;
1429
+ const propertyNodes = [
1430
+ ...Object.keys(properties).map((name) => ({ name, ...properties[name] })).map(
1431
+ ({ name, node, required }) => this.makeAnnotations(
1432
+ this.context.factory.createPropertySignature(
1433
+ void 0,
1434
+ // modifiers
1435
+ name,
1436
+ required ? void 0 : this.context.factory.createToken(ts4.SyntaxKind.QuestionToken),
1437
+ this.convertTypeNode(node)
1438
+ ),
1439
+ node
1440
+ )
1441
+ )
1442
+ ];
1443
+ if (additionalProperties) {
1444
+ propertyNodes.push(
1445
+ this.context.factory.createIndexSignature(
1446
+ void 0,
1447
+ // modifiers
1448
+ [
1449
+ this.context.factory.createParameterDeclaration(
1450
+ void 0,
1451
+ // modifiers
1452
+ void 0,
1453
+ // dotdotdot token
1454
+ "key",
1455
+ void 0,
1456
+ // question token
1457
+ this.context.factory.createKeywordTypeNode(
1458
+ ts4.SyntaxKind.StringKeyword
1459
+ )
1460
+ )
1461
+ ],
1462
+ this.convertTypeNode(additionalProperties)
1463
+ )
1464
+ );
1465
+ }
1466
+ return this.context.factory.createTypeLiteralNode(propertyNodes);
1467
+ }
1468
+ createTemplateLiteral(xlrNode) {
1469
+ const templateSegments = xlrNode.format.split(templateTokenize);
1470
+ let templateHead;
1471
+ if (templateSegments.length % 2 === 0) {
1472
+ templateHead = this.context.factory.createTemplateHead(
1473
+ templateSegments[0]
1474
+ );
1475
+ templateSegments.splice(0, 1);
1476
+ } else {
1477
+ templateHead = this.context.factory.createTemplateHead("");
1478
+ }
1479
+ return this.context.factory.createTemplateLiteralType(
1480
+ templateHead,
1481
+ templateSegments.map((segments, i) => {
1482
+ const [regexSegment, stringSegment = ""] = segments.split(tokenSplit);
1483
+ let regexTemplateType;
1484
+ if (regexSegment === ".*") {
1485
+ regexTemplateType = ts4.SyntaxKind.StringKeyword;
1486
+ } else if (regexSegment === "[0-9]*") {
1487
+ regexTemplateType = ts4.SyntaxKind.NumberKeyword;
1488
+ } else if (regexSegment === "true|false") {
1489
+ regexTemplateType = ts4.SyntaxKind.BooleanKeyword;
1490
+ } else {
1491
+ this.context.throwError(
1492
+ `Can't make template literal type from regex ${regexSegment}`
1493
+ );
1494
+ }
1495
+ let stringTemplateType;
1496
+ if (i === templateSegments.length - 1) {
1497
+ stringTemplateType = this.context.factory.createTemplateTail(stringSegment);
1498
+ } else {
1499
+ stringTemplateType = this.context.factory.createTemplateMiddle(stringSegment);
1500
+ }
1501
+ return this.context.factory.createTemplateLiteralTypeSpan(
1502
+ this.context.factory.createKeywordTypeNode(regexTemplateType),
1503
+ stringTemplateType
1504
+ );
1505
+ })
1506
+ );
1507
+ }
1508
+ createGenericArgumentNode(node) {
1509
+ if (node) {
1510
+ if (node.type === "object" && node.name) {
1511
+ const additionalType = this.convertNamedTypeNode(
1512
+ node
1513
+ );
1514
+ this.additionalTypes.set(node.name, additionalType);
1515
+ return this.context.factory.createTypeReferenceNode(node.name);
1516
+ }
1517
+ return this.convertTypeNode(node);
1518
+ }
1519
+ return void 0;
1520
+ }
1521
+ makeAnnotations(tsNode, xlrAnnotations) {
1522
+ let comment = xlrAnnotations.description;
1523
+ if (!comment) {
1524
+ return tsNode;
1525
+ }
1526
+ if (comment.includes("\n")) {
1527
+ comment = `*
1528
+ ${comment.split("\n").map((s) => ` * ${s}`).join("\n")}
1529
+ `;
1530
+ } else {
1531
+ comment = `* ${comment} `;
1532
+ }
1533
+ return ts4.addSyntheticLeadingComment(
1534
+ tsNode,
1535
+ ts4.SyntaxKind.MultiLineCommentTrivia,
1536
+ comment,
1537
+ true
1538
+ );
1539
+ }
1540
+ createTypeParameters(genericXLRNode) {
1541
+ return genericXLRNode.genericTokens.map((generic) => {
1542
+ return this.context.factory.createTypeParameterDeclaration(
1543
+ void 0,
1544
+ generic.symbol,
1545
+ this.createGenericArgumentNode(generic.constraints),
1546
+ this.createGenericArgumentNode(generic.default)
1547
+ );
1548
+ });
1549
+ }
1550
+ makeInterfaceDeclaration(name, node, generics, heritageClass) {
1551
+ return this.context.factory.createInterfaceDeclaration(
1552
+ this.context.factory.createModifiersFromModifierFlags(
1553
+ ts4.ModifierFlags.Export
1554
+ ),
1555
+ this.context.factory.createIdentifier(name),
1556
+ generics,
1557
+ // type parameters
1558
+ heritageClass,
1559
+ // heritage
1560
+ node
1561
+ );
1562
+ }
1563
+ makeTypeDeclaration(name, node, generics) {
1564
+ return this.context.factory.createTypeAliasDeclaration(
1565
+ this.context.factory.createModifiersFromModifierFlags(
1566
+ ts4.ModifierFlags.Export
1567
+ ),
1568
+ this.context.factory.createIdentifier(name),
1569
+ generics,
1570
+ // type parameters
1571
+ node
1572
+ );
1573
+ }
1574
+ };
1575
+ function exportTypesToTypeScript(typesToExport, importMap) {
1576
+ const writer = new TSWriter();
1577
+ const referencedImports = /* @__PURE__ */ new Set();
1578
+ const exportedTypes = /* @__PURE__ */ new Map();
1579
+ const printer = ts4.createPrinter({ newLine: ts4.NewLineKind.LineFeed });
1580
+ let resultFile = ts4.createSourceFile(
1581
+ "output.d.ts",
1582
+ "",
1583
+ ts4.ScriptTarget.ES2017,
1584
+ false,
1585
+ ts4.ScriptKind.TS
1586
+ );
1587
+ typesToExport.forEach((typeNode) => {
1588
+ const { type, referencedTypes, additionalTypes } = writer.convertNamedType(typeNode);
1589
+ exportedTypes.set(typeNode.name, type);
1590
+ additionalTypes?.forEach(
1591
+ (additionalType, name) => exportedTypes.set(name, additionalType)
1592
+ );
1593
+ referencedTypes?.forEach(
1594
+ (referencedType) => referencedImports.add(referencedType)
1595
+ );
1596
+ });
1597
+ const typesToPrint = [];
1598
+ exportedTypes.forEach(
1599
+ (type) => typesToPrint.push(
1600
+ printer.printNode(ts4.EmitHint.Unspecified, type, resultFile)
1601
+ )
1602
+ );
1603
+ importMap.forEach((imports, packageName) => {
1604
+ const applicableImports = imports.filter((i) => referencedImports.has(i));
1605
+ if (applicableImports.length === 0) return;
1606
+ resultFile = ts4.factory.updateSourceFile(resultFile, [
1607
+ ts4.factory.createImportDeclaration(
1608
+ /* modifiers */
1609
+ void 0,
1610
+ ts4.factory.createImportClause(
1611
+ false,
1612
+ void 0,
1613
+ ts4.factory.createNamedImports(
1614
+ applicableImports.map(
1615
+ (i) => ts4.factory.createImportSpecifier(
1616
+ false,
1617
+ void 0,
1618
+ ts4.factory.createIdentifier(i)
1619
+ )
1620
+ )
1621
+ )
1622
+ ),
1623
+ ts4.factory.createStringLiteral(packageName)
1624
+ ),
1625
+ ...resultFile.statements
1626
+ ]);
1627
+ });
1628
+ const headerText = printer.printFile(resultFile);
1629
+ const nodeText = typesToPrint.join("\n");
1630
+ return `${headerText}
1631
+ ${nodeText}`;
1632
+ }
1633
+
1634
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/helpers/converter.ts
1635
+ import ts5 from "typescript";
1636
+ import path2 from "path";
1637
+ import fs2 from "fs";
1638
+
1639
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/helpers/writeManifest.ts
1640
+ import path from "path";
1641
+ import fs from "fs";
1642
+ function replacer(key, value) {
1643
+ if (value instanceof Map) {
1644
+ return Object.fromEntries(value.entries());
1645
+ }
1646
+ return value;
1647
+ }
1648
+ function writeManifest(capabilities, outputDirectory) {
1649
+ const jsonManifest = JSON.stringify(capabilities, replacer, 4);
1650
+ fs.writeFileSync(path.join(outputDirectory, "manifest.json"), jsonManifest);
1651
+ const tsManifestFile = `${[...capabilities.capabilities?.values() ?? []].flat(2).map((capability) => {
1652
+ return `const ${capability} = require("./${capability}.json")`;
1653
+ }).join("\n")}
1654
+
1655
+ module.exports = {
1656
+ "pluginName": "${capabilities.pluginName}",
1657
+ "capabilities": {
1658
+ ${[...capabilities.capabilities?.entries() ?? []].map(([capabilityName, provides]) => {
1659
+ return `"${capabilityName}":[${provides.join(",")}],`;
1660
+ }).join("\n ")}
1661
+ },
1662
+ "customPrimitives": [
1663
+ ${[capabilities.customPrimitives?.map((i) => `"${i}"`).join(",") ?? ""]}
1664
+ ]
1665
+ }
1666
+ `;
1667
+ fs.writeFileSync(path.join(outputDirectory, "manifest.js"), tsManifestFile);
1668
+ }
1669
+
1670
+ // ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/converters/src/helpers/converter.ts
1671
+ function converter(sourceFile, outputDirectory, customPrimitives, tsOptions = {}) {
1672
+ const program = ts5.createProgram([sourceFile], tsOptions);
1673
+ fs2.mkdirSync(outputDirectory, { recursive: true });
1674
+ const checker = program.getTypeChecker();
1675
+ const converter2 = new TsConverter(checker, customPrimitives);
1676
+ const convertedTypes = converter2.convertSourceFile(
1677
+ program.getSourceFiles()[0]
1678
+ );
1679
+ if (convertedTypes.data.types.length === 0) {
1680
+ return void 0;
1681
+ }
1682
+ convertedTypes.data.types.forEach((type) => {
1683
+ fs2.writeFileSync(
1684
+ path2.join(outputDirectory, `${type.name}.json`),
1685
+ JSON.stringify(type, void 0, 4)
1686
+ );
1687
+ });
1688
+ const manifest = {
1689
+ pluginName: "Types",
1690
+ capabilities: /* @__PURE__ */ new Map([["Types", convertedTypes.convertedTypes]]),
1691
+ customPrimitives
1692
+ };
1693
+ writeManifest(manifest, outputDirectory);
1694
+ }
1695
+ export {
1696
+ ConversionError,
1697
+ TSWriter,
1698
+ TsConverter,
1699
+ converter,
1700
+ exportTypesToTypeScript,
1701
+ writeManifest
1702
+ };
1703
+ //# sourceMappingURL=index.mjs.map