@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.
Files changed (64) 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 +154 -69
  6. package/dist/Glutinum.Converter/Generate.js +44 -23
  7. package/dist/Glutinum.Converter/GlueAST.js +122 -74
  8. package/dist/Glutinum.Converter/Hosting.js +892 -0
  9. package/dist/Glutinum.Converter/Merge.js +469 -301
  10. package/dist/Glutinum.Converter/Packages.js +403 -77
  11. package/dist/Glutinum.Converter/Printer.js +455 -388
  12. package/dist/Glutinum.Converter/Read.js +366 -104
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +9 -9
  14. package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
  15. package/dist/Glutinum.Converter/Reader/Declaration.js +24 -30
  16. package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
  17. package/dist/Glutinum.Converter/Reader/Documentation.js +56 -67
  18. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +105 -38
  19. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +52 -55
  20. package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
  21. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +28 -16
  22. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +46 -45
  23. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +48 -5
  24. package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
  25. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
  26. package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
  27. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +55 -7
  28. package/dist/Glutinum.Converter/Reader/Node.js +23 -26
  29. package/dist/Glutinum.Converter/Reader/Parameters.js +39 -30
  30. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
  31. package/dist/Glutinum.Converter/Reader/TypeNode.js +410 -1545
  32. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +78 -51
  33. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +116 -71
  34. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +25 -7
  35. package/dist/Glutinum.Converter/Reader/Types.js +296 -16
  36. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +21 -34
  37. package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
  38. package/dist/Glutinum.Converter/Reader/Utils.js +584 -148
  39. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
  40. package/dist/Glutinum.Converter/Transform.js +2971 -6875
  41. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  42. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  43. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  44. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1087 -0
  45. package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
  46. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  47. package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
  48. package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
  49. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  50. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
  51. package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
  52. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  53. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +356 -0
  54. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  55. package/dist/Glutinum.Converter/TypeScript.Extensions.js +193 -211
  56. package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
  57. package/dist/Glutinum.Converter/Utils/String.js +15 -4
  58. package/dist/Program.js +107 -232
  59. package/package.json +4 -3
  60. package/dist/Glutinum.Converter/TypeScript.js +0 -12
  61. package/src/Glutinum.Converter/js/bootstrap.js +0 -123
  62. package/src/Glutinum.Converter/js/host.js +0 -144
  63. package/src/Glutinum.Converter/js/npm.js +0 -137
  64. package/src/Glutinum.Converter/js/resolve.js +0 -402
@@ -0,0 +1,136 @@
1
+
2
+ import { Record } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
3
+ import { FSharpCommentTypeParam, FSharpCommentParam, FSharpXmlDoc, FSharpAttribute, FSharpXmlDoc_$reflection, FSharpAttribute_$reflection } from "../FsharpAST.js";
4
+ import { record_type, list_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
5
+ import { sortBy, map, empty, singleton, append, head, tail, isEmpty } from "../../fable_modules/fable-library-js.5.17.2/List.js";
6
+ import { normalizeLineEndings } from "../Utils/String.js";
7
+ import { trimStart, join } from "../../fable_modules/fable-library-js.5.17.2/String.js";
8
+ import { collect, empty as empty_1, singleton as singleton_1, append as append_1, delay, toList } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
9
+ import { value as value_2, defaultArg } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
10
+ import { comparePrimitives, Exception } from "../../fable_modules/fable-library-js.5.17.2/Util.js";
11
+
12
+ export class TransformCommentResult extends Record {
13
+ constructor(ObsoleteAttributes, XmlDoc) {
14
+ super();
15
+ this.ObsoleteAttributes = ObsoleteAttributes;
16
+ this.XmlDoc = XmlDoc;
17
+ }
18
+ }
19
+
20
+ export function TransformCommentResult_$reflection() {
21
+ return record_type("Glutinum.Converter.Transformer.Comment.TransformCommentResult", [], TransformCommentResult, () => [["ObsoleteAttributes", list_type(FSharpAttribute_$reflection())], ["XmlDoc", list_type(FSharpXmlDoc_$reflection())]]);
22
+ }
23
+
24
+ export function transformComment(comment) {
25
+ const categorize = (acc_mut, comments_mut) => {
26
+ categorize:
27
+ while (true) {
28
+ const acc = acc_mut, comments = comments_mut;
29
+ if (!isEmpty(comments)) {
30
+ const rest = tail(comments);
31
+ const comment_1 = head(comments);
32
+ switch (comment_1.tag) {
33
+ case 3: {
34
+ acc_mut = {
35
+ Deprecated: append(acc.Deprecated, singleton(comment_1.fields[0])),
36
+ Others: acc.Others,
37
+ Remarks: acc.Remarks,
38
+ Throws: acc.Throws,
39
+ };
40
+ comments_mut = rest;
41
+ continue categorize;
42
+ }
43
+ case 8: {
44
+ acc_mut = {
45
+ Deprecated: acc.Deprecated,
46
+ Others: acc.Others,
47
+ Remarks: acc.Remarks,
48
+ Throws: append(acc.Throws, singleton(comment_1.fields[0])),
49
+ };
50
+ comments_mut = rest;
51
+ continue categorize;
52
+ }
53
+ case 4: {
54
+ acc_mut = {
55
+ Deprecated: acc.Deprecated,
56
+ Others: acc.Others,
57
+ Remarks: append(acc.Remarks, singleton(comment_1.fields[0])),
58
+ Throws: acc.Throws,
59
+ };
60
+ comments_mut = rest;
61
+ continue categorize;
62
+ }
63
+ default: {
64
+ acc_mut = {
65
+ Deprecated: acc.Deprecated,
66
+ Others: append(acc.Others, singleton(comment_1)),
67
+ Remarks: acc.Remarks,
68
+ Throws: acc.Throws,
69
+ };
70
+ comments_mut = rest;
71
+ continue categorize;
72
+ }
73
+ }
74
+ }
75
+ else {
76
+ return acc;
77
+ }
78
+ break;
79
+ }
80
+ };
81
+ const categories = categorize({
82
+ Deprecated: empty(),
83
+ Others: empty(),
84
+ Remarks: empty(),
85
+ Throws: empty(),
86
+ }, comment);
87
+ const obsoleteAttributes = map((arg) => {
88
+ let option_1;
89
+ return new FSharpAttribute(/* Obsolete */ 11, [(option_1 = arg, (option_1 != null) ? normalizeLineEndings(option_1) : undefined)]);
90
+ }, categories.Deprecated);
91
+ const remarks = (!isEmpty(categories.Remarks) ? true : !isEmpty(categories.Throws)) ? (new FSharpXmlDoc(/* Remarks */ 3, [join("\n", toList(delay(() => append_1(categories.Remarks, delay(() => append_1(!isEmpty(categories.Throws) ? append_1(!isEmpty(categories.Remarks) ? singleton_1("") : empty_1(), delay(() => append_1(singleton_1("Throws:"), delay(() => singleton_1("-------"))))) : empty_1(), delay(() => collect((throws) => append_1(singleton_1(""), delay(() => singleton_1(throws))), categories.Throws))))))))])) : undefined;
92
+ const others = map((comment_2) => {
93
+ let option_3, content_3;
94
+ switch (comment_2.tag) {
95
+ case 0:
96
+ return new FSharpXmlDoc(/* Summary */ 0, [comment_2.fields[0]]);
97
+ case 1:
98
+ return new FSharpXmlDoc(/* Returns */ 2, [comment_2.fields[0]]);
99
+ case 2: {
100
+ const param = comment_2.fields[0];
101
+ return new FSharpXmlDoc(/* Param */ 1, [new FSharpCommentParam(param.Name, defaultArg((option_3 = param.Content, (option_3 != null) ? ((content_3 = option_3, trimStart(content_3.trimStart(), "-").trimStart())) : undefined), ""))]);
102
+ }
103
+ case 5:
104
+ return new FSharpXmlDoc(/* DefaultValue */ 4, [comment_2.fields[0]]);
105
+ case 6:
106
+ return new FSharpXmlDoc(/* Example */ 5, [comment_2.fields[0]]);
107
+ case 7: {
108
+ const typeParam = comment_2.fields[0];
109
+ return new FSharpXmlDoc(/* TypeParam */ 6, [new FSharpCommentTypeParam(typeParam.TypeName, defaultArg(typeParam.Content, ""))]);
110
+ }
111
+ default:
112
+ throw new Exception("Should not happen");
113
+ }
114
+ }, categories.Others);
115
+ return new TransformCommentResult(obsoleteAttributes, sortBy((xmlDoc) => {
116
+ switch (xmlDoc.tag) {
117
+ case 4:
118
+ return 1;
119
+ case 3:
120
+ return 2;
121
+ case 5:
122
+ return 3;
123
+ case 1:
124
+ return 4;
125
+ case 6:
126
+ return 5;
127
+ case 2:
128
+ return 999;
129
+ default:
130
+ return 0;
131
+ }
132
+ }, toList(delay(() => append_1(others, delay(() => ((remarks != null) ? singleton_1(value_2(remarks)) : empty_1()))))), {
133
+ Compare: (x, y) => (comparePrimitives(x, y) | 0),
134
+ }));
135
+ }
136
+