@glutinum/cli 1.0.0-beta.14 → 1.0.0-beta.16

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 (34) hide show
  1. package/dist/Glutinum.Converter/GlueAST.js +19 -14
  2. package/dist/Glutinum.Converter/Merge.js +490 -206
  3. package/dist/Glutinum.Converter/Packages.js +2 -2
  4. package/dist/Glutinum.Converter/Printer.js +26 -21
  5. package/dist/Glutinum.Converter/Read.js +377 -169
  6. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +25 -8
  7. package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +2 -2
  8. package/dist/Glutinum.Converter/Reader/Declaration.js +15 -15
  9. package/dist/Glutinum.Converter/Reader/Deferred.js +114 -43
  10. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +98 -44
  11. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +2 -2
  12. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +61 -46
  13. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +31 -26
  14. package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +38 -25
  15. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +6 -5
  16. package/dist/Glutinum.Converter/Reader/Node.js +1 -1
  17. package/dist/Glutinum.Converter/Reader/TypeNode.js +292 -30
  18. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +1 -1
  19. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +143 -35
  20. package/dist/Glutinum.Converter/Reader/UtilityType.js +179 -34
  21. package/dist/Glutinum.Converter/Reader/Utils.js +186 -17
  22. package/dist/Glutinum.Converter/Reader/VariableStatement.js +46 -16
  23. package/dist/Glutinum.Converter/Transform.js +1073 -638
  24. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +2 -2
  25. package/dist/Glutinum.Converter/Transformer/Conditionals.js +17 -16
  26. package/dist/Glutinum.Converter/Transformer/Context.js +12 -4
  27. package/dist/Glutinum.Converter/Transformer/Exports.js +242 -66
  28. package/dist/Glutinum.Converter/Transformer/Heritage.js +449 -17
  29. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +4 -4
  30. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +105 -19
  31. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +2 -2
  32. package/dist/Glutinum.Converter/Transformer/Utils.js +3 -3
  33. package/dist/Glutinum.Converter/Utils/Naming.js +10 -3
  34. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
1
 
2
- import { primitiveOfFlags, isFromEsLib, isFromEs5Lib, withInProgress, identifierText, isTopLevelModuleDeclaration, modulePathForSymbol, declaredName, $007CHasSymbolFlags$007C_$007C, resolveAlias, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
2
+ import { primitiveOfFlags, Type_NumberLiteral_$007CInt$007CFloat$007COther$007C, Type_StringLiteral_$007CString$007COther$007C, isFromEsLib, isFromEs5Lib, withInProgress, identifierText, isTopLevelModuleDeclaration, isExternalToPackages, modulePathForSymbol, declaredName, $007CHasSymbolFlags$007C_$007C, resolveAlias, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
3
3
  import { defaultArg } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
4
4
  import { contains, item } from "../../fable_modules/fable-library-js.5.21.0/Array.js";
5
5
  import { collect as collect_1, append as append_1, delay, toList, exists } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
6
6
  import { filter, isEmpty, singleton, append, map, empty } from "../../fable_modules/fable-library-js.5.21.0/List.js";
7
- import { GlueFunctionDeclaration, GlueSubstitution_substituteParameter, GlueSubstitution_substitute, GlueSubstitution_mentionedTypeParameters, GlueFunctionType, GlueTypeReference, GlueType, GluePrimitive } from "../GlueAST.js";
7
+ import { GlueLiteral, GlueFunctionDeclaration, GlueSubstitution_substituteParameter, GlueSubstitution_substitute, GlueSubstitution_mentionedTypeParameters, GlueFunctionType, GluePrimitive, GlueType, GlueTypeReference } from "../GlueAST.js";
8
8
  import { sanitizeTypeName, removeSurroundingQuotes } from "../Utils/Naming.js";
9
- import { PackageContext__ModulePath_Z721C83C5 } from "./Types.js";
9
+ import { PackageContext__IsHoisted_32BC514A, PackageContext__TryFindPackage_Z721C83C5, PackageContext__IsImportable_Z384F8060, PackageContext__ModulePath_Z721C83C5 } from "./Types.js";
10
10
  import { normalizePath } from "../Utils/String.js";
11
11
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.21.0/FSharp.Core.js";
12
12
  import { FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
@@ -18,7 +18,7 @@ import { concat } from "../../fable_modules/fable-library-js.5.21.0/String.js";
18
18
  import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
19
19
 
20
20
  export function readTypeQueryNode(reader, typeQueryNode) {
21
- let declarations_1;
21
+ let matchValue_10, packageContext, declarations_1;
22
22
  const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
23
23
  const typ = checker.getTypeAtLocation(typeQueryNode.exprName);
24
24
  const matchValue = typ.flags;
@@ -66,7 +66,7 @@ export function readTypeQueryNode(reader, typeQueryNode) {
66
66
  }
67
67
  switch (matchResult_1) {
68
68
  case 0:
69
- return isOwnDeclaration(item(0, declarations_4));
69
+ return isOwnDeclaration(export$_1.name)(item(0, declarations_4));
70
70
  default:
71
71
  return false;
72
72
  }
@@ -99,23 +99,83 @@ export function readTypeQueryNode(reader, typeQueryNode) {
99
99
  matchResult_2 = 2;
100
100
  break;
101
101
  }
102
- default:
102
+ case 185: {
103
+ if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
104
+ matchResult_2 = 5;
105
+ }
106
+ else {
107
+ matchResult_2 = 6;
108
+ }
109
+ break;
110
+ }
111
+ case 186: {
103
112
  if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
104
113
  matchResult_2 = 5;
105
114
  }
106
115
  else {
107
116
  matchResult_2 = 6;
108
117
  }
118
+ break;
119
+ }
120
+ case 188: {
121
+ if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
122
+ matchResult_2 = 5;
123
+ }
124
+ else {
125
+ matchResult_2 = 6;
126
+ }
127
+ break;
128
+ }
129
+ case 201: {
130
+ if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
131
+ matchResult_2 = 5;
132
+ }
133
+ else {
134
+ matchResult_2 = 6;
135
+ }
136
+ break;
137
+ }
138
+ default:
139
+ if (isFromEs5Lib(symbol_1) ? true : isFromEsLib(symbol_1)) {
140
+ matchResult_2 = 5;
141
+ }
142
+ else {
143
+ matchResult_2 = 7;
144
+ }
109
145
  }
110
146
  switch (matchResult_2) {
111
147
  case 0: {
112
- let typeArguments;
113
- const matchValue_9 = declaration_1.typeParameters;
114
- typeArguments = ((matchValue_9 == null) ? empty() : map((_arg_6) => (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])), toList(matchValue_9)));
115
- return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(defaultArg(declaredName(symbol_1), symbol_1.name), checker.getFullyQualifiedName(symbol_1), modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), false, symbol_1), typeArguments, false)]);
148
+ const reference = new GlueTypeReference(defaultArg(declaredName(symbol_1), symbol_1.name), checker.getFullyQualifiedName(symbol_1), modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), false, symbol_1), empty(), false);
149
+ const matchValue_9 = typeQueryNode.parent.kind;
150
+ let matchResult_3;
151
+ if (isExternalToPackages(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), symbol_1)) {
152
+ matchResult_3 = 0;
153
+ }
154
+ else {
155
+ switch (matchValue_9) {
156
+ case 169:
157
+ case 184:
158
+ case 234: {
159
+ matchResult_3 = 1;
160
+ break;
161
+ }
162
+ default:
163
+ matchResult_3 = 2;
164
+ }
165
+ }
166
+ switch (matchResult_3) {
167
+ case 0:
168
+ return new GlueType(/* TypeReference */ 13, [reference]);
169
+ case 1:
170
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(reference.Name, reference.FullName, reference.ModulePath, (matchValue_10 = declaration_1.typeParameters, (matchValue_10 == null) ? empty() : map((_arg_6) => (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])), toList(matchValue_10))), reference.IsStandardLibrary)]);
171
+ default: {
172
+ void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_TypeMemory"]().push(new GlueType(/* ClassConstructor */ 30, [reference])));
173
+ return new GlueType(/* ClassConstructor */ 30, [reference]);
174
+ }
175
+ }
116
176
  }
117
177
  case 1:
118
- if (!hasValueExport((_arg_7) => true)) {
178
+ if (!hasValueExport((_arg_7) => ((_arg_8) => true))) {
119
179
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
120
180
  }
121
181
  else {
@@ -126,39 +186,47 @@ export function readTypeQueryNode(reader, typeQueryNode) {
126
186
  }
127
187
  case 2: {
128
188
  const sourceFile = declaration_1;
129
- const matchValue_10 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
130
- let matchResult_3, packageContext_1;
131
- if (matchValue_10 != null) {
132
- if (hasValueExport((declaration_2) => (normalizePath(declaration_2.getSourceFile().fileName) === normalizePath(sourceFile.fileName)))) {
133
- matchResult_3 = 0;
134
- packageContext_1 = matchValue_10;
189
+ const matchValue_12 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
190
+ let matchResult_4, packageContext_2;
191
+ if (matchValue_12 != null) {
192
+ if (hasValueExport((packageContext = matchValue_12, (name) => ((declaration_3) => {
193
+ if ((normalizePath(declaration_3.getSourceFile().fileName) === normalizePath(sourceFile.fileName)) && PackageContext__IsImportable_Z384F8060(packageContext, sourceFile.fileName, name)) {
194
+ const matchValue_11 = PackageContext__TryFindPackage_Z721C83C5(packageContext, sourceFile.fileName);
195
+ return (matchValue_11 == null) ? true : !PackageContext__IsHoisted_32BC514A(packageContext, matchValue_11, sourceFile.fileName, name);
196
+ }
197
+ else {
198
+ return false;
199
+ }
200
+ })))) {
201
+ matchResult_4 = 0;
202
+ packageContext_2 = matchValue_12;
135
203
  }
136
204
  else {
137
- matchResult_3 = 1;
205
+ matchResult_4 = 1;
138
206
  }
139
207
  }
140
208
  else {
141
- matchResult_3 = 1;
209
+ matchResult_4 = 1;
142
210
  }
143
- switch (matchResult_3) {
211
+ switch (matchResult_4) {
144
212
  case 0:
145
- return new GlueType(/* TypeReference */ 13, [new GlueTypeReference("Exports", checker.getFullyQualifiedName(symbol_1), PackageContext__ModulePath_Z721C83C5(packageContext_1, sourceFile.fileName), empty(), false)]);
213
+ return new GlueType(/* TypeReference */ 13, [new GlueTypeReference("Exports", checker.getFullyQualifiedName(symbol_1), PackageContext__ModulePath_Z721C83C5(packageContext_2, sourceFile.fileName), empty(), false)]);
146
214
  default:
147
215
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
148
216
  }
149
217
  }
150
218
  case 3: {
151
- const matchValue_11 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
152
- if (matchValue_11.tag === 6) {
153
- if (!isEmpty(matchValue_11.fields[0].TypeParameters)) {
219
+ const matchValue_13 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1);
220
+ if (matchValue_13.tag === 6) {
221
+ if (!isEmpty(matchValue_13.fields[0].TypeParameters)) {
154
222
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
155
223
  }
156
224
  else {
157
- return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(matchValue_11.fields[0].Documentation, matchValue_11.fields[0].Type, matchValue_11.fields[0].TypeParameters, empty(), matchValue_11.fields[0].Parameters)]);
225
+ return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(matchValue_13.fields[0].Documentation, matchValue_13.fields[0].Type, matchValue_13.fields[0].TypeParameters, empty(), matchValue_13.fields[0].Parameters)]);
158
226
  }
159
227
  }
160
228
  else {
161
- return matchValue_11;
229
+ return matchValue_13;
162
230
  }
163
231
  }
164
232
  case 4: {
@@ -183,20 +251,20 @@ export function readTypeQueryNode(reader, typeQueryNode) {
183
251
  inScope = ofSeq(collect(typeQueryNode, empty()), {
184
252
  Compare: (x_8, y) => (comparePrimitives(x_8, y) | 0),
185
253
  });
186
- const toFunctionDeclaration = (name, documentation, parameters, returnType) => {
187
- const free = ofList(map((name_2) => [name_2, new GlueType(/* Primitive */ 3, [GluePrimitive.Any])], filter((name_1) => !FSharpSet__Contains(inScope, name_1), toList(delay(() => append_1(GlueSubstitution_mentionedTypeParameters(returnType), delay(() => collect_1((parameter) => GlueSubstitution_mentionedTypeParameters(parameter.Type), parameters))))))), {
254
+ const toFunctionDeclaration = (name_1, documentation, parameters, returnType) => {
255
+ const free = ofList(map((name_3) => [name_3, new GlueType(/* Primitive */ 3, [GluePrimitive.Any])], filter((name_2) => !FSharpSet__Contains(inScope, name_2), toList(delay(() => append_1(GlueSubstitution_mentionedTypeParameters(returnType), delay(() => collect_1((parameter) => GlueSubstitution_mentionedTypeParameters(parameter.Type), parameters))))))), {
188
256
  Compare: (x_9, y_1) => (comparePrimitives(x_9, y_1) | 0),
189
257
  });
190
- return new GlueType(/* FunctionDeclaration */ 6, [new GlueFunctionDeclaration(documentation, true, name, GlueSubstitution_substitute(free, returnType), map((parameter_1) => GlueSubstitution_substituteParameter(free, parameter_1), parameters), empty())]);
258
+ return new GlueType(/* FunctionDeclaration */ 6, [new GlueFunctionDeclaration(documentation, true, name_1, GlueSubstitution_substitute(free, returnType), map((parameter_1) => GlueSubstitution_substituteParameter(free, parameter_1), parameters), empty())]);
191
259
  };
192
- const matchValue_12 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_1);
193
- switch (matchValue_12.tag) {
260
+ const matchValue_14 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_1);
261
+ switch (matchValue_14.tag) {
194
262
  case 0: {
195
- const info_3 = matchValue_12.fields[0];
263
+ const info_3 = matchValue_14.fields[0];
196
264
  return toFunctionDeclaration(info_3.Name, info_3.Documentation, info_3.Parameters, info_3.Type);
197
265
  }
198
266
  case 6: {
199
- const info_4 = matchValue_12.fields[0];
267
+ const info_4 = matchValue_14.fields[0];
200
268
  return toFunctionDeclaration(info_4.Name, info_4.Documentation, info_4.Parameters, info_4.Type);
201
269
  }
202
270
  default:
@@ -205,13 +273,23 @@ export function readTypeQueryNode(reader, typeQueryNode) {
205
273
  }
206
274
  case 5:
207
275
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
208
- default:
276
+ case 6:
209
277
  if (contains(declaration_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, {
210
278
  Equals: equals,
211
279
  GetHashCode: (x_10) => (structuralHash(x_10) | 0),
212
280
  })) {
213
281
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
214
282
  }
283
+ else {
284
+ return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, declaration_1, () => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](declaration_1));
285
+ }
286
+ default:
287
+ if (contains(declaration_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, {
288
+ Equals: equals,
289
+ GetHashCode: (x_11) => (structuralHash(x_11) | 0),
290
+ })) {
291
+ return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
292
+ }
215
293
  else {
216
294
  return withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().TypeQueryDeclarations, declaration_1, () => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1));
217
295
  }
@@ -300,7 +378,37 @@ export function readTypeQueryNode(reader, typeQueryNode) {
300
378
  }
301
379
  }
302
380
  else {
303
- return primitiveOfFlags(typ);
381
+ let matchResult_5;
382
+ if ($007CHasTypeFlags$007C_$007C(1024, matchValue) != null) {
383
+ matchResult_5 = 0;
384
+ }
385
+ else if ($007CHasTypeFlags$007C_$007C(2048, matchValue) != null) {
386
+ matchResult_5 = 0;
387
+ }
388
+ else {
389
+ matchResult_5 = 1;
390
+ }
391
+ switch (matchResult_5) {
392
+ case 0: {
393
+ const activePatternResult_4 = Type_StringLiteral_$007CString$007COther$007C(typ);
394
+ if (activePatternResult_4.tag === 0) {
395
+ return new GlueType(/* Literal */ 8, [new GlueLiteral(/* String */ 0, [activePatternResult_4.fields[0]])]);
396
+ }
397
+ else {
398
+ const activePatternResult_5 = Type_NumberLiteral_$007CInt$007CFloat$007COther$007C(typ);
399
+ switch (activePatternResult_5.tag) {
400
+ case 0:
401
+ return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Int */ 1, [activePatternResult_5.fields[0]])]);
402
+ case 1:
403
+ return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Float */ 2, [activePatternResult_5.fields[0]])]);
404
+ default:
405
+ return primitiveOfFlags(typ);
406
+ }
407
+ }
408
+ }
409
+ default:
410
+ return primitiveOfFlags(typ);
411
+ }
304
412
  }
305
413
  }
306
414