@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.3

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 (47) hide show
  1. package/README.md +16 -0
  2. package/dist/Glutinum.Converter/Abbreviations.js +9 -32
  3. package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
  4. package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
  5. package/dist/Glutinum.Converter/FsharpAST.js +116 -65
  6. package/dist/Glutinum.Converter/Generate.js +38 -25
  7. package/dist/Glutinum.Converter/GlueAST.js +79 -41
  8. package/dist/Glutinum.Converter/Hosting.js +141 -167
  9. package/dist/Glutinum.Converter/Merge.js +369 -337
  10. package/dist/Glutinum.Converter/Packages.js +391 -92
  11. package/dist/Glutinum.Converter/Printer.js +398 -387
  12. package/dist/Glutinum.Converter/Read.js +387 -88
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
  14. package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
  15. package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
  16. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
  17. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
  18. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
  19. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
  20. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
  21. package/dist/Glutinum.Converter/Reader/Node.js +8 -11
  22. package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
  23. package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
  24. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
  25. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
  26. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
  27. package/dist/Glutinum.Converter/Reader/Types.js +290 -15
  28. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
  29. package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
  30. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
  31. package/dist/Glutinum.Converter/Transform.js +3572 -8415
  32. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  33. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  34. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  35. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1149 -0
  36. package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
  37. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  38. package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
  39. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  40. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
  41. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  42. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -0
  43. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  44. package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
  45. package/dist/Glutinum.Converter/Utils/String.js +14 -3
  46. package/dist/Program.js +102 -239
  47. package/package.json +3 -2
@@ -1,35 +1,21 @@
1
1
 
2
+ import { ts } from "@ts-morph/bootstrap";
3
+ import { ambientModuleSpecifier, ambientModuleNames as ambientModuleNames_1, isMergedInterfaceDeclaration, promotedAmbientModule } from "./Reader/Utils.js";
4
+ import { FSharpSet__Contains, ofSeq } from "../fable_modules/fable-library-js.5.17.2/Set.js";
5
+ import { exists, sortBy, reverse, concat, partition, ofSeq as ofSeq_1, singleton, fold, collect, append, head as head_1, tail, isEmpty, filter, map, empty as empty_1, cons, foldBack, choose } from "../fable_modules/fable-library-js.5.17.2/List.js";
6
+ import { safeHash, stringHash, equals, comparePrimitives, compareArrays } from "../fable_modules/fable-library-js.5.17.2/Util.js";
7
+ import { ofSeq as ofSeq_2, toSeq, FSharpMap__Add, fold as fold_1, empty, add, tryFind } from "../fable_modules/fable-library-js.5.17.2/Map.js";
8
+ import { GlueClassDeclaration, GlueModuleDeclaration, GlueType, GlueFileModule } from "./GlueAST.js";
9
+ import { split, substring } from "../fable_modules/fable-library-js.5.17.2/String.js";
10
+ import { List_groupBy } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
11
+ import { addRangeInPlace, item } from "../fable_modules/fable-library-js.5.17.2/Array.js";
2
12
  import { TypeScriptReader_$ctor_26550FA4 } from "./Reader/TypeScriptReader.js";
3
- import { unwrap, value } from "../fable_modules/fable-library-js.5.17.2/Option.js";
4
- import { isMergedInterfaceDeclaration, promotedAmbientModule } from "./Reader/Utils.js";
13
+ import { unwrap, value as value_1 } from "../fable_modules/fable-library-js.5.17.2/Option.js";
5
14
  import { removeSurroundingQuotes } from "./Utils/Naming.js";
6
- import { exists, filter, sortBy, isEmpty, partition, collect, singleton, append, fold, empty as empty_1, cons, foldBack, choose, ofSeq } from "../fable_modules/fable-library-js.5.17.2/List.js";
7
- import { ts } from "@ts-morph/bootstrap";
8
- import { FSharpSet__Contains, ofSeq as ofSeq_1 } from "../fable_modules/fable-library-js.5.17.2/Set.js";
9
- import { comparePrimitives, equals, compareArrays } from "../fable_modules/fable-library-js.5.17.2/Util.js";
10
- import { empty, add, tryFind } from "../fable_modules/fable-library-js.5.17.2/Map.js";
11
- import { GlueFileModule, GlueType, GlueModuleDeclaration } from "./GlueAST.js";
15
+ import { PackageContext__TryFindPackage_Z721C83C5, PackageContext__IsImportable_Z384F8060, PackageContext__IsHoisted_32BC514A, PackageContext__SymbolSpecifiers_Z721C83C5, PackageContext__ImportSpecifier_Z721C83C5, PackageContext__FileModuleName_Z11793CAF, PackageContext__AmbientSpecifier_Z721C83C5, PackageContext__NestedAmbientModuleSegments_32BC514A } from "./Reader/Types.js";
12
16
  import { normalizePath } from "./Utils/String.js";
13
- import { addRangeInPlace } from "../fable_modules/fable-library-js.5.17.2/Array.js";
14
- import { PackageContext__TryFindPackage_Z721C83C5, PackageContext__FileModuleName_Z11793CAF, PackageContext__ImportSpecifier_Z721C83C5 } from "./Reader/Types.js";
15
17
  import { FSharpChoice$2 } from "../fable_modules/fable-library-js.5.17.2/Choice.js";
16
18
 
17
- export function readSourceFile(checker, sourceFile) {
18
- let moduleDeclaration;
19
- const reader = TypeScriptReader_$ctor_26550FA4(checker);
20
- const GlueAST = readStatements(reader, value(sourceFile));
21
- let ImportSpecifier;
22
- const option_1 = promotedAmbientModule(value(sourceFile));
23
- ImportSpecifier = ((option_1 != null) ? ((moduleDeclaration = option_1, removeSurroundingQuotes(moduleDeclaration.name.text))) : undefined);
24
- const Warnings = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
25
- return {
26
- GlueAST: GlueAST,
27
- ImportSpecifier: unwrap(ImportSpecifier),
28
- TypeMemory: ofSeq(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_TypeMemory"]()),
29
- Warnings: Warnings,
30
- };
31
- }
32
-
33
19
  function isScript(sourceFile) {
34
20
  if (!(ts.isExternalModule(sourceFile))) {
35
21
  return promotedAmbientModule(sourceFile) == null;
@@ -59,7 +45,7 @@ function declarationKey(glueType) {
59
45
  }
60
46
 
61
47
  function dropShadowedReExports(types) {
62
- const localKeys = ofSeq_1(choose((glueType) => {
48
+ const localKeys = ofSeq(choose((glueType) => {
63
49
  if (glueType.tag === 32) {
64
50
  return undefined;
65
51
  }
@@ -69,15 +55,36 @@ function dropShadowedReExports(types) {
69
55
  }, types), {
70
56
  Compare: (x, y) => (compareArrays(x, y) | 0),
71
57
  });
72
- return foldBack((glueType_1, tupledArg) => {
58
+ const localNames = ofSeq(choose((glueType_1) => {
59
+ if (glueType_1.tag === 32) {
60
+ return undefined;
61
+ }
62
+ else {
63
+ const option_1 = declarationKey(glueType_1);
64
+ if (option_1 != null) {
65
+ return option_1[1];
66
+ }
67
+ else {
68
+ return undefined;
69
+ }
70
+ }
71
+ }, types), {
72
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
73
+ });
74
+ return foldBack((glueType_2, tupledArg) => {
73
75
  let modulePath;
74
76
  const seen = tupledArg[0];
75
77
  const acc = tupledArg[1];
76
- if (glueType_1.tag === 32) {
77
- const reExport = glueType_1.fields[0];
78
+ if (glueType_2.tag === 32) {
79
+ const reExport = glueType_2.fields[0];
78
80
  const matchValue = declarationKey(reExport.Declaration);
79
81
  if (matchValue == null) {
80
- return [seen, cons(glueType_1, acc)];
82
+ if (FSharpSet__Contains(localNames, reExport.Name)) {
83
+ return [seen, acc];
84
+ }
85
+ else {
86
+ return [seen, cons(glueType_2, acc)];
87
+ }
81
88
  }
82
89
  else {
83
90
  const category = matchValue[0];
@@ -88,11 +95,11 @@ function dropShadowedReExports(types) {
88
95
  else {
89
96
  const matchValue_1 = tryFind(key, seen);
90
97
  if (matchValue_1 == null) {
91
- return [add(key, reExport.ModulePath, seen), cons(glueType_1, acc)];
98
+ return [add(key, reExport.ModulePath, seen), cons(glueType_2, acc)];
92
99
  }
93
100
  else if ((modulePath = matchValue_1, (category === "value") && equals(modulePath, reExport.ModulePath))) {
94
101
  const modulePath_1 = matchValue_1;
95
- return [seen, cons(glueType_1, acc)];
102
+ return [seen, cons(glueType_2, acc)];
96
103
  }
97
104
  else {
98
105
  return [seen, acc];
@@ -101,13 +108,48 @@ function dropShadowedReExports(types) {
101
108
  }
102
109
  }
103
110
  else {
104
- return [seen, cons(glueType_1, acc)];
111
+ return [seen, cons(glueType_2, acc)];
105
112
  }
106
113
  }, types, [empty({
107
- Compare: (x_1, y_1) => (compareArrays(x_1, y_1) | 0),
114
+ Compare: (x_2, y_2) => (compareArrays(x_2, y_2) | 0),
108
115
  }), empty_1()])[1];
109
116
  }
110
117
 
118
+ function nestByName(fileModules) {
119
+ return map((tupledArg) => {
120
+ let Types;
121
+ const head = tupledArg[0];
122
+ const group = tupledArg[1];
123
+ const ownModules = filter((fileModule_1) => (fileModule_1.Name === head), group);
124
+ let ownModule;
125
+ if (!isEmpty(ownModules)) {
126
+ const rest = tail(ownModules);
127
+ const first = head_1(ownModules);
128
+ ownModule = ((Types = dropShadowedReExports(append(first.Types, collect((_arg) => _arg.Types, rest))), new GlueFileModule(first.Name, first.ImportSpecifier, fold((acc, other) => fold_1(FSharpMap__Add, acc, other.SymbolSpecifiers), first.SymbolSpecifiers, rest), first.IsGlobal, first.HasRuntime, Types)));
129
+ }
130
+ else {
131
+ ownModule = undefined;
132
+ }
133
+ const nested = nestByName(map((fileModule_3) => (new GlueFileModule(substring(fileModule_3.Name, head.length + 1), fileModule_3.ImportSpecifier, fileModule_3.SymbolSpecifiers, fileModule_3.IsGlobal, fileModule_3.HasRuntime, fileModule_3.Types)), filter((fileModule_2) => (fileModule_2.Name !== head), group)));
134
+ if (ownModule == null) {
135
+ return new GlueType(/* FileModule */ 31, [new GlueFileModule(head, "", empty({
136
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
137
+ }), false, false, nested)]);
138
+ }
139
+ else if (isEmpty(nested)) {
140
+ const fileModule_4 = ownModule;
141
+ return new GlueType(/* FileModule */ 31, [fileModule_4]);
142
+ }
143
+ else {
144
+ const fileModule_5 = ownModule;
145
+ return new GlueType(/* FileModule */ 31, [new GlueFileModule(fileModule_5.Name, fileModule_5.ImportSpecifier, fileModule_5.SymbolSpecifiers, fileModule_5.IsGlobal, fileModule_5.HasRuntime, append(fileModule_5.Types, nested))]);
146
+ }
147
+ }, List_groupBy((fileModule) => item(0, split(fileModule.Name, ["."], undefined, 0)), fileModules, {
148
+ Equals: (x, y) => (x === y),
149
+ GetHashCode: (x) => (stringHash(x) | 0),
150
+ }));
151
+ }
152
+
111
153
  function extractGlobals(types) {
112
154
  return fold((tupledArg, glueType) => {
113
155
  const remaining = tupledArg[0];
@@ -175,7 +217,64 @@ function readStatements(reader, sourceFile) {
175
217
  default:
176
218
  return singleton(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](statement));
177
219
  }
178
- }, ofSeq(sourceFile.statements)));
220
+ }, ofSeq_1(sourceFile.statements)));
221
+ }
222
+
223
+ export function readSourceFile(checker, sourceFile) {
224
+ const reader = TypeScriptReader_$ctor_26550FA4(checker);
225
+ const GlueAST = readStatements(reader, value_1(sourceFile));
226
+ let ImportSpecifier;
227
+ const option = promotedAmbientModule(value_1(sourceFile));
228
+ let mapping;
229
+ const ambientModuleNames = ambientModuleNames_1(checker);
230
+ mapping = ((moduleDeclaration) => ambientModuleSpecifier(ambientModuleNames, moduleDeclaration));
231
+ const option_1 = option;
232
+ ImportSpecifier = ((option_1 != null) ? mapping(option_1) : undefined);
233
+ const Warnings = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
234
+ return {
235
+ GlueAST: GlueAST,
236
+ ImportSpecifier: unwrap(ImportSpecifier),
237
+ TypeMemory: ofSeq_1(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_TypeMemory"]()),
238
+ Warnings: Warnings,
239
+ };
240
+ }
241
+
242
+ function nestAmbientModules(packageContext, package$, fileName, types) {
243
+ const patternInput = partition((_arg) => {
244
+ if (_arg.tag === 11) {
245
+ const info = _arg.fields[0];
246
+ if (info.Name.startsWith("\"")) {
247
+ return true;
248
+ }
249
+ else {
250
+ return info.Name.startsWith("\'");
251
+ }
252
+ }
253
+ else {
254
+ return false;
255
+ }
256
+ }, types);
257
+ const patternInput_2 = partition((tupledArg_3) => isEmpty(tupledArg_3[0]), map((tupledArg_1) => {
258
+ const group = tupledArg_1[1];
259
+ return [tupledArg_1[0], head_1(group)[1], dropShadowedReExports(collect((tupledArg_2) => tupledArg_2[2], group))];
260
+ }, List_groupBy((tupledArg) => tupledArg[0], choose((_arg_1) => {
261
+ if (_arg_1.tag === 11) {
262
+ const info_1 = _arg_1.fields[0];
263
+ const name = removeSurroundingQuotes(info_1.Name);
264
+ return [PackageContext__NestedAmbientModuleSegments_32BC514A(packageContext, package$, fileName, name), PackageContext__AmbientSpecifier_Z721C83C5(packageContext, name), info_1.Types];
265
+ }
266
+ else {
267
+ return undefined;
268
+ }
269
+ }, patternInput[0]), {
270
+ Equals: equals,
271
+ GetHashCode: (x) => (safeHash(x) | 0),
272
+ })));
273
+ const own = patternInput_2[0];
274
+ const patternInput_3 = !isEmpty(own) ? (isEmpty(tail(own)) ? [head_1(own)[2], head_1(own)[1]] : [empty_1(), undefined]) : [empty_1(), undefined];
275
+ return [patternInput[1], append(patternInput_3[0], concat(map((tupledArg_4) => fold((types_3, segment) => singleton(new GlueType(/* FileModule */ 31, [new GlueFileModule(segment, tupledArg_4[1], empty({
276
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
277
+ }), false, package$.HasRuntime, types_3)])), tupledArg_4[2], reverse(tupledArg_4[0])), patternInput_2[1]))), patternInput_3[1]];
179
278
  }
180
279
 
181
280
  /**
@@ -184,61 +283,240 @@ function readStatements(reader, sourceFile) {
184
283
  */
185
284
  export function readPackages(checker, packageContext, sourceFiles) {
186
285
  const reader = TypeScriptReader_$ctor_26550FA4(checker, packageContext);
286
+ const ambientModules = ambientModuleNames_1(checker);
187
287
  const glueAst = collect((package$_2) => {
188
- let patternInput_3;
288
+ let package$;
289
+ let patternInput_5;
189
290
  const package$_1 = package$_2;
190
291
  const globals = [];
191
- const patternInput_2 = partition((_arg_1) => {
192
- if (_arg_1.tag === 1) {
292
+ const unexported = [];
293
+ const hoistedSpecifiers = [];
294
+ const hoistedTypes = [];
295
+ const withoutValues = (types) => choose((_arg) => {
296
+ let matchResult, info, info_1, glueType;
297
+ switch (_arg.tag) {
298
+ case 6:
299
+ case 2: {
300
+ matchResult = 1;
301
+ break;
302
+ }
303
+ case 12: {
304
+ matchResult = 0;
305
+ info = _arg.fields[0];
306
+ break;
307
+ }
308
+ case 25: {
309
+ switch (_arg.fields[0].tag) {
310
+ case 6:
311
+ case 2: {
312
+ matchResult = 1;
313
+ break;
314
+ }
315
+ default: {
316
+ matchResult = 3;
317
+ glueType = _arg;
318
+ }
319
+ }
320
+ break;
321
+ }
322
+ case 11: {
323
+ matchResult = 2;
324
+ info_1 = _arg.fields[0];
325
+ break;
326
+ }
327
+ default: {
328
+ matchResult = 3;
329
+ glueType = _arg;
330
+ }
331
+ }
332
+ switch (matchResult) {
333
+ case 0:
334
+ return new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(info.Documentation, info.FullName, info.Name, info.Constructors, info.Members, info.TypeParameters, info.HeritageClauses, false)]);
335
+ case 1:
336
+ return undefined;
337
+ case 2:
338
+ return new GlueType(/* ModuleDeclaration */ 11, [new GlueModuleDeclaration(info_1.Documentation, info_1.Name, info_1.IsTopLevel, info_1.IsNamespace, info_1.IsGlobal, info_1.IsRecursive, withoutValues(info_1.Types))]);
339
+ default:
340
+ return glueType;
341
+ }
342
+ }, types);
343
+ const patternInput_4 = partition((_arg_2) => {
344
+ if (_arg_2.tag === 1) {
193
345
  return false;
194
346
  }
195
347
  else {
196
348
  return true;
197
349
  }
198
- }, choose((sourceFile_2) => {
199
- const fileName = normalizePath(sourceFile_2.fileName);
200
- const patternInput = extractGlobals(readStatements(reader, sourceFile_2));
201
- const types_1 = patternInput[0];
350
+ }, choose((sourceFile_3) => {
351
+ let specifier, isUnexported;
352
+ const fileName_1 = normalizePath(sourceFile_3.fileName);
353
+ const patternInput = extractGlobals(readStatements(reader, sourceFile_3));
354
+ const types_3 = patternInput[0];
202
355
  addRangeInPlace(patternInput[1], globals);
203
- let importSpecifier;
204
- const matchValue_1 = promotedAmbientModule(sourceFile_2);
205
- if (matchValue_1 == null) {
206
- importSpecifier = PackageContext__ImportSpecifier_Z721C83C5(packageContext, fileName);
356
+ let promotedSpecifier;
357
+ const option_1 = promotedAmbientModule(sourceFile_3);
358
+ promotedSpecifier = ((option_1 != null) ? ambientModuleSpecifier(ambientModules, option_1) : undefined);
359
+ const moduleName = PackageContext__FileModuleName_Z11793CAF(packageContext, package$_1, fileName_1);
360
+ let patternInput_2;
361
+ if (ts.isExternalModule(sourceFile_3)) {
362
+ patternInput_2 = [empty_1(), types_3, undefined];
363
+ }
364
+ else if (isScript(sourceFile_3)) {
365
+ patternInput_2 = nestAmbientModules(packageContext, package$_1, fileName_1, types_3);
207
366
  }
208
367
  else {
209
- const moduleDeclaration = matchValue_1;
210
- importSpecifier = removeSurroundingQuotes(moduleDeclaration.name.text);
211
- }
212
- const fileModule = (types_2) => (new FSharpChoice$2(/* Choice2Of2 */ 1, [new GlueType(/* FileModule */ 31, [new GlueFileModule(PackageContext__FileModuleName_Z11793CAF(packageContext, package$_1, fileName), importSpecifier, false, package$_1.HasRuntime, types_2)])]));
213
- if (fileName === package$_1.EntryFile) {
214
- return new FSharpChoice$2(/* Choice1Of2 */ 0, [[types_1, isScript(sourceFile_2)]]);
215
- }
216
- else if (isScript(sourceFile_2)) {
217
- const patternInput_1 = partition((_arg) => {
218
- if (_arg.tag === 11) {
219
- const info = _arg.fields[0];
220
- if (info.Name.startsWith("\"")) {
221
- return true;
222
- }
223
- else {
224
- return info.Name.startsWith("\'");
225
- }
368
+ const patternInput_1 = nestAmbientModules(packageContext, package$_1, fileName_1, types_3);
369
+ patternInput_2 = [empty_1(), append(patternInput_1[0], patternInput_1[1]), patternInput_1[2]];
370
+ }
371
+ const types_4 = patternInput_2[1];
372
+ const scriptGlobals = patternInput_2[0];
373
+ const ownSpecifier_1 = patternInput_2[2];
374
+ const importSpecifier = (promotedSpecifier == null) ? ((ownSpecifier_1 == null) ? PackageContext__ImportSpecifier_Z721C83C5(packageContext, fileName_1) : ((specifier = ownSpecifier_1, specifier))) : ((specifier = promotedSpecifier, specifier));
375
+ const fileModule = (types_5) => (new FSharpChoice$2(/* Choice2Of2 */ 1, [new GlueType(/* FileModule */ 31, [new GlueFileModule(moduleName, importSpecifier, PackageContext__SymbolSpecifiers_Z721C83C5(packageContext, fileName_1), false, package$_1.HasRuntime, types_5)])]));
376
+ if (fileName_1 === package$_1.EntryFile) {
377
+ return new FSharpChoice$2(/* Choice1Of2 */ 0, [[append(scriptGlobals, types_4), isScript(sourceFile_3)]]);
378
+ }
379
+ else if (isScript(sourceFile_3)) {
380
+ addRangeInPlace(scriptGlobals, globals);
381
+ if (isEmpty(types_4)) {
382
+ return undefined;
383
+ }
384
+ else {
385
+ return fileModule(types_4);
386
+ }
387
+ }
388
+ else {
389
+ const patternInput_3 = partition((glueType_2) => {
390
+ const matchValue_2 = declarationKey((glueType_2.tag === 25) ? glueType_2.fields[0] : glueType_2);
391
+ if (matchValue_2 == null) {
392
+ return false;
226
393
  }
227
394
  else {
395
+ return PackageContext__IsHoisted_32BC514A(packageContext, package$_1, fileName_1, matchValue_2[1]);
396
+ }
397
+ }, (isUnexported = ((name) => {
398
+ if (PackageContext__IsImportable_Z384F8060(packageContext, fileName_1, name)) {
228
399
  return false;
229
400
  }
230
- }, types_1);
231
- const ambientModules = patternInput_1[0];
232
- addRangeInPlace(patternInput_1[1], globals);
233
- if (isEmpty(ambientModules)) {
401
+ else {
402
+ void (unexported.push(name));
403
+ return true;
404
+ }
405
+ }), choose((_arg_1) => {
406
+ let info_8;
407
+ let matchResult_1, info_5, info_6, info_7;
408
+ switch (_arg_1.tag) {
409
+ case 12: {
410
+ if (isUnexported(_arg_1.fields[0].Name)) {
411
+ matchResult_1 = 0;
412
+ info_5 = _arg_1.fields[0];
413
+ }
414
+ else {
415
+ matchResult_1 = 4;
416
+ }
417
+ break;
418
+ }
419
+ case 6: {
420
+ if (isUnexported(_arg_1.fields[0].Name)) {
421
+ matchResult_1 = 1;
422
+ info_6 = _arg_1.fields[0];
423
+ }
424
+ else {
425
+ matchResult_1 = 4;
426
+ }
427
+ break;
428
+ }
429
+ case 2: {
430
+ if (isUnexported(_arg_1.fields[0].Name)) {
431
+ matchResult_1 = 2;
432
+ info_7 = _arg_1.fields[0];
433
+ }
434
+ else {
435
+ matchResult_1 = 4;
436
+ }
437
+ break;
438
+ }
439
+ case 25: {
440
+ switch (_arg_1.fields[0].tag) {
441
+ case 6: {
442
+ if (isUnexported("default")) {
443
+ matchResult_1 = 3;
444
+ }
445
+ else {
446
+ matchResult_1 = 4;
447
+ }
448
+ break;
449
+ }
450
+ case 2: {
451
+ if (isUnexported("default")) {
452
+ matchResult_1 = 3;
453
+ }
454
+ else {
455
+ matchResult_1 = 4;
456
+ }
457
+ break;
458
+ }
459
+ default:
460
+ matchResult_1 = 4;
461
+ }
462
+ break;
463
+ }
464
+ default:
465
+ matchResult_1 = 4;
466
+ }
467
+ switch (matchResult_1) {
468
+ case 0:
469
+ return new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(info_5.Documentation, info_5.FullName, info_5.Name, info_5.Constructors, info_5.Members, info_5.TypeParameters, info_5.HeritageClauses, false)]);
470
+ case 1:
471
+ return undefined;
472
+ case 2:
473
+ return undefined;
474
+ case 3:
475
+ return undefined;
476
+ default: {
477
+ let matchResult_2, info_9, glueType_1;
478
+ if (_arg_1.tag === 11) {
479
+ if ((info_8 = _arg_1.fields[0], (!info_8.IsGlobal && !(info_8.Name.startsWith("\"") ? true : info_8.Name.startsWith("\'"))) && isUnexported(info_8.Name))) {
480
+ matchResult_2 = 0;
481
+ info_9 = _arg_1.fields[0];
482
+ }
483
+ else {
484
+ matchResult_2 = 1;
485
+ glueType_1 = _arg_1;
486
+ }
487
+ }
488
+ else {
489
+ matchResult_2 = 1;
490
+ glueType_1 = _arg_1;
491
+ }
492
+ switch (matchResult_2) {
493
+ case 0:
494
+ return new GlueType(/* ModuleDeclaration */ 11, [new GlueModuleDeclaration(info_9.Documentation, info_9.Name, info_9.IsTopLevel, info_9.IsNamespace, info_9.IsGlobal, info_9.IsRecursive, withoutValues(info_9.Types))]);
495
+ default:
496
+ return glueType_1;
497
+ }
498
+ }
499
+ }
500
+ }, types_4)));
501
+ const kept = patternInput_3[1];
502
+ const hoisted = patternInput_3[0];
503
+ if (!isEmpty(hoisted)) {
504
+ addRangeInPlace(toSeq(PackageContext__SymbolSpecifiers_Z721C83C5(packageContext, fileName_1)), hoistedSpecifiers);
505
+ addRangeInPlace(hoisted, hoistedTypes);
506
+ }
507
+ if (isEmpty(kept)) {
234
508
  return undefined;
235
509
  }
236
510
  else {
237
- return fileModule(ambientModules);
511
+ return fileModule(kept);
238
512
  }
239
513
  }
514
+ }, (package$ = package$_1, sortBy((sourceFile_2) => {
515
+ if (normalizePath(sourceFile_2.fileName) === package$.EntryFile) {
516
+ return 0;
517
+ }
240
518
  else {
241
- return fileModule(types_1);
519
+ return 1;
242
520
  }
243
521
  }, sortBy((sourceFile_1) => normalizePath(sourceFile_1.fileName), filter((sourceFile) => {
244
522
  const matchValue = PackageContext__TryFindPackage_Z721C83C5(packageContext, sourceFile.fileName);
@@ -246,43 +524,64 @@ export function readPackages(checker, packageContext, sourceFiles) {
246
524
  return false;
247
525
  }
248
526
  else {
249
- return matchValue.Dir === package$_1.Dir;
527
+ return matchValue.Dir === package$.Dir;
250
528
  }
251
529
  }, sourceFiles), {
252
530
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
253
- })));
254
- const entryTypes = patternInput_2[0];
255
- const entryIsGlobal = exists((_arg_2) => {
256
- if (_arg_2.tag === 1) {
531
+ }), {
532
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
533
+ }))));
534
+ const entryTypes = patternInput_4[0];
535
+ const entryIsGlobal = exists((_arg_3) => {
536
+ if (_arg_3.tag === 1) {
257
537
  return false;
258
538
  }
259
539
  else {
260
- return _arg_2.fields[0][1];
540
+ return _arg_3.fields[0][1];
261
541
  }
262
542
  }, entryTypes);
263
- const entryTypes_1 = collect((_arg_3) => {
264
- if (_arg_3.tag === 1) {
543
+ const entryTypes_1 = dropShadowedReExports(append(collect((_arg_4) => {
544
+ if (_arg_4.tag === 1) {
265
545
  return empty_1();
266
546
  }
267
547
  else {
268
- return _arg_3.fields[0][0];
548
+ return _arg_4.fields[0][0];
269
549
  }
270
- }, entryTypes);
271
- const fileModules_1 = choose((_arg_4) => {
272
- if (_arg_4.tag === 0) {
273
- return undefined;
550
+ }, entryTypes), ofSeq_1(hoistedTypes)));
551
+ const fileModules_2 = nestByName(choose((_arg_5) => {
552
+ let matchResult_3, fileModule_1;
553
+ if (_arg_5.tag === 1) {
554
+ if (_arg_5.fields[0].tag === 31) {
555
+ matchResult_3 = 0;
556
+ fileModule_1 = _arg_5.fields[0].fields[0];
557
+ }
558
+ else {
559
+ matchResult_3 = 1;
560
+ }
274
561
  }
275
562
  else {
276
- return _arg_4.fields[0];
563
+ matchResult_3 = 1;
277
564
  }
278
- }, patternInput_2[1]);
279
- patternInput_3 = [append(entryTypes_1, append((globals.length === 0) ? empty_1() : singleton(new GlueType(/* ModuleDeclaration */ 11, [new GlueModuleDeclaration(empty_1(), "global", false, false, true, false, ofSeq(globals))])), fileModules_1)), entryIsGlobal];
280
- return singleton(new GlueType(/* FileModule */ 31, [new GlueFileModule(package$_2.ModuleName, package$_2.RuntimeName, patternInput_3[1], package$_2.HasRuntime, patternInput_3[0])]));
565
+ switch (matchResult_3) {
566
+ case 0:
567
+ return fileModule_1;
568
+ default:
569
+ return undefined;
570
+ }
571
+ }, patternInput_4[1]));
572
+ const globalsModule = (globals.length === 0) ? empty_1() : singleton(new GlueType(/* ModuleDeclaration */ 11, [new GlueModuleDeclaration(empty_1(), "global", false, false, true, false, ofSeq_1(globals))]));
573
+ if (unexported.length > 0) {
574
+ void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(`${package$_1.RuntimeName}: ${unexported.length} declarations are not exported by any entry, they are generated as types only`));
575
+ }
576
+ patternInput_5 = [append(entryTypes_1, append(globalsModule, fileModules_2)), entryIsGlobal, ofSeq_2(hoistedSpecifiers, {
577
+ Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
578
+ })];
579
+ return singleton(new GlueType(/* FileModule */ 31, [new GlueFileModule(package$_2.ModuleName, package$_2.RuntimeName, patternInput_5[2], patternInput_5[1], package$_2.HasRuntime, patternInput_5[0])]));
281
580
  }, packageContext.Packages);
282
581
  const Warnings = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]();
283
582
  return {
284
583
  GlueAST: glueAst,
285
- TypeMemory: ofSeq(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_TypeMemory"]()),
584
+ TypeMemory: ofSeq_1(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_TypeMemory"]()),
286
585
  Warnings: Warnings,
287
586
  };
288
587
  }
@@ -1,8 +1,8 @@
1
1
 
2
- import { map, choose, partition } from "../../fable_modules/fable-library-js.5.17.2/List.js";
2
+ import { filter, map, choose, partition } from "../../fable_modules/fable-library-js.5.17.2/List.js";
3
3
  import { toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
4
4
  import { GlueType, GlueClassDeclaration, GlueConstructor } from "../GlueAST.js";
5
- import { isExportAssignmentTarget, isExportedDeclaration, readHeritageClauses, getFullNameOrEmpty, ModifierUtil_HasModifier_742AC9D } from "./Utils.js";
5
+ import { isExportAssignmentTarget, isExportedDeclaration, readHeritageClauses, getFullNameOrEmpty, isDefaultInExportList, ModifierUtil_HasModifier_742AC9D } from "./Utils.js";
6
6
  import { singleton } from "../../fable_modules/fable-library-js.5.17.2/Set.js";
7
7
  import { comparePrimitives } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
8
8
 
@@ -25,8 +25,8 @@ export function readClassDeclaration(reader, classDeclaration) {
25
25
  return undefined;
26
26
  }
27
27
  }, patternInput[0]);
28
- const members_2 = map((declaration) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration), toList(patternInput[1]));
29
- const isDefaultExport = ModifierUtil_HasModifier_742AC9D(classDeclaration.modifiers, 90);
28
+ const members_2 = map((declaration) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration), filter((classElement) => !ModifierUtil_HasModifier_742AC9D(classElement.modifiers, 124), patternInput[1]));
29
+ const isDefaultExport = ModifierUtil_HasModifier_742AC9D(classDeclaration.modifiers, 90) ? true : isDefaultInExportList(classDeclaration, name.getText());
30
30
  const classDeclaration_1 = new GlueType(/* ClassDeclaration */ 12, [new GlueClassDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](classDeclaration), getFullNameOrEmpty(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), classDeclaration), name.getText(), constructors_1, members_2, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](classDeclaration.typeParameters), readHeritageClauses(reader, classDeclaration.heritageClauses), (isDefaultExport ? true : isExportedDeclaration(classDeclaration, singleton(name.getText(), {
31
31
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
32
32
  }))) ? true : isExportAssignmentTarget(classDeclaration, singleton(name.getText(), {