@glutinum/cli 1.0.0-beta.2 → 1.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +16 -0
  2. package/dist/Glutinum.Converter/Abbreviations.js +9 -32
  3. package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
  4. package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
  5. package/dist/Glutinum.Converter/FsharpAST.js +116 -65
  6. package/dist/Glutinum.Converter/Generate.js +34 -21
  7. package/dist/Glutinum.Converter/GlueAST.js +79 -41
  8. package/dist/Glutinum.Converter/Hosting.js +132 -157
  9. package/dist/Glutinum.Converter/Merge.js +369 -337
  10. package/dist/Glutinum.Converter/Packages.js +391 -92
  11. package/dist/Glutinum.Converter/Printer.js +404 -424
  12. package/dist/Glutinum.Converter/Read.js +387 -88
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
  14. package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
  15. package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
  16. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
  17. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
  18. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
  19. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +15 -21
  20. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
  21. package/dist/Glutinum.Converter/Reader/Node.js +8 -11
  22. package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
  23. package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1343
  24. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
  25. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
  26. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
  27. package/dist/Glutinum.Converter/Reader/Types.js +290 -15
  28. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
  29. package/dist/Glutinum.Converter/Reader/Utils.js +343 -28
  30. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
  31. package/dist/Glutinum.Converter/Transform.js +3619 -8456
  32. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  33. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  34. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  35. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1149 -0
  36. package/dist/Glutinum.Converter/Transformer/Context.js +664 -0
  37. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  38. package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
  39. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  40. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
  41. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  42. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -0
  43. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  44. package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
  45. package/dist/Glutinum.Converter/Utils/String.js +14 -3
  46. package/dist/Program.js +18 -10
  47. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
3
3
  import { Exception, defaultOf } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
4
- import { resolveAlias, readMemberTypeParameters, ModifierUtil_GetAccessor_2944DA29, identifierText, ModifierUtil_HasModifier_742AC9D, ModifierUtil_GetAccessor_Z1CCFC6BA } from "./Utils.js";
4
+ import { resolveAlias, readMemberTypeParameters, isPrivateMember, ModifierUtil_GetAccessor_2944DA29, ModifierUtil_HasModifier_742AC9D, identifierText, ModifierUtil_GetAccessor_Z1CCFC6BA } from "./Utils.js";
5
5
  import { GlueAccessor, GlueType, GluePrimitive, GlueIndexSignature, GlueConstructSignature, GlueCallSignature, GlueSetAccessor, GlueGetAccessor, GlueMethod, GlueMethodSignature, GlueMember, GlueProperty } from "../GlueAST.js";
6
6
  import { defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
7
7
  import { exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
@@ -27,14 +27,12 @@ export function readDeclaration(reader, declaration) {
27
27
  case 173: {
28
28
  const propertyDeclaration = declaration;
29
29
  const name_4 = propertyDeclaration.name;
30
- const hasPrivateModifier = ModifierUtil_HasModifier_742AC9D(propertyDeclaration.modifiers, 123);
31
- const isPrivateIdentifier = name_4.kind === 81;
32
- return new GlueMember(/* Property */ 1, [(Name_1 = identifierText(name_4), (Documentation_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_4), (Type_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](propertyDeclaration.type), (IsOptional_1 = (propertyDeclaration.questionToken != null), new GlueProperty(Name_1, Documentation_2, Type_1, ModifierUtil_HasModifier_742AC9D(propertyDeclaration.modifiers, 126), IsOptional_1, ModifierUtil_GetAccessor_2944DA29(propertyDeclaration.modifiers), hasPrivateModifier ? true : isPrivateIdentifier)))))]);
30
+ return new GlueMember(/* Property */ 1, [(Name_1 = identifierText(name_4), (Documentation_2 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_4), (Type_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](propertyDeclaration.type), (IsOptional_1 = (propertyDeclaration.questionToken != null), new GlueProperty(Name_1, Documentation_2, Type_1, ModifierUtil_HasModifier_742AC9D(propertyDeclaration.modifiers, 126), IsOptional_1, ModifierUtil_GetAccessor_2944DA29(propertyDeclaration.modifiers), isPrivateMember(propertyDeclaration.modifiers, name_4))))))]);
33
31
  }
34
32
  case 174: {
35
33
  const methodSignature = declaration;
36
34
  const name_3 = methodSignature.name;
37
- return new GlueMember(/* MethodSignature */ 6, [(Documentation_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_3), new GlueMethodSignature(identifierText(name_3), Documentation_1, readMemberTypeParameters(reader, methodSignature.typeParameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](methodSignature.parameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](methodSignature.type)))]);
35
+ return new GlueMember(/* MethodSignature */ 6, [(Documentation_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_3), new GlueMethodSignature(identifierText(name_3), Documentation_1, readMemberTypeParameters(reader, methodSignature.typeParameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](methodSignature.parameters), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](methodSignature.type), methodSignature.questionToken != null))]);
38
36
  }
39
37
  case 175: {
40
38
  const methodDeclaration = declaration;
@@ -44,16 +42,12 @@ export function readDeclaration(reader, declaration) {
44
42
  case 178: {
45
43
  const getAccessorDeclaration = declaration;
46
44
  const name_5 = getAccessorDeclaration.name;
47
- const hasPrivateModifier_1 = ModifierUtil_HasModifier_742AC9D(getAccessorDeclaration.modifiers, 123);
48
- const isPrivateIdentifier_1 = name_5.kind === 81;
49
- return new GlueMember(/* GetAccessor */ 2, [new GlueGetAccessor(identifierText(name_5), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_5), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](getAccessorDeclaration.type), ModifierUtil_HasModifier_742AC9D(getAccessorDeclaration.modifiers, 126), hasPrivateModifier_1 ? true : isPrivateIdentifier_1)]);
45
+ return new GlueMember(/* GetAccessor */ 2, [new GlueGetAccessor(identifierText(name_5), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_5), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](getAccessorDeclaration.type), ModifierUtil_HasModifier_742AC9D(getAccessorDeclaration.modifiers, 126), isPrivateMember(getAccessorDeclaration.modifiers, name_5))]);
50
46
  }
51
47
  case 179: {
52
48
  const setAccessorDeclaration = declaration;
53
49
  const name_6 = setAccessorDeclaration.name;
54
- const hasPrivateModifier_2 = ModifierUtil_HasModifier_742AC9D(setAccessorDeclaration.modifiers, 123);
55
- const isPrivateIdentifier_2 = name_6.kind === 81;
56
- return new GlueMember(/* SetAccessor */ 3, [new GlueSetAccessor(identifierText(name_6), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_6), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"]((setAccessorDeclaration.parameters[0]).type), ModifierUtil_HasModifier_742AC9D(setAccessorDeclaration.modifiers, 126), hasPrivateModifier_2 ? true : isPrivateIdentifier_2)]);
50
+ return new GlueMember(/* SetAccessor */ 3, [new GlueSetAccessor(identifierText(name_6), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](name_6), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"]((setAccessorDeclaration.parameters[0]).type), ModifierUtil_HasModifier_742AC9D(setAccessorDeclaration.modifiers, 126), isPrivateMember(setAccessorDeclaration.modifiers, name_6))]);
57
51
  }
58
52
  case 180: {
59
53
  const callSignature = declaration;
@@ -144,7 +138,7 @@ export function readDeclaration(reader, declaration) {
144
138
  }
145
139
  }
146
140
  default:
147
- throw new Exception(Report_readerError_Z19516DCE("declaration", concat("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(declaration.kind)), declaration, "/_//src/Glutinum.Converter/Reader/Declaration.fs", 270));
141
+ throw new Exception(Report_readerError_Z19516DCE("declaration", concat("Unsupported kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(declaration.kind)), declaration, "/_//src/Glutinum.Converter/Reader/Declaration.fs", 255));
148
142
  }
149
143
  }
150
144
 
@@ -2,7 +2,7 @@
2
2
  import { ts } from "@ts-morph/bootstrap";
3
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 value_5, defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
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";
@@ -115,47 +115,35 @@ function readDocumentation(reader, summary, jsDocTags) {
115
115
  const matchValue_5 = tag_3.kind;
116
116
  switch (matchValue_5) {
117
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
+ };
118
127
  const matchValue_8 = tag_3.tagName.getText();
119
128
  switch (matchValue_8) {
120
- 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": {
121
136
  const matchValue_9 = tag_3.comment;
122
137
  if (matchValue_9 == null) {
123
138
  return undefined;
124
139
  }
125
140
  else {
126
- return new GlueComment(/* Remarks */ 4, [defaultArg(textOfComment(matchValue_9), "")]);
127
- }
128
- }
129
- case "defaultValue": {
130
- const matchValue_10 = tag_3.comment;
131
- if (matchValue_10 == null) {
132
- return undefined;
133
- }
134
- else {
135
- return new GlueComment(/* DefaultValue */ 5, [defaultArg(textOfComment(matchValue_10), "")]);
136
- }
137
- }
138
- case "example": {
139
- const matchValue_11 = tag_3.comment;
140
- if (matchValue_11 == null) {
141
- return undefined;
142
- }
143
- else {
144
- return new GlueComment(/* Example */ 6, [defaultArg(textOfComment(matchValue_11), "")]);
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 matchValue_13 = textOfComment(matchValue_12);
154
- if (matchValue_13 == null) {
141
+ const matchValue_10 = textOfComment(matchValue_9);
142
+ if (matchValue_10 == null) {
155
143
  return undefined;
156
144
  }
157
145
  else {
158
- const text_3 = matchValue_13;
146
+ const text_3 = matchValue_10;
159
147
  const m_1 = match(/\s*(?<type>[^-\s]*)\s*-\s*(?<description>.*)/gus, text_3);
160
148
  if (m_1 != null) {
161
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)]);
@@ -213,8 +201,8 @@ function readDocumentation(reader, summary, jsDocTags) {
213
201
  }
214
202
  }, indexed(jsDocTags)));
215
203
  return toList(delay(() => {
216
- let matchValue_14;
217
- return append_1((matchValue_14 = summary_1, (matchValue_14 == null) ? (empty()) : singleton(matchValue_14)), delay(() => jsDocTags_1));
204
+ let matchValue_11;
205
+ return append_1((matchValue_11 = summary_1, (matchValue_11 == null) ? (empty()) : singleton(matchValue_11)), delay(() => jsDocTags_1));
218
206
  }));
219
207
  }
220
208
 
@@ -246,7 +234,7 @@ export function readDocumentationForNode(reader, node) {
246
234
  return empty_1();
247
235
  }
248
236
  else {
249
- const symbol_1 = value_5(matchValue_1);
237
+ const symbol_1 = value_3(matchValue_1);
250
238
  return readDocumentation(reader, symbol_1.getDocumentationComment(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]()), ts.getJSDocTags(node));
251
239
  }
252
240
  }
@@ -1,14 +1,20 @@
1
1
 
2
- import { equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
3
- import { GlueVariable, GluePrimitive, GlueType } from "../GlueAST.js";
4
- import { $007CHasTypeFlags$007C_$007C } from "./Utils.js";
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 exportEqualsDeclarationKind;
11
- if (equals(exportNode.isExportEquals, true) && (exportNode.expression.kind === 80)) {
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
- exportEqualsDeclarationKind = ((option_3 != null) ? ((declaration = option_3, declaration.kind)) : undefined);
27
+ targetDeclarationKind = ((option_3 != null) ? ((declaration = option_3, declaration.kind)) : undefined);
22
28
  }
23
29
  else {
24
- exportEqualsDeclarationKind = undefined;
30
+ targetDeclarationKind = undefined;
25
31
  }
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);
26
73
  const isExportEqualsOfVariable = equals(exportEqualsDeclarationKind, 261);
27
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 symbol_1 = symbolOpt;
33
- if (((symbol_1.name === "default") ? true : isExportEqualsOfVariable) ? true : isExportEqualsOfDeclaration) {
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
- if (isExportEqualsOfVariable) {
38
- let option_7;
39
- const option_5 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(exportNode.expression);
40
- if (option_5 != null) {
41
- const _arg = option_5;
42
- option_7 = _arg.valueDeclaration;
43
- }
44
- else {
45
- option_7 = undefined;
46
- }
47
- if (option_7 != null) {
48
- const declaration_1 = option_7;
49
- declaredTypeNode = declaration_1.type;
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 matchValue_1 = tsTyp.flags;
62
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_1) != null) {
63
- const matchValue_2 = tsTyp.symbol.declarations;
64
- if (matchValue_2 == null) {
65
- typ = (new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
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
- const declarations = matchValue_2;
69
- typ = ((declarations.length === 1) ? reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](item(0, declarations)) : (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])));
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 = (($007CHasTypeFlags$007C_$007C(32, matchValue_1) != null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.String$])) : (($007CHasTypeFlags$007C_$007C(64, matchValue_1) != null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.Number$])) : (($007CHasTypeFlags$007C_$007C(256, matchValue_1) != null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.Bool])) : (($007CHasTypeFlags$007C_$007C(1, matchValue_1) != null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])) : (($007CHasTypeFlags$007C_$007C(16, matchValue_1) != null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.Unit])) : (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])))))));
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
- return new GlueType(/* ExportDefault */ 25, [new GlueType(/* Variable */ 2, [new GlueVariable(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](exportNode), isExportEqualsOfVariable ? ("export=" + identiferNode.getText()) : identiferNode.getText(), typ)])]);
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, $007CHasSymbolFlags$007C_$007C } from "./Utils.js";
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
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 = tryResolveAlias(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"](), symbol);
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,28 +34,35 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
53
34
  return empty();
54
35
  }
55
36
  else {
56
- return List_distinctBy((glueType) => {
37
+ return reverse(fold((tupledArg, glueType) => {
38
+ const kept = tupledArg[0];
39
+ const hasInterface = tupledArg[1];
57
40
  let matchResult_1;
58
41
  if (glueType.tag === 32) {
59
42
  if (glueType.fields[0].Declaration.tag === 1) {
60
- matchResult_1 = 0;
43
+ if (hasInterface) {
44
+ matchResult_1 = 0;
45
+ }
46
+ else {
47
+ matchResult_1 = 1;
48
+ }
61
49
  }
62
50
  else {
63
- matchResult_1 = 1;
51
+ matchResult_1 = 2;
64
52
  }
65
53
  }
66
54
  else {
67
- matchResult_1 = 1;
55
+ matchResult_1 = 2;
68
56
  }
69
57
  switch (matchResult_1) {
70
58
  case 0:
71
- return "interface";
72
- default: {
73
- let copyOfStruct = newGuid();
74
- return copyOfStruct;
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;
@@ -100,10 +88,7 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
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:
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
3
- import { tryReadKeyOfConstraint, ModifierUtil_HasModifier_742AC9D } from "./Utils.js";
3
+ import { tryReadKeyOfConstraint, isDefaultInExportList, ModifierUtil_HasModifier_742AC9D } from "./Utils.js";
4
4
  import { Exception } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
5
5
  import { Report_readerError_Z19516DCE } from "./Report.js";
6
6
  import { mapIndexed } from "../../fable_modules/fable-library-js.5.17.2/List.js";
@@ -11,28 +11,41 @@ export function readFunctionDeclaration(reader, declaration) {
11
11
  let isDeclared;
12
12
  const matchValue = declaration.modifiers;
13
13
  isDeclared = ((matchValue == null) ? false : exists((modifier) => (modifier.kind === 138), matchValue));
14
- const isDefaultExport = ModifierUtil_HasModifier_742AC9D(declaration.modifiers, 90);
15
- let name_1;
16
- const matchValue_1 = declaration.name;
17
- if (matchValue_1 == null) {
14
+ let isDefaultExport;
15
+ if (ModifierUtil_HasModifier_742AC9D(declaration.modifiers, 90)) {
16
+ isDefaultExport = true;
17
+ }
18
+ else {
19
+ const matchValue_1 = declaration.name;
20
+ if (matchValue_1 == null) {
21
+ isDefaultExport = false;
22
+ }
23
+ else {
24
+ const name = matchValue_1;
25
+ isDefaultExport = isDefaultInExportList(declaration, name.getText());
26
+ }
27
+ }
28
+ let name_2;
29
+ const matchValue_2 = declaration.name;
30
+ if (matchValue_2 == null) {
18
31
  if (isDefaultExport) {
19
- name_1 = "defaultExport";
32
+ name_2 = "defaultExport";
20
33
  }
21
34
  else {
22
- throw new Exception(Report_readerError_Z19516DCE("function declaration", "Missing name", declaration, "/_//src/Glutinum.Converter/Reader/FunctionDeclaration.fs", 29));
35
+ throw new Exception(Report_readerError_Z19516DCE("function declaration", "Missing name", declaration, "/_//src/Glutinum.Converter/Reader/FunctionDeclaration.fs", 34));
23
36
  }
24
37
  }
25
38
  else {
26
- const name = matchValue_1;
27
- name_1 = name.getText();
39
+ const name_1 = matchValue_2;
40
+ name_2 = name_1.getText();
28
41
  }
29
- const functionDeclaration = new GlueFunctionDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromSignature61B89E55"](declaration), isDeclared, name_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](declaration.type), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](declaration.parameters), mapIndexed((index, typeParameter) => {
30
- const matchValue_2 = tryReadKeyOfConstraint(reader, value(declaration.typeParameters)[index]);
31
- if (matchValue_2 == null) {
42
+ const functionDeclaration = new GlueFunctionDeclaration(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromSignature61B89E55"](declaration), isDeclared, name_2, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNodeZ64B23DD2"](declaration.type), reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadParameters716C1F42"](declaration.parameters), mapIndexed((index, typeParameter) => {
43
+ const matchValue_3 = tryReadKeyOfConstraint(reader, value(declaration.typeParameters)[index]);
44
+ if (matchValue_3 == null) {
32
45
  return typeParameter;
33
46
  }
34
47
  else {
35
- return new GlueTypeParameter(typeParameter.Name, matchValue_2, typeParameter.Default);
48
+ return new GlueTypeParameter(typeParameter.Name, matchValue_3, typeParameter.Default);
36
49
  }
37
50
  }, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](declaration.typeParameters)));
38
51
  if (isDefaultExport) {
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { GluePrimitive, GlueType, GlueIndexedAccessType } from "../GlueAST.js";
3
- import { $007CHasTypeFlags$007C_$007C } from "./Utils.js";
3
+ import { typeNodeBuilderFlags, $007CHasTypeFlags$007C_$007C, enclosingDeclarationOf } from "./Utils.js";
4
4
  import { Report_readerError_Z19516DCE } from "./Report.js";
5
5
  import { concat } from "../../fable_modules/fable-library-js.5.17.2/String.js";
6
6
  import { TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name } from "../TypeScript.Extensions.js";
@@ -12,7 +12,7 @@ export function readIndexedAccessType(reader, declaration) {
12
12
  const node = declaration;
13
13
  const tryTypeToTypeNode = (typ, flags) => {
14
14
  try {
15
- return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, node, flags);
15
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, enclosingDeclarationOf(node), flags);
16
16
  }
17
17
  catch (matchValue) {
18
18
  return undefined;
@@ -21,17 +21,14 @@ export function readIndexedAccessType(reader, declaration) {
21
21
  const matchValue_3 = idxNodeType.kind;
22
22
  let matchResult;
23
23
  switch (matchValue_3) {
24
- case 150: {
25
- matchResult = 1;
26
- break;
27
- }
24
+ case 150:
28
25
  case 154:
29
26
  case 184: {
30
- matchResult = 4;
27
+ matchResult = 3;
31
28
  break;
32
29
  }
33
30
  case 194: {
34
- matchResult = 5;
31
+ matchResult = 4;
35
32
  break;
36
33
  }
37
34
  case 199: {
@@ -40,15 +37,15 @@ export function readIndexedAccessType(reader, declaration) {
40
37
  }
41
38
  case 202: {
42
39
  if (node.pos >= 0) {
43
- matchResult = 2;
40
+ matchResult = 1;
44
41
  }
45
42
  else {
46
- matchResult = 3;
43
+ matchResult = 2;
47
44
  }
48
45
  break;
49
46
  }
50
47
  default:
51
- matchResult = 6;
48
+ matchResult = 5;
52
49
  }
53
50
  switch (matchResult) {
54
51
  case 0: {
@@ -61,7 +58,7 @@ export function readIndexedAccessType(reader, declaration) {
61
58
  const typ_1 = checker.getTypeAtLocation(node);
62
59
  const matchValue_1 = typ_1.flags;
63
60
  if ($007CHasTypeFlags$007C_$007C(134217728, matchValue_1) != null) {
64
- const matchValue_2 = tryTypeToTypeNode(typ_1, 1 | 16384);
61
+ const matchValue_2 = tryTypeToTypeNode(typ_1, typeNodeBuilderFlags);
65
62
  let matchResult_1, typeNode_1;
66
63
  if (matchValue_2 != null) {
67
64
  if ((typeNode = matchValue_2, typeNode.kind === 193)) {
@@ -96,20 +93,17 @@ export function readIndexedAccessType(reader, declaration) {
96
93
  return matchValue_4;
97
94
  }
98
95
  }
99
- case 1:
100
- return withIndexType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](idxNodeType));
101
- case 2: {
96
+ case 1: {
102
97
  const checker_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
103
98
  const objectType = checker_1.getTypeAtLocation(declaration.objectType);
104
99
  const key = idxNodeType.literal.text;
105
- const flags_2 = 1 | 16384;
106
100
  const matchValue_5 = checker_1.getPropertyOfType(objectType, key);
107
101
  if (matchValue_5 == null) {
108
102
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
109
103
  }
110
104
  else {
111
105
  const property = matchValue_5;
112
- const matchValue_6 = tryTypeToTypeNode(checker_1.getTypeOfSymbol(property), flags_2);
106
+ const matchValue_6 = tryTypeToTypeNode(checker_1.getTypeOfSymbol(property), typeNodeBuilderFlags);
113
107
  if (matchValue_6 == null) {
114
108
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
115
109
  }
@@ -119,14 +113,14 @@ export function readIndexedAccessType(reader, declaration) {
119
113
  }
120
114
  }
121
115
  }
122
- case 3:
116
+ case 2:
123
117
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
124
- case 4:
118
+ case 3:
125
119
  return withIndexType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](idxNodeType));
126
- case 5:
120
+ case 4:
127
121
  return withIndexType(GlueType.Discard);
128
122
  default: {
129
- const warning = Report_readerError_Z19516DCE("readIndexedAccessType", concat("Unsupported node kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_3)), idxNodeType, "/_//src/Glutinum.Converter/Reader/IndexedAccessType.fs", 93);
123
+ const warning = Report_readerError_Z19516DCE("readIndexedAccessType", concat("Unsupported node kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_3)), idxNodeType, "/_//src/Glutinum.Converter/Reader/IndexedAccessType.fs", 87);
130
124
  void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning));
131
125
  return withIndexType(GlueType.Discard);
132
126
  }