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

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 (155) hide show
  1. package/README.md +16 -0
  2. package/dist/Glutinum.Converter/Abbreviations.js +16 -39
  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 +117 -66
  6. package/dist/Glutinum.Converter/Generate.js +52 -26
  7. package/dist/Glutinum.Converter/GlueAST.js +85 -46
  8. package/dist/Glutinum.Converter/Hosting.js +148 -174
  9. package/dist/Glutinum.Converter/Merge.js +463 -355
  10. package/dist/Glutinum.Converter/Packages.js +387 -97
  11. package/dist/Glutinum.Converter/Printer.js +439 -400
  12. package/dist/Glutinum.Converter/Read.js +362 -100
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
  14. package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
  15. package/dist/Glutinum.Converter/Reader/Declaration.js +13 -19
  16. package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
  17. package/dist/Glutinum.Converter/Reader/Documentation.js +28 -40
  18. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +2 -2
  19. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +104 -37
  20. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +24 -39
  21. package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
  22. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +30 -17
  23. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +16 -22
  24. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +49 -6
  25. package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
  26. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +4 -4
  27. package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
  28. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +54 -6
  29. package/dist/Glutinum.Converter/Reader/Node.js +11 -14
  30. package/dist/Glutinum.Converter/Reader/Parameters.js +39 -30
  31. package/dist/Glutinum.Converter/Reader/Report.js +4 -4
  32. package/dist/Glutinum.Converter/Reader/TypeNode.js +390 -1584
  33. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +80 -53
  34. package/dist/Glutinum.Converter/Reader/TypeParameters.js +2 -2
  35. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +24 -47
  36. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +24 -6
  37. package/dist/Glutinum.Converter/Reader/Types.js +297 -17
  38. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +16 -30
  39. package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
  40. package/dist/Glutinum.Converter/Reader/Utils.js +497 -111
  41. package/dist/Glutinum.Converter/Reader/VariableStatement.js +7 -8
  42. package/dist/Glutinum.Converter/Transform.js +2915 -8180
  43. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  44. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  45. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  46. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1087 -0
  47. package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
  48. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  49. package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
  50. package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
  51. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  52. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
  53. package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
  54. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  55. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +338 -0
  56. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  57. package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
  58. package/dist/Glutinum.Converter/Utils/Keywords.js +3 -3
  59. package/dist/Glutinum.Converter/Utils/List.js +2 -2
  60. package/dist/Glutinum.Converter/Utils/Naming.js +6 -6
  61. package/dist/Glutinum.Converter/Utils/String.js +16 -5
  62. package/dist/Program.js +104 -241
  63. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +2 -2
  64. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +4 -4
  65. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +2 -2
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +5 -5
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +4 -4
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +3 -3
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +1 -1
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +3 -3
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +1 -1
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +1 -1
  73. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +4 -4
  74. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +1 -1
  75. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +3 -3
  76. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +1 -1
  77. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +1 -1
  78. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +1 -1
  79. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +2 -2
  80. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +2 -2
  81. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +1 -1
  82. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +7 -7
  83. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +1 -1
  84. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Async.js +21 -7
  85. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/AsyncBuilder.js +51 -6
  86. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/CHANGELOG.md +23 -1
  87. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/CollectionUtil.js +10 -16
  88. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MailboxProcessor.js +19 -3
  89. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MutableMap.js +5 -1
  90. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MutableSet.js +5 -1
  91. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Util.js +15 -3
  92. package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/package.json +1 -1
  93. package/package.json +3 -2
  94. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Array.js +0 -0
  95. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/BigInt.js +0 -0
  96. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/BitConverter.js +0 -0
  97. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Boolean.js +0 -0
  98. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Char.js +0 -0
  99. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Choice.js +0 -0
  100. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/ConditionalWeakTable.js +0 -0
  101. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Date.js +0 -0
  102. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOffset.js +0 -0
  103. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOnly.js +0 -0
  104. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOnlyTemporal.js +0 -0
  105. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeFormat.js +0 -0
  106. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeOffsetTemporal.js +0 -0
  107. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeTemporal.js +0 -0
  108. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Decimal.js +0 -0
  109. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Directory.js +0 -0
  110. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Double.js +0 -0
  111. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Encoding.js +0 -0
  112. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Environment.js +0 -0
  113. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Event.js +0 -0
  114. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Collections.js +0 -0
  115. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Core.CompilerServices.js +0 -0
  116. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Core.js +0 -0
  117. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/File.js +0 -0
  118. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Global.js +0 -0
  119. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Guid.js +0 -0
  120. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Int32.js +0 -0
  121. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/List.js +0 -0
  122. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Long.js +0 -0
  123. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Map.js +0 -0
  124. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MapUtil.js +0 -0
  125. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Native.js +0 -0
  126. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Numeric.js +0 -0
  127. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Observable.js +0 -0
  128. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Option.js +0 -0
  129. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Path.js +0 -0
  130. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/README.md +0 -0
  131. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Random.js +0 -0
  132. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Range.js +0 -0
  133. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Reflection.js +0 -0
  134. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/RegExp.js +0 -0
  135. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Result.js +0 -0
  136. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Seq.js +0 -0
  137. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Seq2.js +0 -0
  138. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Set.js +0 -0
  139. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/String.js +0 -0
  140. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.Collections.Generic.js +0 -0
  141. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.Text.js +0 -0
  142. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.js +0 -0
  143. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Task.js +0 -0
  144. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TaskBuilder.js +0 -0
  145. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeOnly.js +0 -0
  146. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeOnlyTemporal.js +0 -0
  147. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeSpan.js +0 -0
  148. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeSpanTemporal.js +0 -0
  149. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Timer.js +0 -0
  150. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Types.js +0 -0
  151. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Unicode.13.0.0.js +0 -0
  152. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Uri.js +0 -0
  153. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/big.d.ts +0 -0
  154. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/lib/big.js +0 -0
  155. /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/quotation.js +0 -0
@@ -1,17 +1,19 @@
1
1
 
2
- import { Record } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
3
- import { lambda_type, option_type, record_type, list_type, tuple_type, bool_type, string_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
4
- import { normalizePath } from "../Utils/String.js";
5
- import { tryFind, cons, head, tail, empty as empty_1, isEmpty, reverse, map, ofArray, exists, tryPick, filter, tryHead } from "../../fable_modules/fable-library-js.5.17.2/List.js";
6
- import { split, join, substring } from "../../fable_modules/fable-library-js.5.17.2/String.js";
7
- import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
2
+ import { Record } from "../../fable_modules/fable-library-js.5.21.0/Types.js";
3
+ import { array_type, lambda_type, option_type, record_type, class_type, list_type, tuple_type, bool_type, string_type } from "../../fable_modules/fable-library-js.5.21.0/Reflection.js";
8
4
  import { sanitizeTypeName } from "../Utils/Naming.js";
9
- import { replace } from "../../fable_modules/fable-library-js.5.17.2/RegExp.js";
10
- import { equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
11
- import { defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
5
+ import { substring, split, join } from "../../fable_modules/fable-library-js.5.21.0/String.js";
6
+ import { FSharpSet__Contains } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
7
+ import { choose, tryFind, skip, take, length, cons, head, tail, empty as empty_1, isEmpty, reverse, exists, tryPick, tryHead, ofArray, filter, map } from "../../fable_modules/fable-library-js.5.21.0/List.js";
8
+ import { withoutDeclarationExtension, normalizePath } from "../Utils/String.js";
9
+ import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
10
+ import { toList as toList_1, ofList, map as map_2, empty as empty_2, add, fold, FSharpMap__ContainsKey, FSharpMap__TryFind } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
11
+ import { map as map_1 } from "../../fable_modules/fable-library-js.5.21.0/Array.js";
12
+ import { comparePrimitives, equals } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
13
+ import { defaultArg } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
12
14
 
13
15
  export class PackageInfo extends Record {
14
- constructor(ModuleName, RuntimeName, HasRuntime, Dir, TypesRoot, EntryFile, SubpathEntries) {
16
+ constructor(ModuleName, RuntimeName, HasRuntime, Dir, TypesRoot, EntryFile, SubpathEntries, ReExportedSymbols, ReExportedFiles, ReExportedNames, DefaultExportNames, HasExportsMap, HoistableDeclarations, AmbientModuleFiles) {
15
17
  super();
16
18
  this.ModuleName = ModuleName;
17
19
  this.RuntimeName = RuntimeName;
@@ -20,11 +22,18 @@ export class PackageInfo extends Record {
20
22
  this.TypesRoot = TypesRoot;
21
23
  this.EntryFile = EntryFile;
22
24
  this.SubpathEntries = SubpathEntries;
25
+ this.ReExportedSymbols = ReExportedSymbols;
26
+ this.ReExportedFiles = ReExportedFiles;
27
+ this.ReExportedNames = ReExportedNames;
28
+ this.DefaultExportNames = DefaultExportNames;
29
+ this.HasExportsMap = HasExportsMap;
30
+ this.HoistableDeclarations = HoistableDeclarations;
31
+ this.AmbientModuleFiles = AmbientModuleFiles;
23
32
  }
24
33
  }
25
34
 
26
35
  export function PackageInfo_$reflection() {
27
- return record_type("Glutinum.Converter.Reader.Types.PackageInfo", [], PackageInfo, () => [["ModuleName", string_type], ["RuntimeName", string_type], ["HasRuntime", bool_type], ["Dir", string_type], ["TypesRoot", string_type], ["EntryFile", string_type], ["SubpathEntries", list_type(tuple_type(string_type, string_type))]]);
36
+ return record_type("Glutinum.Converter.Reader.Types.PackageInfo", [], PackageInfo, () => [["ModuleName", string_type], ["RuntimeName", string_type], ["HasRuntime", bool_type], ["Dir", string_type], ["TypesRoot", string_type], ["EntryFile", string_type], ["SubpathEntries", list_type(tuple_type(string_type, string_type))], ["ReExportedSymbols", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [tuple_type(string_type, string_type), string_type])], ["ReExportedFiles", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, string_type])], ["ReExportedNames", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, string_type])], ["DefaultExportNames", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, string_type])], ["HasExportsMap", bool_type], ["HoistableDeclarations", class_type("Microsoft.FSharp.Collections.FSharpSet`1", [tuple_type(string_type, string_type)])], ["AmbientModuleFiles", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, string_type])]]);
28
37
  }
29
38
 
30
39
  /**
@@ -43,17 +52,53 @@ export function ExternalPackage_$reflection() {
43
52
  return record_type("Glutinum.Converter.Reader.Types.ExternalPackage", [], ExternalPackage, () => [["ModuleName", string_type], ["Package", option_type(PackageInfo_$reflection())], ["LibFilePrefixes", list_type(string_type)]]);
44
53
  }
45
54
 
55
+ function moduleNameOfSegment(segment) {
56
+ return sanitizeTypeName(join("_", split(segment, ["-", ".", " "], undefined, 1)));
57
+ }
58
+
59
+ /**
60
+ * `node:fs` when the program declares that alias of `fs`, the specifier Node documents
61
+ */
62
+ export function ambientSpecifier(ambientModuleNames, name) {
63
+ if (!name.startsWith("node:") && FSharpSet__Contains(ambientModuleNames, "node:" + name)) {
64
+ return "node:" + name;
65
+ }
66
+ else {
67
+ return name;
68
+ }
69
+ }
70
+
46
71
  export class PackageContext extends Record {
47
- constructor(Packages, Externals, IsLibraryName) {
72
+ constructor(Packages, Externals, IsLibraryName, AmbientModuleNames) {
48
73
  super();
49
74
  this.Packages = Packages;
50
75
  this.Externals = Externals;
51
76
  this.IsLibraryName = IsLibraryName;
77
+ this.AmbientModuleNames = AmbientModuleNames;
52
78
  }
53
79
  }
54
80
 
55
81
  export function PackageContext_$reflection() {
56
- return record_type("Glutinum.Converter.Reader.Types.PackageContext", [], PackageContext, () => [["Packages", list_type(PackageInfo_$reflection())], ["Externals", list_type(ExternalPackage_$reflection())], ["IsLibraryName", lambda_type(string_type, bool_type)]]);
82
+ return record_type("Glutinum.Converter.Reader.Types.PackageContext", [], PackageContext, () => [["Packages", list_type(PackageInfo_$reflection())], ["Externals", list_type(ExternalPackage_$reflection())], ["IsLibraryName", lambda_type(string_type, bool_type)], ["AmbientModuleNames", class_type("Microsoft.FSharp.Collections.FSharpSet`1", [string_type])]]);
83
+ }
84
+
85
+ export function PackageContext__AmbientSpecifier_Z721C83C5(this$, name) {
86
+ return ambientSpecifier(this$.AmbientModuleNames, name);
87
+ }
88
+
89
+ /**
90
+ * The F# modules of an ambient module, spelled as its specifier is: `node:stream/web` is
91
+ * `stream.web`, `dayjs/locale/*` of the package `dayjs` is `locale`
92
+ */
93
+ export function PackageContext__AmbientModuleSegments_Z11793CAF(this$, package$, specifier) {
94
+ return map(moduleNameOfSegment, filter((segment) => {
95
+ if (segment !== "") {
96
+ return segment !== "*";
97
+ }
98
+ else {
99
+ return false;
100
+ }
101
+ }, ofArray(split(specifier.startsWith("node:") ? substring(specifier, "node:".length) : (specifier.startsWith(package$.RuntimeName + "/") ? substring(specifier, package$.RuntimeName.length + 1) : specifier), ["/"], undefined, 0))));
57
102
  }
58
103
 
59
104
  export function PackageContext__TryFindPackage_Z721C83C5(this$, fileName) {
@@ -107,6 +152,11 @@ export function PackageContext__TryFindExternalModulePath_Z55EFCE8F(this$, fileN
107
152
  }, this$.Externals);
108
153
  }
109
154
 
155
+ export function PackageContext__IsExternalLibFile_Z721C83C5(this$, fileName) {
156
+ const fileName_1 = normalizePath(fileName);
157
+ return exists((external) => exists((prefix) => (fileName_1.indexOf(prefix) >= 0), external.LibFilePrefixes), this$.Externals);
158
+ }
159
+
110
160
  export function PackageContext__IsExternal_Z721C83C5(this$, fileName) {
111
161
  if (PackageContext__TryFindPackage_Z721C83C5(this$, fileName) == null) {
112
162
  return PackageContext__TryFindExternalModulePath_Z721C83C5(this$, fileName) == null;
@@ -116,10 +166,94 @@ export function PackageContext__IsExternal_Z721C83C5(this$, fileName) {
116
166
  }
117
167
  }
118
168
 
169
+ /**
170
+ * Whether the root entry exports the declaration: it belongs to the package module, the
171
+ * file declaring it is an implementation detail
172
+ */
173
+ export function PackageContext__IsHoisted_32BC514A(this$, package$, fileName, name) {
174
+ return FSharpSet__Contains(package$.HoistableDeclarations, [normalizePath(fileName), name]);
175
+ }
176
+
177
+ /**
178
+ * The subpath a public entry exports the declarations of the file from, when there is one
179
+ */
180
+ export function PackageContext__SubpathOf_Z11793CAF(this$, package$, fileName) {
181
+ const fileName_1 = normalizePath(fileName);
182
+ const option_1 = tryPick((tupledArg) => {
183
+ if (tupledArg[0] === fileName_1) {
184
+ return tupledArg[1];
185
+ }
186
+ else {
187
+ return undefined;
188
+ }
189
+ }, package$.SubpathEntries);
190
+ if (option_1 != null) {
191
+ return option_1;
192
+ }
193
+ else {
194
+ return FSharpMap__TryFind(package$.ReExportedFiles, fileName_1);
195
+ }
196
+ }
197
+
119
198
  export function PackageContext__FileModuleName_Z11793CAF(this$, package$, fileName) {
120
- let matchValue, rest, withoutExtension, isSubpathEntry;
199
+ let matchValue_2, rest, withoutExtension, isSubpathEntry;
121
200
  const fileName_1 = normalizePath(fileName);
122
- return sanitizeTypeName(join("_", map((segment_1) => join("_", split(segment_1, ["-", ".", " "], undefined, 1)), (matchValue = reverse(filter((segment) => (segment !== ""), ofArray(split(fileName_1.startsWith(package$.TypesRoot) ? substring(fileName_1, package$.TypesRoot.length) : substring(fileName_1, package$.Dir.length), ["/"], undefined, 0)))), isEmpty(matchValue) ? empty_1() : ((rest = tail(matchValue), (withoutExtension = replace(head(matchValue), "\\.d\\.[cm]?ts$", ""), (isSubpathEntry = exists((tupledArg) => (tupledArg[0] === fileName_1), package$.SubpathEntries), ((withoutExtension === "index") && !isEmpty(rest)) ? reverse(rest) : ((equals(tryHead(rest), withoutExtension) && isSubpathEntry) ? reverse(rest) : reverse(cons(withoutExtension, rest)))))))))));
201
+ let fromAmbientModule;
202
+ const option_1 = FSharpMap__TryFind(package$.AmbientModuleFiles, fileName_1);
203
+ fromAmbientModule = ((option_1 != null) ? join(".", PackageContext__AmbientModuleSegments_Z11793CAF(this$, package$, option_1)) : undefined);
204
+ let fromSubpath;
205
+ const matchValue = PackageContext__SubpathOf_Z11793CAF(this$, package$, fileName_1);
206
+ let matchResult, name, subpath_1;
207
+ if (fromAmbientModule == null) {
208
+ if (matchValue != null) {
209
+ if (matchValue !== "") {
210
+ matchResult = 1;
211
+ subpath_1 = matchValue;
212
+ }
213
+ else {
214
+ matchResult = 2;
215
+ }
216
+ }
217
+ else {
218
+ matchResult = 2;
219
+ }
220
+ }
221
+ else {
222
+ matchResult = 0;
223
+ name = fromAmbientModule;
224
+ }
225
+ switch (matchResult) {
226
+ case 0: {
227
+ fromSubpath = name;
228
+ break;
229
+ }
230
+ case 1: {
231
+ fromSubpath = join(".", map_1((segment) => sanitizeTypeName(join("_", split(segment, ["-", ".", " "], undefined, 1))), split(subpath_1, ["/"], undefined, 0)));
232
+ break;
233
+ }
234
+ default:
235
+ fromSubpath = undefined;
236
+ }
237
+ if (fromSubpath == null) {
238
+ return join(".", map(moduleNameOfSegment, (matchValue_2 = reverse(filter((segment_1) => (segment_1 !== ""), ofArray(split(fileName_1.startsWith(package$.TypesRoot) ? substring(fileName_1, package$.TypesRoot.length) : substring(fileName_1, package$.Dir.length), ["/"], undefined, 0)))), isEmpty(matchValue_2) ? empty_1() : ((rest = tail(matchValue_2), (withoutExtension = withoutDeclarationExtension(head(matchValue_2)), (isSubpathEntry = exists((tupledArg) => (tupledArg[0] === fileName_1), package$.SubpathEntries), ((withoutExtension === "index") && !isEmpty(rest)) ? reverse(rest) : ((equals(tryHead(rest), withoutExtension) && isSubpathEntry) ? reverse(rest) : reverse(cons(withoutExtension, rest))))))))));
239
+ }
240
+ else {
241
+ return fromSubpath;
242
+ }
243
+ }
244
+
245
+ /**
246
+ * The F# modules of `declare module "util/types"` under the module of its file `util`
247
+ */
248
+ export function PackageContext__NestedAmbientModuleSegments_32BC514A(this$, package$, fileName, name) {
249
+ const segments = PackageContext__AmbientModuleSegments_Z11793CAF(this$, package$, PackageContext__AmbientSpecifier_Z721C83C5(this$, name));
250
+ const fileSegments = ofArray(split(PackageContext__FileModuleName_Z11793CAF(this$, package$, fileName), ["."], undefined, 0));
251
+ if ((length(segments) >= length(fileSegments)) && equals(take(length(fileSegments), segments), fileSegments)) {
252
+ return skip(length(fileSegments), segments);
253
+ }
254
+ else {
255
+ return segments;
256
+ }
123
257
  }
124
258
 
125
259
  /**
@@ -133,11 +267,19 @@ export function PackageContext__ModulePath_Z721C83C5(this$, fileName) {
133
267
  * `includeFile = false` gives the package module only, where its globals are
134
268
  */
135
269
  export function PackageContext__ModulePath_Z55EFCE8F(this$, fileName, includeFile) {
270
+ return PackageContext__ModulePath_Z7E147617(this$, fileName, includeFile, undefined);
271
+ }
272
+
273
+ /**
274
+ * `name` is the declaration at the top of the file the reference lands in
275
+ */
276
+ export function PackageContext__ModulePath_Z7E147617(this$, fileName, includeFile, name) {
136
277
  const matchValue = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
137
278
  if (matchValue != null) {
138
279
  const package$ = matchValue;
139
280
  const fileName_1 = normalizePath(fileName);
140
- return toList(delay(() => append(singleton(package$.ModuleName), delay(() => ((includeFile && (fileName_1 !== package$.EntryFile)) ? singleton(PackageContext__FileModuleName_Z11793CAF(this$, package$, fileName_1)) : empty())))));
281
+ const isHoisted = (name == null) ? false : PackageContext__IsHoisted_32BC514A(this$, package$, fileName_1, name);
282
+ return toList(delay(() => append(singleton(package$.ModuleName), delay(() => (((includeFile && (fileName_1 !== package$.EntryFile)) && !isHoisted) ? singleton(PackageContext__FileModuleName_Z11793CAF(this$, package$, fileName_1)) : empty())))));
141
283
  }
142
284
  else {
143
285
  return defaultArg(PackageContext__TryFindExternalModulePath_Z55EFCE8F(this$, fileName, includeFile), empty_1());
@@ -166,7 +308,17 @@ export function PackageContext__ImportSpecifier_Z721C83C5(this$, fileName) {
166
308
  else {
167
309
  const matchValue_1 = tryFind((tupledArg) => (tupledArg[0] === fileName_1), package$.SubpathEntries);
168
310
  if (matchValue_1 == null) {
169
- return ((package$.RuntimeName + "/") + replace(substring(fileName_1, package$.Dir.length), "\\.d\\.[cm]?ts$", "")) + ".js";
311
+ const matchValue_2 = FSharpMap__TryFind(package$.ReExportedFiles, fileName_1);
312
+ if (matchValue_2 == null) {
313
+ return ((package$.RuntimeName + "/") + withoutDeclarationExtension(substring(fileName_1, package$.Dir.length))) + ".js";
314
+ }
315
+ else if (matchValue_2 === "") {
316
+ return package$.RuntimeName;
317
+ }
318
+ else {
319
+ const subpath_1 = matchValue_2;
320
+ return (package$.RuntimeName + "/") + subpath_1;
321
+ }
170
322
  }
171
323
  else {
172
324
  return (package$.RuntimeName + "/") + matchValue_1[1];
@@ -178,3 +330,131 @@ export function PackageContext__ImportSpecifier_Z721C83C5(this$, fileName) {
178
330
  }
179
331
  }
180
332
 
333
+ /**
334
+ * Whether a public entry of the package re-exports a declaration of the file
335
+ */
336
+ export function PackageContext__IsReExported_Z721C83C5(this$, fileName) {
337
+ const matchValue = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
338
+ if (matchValue != null) {
339
+ const package$ = matchValue;
340
+ const fileName_1 = normalizePath(fileName);
341
+ if ((fileName_1 === package$.EntryFile) ? true : exists((tupledArg) => (tupledArg[0] === fileName_1), package$.SubpathEntries)) {
342
+ return true;
343
+ }
344
+ else {
345
+ return FSharpMap__ContainsKey(package$.ReExportedFiles, fileName_1);
346
+ }
347
+ }
348
+ else {
349
+ return true;
350
+ }
351
+ }
352
+
353
+ /**
354
+ * Whether a specifier can import the declaration at runtime: the `exports` map of a package
355
+ * blocks the file declaring it unless a public entry exports the name
356
+ */
357
+ export function PackageContext__IsImportable_Z384F8060(this$, fileName, name) {
358
+ const matchValue = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
359
+ if (matchValue != null) {
360
+ if (!matchValue.HasExportsMap) {
361
+ const package$_1 = matchValue;
362
+ return true;
363
+ }
364
+ else {
365
+ const package$_2 = matchValue;
366
+ const fileName_1 = normalizePath(fileName);
367
+ if ((fileName_1 === package$_2.EntryFile) ? true : exists((tupledArg) => (tupledArg[0] === fileName_1), package$_2.SubpathEntries)) {
368
+ return true;
369
+ }
370
+ else if (name === "default") {
371
+ return FSharpMap__ContainsKey(package$_2.DefaultExportNames, fileName_1);
372
+ }
373
+ else if (FSharpMap__ContainsKey(package$_2.ReExportedSymbols, [fileName_1, name])) {
374
+ return true;
375
+ }
376
+ else {
377
+ return FSharpMap__ContainsKey(package$_2.ReExportedNames, name);
378
+ }
379
+ }
380
+ }
381
+ else {
382
+ return true;
383
+ }
384
+ }
385
+
386
+ /**
387
+ * The name a public entry exports the default export of the file under
388
+ */
389
+ export function PackageContext__DefaultExportName_Z721C83C5(this$, fileName) {
390
+ const option_1 = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
391
+ if (option_1 != null) {
392
+ return FSharpMap__TryFind(option_1.DefaultExportNames, normalizePath(fileName));
393
+ }
394
+ else {
395
+ return undefined;
396
+ }
397
+ }
398
+
399
+ /**
400
+ * The declarations of the file a public entry re-exports, with the specifier to import each
401
+ * of them from
402
+ */
403
+ export function PackageContext__SymbolSpecifiers_Z721C83C5(this$, fileName) {
404
+ const matchValue = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
405
+ if (matchValue != null) {
406
+ const package$ = matchValue;
407
+ const fileName_1 = normalizePath(fileName);
408
+ const specifierOf = (subpath) => {
409
+ if (subpath === "") {
410
+ return package$.RuntimeName;
411
+ }
412
+ else {
413
+ return (package$.RuntimeName + "/") + subpath;
414
+ }
415
+ };
416
+ return fold((acc, name_1, specifier) => add(name_1, specifier, acc), PackageContext__IsReExported_Z721C83C5(this$, fileName_1) ? empty_2({
417
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
418
+ }) : map_2((_arg, subpath_1) => specifierOf(subpath_1), package$.ReExportedNames), ofList(choose((tupledArg) => {
419
+ const _arg_1 = tupledArg[0];
420
+ if (_arg_1[0] === fileName_1) {
421
+ return [_arg_1[1], specifierOf(tupledArg[1])];
422
+ }
423
+ else {
424
+ return undefined;
425
+ }
426
+ }, toList_1(package$.ReExportedSymbols)), {
427
+ Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
428
+ }));
429
+ }
430
+ else {
431
+ return empty_2({
432
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
433
+ });
434
+ }
435
+ }
436
+
437
+ /**
438
+ * The declarations being read, so that one reaching itself through its members is detected
439
+ */
440
+ export class ReadInProgress extends Record {
441
+ constructor(Intersections, Expansions, Partials, KeyOfDeclarations, TypeQueryDeclarations, UnionAliases, Landing) {
442
+ super();
443
+ this.Intersections = Intersections;
444
+ this.Expansions = Expansions;
445
+ this.Partials = Partials;
446
+ this.KeyOfDeclarations = KeyOfDeclarations;
447
+ this.TypeQueryDeclarations = TypeQueryDeclarations;
448
+ this.UnionAliases = UnionAliases;
449
+ this.Landing = Landing;
450
+ }
451
+ }
452
+
453
+ export function ReadInProgress_$reflection() {
454
+ return record_type("Glutinum.Converter.Reader.Types.ReadInProgress", [], ReadInProgress, () => [["Intersections", array_type(class_type("TypeScript.Ts.Type"))], ["Expansions", array_type(class_type("TypeScript.Ts.Type"))], ["Partials", array_type(class_type("TypeScript.Ts.Type"))], ["KeyOfDeclarations", array_type(class_type("TypeScript.Ts.Node"))], ["TypeQueryDeclarations", array_type(class_type("TypeScript.Ts.Node"))], ["UnionAliases", array_type(class_type("TypeScript.Ts.Node"))], ["Landing", array_type(class_type("TypeScript.Ts.Node"))]]);
455
+ }
456
+
457
+ export function ReadInProgress_Create() {
458
+ return new ReadInProgress([], [], [], [], [], [], []);
459
+ }
460
+
@@ -1,30 +1,15 @@
1
1
 
2
+ import { map, isEmpty, singleton, choose, concat } from "../../fable_modules/fable-library-js.5.21.0/List.js";
2
3
  import { ts } from "@ts-morph/bootstrap";
3
- import { map, isEmpty, singleton, choose, concat } from "../../fable_modules/fable-library-js.5.17.2/List.js";
4
- import { modulePathForSymbol, isExternalToPackages, isFromEs5Lib, $007CHasTypeFlags$007C_$007C, symbolAtLocation, tryReadLiteral } from "./Utils.js";
5
- import { Exception } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
4
+ import { removeParenthesizedType, withInProgress, modulePathForSymbol, isExternalToPackages, isFromEs5Lib, $007CHasTypeFlags$007C_$007C, symbolAtLocation, tryReadLiteral } from "./Utils.js";
5
+ import { Exception } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
6
6
  import { GlueTypeUnion, GluePrimitive, GlueType } from "../GlueAST.js";
7
7
  import { Report_readerError_Z19516DCE } from "./Report.js";
8
- import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
9
- import { toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
8
+ import { item } from "../../fable_modules/fable-library-js.5.21.0/Array.js";
9
+ import { toList, exists } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
10
10
 
11
11
  function readUnionTypeCases(reader, unionTypeNode) {
12
12
  const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
13
- const removeParenthesizedType = (node_mut) => {
14
- removeParenthesizedType:
15
- while (true) {
16
- const node = node_mut;
17
- if (ts.isParenthesizedTypeNode(node)) {
18
- const parenthesizedTypeNode = node;
19
- node_mut = parenthesizedTypeNode.type;
20
- continue removeParenthesizedType;
21
- }
22
- else {
23
- return node;
24
- }
25
- break;
26
- }
27
- };
28
13
  return new GlueTypeUnion(concat(choose((node_1) => {
29
14
  let option_1;
30
15
  if (ts.isLiteralTypeNode(node_1)) {
@@ -73,12 +58,12 @@ function readUnionTypeCases(reader, unionTypeNode) {
73
58
  const matchValue_1 = symbol.declarations;
74
59
  if (matchValue_1 == null) {
75
60
  const typ = checker.getTypeOfSymbol(symbol);
76
- const matchValue_4 = typ.flags;
77
- if ($007CHasTypeFlags$007C_$007C(1, matchValue_4) != null) {
61
+ const matchValue_3 = typ.flags;
62
+ if ($007CHasTypeFlags$007C_$007C(1, matchValue_3) != null) {
78
63
  return singleton(new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
79
64
  }
80
65
  else {
81
- throw new Exception(Report_readerError_Z19516DCE("union type cases", "Unsupported type reference reach a point where it was expected to have flags like Any", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UnionTypeNode.fs", 120));
66
+ throw new Exception(Report_readerError_Z19516DCE("union type cases", "Unsupported type reference reach a point where it was expected to have flags like Any", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UnionTypeNode.fs", 124));
82
67
  }
83
68
  }
84
69
  else {
@@ -92,16 +77,17 @@ function readUnionTypeCases(reader, unionTypeNode) {
92
77
  else {
93
78
  const declaration = item(0, declarations);
94
79
  if (declaration.kind === 266) {
95
- if (!isEmpty(modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), false, symbolOpt))) {
80
+ const isInAnotherModule = !isEmpty(modulePathForSymbol(checker, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"](), false, symbolOpt));
81
+ const isBeingInlined = exists((inProgress) => (inProgress === declaration), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().UnionAliases);
82
+ if (isInAnotherModule ? true : isBeingInlined) {
96
83
  return singleton(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeReferenceNode));
97
84
  }
98
85
  else {
99
- const matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration);
100
- let matchResult, aliasType;
101
- if (matchValue_3.tag === 5) {
102
- if (matchValue_3.fields[0].Type.tag === 7) {
86
+ const aliasType = withInProgress(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_InProgress"]().UnionAliases, declaration, () => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration));
87
+ let matchResult;
88
+ if (aliasType.tag === 5) {
89
+ if (aliasType.fields[0].Type.tag === 7) {
103
90
  matchResult = 0;
104
- aliasType = matchValue_3;
105
91
  }
106
92
  else {
107
93
  matchResult = 1;
@@ -128,7 +114,7 @@ function readUnionTypeCases(reader, unionTypeNode) {
128
114
  return singleton(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeReferenceNode));
129
115
  }
130
116
  else {
131
- throw new Exception(Report_readerError_Z19516DCE("union type cases", "Missing symbol", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UnionTypeNode.fs", 71));
117
+ throw new Exception(Report_readerError_Z19516DCE("union type cases", "Missing symbol", typeReferenceNode, "/_//src/Glutinum.Converter/Reader/UnionTypeNode.fs", 62));
132
118
  }
133
119
  }
134
120
  else if (node_1.kind === 193) {