@glutinum/cli 0.14.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 +154 -69
- package/dist/Glutinum.Converter/Generate.js +44 -23
- package/dist/Glutinum.Converter/GlueAST.js +122 -74
- package/dist/Glutinum.Converter/Hosting.js +892 -0
- package/dist/Glutinum.Converter/Merge.js +469 -301
- package/dist/Glutinum.Converter/Packages.js +403 -77
- package/dist/Glutinum.Converter/Printer.js +455 -388
- package/dist/Glutinum.Converter/Read.js +366 -104
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +9 -9
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
- package/dist/Glutinum.Converter/Reader/Declaration.js +24 -30
- package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
- package/dist/Glutinum.Converter/Reader/Documentation.js +56 -67
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +105 -38
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +52 -55
- package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +28 -16
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +46 -45
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +48 -5
- package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
- package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +55 -7
- package/dist/Glutinum.Converter/Reader/Node.js +23 -26
- package/dist/Glutinum.Converter/Reader/Parameters.js +39 -30
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
- package/dist/Glutinum.Converter/Reader/TypeNode.js +410 -1545
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +78 -51
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +116 -71
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +25 -7
- package/dist/Glutinum.Converter/Reader/Types.js +296 -16
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +21 -34
- package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
- package/dist/Glutinum.Converter/Reader/Utils.js +584 -148
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +2971 -6875
- 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 +193 -211
- package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
- package/dist/Glutinum.Converter/Utils/String.js +15 -4
- package/dist/Program.js +107 -232
- package/package.json +4 -3
- package/dist/Glutinum.Converter/TypeScript.js +0 -12
- package/src/Glutinum.Converter/js/bootstrap.js +0 -123
- package/src/Glutinum.Converter/js/host.js +0 -144
- package/src/Glutinum.Converter/js/npm.js +0 -137
- package/src/Glutinum.Converter/js/resolve.js +0 -402
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
|
|
2
|
-
import { singleton, empty, append as append_1, delay, indexed, choose, toList, tryItem } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
3
2
|
import { ts } from "@ts-morph/bootstrap";
|
|
3
|
+
import { singleton, empty, append as append_1, delay, indexed, choose, toList, tryItem } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
4
4
|
import { isNullOrWhiteSpace, concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
|
|
5
|
-
import { value as
|
|
5
|
+
import { value as value_3, defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
6
6
|
import { match } from "../../fable_modules/fable-library-js.5.17.2/RegExp.js";
|
|
7
7
|
import { empty as empty_1, forAll, append } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
8
8
|
import { splitLines } from "../Utils/String.js";
|
|
9
9
|
import { GlueCommentParam, GlueCommentTypeParam, GlueComment } from "../GlueAST.js";
|
|
10
|
+
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
11
|
+
|
|
12
|
+
function textOfComment(comment) {
|
|
13
|
+
if (typeof comment === "string") {
|
|
14
|
+
return ts.getTextOfJSDocComment(comment);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return ts.getTextOfJSDocComment(comment);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
10
20
|
|
|
11
21
|
function readDocumentation(reader, summary, jsDocTags) {
|
|
12
22
|
const isInlineLinkReadAsTag = (tag) => {
|
|
13
|
-
if ((tag.kind ===
|
|
23
|
+
if ((tag.kind === 328) && (tag.tagName.getText() === "link")) {
|
|
14
24
|
const start = ~~tag.getStart() | 0;
|
|
15
25
|
if (start > 0) {
|
|
16
26
|
return tag.getSourceFile().text[start - 1] === "{";
|
|
@@ -44,13 +54,7 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
44
54
|
case 0: {
|
|
45
55
|
let option_4;
|
|
46
56
|
const option_2 = nextTag_1.comment;
|
|
47
|
-
|
|
48
|
-
const comment_1 = option_2;
|
|
49
|
-
option_4 = ts.getTextOfJSDocComment(comment_1);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
option_4 = undefined;
|
|
53
|
-
}
|
|
57
|
+
option_4 = ((option_2 != null) ? textOfComment(option_2) : undefined);
|
|
54
58
|
if (option_4 != null) {
|
|
55
59
|
return concat("{@link ", option_4);
|
|
56
60
|
}
|
|
@@ -63,8 +67,7 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
else {
|
|
66
|
-
|
|
67
|
-
return defaultArg(ts.getTextOfJSDocComment(comment), "");
|
|
70
|
+
return defaultArg(textOfComment(matchValue), "");
|
|
68
71
|
}
|
|
69
72
|
};
|
|
70
73
|
const blockLinks = toList(choose((tag_2) => {
|
|
@@ -72,7 +75,7 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
72
75
|
const matchValue_2 = tag_2.kind;
|
|
73
76
|
const matchValue_3 = tag_2.comment;
|
|
74
77
|
let matchResult_1, comment_3;
|
|
75
|
-
if (matchValue_2 ===
|
|
78
|
+
if (matchValue_2 === 328) {
|
|
76
79
|
if (matchValue_3 != null) {
|
|
77
80
|
if ((tag_2.tagName.getText() === "link") && !isInlineLinkReadAsTag(tag_2)) {
|
|
78
81
|
matchResult_1 = 0;
|
|
@@ -91,7 +94,7 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
91
94
|
}
|
|
92
95
|
switch (matchResult_1) {
|
|
93
96
|
case 0: {
|
|
94
|
-
const option_6 =
|
|
97
|
+
const option_6 = textOfComment(comment_3);
|
|
95
98
|
if (option_6 != null) {
|
|
96
99
|
return (text_1 = option_6, (m = match(/^\[(?<label>[^\]]+)\]\((?<url>[^)\s]+)\)$/gu, text_1.trim()), (m != null) ? (`{@link ${(m.groups && m.groups.url) || ""} | ${(m.groups && m.groups.label) || ""}}`) : concat("{@link ", text_1.trim(), "}")));
|
|
97
100
|
}
|
|
@@ -111,52 +114,36 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
111
114
|
const tag_3 = tupledArg[1];
|
|
112
115
|
const matchValue_5 = tag_3.kind;
|
|
113
116
|
switch (matchValue_5) {
|
|
114
|
-
case
|
|
117
|
+
case 328: {
|
|
118
|
+
const textTag = (make) => {
|
|
119
|
+
const option_13 = tag_3.comment;
|
|
120
|
+
if (option_13 != null) {
|
|
121
|
+
return make(defaultArg(textOfComment(option_13), ""));
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
115
127
|
const matchValue_8 = tag_3.tagName.getText();
|
|
116
128
|
switch (matchValue_8) {
|
|
117
|
-
case "remarks":
|
|
129
|
+
case "remarks":
|
|
130
|
+
return textTag((Item_4) => (new GlueComment(/* Remarks */ 4, [Item_4])));
|
|
131
|
+
case "defaultValue":
|
|
132
|
+
return textTag((Item_5) => (new GlueComment(/* DefaultValue */ 5, [Item_5])));
|
|
133
|
+
case "example":
|
|
134
|
+
return textTag((Item_6) => (new GlueComment(/* Example */ 6, [Item_6])));
|
|
135
|
+
case "typeParam": {
|
|
118
136
|
const matchValue_9 = tag_3.comment;
|
|
119
137
|
if (matchValue_9 == null) {
|
|
120
138
|
return undefined;
|
|
121
139
|
}
|
|
122
140
|
else {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
case "defaultValue": {
|
|
128
|
-
const matchValue_10 = tag_3.comment;
|
|
129
|
-
if (matchValue_10 == null) {
|
|
130
|
-
return undefined;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
const comment_7 = matchValue_10;
|
|
134
|
-
return new GlueComment(/* DefaultValue */ 5, [defaultArg(ts.getTextOfJSDocComment(comment_7), "")]);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
case "example": {
|
|
138
|
-
const matchValue_11 = tag_3.comment;
|
|
139
|
-
if (matchValue_11 == null) {
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
const comment_8 = matchValue_11;
|
|
144
|
-
return new GlueComment(/* Example */ 6, [defaultArg(ts.getTextOfJSDocComment(comment_8), "")]);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
case "typeParam": {
|
|
148
|
-
const matchValue_12 = tag_3.comment;
|
|
149
|
-
if (matchValue_12 == null) {
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
const comment_9 = matchValue_12;
|
|
154
|
-
const matchValue_13 = ts.getTextOfJSDocComment(comment_9);
|
|
155
|
-
if (matchValue_13 == null) {
|
|
141
|
+
const matchValue_10 = textOfComment(matchValue_9);
|
|
142
|
+
if (matchValue_10 == null) {
|
|
156
143
|
return undefined;
|
|
157
144
|
}
|
|
158
145
|
else {
|
|
159
|
-
const text_3 =
|
|
146
|
+
const text_3 = matchValue_10;
|
|
160
147
|
const m_1 = match(/\s*(?<type>[^-\s]*)\s*-\s*(?<description>.*)/gus, text_3);
|
|
161
148
|
if (m_1 != null) {
|
|
162
149
|
return new GlueComment(/* TypeParam */ 7, [new GlueCommentTypeParam((m_1.groups && m_1.groups.type) || "", ((m_1.groups && m_1.groups.description) != null) ? ((m_1.groups && m_1.groups.description) || "") : undefined)]);
|
|
@@ -174,31 +161,24 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
174
161
|
return undefined;
|
|
175
162
|
}
|
|
176
163
|
}
|
|
177
|
-
case
|
|
164
|
+
case 332: {
|
|
178
165
|
const matchValue_7 = tag_3.comment;
|
|
179
166
|
if (matchValue_7 == null) {
|
|
180
167
|
return new GlueComment(/* Deprecated */ 3, [undefined]);
|
|
181
168
|
}
|
|
182
169
|
else {
|
|
183
|
-
|
|
184
|
-
return new GlueComment(/* Deprecated */ 3, [ts.getTextOfJSDocComment(comment_5)]);
|
|
170
|
+
return new GlueComment(/* Deprecated */ 3, [textOfComment(matchValue_7)]);
|
|
185
171
|
}
|
|
186
172
|
}
|
|
187
|
-
case
|
|
173
|
+
case 342: {
|
|
188
174
|
const parameterTag = tag_3;
|
|
189
175
|
const identifier = parameterTag.name;
|
|
190
176
|
let content_1;
|
|
191
177
|
const matchValue_6 = parameterTag.comment;
|
|
192
|
-
|
|
193
|
-
content_1 = undefined;
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
const comment_4 = matchValue_6;
|
|
197
|
-
content_1 = ts.getTextOfJSDocComment(comment_4);
|
|
198
|
-
}
|
|
178
|
+
content_1 = ((matchValue_6 == null) ? undefined : textOfComment(matchValue_6));
|
|
199
179
|
return new GlueComment(/* Param */ 2, [new GlueCommentParam(identifier.getText(), content_1)]);
|
|
200
180
|
}
|
|
201
|
-
case
|
|
181
|
+
case 343: {
|
|
202
182
|
const option_8 = readTagComment(index_1, tag_3);
|
|
203
183
|
if (option_8 != null) {
|
|
204
184
|
return new GlueComment(/* Returns */ 1, [option_8]);
|
|
@@ -207,7 +187,7 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
207
187
|
return undefined;
|
|
208
188
|
}
|
|
209
189
|
}
|
|
210
|
-
case
|
|
190
|
+
case 350: {
|
|
211
191
|
const option_10 = readTagComment(index_1, tag_3);
|
|
212
192
|
if (option_10 != null) {
|
|
213
193
|
return new GlueComment(/* Throws */ 8, [option_10]);
|
|
@@ -221,8 +201,8 @@ function readDocumentation(reader, summary, jsDocTags) {
|
|
|
221
201
|
}
|
|
222
202
|
}, indexed(jsDocTags)));
|
|
223
203
|
return toList(delay(() => {
|
|
224
|
-
let
|
|
225
|
-
return append_1((
|
|
204
|
+
let matchValue_11;
|
|
205
|
+
return append_1((matchValue_11 = summary_1, (matchValue_11 == null) ? (empty()) : singleton(matchValue_11)), delay(() => jsDocTags_1));
|
|
226
206
|
}));
|
|
227
207
|
}
|
|
228
208
|
|
|
@@ -237,6 +217,15 @@ export function readDocumentationForSignature(reader, declaration) {
|
|
|
237
217
|
}
|
|
238
218
|
}
|
|
239
219
|
|
|
220
|
+
function jsDocTagsOfParent(node) {
|
|
221
|
+
if (Operators_IsNull(node.parent)) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
return ts.getJSDocTags(node.parent);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
240
229
|
export function readDocumentationForNode(reader, node) {
|
|
241
230
|
const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(node);
|
|
242
231
|
if (matchValue == null) {
|
|
@@ -245,13 +234,13 @@ export function readDocumentationForNode(reader, node) {
|
|
|
245
234
|
return empty_1();
|
|
246
235
|
}
|
|
247
236
|
else {
|
|
248
|
-
const symbol_1 =
|
|
237
|
+
const symbol_1 = value_3(matchValue_1);
|
|
249
238
|
return readDocumentation(reader, symbol_1.getDocumentationComment(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]()), ts.getJSDocTags(node));
|
|
250
239
|
}
|
|
251
240
|
}
|
|
252
241
|
else {
|
|
253
242
|
const symbol = matchValue;
|
|
254
|
-
return readDocumentation(reader, symbol.getDocumentationComment(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]()),
|
|
243
|
+
return readDocumentation(reader, symbol.getDocumentationComment(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]()), jsDocTagsOfParent(node));
|
|
255
244
|
}
|
|
256
245
|
}
|
|
257
246
|
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
import { equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { defaultOf, equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
3
|
+
import { PackageContext__DefaultExportName_Z721C83C5, PackageContext__TryFindPackage_Z721C83C5 } from "./Types.js";
|
|
4
|
+
import { normalizePath } from "../Utils/String.js";
|
|
5
|
+
import { forAll } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
6
|
+
import { isLetterOrDigit } from "../../fable_modules/fable-library-js.5.17.2/Char.js";
|
|
7
|
+
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
8
|
+
import { primitiveOfFlags, $007CHasTypeFlags$007C_$007C, $007CHasSymbolFlags$007C_$007C } from "./Utils.js";
|
|
9
|
+
import { value as value_2, some, defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
10
|
+
import { GlueVariable, GlueFunctionDeclaration, GluePrimitive, GlueType } from "../GlueAST.js";
|
|
5
11
|
import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
6
12
|
|
|
7
13
|
export function readExportAssignment(reader, exportNode) {
|
|
8
|
-
let declaration;
|
|
14
|
+
let declaration, package$, name_1, declares, exports, option_5, moduleSymbol, declaration_1, declarations;
|
|
9
15
|
const symbolOpt = exportNode.symbol;
|
|
10
|
-
let
|
|
11
|
-
if (
|
|
16
|
+
let targetDeclarationKind;
|
|
17
|
+
if (exportNode.expression.kind === 80) {
|
|
12
18
|
let option_3;
|
|
13
19
|
const option_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(exportNode.expression);
|
|
14
20
|
if (option_1 != null) {
|
|
@@ -18,39 +24,77 @@ export function readExportAssignment(reader, exportNode) {
|
|
|
18
24
|
else {
|
|
19
25
|
option_3 = undefined;
|
|
20
26
|
}
|
|
21
|
-
|
|
27
|
+
targetDeclarationKind = ((option_3 != null) ? ((declaration = option_3, declaration.kind)) : undefined);
|
|
22
28
|
}
|
|
23
29
|
else {
|
|
24
|
-
|
|
30
|
+
targetDeclarationKind = undefined;
|
|
25
31
|
}
|
|
26
|
-
const
|
|
27
|
-
const
|
|
32
|
+
const exportEqualsDeclarationKind = equals(exportNode.isExportEquals, true) ? targetDeclarationKind : undefined;
|
|
33
|
+
const isDefaultOfVariable = !equals(exportNode.isExportEquals, true) && equals(targetDeclarationKind, 261);
|
|
34
|
+
const sourceFile = exportNode.getSourceFile();
|
|
35
|
+
let packageName;
|
|
36
|
+
let option_14;
|
|
37
|
+
let option_12;
|
|
38
|
+
let option_10;
|
|
39
|
+
const option_8 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
|
|
40
|
+
option_10 = ((option_8 != null) ? PackageContext__TryFindPackage_Z721C83C5(option_8, sourceFile.fileName) : undefined);
|
|
41
|
+
option_12 = ((option_10 != null) ? (((package$ = option_10, normalizePath(sourceFile.fileName) === package$.EntryFile)) ? option_10 : undefined) : undefined);
|
|
42
|
+
option_14 = ((option_12 != null) ? option_12.RuntimeName : undefined);
|
|
43
|
+
packageName = ((option_14 != null) ? (((name_1 = option_14, forAll((c) => {
|
|
44
|
+
if (isLetterOrDigit(c)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return c === "_";
|
|
49
|
+
}
|
|
50
|
+
}, name_1.split("")) && !((declares = ((table) => {
|
|
51
|
+
if (Operators_IsNull(table)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const symbol_1 = table.get(name_1);
|
|
56
|
+
if (!Operators_IsNull(symbol_1)) {
|
|
57
|
+
const matchValue = symbol_1.flags;
|
|
58
|
+
if ($007CHasSymbolFlags$007C_$007C(2097152, matchValue) != null) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}), (exports = defaultArg((option_5 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(sourceFile), (option_5 != null) ? some((moduleSymbol = option_5, moduleSymbol.exports)) : undefined), defaultOf()), declares(sourceFile.locals) ? true : declares(exports)))))) ? option_14 : undefined) : undefined);
|
|
70
|
+
let publishedName;
|
|
71
|
+
const option_16 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_PackageContext"]();
|
|
72
|
+
publishedName = ((option_16 != null) ? PackageContext__DefaultExportName_Z721C83C5(option_16, sourceFile.fileName) : undefined);
|
|
73
|
+
const isExportEqualsOfVariable = equals(exportEqualsDeclarationKind, 261);
|
|
74
|
+
const isExportEqualsOfDeclaration = equals(exportEqualsDeclarationKind, 263) ? true : equals(exportEqualsDeclarationKind, 264);
|
|
28
75
|
if (symbolOpt == null) {
|
|
29
76
|
return GlueType.Discard;
|
|
30
77
|
}
|
|
31
78
|
else {
|
|
32
|
-
const
|
|
33
|
-
if (((
|
|
79
|
+
const symbol_2 = symbolOpt;
|
|
80
|
+
if (((symbol_2.name === "default") ? true : isExportEqualsOfVariable) ? true : isExportEqualsOfDeclaration) {
|
|
34
81
|
if (exportNode.expression.kind === 80) {
|
|
35
82
|
const identiferNode = exportNode.expression;
|
|
36
83
|
let declaredTypeNode;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
else {
|
|
52
|
-
declaredTypeNode = undefined;
|
|
53
|
-
}
|
|
84
|
+
let option_22;
|
|
85
|
+
let option_20;
|
|
86
|
+
const option_18 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(exportNode.expression);
|
|
87
|
+
if (option_18 != null) {
|
|
88
|
+
const _arg_1 = option_18;
|
|
89
|
+
option_20 = _arg_1.valueDeclaration;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
option_20 = undefined;
|
|
93
|
+
}
|
|
94
|
+
option_22 = ((option_20 != null) ? (((declaration_1 = option_20, declaration_1.kind === 261)) ? option_20 : undefined) : undefined);
|
|
95
|
+
if (option_22 != null) {
|
|
96
|
+
const declaration_2 = option_22;
|
|
97
|
+
declaredTypeNode = declaration_2.type;
|
|
54
98
|
}
|
|
55
99
|
else {
|
|
56
100
|
declaredTypeNode = undefined;
|
|
@@ -58,26 +102,49 @@ export function readExportAssignment(reader, exportNode) {
|
|
|
58
102
|
let typ;
|
|
59
103
|
const tsTyp = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeAtLocation(exportNode.expression);
|
|
60
104
|
if (declaredTypeNode == null) {
|
|
61
|
-
const
|
|
62
|
-
if ($007CHasTypeFlags$007C_$007C(
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
105
|
+
const matchValue_2 = tsTyp.flags;
|
|
106
|
+
if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_2) != null) {
|
|
107
|
+
const matchValue_3 = tsTyp.symbol.declarations;
|
|
108
|
+
let matchResult, declarations_1;
|
|
109
|
+
if (matchValue_3 != null) {
|
|
110
|
+
if ((declarations = matchValue_3, declarations.length === 1)) {
|
|
111
|
+
matchResult = 0;
|
|
112
|
+
declarations_1 = matchValue_3;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
matchResult = 1;
|
|
116
|
+
}
|
|
66
117
|
}
|
|
67
118
|
else {
|
|
68
|
-
|
|
69
|
-
|
|
119
|
+
matchResult = 1;
|
|
120
|
+
}
|
|
121
|
+
switch (matchResult) {
|
|
122
|
+
case 0: {
|
|
123
|
+
typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](item(0, declarations_1));
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
default:
|
|
127
|
+
typ = (new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
|
|
70
128
|
}
|
|
71
129
|
}
|
|
72
130
|
else {
|
|
73
|
-
typ = (
|
|
131
|
+
typ = primitiveOfFlags(tsTyp);
|
|
74
132
|
}
|
|
75
133
|
}
|
|
76
134
|
else {
|
|
77
135
|
const typeNode = declaredTypeNode;
|
|
78
136
|
typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
|
|
79
137
|
}
|
|
80
|
-
|
|
138
|
+
const documentation = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](exportNode);
|
|
139
|
+
const isPublished = isDefaultOfVariable && (publishedName != null);
|
|
140
|
+
const name_2 = isExportEqualsOfVariable ? ("export=" + identiferNode.getText()) : (isPublished ? value_2(publishedName) : (isDefaultOfVariable ? defaultArg(packageName, identiferNode.getText()) : identiferNode.getText()));
|
|
141
|
+
const declaration_3 = (typ.tag === 15) ? (isDefaultOfVariable ? (new GlueType(/* FunctionDeclaration */ 6, [new GlueFunctionDeclaration(documentation, true, name_2, typ.fields[0].Type, typ.fields[0].Parameters, typ.fields[0].TypeParameters)])) : (new GlueType(/* Variable */ 2, [new GlueVariable(documentation, name_2, typ)]))) : (new GlueType(/* Variable */ 2, [new GlueVariable(documentation, name_2, typ)]));
|
|
142
|
+
if (isPublished) {
|
|
143
|
+
return declaration_3;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
return new GlueType(/* ExportDefault */ 25, [declaration_3]);
|
|
147
|
+
}
|
|
81
148
|
}
|
|
82
149
|
else {
|
|
83
150
|
return GlueType.Discard;
|
|
@@ -1,35 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
import { modulePathForDeclaration,
|
|
3
|
-
import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
|
|
2
|
+
import { modulePathForDeclaration, resolveAlias } from "./Utils.js";
|
|
4
3
|
import { normalizePath } from "../Utils/String.js";
|
|
5
|
-
import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
4
|
+
import { contains, item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
6
5
|
import { PackageContext__IsExternal_Z721C83C5 } from "./Types.js";
|
|
7
|
-
import { filter, collect, choose, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
8
|
-
import { List_distinctBy } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
9
|
-
import { newGuid } from "../../fable_modules/fable-library-js.5.17.2/Guid.js";
|
|
6
|
+
import { filter, collect, choose, cons, fold, reverse, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
|
|
10
7
|
import { GlueType, GlueReExport } from "../GlueAST.js";
|
|
11
8
|
import { toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
12
9
|
import { stringHash } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
13
10
|
|
|
14
|
-
function tryResolveAlias(checker, symbol) {
|
|
15
|
-
const matchValue = symbol.flags;
|
|
16
|
-
if ($007CHasSymbolFlags$007C_$007C(2097152, matchValue) != null) {
|
|
17
|
-
try {
|
|
18
|
-
const aliased = checker.getAliasedSymbol(symbol);
|
|
19
|
-
return Operators_IsNull(aliased) ? undefined : aliased;
|
|
20
|
-
}
|
|
21
|
-
catch (matchValue_1) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return symbol;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
11
|
function readReExport(reader, packageContext, currentFile, exportedName, symbol) {
|
|
31
12
|
let declarations;
|
|
32
|
-
const matchValue =
|
|
13
|
+
const matchValue = resolveAlias(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), symbol);
|
|
33
14
|
if (matchValue != null) {
|
|
34
15
|
const target = matchValue;
|
|
35
16
|
const matchValue_1 = target.declarations;
|
|
@@ -53,41 +34,48 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
|
|
|
53
34
|
return empty();
|
|
54
35
|
}
|
|
55
36
|
else {
|
|
56
|
-
return
|
|
37
|
+
return reverse(fold((tupledArg, glueType) => {
|
|
38
|
+
const kept = tupledArg[0];
|
|
39
|
+
const hasInterface = tupledArg[1];
|
|
57
40
|
let matchResult_1;
|
|
58
|
-
if (glueType.tag ===
|
|
41
|
+
if (glueType.tag === 32) {
|
|
59
42
|
if (glueType.fields[0].Declaration.tag === 1) {
|
|
60
|
-
|
|
43
|
+
if (hasInterface) {
|
|
44
|
+
matchResult_1 = 0;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
matchResult_1 = 1;
|
|
48
|
+
}
|
|
61
49
|
}
|
|
62
50
|
else {
|
|
63
|
-
matchResult_1 =
|
|
51
|
+
matchResult_1 = 2;
|
|
64
52
|
}
|
|
65
53
|
}
|
|
66
54
|
else {
|
|
67
|
-
matchResult_1 =
|
|
55
|
+
matchResult_1 = 2;
|
|
68
56
|
}
|
|
69
57
|
switch (matchResult_1) {
|
|
70
58
|
case 0:
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
return [kept, true];
|
|
60
|
+
case 1:
|
|
61
|
+
return [cons(glueType, kept), true];
|
|
62
|
+
default:
|
|
63
|
+
return [cons(glueType, kept), hasInterface];
|
|
76
64
|
}
|
|
77
|
-
}, choose((declaration) => {
|
|
65
|
+
}, [empty(), false], choose((declaration) => {
|
|
78
66
|
let declaration_1;
|
|
79
67
|
let option_1;
|
|
80
68
|
const matchValue_2 = declaration.kind;
|
|
81
69
|
switch (matchValue_2) {
|
|
82
|
-
case
|
|
70
|
+
case 261: {
|
|
83
71
|
option_1 = declaration.parent.parent;
|
|
84
72
|
break;
|
|
85
73
|
}
|
|
86
|
-
case 262:
|
|
87
74
|
case 263:
|
|
88
75
|
case 264:
|
|
89
76
|
case 265:
|
|
90
|
-
case 266:
|
|
77
|
+
case 266:
|
|
78
|
+
case 267: {
|
|
91
79
|
option_1 = declaration;
|
|
92
80
|
break;
|
|
93
81
|
}
|
|
@@ -95,15 +83,12 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
|
|
|
95
83
|
option_1 = undefined;
|
|
96
84
|
}
|
|
97
85
|
if (option_1 != null) {
|
|
98
|
-
return (declaration_1 = option_1, new GlueType(/* ReExport */
|
|
86
|
+
return (declaration_1 = option_1, new GlueType(/* ReExport */ 32, [new GlueReExport(exportedName, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1), modulePathForDeclaration(packageContext, declaration_1))]));
|
|
99
87
|
}
|
|
100
88
|
else {
|
|
101
89
|
return undefined;
|
|
102
90
|
}
|
|
103
|
-
}, toList(declarations_1))
|
|
104
|
-
Equals: (x, y) => (x === y),
|
|
105
|
-
GetHashCode: (x) => (stringHash(x) | 0),
|
|
106
|
-
});
|
|
91
|
+
}, toList(declarations_1)))[0]);
|
|
107
92
|
}
|
|
108
93
|
}
|
|
109
94
|
default:
|
|
@@ -121,15 +106,15 @@ export function readExportDeclaration(reader, exportDeclaration) {
|
|
|
121
106
|
const packageContext = matchValue;
|
|
122
107
|
const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
|
|
123
108
|
const currentFile = normalizePath(exportDeclaration.getSourceFile().fileName);
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
126
|
-
const exportClause =
|
|
127
|
-
if (exportClause.kind ===
|
|
109
|
+
const matchValue_2 = exportDeclaration.exportClause;
|
|
110
|
+
if (matchValue_2 != null) {
|
|
111
|
+
const exportClause = matchValue_2;
|
|
112
|
+
if (exportClause.kind === 280) {
|
|
128
113
|
return collect((specifier) => {
|
|
129
114
|
const exportedName = specifier.name.text;
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
return readReExport(reader, packageContext, currentFile, exportedName,
|
|
115
|
+
const matchValue_6 = checker.getExportSpecifierLocalTargetSymbol(specifier);
|
|
116
|
+
if (matchValue_6 != null) {
|
|
117
|
+
return readReExport(reader, packageContext, currentFile, exportedName, matchValue_6);
|
|
133
118
|
}
|
|
134
119
|
else {
|
|
135
120
|
return empty();
|
|
@@ -141,12 +126,12 @@ export function readExportDeclaration(reader, exportDeclaration) {
|
|
|
141
126
|
}
|
|
142
127
|
}
|
|
143
128
|
else {
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
const moduleSpecifier =
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
const moduleSymbol =
|
|
129
|
+
const matchValue_3 = exportDeclaration.moduleSpecifier;
|
|
130
|
+
if (matchValue_3 != null) {
|
|
131
|
+
const moduleSpecifier = matchValue_3;
|
|
132
|
+
const matchValue_4 = checker.getSymbolAtLocation(moduleSpecifier);
|
|
133
|
+
if (matchValue_4 != null) {
|
|
134
|
+
const moduleSymbol = matchValue_4;
|
|
150
135
|
return collect((symbol_1) => readReExport(reader, packageContext, currentFile, symbol_1.name, symbol_1), filter((symbol) => (symbol.name !== "default"), toList(checker.getExportsOfModule(moduleSymbol))));
|
|
151
136
|
}
|
|
152
137
|
else {
|
|
@@ -159,6 +144,18 @@ export function readExportDeclaration(reader, exportDeclaration) {
|
|
|
159
144
|
}
|
|
160
145
|
}
|
|
161
146
|
else {
|
|
147
|
+
const matchValue_1 = exportDeclaration.moduleSpecifier;
|
|
148
|
+
if (matchValue_1 == null) {
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
const warning = "A re-export from another file is only resolved when generating a package, run `glue <package>` instead of a single declaration file";
|
|
152
|
+
if (!contains(warning, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), {
|
|
153
|
+
Equals: (x, y) => (x === y),
|
|
154
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
155
|
+
})) {
|
|
156
|
+
void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
162
159
|
return empty();
|
|
163
160
|
}
|
|
164
161
|
}
|