@glutinum/cli 0.14.1 → 1.0.0-beta.1

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 (39) hide show
  1. package/dist/Glutinum.Converter/FsharpAST.js +38 -4
  2. package/dist/Glutinum.Converter/Generate.js +15 -7
  3. package/dist/Glutinum.Converter/GlueAST.js +45 -36
  4. package/dist/Glutinum.Converter/Hosting.js +918 -0
  5. package/dist/Glutinum.Converter/Merge.js +218 -82
  6. package/dist/Glutinum.Converter/Packages.js +44 -8
  7. package/dist/Glutinum.Converter/Printer.js +77 -49
  8. package/dist/Glutinum.Converter/Read.js +8 -8
  9. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
  10. package/dist/Glutinum.Converter/Reader/Declaration.js +26 -26
  11. package/dist/Glutinum.Converter/Reader/Documentation.js +37 -36
  12. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +5 -5
  13. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +31 -19
  14. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +6 -7
  15. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +36 -29
  16. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -3
  17. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
  18. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +3 -3
  19. package/dist/Glutinum.Converter/Reader/Node.js +20 -20
  20. package/dist/Glutinum.Converter/Reader/Parameters.js +7 -7
  21. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
  22. package/dist/Glutinum.Converter/Reader/TypeNode.js +291 -232
  23. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +8 -8
  24. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +108 -40
  25. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +2 -2
  26. package/dist/Glutinum.Converter/Reader/Types.js +6 -6
  27. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +7 -6
  28. package/dist/Glutinum.Converter/Reader/Utils.js +106 -56
  29. package/dist/Glutinum.Converter/Transform.js +2057 -700
  30. package/dist/Glutinum.Converter/TypeScript.Extensions.js +194 -202
  31. package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
  32. package/dist/Glutinum.Converter/Utils/String.js +2 -2
  33. package/dist/Program.js +38 -26
  34. package/package.json +2 -2
  35. package/dist/Glutinum.Converter/TypeScript.js +0 -12
  36. package/src/Glutinum.Converter/js/bootstrap.js +0 -123
  37. package/src/Glutinum.Converter/js/host.js +0 -144
  38. package/src/Glutinum.Converter/js/npm.js +0 -137
  39. 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
5
  import { value as value_5, 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 === 334) && (tag.tagName.getText() === "link")) {
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
- if (option_2 != null) {
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
- const comment = matchValue;
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 === 334) {
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 = ts.getTextOfJSDocComment(comment_3);
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,7 +114,7 @@ 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 334: {
117
+ case 328: {
115
118
  const matchValue_8 = tag_3.tagName.getText();
116
119
  switch (matchValue_8) {
117
120
  case "remarks": {
@@ -120,8 +123,7 @@ function readDocumentation(reader, summary, jsDocTags) {
120
123
  return undefined;
121
124
  }
122
125
  else {
123
- const comment_6 = matchValue_9;
124
- return new GlueComment(/* Remarks */ 4, [defaultArg(ts.getTextOfJSDocComment(comment_6), "")]);
126
+ return new GlueComment(/* Remarks */ 4, [defaultArg(textOfComment(matchValue_9), "")]);
125
127
  }
126
128
  }
127
129
  case "defaultValue": {
@@ -130,8 +132,7 @@ function readDocumentation(reader, summary, jsDocTags) {
130
132
  return undefined;
131
133
  }
132
134
  else {
133
- const comment_7 = matchValue_10;
134
- return new GlueComment(/* DefaultValue */ 5, [defaultArg(ts.getTextOfJSDocComment(comment_7), "")]);
135
+ return new GlueComment(/* DefaultValue */ 5, [defaultArg(textOfComment(matchValue_10), "")]);
135
136
  }
136
137
  }
137
138
  case "example": {
@@ -140,8 +141,7 @@ function readDocumentation(reader, summary, jsDocTags) {
140
141
  return undefined;
141
142
  }
142
143
  else {
143
- const comment_8 = matchValue_11;
144
- return new GlueComment(/* Example */ 6, [defaultArg(ts.getTextOfJSDocComment(comment_8), "")]);
144
+ return new GlueComment(/* Example */ 6, [defaultArg(textOfComment(matchValue_11), "")]);
145
145
  }
146
146
  }
147
147
  case "typeParam": {
@@ -150,8 +150,7 @@ function readDocumentation(reader, summary, jsDocTags) {
150
150
  return undefined;
151
151
  }
152
152
  else {
153
- const comment_9 = matchValue_12;
154
- const matchValue_13 = ts.getTextOfJSDocComment(comment_9);
153
+ const matchValue_13 = textOfComment(matchValue_12);
155
154
  if (matchValue_13 == null) {
156
155
  return undefined;
157
156
  }
@@ -174,31 +173,24 @@ function readDocumentation(reader, summary, jsDocTags) {
174
173
  return undefined;
175
174
  }
176
175
  }
177
- case 338: {
176
+ case 332: {
178
177
  const matchValue_7 = tag_3.comment;
179
178
  if (matchValue_7 == null) {
180
179
  return new GlueComment(/* Deprecated */ 3, [undefined]);
181
180
  }
182
181
  else {
183
- const comment_5 = matchValue_7;
184
- return new GlueComment(/* Deprecated */ 3, [ts.getTextOfJSDocComment(comment_5)]);
182
+ return new GlueComment(/* Deprecated */ 3, [textOfComment(matchValue_7)]);
185
183
  }
186
184
  }
187
- case 348: {
185
+ case 342: {
188
186
  const parameterTag = tag_3;
189
187
  const identifier = parameterTag.name;
190
188
  let content_1;
191
189
  const matchValue_6 = parameterTag.comment;
192
- if (matchValue_6 == null) {
193
- content_1 = undefined;
194
- }
195
- else {
196
- const comment_4 = matchValue_6;
197
- content_1 = ts.getTextOfJSDocComment(comment_4);
198
- }
190
+ content_1 = ((matchValue_6 == null) ? undefined : textOfComment(matchValue_6));
199
191
  return new GlueComment(/* Param */ 2, [new GlueCommentParam(identifier.getText(), content_1)]);
200
192
  }
201
- case 349: {
193
+ case 343: {
202
194
  const option_8 = readTagComment(index_1, tag_3);
203
195
  if (option_8 != null) {
204
196
  return new GlueComment(/* Returns */ 1, [option_8]);
@@ -207,7 +199,7 @@ function readDocumentation(reader, summary, jsDocTags) {
207
199
  return undefined;
208
200
  }
209
201
  }
210
- case 356: {
202
+ case 350: {
211
203
  const option_10 = readTagComment(index_1, tag_3);
212
204
  if (option_10 != null) {
213
205
  return new GlueComment(/* Throws */ 8, [option_10]);
@@ -237,6 +229,15 @@ export function readDocumentationForSignature(reader, declaration) {
237
229
  }
238
230
  }
239
231
 
232
+ function jsDocTagsOfParent(node) {
233
+ if (Operators_IsNull(node.parent)) {
234
+ return [];
235
+ }
236
+ else {
237
+ return ts.getJSDocTags(node.parent);
238
+ }
239
+ }
240
+
240
241
  export function readDocumentationForNode(reader, node) {
241
242
  const matchValue = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getSymbolAtLocation(node);
242
243
  if (matchValue == null) {
@@ -251,7 +252,7 @@ export function readDocumentationForNode(reader, node) {
251
252
  }
252
253
  else {
253
254
  const symbol = matchValue;
254
- return readDocumentation(reader, symbol.getDocumentationComment(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]()), ts.getJSDocTags(node.parent));
255
+ return readDocumentation(reader, symbol.getDocumentationComment(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]()), jsDocTagsOfParent(node));
255
256
  }
256
257
  }
257
258
 
@@ -23,8 +23,8 @@ export function readExportAssignment(reader, exportNode) {
23
23
  else {
24
24
  exportEqualsDeclarationKind = undefined;
25
25
  }
26
- const isExportEqualsOfVariable = equals(exportEqualsDeclarationKind, 260);
27
- const isExportEqualsOfDeclaration = equals(exportEqualsDeclarationKind, 262) ? true : equals(exportEqualsDeclarationKind, 263);
26
+ const isExportEqualsOfVariable = equals(exportEqualsDeclarationKind, 261);
27
+ const isExportEqualsOfDeclaration = equals(exportEqualsDeclarationKind, 263) ? true : equals(exportEqualsDeclarationKind, 264);
28
28
  if (symbolOpt == null) {
29
29
  return GlueType.Discard;
30
30
  }
@@ -59,7 +59,7 @@ export function readExportAssignment(reader, exportNode) {
59
59
  const tsTyp = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().getTypeAtLocation(exportNode.expression);
60
60
  if (declaredTypeNode == null) {
61
61
  const matchValue_1 = tsTyp.flags;
62
- if ($007CHasTypeFlags$007C_$007C(524288, matchValue_1) != null) {
62
+ if ($007CHasTypeFlags$007C_$007C(1048576, matchValue_1) != null) {
63
63
  const matchValue_2 = tsTyp.symbol.declarations;
64
64
  if (matchValue_2 == null) {
65
65
  typ = (new GlueType(/* Primitive */ 3, [GluePrimitive.Any]));
@@ -70,14 +70,14 @@ export function readExportAssignment(reader, exportNode) {
70
70
  }
71
71
  }
72
72
  else {
73
- typ = (($007CHasTypeFlags$007C_$007C(4, matchValue_1) != null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.String$])) : (($007CHasTypeFlags$007C_$007C(8, matchValue_1) != null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.Number$])) : (($007CHasTypeFlags$007C_$007C(16, 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(16384, matchValue_1) != null) ? (new GlueType(/* Primitive */ 3, [GluePrimitive.Unit])) : (new GlueType(/* Primitive */ 3, [GluePrimitive.Any])))))));
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])))))));
74
74
  }
75
75
  }
76
76
  else {
77
77
  const typeNode = declaredTypeNode;
78
78
  typ = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode);
79
79
  }
80
- return new GlueType(/* ExportDefault */ 24, [new GlueType(/* Variable */ 2, [new GlueVariable(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDocumentationFromNode6C0FD055"](exportNode), isExportEqualsOfVariable ? ("export=" + identiferNode.getText()) : identiferNode.getText(), typ)])]);
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)])]);
81
81
  }
82
82
  else {
83
83
  return GlueType.Discard;
@@ -2,7 +2,7 @@
2
2
  import { modulePathForDeclaration, $007CHasSymbolFlags$007C_$007C } from "./Utils.js";
3
3
  import { Operators_IsNull } from "../../fable_modules/fable-library-js.5.17.2/FSharp.Core.js";
4
4
  import { normalizePath } from "../Utils/String.js";
5
- import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
5
+ import { contains, item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
6
6
  import { PackageContext__IsExternal_Z721C83C5 } from "./Types.js";
7
7
  import { filter, collect, choose, empty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
8
8
  import { List_distinctBy } from "../../fable_modules/fable-library-js.5.17.2/Seq2.js";
@@ -55,7 +55,7 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
55
55
  else {
56
56
  return List_distinctBy((glueType) => {
57
57
  let matchResult_1;
58
- if (glueType.tag === 31) {
58
+ if (glueType.tag === 32) {
59
59
  if (glueType.fields[0].Declaration.tag === 1) {
60
60
  matchResult_1 = 0;
61
61
  }
@@ -79,15 +79,15 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
79
79
  let option_1;
80
80
  const matchValue_2 = declaration.kind;
81
81
  switch (matchValue_2) {
82
- case 260: {
82
+ case 261: {
83
83
  option_1 = declaration.parent.parent;
84
84
  break;
85
85
  }
86
- case 262:
87
86
  case 263:
88
87
  case 264:
89
88
  case 265:
90
- case 266: {
89
+ case 266:
90
+ case 267: {
91
91
  option_1 = declaration;
92
92
  break;
93
93
  }
@@ -95,7 +95,7 @@ function readReExport(reader, packageContext, currentFile, exportedName, symbol)
95
95
  option_1 = undefined;
96
96
  }
97
97
  if (option_1 != null) {
98
- return (declaration_1 = option_1, new GlueType(/* ReExport */ 31, [new GlueReExport(exportedName, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadNode6C0FD055"](declaration_1), modulePathForDeclaration(packageContext, declaration_1))]));
98
+ 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
99
  }
100
100
  else {
101
101
  return undefined;
@@ -121,15 +121,15 @@ export function readExportDeclaration(reader, exportDeclaration) {
121
121
  const packageContext = matchValue;
122
122
  const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
123
123
  const currentFile = normalizePath(exportDeclaration.getSourceFile().fileName);
124
- const matchValue_1 = exportDeclaration.exportClause;
125
- if (matchValue_1 != null) {
126
- const exportClause = matchValue_1;
127
- if (exportClause.kind === 279) {
124
+ const matchValue_2 = exportDeclaration.exportClause;
125
+ if (matchValue_2 != null) {
126
+ const exportClause = matchValue_2;
127
+ if (exportClause.kind === 280) {
128
128
  return collect((specifier) => {
129
129
  const exportedName = specifier.name.text;
130
- const matchValue_5 = checker.getExportSpecifierLocalTargetSymbol(specifier);
131
- if (matchValue_5 != null) {
132
- return readReExport(reader, packageContext, currentFile, exportedName, matchValue_5);
130
+ const matchValue_6 = checker.getExportSpecifierLocalTargetSymbol(specifier);
131
+ if (matchValue_6 != null) {
132
+ return readReExport(reader, packageContext, currentFile, exportedName, matchValue_6);
133
133
  }
134
134
  else {
135
135
  return empty();
@@ -141,12 +141,12 @@ export function readExportDeclaration(reader, exportDeclaration) {
141
141
  }
142
142
  }
143
143
  else {
144
- const matchValue_2 = exportDeclaration.moduleSpecifier;
145
- if (matchValue_2 != null) {
146
- const moduleSpecifier = matchValue_2;
147
- const matchValue_3 = checker.getSymbolAtLocation(moduleSpecifier);
148
- if (matchValue_3 != null) {
149
- const moduleSymbol = matchValue_3;
144
+ const matchValue_3 = exportDeclaration.moduleSpecifier;
145
+ if (matchValue_3 != null) {
146
+ const moduleSpecifier = matchValue_3;
147
+ const matchValue_4 = checker.getSymbolAtLocation(moduleSpecifier);
148
+ if (matchValue_4 != null) {
149
+ const moduleSymbol = matchValue_4;
150
150
  return collect((symbol_1) => readReExport(reader, packageContext, currentFile, symbol_1.name, symbol_1), filter((symbol) => (symbol.name !== "default"), toList(checker.getExportsOfModule(moduleSymbol))));
151
151
  }
152
152
  else {
@@ -159,6 +159,18 @@ export function readExportDeclaration(reader, exportDeclaration) {
159
159
  }
160
160
  }
161
161
  else {
162
+ const matchValue_1 = exportDeclaration.moduleSpecifier;
163
+ if (matchValue_1 == null) {
164
+ }
165
+ else {
166
+ const warning = "A re-export from another file is only resolved when generating a package, run `glue <package>` instead of a single declaration file";
167
+ if (!contains(warning, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"](), {
168
+ Equals: (x, y) => (x === y),
169
+ GetHashCode: (x) => (stringHash(x) | 0),
170
+ })) {
171
+ void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning));
172
+ }
173
+ }
162
174
  return empty();
163
175
  }
164
176
  }
@@ -1,10 +1,9 @@
1
1
 
2
2
  import { exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
3
- import { tryReadKeyOfConstraint, ModifierUtil_HasModifier_Z687DC302 } from "./Utils.js";
3
+ import { tryReadKeyOfConstraint, 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";
7
- import { item } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
8
7
  import { value } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
9
8
  import { GlueType, GlueFunctionDeclaration, GlueTypeParameter } from "../GlueAST.js";
10
9
 
@@ -12,7 +11,7 @@ export function readFunctionDeclaration(reader, declaration) {
12
11
  let isDeclared;
13
12
  const matchValue = declaration.modifiers;
14
13
  isDeclared = ((matchValue == null) ? false : exists((modifier) => (modifier.kind === 138), matchValue));
15
- const isDefaultExport = ModifierUtil_HasModifier_Z687DC302(declaration.modifiers, 90);
14
+ const isDefaultExport = ModifierUtil_HasModifier_742AC9D(declaration.modifiers, 90);
16
15
  let name_1;
17
16
  const matchValue_1 = declaration.name;
18
17
  if (matchValue_1 == null) {
@@ -27,17 +26,17 @@ export function readFunctionDeclaration(reader, declaration) {
27
26
  const name = matchValue_1;
28
27
  name_1 = name.getText();
29
28
  }
30
- 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.ReadParametersZ17143B5B"](declaration.parameters), mapIndexed((index, typeParameter) => {
31
- const matchValue_2 = tryReadKeyOfConstraint(reader, item(index, value(declaration.typeParameters)));
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]);
32
31
  if (matchValue_2 == null) {
33
32
  return typeParameter;
34
33
  }
35
34
  else {
36
35
  return new GlueTypeParameter(typeParameter.Name, matchValue_2, typeParameter.Default);
37
36
  }
38
- }, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4088FB9E"](declaration.typeParameters)));
37
+ }, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](declaration.typeParameters)));
39
38
  if (isDefaultExport) {
40
- return new GlueType(/* ExportDefault */ 24, [new GlueType(/* FunctionDeclaration */ 6, [functionDeclaration])]);
39
+ return new GlueType(/* ExportDefault */ 25, [new GlueType(/* FunctionDeclaration */ 6, [functionDeclaration])]);
41
40
  }
42
41
  else {
43
42
  return new GlueType(/* FunctionDeclaration */ 6, [functionDeclaration]);
@@ -10,27 +10,35 @@ export function readIndexedAccessType(reader, declaration) {
10
10
  const idxNodeType = declaration.indexType;
11
11
  const withIndexType = (indexType) => (new GlueType(/* IndexedAccessType */ 10, [new GlueIndexedAccessType(indexType, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](declaration.objectType))]));
12
12
  const node = declaration;
13
- const matchValue_2 = idxNodeType.kind;
13
+ const tryTypeToTypeNode = (typ, flags) => {
14
+ try {
15
+ return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]().typeToTypeNode(typ, node, flags);
16
+ }
17
+ catch (matchValue) {
18
+ return undefined;
19
+ }
20
+ };
21
+ const matchValue_3 = idxNodeType.kind;
14
22
  let matchResult;
15
- switch (matchValue_2) {
23
+ switch (matchValue_3) {
16
24
  case 150: {
17
25
  matchResult = 1;
18
26
  break;
19
27
  }
20
28
  case 154:
21
- case 183: {
29
+ case 184: {
22
30
  matchResult = 4;
23
31
  break;
24
32
  }
25
- case 193: {
33
+ case 194: {
26
34
  matchResult = 5;
27
35
  break;
28
36
  }
29
- case 198: {
37
+ case 199: {
30
38
  matchResult = 0;
31
39
  break;
32
40
  }
33
- case 201: {
41
+ case 202: {
34
42
  if (node.pos >= 0) {
35
43
  matchResult = 2;
36
44
  }
@@ -44,22 +52,21 @@ export function readIndexedAccessType(reader, declaration) {
44
52
  }
45
53
  switch (matchResult) {
46
54
  case 0: {
47
- let matchValue_3;
55
+ let matchValue_4;
48
56
  if (node.pos < 0) {
49
- matchValue_3 = undefined;
57
+ matchValue_4 = undefined;
50
58
  }
51
59
  else {
52
60
  const checker = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
53
- const typ = checker.getTypeAtLocation(node);
54
- const matchValue = typ.flags;
55
- if ($007CHasTypeFlags$007C_$007C(1048576, matchValue) != null) {
56
- const flags = 1 | 16384;
57
- const matchValue_1 = checker.typeToTypeNode(typ, node, flags);
61
+ const typ_1 = checker.getTypeAtLocation(node);
62
+ const matchValue_1 = typ_1.flags;
63
+ if ($007CHasTypeFlags$007C_$007C(134217728, matchValue_1) != null) {
64
+ const matchValue_2 = tryTypeToTypeNode(typ_1, 1 | 16384);
58
65
  let matchResult_1, typeNode_1;
59
- if (matchValue_1 != null) {
60
- if ((typeNode = matchValue_1, typeNode.kind === 192)) {
66
+ if (matchValue_2 != null) {
67
+ if ((typeNode = matchValue_2, typeNode.kind === 193)) {
61
68
  matchResult_1 = 0;
62
- typeNode_1 = matchValue_1;
69
+ typeNode_1 = matchValue_2;
63
70
  }
64
71
  else {
65
72
  matchResult_1 = 1;
@@ -70,23 +77,23 @@ export function readIndexedAccessType(reader, declaration) {
70
77
  }
71
78
  switch (matchResult_1) {
72
79
  case 0: {
73
- matchValue_3 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode_1);
80
+ matchValue_4 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode_1);
74
81
  break;
75
82
  }
76
83
  default:
77
- matchValue_3 = undefined;
84
+ matchValue_4 = undefined;
78
85
  }
79
86
  }
80
87
  else {
81
- matchValue_3 = undefined;
88
+ matchValue_4 = undefined;
82
89
  }
83
90
  }
84
- if (matchValue_3 == null) {
91
+ if (matchValue_4 == null) {
85
92
  const typeOperatorNode = declaration.indexType;
86
93
  return withIndexType(reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeOperatorNodeZ6830FC33"](typeOperatorNode));
87
94
  }
88
95
  else {
89
- return matchValue_3;
96
+ return matchValue_4;
90
97
  }
91
98
  }
92
99
  case 1:
@@ -95,19 +102,19 @@ export function readIndexedAccessType(reader, declaration) {
95
102
  const checker_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_checker"]();
96
103
  const objectType = checker_1.getTypeAtLocation(declaration.objectType);
97
104
  const key = idxNodeType.literal.text;
98
- const flags_1 = 1 | 16384;
99
- const matchValue_4 = checker_1.getPropertyOfType(objectType, key);
100
- if (matchValue_4 == null) {
105
+ const flags_2 = 1 | 16384;
106
+ const matchValue_5 = checker_1.getPropertyOfType(objectType, key);
107
+ if (matchValue_5 == null) {
101
108
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
102
109
  }
103
110
  else {
104
- const property = matchValue_4;
105
- const matchValue_5 = checker_1.typeToTypeNode(checker_1.getTypeOfSymbol(property), node, flags_1);
106
- if (matchValue_5 == null) {
111
+ const property = matchValue_5;
112
+ const matchValue_6 = tryTypeToTypeNode(checker_1.getTypeOfSymbol(property), flags_2);
113
+ if (matchValue_6 == null) {
107
114
  return new GlueType(/* Primitive */ 3, [GluePrimitive.Any]);
108
115
  }
109
116
  else {
110
- const typeNode_2 = matchValue_5;
117
+ const typeNode_2 = matchValue_6;
111
118
  return reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typeNode_2);
112
119
  }
113
120
  }
@@ -119,7 +126,7 @@ export function readIndexedAccessType(reader, declaration) {
119
126
  case 5:
120
127
  return withIndexType(GlueType.Discard);
121
128
  default: {
122
- const warning = Report_readerError_Z19516DCE("readIndexedAccessType", concat("Unsupported node kind ", TypeScript_Ts_SyntaxKind__SyntaxKind_get_Name(matchValue_2)), idxNodeType, "/_//src/Glutinum.Converter/Reader/IndexedAccessType.fs", 88);
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
130
  void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(warning));
124
131
  return withIndexType(GlueType.Discard);
125
132
  }
@@ -41,7 +41,7 @@ export function readInterfaceDeclaration(reader, declaration) {
41
41
  }
42
42
  const members = collect((declaration_1) => map((declaration_2) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadDeclaration61B89E55"](declaration_2), toList(declaration_1.members)), cons(declaration, otherDeclarations));
43
43
  let typeParameters;
44
- const own = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4088FB9E"](declaration.typeParameters);
44
+ const own = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](declaration.typeParameters);
45
45
  if (forAll((typeParameter) => (typeParameter.Default != null), own)) {
46
46
  typeParameters = own;
47
47
  }
@@ -53,8 +53,8 @@ export function readInterfaceDeclaration(reader, declaration) {
53
53
  }
54
54
  else {
55
55
  const symbol_1 = matchValue_1;
56
- othersDefaults = map((other_1) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4088FB9E"](other_1.typeParameters), filter((other) => {
57
- if (other.kind === 264) {
56
+ othersDefaults = map((other_1) => reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"](other_1.typeParameters), filter((other) => {
57
+ if (other.kind === 265) {
58
58
  return !(other === declaration);
59
59
  }
60
60
  else {
@@ -1,14 +1,92 @@
1
1
 
2
+ import { entityNameText, identifierText } from "./Utils.js";
3
+ import { exists } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
4
+ import { equals } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
5
+ import { ts } from "@ts-morph/bootstrap";
2
6
  import { FSharpResult$2 } from "../../fable_modules/fable-library-js.5.17.2/Result.js";
3
7
  import { Report_readerError_Z19516DCE } from "./Report.js";
4
8
  import { head, tail, isEmpty, length } from "../../fable_modules/fable-library-js.5.17.2/List.js";
5
9
  import { GlueType, GlueMappedType } from "../GlueAST.js";
6
10
 
11
+ function tryIdentitySource(reader, mappedTypeNode) {
12
+ let templateNode, constraintNode;
13
+ const matchValue = mappedTypeNode.readonlyToken;
14
+ const matchValue_1 = mappedTypeNode.questionToken;
15
+ const matchValue_2 = mappedTypeNode.typeParameter.constraint;
16
+ const matchValue_3 = mappedTypeNode.type;
17
+ let matchResult, constraintNode_1, templateNode_1;
18
+ if (matchValue == null) {
19
+ if (matchValue_1 == null) {
20
+ if (matchValue_2 != null) {
21
+ if (matchValue_3 != null) {
22
+ if ((templateNode = matchValue_3, (constraintNode = matchValue_2, ((constraintNode.kind === 199) && (constraintNode.operator === 143)) && (templateNode.kind === 200)))) {
23
+ matchResult = 0;
24
+ constraintNode_1 = matchValue_2;
25
+ templateNode_1 = matchValue_3;
26
+ }
27
+ else {
28
+ matchResult = 1;
29
+ }
30
+ }
31
+ else {
32
+ matchResult = 1;
33
+ }
34
+ }
35
+ else {
36
+ matchResult = 1;
37
+ }
38
+ }
39
+ else {
40
+ matchResult = 1;
41
+ }
42
+ }
43
+ else {
44
+ matchResult = 1;
45
+ }
46
+ switch (matchResult) {
47
+ case 0: {
48
+ const keyName = identifierText(mappedTypeNode.typeParameter.name);
49
+ const indexed = templateNode_1;
50
+ const isKey = (node) => {
51
+ if (node.kind === 184) {
52
+ return entityNameText(node.typeName) === keyName;
53
+ }
54
+ else {
55
+ return false;
56
+ }
57
+ };
58
+ let remapKeepsKey;
59
+ const matchValue_5 = mappedTypeNode.nameType;
60
+ if (matchValue_5 != null) {
61
+ const nameType = matchValue_5;
62
+ remapKeepsKey = ((nameType.kind === 193) && exists(isKey, nameType.types));
63
+ }
64
+ else {
65
+ remapKeepsKey = true;
66
+ }
67
+ if (isKey(indexed.indexType) && remapKeepsKey) {
68
+ const source_1 = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](constraintNode_1.type);
69
+ if (equals(source_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](indexed.objectType))) {
70
+ return source_1;
71
+ }
72
+ else {
73
+ return undefined;
74
+ }
75
+ }
76
+ else {
77
+ return undefined;
78
+ }
79
+ }
80
+ default:
81
+ return undefined;
82
+ }
83
+ }
84
+
7
85
  export function readMappedTypeNode(reader, mappedTypeNode) {
8
- let input_1, typNode;
86
+ let matchValue, input_1, typNode;
9
87
  let _arg_1;
10
88
  let input_2;
11
- const typeParameters = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4088FB9E"]([mappedTypeNode.typeParameter]);
89
+ const typeParameters = reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeParameters4BD418D9"]((ts.factory).createNodeArray([mappedTypeNode.typeParameter]));
12
90
  let matchResult, tp;
13
91
  if (!isEmpty(typeParameters)) {
14
92
  if (isEmpty(tail(typeParameters))) {
@@ -28,9 +106,9 @@ export function readMappedTypeNode(reader, mappedTypeNode) {
28
106
  break;
29
107
  }
30
108
  default:
31
- input_2 = (new FSharpResult$2(/* Error */ 1, [Report_readerError_Z19516DCE("readMappedTypeNode", `Expected exactly one type parameter but was ${length(typeParameters)}`, mappedTypeNode, "/_//src/Glutinum.Converter/Reader/MappedTypeNode.fs", 18)]));
109
+ input_2 = (new FSharpResult$2(/* Error */ 1, [Report_readerError_Z19516DCE("readMappedTypeNode", `Expected exactly one type parameter but was ${length(typeParameters)}`, mappedTypeNode, "/_//src/Glutinum.Converter/Reader/MappedTypeNode.fs", 60)]));
32
110
  }
33
- _arg_1 = ((input_2.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [input_2.fields[0]])) : (new FSharpResult$2(/* Ok */ 0, [new GlueType(/* MappedType */ 27, [new GlueMappedType(input_2.fields[0], (input_1 = mappedTypeNode.type, (input_1 == null) ? undefined : ((typNode = input_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode)))))])])));
111
+ _arg_1 = ((input_2.tag === 1) ? (new FSharpResult$2(/* Error */ 1, [input_2.fields[0]])) : (new FSharpResult$2(/* Ok */ 0, [(matchValue = tryIdentitySource(reader, mappedTypeNode), (matchValue == null) ? (new GlueType(/* MappedType */ 28, [new GlueMappedType(input_2.fields[0], (input_1 = mappedTypeNode.type, (input_1 == null) ? undefined : ((typNode = input_1, reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.ReadTypeNode24A678AD"](typNode)))))])) : matchValue)])));
34
112
  if (_arg_1.tag === 1) {
35
113
  void (reader["Glutinum.Converter.Reader.Types.ITypeScriptReader.get_Warnings"]().push(_arg_1.fields[0]));
36
114
  return GlueType.Discard;