@glutinum/cli 1.0.0-beta.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 (56) 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 +38 -25
  7. package/dist/Glutinum.Converter/GlueAST.js +82 -43
  8. package/dist/Glutinum.Converter/Hosting.js +143 -169
  9. package/dist/Glutinum.Converter/Merge.js +369 -337
  10. package/dist/Glutinum.Converter/Packages.js +384 -94
  11. package/dist/Glutinum.Converter/Printer.js +432 -393
  12. package/dist/Glutinum.Converter/Read.js +361 -99
  13. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
  14. package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
  15. package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
  16. package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
  17. package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
  18. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
  19. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
  20. package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
  21. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
  22. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +15 -21
  23. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
  24. package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
  25. package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
  26. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +53 -5
  27. package/dist/Glutinum.Converter/Reader/Node.js +8 -11
  28. package/dist/Glutinum.Converter/Reader/Parameters.js +36 -27
  29. package/dist/Glutinum.Converter/Reader/TypeNode.js +389 -1583
  30. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +76 -49
  31. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
  32. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
  33. package/dist/Glutinum.Converter/Reader/Types.js +295 -15
  34. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
  35. package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
  36. package/dist/Glutinum.Converter/Reader/Utils.js +487 -101
  37. package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
  38. package/dist/Glutinum.Converter/Transform.js +2915 -8176
  39. package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
  40. package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
  41. package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
  42. package/dist/Glutinum.Converter/Transformer/Conditionals.js +1087 -0
  43. package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
  44. package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
  45. package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
  46. package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
  47. package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
  48. package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
  49. package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
  50. package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
  51. package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +356 -0
  52. package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
  53. package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
  54. package/dist/Glutinum.Converter/Utils/String.js +14 -3
  55. package/dist/Program.js +102 -239
  56. package/package.json +3 -2
@@ -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
+