@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,21 +1,25 @@
1
1
 
2
- import { toString, Record } from "../fable_modules/fable-library-js.5.17.2/Types.js";
2
+ import { toString, Record } from "../fable_modules/fable-library-js.5.21.0/Types.js";
3
3
  import { GlueModuleDeclaration, GlueType, GlueFileModule, GlueType_$reflection } from "./GlueAST.js";
4
- import { tuple_type, option_type, bool_type, record_type, string_type, list_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
4
+ import { int32_type, tuple_type, option_type, bool_type, record_type, string_type, list_type } from "../fable_modules/fable-library-js.5.21.0/Reflection.js";
5
5
  import { FSharpType_$reflection } from "./FsharpAST.js";
6
- import { Bootstrap_reachableFiles, Bootstrap_createProgramFromFiles, Resolve_listInstalledPackages, Resolve_findPackageDir, Resolve_describePackage, Resolve_resolveInput, Npm_installPackage, createInMemoryHost as createInMemoryHost_1 } from "./Hosting.js";
7
- import { toNullable } from "../fable_modules/fable-library-js.5.17.2/Option.js";
8
- import { FSharpSet__get_IsEmpty, FSharpSet__Contains, filter, map as map_2, ofSeq } from "../fable_modules/fable-library-js.5.17.2/Set.js";
9
- import { stringHash, Exception, defaultOf, equals, comparePrimitives } from "../fable_modules/fable-library-js.5.17.2/Util.js";
10
- import { replace, concat, split, substring, join } from "../fable_modules/fable-library-js.5.17.2/String.js";
11
- import { map } from "../fable_modules/fable-library-js.5.17.2/Array.js";
6
+ import { Bootstrap_reachableFiles, Bootstrap_createProgramFromFiles, Resolve_findNodeModules, Resolve_findPackageDir, Resolve_resolveInput, Resolve_listInstalledPackages, Resolve_describePackage, Npm_installPackage, createInMemoryHost as createInMemoryHost_1 } from "./Hosting.js";
7
+ import { FSharpSet__get_IsEmpty, filter as filter_2, map as map_3, union, difference, FSharpSet__Contains, empty as empty_1, ofSeq } from "../fable_modules/fable-library-js.5.21.0/Set.js";
8
+ import { stringHash, Exception, defaultOf, equals, compareArrays, comparePrimitives } from "../fable_modules/fable-library-js.5.21.0/Util.js";
9
+ import { replace, concat, split, substring, join } from "../fable_modules/fable-library-js.5.21.0/String.js";
10
+ import { map } from "../fable_modules/fable-library-js.5.21.0/Array.js";
12
11
  import { normalizePath } from "./Utils/String.js";
13
- import { append as append_1, contains, sortBy, tryFind, filter as filter_1, exists, cons, collect, toArray, singleton, isEmpty, choose, empty, ofArray, map as map_1 } from "../fable_modules/fable-library-js.5.17.2/List.js";
12
+ import { contains, sortBy, tryFind as tryFind_1, collect, toArray, singleton, isEmpty, choose, empty as empty_2, filter as filter_1, sort, append, exists as exists_1, cons, fold, ofArray, map as map_1 } from "../fable_modules/fable-library-js.5.21.0/List.js";
13
+ import { add, ofSeq as ofSeq_1, toList, FSharpMap__TryFind, FSharpMap__ContainsKey, FSharpMap__Add, containsKey, empty } from "../fable_modules/fable-library-js.5.21.0/Map.js";
14
14
  import { PackageContext__TryFindPackage_Z721C83C5, PackageContext, ExternalPackage, PackageInfo } from "./Reader/Types.js";
15
- import { List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
16
- import { singleton as singleton_1, collect as collect_1, empty as empty_1, append, delay, toList } from "../fable_modules/fable-library-js.5.17.2/Seq.js";
15
+ import { choose as choose_1, singleton as singleton_1, collect as collect_1, empty as empty_3, append as append_1, delay, sort as sort_1, toList as toList_1, exists, filter, tryPick, map as map_2, tryFind, fold as fold_1 } from "../fable_modules/fable-library-js.5.21.0/Seq.js";
16
+ import { toArray as toArray_1, defaultArg } from "../fable_modules/fable-library-js.5.21.0/Option.js";
17
+ import { ambientModuleSpecifier, promotedAmbientModule, ambientModuleNames, $007CHasSymbolFlags$007C_$007C, resolveAlias } from "./Reader/Utils.js";
18
+ import { defaultMaxOverloads } from "./Transformer/UnionOverloads.js";
19
+ import { List_distinctBy, List_distinct } from "../fable_modules/fable-library-js.5.21.0/Seq2.js";
17
20
  import { readPackages } from "./Read.js";
18
- import { applyWith } from "./Transform.js";
21
+ import { TransformOptions, applyWithOptions } from "./Transform.js";
22
+ import { ImportSource } from "./Transformer/Context.js";
19
23
  import { printFileWith, Printer_$ctor } from "./Printer.js";
20
24
 
21
25
  export class GenerationResult extends Record {
@@ -45,40 +49,280 @@ export function installPackage(fileSystem, spec, options) {
45
49
  return Npm_installPackage(fileSystem, spec, options);
46
50
  }
47
51
 
48
- function resolveInput(host, input) {
49
- return Resolve_resolveInput(host, input);
50
- }
52
+ const domLibReplacements = ofSeq(["@types/web", "@typescript/lib-dom"], {
53
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
54
+ });
51
55
 
52
- function describePackage(host, packageDir) {
53
- return toNullable(Resolve_describePackage(host, packageDir));
56
+ function moduleNameForPackage(runtimeName) {
57
+ return join("", map((part) => (part[0].toLocaleUpperCase() + substring(part, 1)), split(runtimeName, ["@", "/", "-", ".", "_"], undefined, 1)));
54
58
  }
55
59
 
56
- function findPackageDir(host, file) {
57
- return toNullable(Resolve_findPackageDir(host, file));
60
+ function toPackageInfo(description) {
61
+ return new PackageInfo(moduleNameForPackage(description.runtimeName), description.runtimeName, description.hasRuntime, normalizePath(description.dir) + "/", normalizePath(description.typesRoot) + "/", normalizePath(description.entryFile), map_1((entry) => [normalizePath(entry.file), entry.subpath], ofArray(description.subpathEntries)), empty({
62
+ Compare: (x, y) => (compareArrays(x, y) | 0),
63
+ }), empty({
64
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
65
+ }), empty({
66
+ Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
67
+ }), empty({
68
+ Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
69
+ }), false, empty_1({
70
+ Compare: (x_4, y_4) => (compareArrays(x_4, y_4) | 0),
71
+ }), empty({
72
+ Compare: (x_5, y_5) => (comparePrimitives(x_5, y_5) | 0),
73
+ }));
58
74
  }
59
75
 
60
- function listInstalledPackages(host) {
61
- return Resolve_listInstalledPackages(host);
76
+ function reExportedNames(program, checker, hasExportsMap, package$) {
77
+ if (!hasExportsMap) {
78
+ return empty({
79
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
80
+ });
81
+ }
82
+ else {
83
+ return fold((acc, tupledArg) => {
84
+ const matchValue = program.getSourceFile(tupledArg[0]);
85
+ if (matchValue != null) {
86
+ const sourceFile = matchValue;
87
+ const matchValue_1 = checker.getSymbolAtLocation(sourceFile);
88
+ if (matchValue_1 != null) {
89
+ const moduleSymbol = matchValue_1;
90
+ return fold_1((acc_1, exportedSymbol) => {
91
+ if (containsKey(exportedSymbol.name, acc_1)) {
92
+ return acc_1;
93
+ }
94
+ else {
95
+ return FSharpMap__Add(acc_1, exportedSymbol.name, tupledArg[1]);
96
+ }
97
+ }, acc, checker.getExportsOfModule(moduleSymbol));
98
+ }
99
+ else {
100
+ return acc;
101
+ }
102
+ }
103
+ else {
104
+ return acc;
105
+ }
106
+ }, empty({
107
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
108
+ }), cons([package$.EntryFile, ""], package$.SubpathEntries));
109
+ }
62
110
  }
63
111
 
64
- function createProgramFromFiles(host, entryFiles, options) {
65
- return Bootstrap_createProgramFromFiles(host, entryFiles, options.withoutDomLib, options.noLib);
112
+ function defaultExportOf(program, checker, fileName) {
113
+ let symbol;
114
+ let option_6;
115
+ let option_3;
116
+ const option_1 = program.getSourceFile(fileName);
117
+ if (option_1 != null) {
118
+ const sourceFile = option_1;
119
+ option_3 = checker.getSymbolAtLocation(sourceFile);
120
+ }
121
+ else {
122
+ option_3 = undefined;
123
+ }
124
+ if (option_3 != null) {
125
+ const moduleSymbol = option_3;
126
+ option_6 = tryFind((exported) => (exported.name === "default"), checker.getExportsOfModule(moduleSymbol));
127
+ }
128
+ else {
129
+ option_6 = undefined;
130
+ }
131
+ if (option_6 != null) {
132
+ return (symbol = option_6, defaultArg(resolveAlias(checker, symbol), symbol));
133
+ }
134
+ else {
135
+ return undefined;
136
+ }
66
137
  }
67
138
 
68
- function reachableFiles(host, program, entryFiles, excludedRuntimeNames) {
69
- return Bootstrap_reachableFiles(host, program, entryFiles, excludedRuntimeNames);
139
+ function reExportedSymbols(program, checker, hasExportsMap, package$) {
140
+ if (!hasExportsMap) {
141
+ return [empty({
142
+ Compare: (x, y) => (compareArrays(x, y) | 0),
143
+ }), empty({
144
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
145
+ })];
146
+ }
147
+ else {
148
+ const entries = cons([package$.EntryFile, ""], package$.SubpathEntries);
149
+ const entryFiles = ofSeq(map_1((tuple) => tuple[0], entries), {
150
+ Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
151
+ });
152
+ return fold((acc, tupledArg) => {
153
+ const matchValue = program.getSourceFile(tupledArg[0]);
154
+ if (matchValue != null) {
155
+ const sourceFile = matchValue;
156
+ const matchValue_1 = checker.getSymbolAtLocation(sourceFile);
157
+ if (matchValue_1 != null) {
158
+ const moduleSymbol = matchValue_1;
159
+ const tupledArg_3 = acc;
160
+ return fold_1((acc_1, exportedSymbol) => {
161
+ const exportName = exportedSymbol.name;
162
+ const exportedSymbol_1 = defaultArg(resolveAlias(checker, exportedSymbol), exportedSymbol);
163
+ const matchValue_2 = exportedSymbol_1.declarations;
164
+ if (matchValue_2 != null) {
165
+ const tupledArg_2 = acc_1;
166
+ return fold_1((tupledArg_1, declaration) => {
167
+ const symbols = tupledArg_1[0];
168
+ const defaults = tupledArg_1[1];
169
+ const declaringFile = normalizePath(declaration.getSourceFile().fileName);
170
+ const key = [declaringFile, exportName];
171
+ if ((declaringFile.startsWith(package$.Dir) && !FSharpSet__Contains(entryFiles, declaringFile)) && !FSharpMap__ContainsKey(symbols, key)) {
172
+ let isDefault;
173
+ if (!FSharpMap__ContainsKey(defaults, declaringFile)) {
174
+ const matchValue_3 = defaultExportOf(program, checker, declaringFile);
175
+ isDefault = ((matchValue_3 == null) ? false : (matchValue_3 === exportedSymbol_1));
176
+ }
177
+ else {
178
+ isDefault = false;
179
+ }
180
+ return [FSharpMap__Add(symbols, key, tupledArg[1]), isDefault ? FSharpMap__Add(defaults, declaringFile, exportName) : defaults];
181
+ }
182
+ else {
183
+ return [symbols, defaults];
184
+ }
185
+ }, [tupledArg_2[0], tupledArg_2[1]], matchValue_2);
186
+ }
187
+ else {
188
+ return acc_1;
189
+ }
190
+ }, [tupledArg_3[0], tupledArg_3[1]], checker.getExportsOfModule(moduleSymbol));
191
+ }
192
+ else {
193
+ return acc;
194
+ }
195
+ }
196
+ else {
197
+ return acc;
198
+ }
199
+ }, [empty({
200
+ Compare: (x_3, y_3) => (compareArrays(x_3, y_3) | 0),
201
+ }), empty({
202
+ Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
203
+ })], entries);
204
+ }
70
205
  }
71
206
 
72
- const domLibReplacements = ofSeq(["@types/web", "@typescript/lib-dom"], {
73
- Compare: (x, y) => (comparePrimitives(x, y) | 0),
74
- });
75
-
76
- function moduleNameForPackage(runtimeName) {
77
- return join("", map((part) => (part[0].toLocaleUpperCase() + substring(part, 1)), split(runtimeName, ["@", "/", "-", ".", "_"], undefined, 1)));
207
+ function declaredNames(program, checker, defaultExportNames, fileName) {
208
+ const matchValue = program.getSourceFile(fileName);
209
+ if (matchValue != null) {
210
+ const sourceFile = matchValue;
211
+ const matchValue_1 = checker.getSymbolAtLocation(sourceFile);
212
+ if (matchValue_1 != null) {
213
+ const moduleSymbol = matchValue_1;
214
+ const normalized = normalizePath(fileName);
215
+ return ofSeq(map_2((exportedSymbol_2) => {
216
+ let option_2;
217
+ if (exportedSymbol_2.name === "default") {
218
+ const matchValue_4 = FSharpMap__TryFind(defaultExportNames, normalized);
219
+ if (matchValue_4 == null) {
220
+ return defaultArg((option_2 = exportedSymbol_2.declarations, (option_2 != null) ? tryPick((declaration_1) => {
221
+ const matchValue_5 = declaration_1.name;
222
+ if (equals(matchValue_5, defaultOf())) {
223
+ return undefined;
224
+ }
225
+ else {
226
+ return matchValue_5.getText();
227
+ }
228
+ }, option_2) : undefined), exportedSymbol_2.name);
229
+ }
230
+ else {
231
+ return matchValue_4;
232
+ }
233
+ }
234
+ else {
235
+ return exportedSymbol_2.name;
236
+ }
237
+ }, filter((exportedSymbol_1) => {
238
+ const matchValue_3 = defaultArg(resolveAlias(checker, exportedSymbol_1), exportedSymbol_1).declarations;
239
+ if (matchValue_3 == null) {
240
+ return false;
241
+ }
242
+ else {
243
+ return exists((declaration) => {
244
+ if ((declaration.kind !== 282) && (declaration.kind !== 278)) {
245
+ return normalizePath(declaration.getSourceFile().fileName) === normalized;
246
+ }
247
+ else {
248
+ return false;
249
+ }
250
+ }, matchValue_3);
251
+ }
252
+ }, filter((exportedSymbol) => {
253
+ const matchValue_2 = exportedSymbol.flags;
254
+ let matchResult;
255
+ if ($007CHasSymbolFlags$007C_$007C(512, matchValue_2) != null) {
256
+ matchResult = 0;
257
+ }
258
+ else if ($007CHasSymbolFlags$007C_$007C(1024, matchValue_2) != null) {
259
+ matchResult = 0;
260
+ }
261
+ else {
262
+ matchResult = 1;
263
+ }
264
+ switch (matchResult) {
265
+ case 0:
266
+ return false;
267
+ default:
268
+ return true;
269
+ }
270
+ }, checker.getExportsOfModule(moduleSymbol)))), {
271
+ Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
272
+ });
273
+ }
274
+ else {
275
+ return empty_1({
276
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
277
+ });
278
+ }
279
+ }
280
+ else {
281
+ return empty_1({
282
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
283
+ });
284
+ }
78
285
  }
79
286
 
80
- function toPackageInfo(description) {
81
- return new PackageInfo(moduleNameForPackage(description.runtimeName), description.runtimeName, description.hasRuntime, normalizePath(description.dir) + "/", normalizePath(description.typesRoot) + "/", normalizePath(description.entryFile), map_1((entry) => [normalizePath(entry.file), entry.subpath], ofArray(description.subpathEntries)));
287
+ function hoistableDeclarations(program, checker, package$, reExportedFiles, defaultExportNames) {
288
+ const declaredNames_1 = (fileName) => declaredNames(program, checker, defaultExportNames, fileName);
289
+ const entryNames = declaredNames_1(package$.EntryFile);
290
+ const isEntry = (file) => {
291
+ if (file === package$.EntryFile) {
292
+ return true;
293
+ }
294
+ else {
295
+ return exists_1((tupledArg) => (tupledArg[0] === file), package$.SubpathEntries);
296
+ }
297
+ };
298
+ const candidates = append(sort(map_1((tuple) => tuple[0], filter_1((tupledArg_1) => {
299
+ if (tupledArg_1[1] === "") {
300
+ return !isEntry(tupledArg_1[0]);
301
+ }
302
+ else {
303
+ return false;
304
+ }
305
+ }, toList(reExportedFiles))), {
306
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
307
+ }), toList_1(sort_1(filter((file_2) => {
308
+ if ((file_2.startsWith(package$.Dir) && !(substring(file_2, package$.Dir.length).indexOf("node_modules/") >= 0)) && !isEntry(file_2)) {
309
+ return !FSharpMap__ContainsKey(reExportedFiles, file_2);
310
+ }
311
+ else {
312
+ return false;
313
+ }
314
+ }, map_2((sourceFile) => normalizePath(sourceFile.fileName), program.getSourceFiles())), {
315
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
316
+ })));
317
+ return fold((tupledArg_2, file_3) => {
318
+ const taken = tupledArg_2[0];
319
+ const free = difference(declaredNames_1(file_3), taken);
320
+ return [union(taken, free), union(tupledArg_2[1], map_3((name) => [file_3, name], free, {
321
+ Compare: (x_3, y_3) => (compareArrays(x_3, y_3) | 0),
322
+ }))];
323
+ }, [entryNames, empty_1({
324
+ Compare: (x_2, y_2) => (compareArrays(x_2, y_2) | 0),
325
+ })], candidates)[1];
82
326
  }
83
327
 
84
328
  function isTypeScriptLibFile(fileName) {
@@ -86,21 +330,23 @@ function isTypeScriptLibFile(fileName) {
86
330
  }
87
331
 
88
332
  export class GenerateOptions extends Record {
89
- constructor(ExternalPackages, Externals, ModuleName, Include, NoLib) {
333
+ constructor(ExternalPackages, Externals, ModuleName, GlobalScript, MaxOverloads, Include, NoLib) {
90
334
  super();
91
335
  this.ExternalPackages = ExternalPackages;
92
336
  this.Externals = Externals;
93
337
  this.ModuleName = ModuleName;
338
+ this.GlobalScript = GlobalScript;
339
+ this.MaxOverloads = (MaxOverloads | 0);
94
340
  this.Include = Include;
95
341
  this.NoLib = NoLib;
96
342
  }
97
343
  }
98
344
 
99
345
  export function GenerateOptions_$reflection() {
100
- return record_type("Glutinum.Converter.Packages.GenerateOptions", [], GenerateOptions, () => [["ExternalPackages", bool_type], ["Externals", list_type(tuple_type(string_type, option_type(string_type)))], ["ModuleName", option_type(string_type)], ["Include", list_type(string_type)], ["NoLib", bool_type]]);
346
+ return record_type("Glutinum.Converter.Packages.GenerateOptions", [], GenerateOptions, () => [["ExternalPackages", bool_type], ["Externals", list_type(tuple_type(string_type, option_type(string_type)))], ["ModuleName", option_type(string_type)], ["GlobalScript", bool_type], ["MaxOverloads", int32_type], ["Include", list_type(string_type)], ["NoLib", bool_type]]);
101
347
  }
102
348
 
103
- export const defaultOptions = new GenerateOptions(true, empty(), undefined, empty(), false);
349
+ export const defaultOptions = new GenerateOptions(true, empty_2(), undefined, false, defaultMaxOverloads, empty_2(), false);
104
350
 
105
351
  function splitModuleName(fullName) {
106
352
  const matchValue = fullName.lastIndexOf(".") | 0;
@@ -161,7 +407,7 @@ function isValue(glueType_mut) {
161
407
  }
162
408
 
163
409
  function keepIncluded(included, types) {
164
- const values = map_2((name_1) => substring(name_1, "value:".length), filter((name) => name.startsWith("value:"), included), {
410
+ const values = map_3((name_1) => substring(name_1, "value:".length), filter_2((name) => name.startsWith("value:"), included), {
165
411
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
166
412
  });
167
413
  return choose((glueType) => {
@@ -172,7 +418,7 @@ function keepIncluded(included, types) {
172
418
  return undefined;
173
419
  }
174
420
  else {
175
- return new GlueType(/* FileModule */ 31, [new GlueFileModule(glueType.fields[0].Name, glueType.fields[0].ImportSpecifier, glueType.fields[0].IsGlobal, glueType.fields[0].HasRuntime, matchValue)]);
421
+ return new GlueType(/* FileModule */ 31, [new GlueFileModule(glueType.fields[0].Name, glueType.fields[0].ImportSpecifier, glueType.fields[0].SymbolSpecifiers, glueType.fields[0].IsGlobal, glueType.fields[0].HasRuntime, matchValue)]);
176
422
  }
177
423
  }
178
424
  case 11:
@@ -185,7 +431,7 @@ function keepIncluded(included, types) {
185
431
  return undefined;
186
432
  }
187
433
  else {
188
- return new GlueType(/* ModuleDeclaration */ 11, [new GlueModuleDeclaration(glueType.fields[0].Documentation, glueType.fields[0].Name, glueType.fields[0].IsTopLevel, glueType.fields[0].IsNamespace, glueType.fields[0].IsGlobal, glueType.fields[0].IsRecursive, matchValue_1)]);
434
+ return new GlueType(/* ModuleDeclaration */ 11, [new GlueModuleDeclaration(glueType.fields[0].Documentation, glueType.fields[0].Name, glueType.fields[0].IsTopLevel, glueType.fields[0].IsNamespace, glueType.fields[0].IsGlobal, glueType.fields[0].IsExported, glueType.fields[0].IsRecursive, matchValue_1)]);
189
435
  }
190
436
  }
191
437
  default: {
@@ -220,34 +466,34 @@ function keepIncluded(included, types) {
220
466
  }, types);
221
467
  }
222
468
 
223
- const builtInExternalPackageNames = ofArray([["@types/node", "Node", empty()], ["@types/web", "Web", singleton("/typescript/lib/lib.dom")]]);
469
+ const builtInExternalPackageNames = ofArray([["@types/node", "Node", empty_2()], ["@types/web", "Web", singleton("/typescript/lib/lib.dom")]]);
224
470
 
225
471
  /**
226
472
  * Generate a single binding file for the packages, and the packages they depend on.
227
473
  * An empty list generates every package installed in the nearest <c>node_modules</c>.
228
474
  */
229
475
  export function generateWith(options, host, inputs) {
230
- let matchValue_8;
476
+ let option_11, option_8, option_6, option_5, nodeModules, predicate_3, objectArg, option_7, mapping_6, objectArg_1, option_9;
231
477
  const targets = map_1((dir) => {
232
- const matchValue_2 = describePackage(host, dir);
233
- if (equals(matchValue_2, defaultOf())) {
234
- throw new Exception(concat("Could not find a declaration file for the package in ", dir));
478
+ const option_3 = Resolve_describePackage(host, dir);
479
+ if (option_3 != null) {
480
+ return option_3;
235
481
  }
236
482
  else {
237
- return matchValue_2;
483
+ throw new Exception(concat("Could not find a declaration file for the package in ", dir));
238
484
  }
239
- }, isEmpty(inputs) ? ofArray(listInstalledPackages(host)) : List_distinct(map_1((input) => {
240
- const resolved = resolveInput(host, input);
485
+ }, isEmpty(inputs) ? ofArray(Resolve_listInstalledPackages(host)) : List_distinct(map_1((input) => {
486
+ const resolved = Resolve_resolveInput(host, input);
241
487
  if (resolved.kind === "package") {
242
488
  return resolved.packageDir;
243
489
  }
244
490
  else {
245
- const matchValue_1 = findPackageDir(host, resolved.file);
246
- if (matchValue_1 === defaultOf()) {
247
- throw new Exception(concat("Could not find the package of ", resolved.file));
491
+ const option_1 = Resolve_findPackageDir(host, resolved.file);
492
+ if (option_1 != null) {
493
+ return option_1;
248
494
  }
249
495
  else {
250
- return matchValue_1;
496
+ throw new Exception(concat("Could not find the package of ", resolved.file));
251
497
  }
252
498
  }
253
499
  }, inputs), {
@@ -255,87 +501,131 @@ export function generateWith(options, host, inputs) {
255
501
  GetHashCode: (x) => (stringHash(x) | 0),
256
502
  }));
257
503
  const entryFiles = toArray(collect((target) => cons(target.entryFile, map_1((_arg) => _arg.file, ofArray(target.subpathEntries))), targets));
258
- const program = createProgramFromFiles(host, entryFiles, {
259
- noLib: options.NoLib,
260
- withoutDomLib: exists((target_1) => FSharpSet__Contains(domLibReplacements, target_1.name), targets),
261
- });
504
+ const withoutDomLib = exists_1((target_1) => FSharpSet__Contains(domLibReplacements, target_1.name), targets);
505
+ let globalTypePackages;
506
+ const isRuntime = exists_1((target_2) => exists_1((tupledArg) => (tupledArg[0] === target_2.name), builtInExternalPackageNames), targets);
507
+ globalTypePackages = ((options.ExternalPackages && !isRuntime) ? ofArray(toArray_1((option_11 = ((option_8 = ((option_6 = ((option_5 = Resolve_findNodeModules(host, host.cwd), (option_5 != null) ? ((nodeModules = option_5, host.path.join([nodeModules, "@types/node"]))) : undefined)), (predicate_3 = ((objectArg = host.fs, (path) => objectArg.directoryExists(path))), (option_7 = option_6, (option_7 != null) ? (predicate_3(option_7) ? option_7 : undefined) : undefined)))), (mapping_6 = ((objectArg_1 = host.fs, (path_1) => objectArg_1.realPath(path_1))), (option_9 = option_8, (option_9 != null) ? mapping_6(option_9) : undefined)))), (option_11 != null) ? Resolve_describePackage(host, option_11) : undefined))) : empty_2());
508
+ const program = Bootstrap_createProgramFromFiles(host, entryFiles, map_1((_arg_3) => _arg_3.runtimeName, globalTypePackages), withoutDomLib, options.NoLib);
262
509
  const checker = program.getTypeChecker();
263
- const targetDirs_1 = ofSeq(map_1((target_2) => normalizePath(target_2.dir), targets), {
510
+ const targetDirSet = ofSeq(map_1((target_3) => normalizePath(target_3.dir), targets), {
264
511
  Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
265
512
  });
266
- const describeReachable = (excludedRuntimeNames) => choose((dir_3) => {
267
- const matchValue_4 = describePackage(host, dir_3);
268
- if (equals(matchValue_4, defaultOf())) {
269
- return undefined;
513
+ const describeReachable = (excludedRuntimeNames) => choose((packageDir_1) => Resolve_describePackage(host, packageDir_1), filter_1((dir_1) => !FSharpSet__Contains(targetDirSet, dir_1), List_distinct(choose((arg) => {
514
+ const option_14 = Resolve_findPackageDir(host, arg);
515
+ if (option_14 != null) {
516
+ return normalizePath(option_14);
270
517
  }
271
518
  else {
272
- return matchValue_4;
273
- }
274
- }, filter_1((dir_2) => !FSharpSet__Contains(targetDirs_1, dir_2), List_distinct(choose((fileName_1) => {
275
- const matchValue_3 = findPackageDir(host, fileName_1);
276
- if (matchValue_3 === defaultOf()) {
277
519
  return undefined;
278
520
  }
279
- else {
280
- return normalizePath(matchValue_3);
281
- }
282
- }, filter_1((fileName) => !isTypeScriptLibFile(fileName), ofArray(reachableFiles(host, program, entryFiles, toArray(excludedRuntimeNames))))), {
521
+ }, filter_1((fileName) => !isTypeScriptLibFile(fileName), ofArray(Bootstrap_reachableFiles(host, program, entryFiles, toArray(excludedRuntimeNames))))), {
283
522
  Equals: (x_2, y_2) => (x_2 === y_2),
284
523
  GetHashCode: (x_2) => (stringHash(x_2) | 0),
285
524
  })));
286
- const externalPackageNames = toList(delay(() => append(options.ExternalPackages ? builtInExternalPackageNames : empty_1(), delay(() => collect_1((matchValue_5) => singleton_1([matchValue_5[0], matchValue_5[1], empty()]), options.Externals)))));
525
+ const externalPackageNames = toList_1(delay(() => append_1(options.ExternalPackages ? builtInExternalPackageNames : empty_3(), delay(() => collect_1((matchValue_1) => singleton_1([matchValue_1[0], matchValue_1[1], empty_2()]), options.Externals)))));
287
526
  let externals;
288
527
  if (isEmpty(externalPackageNames)) {
289
- externals = empty();
528
+ externals = empty_2();
290
529
  }
291
530
  else {
292
- const reachable = describeReachable(empty());
293
- externals = map_1((tupledArg_1) => {
294
- let package$_1, option_1;
295
- const name_2 = tupledArg_1[0];
296
- const moduleName_1 = tupledArg_1[1];
297
- const package$ = tryFind((description_2) => (description_2.name === name_2), reachable);
298
- return new ExternalPackage((moduleName_1 == null) ? ((package$ == null) ? moduleNameForPackage(replace(name_2, "@types/", "")) : ((package$_1 = package$, moduleNameForPackage(package$_1.runtimeName)))) : moduleName_1, (option_1 = package$, (option_1 != null) ? toPackageInfo(option_1) : undefined), tupledArg_1[2]);
299
- }, filter_1((tupledArg) => !exists((target_3) => (target_3.name === tupledArg[0]), targets), externalPackageNames));
531
+ const reachable = List_distinctBy((_arg_4) => _arg_4.name, append(describeReachable(empty_2()), globalTypePackages), {
532
+ Equals: (x_3, y_3) => (x_3 === y_3),
533
+ GetHashCode: (x_3) => (stringHash(x_3) | 0),
534
+ });
535
+ externals = map_1((tupledArg_2) => {
536
+ let package$_1, option_16;
537
+ const name_3 = tupledArg_2[0];
538
+ const moduleName_1 = tupledArg_2[1];
539
+ const package$ = tryFind_1((description) => (description.name === name_3), reachable);
540
+ return new ExternalPackage((moduleName_1 == null) ? ((package$ == null) ? moduleNameForPackage(replace(name_3, "@types/", "")) : ((package$_1 = package$, moduleNameForPackage(package$_1.runtimeName)))) : moduleName_1, (option_16 = package$, (option_16 != null) ? toPackageInfo(option_16) : undefined), tupledArg_2[2]);
541
+ }, filter_1((tupledArg_1) => !exists_1((target_4) => (target_4.name === tupledArg_1[0]), targets), externalPackageNames));
300
542
  }
301
543
  const externalRuntimeNames = choose((external) => {
302
- const option_3 = external.Package;
303
- if (option_3 != null) {
304
- return option_3.RuntimeName;
544
+ const option_18 = external.Package;
545
+ if (option_18 != null) {
546
+ return option_18.RuntimeName;
305
547
  }
306
548
  else {
307
549
  return undefined;
308
550
  }
309
551
  }, externals);
310
- const dependencies = sortBy((_arg_4) => _arg_4.runtimeName, filter_1((description_4) => !contains(description_4.runtimeName, externalRuntimeNames, {
311
- Equals: (x_3, y_3) => (x_3 === y_3),
312
- GetHashCode: (x_3) => (stringHash(x_3) | 0),
552
+ const dependencies = sortBy((_arg_8) => _arg_8.runtimeName, filter_1((description_2) => !contains(description_2.runtimeName, externalRuntimeNames, {
553
+ Equals: (x_4, y_4) => (x_4 === y_4),
554
+ GetHashCode: (x_4) => (stringHash(x_4) | 0),
313
555
  }), describeReachable(externalRuntimeNames)), {
314
- Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
556
+ Compare: (x_5, y_5) => (comparePrimitives(x_5, y_5) | 0),
315
557
  });
316
558
  let patternInput;
317
- const matchValue_7 = options.ModuleName;
318
- patternInput = ((matchValue_7 == null) ? ["Glutinum", ""] : splitModuleName(matchValue_7));
559
+ const matchValue_3 = options.ModuleName;
560
+ patternInput = ((matchValue_3 == null) ? ["Glutinum", ""] : splitModuleName(matchValue_3));
319
561
  const moduleName_3 = patternInput[1];
320
562
  const targetPackages = map_1((package$_2) => {
321
563
  if (moduleName_3 === "") {
322
564
  return package$_2;
323
565
  }
324
566
  else {
325
- return new PackageInfo(moduleName_3, package$_2.RuntimeName, package$_2.HasRuntime, package$_2.Dir, package$_2.TypesRoot, package$_2.EntryFile, package$_2.SubpathEntries);
567
+ return new PackageInfo(moduleName_3, package$_2.RuntimeName, package$_2.HasRuntime, package$_2.Dir, package$_2.TypesRoot, package$_2.EntryFile, package$_2.SubpathEntries, package$_2.ReExportedSymbols, package$_2.ReExportedFiles, package$_2.ReExportedNames, package$_2.DefaultExportNames, package$_2.HasExportsMap, package$_2.HoistableDeclarations, package$_2.AmbientModuleFiles);
326
568
  }
327
569
  }, map_1(toPackageInfo, targets));
328
570
  const included = ofSeq(options.Include, {
329
- Compare: (x_5, y_5) => (comparePrimitives(x_5, y_5) | 0),
330
- });
331
- const packageContext = new PackageContext(append_1(targetPackages, map_1(toPackageInfo, dependencies)), externals, (name_3) => ((options.NoLib && !FSharpSet__get_IsEmpty(included)) && !FSharpSet__Contains(included, name_3)));
332
- const readerResult = readPackages(checker, packageContext, filter_1((sourceFile) => (PackageContext__TryFindPackage_Z721C83C5(packageContext, sourceFile.fileName) != null), toList(program.getSourceFiles())));
333
- const transformResult = applyWith("REPLACE_ME_WITH_MODULE_NAME", readerResult.TypeMemory, (matchValue_8 = options.Include, isEmpty(matchValue_8) ? readerResult.GlueAST : keepIncluded(ofSeq(matchValue_8, {
334
571
  Compare: (x_6, y_6) => (comparePrimitives(x_6, y_6) | 0),
335
- }), readerResult.GlueAST)));
572
+ });
573
+ const exportsMapPackages = ofSeq(map_1((description_5) => (normalizePath(description_5.dir) + "/"), filter_1((description_4) => description_4.hasExportsMap, append(targets, dependencies))), {
574
+ Compare: (x_7, y_7) => (comparePrimitives(x_7, y_7) | 0),
575
+ });
576
+ const ambientNames = ambientModuleNames(checker);
577
+ const packageContext = new PackageContext(map_1((package$_3) => {
578
+ const hasExportsMap = FSharpSet__Contains(exportsMapPackages, package$_3.Dir);
579
+ const ambientModuleFiles = ofSeq_1(choose_1((sourceFile) => {
580
+ const fileName_1 = normalizePath(sourceFile.fileName);
581
+ if (fileName_1.startsWith(package$_3.Dir)) {
582
+ const option_20 = promotedAmbientModule(sourceFile);
583
+ if (option_20 != null) {
584
+ return [fileName_1, ambientModuleSpecifier(ambientNames, option_20)];
585
+ }
586
+ else {
587
+ return undefined;
588
+ }
589
+ }
590
+ else {
591
+ return undefined;
592
+ }
593
+ }, program.getSourceFiles()), {
594
+ Compare: (x_8, y_8) => (comparePrimitives(x_8, y_8) | 0),
595
+ });
596
+ const patternInput_1 = reExportedSymbols(program, checker, hasExportsMap, package$_3);
597
+ const symbols = patternInput_1[0];
598
+ const defaultExportNames = patternInput_1[1];
599
+ let reExportedFiles;
600
+ const list_28 = toList(symbols);
601
+ reExportedFiles = fold((acc, tupledArg_3) => {
602
+ const file_1 = tupledArg_3[0][0];
603
+ if (containsKey(file_1, acc)) {
604
+ return acc;
605
+ }
606
+ else {
607
+ return add(file_1, tupledArg_3[1], acc);
608
+ }
609
+ }, empty({
610
+ Compare: (x_9, y_9) => (comparePrimitives(x_9, y_9) | 0),
611
+ }), list_28);
612
+ const HoistableDeclarations = hasExportsMap ? hoistableDeclarations(program, checker, package$_3, reExportedFiles, defaultExportNames) : empty_1({
613
+ Compare: (x_10, y_10) => (compareArrays(x_10, y_10) | 0),
614
+ });
615
+ return new PackageInfo(package$_3.ModuleName, package$_3.RuntimeName, package$_3.HasRuntime, package$_3.Dir, package$_3.TypesRoot, package$_3.EntryFile, package$_3.SubpathEntries, symbols, reExportedFiles, reExportedNames(program, checker, hasExportsMap, package$_3), defaultExportNames, hasExportsMap, HoistableDeclarations, ambientModuleFiles);
616
+ }, append(targetPackages, map_1(toPackageInfo, dependencies))), externals, (name_4) => ((options.NoLib && !FSharpSet__get_IsEmpty(included)) && !FSharpSet__Contains(included, name_4)), ambientNames);
617
+ const readerResult = readPackages(checker, packageContext, filter_1((sourceFile_1) => (PackageContext__TryFindPackage_Z721C83C5(packageContext, sourceFile_1.fileName) != null), toList_1(program.getSourceFiles())));
618
+ let glueAst;
619
+ const matchValue_4 = options.Include;
620
+ glueAst = (isEmpty(matchValue_4) ? readerResult.GlueAST : keepIncluded(ofSeq(matchValue_4, {
621
+ Compare: (x_11, y_11) => (comparePrimitives(x_11, y_11) | 0),
622
+ }), readerResult.GlueAST));
623
+ const transformResult = applyWithOptions(new TransformOptions(new ImportSource(/* Module */ 0, ["REPLACE_ME_WITH_MODULE_NAME", empty({
624
+ Compare: (x_12, y_12) => (comparePrimitives(x_12, y_12) | 0),
625
+ })]), options.MaxOverloads), readerResult.TypeMemory, glueAst);
336
626
  const printer = Printer_$ctor();
337
- printFileWith(patternInput[0], true, map_1((_arg_5) => _arg_5.ModuleName, externals), printer, transformResult);
338
- return new GenerationResult(readerResult.GlueAST, transformResult.FSharpAST, toString(printer), toList(delay(() => append(readerResult.Warnings, delay(() => transformResult.Warnings)))), toList(transformResult.Errors));
627
+ printFileWith(patternInput[0], true, map_1((_arg_10) => _arg_10.ModuleName, externals), printer, transformResult);
628
+ return new GenerationResult(readerResult.GlueAST, transformResult.FSharpAST, toString(printer), toList_1(delay(() => append_1(readerResult.Warnings, delay(() => transformResult.Warnings)))), toList_1(transformResult.Errors));
339
629
  }
340
630
 
341
631
  export function generate(host, inputs) {