@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +79 -41
- package/dist/Glutinum.Converter/Hosting.js +141 -167
- package/dist/Glutinum.Converter/Merge.js +369 -337
- package/dist/Glutinum.Converter/Packages.js +391 -92
- package/dist/Glutinum.Converter/Printer.js +398 -387
- package/dist/Glutinum.Converter/Read.js +387 -88
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
- package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
- 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/FunctionDeclaration.js +26 -13
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
- package/dist/Glutinum.Converter/Reader/Node.js +8 -11
- package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
- package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
- 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 +290 -15
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
- package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +3572 -8415
- 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 +1149 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -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) {
|
|
@@ -116,10 +161,94 @@ export function PackageContext__IsExternal_Z721C83C5(this$, fileName) {
|
|
|
116
161
|
}
|
|
117
162
|
}
|
|
118
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Whether the root entry exports the declaration: it belongs to the package module, the
|
|
166
|
+
* file declaring it is an implementation detail
|
|
167
|
+
*/
|
|
168
|
+
export function PackageContext__IsHoisted_32BC514A(this$, package$, fileName, name) {
|
|
169
|
+
return FSharpSet__Contains(package$.HoistableDeclarations, [normalizePath(fileName), name]);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The subpath a public entry exports the declarations of the file from, when there is one
|
|
174
|
+
*/
|
|
175
|
+
export function PackageContext__SubpathOf_Z11793CAF(this$, package$, fileName) {
|
|
176
|
+
const fileName_1 = normalizePath(fileName);
|
|
177
|
+
const option_1 = tryPick((tupledArg) => {
|
|
178
|
+
if (tupledArg[0] === fileName_1) {
|
|
179
|
+
return tupledArg[1];
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
}, package$.SubpathEntries);
|
|
185
|
+
if (option_1 != null) {
|
|
186
|
+
return option_1;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
return FSharpMap__TryFind(package$.ReExportedFiles, fileName_1);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
119
193
|
export function PackageContext__FileModuleName_Z11793CAF(this$, package$, fileName) {
|
|
120
|
-
let
|
|
194
|
+
let matchValue_2, rest, withoutExtension, isSubpathEntry;
|
|
121
195
|
const fileName_1 = normalizePath(fileName);
|
|
122
|
-
|
|
196
|
+
let fromAmbientModule;
|
|
197
|
+
const option_1 = FSharpMap__TryFind(package$.AmbientModuleFiles, fileName_1);
|
|
198
|
+
fromAmbientModule = ((option_1 != null) ? join(".", PackageContext__AmbientModuleSegments_Z11793CAF(this$, package$, option_1)) : undefined);
|
|
199
|
+
let fromSubpath;
|
|
200
|
+
const matchValue = PackageContext__SubpathOf_Z11793CAF(this$, package$, fileName_1);
|
|
201
|
+
let matchResult, name, subpath_1;
|
|
202
|
+
if (fromAmbientModule == null) {
|
|
203
|
+
if (matchValue != null) {
|
|
204
|
+
if (matchValue !== "") {
|
|
205
|
+
matchResult = 1;
|
|
206
|
+
subpath_1 = matchValue;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
matchResult = 2;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
matchResult = 2;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
matchResult = 0;
|
|
218
|
+
name = fromAmbientModule;
|
|
219
|
+
}
|
|
220
|
+
switch (matchResult) {
|
|
221
|
+
case 0: {
|
|
222
|
+
fromSubpath = name;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case 1: {
|
|
226
|
+
fromSubpath = join(".", map_1((segment) => sanitizeTypeName(join("_", split(segment, ["-", ".", " "], undefined, 1))), split(subpath_1, ["/"], undefined, 0)));
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
default:
|
|
230
|
+
fromSubpath = undefined;
|
|
231
|
+
}
|
|
232
|
+
if (fromSubpath == null) {
|
|
233
|
+
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))))))))));
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
return fromSubpath;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The F# modules of `declare module "util/types"` under the module of its file `util`
|
|
242
|
+
*/
|
|
243
|
+
export function PackageContext__NestedAmbientModuleSegments_32BC514A(this$, package$, fileName, name) {
|
|
244
|
+
const segments = PackageContext__AmbientModuleSegments_Z11793CAF(this$, package$, PackageContext__AmbientSpecifier_Z721C83C5(this$, name));
|
|
245
|
+
const fileSegments = ofArray(split(PackageContext__FileModuleName_Z11793CAF(this$, package$, fileName), ["."], undefined, 0));
|
|
246
|
+
if ((length(segments) >= length(fileSegments)) && equals(take(length(fileSegments), segments), fileSegments)) {
|
|
247
|
+
return skip(length(fileSegments), segments);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
return segments;
|
|
251
|
+
}
|
|
123
252
|
}
|
|
124
253
|
|
|
125
254
|
/**
|
|
@@ -133,11 +262,19 @@ export function PackageContext__ModulePath_Z721C83C5(this$, fileName) {
|
|
|
133
262
|
* `includeFile = false` gives the package module only, where its globals are
|
|
134
263
|
*/
|
|
135
264
|
export function PackageContext__ModulePath_Z55EFCE8F(this$, fileName, includeFile) {
|
|
265
|
+
return PackageContext__ModulePath_Z7E147617(this$, fileName, includeFile, undefined);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* `name` is the declaration at the top of the file the reference lands in
|
|
270
|
+
*/
|
|
271
|
+
export function PackageContext__ModulePath_Z7E147617(this$, fileName, includeFile, name) {
|
|
136
272
|
const matchValue = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
|
|
137
273
|
if (matchValue != null) {
|
|
138
274
|
const package$ = matchValue;
|
|
139
275
|
const fileName_1 = normalizePath(fileName);
|
|
140
|
-
|
|
276
|
+
const isHoisted = (name == null) ? false : PackageContext__IsHoisted_32BC514A(this$, package$, fileName_1, name);
|
|
277
|
+
return toList(delay(() => append(singleton(package$.ModuleName), delay(() => (((includeFile && (fileName_1 !== package$.EntryFile)) && !isHoisted) ? singleton(PackageContext__FileModuleName_Z11793CAF(this$, package$, fileName_1)) : empty())))));
|
|
141
278
|
}
|
|
142
279
|
else {
|
|
143
280
|
return defaultArg(PackageContext__TryFindExternalModulePath_Z55EFCE8F(this$, fileName, includeFile), empty_1());
|
|
@@ -166,7 +303,17 @@ export function PackageContext__ImportSpecifier_Z721C83C5(this$, fileName) {
|
|
|
166
303
|
else {
|
|
167
304
|
const matchValue_1 = tryFind((tupledArg) => (tupledArg[0] === fileName_1), package$.SubpathEntries);
|
|
168
305
|
if (matchValue_1 == null) {
|
|
169
|
-
|
|
306
|
+
const matchValue_2 = FSharpMap__TryFind(package$.ReExportedFiles, fileName_1);
|
|
307
|
+
if (matchValue_2 == null) {
|
|
308
|
+
return ((package$.RuntimeName + "/") + withoutDeclarationExtension(substring(fileName_1, package$.Dir.length))) + ".js";
|
|
309
|
+
}
|
|
310
|
+
else if (matchValue_2 === "") {
|
|
311
|
+
return package$.RuntimeName;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
const subpath_1 = matchValue_2;
|
|
315
|
+
return (package$.RuntimeName + "/") + subpath_1;
|
|
316
|
+
}
|
|
170
317
|
}
|
|
171
318
|
else {
|
|
172
319
|
return (package$.RuntimeName + "/") + matchValue_1[1];
|
|
@@ -178,3 +325,131 @@ export function PackageContext__ImportSpecifier_Z721C83C5(this$, fileName) {
|
|
|
178
325
|
}
|
|
179
326
|
}
|
|
180
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Whether a public entry of the package re-exports a declaration of the file
|
|
330
|
+
*/
|
|
331
|
+
export function PackageContext__IsReExported_Z721C83C5(this$, fileName) {
|
|
332
|
+
const matchValue = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
|
|
333
|
+
if (matchValue != null) {
|
|
334
|
+
const package$ = matchValue;
|
|
335
|
+
const fileName_1 = normalizePath(fileName);
|
|
336
|
+
if ((fileName_1 === package$.EntryFile) ? true : exists((tupledArg) => (tupledArg[0] === fileName_1), package$.SubpathEntries)) {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
return FSharpMap__ContainsKey(package$.ReExportedFiles, fileName_1);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Whether a specifier can import the declaration at runtime: the `exports` map of a package
|
|
350
|
+
* blocks the file declaring it unless a public entry exports the name
|
|
351
|
+
*/
|
|
352
|
+
export function PackageContext__IsImportable_Z384F8060(this$, fileName, name) {
|
|
353
|
+
const matchValue = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
|
|
354
|
+
if (matchValue != null) {
|
|
355
|
+
if (!matchValue.HasExportsMap) {
|
|
356
|
+
const package$_1 = matchValue;
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
const package$_2 = matchValue;
|
|
361
|
+
const fileName_1 = normalizePath(fileName);
|
|
362
|
+
if ((fileName_1 === package$_2.EntryFile) ? true : exists((tupledArg) => (tupledArg[0] === fileName_1), package$_2.SubpathEntries)) {
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
else if (name === "default") {
|
|
366
|
+
return FSharpMap__ContainsKey(package$_2.DefaultExportNames, fileName_1);
|
|
367
|
+
}
|
|
368
|
+
else if (FSharpMap__ContainsKey(package$_2.ReExportedSymbols, [fileName_1, name])) {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
return FSharpMap__ContainsKey(package$_2.ReExportedNames, name);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* The name a public entry exports the default export of the file under
|
|
383
|
+
*/
|
|
384
|
+
export function PackageContext__DefaultExportName_Z721C83C5(this$, fileName) {
|
|
385
|
+
const option_1 = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
|
|
386
|
+
if (option_1 != null) {
|
|
387
|
+
return FSharpMap__TryFind(option_1.DefaultExportNames, normalizePath(fileName));
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* The declarations of the file a public entry re-exports, with the specifier to import each
|
|
396
|
+
* of them from
|
|
397
|
+
*/
|
|
398
|
+
export function PackageContext__SymbolSpecifiers_Z721C83C5(this$, fileName) {
|
|
399
|
+
const matchValue = PackageContext__TryFindPackage_Z721C83C5(this$, fileName);
|
|
400
|
+
if (matchValue != null) {
|
|
401
|
+
const package$ = matchValue;
|
|
402
|
+
const fileName_1 = normalizePath(fileName);
|
|
403
|
+
const specifierOf = (subpath) => {
|
|
404
|
+
if (subpath === "") {
|
|
405
|
+
return package$.RuntimeName;
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
return (package$.RuntimeName + "/") + subpath;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
return fold((acc, name_1, specifier) => add(name_1, specifier, acc), PackageContext__IsReExported_Z721C83C5(this$, fileName_1) ? empty_2({
|
|
412
|
+
Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
|
|
413
|
+
}) : map_2((_arg, subpath_1) => specifierOf(subpath_1), package$.ReExportedNames), ofList(choose((tupledArg) => {
|
|
414
|
+
const _arg_1 = tupledArg[0];
|
|
415
|
+
if (_arg_1[0] === fileName_1) {
|
|
416
|
+
return [_arg_1[1], specifierOf(tupledArg[1])];
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
}, toList_1(package$.ReExportedSymbols)), {
|
|
422
|
+
Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
|
|
423
|
+
}));
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
return empty_2({
|
|
427
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The declarations being read, so that one reaching itself through its members is detected
|
|
434
|
+
*/
|
|
435
|
+
export class ReadInProgress extends Record {
|
|
436
|
+
constructor(Intersections, Expansions, Partials, KeyOfDeclarations, TypeQueryDeclarations, UnionAliases, Landing) {
|
|
437
|
+
super();
|
|
438
|
+
this.Intersections = Intersections;
|
|
439
|
+
this.Expansions = Expansions;
|
|
440
|
+
this.Partials = Partials;
|
|
441
|
+
this.KeyOfDeclarations = KeyOfDeclarations;
|
|
442
|
+
this.TypeQueryDeclarations = TypeQueryDeclarations;
|
|
443
|
+
this.UnionAliases = UnionAliases;
|
|
444
|
+
this.Landing = Landing;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export function ReadInProgress_$reflection() {
|
|
449
|
+
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"))]]);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export function ReadInProgress_Create() {
|
|
453
|
+
return new ReadInProgress([], [], [], [], [], [], []);
|
|
454
|
+
}
|
|
455
|
+
|
|
@@ -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) {
|