@powerlines/deepkit 0.5.0 → 0.5.1

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 (97) hide show
  1. package/dist/capnp.cjs +48 -47
  2. package/dist/capnp.js +3 -2
  3. package/dist/{chunk-TVDEXHJN.js → chunk-4V4LIAN2.js} +8 -9
  4. package/dist/chunk-7J3ZDT6O.cjs +30 -0
  5. package/dist/{chunk-U4JSDAXK.js → chunk-B6GTAZEL.js} +8 -7
  6. package/dist/{chunk-KYFUOGZ6.cjs → chunk-ESVH44QW.cjs} +9 -10
  7. package/dist/chunk-FFBZWTR7.cjs +63 -0
  8. package/dist/chunk-GRNJVY7I.cjs +19 -0
  9. package/dist/{chunk-DGXATHAN.js → chunk-I5CVIT7W.js} +41 -46
  10. package/dist/chunk-IRPJW6HH.js +16 -0
  11. package/dist/{chunk-SKYW5GV2.cjs → chunk-J2FVIV7W.cjs} +127 -132
  12. package/dist/chunk-J4SVRFV4.js +127 -0
  13. package/dist/{chunk-FEBG7WWO.js → chunk-MEMIQ5AA.js} +1 -3
  14. package/dist/chunk-ORA4UQMU.cjs +2 -0
  15. package/dist/chunk-OULCUN6I.js +1 -0
  16. package/dist/chunk-PKLLVKY2.cjs +193 -0
  17. package/dist/chunk-QLKLDV3V.cjs +135 -0
  18. package/dist/chunk-U5O6DHJ2.js +187 -0
  19. package/dist/{chunk-JHEBLHYK.cjs → chunk-VMRRVNO2.cjs} +2 -4
  20. package/dist/{chunk-55HOZO7D.cjs → chunk-VWKKT7CM.cjs} +5 -7
  21. package/dist/chunk-XGQQM64U.js +8 -0
  22. package/dist/{chunk-BTXPY3B4.js → chunk-YQQIT5YX.js} +2 -4
  23. package/dist/esbuild-plugin.cjs +5 -5
  24. package/dist/esbuild-plugin.d.cts +3 -2
  25. package/dist/esbuild-plugin.d.ts +3 -2
  26. package/dist/esbuild-plugin.js +4 -4
  27. package/dist/index.cjs +69 -69
  28. package/dist/index.js +10 -12
  29. package/dist/reflect-type.cjs +7 -6
  30. package/dist/reflect-type.js +6 -5
  31. package/dist/resolve-reflections.cjs +3 -3
  32. package/dist/resolve-reflections.js +2 -2
  33. package/dist/transformer.cjs +4 -4
  34. package/dist/transformer.js +2 -2
  35. package/dist/transpile.cjs +4 -4
  36. package/dist/transpile.js +3 -3
  37. package/dist/types.cjs +1 -2
  38. package/dist/types.js +1 -2
  39. package/dist/utilities.cjs +10 -9
  40. package/dist/utilities.js +3 -2
  41. package/dist/{chunk-YKFG2BZQ.cjs → vendor/chunk-5NPGWGPO.cjs} +0 -6
  42. package/dist/vendor/{chunk-BLN7QVCP.js → chunk-7LAB3COT.js} +7 -154
  43. package/dist/vendor/chunk-IOMA7ABE.js +359 -0
  44. package/dist/vendor/chunk-K5KCTNDL.cjs +2678 -0
  45. package/dist/vendor/chunk-L3KIZV6P.js +2664 -0
  46. package/dist/vendor/chunk-M3FJ3QXG.cjs +377 -0
  47. package/dist/vendor/chunk-SHUYVCID.js +4 -0
  48. package/dist/vendor/chunk-USNT2KNT.cjs +6 -0
  49. package/dist/{chunk-4WJJKR53.js → vendor/chunk-ZDFKNN7Y.cjs} +281 -322
  50. package/dist/vendor/compiler.cjs +12 -13
  51. package/dist/vendor/compiler.js +2 -5
  52. package/dist/vendor/config.cjs +9 -10
  53. package/dist/vendor/config.js +1 -5
  54. package/dist/vendor/core.cjs +130 -131
  55. package/dist/vendor/core.js +2 -5
  56. package/dist/vendor/index.cjs +14 -22
  57. package/dist/vendor/index.js +3 -11
  58. package/dist/vendor/type-spec.cjs +5 -6
  59. package/dist/vendor/type-spec.js +2 -5
  60. package/dist/vendor/type.cjs +631 -758
  61. package/dist/vendor/type.js +15 -138
  62. package/package.json +4 -4
  63. package/dist/chunk-2V4ET57D.js +0 -6954
  64. package/dist/chunk-6ETLMANX.js +0 -3472
  65. package/dist/chunk-6IQVU53O.cjs +0 -24
  66. package/dist/chunk-6OXPIOZY.cjs +0 -43
  67. package/dist/chunk-7WAH4JD3.js +0 -115
  68. package/dist/chunk-B4PTD5KQ.js +0 -4
  69. package/dist/chunk-ITQKPDCW.cjs +0 -3859
  70. package/dist/chunk-LBHO5BRF.js +0 -2251
  71. package/dist/chunk-OYRIJX67.cjs +0 -3487
  72. package/dist/chunk-PANPZ6S6.cjs +0 -6
  73. package/dist/chunk-QPSZUUB6.cjs +0 -2259
  74. package/dist/chunk-QQ7GKXIS.js +0 -43
  75. package/dist/chunk-SA3DCC4M.cjs +0 -6968
  76. package/dist/chunk-WVKPC33H.cjs +0 -49
  77. package/dist/chunk-YUO4MCOI.js +0 -18
  78. package/dist/vendor/chunk-5BKT4CS5.js +0 -28
  79. package/dist/vendor/chunk-BDXVTHBY.cjs +0 -3859
  80. package/dist/vendor/chunk-EQXMWOHO.cjs +0 -115
  81. package/dist/vendor/chunk-MCNMRQDT.js +0 -3513
  82. package/dist/vendor/chunk-MO4O4UYI.cjs +0 -42
  83. package/dist/vendor/chunk-RH4YMONA.js +0 -7064
  84. package/dist/vendor/chunk-RZKB5IQZ.cjs +0 -3531
  85. package/dist/vendor/chunk-WOXMCJJU.cjs +0 -7078
  86. package/dist/vendor/type-compiler/compiler.cjs +0 -46
  87. package/dist/vendor/type-compiler/compiler.d.cts +0 -1
  88. package/dist/vendor/type-compiler/compiler.d.ts +0 -1
  89. package/dist/vendor/type-compiler/compiler.js +0 -7
  90. package/dist/vendor/type-compiler/config.cjs +0 -36
  91. package/dist/vendor/type-compiler/config.d.cts +0 -6
  92. package/dist/vendor/type-compiler/config.d.ts +0 -6
  93. package/dist/vendor/type-compiler/config.js +0 -5
  94. package/dist/vendor/type-compiler/index.cjs +0 -108
  95. package/dist/vendor/type-compiler/index.d.cts +0 -1
  96. package/dist/vendor/type-compiler/index.d.ts +0 -1
  97. package/dist/vendor/type-compiler/index.js +0 -67
@@ -0,0 +1,2678 @@
1
+ 'use strict';
2
+
3
+ var chunkM3FJ3QXG_cjs = require('./chunk-M3FJ3QXG.cjs');
4
+ var ts2 = require('typescript');
5
+ var vfs = require('@typescript/vfs');
6
+ var tsCloneNode = require('@marcj/ts-clone-node');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var ts2__default = /*#__PURE__*/_interopDefault(ts2);
11
+
12
+ // ../../node_modules/.pnpm/@deepkit+type-spec@1.0.1_patch_hash=f3c3a4fd486751022d78f17d39a5a79f493bca20b185964ca1aba41fbfc93244/node_modules/@deepkit/type-spec/dist/esm/src/type.js
13
+ var TypeNumberBrand;
14
+ (function(TypeNumberBrand2) {
15
+ TypeNumberBrand2[TypeNumberBrand2["integer"] = 0] = "integer";
16
+ TypeNumberBrand2[TypeNumberBrand2["int8"] = 1] = "int8";
17
+ TypeNumberBrand2[TypeNumberBrand2["int16"] = 2] = "int16";
18
+ TypeNumberBrand2[TypeNumberBrand2["int32"] = 3] = "int32";
19
+ TypeNumberBrand2[TypeNumberBrand2["uint8"] = 4] = "uint8";
20
+ TypeNumberBrand2[TypeNumberBrand2["uint16"] = 5] = "uint16";
21
+ TypeNumberBrand2[TypeNumberBrand2["uint32"] = 6] = "uint32";
22
+ TypeNumberBrand2[TypeNumberBrand2["float"] = 7] = "float";
23
+ TypeNumberBrand2[TypeNumberBrand2["float32"] = 8] = "float32";
24
+ TypeNumberBrand2[TypeNumberBrand2["float64"] = 9] = "float64";
25
+ })(TypeNumberBrand || (TypeNumberBrand = {}));
26
+ var ReflectionOp;
27
+ (function(ReflectionOp2) {
28
+ ReflectionOp2[ReflectionOp2["never"] = 0] = "never";
29
+ ReflectionOp2[ReflectionOp2["any"] = 1] = "any";
30
+ ReflectionOp2[ReflectionOp2["unknown"] = 2] = "unknown";
31
+ ReflectionOp2[ReflectionOp2["void"] = 3] = "void";
32
+ ReflectionOp2[ReflectionOp2["object"] = 4] = "object";
33
+ ReflectionOp2[ReflectionOp2["string"] = 5] = "string";
34
+ ReflectionOp2[ReflectionOp2["number"] = 6] = "number";
35
+ ReflectionOp2[ReflectionOp2["numberBrand"] = 7] = "numberBrand";
36
+ ReflectionOp2[ReflectionOp2["boolean"] = 8] = "boolean";
37
+ ReflectionOp2[ReflectionOp2["bigint"] = 9] = "bigint";
38
+ ReflectionOp2[ReflectionOp2["symbol"] = 10] = "symbol";
39
+ ReflectionOp2[ReflectionOp2["null"] = 11] = "null";
40
+ ReflectionOp2[ReflectionOp2["undefined"] = 12] = "undefined";
41
+ ReflectionOp2[ReflectionOp2["literal"] = 13] = "literal";
42
+ ReflectionOp2[ReflectionOp2["function"] = 14] = "function";
43
+ ReflectionOp2[ReflectionOp2["method"] = 15] = "method";
44
+ ReflectionOp2[ReflectionOp2["methodSignature"] = 16] = "methodSignature";
45
+ ReflectionOp2[ReflectionOp2["parameter"] = 17] = "parameter";
46
+ ReflectionOp2[ReflectionOp2["property"] = 18] = "property";
47
+ ReflectionOp2[ReflectionOp2["propertySignature"] = 19] = "propertySignature";
48
+ ReflectionOp2[ReflectionOp2["class"] = 20] = "class";
49
+ ReflectionOp2[ReflectionOp2["classExtends"] = 21] = "classExtends";
50
+ ReflectionOp2[ReflectionOp2["classReference"] = 22] = "classReference";
51
+ ReflectionOp2[ReflectionOp2["optional"] = 23] = "optional";
52
+ ReflectionOp2[ReflectionOp2["readonly"] = 24] = "readonly";
53
+ ReflectionOp2[ReflectionOp2["public"] = 25] = "public";
54
+ ReflectionOp2[ReflectionOp2["private"] = 26] = "private";
55
+ ReflectionOp2[ReflectionOp2["protected"] = 27] = "protected";
56
+ ReflectionOp2[ReflectionOp2["abstract"] = 28] = "abstract";
57
+ ReflectionOp2[ReflectionOp2["defaultValue"] = 29] = "defaultValue";
58
+ ReflectionOp2[ReflectionOp2["description"] = 30] = "description";
59
+ ReflectionOp2[ReflectionOp2["rest"] = 31] = "rest";
60
+ ReflectionOp2[ReflectionOp2["regexp"] = 32] = "regexp";
61
+ ReflectionOp2[ReflectionOp2["enum"] = 33] = "enum";
62
+ ReflectionOp2[ReflectionOp2["enumMember"] = 34] = "enumMember";
63
+ ReflectionOp2[ReflectionOp2["set"] = 35] = "set";
64
+ ReflectionOp2[ReflectionOp2["map"] = 36] = "map";
65
+ ReflectionOp2[ReflectionOp2["array"] = 37] = "array";
66
+ ReflectionOp2[ReflectionOp2["tuple"] = 38] = "tuple";
67
+ ReflectionOp2[ReflectionOp2["tupleMember"] = 39] = "tupleMember";
68
+ ReflectionOp2[ReflectionOp2["namedTupleMember"] = 40] = "namedTupleMember";
69
+ ReflectionOp2[ReflectionOp2["union"] = 41] = "union";
70
+ ReflectionOp2[ReflectionOp2["intersection"] = 42] = "intersection";
71
+ ReflectionOp2[ReflectionOp2["indexSignature"] = 43] = "indexSignature";
72
+ ReflectionOp2[ReflectionOp2["objectLiteral"] = 44] = "objectLiteral";
73
+ ReflectionOp2[ReflectionOp2["mappedType"] = 45] = "mappedType";
74
+ ReflectionOp2[ReflectionOp2["in"] = 46] = "in";
75
+ ReflectionOp2[ReflectionOp2["frame"] = 47] = "frame";
76
+ ReflectionOp2[ReflectionOp2["moveFrame"] = 48] = "moveFrame";
77
+ ReflectionOp2[ReflectionOp2["return"] = 49] = "return";
78
+ ReflectionOp2[ReflectionOp2["templateLiteral"] = 50] = "templateLiteral";
79
+ ReflectionOp2[ReflectionOp2["date"] = 51] = "date";
80
+ ReflectionOp2[ReflectionOp2["int8Array"] = 52] = "int8Array";
81
+ ReflectionOp2[ReflectionOp2["uint8ClampedArray"] = 53] = "uint8ClampedArray";
82
+ ReflectionOp2[ReflectionOp2["uint8Array"] = 54] = "uint8Array";
83
+ ReflectionOp2[ReflectionOp2["int16Array"] = 55] = "int16Array";
84
+ ReflectionOp2[ReflectionOp2["uint16Array"] = 56] = "uint16Array";
85
+ ReflectionOp2[ReflectionOp2["int32Array"] = 57] = "int32Array";
86
+ ReflectionOp2[ReflectionOp2["uint32Array"] = 58] = "uint32Array";
87
+ ReflectionOp2[ReflectionOp2["float32Array"] = 59] = "float32Array";
88
+ ReflectionOp2[ReflectionOp2["float64Array"] = 60] = "float64Array";
89
+ ReflectionOp2[ReflectionOp2["bigInt64Array"] = 61] = "bigInt64Array";
90
+ ReflectionOp2[ReflectionOp2["arrayBuffer"] = 62] = "arrayBuffer";
91
+ ReflectionOp2[ReflectionOp2["promise"] = 63] = "promise";
92
+ ReflectionOp2[ReflectionOp2["arg"] = 64] = "arg";
93
+ ReflectionOp2[ReflectionOp2["typeParameter"] = 65] = "typeParameter";
94
+ ReflectionOp2[ReflectionOp2["typeParameterDefault"] = 66] = "typeParameterDefault";
95
+ ReflectionOp2[ReflectionOp2["var"] = 67] = "var";
96
+ ReflectionOp2[ReflectionOp2["loads"] = 68] = "loads";
97
+ ReflectionOp2[ReflectionOp2["indexAccess"] = 69] = "indexAccess";
98
+ ReflectionOp2[ReflectionOp2["keyof"] = 70] = "keyof";
99
+ ReflectionOp2[ReflectionOp2["infer"] = 71] = "infer";
100
+ ReflectionOp2[ReflectionOp2["typeof"] = 72] = "typeof";
101
+ ReflectionOp2[ReflectionOp2["condition"] = 73] = "condition";
102
+ ReflectionOp2[ReflectionOp2["jumpCondition"] = 74] = "jumpCondition";
103
+ ReflectionOp2[ReflectionOp2["jump"] = 75] = "jump";
104
+ ReflectionOp2[ReflectionOp2["call"] = 76] = "call";
105
+ ReflectionOp2[ReflectionOp2["inline"] = 77] = "inline";
106
+ ReflectionOp2[ReflectionOp2["inlineCall"] = 78] = "inlineCall";
107
+ ReflectionOp2[ReflectionOp2["distribute"] = 79] = "distribute";
108
+ ReflectionOp2[ReflectionOp2["extends"] = 80] = "extends";
109
+ ReflectionOp2[ReflectionOp2["widen"] = 81] = "widen";
110
+ ReflectionOp2[ReflectionOp2["static"] = 82] = "static";
111
+ ReflectionOp2[ReflectionOp2["mappedType2"] = 83] = "mappedType2";
112
+ ReflectionOp2[ReflectionOp2["functionReference"] = 84] = "functionReference";
113
+ ReflectionOp2[ReflectionOp2["callSignature"] = 85] = "callSignature";
114
+ ReflectionOp2[ReflectionOp2["typeName"] = 86] = "typeName";
115
+ ReflectionOp2[ReflectionOp2["implements"] = 87] = "implements";
116
+ ReflectionOp2[ReflectionOp2["nominal"] = 88] = "nominal";
117
+ ReflectionOp2[ReflectionOp2["tags"] = 89] = "tags";
118
+ })(ReflectionOp || (ReflectionOp = {}));
119
+ var { isArrowFunction, isComputedPropertyName, isIdentifier, isNamedImports, isNumericLiteral, isPrivateIdentifier, isStringLiteral, isStringLiteralLike, setOriginalNode, getLeadingCommentRanges, isNoSubstitutionTemplateLiteral, NodeFlags, SyntaxKind } = ts2__default.default;
120
+ function is__String(value) {
121
+ return typeof value === "string";
122
+ }
123
+ chunkM3FJ3QXG_cjs.__name(is__String, "is__String");
124
+ function getIdentifierName(node) {
125
+ if (is__String(node)) return node;
126
+ if (isIdentifier(node) || isPrivateIdentifier(node)) {
127
+ return ts2__default.default.unescapeLeadingUnderscores(node.escapedText);
128
+ }
129
+ if (isStringLiteral(node)) return node.text;
130
+ return "";
131
+ }
132
+ chunkM3FJ3QXG_cjs.__name(getIdentifierName, "getIdentifierName");
133
+ function getEscapedText(node) {
134
+ if (is__String(node)) return node;
135
+ if (isIdentifier(node) || isPrivateIdentifier(node)) return node.escapedText;
136
+ return getIdentifierName(node);
137
+ }
138
+ chunkM3FJ3QXG_cjs.__name(getEscapedText, "getEscapedText");
139
+ function findSourceFile(node) {
140
+ if (node.kind === SyntaxKind.SourceFile) return node;
141
+ let current = node.parent;
142
+ while (current && current.kind !== SyntaxKind.SourceFile) {
143
+ current = current.parent;
144
+ }
145
+ return current;
146
+ }
147
+ chunkM3FJ3QXG_cjs.__name(findSourceFile, "findSourceFile");
148
+ function joinQualifiedName(name) {
149
+ if (isIdentifier(name)) return getIdentifierName(name);
150
+ return joinQualifiedName(name.left) + "_" + getIdentifierName(name.right);
151
+ }
152
+ chunkM3FJ3QXG_cjs.__name(joinQualifiedName, "joinQualifiedName");
153
+ var BANNER_REGEX = /^\/\*\s---.*\n[\s\S]*\s*---\s*\*\//;
154
+ function getCommentOfNode(sourceFile, node) {
155
+ const commentLines = getLeadingCommentRanges(sourceFile.text, node.pos);
156
+ if (!commentLines || commentLines.length === 0) return;
157
+ const commentLine = commentLines.slice(-1)[0];
158
+ if (!commentLine) return;
159
+ const comment = sourceFile.text.slice(commentLine.pos, commentLine.end);
160
+ if (comment.match(BANNER_REGEX)) {
161
+ return void 0;
162
+ }
163
+ return comment;
164
+ }
165
+ chunkM3FJ3QXG_cjs.__name(getCommentOfNode, "getCommentOfNode");
166
+ function parseJSDocAttributeFromText(comment, attribute) {
167
+ const attributeStr = `@${attribute} `;
168
+ const index = comment.indexOf(attributeStr);
169
+ if (index === -1) {
170
+ let start2 = 0;
171
+ while (true) {
172
+ const withoutContent = comment.indexOf(`@${attribute}`, start2);
173
+ if (withoutContent === -1) {
174
+ return [
175
+ void 0,
176
+ -1
177
+ ];
178
+ }
179
+ const nextCharacter = comment[withoutContent + attribute.length + 1];
180
+ if (!nextCharacter || nextCharacter === " " || nextCharacter === "\n" || nextCharacter === "\r" || nextCharacter === " ") {
181
+ return [
182
+ void 0,
183
+ withoutContent + attribute.length + 1
184
+ ];
185
+ }
186
+ start2 = withoutContent + attribute.length + 1;
187
+ }
188
+ }
189
+ const start = index + attributeStr.length;
190
+ const nextAttribute = comment.indexOf("@", start);
191
+ const endOfComment = comment.indexOf("*/", start);
192
+ const end = nextAttribute === -1 ? endOfComment : Math.min(nextAttribute, endOfComment);
193
+ const content = comment.substring(start, end).trim();
194
+ return [
195
+ content.split("\n").map((v) => {
196
+ const indexOfStar = v.indexOf("*");
197
+ if (indexOfStar === -1) {
198
+ return v.trim();
199
+ }
200
+ return v.substring(indexOfStar + 1).trim();
201
+ }).join("\n").replace(/\n*$/g, ""),
202
+ end + 1
203
+ ];
204
+ }
205
+ chunkM3FJ3QXG_cjs.__name(parseJSDocAttributeFromText, "parseJSDocAttributeFromText");
206
+ function parseJSDocBooleanFromText(comment, attribute) {
207
+ return new RegExp(`^s*@(${attribute?.trim()})s*(false|False|FALSE|0|n|N|no|No|NO)s*$`, "gm").test(comment?.trim()) ? false : new RegExp(`^s*@(${attribute?.trim()})s*(true|True|TRUE|1|y|Y|yes|Yes|YES)?s*$`, "gm").test(comment?.trim()) ? true : void 0;
208
+ }
209
+ chunkM3FJ3QXG_cjs.__name(parseJSDocBooleanFromText, "parseJSDocBooleanFromText");
210
+ function parseJSDocDescription(comment) {
211
+ let lines = comment.split("\n").filter((line) => line && !line.includes("/**") && !line.includes("*/")).map((line) => line.replace(/^\s*\*\s*/g, "").replace(/^\*\s*/g, "").trim());
212
+ const attribute = lines.findIndex((line) => line.startsWith("@"));
213
+ if (attribute !== -1) {
214
+ lines = lines.slice(0, attribute);
215
+ }
216
+ return lines.join("\n").trim() || void 0;
217
+ }
218
+ chunkM3FJ3QXG_cjs.__name(parseJSDocDescription, "parseJSDocDescription");
219
+ function extractJSDocAttribute(sourceFile, node, attribute) {
220
+ if (!node) return void 0;
221
+ const comment = getCommentOfNode(sourceFile, node);
222
+ if (!comment) return void 0;
223
+ let result = parseJSDocAttributeFromText(comment, attribute);
224
+ if (!result[0] && attribute === "description") {
225
+ result[0] = parseJSDocDescription(comment);
226
+ }
227
+ return result[0];
228
+ }
229
+ chunkM3FJ3QXG_cjs.__name(extractJSDocAttribute, "extractJSDocAttribute");
230
+ function extractJSDocArray(sourceFile, node, attribute) {
231
+ if (!node) return void 0;
232
+ const comment = getCommentOfNode(sourceFile, node);
233
+ if (!comment) return void 0;
234
+ const results = [];
235
+ try {
236
+ let result = parseJSDocAttributeFromText(comment, attribute);
237
+ if (result.length < 2) {
238
+ return void 0;
239
+ }
240
+ if (result[0] && result[1] > -1) {
241
+ results.push(result[0]);
242
+ }
243
+ let currentComment = comment;
244
+ while (result[1] > -1 && currentComment.length > result[1]) {
245
+ currentComment = currentComment.substring(result[1]);
246
+ result = parseJSDocAttributeFromText(currentComment, attribute);
247
+ if (result[0]) {
248
+ results.push(result[0]);
249
+ }
250
+ }
251
+ } catch (error) {
252
+ console.error("Error parsing JSDoc attribute:", attribute, "in comment:", comment);
253
+ console.error(error);
254
+ }
255
+ return results;
256
+ }
257
+ chunkM3FJ3QXG_cjs.__name(extractJSDocArray, "extractJSDocArray");
258
+ function extractJSDocBoolean(sourceFile, node, attribute) {
259
+ if (!node) {
260
+ return void 0;
261
+ }
262
+ const comment = getCommentOfNode(sourceFile, node);
263
+ if (!comment) {
264
+ return void 0;
265
+ }
266
+ return parseJSDocBooleanFromText(comment, attribute);
267
+ }
268
+ chunkM3FJ3QXG_cjs.__name(extractJSDocBoolean, "extractJSDocBoolean");
269
+ function getPropertyName(f, node) {
270
+ if (!node) return "";
271
+ if (isIdentifier(node)) return getIdentifierName(node);
272
+ if (isStringLiteral(node)) return node.text;
273
+ if (isNumericLiteral(node)) return +node.text;
274
+ if (isNoSubstitutionTemplateLiteral(node)) return node.text;
275
+ if (isComputedPropertyName(node)) {
276
+ return f.createArrowFunction(void 0, void 0, [], void 0, void 0, node.expression);
277
+ }
278
+ if (isPrivateIdentifier(node)) return getIdentifierName(node);
279
+ return "";
280
+ }
281
+ chunkM3FJ3QXG_cjs.__name(getPropertyName, "getPropertyName");
282
+ function getNameAsString(node) {
283
+ if (!node) return "";
284
+ if (isIdentifier(node)) return getIdentifierName(node);
285
+ if (isStringLiteral(node)) return node.text;
286
+ if (isNumericLiteral(node)) return node.text;
287
+ if (ts2.isBigIntLiteral(node)) return node.text;
288
+ if (isNoSubstitutionTemplateLiteral(node)) return node.text;
289
+ if (isComputedPropertyName(node)) {
290
+ if (isStringLiteralLike(node) || isNumericLiteral(node)) return node.text;
291
+ return "";
292
+ }
293
+ if (isPrivateIdentifier(node)) return getIdentifierName(node);
294
+ return joinQualifiedName(node);
295
+ }
296
+ chunkM3FJ3QXG_cjs.__name(getNameAsString, "getNameAsString");
297
+ function hasModifier(node, modifier) {
298
+ if (!node.modifiers) return false;
299
+ return node.modifiers.some((v) => v.kind === modifier);
300
+ }
301
+ chunkM3FJ3QXG_cjs.__name(hasModifier, "hasModifier");
302
+ var cloneHook = /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((node, payload) => {
303
+ if (isIdentifier(node)) {
304
+ return {
305
+ text: /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name(() => {
306
+ return getIdentifierName(node);
307
+ }, "text")
308
+ };
309
+ }
310
+ return;
311
+ }, "cloneHook");
312
+ var NodeConverter = class {
313
+ static {
314
+ chunkM3FJ3QXG_cjs.__name(this, "NodeConverter");
315
+ }
316
+ constructor(f) {
317
+ this.f = f;
318
+ }
319
+ toExpression(node) {
320
+ if (node === void 0) return this.f.createIdentifier("undefined");
321
+ if (Array.isArray(node)) {
322
+ return this.f.createArrayLiteralExpression(this.f.createNodeArray(node.map((v) => this.toExpression(v))));
323
+ }
324
+ if ("string" === typeof node) return this.f.createStringLiteral(node, true);
325
+ if ("number" === typeof node) return this.f.createNumericLiteral(node);
326
+ if ("bigint" === typeof node) return this.f.createBigIntLiteral(String(node));
327
+ if ("boolean" === typeof node) return node ? this.f.createTrue() : this.f.createFalse();
328
+ if (node.pos === -1 && node.end === -1 && node.parent === void 0) {
329
+ if (isArrowFunction(node)) {
330
+ if (node.body.pos === -1 && node.body.end === -1 && node.body.parent === void 0) return node;
331
+ return this.f.createArrowFunction(node.modifiers, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, this.toExpression(node.body));
332
+ }
333
+ return node;
334
+ }
335
+ switch (node.kind) {
336
+ case SyntaxKind.Identifier:
337
+ return finish(node, this.f.createIdentifier(getIdentifierName(node)));
338
+ case SyntaxKind.StringLiteral:
339
+ return finish(node, this.f.createStringLiteral(node.text));
340
+ case SyntaxKind.NumericLiteral:
341
+ return finish(node, this.f.createNumericLiteral(node.text));
342
+ case SyntaxKind.BigIntLiteral:
343
+ return finish(node, this.f.createBigIntLiteral(node.text));
344
+ case SyntaxKind.TrueKeyword:
345
+ return finish(node, this.f.createTrue());
346
+ case SyntaxKind.FalseKeyword:
347
+ return finish(node, this.f.createFalse());
348
+ }
349
+ try {
350
+ return tsCloneNode.cloneNode(node, {
351
+ preserveComments: false,
352
+ factory: this.f,
353
+ setOriginalNodes: true,
354
+ preserveSymbols: true,
355
+ setParents: true,
356
+ hook: cloneHook
357
+ });
358
+ } catch (error) {
359
+ console.error("could not clone node", node);
360
+ throw error;
361
+ }
362
+ }
363
+ };
364
+ function isExternalOrCommonJsModule(file) {
365
+ return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== void 0;
366
+ }
367
+ chunkM3FJ3QXG_cjs.__name(isExternalOrCommonJsModule, "isExternalOrCommonJsModule");
368
+ function isNodeWithLocals(node) {
369
+ return "locals" in node;
370
+ }
371
+ chunkM3FJ3QXG_cjs.__name(isNodeWithLocals, "isNodeWithLocals");
372
+ function getGlobalsOfSourceFile(file) {
373
+ if (file.redirectInfo) return;
374
+ if (!isNodeWithLocals(file)) return;
375
+ if (!isExternalOrCommonJsModule(file)) return file.locals;
376
+ if (file.jsGlobalAugmentations) return file.jsGlobalAugmentations;
377
+ if (file.symbol && file.symbol.globalExports) return file.symbol.globalExports;
378
+ }
379
+ chunkM3FJ3QXG_cjs.__name(getGlobalsOfSourceFile, "getGlobalsOfSourceFile");
380
+ function ensureImportIsEmitted(importDeclaration, specifierName) {
381
+ if (specifierName && importDeclaration.importClause && importDeclaration.importClause.namedBindings) {
382
+ if (isNamedImports(importDeclaration.importClause.namedBindings)) {
383
+ for (const element of importDeclaration.importClause.namedBindings.elements) {
384
+ if (element.name.escapedText === specifierName.escapedText) {
385
+ element.flags |= NodeFlags.Synthesized;
386
+ return;
387
+ }
388
+ }
389
+ }
390
+ }
391
+ importDeclaration.flags |= NodeFlags.Synthesized;
392
+ }
393
+ chunkM3FJ3QXG_cjs.__name(ensureImportIsEmitted, "ensureImportIsEmitted");
394
+ function serializeEntityNameAsExpression(f, node) {
395
+ switch (node.kind) {
396
+ case SyntaxKind.Identifier:
397
+ return finish(node, f.createIdentifier(getIdentifierName(node)));
398
+ case SyntaxKind.QualifiedName:
399
+ return finish(node, serializeQualifiedNameAsExpression(f, node));
400
+ }
401
+ return node;
402
+ }
403
+ chunkM3FJ3QXG_cjs.__name(serializeEntityNameAsExpression, "serializeEntityNameAsExpression");
404
+ function serializeQualifiedNameAsExpression(f, node) {
405
+ return f.createPropertyAccessExpression(serializeEntityNameAsExpression(f, node.left), node.right);
406
+ }
407
+ chunkM3FJ3QXG_cjs.__name(serializeQualifiedNameAsExpression, "serializeQualifiedNameAsExpression");
408
+ function finish(oldNode, newNode) {
409
+ setOriginalNode(newNode, oldNode);
410
+ newNode._original = newNode.original;
411
+ newNode._symbol = oldNode._symbol ?? oldNode.symbol;
412
+ newNode.symbol = newNode._symbol;
413
+ return newNode;
414
+ }
415
+ chunkM3FJ3QXG_cjs.__name(finish, "finish");
416
+
417
+ // ../../node_modules/.pnpm/@deepkit+type-compiler@1.0.5_patch_hash=88e8267ac73f46799c551ae3696181dc1f272895f490f8c_ef8b874d406bec4900e1fddc1ea375be/node_modules/@deepkit/type-compiler/dist/esm/src/compiler.js
418
+ var { visitEachChild, visitNode, isPropertyAssignment, isArrayTypeNode, isArrowFunction: isArrowFunction2, isBlock, isCallExpression, isCallSignatureDeclaration, isClassDeclaration, isClassExpression, isConstructorDeclaration, isConstructorTypeNode, isConstructSignatureDeclaration, isEnumDeclaration, isExportDeclaration, isExpression, isExpressionWithTypeArguments, isFunctionDeclaration, isFunctionExpression, isFunctionLike, isIdentifier: isIdentifier2, isImportClause, isImportDeclaration, isImportSpecifier, isInferTypeNode, isInterfaceDeclaration, isMethodDeclaration, isMethodSignature, isModuleDeclaration, isNamedExports, isNamedTupleMember, isNewExpression, isObjectLiteralExpression, isOptionalTypeNode, isParameter, isParenthesizedExpression, isParenthesizedTypeNode, isPropertyAccessExpression, isQualifiedName, isSourceFile, isStringLiteral: isStringLiteral2, isTypeAliasDeclaration, isTypeLiteralNode, isTypeParameterDeclaration, isTypeQueryNode, isTypeReferenceNode, isUnionTypeNode, isExpressionStatement, isVariableDeclaration, getEffectiveConstraintOfTypeParameter, addSyntheticLeadingComment, createCompilerHost, createPrinter, escapeLeadingUnderscores, EmitHint, NodeFlags: NodeFlags2, SyntaxKind: SyntaxKind2, ScriptTarget, ModifierFlags, ScriptKind } = ts2__default.default;
419
+ function encodeOps(ops) {
420
+ return ops.map((v) => String.fromCharCode(v + 33)).join("");
421
+ }
422
+ chunkM3FJ3QXG_cjs.__name(encodeOps, "encodeOps");
423
+ function filterUndefined(object) {
424
+ return Object.fromEntries(Object.entries(object).filter(([, v]) => v !== void 0));
425
+ }
426
+ chunkM3FJ3QXG_cjs.__name(filterUndefined, "filterUndefined");
427
+ var packSizeByte = 6;
428
+ var packSize = 2 ** packSizeByte;
429
+ var OPs = {
430
+ [ReflectionOp.literal]: {
431
+ params: 1
432
+ },
433
+ // [ReflectionOp.pointer]: { params: 1 },
434
+ // [ReflectionOp.arg]: { params: 1 },
435
+ [ReflectionOp.classReference]: {
436
+ params: 1
437
+ },
438
+ [ReflectionOp.propertySignature]: {
439
+ params: 1
440
+ },
441
+ [ReflectionOp.property]: {
442
+ params: 1
443
+ },
444
+ [ReflectionOp.jump]: {
445
+ params: 1
446
+ },
447
+ [ReflectionOp.enum]: {
448
+ params: 0
449
+ },
450
+ [ReflectionOp.enumMember]: {
451
+ params: 1
452
+ },
453
+ [ReflectionOp.typeParameter]: {
454
+ params: 1
455
+ },
456
+ [ReflectionOp.typeParameterDefault]: {
457
+ params: 1
458
+ },
459
+ [ReflectionOp.mappedType]: {
460
+ params: 2
461
+ },
462
+ [ReflectionOp.call]: {
463
+ params: 1
464
+ },
465
+ [ReflectionOp.inline]: {
466
+ params: 1
467
+ },
468
+ [ReflectionOp.inlineCall]: {
469
+ params: 2
470
+ },
471
+ [ReflectionOp.loads]: {
472
+ params: 2
473
+ },
474
+ [ReflectionOp.extends]: {
475
+ params: 0
476
+ },
477
+ [ReflectionOp.infer]: {
478
+ params: 2
479
+ },
480
+ [ReflectionOp.defaultValue]: {
481
+ params: 1
482
+ },
483
+ [ReflectionOp.parameter]: {
484
+ params: 1
485
+ },
486
+ [ReflectionOp.method]: {
487
+ params: 1
488
+ },
489
+ [ReflectionOp.function]: {
490
+ params: 1
491
+ },
492
+ [ReflectionOp.description]: {
493
+ params: 1
494
+ },
495
+ [ReflectionOp.numberBrand]: {
496
+ params: 1
497
+ },
498
+ [ReflectionOp.typeof]: {
499
+ params: 1
500
+ },
501
+ [ReflectionOp.classExtends]: {
502
+ params: 1
503
+ },
504
+ [ReflectionOp.distribute]: {
505
+ params: 1
506
+ },
507
+ [ReflectionOp.jumpCondition]: {
508
+ params: 2
509
+ },
510
+ [ReflectionOp.typeName]: {
511
+ params: 1
512
+ },
513
+ [ReflectionOp.implements]: {
514
+ params: 1
515
+ },
516
+ [ReflectionOp.tags]: {
517
+ params: 1
518
+ }
519
+ };
520
+ function debugPackStruct(sourceFile, forType, pack) {
521
+ const items = [];
522
+ for (let i = 0; i < pack.ops.length; i++) {
523
+ const op = pack.ops[i];
524
+ const opInfo = OPs[op];
525
+ items.push(ReflectionOp[op]);
526
+ if (opInfo && opInfo.params > 0) {
527
+ for (let j = 0; j < opInfo.params; j++) {
528
+ const address = pack.ops[++i];
529
+ items.push(address);
530
+ }
531
+ }
532
+ }
533
+ const printer = createPrinter();
534
+ const stack = [];
535
+ for (const s of pack.stack) {
536
+ if ("object" === typeof s && "getText" in s) {
537
+ stack.push(printer.printNode(EmitHint.Unspecified, s, sourceFile));
538
+ } else {
539
+ stack.push(JSON.stringify(s));
540
+ }
541
+ }
542
+ console.log(stack.join(","), "|", ...items);
543
+ }
544
+ chunkM3FJ3QXG_cjs.__name(debugPackStruct, "debugPackStruct");
545
+ function findVariable(frame, name, frameOffset = 0) {
546
+ const variable = frame.variables.find((v) => v.name === name);
547
+ if (variable) {
548
+ return {
549
+ frameOffset,
550
+ stackIndex: variable.index
551
+ };
552
+ }
553
+ if (frame.previous) return findVariable(frame.previous, name, frameOffset + 1);
554
+ return;
555
+ }
556
+ chunkM3FJ3QXG_cjs.__name(findVariable, "findVariable");
557
+ function findConditionalFrame(frame) {
558
+ if (frame.conditional) return frame;
559
+ if (frame.previous) return findConditionalFrame(frame.previous);
560
+ return;
561
+ }
562
+ chunkM3FJ3QXG_cjs.__name(findConditionalFrame, "findConditionalFrame");
563
+ var CompilerProgram = class CompilerProgram2 {
564
+ static {
565
+ chunkM3FJ3QXG_cjs.__name(this, "CompilerProgram");
566
+ }
567
+ constructor(forNode, sourceFile) {
568
+ this.forNode = forNode;
569
+ this.sourceFile = sourceFile;
570
+ this.ops = [];
571
+ this.stack = [];
572
+ this.mainOffset = 0;
573
+ this.stackPosition = 0;
574
+ this.frame = {
575
+ variables: [],
576
+ opIndex: 0
577
+ };
578
+ this.activeCoRoutines = [];
579
+ this.coRoutines = [];
580
+ this.resolveFunctionParameters = /* @__PURE__ */ new Map();
581
+ }
582
+ buildPackStruct() {
583
+ const ops = [
584
+ ...this.ops
585
+ ];
586
+ if (this.coRoutines.length) {
587
+ for (let i = this.coRoutines.length - 1; i >= 0; i--) {
588
+ ops.unshift(...this.coRoutines[i].ops);
589
+ }
590
+ }
591
+ if (this.mainOffset) {
592
+ ops.unshift(ReflectionOp.jump, this.mainOffset);
593
+ }
594
+ return {
595
+ ops,
596
+ stack: this.stack
597
+ };
598
+ }
599
+ isEmpty() {
600
+ return this.ops.length === 0;
601
+ }
602
+ pushConditionalFrame() {
603
+ const frame = this.pushFrame();
604
+ frame.conditional = true;
605
+ }
606
+ pushStack(item) {
607
+ this.stack.push(item);
608
+ return this.stackPosition++;
609
+ }
610
+ pushCoRoutine() {
611
+ this.pushFrame(true);
612
+ this.activeCoRoutines.push({
613
+ ops: []
614
+ });
615
+ }
616
+ popCoRoutine() {
617
+ const coRoutine = this.activeCoRoutines.pop();
618
+ if (!coRoutine) throw new Error("No active co routine found");
619
+ this.popFrameImplicit();
620
+ if (this.mainOffset === 0) {
621
+ this.mainOffset = 2;
622
+ }
623
+ const startIndex = this.mainOffset;
624
+ coRoutine.ops.push(ReflectionOp.return);
625
+ this.coRoutines.push(coRoutine);
626
+ this.mainOffset += coRoutine.ops.length;
627
+ return startIndex;
628
+ }
629
+ pushOp(...ops) {
630
+ for (const op of ops) {
631
+ if ("number" !== typeof op) {
632
+ throw new Error("No valid OP added");
633
+ }
634
+ }
635
+ if (this.activeCoRoutines.length) {
636
+ this.activeCoRoutines[this.activeCoRoutines.length - 1].ops.push(...ops);
637
+ return;
638
+ }
639
+ this.ops.push(...ops);
640
+ }
641
+ pushOpAtFrame(frame, ...ops) {
642
+ if (this.activeCoRoutines.length) {
643
+ this.activeCoRoutines[this.activeCoRoutines.length - 1].ops.splice(frame.opIndex, 0, ...ops);
644
+ return;
645
+ }
646
+ this.ops.splice(frame.opIndex, 0, ...ops);
647
+ }
648
+ /**
649
+ * Returns the index of the `entry` in the stack, if already exists. If not, add it, and return that new index.
650
+ */
651
+ findOrAddStackEntry(entry) {
652
+ const index = this.stack.indexOf(entry);
653
+ if (index !== -1) return index;
654
+ return this.pushStack(entry);
655
+ }
656
+ /**
657
+ * To make room for a stack entry expected on the stack as input for example.
658
+ */
659
+ increaseStackPosition() {
660
+ return this.stackPosition++;
661
+ }
662
+ resolveFunctionParametersIncrease(fn) {
663
+ this.resolveFunctionParameters.set(fn, (this.resolveFunctionParameters.get(fn) || 0) + 1);
664
+ }
665
+ resolveFunctionParametersDecrease(fn) {
666
+ this.resolveFunctionParameters.set(fn, (this.resolveFunctionParameters.get(fn) || 1) - 1);
667
+ }
668
+ isResolveFunctionParameters(fn) {
669
+ return (this.resolveFunctionParameters.get(fn) || 0) > 0;
670
+ }
671
+ /**
672
+ *
673
+ * Each pushFrame() call needs a popFrame() call.
674
+ */
675
+ pushFrame(implicit = false) {
676
+ if (!implicit) this.pushOp(ReflectionOp.frame);
677
+ const opIndex = this.activeCoRoutines.length ? this.activeCoRoutines[this.activeCoRoutines.length - 1].ops.length : this.ops.length;
678
+ this.frame = {
679
+ previous: this.frame,
680
+ variables: [],
681
+ opIndex
682
+ };
683
+ return this.frame;
684
+ }
685
+ findConditionalFrame() {
686
+ return findConditionalFrame(this.frame);
687
+ }
688
+ /**
689
+ * Remove stack without doing it as OP in the processor. Some other command calls popFrame() already, which makes popFrameImplicit() an implicit popFrame.
690
+ * e.g. union, class, etc. all call popFrame(). the current CompilerProgram needs to be aware of that, which this function is for.
691
+ */
692
+ popFrameImplicit() {
693
+ if (this.frame.previous) this.frame = this.frame.previous;
694
+ }
695
+ moveFrame() {
696
+ this.pushOp(ReflectionOp.moveFrame);
697
+ if (this.frame.previous) this.frame = this.frame.previous;
698
+ }
699
+ pushVariable(name, frame = this.frame) {
700
+ this.pushOpAtFrame(frame, ReflectionOp.var);
701
+ frame.variables.push({
702
+ index: frame.variables.length,
703
+ name
704
+ });
705
+ return frame.variables.length - 1;
706
+ }
707
+ pushTemplateParameter(name, withDefault = false) {
708
+ this.pushOp(withDefault ? ReflectionOp.typeParameterDefault : ReflectionOp.typeParameter, this.findOrAddStackEntry(name));
709
+ this.frame.variables.push({
710
+ index: this.frame.variables.length,
711
+ name
712
+ });
713
+ return this.frame.variables.length - 1;
714
+ }
715
+ findVariable(name, frame = this.frame) {
716
+ return findVariable(frame, name);
717
+ }
718
+ };
719
+ function getAssignTypeExpression(call) {
720
+ if (isParenthesizedExpression(call) && isCallExpression(call.expression)) {
721
+ call = call.expression;
722
+ }
723
+ if (isCallExpression(call) && isIdentifier2(call.expression) && getIdentifierName(call.expression) === "__assignType" && call.arguments.length > 0) {
724
+ return call.arguments[0];
725
+ }
726
+ return;
727
+ }
728
+ chunkM3FJ3QXG_cjs.__name(getAssignTypeExpression, "getAssignTypeExpression");
729
+ function getReceiveTypeParameter(type) {
730
+ if (isUnionTypeNode(type)) {
731
+ for (const t of type.types) {
732
+ const rfn = getReceiveTypeParameter(t);
733
+ if (rfn) return rfn;
734
+ }
735
+ } else if (isTypeReferenceNode(type) && isIdentifier2(type.typeName) && getIdentifierName(type.typeName) === "ReceiveType" && !!type.typeArguments && type.typeArguments.length === 1) return type;
736
+ return;
737
+ }
738
+ chunkM3FJ3QXG_cjs.__name(getReceiveTypeParameter, "getReceiveTypeParameter");
739
+ var Cache = class {
740
+ static {
741
+ chunkM3FJ3QXG_cjs.__name(this, "Cache");
742
+ }
743
+ constructor() {
744
+ this.resolver = {};
745
+ this.sourceFiles = {};
746
+ }
747
+ /**
748
+ * Signals the cache to check if it needs to be cleared.
749
+ */
750
+ tick() {
751
+ if (Object.keys(this.sourceFiles).length > 300) {
752
+ this.sourceFiles = {};
753
+ }
754
+ }
755
+ };
756
+ var ReflectionTransformer = class {
757
+ static {
758
+ chunkM3FJ3QXG_cjs.__name(this, "ReflectionTransformer");
759
+ }
760
+ constructor(context, cache2 = new Cache()) {
761
+ this.context = context;
762
+ this.cache = cache2;
763
+ this.embedAssignType = false;
764
+ this.compileDeclarations = /* @__PURE__ */ new Map();
765
+ this.embedDeclarations = /* @__PURE__ */ new Map();
766
+ this.compiledDeclarations = /* @__PURE__ */ new Set();
767
+ this.addImports = [];
768
+ this.overriddenHost = false;
769
+ this.knownClasses = {
770
+ "Int8Array": ReflectionOp.int8Array,
771
+ "Uint8Array": ReflectionOp.uint8Array,
772
+ "Uint8ClampedArray": ReflectionOp.uint8ClampedArray,
773
+ "Int16Array": ReflectionOp.int16Array,
774
+ "Uint16Array": ReflectionOp.uint16Array,
775
+ "Int32Array": ReflectionOp.int32Array,
776
+ "Uint32Array": ReflectionOp.uint32Array,
777
+ "Float32Array": ReflectionOp.float32Array,
778
+ "Float64Array": ReflectionOp.float64Array,
779
+ "ArrayBuffer": ReflectionOp.arrayBuffer,
780
+ "BigInt64Array": ReflectionOp.bigInt64Array,
781
+ "Date": ReflectionOp.date,
782
+ "RegExp": ReflectionOp.regexp,
783
+ "String": ReflectionOp.string,
784
+ "Number": ReflectionOp.number,
785
+ "BigInt": ReflectionOp.bigint,
786
+ "Boolean": ReflectionOp.boolean
787
+ };
788
+ this.f = context.factory;
789
+ this.nodeConverter = new NodeConverter(this.f);
790
+ this.compilerOptions = {
791
+ ...filterUndefined(context.getCompilerOptions())
792
+ };
793
+ this.host = createCompilerHost(this.compilerOptions);
794
+ this.resolver = new chunkM3FJ3QXG_cjs.Resolver(this.compilerOptions, this.host, this.cache.sourceFiles);
795
+ this.parseConfigHost = {
796
+ useCaseSensitiveFileNames: true,
797
+ fileExists: /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((path) => this.host.fileExists(path), "fileExists"),
798
+ readFile: /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((path) => this.host.readFile(path), "readFile"),
799
+ readDirectory: /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((path, extensions, exclude, include, depth) => {
800
+ if (!this.host.readDirectory) return [];
801
+ return this.host.readDirectory(path, extensions || [], exclude, include || [], depth);
802
+ }, "readDirectory")
803
+ };
804
+ {
805
+ const T = this.f.createIdentifier("T");
806
+ const Options = this.f.createIdentifier("Options");
807
+ this.intrinsicMetaDeclaration = this.f.createTypeAliasDeclaration([], "TypeAnnotation", [
808
+ this.f.createTypeParameterDeclaration([], T),
809
+ this.f.createTypeParameterDeclaration([], Options, void 0, this.f.createTypeReferenceNode("never"))
810
+ ], this.f.createTypeLiteralNode([
811
+ this.f.createPropertySignature(void 0, "__meta", this.f.createToken(SyntaxKind2.QuestionToken), this.f.createIntersectionTypeNode([
812
+ this.f.createTypeReferenceNode("never"),
813
+ this.f.createTupleTypeNode([
814
+ this.f.createTypeReferenceNode(T),
815
+ this.f.createTypeReferenceNode(Options)
816
+ ])
817
+ ]))
818
+ ]));
819
+ }
820
+ }
821
+ forHost(host) {
822
+ this.host = host;
823
+ this.resolver.host = host;
824
+ this.overriddenHost = true;
825
+ return this;
826
+ }
827
+ withReflection(config) {
828
+ const configResolver = {
829
+ reflectionLevel: "normal",
830
+ ...config,
831
+ path: "",
832
+ mergeStrategy: "replace",
833
+ compilerOptions: this.compilerOptions
834
+ };
835
+ const match = /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((path) => {
836
+ const mode = chunkM3FJ3QXG_cjs.reflectionModeMatcher(config, path);
837
+ return {
838
+ mode,
839
+ tsConfigPath: "",
840
+ level: configResolver.reflectionLevel
841
+ };
842
+ }, "match");
843
+ this.overriddenConfigResolver = {
844
+ config: configResolver,
845
+ match
846
+ };
847
+ return this;
848
+ }
849
+ transformBundle(node) {
850
+ return node;
851
+ }
852
+ getTempResultIdentifier() {
853
+ if (this.tempResultIdentifier) return this.tempResultIdentifier;
854
+ const locals = isNodeWithLocals(this.sourceFile) ? this.sourceFile.locals : void 0;
855
+ if (locals) {
856
+ let found = "\u03A9r";
857
+ for (let i = 0; ; i++) {
858
+ found = "\u03A9r" + (i ? i : "");
859
+ if (!locals.has(escapeLeadingUnderscores(found))) break;
860
+ }
861
+ this.tempResultIdentifier = this.f.createIdentifier(found);
862
+ } else {
863
+ this.tempResultIdentifier = this.f.createIdentifier("\u03A9r");
864
+ }
865
+ return this.tempResultIdentifier;
866
+ }
867
+ getConfigResolver(sourceFile) {
868
+ if (this.overriddenConfigResolver) {
869
+ return this.overriddenConfigResolver;
870
+ }
871
+ return chunkM3FJ3QXG_cjs.getConfigResolver(this.cache.resolver, this.parseConfigHost, this.compilerOptions, sourceFile);
872
+ }
873
+ getReflectionConfig(sourceFile) {
874
+ const configResolver = this.getConfigResolver(sourceFile);
875
+ return configResolver.match(sourceFile.fileName);
876
+ }
877
+ isWithReflection(sourceFile, node) {
878
+ const mode = this.getExplicitReflectionMode(sourceFile, node);
879
+ if (mode === false) return false;
880
+ if (!sourceFile) return true;
881
+ const reflection = this.getReflectionConfig(sourceFile);
882
+ if (reflection.mode === "explicit") return mode === true;
883
+ return reflection.mode === "default";
884
+ }
885
+ transformSourceFile(sourceFile) {
886
+ this.sourceFile = sourceFile;
887
+ if (sourceFile.scriptKind !== ScriptKind.TS && sourceFile.scriptKind !== ScriptKind.TSX) return sourceFile;
888
+ if (sourceFile.deepkitTransformed) return sourceFile;
889
+ this.embedAssignType = false;
890
+ this.addImports = [];
891
+ const start = Date.now();
892
+ const configResolver = this.getConfigResolver(sourceFile);
893
+ const reflection = configResolver.match(sourceFile.fileName);
894
+ Object.assign(this.compilerOptions, configResolver.config.compilerOptions);
895
+ if (reflection.mode === "never") {
896
+ chunkM3FJ3QXG_cjs.debug(`Transform file with reflection=${reflection.mode} took ${Date.now() - start}ms (${this.getModuleType()}) ${sourceFile.fileName} via config ${reflection.tsConfigPath || "none"}.`);
897
+ return sourceFile;
898
+ }
899
+ if (!sourceFile.locals) {
900
+ ts2__default.default.bindSourceFile(sourceFile, this.compilerOptions);
901
+ }
902
+ if (sourceFile.kind !== SyntaxKind2.SourceFile) {
903
+ if ("undefined" === typeof chunkM3FJ3QXG_cjs.__require) {
904
+ throw new Error(`Invalid TypeScript library imported. SyntaxKind different ${sourceFile.kind} !== ${SyntaxKind2.SourceFile}.`);
905
+ }
906
+ const path = chunkM3FJ3QXG_cjs.__require.resolve("typescript");
907
+ throw new Error(`Invalid TypeScript library imported. SyntaxKind different ${sourceFile.kind} !== ${SyntaxKind2.SourceFile}. typescript package path: ${path}`);
908
+ }
909
+ const visitor = /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((node) => {
910
+ node = visitEachChild(node, visitor, this.context);
911
+ if (isInterfaceDeclaration(node) || isTypeAliasDeclaration(node) || isEnumDeclaration(node)) {
912
+ if (this.isWithReflection(sourceFile, node)) {
913
+ this.compileDeclarations.set(node, {
914
+ name: node.name,
915
+ sourceFile: this.sourceFile
916
+ });
917
+ }
918
+ }
919
+ if (isMethodDeclaration(node) && node.parent && node.body && isObjectLiteralExpression(node.parent)) {
920
+ let valid = true;
921
+ if (node.name.kind === SyntaxKind2.Identifier && getIdentifierName(node.name) === "default") valid = false;
922
+ if (valid) {
923
+ const method = this.decorateFunctionExpression(this.f.createFunctionExpression(node.modifiers, node.asteriskToken, isIdentifier2(node.name) ? node.name : void 0, node.typeParameters, node.parameters, node.type, node.body));
924
+ node = this.f.createPropertyAssignment(node.name, method);
925
+ }
926
+ }
927
+ if (isClassDeclaration(node)) {
928
+ return this.decorateClass(sourceFile, node);
929
+ } else if (isParameter(node) && node.parent && node.type) {
930
+ const typeParameters = isConstructorDeclaration(node.parent) ? node.parent.parent.typeParameters : node.parent.typeParameters;
931
+ if (!typeParameters) return node;
932
+ const receiveType = getReceiveTypeParameter(node.type);
933
+ if (receiveType && receiveType.typeArguments) {
934
+ const first = receiveType.typeArguments[0];
935
+ if (first && isTypeReferenceNode(first) && isIdentifier2(first.typeName)) {
936
+ const name = getIdentifierName(first.typeName);
937
+ const index = typeParameters.findIndex((v) => getIdentifierName(v.name) === name);
938
+ let container = this.f.createIdentifier("globalThis");
939
+ if (isArrowFunction2(node.parent)) {
940
+ const next = this.getArrowFunction\u03A9PropertyAccessIdentifier(node.parent);
941
+ if (!next) return node;
942
+ container = next;
943
+ } else if ((isFunctionDeclaration(node.parent) || isFunctionExpression(node.parent)) && node.parent.name) {
944
+ container = node.parent.name;
945
+ } else if (isMethodDeclaration(node.parent) && isIdentifier2(node.parent.name)) {
946
+ container = this.f.createPropertyAccessExpression(this.f.createIdentifier("this"), node.parent.name);
947
+ } else if (isConstructorDeclaration(node.parent)) {
948
+ container = this.f.createPropertyAccessExpression(this.f.createIdentifier("this"), "constructor");
949
+ }
950
+ return this.f.updateParameterDeclaration(node, node.modifiers, node.dotDotDotToken, node.name, node.questionToken, receiveType, this.f.createElementAccessChain(this.f.createPropertyAccessExpression(container, this.f.createIdentifier("\u03A9")), this.f.createToken(SyntaxKind2.QuestionDotToken), this.f.createNumericLiteral(index)));
951
+ }
952
+ }
953
+ } else if (isClassExpression(node)) {
954
+ return this.decorateClass(sourceFile, node);
955
+ } else if (isFunctionExpression(node)) {
956
+ return this.decorateFunctionExpression(this.injectReset\u03A9(node));
957
+ } else if (isFunctionDeclaration(node)) {
958
+ return this.decorateFunctionDeclaration(this.injectReset\u03A9(node));
959
+ } else if (isMethodDeclaration(node) || isConstructorDeclaration(node)) {
960
+ return this.injectReset\u03A9(node);
961
+ } else if (isArrowFunction2(node)) {
962
+ return this.decorateArrowFunction(this.injectReset\u03A9(node));
963
+ } else if ((isNewExpression(node) || isCallExpression(node)) && node.typeArguments && node.typeArguments.length > 0) {
964
+ if (isCallExpression(node)) {
965
+ const autoTypeFunctions = [
966
+ "valuesOf",
967
+ "propertiesOf",
968
+ "typeOf"
969
+ ];
970
+ if (isIdentifier2(node.expression) && autoTypeFunctions.includes(getIdentifierName(node.expression))) {
971
+ const args = [
972
+ ...node.arguments
973
+ ];
974
+ if (!args.length) {
975
+ args.push(this.f.createArrayLiteralExpression());
976
+ }
977
+ const type = this.getTypeOfType(node.typeArguments[0]);
978
+ if (!type) return node;
979
+ args.push(type);
980
+ return this.f.updateCallExpression(node, node.expression, node.typeArguments, this.f.createNodeArray(args));
981
+ }
982
+ }
983
+ const expressionToCheck = getAssignTypeExpression(node.expression) || node.expression;
984
+ if (isArrowFunction2(expressionToCheck)) {
985
+ return node;
986
+ }
987
+ const typeExpressions = [];
988
+ for (const a of node.typeArguments) {
989
+ const type = this.getTypeOfType(a);
990
+ typeExpressions.push(type || this.f.createIdentifier("undefined"));
991
+ }
992
+ let container = this.f.createIdentifier("globalThis");
993
+ if (isIdentifier2(node.expression)) {
994
+ container = node.expression;
995
+ } else if (isPropertyAccessExpression(node.expression)) {
996
+ container = node.expression;
997
+ }
998
+ const assignQ = this.f.createBinaryExpression(this.f.createPropertyAccessExpression(container, "\u03A9"), this.f.createToken(SyntaxKind2.EqualsToken), this.f.createArrayLiteralExpression(typeExpressions));
999
+ const update = isNewExpression(node) ? this.f.updateNewExpression : this.f.updateCallExpression;
1000
+ if (isPropertyAccessExpression(node.expression)) {
1001
+ if (isCallExpression(node.expression.expression)) {
1002
+ const r = this.getTempResultIdentifier();
1003
+ const assignQ2 = this.f.createBinaryExpression(this.f.createPropertyAccessExpression(this.f.createPropertyAccessExpression(r, node.expression.name), "\u03A9"), this.f.createToken(SyntaxKind2.EqualsToken), this.f.createArrayLiteralExpression(typeExpressions));
1004
+ return update(node, this.f.createPropertyAccessExpression(this.f.createParenthesizedExpression(this.f.createBinaryExpression(this.f.createBinaryExpression(this.f.createBinaryExpression(r, this.f.createToken(ts2__default.default.SyntaxKind.EqualsToken), node.expression.expression), this.f.createToken(ts2__default.default.SyntaxKind.CommaToken), assignQ2), this.f.createToken(ts2__default.default.SyntaxKind.CommaToken), r)), node.expression.name), node.typeArguments, node.arguments);
1005
+ } else if (isParenthesizedExpression(node.expression.expression)) {
1006
+ const r = this.getTempResultIdentifier();
1007
+ const assignQ2 = this.f.createBinaryExpression(this.f.createPropertyAccessExpression(this.f.createPropertyAccessExpression(r, node.expression.name), "\u03A9"), this.f.createToken(SyntaxKind2.EqualsToken), this.f.createArrayLiteralExpression(typeExpressions));
1008
+ const updatedNode = update(node, this.f.updatePropertyAccessExpression(node.expression, this.f.updateParenthesizedExpression(node.expression.expression, this.f.createBinaryExpression(this.f.createBinaryExpression(this.f.createBinaryExpression(r, this.f.createToken(SyntaxKind2.EqualsToken), node.expression.expression.expression), this.f.createToken(SyntaxKind2.CommaToken), assignQ2), this.f.createToken(SyntaxKind2.CommaToken), r)), node.expression.name), node.typeArguments, node.arguments);
1009
+ return this.f.createParenthesizedExpression(updatedNode);
1010
+ } else ;
1011
+ }
1012
+ return this.f.createParenthesizedExpression(this.f.createBinaryExpression(assignQ, this.f.createToken(SyntaxKind2.CommaToken), node));
1013
+ }
1014
+ return node;
1015
+ }, "visitor");
1016
+ this.sourceFile = visitNode(this.sourceFile, visitor);
1017
+ const newTopStatements = [];
1018
+ while (true) {
1019
+ let allCompiled = true;
1020
+ for (const d of this.compileDeclarations.values()) {
1021
+ if (d.compiled) continue;
1022
+ allCompiled = false;
1023
+ break;
1024
+ }
1025
+ if (this.embedDeclarations.size === 0 && allCompiled) break;
1026
+ for (const [node, d] of [
1027
+ ...this.compileDeclarations.entries()
1028
+ ]) {
1029
+ if (d.compiled) continue;
1030
+ d.compiled = this.createProgramVarFromNode(node, d.name, this.sourceFile);
1031
+ }
1032
+ if (this.embedDeclarations.size) {
1033
+ for (const node of this.embedDeclarations.keys()) {
1034
+ this.compiledDeclarations.add(node);
1035
+ }
1036
+ const entries = Array.from(this.embedDeclarations.entries());
1037
+ this.embedDeclarations.clear();
1038
+ for (const [node, d] of entries) {
1039
+ newTopStatements.push(...this.createProgramVarFromNode(node, d.name, d.sourceFile));
1040
+ }
1041
+ }
1042
+ }
1043
+ const compileDeclarations = /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((node) => {
1044
+ node = visitEachChild(node, compileDeclarations, this.context);
1045
+ if (isTypeAliasDeclaration(node) || isInterfaceDeclaration(node) || isEnumDeclaration(node)) {
1046
+ const d = this.compileDeclarations.get(node);
1047
+ if (!d) {
1048
+ return node;
1049
+ }
1050
+ this.compileDeclarations.delete(node);
1051
+ this.compiledDeclarations.add(node);
1052
+ if (d.compiled) {
1053
+ return [
1054
+ ...d.compiled,
1055
+ node
1056
+ ];
1057
+ }
1058
+ }
1059
+ return node;
1060
+ }, "compileDeclarations");
1061
+ this.sourceFile = visitNode(this.sourceFile, compileDeclarations);
1062
+ if (this.addImports.length) {
1063
+ const handledIdentifier = [];
1064
+ for (const imp of this.addImports) {
1065
+ if (handledIdentifier.includes(getIdentifierName(imp.identifier))) continue;
1066
+ handledIdentifier.push(getIdentifierName(imp.identifier));
1067
+ if (this.getModuleType() === "cjs") {
1068
+ const test = this.f.createIdentifier(getIdentifierName(imp.identifier));
1069
+ const variable = this.f.createVariableStatement(void 0, this.f.createVariableDeclarationList([
1070
+ this.f.createVariableDeclaration(this.f.createObjectBindingPattern([
1071
+ this.f.createBindingElement(void 0, void 0, test)
1072
+ ]), void 0, void 0, this.f.createCallExpression(this.f.createIdentifier("require"), void 0, [
1073
+ imp.from
1074
+ ]))
1075
+ ], NodeFlags2.Const));
1076
+ const typeDeclWithComment = addSyntheticLeadingComment(variable, SyntaxKind2.MultiLineCommentTrivia, "@ts-ignore", true);
1077
+ newTopStatements.push(typeDeclWithComment);
1078
+ } else {
1079
+ const specifier = this.f.createImportSpecifier(false, void 0, imp.identifier);
1080
+ const namedImports = this.f.createNamedImports([
1081
+ specifier
1082
+ ]);
1083
+ const importStatement = this.f.createImportDeclaration(void 0, this.f.createImportClause(false, void 0, namedImports), imp.from);
1084
+ const typeDeclWithComment = addSyntheticLeadingComment(importStatement, SyntaxKind2.MultiLineCommentTrivia, "@ts-ignore", true);
1085
+ newTopStatements.push(typeDeclWithComment);
1086
+ }
1087
+ }
1088
+ }
1089
+ if (this.embedAssignType) {
1090
+ const assignType = this.f.createFunctionDeclaration(void 0, void 0, this.f.createIdentifier("__assignType"), void 0, [
1091
+ this.f.createParameterDeclaration(void 0, void 0, this.f.createIdentifier("fn"), void 0, void 0, void 0),
1092
+ this.f.createParameterDeclaration(void 0, void 0, this.f.createIdentifier("args"), void 0, void 0, void 0)
1093
+ ], void 0, this.f.createBlock([
1094
+ this.f.createExpressionStatement(this.f.createBinaryExpression(this.f.createPropertyAccessExpression(this.f.createIdentifier("fn"), this.f.createIdentifier("__type")), this.f.createToken(SyntaxKind2.EqualsToken), this.f.createIdentifier("args"))),
1095
+ this.f.createReturnStatement(this.f.createIdentifier("fn"))
1096
+ ], true));
1097
+ newTopStatements.push(assignType);
1098
+ }
1099
+ if (this.tempResultIdentifier) {
1100
+ newTopStatements.push(this.f.createVariableStatement(void 0, this.f.createVariableDeclarationList([
1101
+ this.f.createVariableDeclaration(this.tempResultIdentifier, void 0, void 0, void 0)
1102
+ ], ts2__default.default.NodeFlags.None)));
1103
+ }
1104
+ if (newTopStatements.length) {
1105
+ const indexOfFirstLiteralExpression = this.sourceFile.statements.findIndex((v) => isExpressionStatement(v) && isStringLiteral2(v.expression));
1106
+ const newStatements = indexOfFirstLiteralExpression === -1 ? [
1107
+ ...newTopStatements,
1108
+ ...this.sourceFile.statements
1109
+ ] : [
1110
+ ...this.sourceFile.statements.slice(0, indexOfFirstLiteralExpression + 1),
1111
+ ...newTopStatements,
1112
+ ...this.sourceFile.statements.slice(indexOfFirstLiteralExpression + 1)
1113
+ ];
1114
+ this.sourceFile = this.f.updateSourceFile(this.sourceFile, newStatements);
1115
+ }
1116
+ const took = Date.now() - start;
1117
+ chunkM3FJ3QXG_cjs.debug(`Transform file with reflection=${reflection.mode} took ${took}ms (${this.getModuleType()}) ${sourceFile.fileName} via config ${reflection.tsConfigPath || "none"}.`);
1118
+ this.sourceFile.deepkitTransformed = true;
1119
+ return this.sourceFile;
1120
+ }
1121
+ getModuleType() {
1122
+ if (this.compilerOptions.module === ts2__default.default.ModuleKind.Node16 || this.compilerOptions.module === ts2__default.default.ModuleKind.NodeNext) {
1123
+ if (this.sourceFile.impliedNodeFormat === ts2__default.default.ModuleKind.ESNext) {
1124
+ return "esm";
1125
+ }
1126
+ return "cjs";
1127
+ }
1128
+ return this.compilerOptions.module === ts2__default.default.ModuleKind.CommonJS ? "cjs" : "esm";
1129
+ }
1130
+ getArrowFunction\u03A9PropertyAccessIdentifier(node) {
1131
+ let { parent } = node.original || node;
1132
+ if (isVariableDeclaration(parent) && isIdentifier2(parent.name)) {
1133
+ return parent.name;
1134
+ } else if (isPropertyAssignment(parent) && isIdentifier2(parent.name)) {
1135
+ const names = [];
1136
+ while (parent) {
1137
+ if (isObjectLiteralExpression(parent)) {
1138
+ parent = parent.parent;
1139
+ } else if (isVariableDeclaration(parent)) {
1140
+ names.unshift(getIdentifierName(parent.name));
1141
+ break;
1142
+ } else if (isIdentifier2(parent.name)) {
1143
+ names.unshift(getIdentifierName(parent.name));
1144
+ parent = parent.parent;
1145
+ } else {
1146
+ return;
1147
+ }
1148
+ }
1149
+ return this.f.createIdentifier(names.join("."));
1150
+ }
1151
+ return;
1152
+ }
1153
+ injectReset\u03A9(node) {
1154
+ let hasReceiveType = false;
1155
+ for (const param of node.parameters) {
1156
+ if (param.type && getReceiveTypeParameter(param.type)) hasReceiveType = true;
1157
+ }
1158
+ if (!hasReceiveType) return node;
1159
+ let container = this.f.createIdentifier("globalThis");
1160
+ if (isArrowFunction2(node)) {
1161
+ const next = this.getArrowFunction\u03A9PropertyAccessIdentifier(node);
1162
+ if (!next) return node;
1163
+ container = next;
1164
+ } else if ((isFunctionDeclaration(node) || isFunctionExpression(node)) && node.name) {
1165
+ container = node.name;
1166
+ } else if (isMethodDeclaration(node) && isIdentifier2(node.name)) {
1167
+ container = this.f.createPropertyAccessExpression(this.f.createIdentifier("this"), node.name);
1168
+ } else if (isConstructorDeclaration(node)) {
1169
+ container = this.f.createPropertyAccessExpression(this.f.createIdentifier("this"), "constructor");
1170
+ }
1171
+ const reset = this.f.createExpressionStatement(this.f.createBinaryExpression(this.f.createPropertyAccessExpression(container, this.f.createIdentifier("\u03A9")), this.f.createToken(ts2__default.default.SyntaxKind.EqualsToken), this.f.createIdentifier("undefined")));
1172
+ let body = node.body && isBlock(node.body) ? node.body : void 0;
1173
+ let bodyStatements = node.body && isBlock(node.body) ? [
1174
+ ...node.body.statements
1175
+ ] : [];
1176
+ if (node.body) {
1177
+ if (isExpression(node.body)) {
1178
+ bodyStatements = [
1179
+ this.f.createReturnStatement(node.body)
1180
+ ];
1181
+ }
1182
+ body = this.f.updateBlock(node.body, [
1183
+ reset,
1184
+ ...bodyStatements
1185
+ ]);
1186
+ }
1187
+ if (isArrowFunction2(node)) {
1188
+ return this.f.updateArrowFunction(node, node.modifiers, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, body);
1189
+ } else if (isFunctionDeclaration(node)) {
1190
+ return this.f.updateFunctionDeclaration(node, node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, body);
1191
+ } else if (isFunctionExpression(node)) {
1192
+ return this.f.updateFunctionExpression(node, node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, body || node.body);
1193
+ } else if (isMethodDeclaration(node)) {
1194
+ return this.f.updateMethodDeclaration(node, node.modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, body);
1195
+ } else if (isConstructorDeclaration(node)) {
1196
+ return this.f.updateConstructorDeclaration(node, node.modifiers, node.parameters, body);
1197
+ }
1198
+ return node;
1199
+ }
1200
+ createProgramVarFromNode(node, name, sourceFile) {
1201
+ const typeProgram = new CompilerProgram(node, sourceFile);
1202
+ if ((isTypeAliasDeclaration(node) || isInterfaceDeclaration(node)) && node.typeParameters) {
1203
+ for (const param of node.typeParameters) {
1204
+ if (param.default) {
1205
+ this.extractPackStructOfType(param.default, typeProgram);
1206
+ }
1207
+ typeProgram.pushTemplateParameter(getIdentifierName(param.name), !!param.default);
1208
+ }
1209
+ }
1210
+ this.extractPackStructOfType(node, typeProgram);
1211
+ if (isTypeAliasDeclaration(node) || isInterfaceDeclaration(node) || isClassDeclaration(node) || isClassExpression(node)) {
1212
+ typeProgram.pushOp(ReflectionOp.nominal);
1213
+ }
1214
+ const typeProgramExpression = this.packOpsAndStack(typeProgram);
1215
+ const variable = this.f.createVariableStatement([], this.f.createVariableDeclarationList([
1216
+ this.f.createVariableDeclaration(this.getDeclarationVariableName(name), void 0, void 0, typeProgramExpression)
1217
+ ], NodeFlags2.Const));
1218
+ if (hasModifier(node, SyntaxKind2.ExportKeyword)) {
1219
+ const exportNode = this.f.createExportDeclaration(void 0, false, this.f.createNamedExports([
1220
+ this.f.createExportSpecifier(false, this.getDeclarationVariableName(name), this.getDeclarationVariableName(name))
1221
+ ]));
1222
+ return [
1223
+ variable,
1224
+ exportNode
1225
+ ];
1226
+ }
1227
+ return [
1228
+ variable
1229
+ ];
1230
+ }
1231
+ extractPackStructOfExpression(node, program) {
1232
+ switch (node.kind) {
1233
+ case SyntaxKind2.StringLiteral: {
1234
+ program.pushOp(ReflectionOp.string);
1235
+ return;
1236
+ }
1237
+ case SyntaxKind2.NumericLiteral: {
1238
+ program.pushOp(ReflectionOp.number);
1239
+ return;
1240
+ }
1241
+ case SyntaxKind2.FalseKeyword:
1242
+ case SyntaxKind2.TrueKeyword: {
1243
+ program.pushOp(ReflectionOp.boolean);
1244
+ return;
1245
+ }
1246
+ case SyntaxKind2.BigIntLiteral: {
1247
+ program.pushOp(ReflectionOp.bigint);
1248
+ return;
1249
+ }
1250
+ //Symbol() is a function call, so we need to check for that
1251
+ case SyntaxKind2.CallExpression: {
1252
+ const call = node;
1253
+ if (isIdentifier2(call.expression) && getIdentifierName(call.expression) === "Symbol") {
1254
+ program.pushOp(ReflectionOp.symbol);
1255
+ return;
1256
+ }
1257
+ break;
1258
+ }
1259
+ //new Date()
1260
+ case SyntaxKind2.NewExpression: {
1261
+ const call = node;
1262
+ if (isIdentifier2(call.expression)) {
1263
+ const map = {
1264
+ "Date": ReflectionOp.date,
1265
+ "RegExp": ReflectionOp.regexp,
1266
+ "Uint8Array": ReflectionOp.uint8Array,
1267
+ "Uint8ClampedArray": ReflectionOp.uint8ClampedArray,
1268
+ "Uint16Array": ReflectionOp.uint16Array,
1269
+ "Uint32Array": ReflectionOp.uint32Array,
1270
+ "Int8Array": ReflectionOp.int8Array,
1271
+ "Int16Array": ReflectionOp.int16Array,
1272
+ "Int32Array": ReflectionOp.int32Array,
1273
+ "Float32Array": ReflectionOp.float32Array,
1274
+ "Float64Array": ReflectionOp.float64Array,
1275
+ "ArrayBuffer": ReflectionOp.arrayBuffer
1276
+ };
1277
+ const op = map[getIdentifierName(call.expression)];
1278
+ if (op) {
1279
+ program.pushOp(op);
1280
+ return;
1281
+ }
1282
+ }
1283
+ break;
1284
+ }
1285
+ }
1286
+ program.pushOp(ReflectionOp.never);
1287
+ }
1288
+ parseDefaultValue(kind, defaultValue) {
1289
+ switch (kind) {
1290
+ case SyntaxKind2.NumberKeyword: {
1291
+ return Number.isInteger(Number.parseFloat(defaultValue)) ? Number.parseInt(defaultValue) : Number.parseFloat(defaultValue);
1292
+ }
1293
+ case SyntaxKind2.BooleanKeyword: {
1294
+ return Boolean(defaultValue?.trim());
1295
+ }
1296
+ case SyntaxKind2.BigIntKeyword: {
1297
+ return Number.parseInt(defaultValue);
1298
+ }
1299
+ case SyntaxKind2.ObjectKeyword: {
1300
+ return JSON.parse(defaultValue);
1301
+ }
1302
+ case SyntaxKind2.NullKeyword: {
1303
+ return null;
1304
+ }
1305
+ case SyntaxKind2.TrueKeyword: {
1306
+ return true;
1307
+ }
1308
+ case SyntaxKind2.FalseKeyword: {
1309
+ return false;
1310
+ }
1311
+ case SyntaxKind2.UndefinedKeyword: {
1312
+ return void 0;
1313
+ }
1314
+ case SyntaxKind2.StringLiteral:
1315
+ case SyntaxKind2.StringKeyword:
1316
+ default: {
1317
+ if (defaultValue?.trim().toLowerCase() === "false") {
1318
+ return false;
1319
+ } else if (defaultValue?.trim().toLowerCase() === "true") {
1320
+ return true;
1321
+ }
1322
+ return defaultValue;
1323
+ }
1324
+ }
1325
+ }
1326
+ parseTagReflection(node) {
1327
+ const tags = {};
1328
+ tags.hidden = extractJSDocBoolean(this.sourceFile, node, "hidden");
1329
+ tags.ignore = extractJSDocBoolean(this.sourceFile, node, "ignore");
1330
+ tags.internal = extractJSDocBoolean(this.sourceFile, node, "internal");
1331
+ tags.alias = extractJSDocArray(this.sourceFile, node, "alias");
1332
+ tags.permission = extractJSDocArray(this.sourceFile, node, "permission");
1333
+ tags.domain = extractJSDocAttribute(this.sourceFile, node, "domain");
1334
+ if (this.getReflectionConfig(this.sourceFile).level === "verbose") {
1335
+ tags.title = extractJSDocAttribute(this.sourceFile, node, "title");
1336
+ }
1337
+ return tags;
1338
+ }
1339
+ extractTagReflections(program, node) {
1340
+ if (!node) return;
1341
+ const tags = this.parseTagReflection(node);
1342
+ if (Object.entries(tags).filter(([, value]) => value !== void 0 && (!Array.isArray(value) || value.length > 0) && (typeof value !== "string" || value?.trim().replace(/^"/gm, "").replace(/"$/gm, ""))).length > 0) {
1343
+ program.pushOp(ReflectionOp.tags, program.findOrAddStackEntry(this.f.createObjectLiteralExpression(this.f.createNodeArray(Object.entries(tags).filter(([, value]) => value !== void 0 && (!Array.isArray(value) || value.length > 0) && (typeof value !== "string" || value.trim().replace(/^"/gm, "").replace(/"$/gm, ""))).map(([key, value]) => {
1344
+ return this.f.createPropertyAssignment(key, Array.isArray(value) ? this.f.createArrayLiteralExpression(value.map((item) => this.valueToExpression(item))) : typeof value === "boolean" ? value ? this.f.createTrue() : this.f.createFalse() : this.valueToExpression(value));
1345
+ })))));
1346
+ }
1347
+ }
1348
+ extractDefaultValueReflection(program, node) {
1349
+ if (!node) return;
1350
+ let defaultValue = extractJSDocAttribute(this.sourceFile, node, "defaultValue");
1351
+ if (!defaultValue) {
1352
+ defaultValue = extractJSDocAttribute(this.sourceFile, node, "default");
1353
+ }
1354
+ if (defaultValue) {
1355
+ program.pushOp(ReflectionOp.defaultValue, program.findOrAddStackEntry(this.parseDefaultValue((node.kind === SyntaxKind2.ClassDeclaration || node.kind === SyntaxKind2.ClassExpression ? node?.name?.parent?.kind : node.kind === SyntaxKind2.PropertySignature || node.kind === SyntaxKind2.PropertyDeclaration ? node.type?.kind : node.kind) || SyntaxKind2.StringKeyword, defaultValue.trim().replace(/^"/gm, "").replace(/"$/gm, ""))));
1356
+ }
1357
+ }
1358
+ extractDescriptionReflection(program, node) {
1359
+ if (!node || this.getReflectionConfig(this.sourceFile).level !== "verbose") return;
1360
+ const description = extractJSDocAttribute(this.sourceFile, node, "description");
1361
+ if (description) {
1362
+ program.pushOp(ReflectionOp.description, program.findOrAddStackEntry(description.trim().replace(/^"/gm, "").replace(/"$/gm, "")));
1363
+ }
1364
+ }
1365
+ extractPackStructOfType(node, program) {
1366
+ if (isParenthesizedTypeNode(node)) return this.extractPackStructOfType(node.type, program);
1367
+ switch (node.kind) {
1368
+ case SyntaxKind2.StringKeyword: {
1369
+ program.pushOp(ReflectionOp.string);
1370
+ break;
1371
+ }
1372
+ case SyntaxKind2.NumberKeyword: {
1373
+ program.pushOp(ReflectionOp.number);
1374
+ break;
1375
+ }
1376
+ case SyntaxKind2.BooleanKeyword: {
1377
+ program.pushOp(ReflectionOp.boolean);
1378
+ break;
1379
+ }
1380
+ case SyntaxKind2.BigIntKeyword: {
1381
+ program.pushOp(ReflectionOp.bigint);
1382
+ break;
1383
+ }
1384
+ case SyntaxKind2.VoidKeyword: {
1385
+ program.pushOp(ReflectionOp.void);
1386
+ break;
1387
+ }
1388
+ case SyntaxKind2.UnknownKeyword: {
1389
+ program.pushOp(ReflectionOp.unknown);
1390
+ break;
1391
+ }
1392
+ case SyntaxKind2.ObjectKeyword: {
1393
+ program.pushOp(ReflectionOp.object);
1394
+ break;
1395
+ }
1396
+ case SyntaxKind2.SymbolKeyword: {
1397
+ program.pushOp(ReflectionOp.symbol);
1398
+ break;
1399
+ }
1400
+ case SyntaxKind2.NullKeyword: {
1401
+ program.pushOp(ReflectionOp.null);
1402
+ break;
1403
+ }
1404
+ case SyntaxKind2.NeverKeyword: {
1405
+ program.pushOp(ReflectionOp.never);
1406
+ break;
1407
+ }
1408
+ case SyntaxKind2.AnyKeyword: {
1409
+ program.pushOp(ReflectionOp.any);
1410
+ break;
1411
+ }
1412
+ case SyntaxKind2.UndefinedKeyword: {
1413
+ program.pushOp(ReflectionOp.undefined);
1414
+ break;
1415
+ }
1416
+ case SyntaxKind2.TrueKeyword: {
1417
+ program.pushOp(ReflectionOp.literal, program.pushStack(this.f.createTrue()));
1418
+ break;
1419
+ }
1420
+ case SyntaxKind2.FalseKeyword: {
1421
+ program.pushOp(ReflectionOp.literal, program.pushStack(this.f.createFalse()));
1422
+ break;
1423
+ }
1424
+ case SyntaxKind2.ClassDeclaration:
1425
+ case SyntaxKind2.ClassExpression: {
1426
+ const narrowed = node;
1427
+ if (node) {
1428
+ const members = [];
1429
+ if (narrowed.typeParameters) {
1430
+ for (const typeParameter of narrowed.typeParameters) {
1431
+ const name = getNameAsString(typeParameter.name);
1432
+ if (typeParameter.default) {
1433
+ this.extractPackStructOfType(typeParameter.default, program);
1434
+ }
1435
+ program.pushTemplateParameter(name, !!typeParameter.default);
1436
+ }
1437
+ }
1438
+ if (narrowed.heritageClauses) {
1439
+ for (const heritage of narrowed.heritageClauses) {
1440
+ if (heritage.token === SyntaxKind2.ExtendsKeyword) {
1441
+ for (const extendType of heritage.types) {
1442
+ program.pushFrame();
1443
+ if (extendType.typeArguments) {
1444
+ for (const typeArgument of extendType.typeArguments) {
1445
+ this.extractPackStructOfType(typeArgument, program);
1446
+ }
1447
+ }
1448
+ const index = program.pushStack(this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, this.nodeConverter.toExpression(extendType.expression)));
1449
+ program.pushOp(ReflectionOp.classReference, index);
1450
+ program.popFrameImplicit();
1451
+ }
1452
+ }
1453
+ }
1454
+ }
1455
+ for (const member of narrowed.members) {
1456
+ const name = getNameAsString(member.name);
1457
+ if (name) {
1458
+ const has = members.some((v) => getNameAsString(v.name) === name);
1459
+ if (has) continue;
1460
+ }
1461
+ members.push(member);
1462
+ this.extractPackStructOfType(member, program);
1463
+ }
1464
+ program.pushOp(ReflectionOp.class);
1465
+ if (narrowed.heritageClauses) {
1466
+ for (const heritageClause of narrowed.heritageClauses) {
1467
+ if (heritageClause.token === SyntaxKind2.ExtendsKeyword) {
1468
+ const first = heritageClause.types[0];
1469
+ if (isExpressionWithTypeArguments(first) && first.typeArguments) {
1470
+ for (const typeArgument of first.typeArguments) {
1471
+ this.extractPackStructOfType(typeArgument, program);
1472
+ }
1473
+ program.pushOp(ReflectionOp.classExtends, first.typeArguments.length);
1474
+ }
1475
+ } else if (heritageClause.token === SyntaxKind2.ImplementsKeyword) {
1476
+ for (const type of heritageClause.types) {
1477
+ this.extractPackStructOfTypeReference(type, program);
1478
+ }
1479
+ program.pushOp(ReflectionOp.implements, heritageClause.types.length);
1480
+ }
1481
+ }
1482
+ }
1483
+ if (narrowed.name) this.resolveTypeName(getIdentifierName(narrowed.name), program);
1484
+ this.extractDefaultValueReflection(program, narrowed.name?.parent);
1485
+ this.extractDescriptionReflection(program, narrowed.name?.parent);
1486
+ this.extractTagReflections(program, narrowed.name?.parent);
1487
+ }
1488
+ break;
1489
+ }
1490
+ case SyntaxKind2.IntersectionType: {
1491
+ const narrowed = node;
1492
+ program.pushFrame();
1493
+ for (const type of narrowed.types) {
1494
+ this.extractPackStructOfType(type, program);
1495
+ }
1496
+ program.pushOp(ReflectionOp.intersection);
1497
+ program.popFrameImplicit();
1498
+ break;
1499
+ }
1500
+ case SyntaxKind2.MappedType: {
1501
+ const narrowed = node;
1502
+ program.pushFrame();
1503
+ program.pushVariable(getIdentifierName(narrowed.typeParameter.name));
1504
+ const constraint = getEffectiveConstraintOfTypeParameter(narrowed.typeParameter);
1505
+ if (constraint) {
1506
+ this.extractPackStructOfType(constraint, program);
1507
+ } else {
1508
+ program.pushOp(ReflectionOp.never);
1509
+ }
1510
+ let modifier = 0;
1511
+ if (narrowed.questionToken) {
1512
+ if (narrowed.questionToken.kind === SyntaxKind2.QuestionToken) {
1513
+ modifier |= 1;
1514
+ }
1515
+ if (narrowed.questionToken.kind === SyntaxKind2.MinusToken) {
1516
+ modifier |= 2;
1517
+ }
1518
+ }
1519
+ if (narrowed.readonlyToken) {
1520
+ if (narrowed.readonlyToken.kind === SyntaxKind2.ReadonlyKeyword) {
1521
+ modifier |= 4;
1522
+ }
1523
+ if (narrowed.readonlyToken.kind === SyntaxKind2.MinusToken) {
1524
+ modifier |= 8;
1525
+ }
1526
+ }
1527
+ program.pushCoRoutine();
1528
+ if (narrowed.nameType) program.pushFrame();
1529
+ if (narrowed.type) {
1530
+ this.extractPackStructOfType(narrowed.type, program);
1531
+ } else {
1532
+ program.pushOp(ReflectionOp.never);
1533
+ }
1534
+ if (narrowed.nameType) {
1535
+ this.extractPackStructOfType(narrowed.nameType, program);
1536
+ program.pushOp(ReflectionOp.tuple);
1537
+ program.popFrameImplicit();
1538
+ }
1539
+ const coRoutineIndex = program.popCoRoutine();
1540
+ if (narrowed.nameType) {
1541
+ program.pushOp(ReflectionOp.mappedType2, coRoutineIndex, modifier);
1542
+ } else {
1543
+ program.pushOp(ReflectionOp.mappedType, coRoutineIndex, modifier);
1544
+ }
1545
+ program.popFrameImplicit();
1546
+ break;
1547
+ }
1548
+ case SyntaxKind2.TypeAliasDeclaration: {
1549
+ let narrowed = node;
1550
+ if (program.sourceFile && getNameAsString(narrowed.name) === "TypeAnnotation") {
1551
+ const attribute = extractJSDocAttribute(program.sourceFile, narrowed, "intrinsic");
1552
+ if (attribute !== void 0) {
1553
+ narrowed = this.intrinsicMetaDeclaration;
1554
+ }
1555
+ }
1556
+ this.extractPackStructOfType(narrowed.type, program);
1557
+ if (narrowed.name) this.resolveTypeName(getIdentifierName(narrowed.name), program);
1558
+ break;
1559
+ }
1560
+ case SyntaxKind2.TypeLiteral:
1561
+ case SyntaxKind2.InterfaceDeclaration: {
1562
+ const narrowed = node;
1563
+ let descriptionNode = narrowed;
1564
+ program.pushFrame();
1565
+ if (isInterfaceDeclaration(narrowed) && narrowed.heritageClauses) {
1566
+ for (const heritage of narrowed.heritageClauses) {
1567
+ if (heritage.token === SyntaxKind2.ExtendsKeyword) {
1568
+ for (const extendType of heritage.types) {
1569
+ this.extractPackStructOfTypeReference(extendType, program);
1570
+ }
1571
+ }
1572
+ }
1573
+ }
1574
+ for (const member of narrowed.members) {
1575
+ this.extractPackStructOfType(member, program);
1576
+ }
1577
+ program.pushOp(ReflectionOp.objectLiteral);
1578
+ if (isTypeLiteralNode(narrowed)) {
1579
+ descriptionNode = narrowed.parent;
1580
+ }
1581
+ this.extractDefaultValueReflection(program, descriptionNode);
1582
+ this.extractDescriptionReflection(program, descriptionNode);
1583
+ this.extractTagReflections(program, descriptionNode);
1584
+ if (isInterfaceDeclaration(narrowed)) {
1585
+ if (narrowed.name) this.resolveTypeName(getIdentifierName(narrowed.name), program);
1586
+ }
1587
+ program.popFrameImplicit();
1588
+ break;
1589
+ }
1590
+ case SyntaxKind2.TypeReference: {
1591
+ this.extractPackStructOfTypeReference(node, program);
1592
+ break;
1593
+ }
1594
+ case SyntaxKind2.ArrayType: {
1595
+ this.extractPackStructOfType(node.elementType, program);
1596
+ program.pushOp(ReflectionOp.array);
1597
+ break;
1598
+ }
1599
+ case SyntaxKind2.RestType: {
1600
+ let type = node.type;
1601
+ if (isArrayTypeNode(type)) {
1602
+ type = type.elementType;
1603
+ }
1604
+ this.extractPackStructOfType(type, program);
1605
+ program.pushOp(ReflectionOp.rest);
1606
+ break;
1607
+ }
1608
+ case SyntaxKind2.TupleType: {
1609
+ program.pushFrame();
1610
+ for (const element of node.elements) {
1611
+ if (isOptionalTypeNode(element)) {
1612
+ this.extractPackStructOfType(element.type, program);
1613
+ program.pushOp(ReflectionOp.tupleMember);
1614
+ program.pushOp(ReflectionOp.optional);
1615
+ } else if (isNamedTupleMember(element)) {
1616
+ if (element.dotDotDotToken) {
1617
+ let type = element.type;
1618
+ if (isArrayTypeNode(type)) {
1619
+ type = type.elementType;
1620
+ }
1621
+ this.extractPackStructOfType(type, program);
1622
+ program.pushOp(ReflectionOp.rest);
1623
+ } else {
1624
+ this.extractPackStructOfType(element.type, program);
1625
+ }
1626
+ const index = program.findOrAddStackEntry(getIdentifierName(element.name));
1627
+ program.pushOp(ReflectionOp.namedTupleMember, index);
1628
+ if (element.questionToken) {
1629
+ program.pushOp(ReflectionOp.optional);
1630
+ }
1631
+ } else {
1632
+ this.extractPackStructOfType(element, program);
1633
+ }
1634
+ }
1635
+ program.pushOp(ReflectionOp.tuple);
1636
+ program.popFrameImplicit();
1637
+ break;
1638
+ }
1639
+ case SyntaxKind2.PropertySignature: {
1640
+ const narrowed = node;
1641
+ if (narrowed.type) {
1642
+ this.extractPackStructOfType(narrowed.type, program);
1643
+ const name = getPropertyName(this.f, narrowed.name);
1644
+ program.pushOp(ReflectionOp.propertySignature, program.findOrAddStackEntry(name));
1645
+ if (narrowed.questionToken) {
1646
+ program.pushOp(ReflectionOp.optional);
1647
+ }
1648
+ if (hasModifier(narrowed, SyntaxKind2.ReadonlyKeyword)) program.pushOp(ReflectionOp.readonly);
1649
+ else {
1650
+ const readonly = extractJSDocBoolean(this.sourceFile, narrowed, "readonly");
1651
+ if (readonly) {
1652
+ program.pushOp(ReflectionOp.readonly);
1653
+ }
1654
+ }
1655
+ this.extractDefaultValueReflection(program, narrowed);
1656
+ this.extractDescriptionReflection(program, narrowed);
1657
+ this.extractTagReflections(program, narrowed);
1658
+ } else {
1659
+ program.pushOp(ReflectionOp.unknown);
1660
+ }
1661
+ break;
1662
+ }
1663
+ case SyntaxKind2.PropertyDeclaration: {
1664
+ const narrowed = node;
1665
+ if (false === this.getExplicitReflectionMode(program.sourceFile, narrowed)) return;
1666
+ if (narrowed.type) {
1667
+ this.extractPackStructOfType(narrowed.type, program);
1668
+ } else if (narrowed.initializer) {
1669
+ this.extractPackStructOfExpression(narrowed.initializer, program);
1670
+ } else {
1671
+ program.pushOp(ReflectionOp.unknown);
1672
+ }
1673
+ program.pushOp(ReflectionOp.property, program.findOrAddStackEntry(getPropertyName(this.f, narrowed.name)));
1674
+ if (narrowed.questionToken) program.pushOp(ReflectionOp.optional);
1675
+ if (hasModifier(narrowed, SyntaxKind2.ReadonlyKeyword)) {
1676
+ program.pushOp(ReflectionOp.readonly);
1677
+ } else {
1678
+ const readonly = extractJSDocBoolean(this.sourceFile, narrowed, "readonly");
1679
+ if (readonly) {
1680
+ program.pushOp(ReflectionOp.readonly);
1681
+ }
1682
+ }
1683
+ if (hasModifier(narrowed, SyntaxKind2.PrivateKeyword)) program.pushOp(ReflectionOp.private);
1684
+ if (hasModifier(narrowed, SyntaxKind2.ProtectedKeyword)) program.pushOp(ReflectionOp.protected);
1685
+ if (hasModifier(narrowed, SyntaxKind2.AbstractKeyword)) program.pushOp(ReflectionOp.abstract);
1686
+ if (hasModifier(narrowed, SyntaxKind2.StaticKeyword)) program.pushOp(ReflectionOp.static);
1687
+ if (narrowed.initializer) {
1688
+ program.pushOp(ReflectionOp.defaultValue, program.findOrAddStackEntry(this.f.createFunctionExpression(void 0, void 0, void 0, void 0, void 0, void 0, this.f.createBlock([
1689
+ this.f.createReturnStatement(narrowed.initializer)
1690
+ ]))));
1691
+ } else {
1692
+ this.extractDefaultValueReflection(program, narrowed);
1693
+ }
1694
+ this.extractDescriptionReflection(program, narrowed);
1695
+ this.extractTagReflections(program, narrowed);
1696
+ break;
1697
+ }
1698
+ case SyntaxKind2.ConditionalType: {
1699
+ const narrowed = node;
1700
+ const distributiveOverIdentifier = isTypeReferenceNode(narrowed.checkType) && isIdentifier2(narrowed.checkType.typeName) ? narrowed.checkType.typeName : void 0;
1701
+ if (distributiveOverIdentifier) {
1702
+ program.pushFrame();
1703
+ this.extractPackStructOfType(narrowed.checkType, program);
1704
+ program.pushVariable(getIdentifierName(distributiveOverIdentifier));
1705
+ program.pushCoRoutine();
1706
+ }
1707
+ program.pushConditionalFrame();
1708
+ this.extractPackStructOfType(narrowed.checkType, program);
1709
+ this.extractPackStructOfType(narrowed.extendsType, program);
1710
+ program.pushOp(ReflectionOp.extends);
1711
+ program.pushCoRoutine();
1712
+ this.extractPackStructOfType(narrowed.trueType, program);
1713
+ const trueProgram = program.popCoRoutine();
1714
+ program.pushCoRoutine();
1715
+ this.extractPackStructOfType(narrowed.falseType, program);
1716
+ const falseProgram = program.popCoRoutine();
1717
+ program.pushOp(ReflectionOp.jumpCondition, trueProgram, falseProgram);
1718
+ program.moveFrame();
1719
+ if (distributiveOverIdentifier) {
1720
+ const coRoutineIndex = program.popCoRoutine();
1721
+ program.pushOp(ReflectionOp.distribute, coRoutineIndex);
1722
+ program.popFrameImplicit();
1723
+ }
1724
+ break;
1725
+ }
1726
+ case SyntaxKind2.InferType: {
1727
+ const narrowed = node;
1728
+ const frame = program.findConditionalFrame();
1729
+ if (frame) {
1730
+ const typeParameterName = getIdentifierName(narrowed.typeParameter.name);
1731
+ let variable = program.findVariable(typeParameterName);
1732
+ if (!variable) {
1733
+ program.pushVariable(typeParameterName, frame);
1734
+ variable = program.findVariable(typeParameterName);
1735
+ if (!variable) throw new Error("Could not find inserted infer variable");
1736
+ }
1737
+ program.pushOp(ReflectionOp.infer, variable.frameOffset, variable.stackIndex);
1738
+ } else {
1739
+ program.pushOp(ReflectionOp.never);
1740
+ }
1741
+ break;
1742
+ }
1743
+ case SyntaxKind2.MethodSignature:
1744
+ case SyntaxKind2.MethodDeclaration:
1745
+ case SyntaxKind2.Constructor:
1746
+ case SyntaxKind2.ArrowFunction:
1747
+ case SyntaxKind2.FunctionExpression:
1748
+ case SyntaxKind2.ConstructSignature:
1749
+ case SyntaxKind2.ConstructorType:
1750
+ case SyntaxKind2.FunctionType:
1751
+ case SyntaxKind2.CallSignature:
1752
+ case SyntaxKind2.FunctionDeclaration: {
1753
+ const narrowed = node;
1754
+ if (false === this.getExplicitReflectionMode(program.sourceFile, narrowed)) {
1755
+ program.pushOp(ReflectionOp.any);
1756
+ return;
1757
+ }
1758
+ const name = isCallSignatureDeclaration(node) ? "" : isConstructorTypeNode(narrowed) || isConstructSignatureDeclaration(node) ? "new" : isConstructorDeclaration(narrowed) ? "constructor" : getPropertyName(this.f, narrowed.name);
1759
+ if (!narrowed.type && narrowed.parameters.length === 0 && !name) return;
1760
+ program.pushFrame();
1761
+ for (let i = 0; i < narrowed.parameters.length; i++) {
1762
+ const parameter = narrowed.parameters[i];
1763
+ const parameterName = isIdentifier2(parameter.name) ? getNameAsString(parameter.name) : "param" + i;
1764
+ const type = parameter.type ? parameter.dotDotDotToken && isArrayTypeNode(parameter.type) ? parameter.type.elementType : parameter.type : void 0;
1765
+ if (type) {
1766
+ this.extractPackStructOfType(type, program);
1767
+ } else {
1768
+ program.pushOp(ReflectionOp.any);
1769
+ }
1770
+ if (parameter.dotDotDotToken) {
1771
+ program.pushOp(ReflectionOp.rest);
1772
+ }
1773
+ program.pushOp(ReflectionOp.parameter, program.findOrAddStackEntry(parameterName));
1774
+ if (parameter.questionToken) program.pushOp(ReflectionOp.optional);
1775
+ if (hasModifier(parameter, SyntaxKind2.PublicKeyword)) program.pushOp(ReflectionOp.public);
1776
+ if (hasModifier(parameter, SyntaxKind2.PrivateKeyword)) program.pushOp(ReflectionOp.private);
1777
+ if (hasModifier(parameter, SyntaxKind2.ProtectedKeyword)) program.pushOp(ReflectionOp.protected);
1778
+ if (hasModifier(parameter, SyntaxKind2.ReadonlyKeyword)) program.pushOp(ReflectionOp.readonly);
1779
+ else {
1780
+ let readonly = extractJSDocBoolean(this.sourceFile, parameter, "readonly");
1781
+ if (readonly) {
1782
+ program.pushOp(ReflectionOp.readonly);
1783
+ } else {
1784
+ readonly = extractJSDocBoolean(this.sourceFile, narrowed, "readonly");
1785
+ if (readonly) {
1786
+ program.pushOp(ReflectionOp.readonly);
1787
+ }
1788
+ }
1789
+ }
1790
+ if (parameter.initializer && parameter.type && !getReceiveTypeParameter(parameter.type)) {
1791
+ program.pushOp(ReflectionOp.defaultValue, program.findOrAddStackEntry(this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, parameter.initializer)));
1792
+ } else {
1793
+ this.extractDefaultValueReflection(program, parameter);
1794
+ }
1795
+ this.extractDescriptionReflection(program, parameter);
1796
+ }
1797
+ if (narrowed.type) {
1798
+ this.extractPackStructOfType(narrowed.type, program);
1799
+ } else {
1800
+ program.pushOp(ReflectionOp.any);
1801
+ }
1802
+ program.pushOp(isCallSignatureDeclaration(node) ? ReflectionOp.callSignature : isMethodSignature(narrowed) || isConstructSignatureDeclaration(narrowed) ? ReflectionOp.methodSignature : isMethodDeclaration(narrowed) || isConstructorDeclaration(narrowed) ? ReflectionOp.method : ReflectionOp.function, program.findOrAddStackEntry(name));
1803
+ if (isMethodDeclaration(narrowed)) {
1804
+ if (hasModifier(narrowed, SyntaxKind2.PrivateKeyword)) program.pushOp(ReflectionOp.private);
1805
+ if (hasModifier(narrowed, SyntaxKind2.ProtectedKeyword)) program.pushOp(ReflectionOp.protected);
1806
+ if (hasModifier(narrowed, SyntaxKind2.AbstractKeyword)) program.pushOp(ReflectionOp.abstract);
1807
+ if (hasModifier(narrowed, SyntaxKind2.StaticKeyword)) program.pushOp(ReflectionOp.static);
1808
+ }
1809
+ this.extractDefaultValueReflection(program, narrowed);
1810
+ this.extractDescriptionReflection(program, narrowed);
1811
+ this.extractTagReflections(program, narrowed);
1812
+ program.popFrameImplicit();
1813
+ break;
1814
+ }
1815
+ case SyntaxKind2.LiteralType: {
1816
+ const narrowed = node;
1817
+ if (narrowed.literal.kind === SyntaxKind2.NullKeyword) {
1818
+ program.pushOp(ReflectionOp.null);
1819
+ } else {
1820
+ program.pushOp(ReflectionOp.literal, program.findOrAddStackEntry(narrowed.literal));
1821
+ }
1822
+ break;
1823
+ }
1824
+ case SyntaxKind2.TemplateLiteralType: {
1825
+ const narrowed = node;
1826
+ program.pushFrame();
1827
+ if (narrowed.head.rawText) {
1828
+ program.pushOp(ReflectionOp.literal, program.findOrAddStackEntry(narrowed.head.rawText));
1829
+ }
1830
+ for (const span of narrowed.templateSpans) {
1831
+ this.extractPackStructOfType(span.type, program);
1832
+ if (span.literal.rawText) {
1833
+ program.pushOp(ReflectionOp.literal, program.findOrAddStackEntry(span.literal.rawText));
1834
+ }
1835
+ }
1836
+ program.pushOp(ReflectionOp.templateLiteral);
1837
+ program.popFrameImplicit();
1838
+ break;
1839
+ }
1840
+ case SyntaxKind2.UnionType: {
1841
+ const narrowed = node;
1842
+ if (narrowed.types.length === 0) ; else if (narrowed.types.length === 1) {
1843
+ this.extractPackStructOfType(narrowed.types[0], program);
1844
+ } else {
1845
+ program.pushFrame();
1846
+ for (const subType of narrowed.types) {
1847
+ this.extractPackStructOfType(subType, program);
1848
+ }
1849
+ program.pushOp(ReflectionOp.union);
1850
+ program.popFrameImplicit();
1851
+ }
1852
+ break;
1853
+ }
1854
+ case SyntaxKind2.EnumDeclaration: {
1855
+ const narrowed = node;
1856
+ program.pushFrame();
1857
+ for (const type of narrowed.members) {
1858
+ const name = getPropertyName(this.f, type.name);
1859
+ program.pushOp(ReflectionOp.enumMember, program.findOrAddStackEntry(name));
1860
+ this.extractDescriptionReflection(program, type);
1861
+ if (type.initializer) {
1862
+ program.pushOp(ReflectionOp.defaultValue, program.findOrAddStackEntry(this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, type.initializer)));
1863
+ }
1864
+ }
1865
+ program.pushOp(ReflectionOp.enum);
1866
+ this.extractDefaultValueReflection(program, narrowed);
1867
+ this.extractDescriptionReflection(program, narrowed);
1868
+ this.extractTagReflections(program, narrowed);
1869
+ if (narrowed.name) this.resolveTypeName(getIdentifierName(narrowed.name), program);
1870
+ program.popFrameImplicit();
1871
+ break;
1872
+ }
1873
+ case SyntaxKind2.IndexSignature: {
1874
+ const narrowed = node;
1875
+ if (narrowed.parameters.length && narrowed.parameters[0].type) {
1876
+ this.extractPackStructOfType(narrowed.parameters[0].type, program);
1877
+ } else {
1878
+ program.pushOp(ReflectionOp.any);
1879
+ }
1880
+ this.extractPackStructOfType(narrowed.type, program);
1881
+ program.pushOp(ReflectionOp.indexSignature);
1882
+ break;
1883
+ }
1884
+ case SyntaxKind2.TypeQuery: {
1885
+ const narrowed = node;
1886
+ if (isIdentifier2(narrowed.exprName)) {
1887
+ const resolved = this.resolveDeclaration(narrowed.exprName);
1888
+ if (resolved && findSourceFile(resolved.declaration) !== this.sourceFile && resolved.importDeclaration) {
1889
+ ensureImportIsEmitted(resolved.importDeclaration, narrowed.exprName);
1890
+ }
1891
+ }
1892
+ const expression = serializeEntityNameAsExpression(this.f, narrowed.exprName);
1893
+ program.pushOp(ReflectionOp.typeof, program.pushStack(this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, expression)));
1894
+ break;
1895
+ }
1896
+ case SyntaxKind2.TypeOperator: {
1897
+ const narrowed = node;
1898
+ if (narrowed.type.kind === SyntaxKind2.ThisType) {
1899
+ program.pushOp(ReflectionOp.any);
1900
+ break;
1901
+ }
1902
+ switch (narrowed.operator) {
1903
+ case SyntaxKind2.KeyOfKeyword: {
1904
+ this.extractPackStructOfType(narrowed.type, program);
1905
+ program.pushOp(ReflectionOp.keyof);
1906
+ break;
1907
+ }
1908
+ case SyntaxKind2.ReadonlyKeyword: {
1909
+ this.extractPackStructOfType(narrowed.type, program);
1910
+ program.pushOp(ReflectionOp.readonly);
1911
+ break;
1912
+ }
1913
+ default: {
1914
+ program.pushOp(ReflectionOp.never);
1915
+ }
1916
+ }
1917
+ break;
1918
+ }
1919
+ case SyntaxKind2.IndexedAccessType: {
1920
+ const narrowed = node;
1921
+ this.extractPackStructOfType(narrowed.objectType, program);
1922
+ this.extractPackStructOfType(narrowed.indexType, program);
1923
+ program.pushOp(ReflectionOp.indexAccess);
1924
+ break;
1925
+ }
1926
+ case SyntaxKind2.Identifier: {
1927
+ const narrowed = node;
1928
+ const variable = program.findVariable(getIdentifierName(narrowed));
1929
+ if (variable) {
1930
+ program.pushOp(ReflectionOp.loads, variable.frameOffset, variable.stackIndex);
1931
+ } else {
1932
+ program.pushOp(ReflectionOp.never);
1933
+ }
1934
+ break;
1935
+ }
1936
+ default: {
1937
+ program.pushOp(ReflectionOp.never);
1938
+ }
1939
+ }
1940
+ }
1941
+ getGlobalLibs() {
1942
+ if (this.cache.globalSourceFiles) return this.cache.globalSourceFiles;
1943
+ this.cache.globalSourceFiles = [];
1944
+ const options = {
1945
+ ...this.compilerOptions
1946
+ };
1947
+ if (options.target && options.target === ScriptTarget.ESNext) {
1948
+ options.target = ScriptTarget.ES2022;
1949
+ }
1950
+ const libs = vfs.knownLibFilesForCompilerOptions(options, ts2__default.default);
1951
+ for (const lib of libs) {
1952
+ if (this.isExcluded(lib)) continue;
1953
+ const sourceFile = this.resolver.resolveSourceFile(this.sourceFile, this.f.createStringLiteral("typescript/lib/" + lib.replace(".d.ts", "")));
1954
+ if (!sourceFile) continue;
1955
+ this.cache.globalSourceFiles.push(sourceFile);
1956
+ }
1957
+ return this.cache.globalSourceFiles;
1958
+ }
1959
+ /**
1960
+ * This is a custom resolver based on populated `locals` from the binder. It uses a custom resolution algorithm since
1961
+ * we have no access to the binder/TypeChecker directly and instantiating a TypeChecker per file/transformer is incredible slow.
1962
+ */
1963
+ resolveDeclaration(typeName) {
1964
+ let current = typeName.parent;
1965
+ if (typeName.kind === SyntaxKind2.QualifiedName) return;
1966
+ let declaration = void 0;
1967
+ while (current) {
1968
+ if (isNodeWithLocals(current) && current.locals) {
1969
+ const found = current.locals.get(typeName.escapedText);
1970
+ if (found && found.declarations && found.declarations[0]) {
1971
+ if (!isParameter(found.declarations[0])) {
1972
+ declaration = found.declarations[0];
1973
+ break;
1974
+ }
1975
+ }
1976
+ }
1977
+ if (current.kind === SyntaxKind2.SourceFile) break;
1978
+ current = current.parent;
1979
+ }
1980
+ if (!declaration) {
1981
+ for (const file of this.getGlobalLibs()) {
1982
+ const globals = getGlobalsOfSourceFile(file);
1983
+ if (!globals) continue;
1984
+ const symbol = globals.get(typeName.escapedText);
1985
+ if (symbol && symbol.declarations && symbol.declarations[0]) {
1986
+ declaration = symbol.declarations[0];
1987
+ break;
1988
+ }
1989
+ }
1990
+ }
1991
+ let importDeclaration = void 0;
1992
+ let typeOnly = false;
1993
+ if (declaration && isImportSpecifier(declaration)) {
1994
+ if (declaration.isTypeOnly) typeOnly = true;
1995
+ importDeclaration = declaration.parent.parent.parent;
1996
+ } else if (declaration && isImportDeclaration(declaration)) {
1997
+ importDeclaration = declaration;
1998
+ } else if (declaration && isImportClause(declaration)) {
1999
+ importDeclaration = declaration.parent;
2000
+ }
2001
+ if (importDeclaration) {
2002
+ if (importDeclaration.importClause && importDeclaration.importClause.isTypeOnly) typeOnly = true;
2003
+ declaration = this.resolveImportSpecifier(getEscapedText(typeName), importDeclaration, this.sourceFile);
2004
+ }
2005
+ if (declaration && declaration.kind === SyntaxKind2.TypeParameter && declaration.parent.kind === SyntaxKind2.TypeAliasDeclaration) {
2006
+ declaration = declaration.parent;
2007
+ }
2008
+ if (!declaration) return;
2009
+ return {
2010
+ declaration,
2011
+ importDeclaration,
2012
+ typeOnly
2013
+ };
2014
+ }
2015
+ getDeclarationVariableName(typeName) {
2016
+ if (isIdentifier2(typeName)) {
2017
+ return this.f.createIdentifier("__\u03A9" + getIdentifierName(typeName));
2018
+ }
2019
+ function joinQualifiedName2(name) {
2020
+ if (isIdentifier2(name)) return getIdentifierName(name);
2021
+ return joinQualifiedName2(name.left) + "_" + getIdentifierName(name.right);
2022
+ }
2023
+ chunkM3FJ3QXG_cjs.__name(joinQualifiedName2, "joinQualifiedName");
2024
+ return this.f.createIdentifier("__\u03A9" + joinQualifiedName2(typeName));
2025
+ }
2026
+ /**
2027
+ * The semantic of isExcluded is different from checking if the fileName is part
2028
+ * of reflection config option. isExcluded checks if the file should be excluded
2029
+ * via the exclude option. mainly used to exclude globals and external libraries.
2030
+ */
2031
+ isExcluded(fileName) {
2032
+ const resolver = this.overriddenConfigResolver || chunkM3FJ3QXG_cjs.getConfigResolver(this.cache.resolver, this.parseConfigHost, this.compilerOptions, this.sourceFile);
2033
+ const res = chunkM3FJ3QXG_cjs.reflectionModeMatcher({
2034
+ reflection: "default",
2035
+ exclude: resolver.config.exclude
2036
+ }, fileName);
2037
+ return res === "never";
2038
+ }
2039
+ extractPackStructOfTypeReference(type, program) {
2040
+ const typeName = isTypeReferenceNode(type) ? type.typeName : isIdentifier2(type.expression) ? type.expression : void 0;
2041
+ if (!typeName) {
2042
+ program.pushOp(ReflectionOp.any);
2043
+ return;
2044
+ }
2045
+ if (isIdentifier2(typeName) && getIdentifierName(typeName) === "InlineRuntimeType" && type.typeArguments && type.typeArguments[0] && isTypeQueryNode(type.typeArguments[0])) {
2046
+ const expression = serializeEntityNameAsExpression(this.f, type.typeArguments[0].exprName);
2047
+ program.pushOp(ReflectionOp.arg, program.pushStack(expression));
2048
+ return;
2049
+ }
2050
+ if (isIdentifier2(typeName) && getIdentifierName(typeName) !== "constructor" && this.knownClasses[getIdentifierName(typeName)]) {
2051
+ const name = getIdentifierName(typeName);
2052
+ const op = this.knownClasses[name];
2053
+ program.pushOp(op);
2054
+ } else if (isIdentifier2(typeName) && getIdentifierName(typeName) === "Promise") {
2055
+ if (type.typeArguments && type.typeArguments[0]) {
2056
+ this.extractPackStructOfType(type.typeArguments[0], program);
2057
+ } else {
2058
+ program.pushOp(ReflectionOp.any);
2059
+ }
2060
+ program.pushOp(ReflectionOp.promise);
2061
+ } else if (isIdentifier2(typeName) && getIdentifierName(typeName) === "integer") {
2062
+ program.pushOp(ReflectionOp.numberBrand, TypeNumberBrand.integer);
2063
+ } else if (isIdentifier2(typeName) && getIdentifierName(typeName) !== "constructor" && TypeNumberBrand[getIdentifierName(typeName)] !== void 0) {
2064
+ program.pushOp(ReflectionOp.numberBrand, TypeNumberBrand[getIdentifierName(typeName)]);
2065
+ } else {
2066
+ if (isIdentifier2(typeName)) {
2067
+ const variable = program.findVariable(getIdentifierName(typeName));
2068
+ if (variable) {
2069
+ program.pushOp(ReflectionOp.loads, variable.frameOffset, variable.stackIndex);
2070
+ return;
2071
+ }
2072
+ } else if (isInferTypeNode(typeName)) {
2073
+ this.extractPackStructOfType(typeName, program);
2074
+ return;
2075
+ }
2076
+ const resolved = this.resolveDeclaration(typeName);
2077
+ if (!resolved) {
2078
+ if (isQualifiedName(typeName)) {
2079
+ if (isIdentifier2(typeName.left)) {
2080
+ const resolved2 = this.resolveDeclaration(typeName.left);
2081
+ if (resolved2 && isEnumDeclaration(resolved2.declaration)) {
2082
+ let lastExpression;
2083
+ let indexValue = 0;
2084
+ for (const member of resolved2.declaration.members) {
2085
+ if (getNameAsString(member.name) === getNameAsString(typeName.right)) {
2086
+ if (member.initializer) {
2087
+ program.pushOp(ReflectionOp.arg, program.pushStack(this.nodeConverter.toExpression(member.initializer)));
2088
+ } else if (lastExpression) {
2089
+ const exp = this.nodeConverter.toExpression(lastExpression);
2090
+ program.pushOp(ReflectionOp.arg, program.pushStack(this.f.createBinaryExpression(exp, SyntaxKind2.PlusToken, this.nodeConverter.toExpression(indexValue))));
2091
+ } else {
2092
+ program.pushOp(ReflectionOp.arg, program.pushStack(this.nodeConverter.toExpression(indexValue)));
2093
+ }
2094
+ return;
2095
+ } else {
2096
+ indexValue++;
2097
+ if (member.initializer) {
2098
+ lastExpression = member.initializer;
2099
+ indexValue = 0;
2100
+ }
2101
+ }
2102
+ }
2103
+ }
2104
+ }
2105
+ }
2106
+ program.pushOp(ReflectionOp.never);
2107
+ chunkM3FJ3QXG_cjs.debug2(`Could not resolve ${getNameAsString(typeName)} in ${program.sourceFile?.fileName || "intrinsic"}`);
2108
+ return;
2109
+ }
2110
+ let declaration = resolved.declaration;
2111
+ const declarationSourceFile = findSourceFile(declaration);
2112
+ const isGlobal = !declarationSourceFile || resolved.importDeclaration === void 0 && declarationSourceFile.fileName !== this.sourceFile.fileName;
2113
+ const isFromImport = resolved.importDeclaration !== void 0;
2114
+ if (isVariableDeclaration(declaration)) {
2115
+ if (declaration.type) {
2116
+ declaration = declaration.type;
2117
+ } else if (declaration.initializer) {
2118
+ declaration = declaration.initializer;
2119
+ }
2120
+ }
2121
+ if (isModuleDeclaration(declaration) && resolved.importDeclaration) {
2122
+ if (isIdentifier2(typeName)) ensureImportIsEmitted(resolved.importDeclaration, typeName);
2123
+ program.pushOp(ReflectionOp.typeof, program.pushStack(this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, serializeEntityNameAsExpression(this.f, typeName))));
2124
+ } else if (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration) || isEnumDeclaration(declaration)) {
2125
+ const name = getNameAsString(typeName);
2126
+ if (name === "Array") {
2127
+ if (type.typeArguments && type.typeArguments[0]) {
2128
+ this.extractPackStructOfType(type.typeArguments[0], program);
2129
+ } else {
2130
+ program.pushOp(ReflectionOp.any);
2131
+ }
2132
+ program.pushOp(ReflectionOp.array);
2133
+ return;
2134
+ } else if (name === "Function") {
2135
+ program.pushFrame();
2136
+ const index2 = program.pushStack(this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, this.f.createIdentifier("Function")));
2137
+ program.pushOp(ReflectionOp.functionReference, index2);
2138
+ program.popFrameImplicit();
2139
+ return;
2140
+ } else if (name === "Set") {
2141
+ if (type.typeArguments && type.typeArguments[0]) {
2142
+ this.extractPackStructOfType(type.typeArguments[0], program);
2143
+ } else {
2144
+ program.pushOp(ReflectionOp.any);
2145
+ }
2146
+ program.pushOp(ReflectionOp.set);
2147
+ return;
2148
+ } else if (name === "Map") {
2149
+ if (type.typeArguments && type.typeArguments[0]) {
2150
+ this.extractPackStructOfType(type.typeArguments[0], program);
2151
+ } else {
2152
+ program.pushOp(ReflectionOp.any);
2153
+ }
2154
+ if (type.typeArguments && type.typeArguments[1]) {
2155
+ this.extractPackStructOfType(type.typeArguments[1], program);
2156
+ } else {
2157
+ program.pushOp(ReflectionOp.any);
2158
+ }
2159
+ program.pushOp(ReflectionOp.map);
2160
+ return;
2161
+ }
2162
+ const runtimeTypeName = this.getDeclarationVariableName(typeName);
2163
+ if (!this.compiledDeclarations.has(declaration) && !this.compileDeclarations.has(declaration)) {
2164
+ if (declarationSourceFile && this.isExcluded(declarationSourceFile.fileName)) {
2165
+ program.pushOp(ReflectionOp.any);
2166
+ return;
2167
+ }
2168
+ if (isGlobal) {
2169
+ this.embedDeclarations.set(declaration, {
2170
+ name: typeName,
2171
+ sourceFile: declarationSourceFile
2172
+ });
2173
+ } else if (isFromImport) {
2174
+ if (resolved.importDeclaration) {
2175
+ if (resolved.typeOnly) {
2176
+ this.resolveTypeOnlyImport(typeName, program);
2177
+ return;
2178
+ }
2179
+ if (declarationSourceFile.fileName.endsWith(".d.ts")) {
2180
+ const resolverDecVariable = this.resolveImportSpecifier(getEscapedText(runtimeTypeName), resolved.importDeclaration, this.sourceFile);
2181
+ if (!resolverDecVariable) {
2182
+ chunkM3FJ3QXG_cjs.debug2(`Symbol ${runtimeTypeName.escapedText} not found in ${declarationSourceFile.fileName}`);
2183
+ this.resolveTypeOnlyImport(typeName, program);
2184
+ return;
2185
+ }
2186
+ this.addImports.push({
2187
+ identifier: runtimeTypeName,
2188
+ from: resolved.importDeclaration.moduleSpecifier
2189
+ });
2190
+ } else {
2191
+ const reflection = this.getReflectionConfig(declarationSourceFile);
2192
+ if (reflection.mode === "never") {
2193
+ this.resolveTypeOnlyImport(typeName, program);
2194
+ return;
2195
+ }
2196
+ const declarationReflection = this.isWithReflection(declarationSourceFile, declaration);
2197
+ if (!declarationReflection) {
2198
+ this.resolveTypeOnlyImport(typeName, program);
2199
+ return;
2200
+ }
2201
+ this.addImports.push({
2202
+ identifier: runtimeTypeName,
2203
+ from: resolved.importDeclaration.moduleSpecifier
2204
+ });
2205
+ }
2206
+ }
2207
+ } else {
2208
+ const reflection = this.isWithReflection(program.sourceFile, declaration);
2209
+ if (!reflection) {
2210
+ this.resolveTypeOnlyImport(typeName, program);
2211
+ return;
2212
+ }
2213
+ this.compileDeclarations.set(declaration, {
2214
+ name: typeName,
2215
+ sourceFile: declarationSourceFile
2216
+ });
2217
+ }
2218
+ }
2219
+ const index = program.pushStack(program.forNode === declaration ? 0 : this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, runtimeTypeName));
2220
+ if (type.typeArguments) {
2221
+ for (const argument of type.typeArguments) {
2222
+ this.extractPackStructOfType(argument, program);
2223
+ }
2224
+ program.pushOp(ReflectionOp.inlineCall, index, type.typeArguments.length);
2225
+ } else {
2226
+ program.pushOp(ReflectionOp.inline, index);
2227
+ }
2228
+ } else if (isClassDeclaration(declaration) || isFunctionDeclaration(declaration) || isFunctionExpression(declaration) || isArrowFunction2(declaration)) {
2229
+ if (resolved.typeOnly) {
2230
+ this.resolveTypeOnlyImport(typeName, program);
2231
+ return;
2232
+ }
2233
+ const reflection = declarationSourceFile?.fileName.endsWith(".d.ts") || this.isWithReflection(program.sourceFile, declaration);
2234
+ if (!reflection) {
2235
+ this.resolveTypeOnlyImport(typeName, program);
2236
+ return;
2237
+ }
2238
+ if (resolved.importDeclaration && isIdentifier2(typeName)) ensureImportIsEmitted(resolved.importDeclaration, typeName);
2239
+ program.pushFrame();
2240
+ if (type.typeArguments) {
2241
+ for (const typeArgument of type.typeArguments) {
2242
+ this.extractPackStructOfType(typeArgument, program);
2243
+ }
2244
+ }
2245
+ const body = isIdentifier2(typeName) ? typeName : this.createAccessorForEntityName(typeName);
2246
+ const index = program.pushStack(this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, body));
2247
+ program.pushOp(isClassDeclaration(declaration) ? ReflectionOp.classReference : ReflectionOp.functionReference, index);
2248
+ program.popFrameImplicit();
2249
+ } else if (isTypeParameterDeclaration(declaration)) {
2250
+ this.resolveTypeParameter(declaration, type, program);
2251
+ } else {
2252
+ this.extractPackStructOfType(declaration, program);
2253
+ }
2254
+ }
2255
+ }
2256
+ /**
2257
+ * Returns the class declaration, function/arrow declaration, or block where type was used.
2258
+ */
2259
+ getTypeUser(type) {
2260
+ let current = type;
2261
+ while (current) {
2262
+ if (current.kind === SyntaxKind2.Block) return current;
2263
+ if (current.kind === SyntaxKind2.ClassDeclaration) return current;
2264
+ if (current.kind === SyntaxKind2.ClassExpression) return current;
2265
+ if (current.kind === SyntaxKind2.Constructor) return current.parent;
2266
+ if (current.kind === SyntaxKind2.MethodDeclaration) return current.parent;
2267
+ if (current.kind === SyntaxKind2.ArrowFunction || current.kind === SyntaxKind2.FunctionDeclaration || current.kind === SyntaxKind2.FunctionExpression) return current;
2268
+ current = current.parent;
2269
+ }
2270
+ return current;
2271
+ }
2272
+ /**
2273
+ * With this function we want to check if `type` is used in the signature itself from the parent of `declaration`.
2274
+ * If so, we do not try to infer the type from runtime values.
2275
+ *
2276
+ * Examples where we do not infer from runtime, `type` being `T` and `declaration` being `<T>` (return false):
2277
+ *
2278
+ * ```typescript
2279
+ * class User<T> {
2280
+ * config: T;
2281
+ * }
2282
+ *
2283
+ * class User<T> {
2284
+ * constructor(public config: T) {}
2285
+ * }
2286
+ *
2287
+ * function do<T>(item: T): void {}
2288
+ * function do<T>(item: T): T {}
2289
+ * ```
2290
+ *
2291
+ * Examples where we infer from runtime (return true):
2292
+ *
2293
+ * ```typescript
2294
+ * function do<T>(item: T) {
2295
+ * return typeOf<T>; //<-- because of that
2296
+ * }
2297
+ *
2298
+ * function do<T>(item: T) {
2299
+ * class A {
2300
+ * config: T; //<-- because of that
2301
+ * }
2302
+ * return A;
2303
+ * }
2304
+ *
2305
+ * function do<T>(item: T) {
2306
+ * class A {
2307
+ * doIt() {
2308
+ * class B {
2309
+ * config: T; //<-- because of that
2310
+ * }
2311
+ * return B;
2312
+ * }
2313
+ * }
2314
+ * return A;
2315
+ * }
2316
+ *
2317
+ * function do<T>(item: T) {
2318
+ * class A {
2319
+ * doIt(): T { //<-- because of that
2320
+ * }
2321
+ * }
2322
+ * return A;
2323
+ * }
2324
+ * ```
2325
+ */
2326
+ needsToBeInferred(declaration, type) {
2327
+ const declarationUser = this.getTypeUser(declaration);
2328
+ const typeUser = this.getTypeUser(type);
2329
+ return declarationUser !== typeUser;
2330
+ }
2331
+ resolveTypeOnlyImport(entityName, program) {
2332
+ program.pushOp(ReflectionOp.any);
2333
+ const typeName = ts2__default.default.isIdentifier(entityName) ? getIdentifierName(entityName) : getIdentifierName(entityName.right);
2334
+ this.resolveTypeName(typeName, program);
2335
+ }
2336
+ resolveTypeName(typeName, program) {
2337
+ if (!typeName) return;
2338
+ program.pushOp(ReflectionOp.typeName, program.findOrAddStackEntry(typeName));
2339
+ }
2340
+ resolveTypeParameter(declaration, type, program) {
2341
+ const isUsedInFunction = isFunctionLike(declaration.parent);
2342
+ const resolveRuntimeTypeParameter = isUsedInFunction && program.isResolveFunctionParameters(declaration.parent) || this.needsToBeInferred(declaration, type);
2343
+ if (resolveRuntimeTypeParameter) {
2344
+ const argumentName = declaration.name.escapedText;
2345
+ const foundUsers = [];
2346
+ if (isUsedInFunction) {
2347
+ for (const parameter of declaration.parent.parameters) {
2348
+ if (!parameter.type) continue;
2349
+ let found = false;
2350
+ const searchArgument = /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((node) => {
2351
+ node = visitEachChild(node, searchArgument, this.context);
2352
+ if (isTypeReferenceNode(node) && isIdentifier2(node.typeName) && node.typeName.escapedText === argumentName) {
2353
+ found = true;
2354
+ node = this.f.createInferTypeNode(declaration);
2355
+ }
2356
+ return node;
2357
+ }, "searchArgument");
2358
+ if (isIdentifier2(parameter.name)) {
2359
+ const updatedParameterType = visitEachChild(parameter.type, searchArgument, this.context);
2360
+ if (found) {
2361
+ foundUsers.push({
2362
+ type: updatedParameterType,
2363
+ parameterName: parameter.name
2364
+ });
2365
+ }
2366
+ }
2367
+ }
2368
+ }
2369
+ if (foundUsers.length) {
2370
+ if (foundUsers.length > 1) ;
2371
+ const isReceiveType = foundUsers.find((v) => isTypeReferenceNode(v.type) && isIdentifier2(v.type.typeName) && getIdentifierName(v.type.typeName) === "ReceiveType");
2372
+ if (isReceiveType) {
2373
+ program.pushOp(ReflectionOp.inline, program.pushStack(isReceiveType.parameterName));
2374
+ } else {
2375
+ for (const foundUser of foundUsers) {
2376
+ program.pushConditionalFrame();
2377
+ program.pushOp(ReflectionOp.typeof, program.pushStack(this.f.createArrowFunction(void 0, void 0, [], void 0, void 0, foundUser.parameterName)));
2378
+ this.extractPackStructOfType(foundUser.type, program);
2379
+ program.pushOp(ReflectionOp.extends);
2380
+ const found = program.findVariable(getIdentifierName(declaration.name));
2381
+ if (found) {
2382
+ this.extractPackStructOfType(declaration.name, program);
2383
+ } else {
2384
+ program.pushOp(ReflectionOp.any);
2385
+ }
2386
+ this.extractPackStructOfType({
2387
+ kind: SyntaxKind2.NeverKeyword
2388
+ }, program);
2389
+ program.pushOp(ReflectionOp.condition);
2390
+ program.popFrameImplicit();
2391
+ }
2392
+ }
2393
+ if (foundUsers.length > 1) ;
2394
+ } else if (declaration.constraint) {
2395
+ if (isUsedInFunction) program.resolveFunctionParametersIncrease(declaration.parent);
2396
+ const constraint = getEffectiveConstraintOfTypeParameter(declaration);
2397
+ if (constraint) {
2398
+ this.extractPackStructOfType(constraint, program);
2399
+ } else {
2400
+ program.pushOp(ReflectionOp.never);
2401
+ }
2402
+ if (isUsedInFunction) program.resolveFunctionParametersDecrease(declaration.parent);
2403
+ } else {
2404
+ program.pushOp(ReflectionOp.never);
2405
+ }
2406
+ } else {
2407
+ program.pushOp(ReflectionOp.any);
2408
+ }
2409
+ }
2410
+ createAccessorForEntityName(e) {
2411
+ return this.f.createPropertyAccessExpression(isIdentifier2(e.left) ? e.left : this.createAccessorForEntityName(e.left), e.right);
2412
+ }
2413
+ findDeclarationInFile(sourceFile, declarationName) {
2414
+ if (isNodeWithLocals(sourceFile) && sourceFile.locals) {
2415
+ const declarationSymbol = sourceFile.locals.get(declarationName);
2416
+ if (declarationSymbol && declarationSymbol.declarations && declarationSymbol.declarations[0]) {
2417
+ return declarationSymbol.declarations[0];
2418
+ }
2419
+ }
2420
+ return;
2421
+ }
2422
+ resolveImportSpecifier(_declarationName, importOrExport, sourceFile) {
2423
+ const declarationName = "string" === typeof _declarationName ? _declarationName : getIdentifierName(_declarationName);
2424
+ if (!importOrExport.moduleSpecifier || !isStringLiteral2(importOrExport.moduleSpecifier)) {
2425
+ return;
2426
+ }
2427
+ const source = this.resolver.resolve(sourceFile, importOrExport);
2428
+ if (!source) {
2429
+ chunkM3FJ3QXG_cjs.debug("module not found", importOrExport.moduleSpecifier.text, "Is transpileOnly enabled? It needs to be disabled.");
2430
+ return;
2431
+ }
2432
+ const declaration = this.findDeclarationInFile(source, declarationName);
2433
+ sourceFile = source;
2434
+ if (declaration && !isImportSpecifier(declaration)) {
2435
+ if (isExportDeclaration(declaration)) {
2436
+ return this.followExport(declarationName, declaration, sourceFile);
2437
+ }
2438
+ return declaration;
2439
+ }
2440
+ if (isSourceFile(sourceFile)) {
2441
+ for (const statement of sourceFile.statements) {
2442
+ if (!isExportDeclaration(statement)) continue;
2443
+ const found = this.followExport(declarationName, statement, sourceFile);
2444
+ if (found) return found;
2445
+ }
2446
+ }
2447
+ return;
2448
+ }
2449
+ followExport(declarationName, statement, sourceFile) {
2450
+ if (statement.exportClause) {
2451
+ if (isNamedExports(statement.exportClause)) {
2452
+ for (const element of statement.exportClause.elements) {
2453
+ if (getEscapedText(element.name) === declarationName) {
2454
+ if (!statement.moduleSpecifier || !isStringLiteral2(statement.moduleSpecifier)) {
2455
+ if (!statement.moduleSpecifier || !isStringLiteral2(statement.moduleSpecifier)) {
2456
+ if (isNodeWithLocals(sourceFile) && sourceFile.locals) {
2457
+ const found = sourceFile.locals.get(declarationName);
2458
+ if (found && found.declarations && found.declarations[0]) {
2459
+ const declaration = found.declarations[0];
2460
+ if (declaration && isImportSpecifier(declaration)) {
2461
+ const importOrExport = declaration.parent.parent.parent;
2462
+ const found2 = this.resolveImportSpecifier(element.propertyName ? getEscapedText(element.propertyName) : declarationName, importOrExport, sourceFile);
2463
+ if (found2) return found2;
2464
+ }
2465
+ return declaration;
2466
+ }
2467
+ }
2468
+ }
2469
+ } else {
2470
+ const found = this.resolveImportSpecifier(element.propertyName ? getEscapedText(element.propertyName) : declarationName, statement, sourceFile);
2471
+ if (found) return found;
2472
+ }
2473
+ }
2474
+ }
2475
+ }
2476
+ } else {
2477
+ const found = this.resolveImportSpecifier(declarationName, statement, sourceFile);
2478
+ if (found) {
2479
+ return found;
2480
+ }
2481
+ }
2482
+ return;
2483
+ }
2484
+ getTypeOfType(type) {
2485
+ const reflection = this.isWithReflection(this.sourceFile, type);
2486
+ if (!reflection) return;
2487
+ const program = new CompilerProgram(type, this.sourceFile);
2488
+ this.extractPackStructOfType(type, program);
2489
+ return this.packOpsAndStack(program);
2490
+ }
2491
+ packOpsAndStack(program) {
2492
+ const packStruct = program.buildPackStruct();
2493
+ if (packStruct.ops.length === 0) return;
2494
+ const packed = [
2495
+ ...packStruct.stack,
2496
+ encodeOps(packStruct.ops)
2497
+ ];
2498
+ return this.valueToExpression(packed);
2499
+ }
2500
+ /**
2501
+ * Note: We have to duplicate the expressions as it can be that incoming expression are from another file and contain wrong pos/end properties,
2502
+ * so the code generation is then broken when we simply reuse them. Wrong code like ``User.__type = [.toEqual({`` is then generated.
2503
+ * This function is probably not complete, but we add new copies when required.
2504
+ */
2505
+ valueToExpression(value) {
2506
+ return this.nodeConverter.toExpression(value);
2507
+ }
2508
+ /**
2509
+ * A class is decorated with type information by adding a static variable.
2510
+ *
2511
+ * class Model {
2512
+ * static __types = pack(ReflectionOp.string); //<-- encoded type information
2513
+ * title: string;
2514
+ * }
2515
+ */
2516
+ decorateClass(sourceFile, node) {
2517
+ const reflection = this.isWithReflection(sourceFile, node);
2518
+ if (!reflection) {
2519
+ return node;
2520
+ }
2521
+ const type = this.getTypeOfType(node);
2522
+ const __type = this.f.createPropertyDeclaration(this.f.createModifiersFromModifierFlags(ModifierFlags.Static), "__type", void 0, void 0, type);
2523
+ if (isClassDeclaration(node)) {
2524
+ return this.f.updateClassDeclaration(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, this.f.createNodeArray([
2525
+ ...node.members,
2526
+ __type
2527
+ ]));
2528
+ }
2529
+ return this.f.updateClassExpression(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, this.f.createNodeArray([
2530
+ ...node.members,
2531
+ __type
2532
+ ]));
2533
+ }
2534
+ /**
2535
+ * const fn = function() {}
2536
+ *
2537
+ * => const fn = __assignType(function() {}, [34])
2538
+ */
2539
+ decorateFunctionExpression(expression) {
2540
+ const encodedType = this.getTypeOfType(expression);
2541
+ if (!encodedType) return expression;
2542
+ return this.wrapWithAssignType(expression, encodedType);
2543
+ }
2544
+ /**
2545
+ * function name() {}
2546
+ *
2547
+ * => function name() {}; name.__type = 34;
2548
+ */
2549
+ decorateFunctionDeclaration(declaration) {
2550
+ const encodedType = this.getTypeOfType(declaration);
2551
+ if (!encodedType) return declaration;
2552
+ if (!declaration.name) {
2553
+ if (!declaration.body) return;
2554
+ const modifier = declaration.modifiers ? declaration.modifiers.filter((v) => v.kind !== SyntaxKind2.ExportKeyword && v.kind !== SyntaxKind2.DefaultKeyword && v.kind !== SyntaxKind2.Decorator) : [];
2555
+ return this.f.createExportAssignment(void 0, void 0, this.wrapWithAssignType(this.f.createFunctionExpression(modifier, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, declaration.body), encodedType));
2556
+ }
2557
+ const statements = [
2558
+ declaration
2559
+ ];
2560
+ statements.push(this.f.createExpressionStatement(this.f.createAssignment(this.f.createPropertyAccessExpression(serializeEntityNameAsExpression(this.f, declaration.name), "__type"), encodedType)));
2561
+ return statements;
2562
+ }
2563
+ /**
2564
+ * const fn = () => {}
2565
+ * => const fn = __assignType(() => {}, [34])
2566
+ */
2567
+ decorateArrowFunction(expression) {
2568
+ const encodedType = this.getTypeOfType(expression);
2569
+ if (!encodedType) return expression;
2570
+ return this.wrapWithAssignType(expression, encodedType);
2571
+ }
2572
+ /**
2573
+ * Object.assign(fn, {__type: []}) is much slower than a custom implementation like
2574
+ *
2575
+ * assignType(fn, [])
2576
+ *
2577
+ * where we embed assignType() at the beginning of the type.
2578
+ */
2579
+ wrapWithAssignType(fn, type) {
2580
+ this.embedAssignType = true;
2581
+ return this.f.createCallExpression(this.f.createIdentifier("__assignType"), void 0, [
2582
+ fn,
2583
+ type
2584
+ ]);
2585
+ }
2586
+ /**
2587
+ * Checks if reflection was disabled/enabled in file via JSDoc attribute for a particular
2588
+ * Node, e.g `@reflection no`. If nothing is found, "reflection" config option needs to be used.
2589
+ */
2590
+ getExplicitReflectionMode(sourceFile, node) {
2591
+ let current = node;
2592
+ let reflectionComment = void 0;
2593
+ while ("undefined" === typeof reflectionComment && current) {
2594
+ const next = sourceFile && extractJSDocAttribute(sourceFile, current, "reflection");
2595
+ if ("undefined" !== typeof next) reflectionComment = next;
2596
+ current = current.parent;
2597
+ }
2598
+ if (reflectionComment === "" || reflectionComment === "true" || reflectionComment === "default" || reflectionComment === "enabled" || reflectionComment === "1") {
2599
+ return true;
2600
+ }
2601
+ if (reflectionComment === "false" || reflectionComment === "disabled" || reflectionComment === "never" || reflectionComment === "no" || reflectionComment === "0") {
2602
+ return false;
2603
+ }
2604
+ return;
2605
+ }
2606
+ };
2607
+ var DeclarationTransformer = class extends ReflectionTransformer {
2608
+ static {
2609
+ chunkM3FJ3QXG_cjs.__name(this, "DeclarationTransformer");
2610
+ }
2611
+ constructor() {
2612
+ super(...arguments);
2613
+ this.addExports = [];
2614
+ }
2615
+ transformSourceFile(sourceFile) {
2616
+ if (sourceFile.deepkitDeclarationTransformed) return sourceFile;
2617
+ this.sourceFile = sourceFile;
2618
+ this.addExports = [];
2619
+ const configResolver = this.getConfigResolver(sourceFile);
2620
+ const reflection = configResolver.match(sourceFile.fileName);
2621
+ Object.assign(this.compilerOptions, configResolver.config.compilerOptions);
2622
+ if (reflection.mode === "never") return sourceFile;
2623
+ const visitor = /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name((node) => {
2624
+ node = visitEachChild(node, visitor, this.context);
2625
+ if ((isTypeAliasDeclaration(node) || isInterfaceDeclaration(node) || isEnumDeclaration(node)) && hasModifier(node, SyntaxKind2.ExportKeyword)) {
2626
+ const reflection2 = this.isWithReflection(sourceFile, node);
2627
+ if (reflection2) {
2628
+ this.addExports.push({
2629
+ identifier: getIdentifierName(this.getDeclarationVariableName(node.name))
2630
+ });
2631
+ }
2632
+ }
2633
+ return node;
2634
+ }, "visitor");
2635
+ this.sourceFile = visitNode(this.sourceFile, visitor);
2636
+ if (this.addExports.length) {
2637
+ const exports$1 = [];
2638
+ const handledIdentifier = [];
2639
+ for (const imp of this.addExports) {
2640
+ if (handledIdentifier.includes(imp.identifier)) continue;
2641
+ handledIdentifier.push(imp.identifier);
2642
+ exports$1.push(this.f.createTypeAliasDeclaration([
2643
+ this.f.createModifier(SyntaxKind2.ExportKeyword),
2644
+ this.f.createModifier(SyntaxKind2.DeclareKeyword)
2645
+ ], this.f.createIdentifier(imp.identifier), void 0, this.f.createArrayTypeNode(this.f.createKeywordTypeNode(SyntaxKind2.AnyKeyword))));
2646
+ }
2647
+ this.sourceFile = this.f.updateSourceFile(this.sourceFile, [
2648
+ ...this.sourceFile.statements,
2649
+ ...exports$1
2650
+ ]);
2651
+ }
2652
+ this.sourceFile.deepkitDeclarationTransformed = true;
2653
+ return this.sourceFile;
2654
+ }
2655
+ };
2656
+ var loaded = false;
2657
+ var cache = new Cache();
2658
+ var transformer = /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name(function deepkitTransformer(context) {
2659
+ if (!loaded) {
2660
+ chunkM3FJ3QXG_cjs.debug("@deepkit/type transformer loaded\n");
2661
+ loaded = true;
2662
+ }
2663
+ cache.tick();
2664
+ return new ReflectionTransformer(context, cache);
2665
+ }, "deepkitTransformer");
2666
+ var declarationTransformer = /* @__PURE__ */ chunkM3FJ3QXG_cjs.__name(function deepkitDeclarationTransformer(context) {
2667
+ return new DeclarationTransformer(context, cache);
2668
+ }, "deepkitDeclarationTransformer");
2669
+
2670
+ exports.Cache = Cache;
2671
+ exports.DeclarationTransformer = DeclarationTransformer;
2672
+ exports.ReflectionTransformer = ReflectionTransformer;
2673
+ exports.debugPackStruct = debugPackStruct;
2674
+ exports.declarationTransformer = declarationTransformer;
2675
+ exports.encodeOps = encodeOps;
2676
+ exports.packSize = packSize;
2677
+ exports.packSizeByte = packSizeByte;
2678
+ exports.transformer = transformer;