@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.10
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.
- package/README.md +16 -0
- package/dist/Glutinum.Converter/Abbreviations.js +9 -32
- package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
- package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
- package/dist/Glutinum.Converter/FsharpAST.js +116 -65
- package/dist/Glutinum.Converter/Generate.js +38 -25
- package/dist/Glutinum.Converter/GlueAST.js +82 -43
- package/dist/Glutinum.Converter/Hosting.js +143 -169
- package/dist/Glutinum.Converter/Merge.js +369 -337
- package/dist/Glutinum.Converter/Packages.js +384 -94
- package/dist/Glutinum.Converter/Printer.js +432 -393
- package/dist/Glutinum.Converter/Read.js +361 -99
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
- package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
- package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
- package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
- package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +15 -21
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
- package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
- package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +53 -5
- package/dist/Glutinum.Converter/Reader/Node.js +8 -11
- package/dist/Glutinum.Converter/Reader/Parameters.js +36 -27
- package/dist/Glutinum.Converter/Reader/TypeNode.js +389 -1583
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +76 -49
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
- package/dist/Glutinum.Converter/Reader/Types.js +295 -15
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
- package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
- package/dist/Glutinum.Converter/Reader/Utils.js +487 -101
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +2915 -8176
- package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
- package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
- package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
- package/dist/Glutinum.Converter/Transformer/Conditionals.js +1087 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +356 -0
- package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
- package/dist/Glutinum.Converter/Utils/String.js +14 -3
- package/dist/Program.js +102 -239
- package/package.json +3 -2
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
|
|
2
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";
|
|
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.17.2/Reflection.js";
|
|
8
4
|
import { sanitizeTypeName } from "../Utils/Naming.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { substring, split, join } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
6
|
+
import { FSharpSet__Contains } from "../../fable_modules/fable-library-js.5.17.2/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.17.2/List.js";
|
|
8
|
+
import { withoutDeclarationExtension, normalizePath } from "../Utils/String.js";
|
|
9
|
+
import { empty, singleton, append, delay, toList } from "../../fable_modules/fable-library-js.5.17.2/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.17.2/Map.js";
|
|
11
|
+
import { map as map_1 } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
12
|
+
import { comparePrimitives, equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
11
13
|
import { defaultArg } from "../../fable_modules/fable-library-js.5.17.2/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
|
|
199
|
+
let matchValue_2, rest, withoutExtension, isSubpathEntry;
|
|
121
200
|
const fileName_1 = normalizePath(fileName);
|
|
122
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 { ts } from "@ts-morph/bootstrap";
|
|
3
2
|
import { map, isEmpty, singleton, choose, concat } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
4
|
-
import {
|
|
3
|
+
import { ts } from "@ts-morph/bootstrap";
|
|
4
|
+
import { removeParenthesizedType, withInProgress, modulePathForSymbol, isExternalToPackages, isFromEs5Lib, $007CHasTypeFlags$007C_$007C, symbolAtLocation, tryReadLiteral } from "./Utils.js";
|
|
5
5
|
import { Exception } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
6
6
|
import { GlueTypeUnion, GluePrimitive, GlueType } from "../GlueAST.js";
|
|
7
7
|
import { Report_readerError_Z19516DCE } from "./Report.js";
|
|
8
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";
|
|
9
|
+
import { toList, exists } from "../../fable_modules/fable-library-js.5.17.2/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
|
|
77
|
-
if ($007CHasTypeFlags$007C_$007C(1,
|
|
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",
|
|
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
|
-
|
|
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
|
|
100
|
-
let matchResult
|
|
101
|
-
if (
|
|
102
|
-
if (
|
|
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",
|
|
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) {
|