@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.11
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.
- package/README.md +16 -0
- package/dist/Glutinum.Converter/Abbreviations.js +16 -39
- package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
- package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
- package/dist/Glutinum.Converter/FsharpAST.js +117 -66
- package/dist/Glutinum.Converter/Generate.js +52 -26
- package/dist/Glutinum.Converter/GlueAST.js +85 -46
- package/dist/Glutinum.Converter/Hosting.js +148 -174
- package/dist/Glutinum.Converter/Merge.js +463 -355
- package/dist/Glutinum.Converter/Packages.js +387 -97
- package/dist/Glutinum.Converter/Printer.js +439 -400
- package/dist/Glutinum.Converter/Read.js +362 -100
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
- package/dist/Glutinum.Converter/Reader/Declaration.js +13 -19
- package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
- package/dist/Glutinum.Converter/Reader/Documentation.js +28 -40
- package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +2 -2
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +104 -37
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +24 -39
- package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +30 -17
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +16 -22
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +49 -6
- package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +4 -4
- package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +54 -6
- package/dist/Glutinum.Converter/Reader/Node.js +11 -14
- package/dist/Glutinum.Converter/Reader/Parameters.js +39 -30
- package/dist/Glutinum.Converter/Reader/Report.js +4 -4
- package/dist/Glutinum.Converter/Reader/TypeNode.js +390 -1584
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +80 -53
- package/dist/Glutinum.Converter/Reader/TypeParameters.js +2 -2
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +24 -47
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +24 -6
- package/dist/Glutinum.Converter/Reader/Types.js +297 -17
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +16 -30
- package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
- package/dist/Glutinum.Converter/Reader/Utils.js +497 -111
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +7 -8
- package/dist/Glutinum.Converter/Transform.js +2915 -8180
- package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
- package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
- package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
- package/dist/Glutinum.Converter/Transformer/Conditionals.js +1087 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +338 -0
- package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
- package/dist/Glutinum.Converter/Utils/Keywords.js +3 -3
- package/dist/Glutinum.Converter/Utils/List.js +2 -2
- package/dist/Glutinum.Converter/Utils/Naming.js +6 -6
- package/dist/Glutinum.Converter/Utils/String.js +16 -5
- package/dist/Program.js +104 -241
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +2 -2
- package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +4 -4
- package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +2 -2
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +5 -5
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +4 -4
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +4 -4
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +2 -2
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +2 -2
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +7 -7
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Async.js +21 -7
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/AsyncBuilder.js +51 -6
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/CHANGELOG.md +23 -1
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/CollectionUtil.js +10 -16
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MailboxProcessor.js +19 -3
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MutableMap.js +5 -1
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MutableSet.js +5 -1
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Util.js +15 -3
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/package.json +1 -1
- package/package.json +3 -2
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Array.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/BigInt.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/BitConverter.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Boolean.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Char.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Choice.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/ConditionalWeakTable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Date.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOffset.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOnlyTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeFormat.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeOffsetTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Decimal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Directory.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Double.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Encoding.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Environment.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Event.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Collections.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Core.CompilerServices.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Core.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/File.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Global.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Guid.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Int32.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/List.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Long.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Map.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MapUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Native.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Numeric.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Observable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Option.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Path.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/README.md +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Random.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Range.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Reflection.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/RegExp.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Result.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Seq.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Seq2.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Set.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/String.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.Collections.Generic.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.Text.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Task.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TaskBuilder.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeOnlyTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeSpan.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeSpanTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Timer.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Types.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Unicode.13.0.0.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Uri.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/big.d.ts +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/lib/big.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/quotation.js +0 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
|
|
2
|
+
import { ofList as ofList_1, empty as empty_1, FSharpSet__Add, FSharpSet__Contains, ofSeq } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
|
|
3
|
+
import { equals, comparePrimitives } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
|
|
4
|
+
import { exists, take, forAll2, length, forAll, indexed as indexed_1, fold, head, tail, isEmpty, map, singleton, filter, empty, choose, append, collect, tryPick } from "../../fable_modules/fable-library-js.5.21.0/List.js";
|
|
5
|
+
import { defaultArg } from "../../fable_modules/fable-library-js.5.21.0/Option.js";
|
|
6
|
+
import { Record } from "../../fable_modules/fable-library-js.5.21.0/Types.js";
|
|
7
|
+
import { GlueSubstitution_substitute, GlueSubstitution_substituteMember, GlueSubstitution_ofTypeArguments, GlueSubstitution_substituteParameter, GluePrimitive, GlueTypeReference, GlueTypeUnion, GlueType, GlueFunctionType, GlueParameter, GlueType_$reflection, GlueMember_$reflection, GlueTypeParameter_$reflection } from "../GlueAST.js";
|
|
8
|
+
import { record_type, list_type } from "../../fable_modules/fable-library-js.5.21.0/Reflection.js";
|
|
9
|
+
import { ofList } from "../../fable_modules/fable-library-js.5.21.0/Map.js";
|
|
10
|
+
import { max } from "../../fable_modules/fable-library-js.5.21.0/Double.js";
|
|
11
|
+
|
|
12
|
+
const primitiveNames = ofSeq(["string", "float", "int", "bool", "obj", "unit", "bigint"], {
|
|
13
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export function isInheritableType(typ) {
|
|
17
|
+
switch (typ.tag) {
|
|
18
|
+
case 18:
|
|
19
|
+
case 8:
|
|
20
|
+
return false;
|
|
21
|
+
case 11: {
|
|
22
|
+
const typeReference = typ.fields[0];
|
|
23
|
+
if ((!typeReference.Name.startsWith("JS.") && (typeReference.Name !== "Action")) && (typeReference.Name !== "RegExp")) {
|
|
24
|
+
return !FSharpSet__Contains(primitiveNames, typeReference.Name);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
default:
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `declare abstract class XRSystem implements XRSystem {}` merged with the interface
|
|
37
|
+
*/
|
|
38
|
+
export function isSelfHeritage(fullName, heritageClause) {
|
|
39
|
+
if (heritageClause.tag === 13) {
|
|
40
|
+
if (fullName !== "") {
|
|
41
|
+
return heritageClause.fields[0].FullName === fullName;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function isErrorHeritage(heritageClause) {
|
|
53
|
+
if (heritageClause.tag === 13) {
|
|
54
|
+
const typeReference = heritageClause.fields[0];
|
|
55
|
+
if (typeReference.IsStandardLibrary) {
|
|
56
|
+
return typeReference.Name === "Error";
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function isArrayHeritage(heritageClause) {
|
|
68
|
+
if (heritageClause.tag === 13) {
|
|
69
|
+
const typeReference = heritageClause.fields[0];
|
|
70
|
+
if (typeReference.IsStandardLibrary) {
|
|
71
|
+
return typeReference.Name === "Array";
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* F# rejects an abstract property redeclared with the signature of a base class one
|
|
84
|
+
*/
|
|
85
|
+
export function withoutBaseClassProperties(typeMemory, heritageClauses, members) {
|
|
86
|
+
const tryFindClass = (name, glueTypes) => tryPick((glueType) => {
|
|
87
|
+
let matchResult, candidate_1, moduleDeclaration, fileModule;
|
|
88
|
+
switch (glueType.tag) {
|
|
89
|
+
case 12: {
|
|
90
|
+
if (glueType.fields[0].Name === name) {
|
|
91
|
+
matchResult = 0;
|
|
92
|
+
candidate_1 = glueType.fields[0];
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
matchResult = 3;
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case 11: {
|
|
100
|
+
matchResult = 1;
|
|
101
|
+
moduleDeclaration = glueType.fields[0];
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case 31: {
|
|
105
|
+
matchResult = 2;
|
|
106
|
+
fileModule = glueType.fields[0];
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
matchResult = 3;
|
|
111
|
+
}
|
|
112
|
+
switch (matchResult) {
|
|
113
|
+
case 0:
|
|
114
|
+
return candidate_1;
|
|
115
|
+
case 1:
|
|
116
|
+
return tryFindClass(name, moduleDeclaration.Types);
|
|
117
|
+
case 2:
|
|
118
|
+
return tryFindClass(name, fileModule.Types);
|
|
119
|
+
default:
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}, glueTypes);
|
|
123
|
+
const baseProperties = (visited, heritageClauses_1) => collect((heritageClause) => {
|
|
124
|
+
let option_1, baseClass;
|
|
125
|
+
let matchResult_1, typeReference_1;
|
|
126
|
+
if (heritageClause.tag === 13) {
|
|
127
|
+
if (!FSharpSet__Contains(visited, heritageClause.fields[0].Name)) {
|
|
128
|
+
matchResult_1 = 0;
|
|
129
|
+
typeReference_1 = heritageClause.fields[0];
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
matchResult_1 = 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
matchResult_1 = 1;
|
|
137
|
+
}
|
|
138
|
+
switch (matchResult_1) {
|
|
139
|
+
case 0:
|
|
140
|
+
return defaultArg((option_1 = tryFindClass(typeReference_1.Name, typeMemory), (option_1 != null) ? ((baseClass = option_1, append(choose((_arg) => {
|
|
141
|
+
if (_arg.tag === 1) {
|
|
142
|
+
return _arg.fields[0].Name;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
}, baseClass.Members), baseProperties(FSharpSet__Add(visited, typeReference_1.Name), baseClass.HeritageClauses)))) : undefined), empty());
|
|
148
|
+
default:
|
|
149
|
+
return empty();
|
|
150
|
+
}
|
|
151
|
+
}, heritageClauses_1);
|
|
152
|
+
const inherited = ofSeq(baseProperties(empty_1({
|
|
153
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
154
|
+
}), heritageClauses), {
|
|
155
|
+
Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
|
|
156
|
+
});
|
|
157
|
+
return filter((_arg_1) => {
|
|
158
|
+
if (_arg_1.tag === 1) {
|
|
159
|
+
return !FSharpSet__Contains(inherited, _arg_1.fields[0].Name);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}, members);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
class BaseDeclaration extends Record {
|
|
168
|
+
constructor(TypeParameters, Members, HeritageClauses) {
|
|
169
|
+
super();
|
|
170
|
+
this.TypeParameters = TypeParameters;
|
|
171
|
+
this.Members = Members;
|
|
172
|
+
this.HeritageClauses = HeritageClauses;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function BaseDeclaration_$reflection() {
|
|
177
|
+
return record_type("Glutinum.Converter.Transformer.Heritage.BaseDeclaration", [], BaseDeclaration, () => [["TypeParameters", list_type(GlueTypeParameter_$reflection())], ["Members", list_type(GlueMember_$reflection())], ["HeritageClauses", list_type(GlueType_$reflection())]]);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function declarations(glueTypes) {
|
|
181
|
+
return collect((glueType) => {
|
|
182
|
+
switch (glueType.tag) {
|
|
183
|
+
case 12: {
|
|
184
|
+
const info = glueType.fields[0];
|
|
185
|
+
return singleton([info.FullName, info.Name, new BaseDeclaration(info.TypeParameters, info.Members, info.HeritageClauses)]);
|
|
186
|
+
}
|
|
187
|
+
case 1: {
|
|
188
|
+
const info_1 = glueType.fields[0];
|
|
189
|
+
return singleton([info_1.FullName, info_1.Name, new BaseDeclaration(info_1.TypeParameters, info_1.Members, info_1.HeritageClauses)]);
|
|
190
|
+
}
|
|
191
|
+
case 11:
|
|
192
|
+
return declarations(glueType.fields[0].Types);
|
|
193
|
+
case 31:
|
|
194
|
+
return declarations(glueType.fields[0].Types);
|
|
195
|
+
default:
|
|
196
|
+
return empty();
|
|
197
|
+
}
|
|
198
|
+
}, glueTypes);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function tryFindBase(typeMemory, typeReference) {
|
|
202
|
+
let matchValue;
|
|
203
|
+
const candidates = declarations(typeMemory);
|
|
204
|
+
const found = map((tupledArg_2) => tupledArg_2[2], (typeReference.FullName !== "") ? filter((tupledArg) => (tupledArg[0] === typeReference.FullName), candidates) : ((matchValue = filter((tupledArg_1) => (tupledArg_1[1] === typeReference.Name), candidates), !isEmpty(matchValue) ? (isEmpty(tail(matchValue)) ? singleton(head(matchValue)) : empty()) : empty())));
|
|
205
|
+
if (!isEmpty(found)) {
|
|
206
|
+
return new BaseDeclaration(head(found).TypeParameters, collect((_arg_6) => _arg_6.Members, found), collect((_arg_7) => _arg_7.HeritageClauses, found));
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* F# rejects an interface inherited twice with different type arguments (FS3360)
|
|
215
|
+
*/
|
|
216
|
+
export function withoutBasesOfBases(typeMemory, heritageClauses) {
|
|
217
|
+
const basesBelow = (visited, clause) => {
|
|
218
|
+
let typeReference;
|
|
219
|
+
let matchResult, typeReference_1;
|
|
220
|
+
if (clause.tag === 13) {
|
|
221
|
+
if ((typeReference = clause.fields[0], (typeReference.FullName !== "") && !FSharpSet__Contains(visited, typeReference.FullName))) {
|
|
222
|
+
matchResult = 0;
|
|
223
|
+
typeReference_1 = clause.fields[0];
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
matchResult = 1;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
matchResult = 1;
|
|
231
|
+
}
|
|
232
|
+
switch (matchResult) {
|
|
233
|
+
case 0: {
|
|
234
|
+
const matchValue = tryFindBase(typeMemory, typeReference_1);
|
|
235
|
+
if (matchValue == null) {
|
|
236
|
+
return visited;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
return fold((acc, baseClause) => {
|
|
240
|
+
let matchResult_1, baseReference_1;
|
|
241
|
+
if (baseClause.tag === 13) {
|
|
242
|
+
if (baseClause.fields[0].FullName !== "") {
|
|
243
|
+
matchResult_1 = 0;
|
|
244
|
+
baseReference_1 = baseClause.fields[0];
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
matchResult_1 = 1;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
matchResult_1 = 1;
|
|
252
|
+
}
|
|
253
|
+
switch (matchResult_1) {
|
|
254
|
+
case 0:
|
|
255
|
+
return basesBelow(FSharpSet__Add(acc, baseReference_1.FullName), baseClause);
|
|
256
|
+
default:
|
|
257
|
+
return acc;
|
|
258
|
+
}
|
|
259
|
+
}, visited, matchValue.HeritageClauses);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
default:
|
|
263
|
+
return visited;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
const indexed = indexed_1(heritageClauses);
|
|
267
|
+
return map((tuple) => tuple[1], filter((tupledArg) => {
|
|
268
|
+
const clause_1 = tupledArg[1];
|
|
269
|
+
let matchResult_2, typeReference_3;
|
|
270
|
+
if (clause_1.tag === 13) {
|
|
271
|
+
if (clause_1.fields[0].FullName !== "") {
|
|
272
|
+
matchResult_2 = 0;
|
|
273
|
+
typeReference_3 = clause_1.fields[0];
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
matchResult_2 = 1;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
matchResult_2 = 1;
|
|
281
|
+
}
|
|
282
|
+
switch (matchResult_2) {
|
|
283
|
+
case 0:
|
|
284
|
+
return forAll((tupledArg_1) => {
|
|
285
|
+
if (tupledArg_1[0] === tupledArg[0]) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
return !FSharpSet__Contains(basesBelow(empty_1({
|
|
290
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
291
|
+
}), tupledArg_1[1]), typeReference_3.FullName);
|
|
292
|
+
}
|
|
293
|
+
}, indexed);
|
|
294
|
+
default:
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
}, indexed));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function memberName(glueMember) {
|
|
301
|
+
switch (glueMember.tag) {
|
|
302
|
+
case 6:
|
|
303
|
+
return glueMember.fields[0].Name;
|
|
304
|
+
case 1:
|
|
305
|
+
return glueMember.fields[0].Name;
|
|
306
|
+
case 2:
|
|
307
|
+
return glueMember.fields[0].Name;
|
|
308
|
+
case 3:
|
|
309
|
+
return glueMember.fields[0].Name;
|
|
310
|
+
case 4:
|
|
311
|
+
case 5:
|
|
312
|
+
case 7:
|
|
313
|
+
return undefined;
|
|
314
|
+
default:
|
|
315
|
+
return glueMember.fields[0].Name;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function comparable(glueType) {
|
|
320
|
+
switch (glueType.tag) {
|
|
321
|
+
case 15: {
|
|
322
|
+
const functionType = glueType.fields[0];
|
|
323
|
+
return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(empty(), comparable(functionType.Type), empty(), empty(), map((parameter) => (new GlueParameter("", parameter.IsOptional, parameter.IsSpread, comparable(parameter.Type))), functionType.Parameters))]);
|
|
324
|
+
}
|
|
325
|
+
case 7:
|
|
326
|
+
return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(comparable, glueType.fields[0].fields[0]))]);
|
|
327
|
+
case 14:
|
|
328
|
+
return new GlueType(/* Array */ 14, [comparable(glueType.fields[0])]);
|
|
329
|
+
case 30:
|
|
330
|
+
return new GlueType(/* ReadOnly */ 30, [comparable(glueType.fields[0])]);
|
|
331
|
+
case 23:
|
|
332
|
+
return new GlueType(/* OptionalType */ 23, [comparable(glueType.fields[0])]);
|
|
333
|
+
case 18:
|
|
334
|
+
return new GlueType(/* TupleType */ 18, [map(comparable, glueType.fields[0])]);
|
|
335
|
+
case 13: {
|
|
336
|
+
const typeReference = glueType.fields[0];
|
|
337
|
+
return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(typeReference.Name, typeReference.FullName, typeReference.ModulePath, map(comparable, typeReference.TypeArguments), typeReference.IsStandardLibrary)]);
|
|
338
|
+
}
|
|
339
|
+
default:
|
|
340
|
+
return glueType;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function shape(typeParameters, parameters) {
|
|
345
|
+
const substitutions = ofList(map((typeParameter) => [typeParameter.Name, defaultArg(typeParameter.Constraint, new GlueType(/* Primitive */ 3, [GluePrimitive.Any]))], typeParameters), {
|
|
346
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
347
|
+
});
|
|
348
|
+
return map((parameter_1) => [comparable(parameter_1.Type), parameter_1.IsOptional, parameter_1.IsSpread], map((parameter) => GlueSubstitution_substituteParameter(substitutions, parameter), parameters));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function tryShape(glueMember) {
|
|
352
|
+
switch (glueMember.tag) {
|
|
353
|
+
case 0: {
|
|
354
|
+
const info = glueMember.fields[0];
|
|
355
|
+
return [info.Name, shape(info.TypeParameters, info.Parameters)];
|
|
356
|
+
}
|
|
357
|
+
case 6: {
|
|
358
|
+
const info_1 = glueMember.fields[0];
|
|
359
|
+
return [info_1.Name, shape(info_1.TypeParameters, info_1.Parameters)];
|
|
360
|
+
}
|
|
361
|
+
default:
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function collides(derived, baseShape) {
|
|
367
|
+
const required = (parameters) => (length(filter((tupledArg) => !tupledArg[1], parameters)) | 0);
|
|
368
|
+
const shared = max(required(derived), required(baseShape)) | 0;
|
|
369
|
+
if ((!equals(derived, baseShape) && (shared < length(derived))) && (shared < length(baseShape))) {
|
|
370
|
+
return forAll2((tupledArg_1, tupledArg_2) => equals(tupledArg_1[0], tupledArg_2[0]), take(shared, derived), take(shared, baseShape));
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function hasCollision(members, baseMembers) {
|
|
378
|
+
const derived = choose(tryShape, members);
|
|
379
|
+
return exists((tupledArg) => exists((tupledArg_1) => {
|
|
380
|
+
if (tupledArg_1[0] === tupledArg[0]) {
|
|
381
|
+
return collides(tupledArg_1[1], tupledArg[1]);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
}, derived), choose(tryShape, baseMembers));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function isSameKind(a, b) {
|
|
390
|
+
let matchResult;
|
|
391
|
+
switch (a.tag) {
|
|
392
|
+
case 4: {
|
|
393
|
+
if (b.tag === 4) {
|
|
394
|
+
matchResult = 0;
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
matchResult = 1;
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
case 5: {
|
|
402
|
+
if (b.tag === 5) {
|
|
403
|
+
matchResult = 0;
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
matchResult = 1;
|
|
407
|
+
}
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
case 7: {
|
|
411
|
+
if (b.tag === 7) {
|
|
412
|
+
matchResult = 0;
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
matchResult = 1;
|
|
416
|
+
}
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
default:
|
|
420
|
+
matchResult = 1;
|
|
421
|
+
}
|
|
422
|
+
switch (matchResult) {
|
|
423
|
+
case 0:
|
|
424
|
+
return true;
|
|
425
|
+
default:
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* `class RecordService extends CrudService { getOne(id, options?: RecordOptions) }` has one
|
|
432
|
+
* `getOne` in TypeScript, the subclass takes the base heritage and the members it does not redeclare
|
|
433
|
+
*/
|
|
434
|
+
export function withoutRedeclaredBases(typeMemory, members, heritageClauses) {
|
|
435
|
+
const resolve = (visited, members_1, heritageClauses_1) => fold((tupledArg, heritageClause) => {
|
|
436
|
+
const members_2 = tupledArg[0];
|
|
437
|
+
const kept = tupledArg[1];
|
|
438
|
+
if (heritageClause.tag === 13) {
|
|
439
|
+
const typeReference = heritageClause.fields[0];
|
|
440
|
+
const key = (typeReference.FullName !== "") ? typeReference.FullName : typeReference.Name;
|
|
441
|
+
const matchValue = tryFindBase(typeMemory, typeReference);
|
|
442
|
+
let matchResult, baseDeclaration_1;
|
|
443
|
+
if (matchValue != null) {
|
|
444
|
+
if (!FSharpSet__Contains(visited, key)) {
|
|
445
|
+
matchResult = 0;
|
|
446
|
+
baseDeclaration_1 = matchValue;
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
matchResult = 1;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
matchResult = 1;
|
|
454
|
+
}
|
|
455
|
+
switch (matchResult) {
|
|
456
|
+
case 0: {
|
|
457
|
+
const substitutions = GlueSubstitution_ofTypeArguments(baseDeclaration_1.TypeParameters, typeReference.TypeArguments);
|
|
458
|
+
const baseMembers = map((glueMember) => GlueSubstitution_substituteMember(substitutions, glueMember), baseDeclaration_1.Members);
|
|
459
|
+
if (hasCollision(members_2, baseMembers)) {
|
|
460
|
+
const names = ofList_1(choose(memberName, members_2), {
|
|
461
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
462
|
+
});
|
|
463
|
+
const copied = filter((baseMember) => {
|
|
464
|
+
const matchValue_1 = memberName(baseMember);
|
|
465
|
+
if (matchValue_1 == null) {
|
|
466
|
+
return !exists((b) => isSameKind(baseMember, b), members_2);
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
return !FSharpSet__Contains(names, matchValue_1);
|
|
470
|
+
}
|
|
471
|
+
}, baseMembers);
|
|
472
|
+
const baseClauses = map((glueType) => GlueSubstitution_substitute(substitutions, glueType), baseDeclaration_1.HeritageClauses);
|
|
473
|
+
const patternInput = resolve(FSharpSet__Add(visited, key), append(members_2, copied), baseClauses);
|
|
474
|
+
return [patternInput[0], append(kept, patternInput[1])];
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
return [members_2, append(kept, singleton(heritageClause))];
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
default:
|
|
481
|
+
return [members_2, append(kept, singleton(heritageClause))];
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
return [members_2, append(kept, singleton(heritageClause))];
|
|
486
|
+
}
|
|
487
|
+
}, [members_1, empty()], heritageClauses_1);
|
|
488
|
+
const patternInput_1 = resolve(empty_1({
|
|
489
|
+
Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
|
|
490
|
+
}), members, heritageClauses);
|
|
491
|
+
return [patternInput_1[1], patternInput_1[0]];
|
|
492
|
+
}
|
|
493
|
+
|