@glutinum/cli 1.0.0-beta.3 → 1.0.0-beta.5
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/dist/Glutinum.Converter/Printer.js +11 -4
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +2 -2
- package/dist/Glutinum.Converter/Reader/TypeNode.js +13 -14
- package/dist/Glutinum.Converter/Reader/Utils.js +18 -3
- package/dist/Glutinum.Converter/Transform.js +260 -48
- package/dist/Glutinum.Converter/Transformer/Context.js +4 -6
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +217 -353
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { FSharpRef, Record } from "../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
3
|
-
import { Reporter__get_HasIterable, Reporter__get_HasReadonlyArray, Reporter__get_HasRegEpx, Reporter__get_Errors, Reporter__get_Warnings, TransformState_Create_Z68CEF8E2, TypeLiteralsMemory_$ctor, Reporter_$ctor, TransformContext__ToList, TransformContext_$ctor_Z1635F75A, TransformContext__get__Reporter, TransformContext__set_SiblingTypeNames_2FCB1351, TypeLiteralsMemory__LeaveModule, TypeLiteralsMemory__EnterModule_Z721C83C5, TransformContext__ExposeTypeAlias_1CE4A880, TransformContext__AddWarning_Z721C83C5, sanitizeTypeNameAndPushScope, ImportSource, importAllAttribute, TransformContext__get_TypeMemory, importAttribute, sanitizeMemberNameAndPushScope, TransformContext__get_ImportSource, importDefaultAttribute, TransformContext__AddError_Z721C83C5, TypeLiteralsMemory__Remember_74C8CBB, TransformContext__get_TypeLiteralsMemory, TransformContext__get_Root, TypeLiteralsMemory__TryReference_433E080, TransformContext__get_State,
|
|
3
|
+
import { Reporter__get_HasIterable, Reporter__get_HasReadonlyArray, Reporter__get_HasRegEpx, Reporter__get_Errors, Reporter__get_Warnings, TransformState_Create_Z68CEF8E2, TypeLiteralsMemory_$ctor, Reporter_$ctor, TransformContext__ToList, TransformContext_$ctor_Z1635F75A, TransformContext__get__Reporter, TransformContext__set_SiblingTypeNames_2FCB1351, TypeLiteralsMemory__LeaveModule, TypeLiteralsMemory__EnterModule_Z721C83C5, TransformContext__ExposeTypeAlias_1CE4A880, TransformContext__AddWarning_Z721C83C5, sanitizeTypeNameAndPushScope, ImportSource, importAllAttribute, TransformContext__get_TypeMemory, importAttribute, sanitizeMemberNameAndPushScope, TransformContext__get_ImportSource, importDefaultAttribute, TransformContext__AddError_Z721C83C5, TypeLiteralsMemory__Remember_74C8CBB, TransformContext__get_TypeLiteralsMemory, TransformContext__get_Root, TypeLiteralsMemory__TryReference_433E080, TransformContext__get_State, TransformContext__get_FullName, TransformContext__ExposeType_Z1D58A540, TransformContext__PushScope_27AED5E3, sanitizeNameAndPushScope, TransformContext__NewTypeName, TransformContext__get_CurrentScopeName, TransformContext__ExposeIterable, TransformContext__ReferenceName_Z721C83C5, TransformContext__get_OriginalScopeName, TransformContext__ExposeTypeAlias_Z721C83C5, TransformContext__ExposeReadonlyArray, ImportSource_$reflection, TransformContext_$reflection } from "./Transformer/Context.js";
|
|
4
4
|
import { int32_type, array_type, option_type, list_type, record_type, class_type, string_type, bool_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
|
|
5
5
|
import { FSharpModule, FSharpSingleErasedCaseUnion, FSharpJSApi, FSharpEnum, FSharpEnumCase, FSharpLiteral, FSharpTypeParameterInfo_Create_Z6CFD3565, FSharpUnionCaseNamed, FSharpClass, FSharpConstructor, FSharpExplicitField, FSharpStaticMemberInfo, FSharpAccessor, FSharpMemberInfoBody, FSharpAccessibility, FSharpMember, FSharpMemberInfo, FSharpParameter, FSharpThisType, FSharpPrimitive, FSharpTypeAlias, FSharpDelegate, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpTypeParameter, FSharpMapped, FSharpInterface, FSharpAttribute, FSharpType, FSharpType_$reflection, FSharpTypeParameter_$reflection, FSharpMember_$reflection } from "./FsharpAST.js";
|
|
6
6
|
import { GlueReExport, GlueClassDeclaration, GlueLiteral__ToText, GlueIndexSignature, GlueLiteral, GlueMember__TryGetAccessor, GlueMember__get_Documentation, GlueProperty, GlueAccessor, GlueMethod, GlueMethodSignature, GlueSubstitution_mentionedTypeParameters, GlueFunctionType, GlueParameter, GlueTypeUnion, GlueFunctionDeclaration, GlueVariable, GlueType__get_Name, GlueConstructor, GlueTypeReference, GluePrimitive, GlueType, GlueTypeLiteral, GlueMember, GlueTypeParameter, GlueSubstitution_substitute, GlueSubstitution_substituteParameter, GlueInterface, GlueTypeAliasDeclaration_$reflection, GlueType_$reflection } from "./GlueAST.js";
|
|
@@ -8,8 +8,8 @@ import { transformComment, TransformCommentResult_$reflection } from "./Transfor
|
|
|
8
8
|
import { add, contains as contains_2, union, empty as empty_2, ofSeq, singleton as singleton_2, ofList, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.17.2/Set.js";
|
|
9
9
|
import { aggregatedExports, replaceSelfReference, isUnitAlias, typedArrayNames, transformPrimitive, requiredBeforeParamArray, isDataObject, Interface_makePartial, tryUnwrapOption, iteratorNames } from "./Transformer/Utils.js";
|
|
10
10
|
import { value as value_7, unwrap, toArray, defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
11
|
-
import { zip, mapFold, item, concat as concat_1, reverse, iterate, cons, foldBack, fold, tryFind, ofSeq as ofSeq_1, forAll as forAll_1, sortBy, tryPick, truncate, exists, contains,
|
|
12
|
-
import { aliasArities, namedTypeParameters, membersNameUndeclaredTypeParameters, mentionsTypeParameter, ownTypeParameterDefaults, typeParameterNames as
|
|
11
|
+
import { zip, mapFold, item, concat as concat_1, reverse, iterate, cons, foldBack, fold, tryFind, ofSeq as ofSeq_1, forAll as forAll_1, sortBy, tryPick, truncate, exists, contains, partition, mapIndexed, filter, append, length, collect, tryLast, choose, tryHead, singleton, empty, ofArray, map, head as head_1, tail as tail_3, isEmpty } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
12
|
+
import { aliasArities, namedTypeParameters, membersNameUndeclaredTypeParameters, mentionsTypeParameter, ownTypeParameterDefaults, typeParameterNames as typeParameterNames_2, unconstrained, memberTypeParameterNames, typeArguments, declaredTypeParameters } from "./Transformer/TypeParameters.js";
|
|
13
13
|
import { List_groupBy, List_distinct } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
14
14
|
import { uncurry2, curry2, Lazy, structuralHash, Exception, numberHash, int32ToString, disposeSafe, getEnumerator, defaultOf, comparePrimitives, safeHash, equals, stringHash } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
15
15
|
import { replace, trim, printf, toFail, substring, interpolate, concat } from "../fable_modules/fable-library-js.5.17.2/String.js";
|
|
@@ -595,14 +595,23 @@ function UtilityType_readonlyInterface(context, members) {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
function UtilityType_readonlyUnion(context, interfaces) {
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
598
|
+
const isLarge = length(interfaces) > 9;
|
|
599
|
+
const name = isLarge ? TransformContext__NewTypeName(context) : (`U${length(interfaces)}`);
|
|
600
|
+
const caseContext = isLarge ? context : sanitizeNameAndPushScope(name, context)[1];
|
|
601
|
+
const caseTypes = map((glueInterface) => {
|
|
602
|
+
const context_1 = TransformContext__PushScope_27AED5E3(caseContext, concat("ReadOnly", glueInterface.Name));
|
|
603
|
+
const initialInterface = transformInterface(context_1, glueInterface);
|
|
602
604
|
const adaptedInterface = new FSharpInterface(initialInterface.Attributes, initialInterface.Name, initialInterface.XmlDoc, initialInterface.OriginalName, initialInterface.TypeParameters, TransformMembers_forceReadonly(initialInterface.Members), initialInterface.Inheritance);
|
|
603
|
-
TransformContext__ExposeType_Z1D58A540(
|
|
604
|
-
return new
|
|
605
|
-
}, interfaces)
|
|
605
|
+
TransformContext__ExposeType_Z1D58A540(context_1, new FSharpType(/* Interface */ 5, [new FSharpInterface(adaptedInterface.Attributes, TransformContext__get_CurrentScopeName(context_1), adaptedInterface.XmlDoc, adaptedInterface.OriginalName, adaptedInterface.TypeParameters, adaptedInterface.Members, adaptedInterface.Inheritance)]));
|
|
606
|
+
return new FSharpType(/* Interface */ 5, [new FSharpInterface(adaptedInterface.Attributes, TransformContext__get_FullName(context_1), adaptedInterface.XmlDoc, adaptedInterface.OriginalName, adaptedInterface.TypeParameters, adaptedInterface.Members, adaptedInterface.Inheritance)]);
|
|
607
|
+
}, interfaces);
|
|
608
|
+
if (isLarge) {
|
|
609
|
+
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Union */ 1, [erasedUnion(name, empty(), caseTypes)]));
|
|
610
|
+
return referenceToExposed(context, name, empty());
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
return new FSharpType(/* Union */ 1, [new FSharpUnion(empty(), name, map((Item_3) => (new FSharpUnionCase(/* Typed */ 1, [Item_3])), caseTypes), false, empty(), empty())]);
|
|
614
|
+
}
|
|
606
615
|
}
|
|
607
616
|
|
|
608
617
|
function UtilityType_transformReadOnlyInline(context, readonlyInfo) {
|
|
@@ -700,7 +709,7 @@ function UtilityType_transform(context, utilityType) {
|
|
|
700
709
|
return FSharpType.Object$;
|
|
701
710
|
case 2: {
|
|
702
711
|
const name_2 = TransformContext__NewTypeName(context);
|
|
703
|
-
const freeTypeParameterNames_1 = List_distinct(append(
|
|
712
|
+
const freeTypeParameterNames_1 = List_distinct(append(typeParameterNames_2(recordInfo.KeyType), typeParameterNames_2(recordInfo.ValueType)), {
|
|
704
713
|
Equals: (x_1, y_1) => (x_1 === y_1),
|
|
705
714
|
GetHashCode: (x_1) => (stringHash(x_1) | 0),
|
|
706
715
|
});
|
|
@@ -758,6 +767,15 @@ function $007CRememberedTypeLiteral$007C_$007C(context, glueType) {
|
|
|
758
767
|
}
|
|
759
768
|
}
|
|
760
769
|
|
|
770
|
+
function erasedUnion(name, typeParameters, caseTypes) {
|
|
771
|
+
return new FSharpUnion(ofArray([FSharpAttribute.RequireQualifiedAccess, FSharpAttribute.Erase]), name, mapIndexed((index, caseType) => (new FSharpUnionCase(/* Field */ 2, [`Case${index + 1}`, caseType])), caseTypes), false, typeParameters, empty());
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function referenceToExposed(context, name, typeParameterNames) {
|
|
775
|
+
const fullName = TransformContext__ReferenceName_Z721C83C5(context, name);
|
|
776
|
+
return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(fullName, fullName, empty(), map((Item) => (new FSharpType(/* TypeParameter */ 13, [Item])), typeParameterNames), FSharpType.Discard)]);
|
|
777
|
+
}
|
|
778
|
+
|
|
761
779
|
function transformUnionType(context, cases) {
|
|
762
780
|
let typ, unionInfo;
|
|
763
781
|
const patternInput = partition((glueType) => {
|
|
@@ -789,22 +807,16 @@ function transformUnionType(context, cases) {
|
|
|
789
807
|
return FSharpType.Object$;
|
|
790
808
|
}
|
|
791
809
|
}
|
|
792
|
-
else if (length(others) > 9) {
|
|
793
|
-
if (isOptional) {
|
|
794
|
-
return new FSharpType(/* Option */ 3, [FSharpType.Object$]);
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
return FSharpType.Object$;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
810
|
else if (length(others) === 1) {
|
|
801
811
|
return transformType(context, head_1(others));
|
|
802
812
|
}
|
|
803
813
|
else {
|
|
804
814
|
const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others);
|
|
805
815
|
if (matchValue == null) {
|
|
806
|
-
const
|
|
807
|
-
const
|
|
816
|
+
const isLarge = length(others) > 9;
|
|
817
|
+
const name_1 = isLarge ? TransformContext__NewTypeName(context) : (`U${length(others)}`);
|
|
818
|
+
const caseContext = isLarge ? context : sanitizeNameAndPushScope(name_1, context)[1];
|
|
819
|
+
const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(caseContext, `Case${index + 1}`), caseType), others), {
|
|
808
820
|
Equals: equals,
|
|
809
821
|
GetHashCode: (x_1) => (safeHash(x_1) | 0),
|
|
810
822
|
});
|
|
@@ -814,25 +826,45 @@ function transformUnionType(context, cases) {
|
|
|
814
826
|
matchResult = 0;
|
|
815
827
|
single = head_1(caseTypes);
|
|
816
828
|
}
|
|
817
|
-
else {
|
|
829
|
+
else if (isLarge) {
|
|
818
830
|
matchResult = 1;
|
|
819
831
|
}
|
|
832
|
+
else {
|
|
833
|
+
matchResult = 2;
|
|
834
|
+
}
|
|
820
835
|
}
|
|
821
|
-
else {
|
|
836
|
+
else if (isLarge) {
|
|
822
837
|
matchResult = 1;
|
|
823
838
|
}
|
|
839
|
+
else {
|
|
840
|
+
matchResult = 2;
|
|
841
|
+
}
|
|
824
842
|
switch (matchResult) {
|
|
825
843
|
case 0:
|
|
826
844
|
return single;
|
|
845
|
+
case 1: {
|
|
846
|
+
const typeParameterNames_1 = List_distinct(collect(typeParameterNames_2, others), {
|
|
847
|
+
Equals: (x_2, y_2) => (x_2 === y_2),
|
|
848
|
+
GetHashCode: (x_2) => (stringHash(x_2) | 0),
|
|
849
|
+
});
|
|
850
|
+
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(/* Union */ 1, [erasedUnion(name_1, declaredTypeParameters(typeParameterNames_1), caseTypes)]));
|
|
851
|
+
const reference = referenceToExposed(context, name_1, typeParameterNames_1);
|
|
852
|
+
if (isOptional) {
|
|
853
|
+
return new FSharpType(/* Option */ 3, [reference]);
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
return reference;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
827
859
|
default: {
|
|
828
|
-
const cases_1 = map((
|
|
860
|
+
const cases_1 = map((Item_1) => (new FSharpUnionCase(/* Typed */ 1, [Item_1])), caseTypes);
|
|
829
861
|
return new FSharpType(/* Union */ 1, [new FSharpUnion(empty(), `U${length(caseTypes)}`, cases_1, isOptional, empty(), empty())]);
|
|
830
862
|
}
|
|
831
863
|
}
|
|
832
864
|
}
|
|
833
865
|
else {
|
|
834
866
|
const name = TransformContext__NewTypeName(context);
|
|
835
|
-
const typeParameterNames = List_distinct(collect(
|
|
867
|
+
const typeParameterNames = List_distinct(collect(typeParameterNames_2, others), {
|
|
836
868
|
Equals: (x, y) => (x === y),
|
|
837
869
|
GetHashCode: (x) => (stringHash(x) | 0),
|
|
838
870
|
});
|
|
@@ -842,8 +874,7 @@ function transformUnionType(context, cases) {
|
|
|
842
874
|
if (option_3 != null) {
|
|
843
875
|
TransformContext__ExposeType_Z1D58A540(context, option_3);
|
|
844
876
|
}
|
|
845
|
-
|
|
846
|
-
return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(fullName, fullName, empty(), map((Item) => (new FSharpType(/* TypeParameter */ 13, [Item])), typeParameterNames), FSharpType.Discard)]);
|
|
877
|
+
return referenceToExposed(context, name, typeParameterNames);
|
|
847
878
|
}
|
|
848
879
|
}
|
|
849
880
|
}
|
|
@@ -954,7 +985,7 @@ function transformIntersectionOfReferences(context, references, members) {
|
|
|
954
985
|
return FSharpType.Object$;
|
|
955
986
|
}
|
|
956
987
|
else {
|
|
957
|
-
const typeParameterNames = List_distinct(collect(
|
|
988
|
+
const typeParameterNames = List_distinct(collect(typeParameterNames_2, references), {
|
|
958
989
|
Equals: (x, y) => (x === y),
|
|
959
990
|
GetHashCode: (x) => (stringHash(x) | 0),
|
|
960
991
|
});
|
|
@@ -988,7 +1019,7 @@ function transformMappedType(context, mappedType) {
|
|
|
988
1019
|
}
|
|
989
1020
|
else {
|
|
990
1021
|
const name = TransformContext__NewTypeName(context);
|
|
991
|
-
const freeTypeParameterNames = List_distinct(filter((typeParameterName) => (typeParameterName !== mappedType.TypeParameter.Name), defaultArg((option_1 = mappedType.Type, (option_1 != null) ?
|
|
1022
|
+
const freeTypeParameterNames = List_distinct(filter((typeParameterName) => (typeParameterName !== mappedType.TypeParameter.Name), defaultArg((option_1 = mappedType.Type, (option_1 != null) ? typeParameterNames_2(option_1) : undefined), empty())), {
|
|
992
1023
|
Equals: (x, y) => (x === y),
|
|
993
1024
|
GetHashCode: (x) => (stringHash(x) | 0),
|
|
994
1025
|
});
|
|
@@ -3959,7 +3990,8 @@ function TypeParameter_mapFSharpType(seadledTypes, typ) {
|
|
|
3959
3990
|
}
|
|
3960
3991
|
|
|
3961
3992
|
function TypeParameter_mapFsharpParameter(seadledTypes, parameter) {
|
|
3962
|
-
|
|
3993
|
+
const typ = TypeParameter_mapFSharpType(seadledTypes, parameter.Type);
|
|
3994
|
+
return new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, parameter.IsOptional ? defaultArg(tryUnwrapOption(typ), typ) : typ, parameter.OriginalGlueMember);
|
|
3963
3995
|
}
|
|
3964
3996
|
|
|
3965
3997
|
function transformTypeParameters(context, typeParameters) {
|
|
@@ -4759,27 +4791,46 @@ function aliasOfUnion(scope, cases, unionType) {
|
|
|
4759
4791
|
return false;
|
|
4760
4792
|
}
|
|
4761
4793
|
}, cases);
|
|
4762
|
-
let matchResult_1, single;
|
|
4794
|
+
let matchResult_1, single, others_3;
|
|
4763
4795
|
if (!isEmpty(matchValue_1[0])) {
|
|
4764
4796
|
if (!isEmpty(matchValue_1[1])) {
|
|
4765
4797
|
if (isEmpty(tail_3(matchValue_1[1]))) {
|
|
4766
4798
|
matchResult_1 = 0;
|
|
4767
4799
|
single = head_1(matchValue_1[1]);
|
|
4768
4800
|
}
|
|
4769
|
-
else {
|
|
4801
|
+
else if (length(matchValue_1[1]) > 9) {
|
|
4770
4802
|
matchResult_1 = 1;
|
|
4803
|
+
others_3 = matchValue_1[1];
|
|
4804
|
+
}
|
|
4805
|
+
else {
|
|
4806
|
+
matchResult_1 = 2;
|
|
4771
4807
|
}
|
|
4772
4808
|
}
|
|
4773
|
-
else {
|
|
4809
|
+
else if (length(matchValue_1[1]) > 9) {
|
|
4774
4810
|
matchResult_1 = 1;
|
|
4811
|
+
others_3 = matchValue_1[1];
|
|
4812
|
+
}
|
|
4813
|
+
else {
|
|
4814
|
+
matchResult_1 = 2;
|
|
4775
4815
|
}
|
|
4776
4816
|
}
|
|
4777
|
-
else {
|
|
4817
|
+
else if (length(matchValue_1[1]) > 9) {
|
|
4778
4818
|
matchResult_1 = 1;
|
|
4819
|
+
others_3 = matchValue_1[1];
|
|
4820
|
+
}
|
|
4821
|
+
else {
|
|
4822
|
+
matchResult_1 = 2;
|
|
4779
4823
|
}
|
|
4780
4824
|
switch (matchResult_1) {
|
|
4781
4825
|
case 0:
|
|
4782
4826
|
return aliasOf(scope, new FSharpType(/* Option */ 3, [transformType(TransformContext__PushScope_27AED5E3(context, "Value"), single)]));
|
|
4827
|
+
case 1: {
|
|
4828
|
+
const caseTypes = List_distinct(mapIndexed((index, caseType) => transformType(TransformContext__PushScope_27AED5E3(context, `Case${index + 1}`), caseType), others_3), {
|
|
4829
|
+
Equals: equals,
|
|
4830
|
+
GetHashCode: (x) => (safeHash(x) | 0),
|
|
4831
|
+
});
|
|
4832
|
+
return new FSharpType(/* Union */ 1, [erasedUnion(scope.Name, scope.TypeParameters.Value.TypeParameters, caseTypes)]);
|
|
4833
|
+
}
|
|
4783
4834
|
default:
|
|
4784
4835
|
return aliasOf(scope, transformType(context, unionType));
|
|
4785
4836
|
}
|
|
@@ -4943,7 +4994,7 @@ function aliasOfUtilityType(scope, utilityType) {
|
|
|
4943
4994
|
case 4: {
|
|
4944
4995
|
const typeParameters = scope.TypeParameters.Value.TypeParameters;
|
|
4945
4996
|
const candidate = new GlueInterface(scope.Declaration.Documentation, scope.Declaration.FullName, scope.Declaration.Name, members, scope.Declaration.TypeParameters, empty());
|
|
4946
|
-
const creates = isCandidate(
|
|
4997
|
+
const creates = isCandidate(TransformContext__get_TypeMemory(context), candidate) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), members) : empty();
|
|
4947
4998
|
return aliasInterfaceOf(scope, typeParameters, append(TransformMembers_toFSharpMember(context, members), creates), empty());
|
|
4948
4999
|
}
|
|
4949
5000
|
default:
|
|
@@ -4964,7 +5015,7 @@ function aliasOfTypeLiteral(scope, typeLiteralInfo) {
|
|
|
4964
5015
|
const context = scope.Context;
|
|
4965
5016
|
const typeParameters = scope.TypeParameters.Value.TypeParameters;
|
|
4966
5017
|
const candidate = new GlueInterface(scope.Declaration.Documentation, scope.Declaration.FullName, scope.Declaration.Name, typeLiteralInfo.Members, scope.Declaration.TypeParameters, empty());
|
|
4967
|
-
const creates = isCandidate(
|
|
5018
|
+
const creates = isCandidate(TransformContext__get_TypeMemory(context), candidate) ? paramObjectCreateMembers(context, new FSharpType(/* Mapped */ 7, [new FSharpMapped(scope.Name, typeParameters)]), typeLiteralInfo.Members) : empty();
|
|
4968
5019
|
return aliasInterfaceOf(scope, typeParameters, append(TransformMembers_toFSharpMember(context, typeLiteralInfo.Members), creates), ofArray(toArray(TypeLiteral_tryFindIterableType(context, typeLiteralInfo.Members))));
|
|
4969
5020
|
}
|
|
4970
5021
|
|
|
@@ -5534,7 +5585,7 @@ function transformToFsharp(context, glueTypes) {
|
|
|
5534
5585
|
break;
|
|
5535
5586
|
}
|
|
5536
5587
|
default:
|
|
5537
|
-
if (isCandidate(
|
|
5588
|
+
if (isCandidate(TransformContext__get_TypeMemory(context), _arg_1.fields[0])) {
|
|
5538
5589
|
matchResult = 0;
|
|
5539
5590
|
interfaceInfo_1 = _arg_1.fields[0];
|
|
5540
5591
|
}
|
|
@@ -5875,28 +5926,189 @@ function transform(typeMemory, state, reporter, typeLiteralsMemory, importSource
|
|
|
5875
5926
|
}, rest);
|
|
5876
5927
|
const exports_1 = (importSource.tag === 1) ? append(patternInput[0], append(classes, reExportedClasses)) : ((importSource.tag === 0) ? append(patternInput[0], append(classes, reExportedClasses)) : empty());
|
|
5877
5928
|
const rootTransformContext = TransformContext_$ctor_Z1635F75A(reporter, "", typeMemory, state, typeLiteralsMemory, importSource);
|
|
5878
|
-
|
|
5929
|
+
let typeTestAttributes;
|
|
5930
|
+
const classDeclarations = choose((_arg_3) => {
|
|
5931
|
+
let matchResult_6, info_12;
|
|
5932
|
+
switch (_arg_3.tag) {
|
|
5933
|
+
case 12: {
|
|
5934
|
+
matchResult_6 = 0;
|
|
5935
|
+
info_12 = _arg_3.fields[0];
|
|
5936
|
+
break;
|
|
5937
|
+
}
|
|
5938
|
+
case 25: {
|
|
5939
|
+
if (_arg_3.fields[0].tag === 12) {
|
|
5940
|
+
matchResult_6 = 0;
|
|
5941
|
+
info_12 = _arg_3.fields[0].fields[0];
|
|
5942
|
+
}
|
|
5943
|
+
else {
|
|
5944
|
+
matchResult_6 = 1;
|
|
5945
|
+
}
|
|
5946
|
+
break;
|
|
5947
|
+
}
|
|
5948
|
+
default:
|
|
5949
|
+
matchResult_6 = 1;
|
|
5950
|
+
}
|
|
5951
|
+
switch (matchResult_6) {
|
|
5952
|
+
case 0:
|
|
5953
|
+
return info_12;
|
|
5954
|
+
default:
|
|
5955
|
+
return undefined;
|
|
5956
|
+
}
|
|
5957
|
+
}, glueAst_2);
|
|
5958
|
+
const defaultExported = ofSeq(choose((_arg_4) => {
|
|
5959
|
+
let matchResult_7, info_14, name_8;
|
|
5960
|
+
if (_arg_4.tag === 25) {
|
|
5961
|
+
switch (_arg_4.fields[0].tag) {
|
|
5962
|
+
case 12: {
|
|
5963
|
+
matchResult_7 = 0;
|
|
5964
|
+
info_14 = _arg_4.fields[0].fields[0];
|
|
5965
|
+
break;
|
|
5966
|
+
}
|
|
5967
|
+
case 2: {
|
|
5968
|
+
if (exists((info_13) => (info_13.Name === _arg_4.fields[0].fields[0].Name), classDeclarations)) {
|
|
5969
|
+
matchResult_7 = 1;
|
|
5970
|
+
name_8 = _arg_4.fields[0].fields[0].Name;
|
|
5971
|
+
}
|
|
5972
|
+
else {
|
|
5973
|
+
matchResult_7 = 2;
|
|
5974
|
+
}
|
|
5975
|
+
break;
|
|
5976
|
+
}
|
|
5977
|
+
default:
|
|
5978
|
+
matchResult_7 = 2;
|
|
5979
|
+
}
|
|
5980
|
+
}
|
|
5981
|
+
else {
|
|
5982
|
+
matchResult_7 = 2;
|
|
5983
|
+
}
|
|
5984
|
+
switch (matchResult_7) {
|
|
5985
|
+
case 0:
|
|
5986
|
+
return info_14.Name;
|
|
5987
|
+
case 1:
|
|
5988
|
+
return name_8;
|
|
5989
|
+
default:
|
|
5990
|
+
return undefined;
|
|
5991
|
+
}
|
|
5992
|
+
}, glueAst_2), {
|
|
5993
|
+
Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
|
|
5994
|
+
});
|
|
5995
|
+
const classes_1 = ofSeq(map((_arg_5) => _arg_5.Name, filter((info_15) => {
|
|
5996
|
+
if (info_15.IsExported) {
|
|
5997
|
+
return true;
|
|
5998
|
+
}
|
|
5999
|
+
else {
|
|
6000
|
+
return equals(importSource, ImportSource.Global);
|
|
6001
|
+
}
|
|
6002
|
+
}, classDeclarations)), {
|
|
6003
|
+
Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
|
|
6004
|
+
});
|
|
6005
|
+
const constructorVariables = ofSeq(choose((_arg_6) => {
|
|
6006
|
+
let matchResult_8, name_10, members_1, name_11;
|
|
6007
|
+
if (_arg_6.tag === 2) {
|
|
6008
|
+
switch (_arg_6.fields[0].Type.tag) {
|
|
6009
|
+
case 29: {
|
|
6010
|
+
matchResult_8 = 0;
|
|
6011
|
+
name_10 = _arg_6.fields[0].Name;
|
|
6012
|
+
break;
|
|
6013
|
+
}
|
|
6014
|
+
case 22: {
|
|
6015
|
+
if (exists((_arg_7) => {
|
|
6016
|
+
if (_arg_7.tag === 7) {
|
|
6017
|
+
return true;
|
|
6018
|
+
}
|
|
6019
|
+
else {
|
|
6020
|
+
return false;
|
|
6021
|
+
}
|
|
6022
|
+
}, _arg_6.fields[0].Type.fields[0].Members)) {
|
|
6023
|
+
matchResult_8 = 1;
|
|
6024
|
+
members_1 = _arg_6.fields[0].Type.fields[0].Members;
|
|
6025
|
+
name_11 = _arg_6.fields[0].Name;
|
|
6026
|
+
}
|
|
6027
|
+
else {
|
|
6028
|
+
matchResult_8 = 2;
|
|
6029
|
+
}
|
|
6030
|
+
break;
|
|
6031
|
+
}
|
|
6032
|
+
default:
|
|
6033
|
+
matchResult_8 = 2;
|
|
6034
|
+
}
|
|
6035
|
+
}
|
|
6036
|
+
else {
|
|
6037
|
+
matchResult_8 = 2;
|
|
6038
|
+
}
|
|
6039
|
+
switch (matchResult_8) {
|
|
6040
|
+
case 0:
|
|
6041
|
+
return name_10;
|
|
6042
|
+
case 1:
|
|
6043
|
+
return name_11;
|
|
6044
|
+
default:
|
|
6045
|
+
return undefined;
|
|
6046
|
+
}
|
|
6047
|
+
}, glueAst_2), {
|
|
6048
|
+
Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
|
|
6049
|
+
});
|
|
6050
|
+
typeTestAttributes = ((name_12) => (!isTopLevel ? empty() : (FSharpSet__Contains(defaultExported, name_12) ? importDefaultAttribute(name_12, importSource) : ((FSharpSet__Contains(classes_1, name_12) ? true : FSharpSet__Contains(constructorVariables, name_12)) ? importAttribute(name_12, importSource) : empty()))));
|
|
6051
|
+
const rest_1 = map((_arg_9) => {
|
|
6052
|
+
let matchResult_9, info_17, fsharpType;
|
|
6053
|
+
if (_arg_9.tag === 5) {
|
|
6054
|
+
if (!exists((_arg_8) => {
|
|
6055
|
+
switch (_arg_8.tag) {
|
|
6056
|
+
case 3:
|
|
6057
|
+
case 5:
|
|
6058
|
+
case 4:
|
|
6059
|
+
case 21:
|
|
6060
|
+
return true;
|
|
6061
|
+
default:
|
|
6062
|
+
return false;
|
|
6063
|
+
}
|
|
6064
|
+
}, _arg_9.fields[0].Attributes)) {
|
|
6065
|
+
matchResult_9 = 0;
|
|
6066
|
+
info_17 = _arg_9.fields[0];
|
|
6067
|
+
}
|
|
6068
|
+
else {
|
|
6069
|
+
matchResult_9 = 1;
|
|
6070
|
+
fsharpType = _arg_9;
|
|
6071
|
+
}
|
|
6072
|
+
}
|
|
6073
|
+
else {
|
|
6074
|
+
matchResult_9 = 1;
|
|
6075
|
+
fsharpType = _arg_9;
|
|
6076
|
+
}
|
|
6077
|
+
switch (matchResult_9) {
|
|
6078
|
+
case 0: {
|
|
6079
|
+
const matchValue_1 = typeTestAttributes(info_17.OriginalName);
|
|
6080
|
+
if (isEmpty(matchValue_1)) {
|
|
6081
|
+
return new FSharpType(/* Interface */ 5, [info_17]);
|
|
6082
|
+
}
|
|
6083
|
+
else {
|
|
6084
|
+
return new FSharpType(/* Interface */ 5, [new FSharpInterface(append(info_17.Attributes, matchValue_1), info_17.Name, info_17.XmlDoc, info_17.OriginalName, info_17.TypeParameters, info_17.Members, info_17.Inheritance)]);
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
default:
|
|
6088
|
+
return fsharpType;
|
|
6089
|
+
}
|
|
6090
|
+
}, transformToFsharp(rootTransformContext, rest));
|
|
5879
6091
|
let exportsType_1;
|
|
5880
6092
|
if (isEmpty(exports_1)) {
|
|
5881
6093
|
exportsType_1 = undefined;
|
|
5882
6094
|
}
|
|
5883
6095
|
else {
|
|
5884
|
-
const
|
|
5885
|
-
let
|
|
5886
|
-
if (
|
|
5887
|
-
if (isEmpty(
|
|
5888
|
-
|
|
6096
|
+
const matchValue_2 = transformExports(rootTransformContext, isTopLevel, exports_1);
|
|
6097
|
+
let matchResult_10, exportsType;
|
|
6098
|
+
if (matchValue_2.tag === 5) {
|
|
6099
|
+
if (isEmpty(matchValue_2.fields[0].Members)) {
|
|
6100
|
+
matchResult_10 = 0;
|
|
5889
6101
|
}
|
|
5890
6102
|
else {
|
|
5891
|
-
|
|
5892
|
-
exportsType =
|
|
6103
|
+
matchResult_10 = 1;
|
|
6104
|
+
exportsType = matchValue_2;
|
|
5893
6105
|
}
|
|
5894
6106
|
}
|
|
5895
6107
|
else {
|
|
5896
|
-
|
|
5897
|
-
exportsType =
|
|
6108
|
+
matchResult_10 = 1;
|
|
6109
|
+
exportsType = matchValue_2;
|
|
5898
6110
|
}
|
|
5899
|
-
switch (
|
|
6111
|
+
switch (matchResult_10) {
|
|
5900
6112
|
case 0: {
|
|
5901
6113
|
exportsType_1 = undefined;
|
|
5902
6114
|
break;
|
|
@@ -6,8 +6,7 @@ import { isEmpty, empty, singleton, contains, map } from "../../fable_modules/fa
|
|
|
6
6
|
import { FSharpModule, FSharpTypeAlias, FSharpEnum, FSharpUnion, FSharpDelegate, FSharpClass, FSharpInterface, FSharpAttribute, FSharpMember, FSharpMemberInfo, FSharpType } from "../FsharpAST.js";
|
|
7
7
|
import { Union, FSharpRef, Record } from "../../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
8
8
|
import { create, State_$reflection } from "./Conditionals.js";
|
|
9
|
-
import { create as create_1, State_$reflection as State_$reflection_1 } from "./
|
|
10
|
-
import { create as create_2, State_$reflection as State_$reflection_2 } from "./KeyOfMaps.js";
|
|
9
|
+
import { create as create_1, State_$reflection as State_$reflection_1 } from "./KeyOfMaps.js";
|
|
11
10
|
import { getItemFromDict, tryGetValue } from "../../fable_modules/fable-library-js.5.17.2/MapUtil.js";
|
|
12
11
|
import { collect, append, delay, toList, tryFindIndex } from "../../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
13
12
|
import { setItem } from "../../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
@@ -165,10 +164,9 @@ export function typeName(typ) {
|
|
|
165
164
|
* The indexes of the run over the type memory, and the declarations being expanded
|
|
166
165
|
*/
|
|
167
166
|
export class TransformState extends Record {
|
|
168
|
-
constructor(Conditionals,
|
|
167
|
+
constructor(Conditionals, KeyOfMaps, PartialHeritageBeingExpanded, MaxOverloads) {
|
|
169
168
|
super();
|
|
170
169
|
this.Conditionals = Conditionals;
|
|
171
|
-
this.ParamObjects = ParamObjects;
|
|
172
170
|
this.KeyOfMaps = KeyOfMaps;
|
|
173
171
|
this.PartialHeritageBeingExpanded = PartialHeritageBeingExpanded;
|
|
174
172
|
this.MaxOverloads = (MaxOverloads | 0);
|
|
@@ -176,11 +174,11 @@ export class TransformState extends Record {
|
|
|
176
174
|
}
|
|
177
175
|
|
|
178
176
|
export function TransformState_$reflection() {
|
|
179
|
-
return record_type("Glutinum.Converter.Transformer.Context.TransformState", [], TransformState, () => [["Conditionals", State_$reflection()], ["
|
|
177
|
+
return record_type("Glutinum.Converter.Transformer.Context.TransformState", [], TransformState, () => [["Conditionals", State_$reflection()], ["KeyOfMaps", State_$reflection_1()], ["PartialHeritageBeingExpanded", array_type(string_type)], ["MaxOverloads", int32_type]]);
|
|
180
178
|
}
|
|
181
179
|
|
|
182
180
|
export function TransformState_Create_Z68CEF8E2(typeMemory, maxOverloads) {
|
|
183
|
-
return new TransformState(create(typeMemory), create_1(typeMemory),
|
|
181
|
+
return new TransformState(create(typeMemory), create_1(typeMemory), [], maxOverloads);
|
|
184
182
|
}
|
|
185
183
|
|
|
186
184
|
/**
|