@glutinum/cli 1.0.0-beta.7 → 1.0.0-beta.8

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.
@@ -0,0 +1,219 @@
1
+
2
+ import { Record } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
3
+ import { list_type, option_type, record_type, string_type } from "../../fable_modules/fable-library-js.5.17.2/Reflection.js";
4
+ import { FSharpParameter, FSharpTypeAlias, FSharpFunctionType, FSharpUnion, FSharpUnionCase, FSharpTypeReference, FSharpType, FSharpMapped, FSharpTypeParameter, FSharpTypeParameterInfo_Create_Z6CFD3565, FSharpTypeParameter_$reflection, FSharpType_$reflection } from "../FsharpAST.js";
5
+ import { defaultArg, unwrap } from "../../fable_modules/fable-library-js.5.17.2/Option.js";
6
+ import { map, tryFind } from "../../fable_modules/fable-library-js.5.17.2/List.js";
7
+ import { substring } from "../../fable_modules/fable-library-js.5.17.2/String.js";
8
+ import { tryUnwrapOption } from "./Utils.js";
9
+
10
+ export class SealedTypeInfo extends Record {
11
+ constructor(TypeParameterName, FSharpType) {
12
+ super();
13
+ this.TypeParameterName = TypeParameterName;
14
+ this.FSharpType = FSharpType;
15
+ }
16
+ }
17
+
18
+ export function SealedTypeInfo_$reflection() {
19
+ return record_type("Glutinum.Converter.Transformer.TypeParameter.SealedTypeInfo", [], SealedTypeInfo, () => [["TypeParameterName", string_type], ["FSharpType", FSharpType_$reflection()]]);
20
+ }
21
+
22
+ export class TransformResult extends Record {
23
+ constructor(FSharpTypeParameter, SealedTypeOpt) {
24
+ super();
25
+ this.FSharpTypeParameter = FSharpTypeParameter;
26
+ this.SealedTypeOpt = SealedTypeOpt;
27
+ }
28
+ }
29
+
30
+ export function TransformResult_$reflection() {
31
+ return record_type("Glutinum.Converter.Transformer.TypeParameter.TransformResult", [], TransformResult, () => [["FSharpTypeParameter", FSharpTypeParameter_$reflection()], ["SealedTypeOpt", option_type(SealedTypeInfo_$reflection())]]);
32
+ }
33
+
34
+ export function TransformResult_Create_403667D8(typeParameterName, default_, constraint_, sealedType) {
35
+ return new TransformResult(new FSharpTypeParameter(/* FSharpTypeParameter */ 1, [FSharpTypeParameterInfo_Create_Z6CFD3565(typeParameterName, unwrap(constraint_), unwrap(default_))]), (sealedType == null) ? undefined : (new SealedTypeInfo(typeParameterName, sealedType)));
36
+ }
37
+
38
+ /**
39
+ * `withDefault` transforms the default, which exposes the types it names. A signature
40
+ * never prints a default, F# has none, and exposing them there names the type parameters
41
+ * of the enclosing declaration, which the exposed type can't declare.
42
+ */
43
+ export function mapFSharpType(seadledTypes, typ) {
44
+ let matchResult, typeParameter, info_1, info_2, innerType, typeReference, unionInfo, types, typ_7, functionInfo, alias;
45
+ switch (typ.tag) {
46
+ case 0:
47
+ case 2:
48
+ case 4:
49
+ case 5:
50
+ case 6:
51
+ case 8:
52
+ case 10:
53
+ case 15:
54
+ case 17:
55
+ case 18:
56
+ case 19:
57
+ case 20:
58
+ case 21: {
59
+ matchResult = 10;
60
+ break;
61
+ }
62
+ case 7: {
63
+ if (typ.fields[0].Name.startsWith("\'")) {
64
+ matchResult = 1;
65
+ info_1 = typ.fields[0];
66
+ }
67
+ else {
68
+ matchResult = 2;
69
+ info_2 = typ.fields[0];
70
+ }
71
+ break;
72
+ }
73
+ case 3: {
74
+ matchResult = 3;
75
+ innerType = typ.fields[0];
76
+ break;
77
+ }
78
+ case 11: {
79
+ matchResult = 4;
80
+ typeReference = typ.fields[0];
81
+ break;
82
+ }
83
+ case 1: {
84
+ matchResult = 5;
85
+ unionInfo = typ.fields[0];
86
+ break;
87
+ }
88
+ case 12: {
89
+ matchResult = 6;
90
+ types = typ.fields[0];
91
+ break;
92
+ }
93
+ case 14: {
94
+ matchResult = 7;
95
+ typ_7 = typ.fields[0];
96
+ break;
97
+ }
98
+ case 16: {
99
+ matchResult = 8;
100
+ functionInfo = typ.fields[0];
101
+ break;
102
+ }
103
+ case 9: {
104
+ matchResult = 9;
105
+ alias = typ.fields[0];
106
+ break;
107
+ }
108
+ default: {
109
+ matchResult = 0;
110
+ typeParameter = typ.fields[0];
111
+ }
112
+ }
113
+ switch (matchResult) {
114
+ case 0: {
115
+ const needMapping = tryFind((mapperInfo) => (mapperInfo.TypeParameterName === typeParameter), seadledTypes);
116
+ if (needMapping == null) {
117
+ return typ;
118
+ }
119
+ else {
120
+ return needMapping.FSharpType;
121
+ }
122
+ }
123
+ case 1: {
124
+ const matchValue = tryFind((mapperInfo_2) => (mapperInfo_2.TypeParameterName === substring(info_1.Name, 1)), seadledTypes);
125
+ if (matchValue == null) {
126
+ return typ;
127
+ }
128
+ else {
129
+ return matchValue.FSharpType;
130
+ }
131
+ }
132
+ case 2:
133
+ return new FSharpType(/* Mapped */ 7, [new FSharpMapped(info_2.Name, map((_arg) => {
134
+ if (_arg.tag === 1) {
135
+ const paramInfo = _arg.fields[0];
136
+ const matchValue_1 = tryFind((mapperInfo_4) => (mapperInfo_4.TypeParameterName === paramInfo.Name), seadledTypes);
137
+ if (matchValue_1 == null) {
138
+ return new FSharpTypeParameter(/* FSharpTypeParameter */ 1, [paramInfo]);
139
+ }
140
+ else {
141
+ return new FSharpTypeParameter(/* FSharpType */ 0, [matchValue_1.FSharpType]);
142
+ }
143
+ }
144
+ else {
145
+ return new FSharpTypeParameter(/* FSharpType */ 0, [mapFSharpType(seadledTypes, _arg.fields[0])]);
146
+ }
147
+ }, info_2.TypeParameters))]);
148
+ case 3:
149
+ return new FSharpType(/* Option */ 3, [mapFSharpType(seadledTypes, innerType)]);
150
+ case 4:
151
+ return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(typeReference.Name, typeReference.FullName, typeReference.ModulePath, map((typ_2) => mapFSharpType(seadledTypes, typ_2), typeReference.TypeArguments), typeReference.Type)]);
152
+ case 5:
153
+ return new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, map((case$) => {
154
+ switch (case$.tag) {
155
+ case 1:
156
+ return new FSharpUnionCase(/* Typed */ 1, [mapFSharpType(seadledTypes, case$.fields[0])]);
157
+ case 2:
158
+ return new FSharpUnionCase(/* Field */ 2, [case$.fields[0], mapFSharpType(seadledTypes, case$.fields[1])]);
159
+ case 3:
160
+ return new FSharpUnionCase(/* NamedFields */ 3, [case$.fields[0], map((tupledArg) => [tupledArg[0], mapFSharpType(seadledTypes, tupledArg[1])], case$.fields[1])]);
161
+ default:
162
+ return case$;
163
+ }
164
+ }, unionInfo.Cases), unionInfo.IsOptional, unionInfo.TypeParameters, unionInfo.Constants)]);
165
+ case 6:
166
+ return new FSharpType(/* Tuple */ 12, [map((typ_6) => mapFSharpType(seadledTypes, typ_6), types)]);
167
+ case 7:
168
+ return new FSharpType(/* ResizeArray */ 14, [mapFSharpType(seadledTypes, typ_7)]);
169
+ case 8:
170
+ return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => mapFsharpParameter(seadledTypes, parameter), functionInfo.Parameters), mapFSharpType(seadledTypes, functionInfo.ReturnType))]);
171
+ case 9:
172
+ return new FSharpType(/* TypeAlias */ 9, [new FSharpTypeAlias(alias.Attributes, alias.Name, alias.XmlDoc, alias.Type, map((_arg_1) => {
173
+ if (_arg_1.tag === 0) {
174
+ return new FSharpTypeParameter(/* FSharpType */ 0, [mapFSharpType(seadledTypes, _arg_1.fields[0])]);
175
+ }
176
+ else {
177
+ const matchValue_2 = tryFind((mapperInfo_6) => (mapperInfo_6.TypeParameterName === _arg_1.fields[0].Name), seadledTypes);
178
+ if (matchValue_2 == null) {
179
+ return _arg_1;
180
+ }
181
+ else {
182
+ return new FSharpTypeParameter(/* FSharpType */ 0, [matchValue_2.FSharpType]);
183
+ }
184
+ }
185
+ }, alias.TypeParameters))]);
186
+ default:
187
+ return typ;
188
+ }
189
+ }
190
+
191
+ export function mapFsharpParameter(seadledTypes, parameter) {
192
+ const typ = mapFSharpType(seadledTypes, parameter.Type);
193
+ return new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, parameter.IsOptional ? defaultArg(tryUnwrapOption(typ), typ) : typ, parameter.OriginalGlueMember);
194
+ }
195
+
196
+ export class TransformTypeParametersResult extends Record {
197
+ constructor(TypeParameters, SealedTypes) {
198
+ super();
199
+ this.TypeParameters = TypeParameters;
200
+ this.SealedTypes = SealedTypes;
201
+ }
202
+ }
203
+
204
+ export function TransformTypeParametersResult_$reflection() {
205
+ return record_type("Glutinum.Converter.Transformer.TypeParameter.TransformTypeParametersResult", [], TransformTypeParametersResult, () => [["TypeParameters", list_type(FSharpTypeParameter_$reflection())], ["SealedTypes", list_type(SealedTypeInfo_$reflection())]]);
206
+ }
207
+
208
+ export class TransformDeclarationTypeParametersResult extends Record {
209
+ constructor(TypeParameters, SealedTypeArguments) {
210
+ super();
211
+ this.TypeParameters = TypeParameters;
212
+ this.SealedTypeArguments = SealedTypeArguments;
213
+ }
214
+ }
215
+
216
+ export function TransformDeclarationTypeParametersResult_$reflection() {
217
+ return record_type("Glutinum.Converter.Transformer.TypeParameter.TransformDeclarationTypeParametersResult", [], TransformDeclarationTypeParametersResult, () => [["TypeParameters", list_type(FSharpTypeParameter_$reflection())], ["SealedTypeArguments", option_type(list_type(FSharpTypeParameter_$reflection()))]]);
218
+ }
219
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glutinum/cli",
3
- "version": "1.0.0-beta.7",
3
+ "version": "1.0.0-beta.8",
4
4
  "description": "TypeScript definition to F# bindings converter",
5
5
  "type": "module",
6
6
  "main": "index.js",