@glutinum/cli 1.0.0-beta.2 → 1.0.0-beta.3
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 +9 -32
- package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
- package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
- package/dist/Glutinum.Converter/FsharpAST.js +116 -65
- package/dist/Glutinum.Converter/Generate.js +34 -21
- package/dist/Glutinum.Converter/GlueAST.js +79 -41
- package/dist/Glutinum.Converter/Hosting.js +132 -157
- package/dist/Glutinum.Converter/Merge.js +369 -337
- package/dist/Glutinum.Converter/Packages.js +391 -92
- package/dist/Glutinum.Converter/Printer.js +396 -423
- package/dist/Glutinum.Converter/Read.js +387 -88
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
- package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
- package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
- package/dist/Glutinum.Converter/Reader/Node.js +8 -11
- package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
- package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
- package/dist/Glutinum.Converter/Reader/Types.js +290 -15
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
- package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +3568 -8456
- 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 +1149 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -0
- package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
- package/dist/Glutinum.Converter/Utils/String.js +14 -3
- package/dist/Program.js +18 -10
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import { toString, Union, Record } from "../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
3
|
-
import { float64_type, int32_type, bool_type, union_type, list_type, record_type, option_type, string_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
|
|
4
|
-
import { append, singleton, map, collect, empty } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
5
|
-
import { stringHash, int32ToString } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
3
|
+
import { class_type, float64_type, int32_type, bool_type, union_type, list_type, record_type, option_type, string_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
|
|
4
|
+
import { tryItem, mapIndexed, append, singleton, map, collect, empty } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
5
|
+
import { comparePrimitives, stringHash, int32ToString } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
6
6
|
import { join, concat } from "../fable_modules/fable-library-js.5.17.2/String.js";
|
|
7
|
-
import { tryFind } from "../fable_modules/fable-library-js.5.17.2/Map.js";
|
|
7
|
+
import { map as map_1, ofList, tryFind } from "../fable_modules/fable-library-js.5.17.2/Map.js";
|
|
8
8
|
import { List_distinctBy } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
9
|
+
import { orElse, defaultArg } from "../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
9
10
|
|
|
10
11
|
export class GlueCommentParam extends Record {
|
|
11
12
|
constructor(Name, Content) {
|
|
@@ -182,18 +183,19 @@ export function GlueIndexSignature_$reflection() {
|
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
export class GlueMethodSignature extends Record {
|
|
185
|
-
constructor(Name, Documentation, TypeParameters, Parameters, Type) {
|
|
186
|
+
constructor(Name, Documentation, TypeParameters, Parameters, Type, IsOptional) {
|
|
186
187
|
super();
|
|
187
188
|
this.Name = Name;
|
|
188
189
|
this.Documentation = Documentation;
|
|
189
190
|
this.TypeParameters = TypeParameters;
|
|
190
191
|
this.Parameters = Parameters;
|
|
191
192
|
this.Type = Type;
|
|
193
|
+
this.IsOptional = IsOptional;
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
export function GlueMethodSignature_$reflection() {
|
|
196
|
-
return record_type("Glutinum.Converter.GlueAST.GlueMethodSignature", [], GlueMethodSignature, () => [["Name", string_type], ["Documentation", list_type(GlueComment_$reflection())], ["TypeParameters", list_type(GlueTypeParameter_$reflection())], ["Parameters", list_type(GlueParameter_$reflection())], ["Type", GlueType_$reflection()]]);
|
|
198
|
+
return record_type("Glutinum.Converter.GlueAST.GlueMethodSignature", [], GlueMethodSignature, () => [["Name", string_type], ["Documentation", list_type(GlueComment_$reflection())], ["TypeParameters", list_type(GlueTypeParameter_$reflection())], ["Parameters", list_type(GlueParameter_$reflection())], ["Type", GlueType_$reflection()], ["IsOptional", bool_type]]);
|
|
197
199
|
}
|
|
198
200
|
|
|
199
201
|
export class GlueConstructSignature extends Record {
|
|
@@ -440,21 +442,6 @@ export function GlueTypeUnion_$reflection() {
|
|
|
440
442
|
return union_type("Glutinum.Converter.GlueAST.GlueTypeUnion", [], GlueTypeUnion, () => [[["Item", list_type(GlueType_$reflection())]]]);
|
|
441
443
|
}
|
|
442
444
|
|
|
443
|
-
export class ExcludedMember extends Union {
|
|
444
|
-
constructor(Item) {
|
|
445
|
-
super();
|
|
446
|
-
this.tag = 0;
|
|
447
|
-
this.fields = [Item];
|
|
448
|
-
}
|
|
449
|
-
cases() {
|
|
450
|
-
return ["Literal"];
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
export function ExcludedMember_$reflection() {
|
|
455
|
-
return union_type("Glutinum.Converter.GlueAST.ExcludedMember", [], ExcludedMember, () => [[["Item", GlueLiteral_$reflection()]]]);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
445
|
export class GlueFunctionType extends Record {
|
|
459
446
|
constructor(Documentation, Type, TypeParameters, OwnTypeParameterNames, Parameters) {
|
|
460
447
|
super();
|
|
@@ -516,12 +503,12 @@ export class GlueUtilityType extends Union {
|
|
|
516
503
|
this.fields = fields;
|
|
517
504
|
}
|
|
518
505
|
cases() {
|
|
519
|
-
return ["Partial", "Record", "ReturnType", "ThisParameterType", "Omit", "Readonly"];
|
|
506
|
+
return ["Partial", "Record", "ReturnType", "ThisParameterType", "Omit", "Pick", "Readonly"];
|
|
520
507
|
}
|
|
521
508
|
}
|
|
522
509
|
|
|
523
510
|
export function GlueUtilityType_$reflection() {
|
|
524
|
-
return union_type("Glutinum.Converter.GlueAST.GlueUtilityType", [], GlueUtilityType, () => [[["Item", GlueInterface_$reflection()]], [["Item", GlueRecord_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", list_type(GlueMember_$reflection())]], [["Item", GlueReadonly_$reflection()]]]);
|
|
511
|
+
return union_type("Glutinum.Converter.GlueAST.GlueUtilityType", [], GlueUtilityType, () => [[["Item", GlueInterface_$reflection()]], [["Item", GlueRecord_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", list_type(GlueMember_$reflection())]], [["Item", list_type(GlueMember_$reflection())]], [["Item", GlueReadonly_$reflection()]]]);
|
|
525
512
|
}
|
|
526
513
|
|
|
527
514
|
export class GlueMappedType extends Record {
|
|
@@ -575,14 +562,15 @@ export class GlueType extends Union {
|
|
|
575
562
|
}
|
|
576
563
|
|
|
577
564
|
export function GlueType_$reflection() {
|
|
578
|
-
return union_type("Glutinum.Converter.GlueAST.GlueType", [], GlueType, () => [[], [["Item", GlueInterface_$reflection()]], [["Item", GlueVariable_$reflection()]], [["Item", GluePrimitive_$reflection()]], [["Item", GlueEnum_$reflection()]], [["Item", GlueTypeAliasDeclaration_$reflection()]], [["Item", GlueFunctionDeclaration_$reflection()]], [["Item", GlueTypeUnion_$reflection()]], [["Item", GlueLiteral_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueIndexedAccessType_$reflection()]], [["Item", GlueModuleDeclaration_$reflection()]], [["Item", GlueClassDeclaration_$reflection()]], [["Item", GlueTypeReference_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueFunctionType_$reflection()]], [["Item", string_type]], [["Item", GlueThisType_$reflection()]], [["Item", list_type(GlueType_$reflection())]], [["Item", NamedTupleType_$reflection()]], [["Item", list_type(GlueMember_$reflection())]], [["
|
|
565
|
+
return union_type("Glutinum.Converter.GlueAST.GlueType", [], GlueType, () => [[], [["Item", GlueInterface_$reflection()]], [["Item", GlueVariable_$reflection()]], [["Item", GluePrimitive_$reflection()]], [["Item", GlueEnum_$reflection()]], [["Item", GlueTypeAliasDeclaration_$reflection()]], [["Item", GlueFunctionDeclaration_$reflection()]], [["Item", GlueTypeUnion_$reflection()]], [["Item", GlueLiteral_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueIndexedAccessType_$reflection()]], [["Item", GlueModuleDeclaration_$reflection()]], [["Item", GlueClassDeclaration_$reflection()]], [["Item", GlueTypeReference_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueFunctionType_$reflection()]], [["Item", string_type]], [["Item", GlueThisType_$reflection()]], [["Item", list_type(GlueType_$reflection())]], [["Item", NamedTupleType_$reflection()]], [["Item", list_type(GlueMember_$reflection())]], [["references", list_type(GlueType_$reflection())], ["members", list_type(GlueMember_$reflection())]], [["Item", GlueTypeLiteral_$reflection()]], [["Item", GlueType_$reflection()]], [], [["Item", GlueType_$reflection()]], [], [["Item", GlueUtilityType_$reflection()]], [["Item", GlueMappedType_$reflection()]], [["Item", GlueConstructSignature_$reflection()]], [["Item", GlueType_$reflection()]], [["Item", GlueFileModule_$reflection()]], [["Item", GlueReExport_$reflection()]], [["Item", GlueConditionalType_$reflection()]]]);
|
|
579
566
|
}
|
|
580
567
|
|
|
581
568
|
export class GlueFileModule extends Record {
|
|
582
|
-
constructor(Name, ImportSpecifier, IsGlobal, HasRuntime, Types) {
|
|
569
|
+
constructor(Name, ImportSpecifier, SymbolSpecifiers, IsGlobal, HasRuntime, Types) {
|
|
583
570
|
super();
|
|
584
571
|
this.Name = Name;
|
|
585
572
|
this.ImportSpecifier = ImportSpecifier;
|
|
573
|
+
this.SymbolSpecifiers = SymbolSpecifiers;
|
|
586
574
|
this.IsGlobal = IsGlobal;
|
|
587
575
|
this.HasRuntime = HasRuntime;
|
|
588
576
|
this.Types = Types;
|
|
@@ -590,21 +578,22 @@ export class GlueFileModule extends Record {
|
|
|
590
578
|
}
|
|
591
579
|
|
|
592
580
|
export function GlueFileModule_$reflection() {
|
|
593
|
-
return record_type("Glutinum.Converter.GlueAST.GlueFileModule", [], GlueFileModule, () => [["Name", string_type], ["ImportSpecifier", string_type], ["IsGlobal", bool_type], ["HasRuntime", bool_type], ["Types", list_type(GlueType_$reflection())]]);
|
|
581
|
+
return record_type("Glutinum.Converter.GlueAST.GlueFileModule", [], GlueFileModule, () => [["Name", string_type], ["ImportSpecifier", string_type], ["SymbolSpecifiers", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, string_type])], ["IsGlobal", bool_type], ["HasRuntime", bool_type], ["Types", list_type(GlueType_$reflection())]]);
|
|
594
582
|
}
|
|
595
583
|
|
|
596
584
|
export class GlueConditionalType extends Record {
|
|
597
|
-
constructor(CheckType, ExtendsType, TrueType, FalseType) {
|
|
585
|
+
constructor(CheckType, ExtendsType, TrueType, FalseType, Inferred) {
|
|
598
586
|
super();
|
|
599
587
|
this.CheckType = CheckType;
|
|
600
588
|
this.ExtendsType = ExtendsType;
|
|
601
589
|
this.TrueType = TrueType;
|
|
602
590
|
this.FalseType = FalseType;
|
|
591
|
+
this.Inferred = Inferred;
|
|
603
592
|
}
|
|
604
593
|
}
|
|
605
594
|
|
|
606
595
|
export function GlueConditionalType_$reflection() {
|
|
607
|
-
return record_type("Glutinum.Converter.GlueAST.GlueConditionalType", [], GlueConditionalType, () => [["CheckType", GlueType_$reflection()], ["ExtendsType", GlueType_$reflection()], ["TrueType", GlueType_$reflection()], ["FalseType", GlueType_$reflection()]]);
|
|
596
|
+
return record_type("Glutinum.Converter.GlueAST.GlueConditionalType", [], GlueConditionalType, () => [["CheckType", GlueType_$reflection()], ["ExtendsType", GlueType_$reflection()], ["TrueType", GlueType_$reflection()], ["FalseType", GlueType_$reflection()], ["Inferred", list_type(GlueTypeParameter_$reflection())]]);
|
|
608
597
|
}
|
|
609
598
|
|
|
610
599
|
export class GlueReExport extends Record {
|
|
@@ -693,24 +682,63 @@ export function GlueLiteral__ToText(this$) {
|
|
|
693
682
|
}
|
|
694
683
|
|
|
695
684
|
export function GlueUtilityType__get_TypeParameters(this$) {
|
|
685
|
+
let matchResult, info, returnType, thisType, members, members_1, interfaces;
|
|
696
686
|
switch (this$.tag) {
|
|
687
|
+
case 1: {
|
|
688
|
+
matchResult = 1;
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
case 2: {
|
|
692
|
+
matchResult = 2;
|
|
693
|
+
returnType = this$.fields[0];
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
case 3: {
|
|
697
|
+
matchResult = 3;
|
|
698
|
+
thisType = this$.fields[0];
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
case 4: {
|
|
702
|
+
matchResult = 4;
|
|
703
|
+
members = this$.fields[0];
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
case 5: {
|
|
707
|
+
matchResult = 4;
|
|
708
|
+
members = this$.fields[0];
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
case 6: {
|
|
712
|
+
if (this$.fields[0].tag === 1) {
|
|
713
|
+
matchResult = 6;
|
|
714
|
+
interfaces = this$.fields[0].fields[0];
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
matchResult = 5;
|
|
718
|
+
members_1 = this$.fields[0].fields[0];
|
|
719
|
+
}
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
default: {
|
|
723
|
+
matchResult = 0;
|
|
724
|
+
info = this$.fields[0];
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
switch (matchResult) {
|
|
728
|
+
case 0:
|
|
729
|
+
return info.TypeParameters;
|
|
697
730
|
case 1:
|
|
698
731
|
return empty();
|
|
699
732
|
case 2:
|
|
700
|
-
return GlueType__get_TypeParameters(
|
|
733
|
+
return GlueType__get_TypeParameters(returnType);
|
|
701
734
|
case 3:
|
|
702
|
-
return GlueType__get_TypeParameters(
|
|
735
|
+
return GlueType__get_TypeParameters(thisType);
|
|
703
736
|
case 4:
|
|
704
|
-
return collect(GlueMember__get_TypeParameters,
|
|
737
|
+
return collect(GlueMember__get_TypeParameters, members);
|
|
705
738
|
case 5:
|
|
706
|
-
|
|
707
|
-
return collect((interfaceInfo) => interfaceInfo.TypeParameters, this$.fields[0].fields[0]);
|
|
708
|
-
}
|
|
709
|
-
else {
|
|
710
|
-
return collect(GlueMember__get_TypeParameters, this$.fields[0].fields[0]);
|
|
711
|
-
}
|
|
739
|
+
return collect(GlueMember__get_TypeParameters, members_1);
|
|
712
740
|
default:
|
|
713
|
-
return
|
|
741
|
+
return collect((interfaceInfo) => interfaceInfo.TypeParameters, interfaces);
|
|
714
742
|
}
|
|
715
743
|
}
|
|
716
744
|
|
|
@@ -1015,7 +1043,7 @@ export function GlueSubstitution_substitute(substitutions, glueType) {
|
|
|
1015
1043
|
}
|
|
1016
1044
|
case 33: {
|
|
1017
1045
|
const conditionalType = glueType.fields[0];
|
|
1018
|
-
return new GlueType(/* ConditionalType */ 33, [new GlueConditionalType(substitute(conditionalType.CheckType), substitute(conditionalType.ExtendsType), substitute(conditionalType.TrueType), substitute(conditionalType.FalseType))]);
|
|
1046
|
+
return new GlueType(/* ConditionalType */ 33, [new GlueConditionalType(substitute(conditionalType.CheckType), substitute(conditionalType.ExtendsType), substitute(conditionalType.TrueType), substitute(conditionalType.FalseType), conditionalType.Inferred)]);
|
|
1019
1047
|
}
|
|
1020
1048
|
case 9:
|
|
1021
1049
|
return new GlueType(/* KeyOf */ 9, [substitute(glueType.fields[0])]);
|
|
@@ -1026,7 +1054,7 @@ export function GlueSubstitution_substitute(substitutions, glueType) {
|
|
|
1026
1054
|
case 20:
|
|
1027
1055
|
return new GlueType(/* IntersectionType */ 20, [map((glueMember) => GlueSubstitution_substituteMember(substitutions, glueMember), glueType.fields[0])]);
|
|
1028
1056
|
case 21:
|
|
1029
|
-
return new GlueType(/* IntersectionOfReferences */ 21, [map(substitute, glueType.fields[0])]);
|
|
1057
|
+
return new GlueType(/* IntersectionOfReferences */ 21, [map(substitute, glueType.fields[0]), glueType.fields[1]]);
|
|
1030
1058
|
case 22: {
|
|
1031
1059
|
const typeLiteral = glueType.fields[0];
|
|
1032
1060
|
return new GlueType(/* TypeLiteral */ 22, [new GlueTypeLiteral(map((glueMember_1) => GlueSubstitution_substituteMember(substitutions, glueMember_1), typeLiteral.Members), typeLiteral.Id)]);
|
|
@@ -1050,7 +1078,7 @@ export function GlueSubstitution_substituteMember(substitutions, glueMember) {
|
|
|
1050
1078
|
}
|
|
1051
1079
|
case 6: {
|
|
1052
1080
|
const info_2 = glueMember.fields[0];
|
|
1053
|
-
return new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(info_2.Name, info_2.Documentation, info_2.TypeParameters, parameters(info_2.Parameters), substitute(info_2.Type))]);
|
|
1081
|
+
return new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(info_2.Name, info_2.Documentation, info_2.TypeParameters, parameters(info_2.Parameters), substitute(info_2.Type), info_2.IsOptional)]);
|
|
1054
1082
|
}
|
|
1055
1083
|
case 2: {
|
|
1056
1084
|
const info_3 = glueMember.fields[0];
|
|
@@ -1079,3 +1107,13 @@ export function GlueSubstitution_substituteMember(substitutions, glueMember) {
|
|
|
1079
1107
|
}
|
|
1080
1108
|
}
|
|
1081
1109
|
|
|
1110
|
+
/**
|
|
1111
|
+
* The type arguments of a reference by the name of the type parameters they stand for
|
|
1112
|
+
*/
|
|
1113
|
+
export function GlueSubstitution_ofTypeArguments(typeParameters, typeArguments) {
|
|
1114
|
+
const substitutions = ofList(mapIndexed((index, typeParameter) => [typeParameter.Name, defaultArg(orElse(tryItem(index, typeArguments), typeParameter.Default), new GlueType(/* Primitive */ 3, [GluePrimitive.Any]))], typeParameters), {
|
|
1115
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
1116
|
+
});
|
|
1117
|
+
return map_1((_arg, argument_1) => GlueSubstitution_substitute(substitutions, argument_1), substitutions);
|
|
1118
|
+
}
|
|
1119
|
+
|