@glutinum/cli 1.0.0-beta.7 → 1.0.0-beta.8
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/dist/Glutinum.Converter/Hosting.js +2 -2
- package/dist/Glutinum.Converter/Packages.js +12 -21
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
- package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
- package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
- package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
- package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
- package/dist/Glutinum.Converter/Reader/TypeNode.js +48 -1941
- package/dist/Glutinum.Converter/Reader/UtilityType.js +803 -0
- package/dist/Glutinum.Converter/Reader/Utils.js +87 -47
- package/dist/Glutinum.Converter/Transform.js +83 -961
- package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
- package/package.json +1 -1
|
@@ -444,7 +444,7 @@ function Resolve_satisfiesComparator(version, comparator) {
|
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
function Resolve_satisfiesRange(version, range) {
|
|
447
|
+
export function Resolve_satisfiesRange(version, range) {
|
|
448
448
|
const parsed = Resolve_parseVersion(version);
|
|
449
449
|
const array_1 = split_1(range, ["||"], undefined, 0);
|
|
450
450
|
return array_1.some((alternative) => {
|
|
@@ -453,7 +453,7 @@ function Resolve_satisfiesRange(version, range) {
|
|
|
453
453
|
});
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
-
function Resolve_applyTypesVersions(typesVersions, file) {
|
|
456
|
+
export function Resolve_applyTypesVersions(typesVersions, file) {
|
|
457
457
|
if (typesVersions === null || typesVersions === undefined) {
|
|
458
458
|
return file;
|
|
459
459
|
}
|
|
@@ -13,8 +13,8 @@ import { contains, sortBy, tryFind as tryFind_1, collect, toArray, singleton, is
|
|
|
13
13
|
import { add, ofSeq as ofSeq_1, toList, FSharpMap__TryFind, FSharpMap__ContainsKey, FSharpMap__Add, containsKey, empty } from "../fable_modules/fable-library-js.5.17.2/Map.js";
|
|
14
14
|
import { PackageContext__TryFindPackage_Z721C83C5, PackageContext, ExternalPackage, PackageInfo } from "./Reader/Types.js";
|
|
15
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.17.2/Seq.js";
|
|
16
|
-
import { ambientModuleSpecifier, promotedAmbientModule, ambientModuleNames, $007CHasSymbolFlags$007C_$007C } from "./Reader/Utils.js";
|
|
17
16
|
import { toArray as toArray_1, defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
17
|
+
import { ambientModuleSpecifier, promotedAmbientModule, ambientModuleNames, $007CHasSymbolFlags$007C_$007C, resolveAlias } from "./Reader/Utils.js";
|
|
18
18
|
import { defaultMaxOverloads } from "./Transformer/UnionOverloads.js";
|
|
19
19
|
import { List_distinctBy, List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
20
20
|
import { readPackages } from "./Read.js";
|
|
@@ -109,18 +109,9 @@ function reExportedNames(program, checker, hasExportsMap, package$) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function resolveAlias(checker, symbol) {
|
|
113
|
-
const matchValue = symbol.flags;
|
|
114
|
-
if ($007CHasSymbolFlags$007C_$007C(2097152, matchValue) != null) {
|
|
115
|
-
return checker.getAliasedSymbol(symbol);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
return symbol;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
112
|
function defaultExportOf(program, checker, fileName) {
|
|
123
|
-
let
|
|
113
|
+
let symbol;
|
|
114
|
+
let option_6;
|
|
124
115
|
let option_3;
|
|
125
116
|
const option_1 = program.getSourceFile(fileName);
|
|
126
117
|
if (option_1 != null) {
|
|
@@ -132,13 +123,13 @@ function defaultExportOf(program, checker, fileName) {
|
|
|
132
123
|
}
|
|
133
124
|
if (option_3 != null) {
|
|
134
125
|
const moduleSymbol = option_3;
|
|
135
|
-
|
|
126
|
+
option_6 = tryFind((exported) => (exported.name === "default"), checker.getExportsOfModule(moduleSymbol));
|
|
136
127
|
}
|
|
137
128
|
else {
|
|
138
|
-
|
|
129
|
+
option_6 = undefined;
|
|
139
130
|
}
|
|
140
|
-
if (
|
|
141
|
-
return resolveAlias(checker,
|
|
131
|
+
if (option_6 != null) {
|
|
132
|
+
return (symbol = option_6, defaultArg(resolveAlias(checker, symbol), symbol));
|
|
142
133
|
}
|
|
143
134
|
else {
|
|
144
135
|
return undefined;
|
|
@@ -168,7 +159,7 @@ function reExportedSymbols(program, checker, hasExportsMap, package$) {
|
|
|
168
159
|
const tupledArg_3 = acc;
|
|
169
160
|
return fold_1((acc_1, exportedSymbol) => {
|
|
170
161
|
const exportName = exportedSymbol.name;
|
|
171
|
-
const exportedSymbol_1 = resolveAlias(checker, exportedSymbol);
|
|
162
|
+
const exportedSymbol_1 = defaultArg(resolveAlias(checker, exportedSymbol), exportedSymbol);
|
|
172
163
|
const matchValue_2 = exportedSymbol_1.declarations;
|
|
173
164
|
if (matchValue_2 != null) {
|
|
174
165
|
const tupledArg_2 = acc_1;
|
|
@@ -222,11 +213,11 @@ function declaredNames(program, checker, defaultExportNames, fileName) {
|
|
|
222
213
|
const moduleSymbol = matchValue_1;
|
|
223
214
|
const normalized = normalizePath(fileName);
|
|
224
215
|
return ofSeq(map_2((exportedSymbol_2) => {
|
|
225
|
-
let
|
|
216
|
+
let option_2;
|
|
226
217
|
if (exportedSymbol_2.name === "default") {
|
|
227
218
|
const matchValue_4 = FSharpMap__TryFind(defaultExportNames, normalized);
|
|
228
219
|
if (matchValue_4 == null) {
|
|
229
|
-
return defaultArg((
|
|
220
|
+
return defaultArg((option_2 = exportedSymbol_2.declarations, (option_2 != null) ? tryPick((declaration_1) => {
|
|
230
221
|
const matchValue_5 = declaration_1.name;
|
|
231
222
|
if (equals(matchValue_5, defaultOf())) {
|
|
232
223
|
return undefined;
|
|
@@ -234,7 +225,7 @@ function declaredNames(program, checker, defaultExportNames, fileName) {
|
|
|
234
225
|
else {
|
|
235
226
|
return matchValue_5.getText();
|
|
236
227
|
}
|
|
237
|
-
},
|
|
228
|
+
}, option_2) : undefined), exportedSymbol_2.name);
|
|
238
229
|
}
|
|
239
230
|
else {
|
|
240
231
|
return matchValue_4;
|
|
@@ -244,7 +235,7 @@ function declaredNames(program, checker, defaultExportNames, fileName) {
|
|
|
244
235
|
return exportedSymbol_2.name;
|
|
245
236
|
}
|
|
246
237
|
}, filter((exportedSymbol_1) => {
|
|
247
|
-
const matchValue_3 = resolveAlias(checker, exportedSymbol_1).declarations;
|
|
238
|
+
const matchValue_3 = defaultArg(resolveAlias(checker, exportedSymbol_1), exportedSymbol_1).declarations;
|
|
248
239
|
if (matchValue_3 == null) {
|
|
249
240
|
return false;
|
|
250
241
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
import { readTypeUsingFlags, inferTypeNodes, inferredConstraint, tryResolveDeferred, isAnyTypeParameter, isDeferredConditional } from "./Deferred.js";
|
|
3
|
+
import { GlueLiteral, GlueConditionalType, GlueTypeParameter, GlueTypeUnion, GlueType, GluePrimitive } from "../GlueAST.js";
|
|
4
|
+
import { stringHash, equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
5
|
+
import { map, ofArray } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
6
|
+
import { List_distinctBy } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
7
|
+
import { $007CHasTypeFlags$007C_$007C } from "./Utils.js";
|
|
8
|
+
|
|
9
|
+
export function readConditionalType(reader, typeNode) {
|
|
10
|
+
let branch, trueType, falseType;
|
|
11
|
+
const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
12
|
+
const conditionalTypeNode = typeNode;
|
|
13
|
+
const typ = checker.getTypeAtLocation(conditionalTypeNode);
|
|
14
|
+
if (isDeferredConditional(typ)) {
|
|
15
|
+
const resolved = isAnyTypeParameter(reader, conditionalTypeNode.checkType) ? ((branch = ((node) => {
|
|
16
|
+
const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](node);
|
|
17
|
+
let matchResult, glueType;
|
|
18
|
+
if (matchValue.tag === 8) {
|
|
19
|
+
if (matchValue.fields[0].tag === 4) {
|
|
20
|
+
matchResult = 0;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
matchResult = 1;
|
|
24
|
+
glueType = matchValue;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
matchResult = 1;
|
|
29
|
+
glueType = matchValue;
|
|
30
|
+
}
|
|
31
|
+
switch (matchResult) {
|
|
32
|
+
case 0:
|
|
33
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Null]);
|
|
34
|
+
default:
|
|
35
|
+
return glueType;
|
|
36
|
+
}
|
|
37
|
+
}), (trueType = branch(conditionalTypeNode.trueType), (falseType = branch(conditionalTypeNode.falseType), equals(trueType, falseType) ? trueType : (new GlueType(/* Union */ 7, [new GlueTypeUnion(ofArray([trueType, falseType]))])))))) : tryResolveDeferred(reader, typeNode);
|
|
38
|
+
if (resolved == null) {
|
|
39
|
+
const warningsCount = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length | 0;
|
|
40
|
+
const inferred = List_distinctBy((_arg) => _arg.Name, map((inferTypeNode) => (new GlueTypeParameter(inferTypeNode.typeParameter.name.getText(), inferredConstraint(reader, inferTypeNode), undefined)), inferTypeNodes(conditionalTypeNode.extendsType)), {
|
|
41
|
+
Equals: (x, y) => (x === y),
|
|
42
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
43
|
+
});
|
|
44
|
+
const conditionalType = new GlueConditionalType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.checkType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.extendsType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.trueType), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.falseType), inferred);
|
|
45
|
+
if (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length > warningsCount) {
|
|
46
|
+
reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().splice(warningsCount, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().length - warningsCount);
|
|
47
|
+
return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return new GlueType(/* ConditionalType */ 33, [conditionalType]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return resolved;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const matchValue_1 = typ.flags;
|
|
59
|
+
if ($007CHasTypeFlags$007C_$007C(524288, matchValue_1) != null) {
|
|
60
|
+
return new GlueType(/* TypeParameter */ 16, [typ.symbol.name]);
|
|
61
|
+
}
|
|
62
|
+
else if ($007CHasTypeFlags$007C_$007C(8192, matchValue_1) != null) {
|
|
63
|
+
return new GlueType(/* Literal */ 8, [new GlueLiteral(/* Bool */ 3, [typ.intrinsicName === "true"])]);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const matchValue_2 = readTypeUsingFlags(reader, typ);
|
|
67
|
+
let matchResult_1, forward;
|
|
68
|
+
if (matchValue_2.tag === 3) {
|
|
69
|
+
if (matchValue_2.fields[0].tag === 6) {
|
|
70
|
+
matchResult_1 = 0;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
matchResult_1 = 1;
|
|
74
|
+
forward = matchValue_2;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
matchResult_1 = 1;
|
|
79
|
+
forward = matchValue_2;
|
|
80
|
+
}
|
|
81
|
+
switch (matchResult_1) {
|
|
82
|
+
case 0:
|
|
83
|
+
return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](conditionalTypeNode.checkType);
|
|
84
|
+
default:
|
|
85
|
+
return forward;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|