@glutinum/cli 0.3.1 → 0.4.0
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 +102 -1
- package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +5 -4
- package/dist/Glutinum.Converter/Reader/EnumDeclaration.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +2 -1
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/NamedDeclaration.js +3 -1
- package/dist/Glutinum.Converter/Reader/NamedDeclaration.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/Node.js +4 -2
- package/dist/Glutinum.Converter/Reader/Node.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/TypeNode.js +4 -3
- package/dist/Glutinum.Converter/Reader/TypeNode.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +6 -4
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +3 -3
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/Utils.js +9 -0
- package/dist/Glutinum.Converter/Reader/Utils.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -1
- package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,104 @@
|
|
|
1
|
-
# Glutinum.
|
|
1
|
+
# Glutinum.CLI
|
|
2
2
|
|
|
3
3
|
This is a compiler from `.d.ts` to F# bindings for [Fable](https://fable.io/).
|
|
4
|
+
|
|
5
|
+
## Contributing
|
|
6
|
+
|
|
7
|
+
Glutinum.CLI use `./build.sh` or `./build.bat` as a build script.
|
|
8
|
+
|
|
9
|
+
You can see the available options by running:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
./build.sh --help
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
When using the test command, you can focus on a specific by forwarding arguments to the `ava`:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Focus all tests containing "class"
|
|
19
|
+
./build.sh test --watch -- --match="**class**"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If you need to run a local version of `@glutinum/cli`, you can use `./build.sh cli [--watch]` and then run `node cli.js <args>`.
|
|
23
|
+
|
|
24
|
+
### Debugging
|
|
25
|
+
|
|
26
|
+
If you use VSCode, you can run the build script/commands from the `JavaScript Debug Terminal`. This allows you to have access to the debugger, breakpoints, etc. (it works from the F# files too).
|
|
27
|
+
|
|
28
|
+
## Architecture
|
|
29
|
+
|
|
30
|
+
### Glutinum.Converter.CLI
|
|
31
|
+
|
|
32
|
+
CLI tool which uses `Glutinum.Converter` to handle the conversion.
|
|
33
|
+
|
|
34
|
+
### Glutinum.Converter
|
|
35
|
+
|
|
36
|
+
This is the heart of the project. It contains the logic to convert `.d.ts` to F# bindings.
|
|
37
|
+
|
|
38
|
+
From a macro view, it does the following:
|
|
39
|
+
|
|
40
|
+
1. Read the TypeScript AST and transform it into GlueAST
|
|
41
|
+
2. Transform the GlueAST to FsharpAST
|
|
42
|
+
3. Print the F# code from FsharpAST
|
|
43
|
+
|
|
44
|
+
#### GlueAST
|
|
45
|
+
|
|
46
|
+
GlueAST philosophy is to follow the TypeScript AST naming convention as much as possible. Its goal is to provide an easier to use AST than the TypeScript one thanks to F# type system (mainly thanks to discriminated unions).
|
|
47
|
+
|
|
48
|
+
#### FsharpAST
|
|
49
|
+
|
|
50
|
+
FsharpAST provides a more idiomatic F# AST but also contains Fable specific information.
|
|
51
|
+
|
|
52
|
+
For example, `FSharpAttribute` doesn't just map to `string` but also Fable/Glutinum specific syntax.
|
|
53
|
+
|
|
54
|
+
```fs
|
|
55
|
+
[<RequireQualifiedAccess>]
|
|
56
|
+
type FSharpAttribute =
|
|
57
|
+
| Text of string
|
|
58
|
+
/// <summary>
|
|
59
|
+
/// Generates <c>[<Emit("$0($1...)")>]</c> attribute.
|
|
60
|
+
/// </summary>
|
|
61
|
+
| EmitSelfInvoke
|
|
62
|
+
| Import of string * string
|
|
63
|
+
| ImportAll of string
|
|
64
|
+
| Erase
|
|
65
|
+
| AllowNullLiteral
|
|
66
|
+
| StringEnum of Fable.Core.CaseRules
|
|
67
|
+
| CompiledName of string
|
|
68
|
+
| RequireQualifiedAccess
|
|
69
|
+
| EmitConstructor
|
|
70
|
+
| EmitMacroConstructor of className: string
|
|
71
|
+
| EmitIndexer
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Tests
|
|
75
|
+
|
|
76
|
+
Tests are generated based on the `tests/specs/` folder content.
|
|
77
|
+
|
|
78
|
+
Each `.d.ts` correspond to a test and should have a matching `.fsx` file, the name of the test is the relative path to the `tests/specs/` folder without the `.d.ts` extension.
|
|
79
|
+
|
|
80
|
+
For example, if you have a file `tests/specs/exports/variable.d.ts`, you should have a `tests/specs/exports/variable.fsx`.
|
|
81
|
+
|
|
82
|
+
The name of the test is `exports/variable`.
|
|
83
|
+
|
|
84
|
+
> If you are using VSCode, the `fsx` file will be nested under the `d.ts` file in your explorer.
|
|
85
|
+
|
|
86
|
+
The `.fsx` correspond to the expected result suffixed with the following:
|
|
87
|
+
|
|
88
|
+
```fs
|
|
89
|
+
|
|
90
|
+
(***)
|
|
91
|
+
#r "nuget: Fable.Core"
|
|
92
|
+
(***)
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
> This allows us to have IDE support in the `.fsx` file instead of having a lot of syntax errors.
|
|
97
|
+
|
|
98
|
+
## Tools
|
|
99
|
+
|
|
100
|
+
One handy tool when working on the TypeScript AST is [TypeScript AST Viewer](https://ts-ast-viewer.com/).
|
|
101
|
+
|
|
102
|
+
It allows you to have a visual representation of the AST.
|
|
103
|
+
|
|
104
|
+
> Make sure to use the same version of TypeScript as the one used by Glutinum.CLI (found in the `package.json` file). Otherwise, you might have some differences especially in the values of the `kind` property.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tryReadLiteral } from "./Utils.js";
|
|
1
|
+
import { generateReaderError, tryReadLiteral } from "./Utils.js";
|
|
2
2
|
import { GlueEnum, GlueEnumMember, GlueLiteral } from "../GlueAST.js";
|
|
3
3
|
import { fold, ofSeq, empty, singleton, append } from "../../fable_modules/fable-library.4.5.0/List.js";
|
|
4
4
|
import { uncurry2 } from "../../fable_modules/fable-library.4.5.0/Util.js";
|
|
@@ -8,9 +8,10 @@ function readEnumMembers(checker, state, enumMember) {
|
|
|
8
8
|
let caseValue;
|
|
9
9
|
const matchValue = enumMember.initializer;
|
|
10
10
|
if (matchValue != null) {
|
|
11
|
-
const
|
|
11
|
+
const initializer = matchValue;
|
|
12
|
+
const matchValue_2 = tryReadLiteral(initializer);
|
|
12
13
|
if (matchValue_2 == null) {
|
|
13
|
-
throw new Error("readEnumCases: Unsupported enum initializer");
|
|
14
|
+
throw new Error(generateReaderError("enum member", "readEnumCases: Unsupported enum initializer", initializer));
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
16
17
|
const glueLiteral = matchValue_2;
|
|
@@ -41,7 +42,7 @@ function readEnumMembers(checker, state, enumMember) {
|
|
|
41
42
|
break;
|
|
42
43
|
}
|
|
43
44
|
default:
|
|
44
|
-
throw new Error("Boolean literals are not supported in enums");
|
|
45
|
+
throw new Error(generateReaderError("enum member", "Boolean literals are not supported in enums", initializer));
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/EnumDeclaration.fs"],"names":["num","str","caseValue","matchValue","enumMember","glueLiteral","value","checker","state","name","NextCaseIndex","initialState","readEnumResults","list","enumDeclaration","reader","readEnumMembers"],"mappings":";;;;;;QAyB4BA,KADAC;AAJpBC;AACMC,uBAAA,AAAAC;AAAA,QAAA,AAAAD;
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/EnumDeclaration.fs"],"names":["num","str","caseValue","matchValue","enumMember","initializer","glueLiteral","value","checker","state","name","NextCaseIndex","initialState","readEnumResults","list","enumDeclaration","reader","readEnumMembers"],"mappings":";;;;;;QAyB4BA,KADAC;AAJpBC;AACMC,uBAAA,AAAAC;AAAA,QAAA,AAAAD;AAUCE,4BACGF;AAAAA,6BAAA,eAAeE;AAAf,YAAA,AAAAF;AAeF,4BACI,oBACI,eACA,\u002BCACAE;;;AAlBLC,gCACGH;6BAGmBI;oBAHnBD;;;AAGmBC,4BAHnBD;;;;;AAGmBC,4BAHnBD;;;;;;;;;AAGmBC,4BAHnBD;;;;;AAddJ,gCAiB0CK;;;;AAE9B,oCACI,oBACI,eACA,\u002BCACAF;;;;;AApBVF,6BAAA,AAAAK,yBAA4BJ;AAA5B,AAHVF,qBAGU,CAAA,AAAAC,yBAOI,oBAAgB,AAAAM,0BAPpB,CAAA,OACJN,\u002BBACcH,MADdG,cAEE,AAAG,qBAAkCH,QACjC,sBAAoBA,UAEpB,oBAAkBA,aALVC,MAAdE,cAAsB,oBAAmBF;;AA8B/CS,iBAA4B,AAAAN;AAWlBO,2BAAA,CAAA,AAAAT,wBAKiB,AAAAA,sBAAI,MAGpB,AAAAO,sBAAsB;;iBACvB,OAAA,AAAAA,eAAgB,UAjB1B,mBACW,AAAAC,gBACCR;uBAMFS;;;;;QA0BIH;AATdI;iBAGc;uBADM;;AAIpBC;AAGGC,iBADA,MADH,AAAAC;AAEG,AAHHF,sBAGG,eAAWL,UAAgB,AAAAQ,sGAAhB,AAAAC,gBAAAT,SAAAC,OAAAL,gBAAXQ,cAAAE;AAEP,WAAA,aACW,AAAAC,gCACG,AAAAF","file":null,"sourcesContent":null,"sourceRoot":null}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { exists } from "../../fable_modules/fable-library.4.5.0/Seq.js";
|
|
2
|
+
import { generateReaderError } from "./Utils.js";
|
|
2
3
|
import { GlueFunctionDeclaration } from "../GlueAST.js";
|
|
3
4
|
|
|
4
5
|
export function readFunctionDeclaration(reader, declaration) {
|
|
5
6
|
let matchValue, matchValue_1, name;
|
|
6
7
|
return new GlueFunctionDeclaration((matchValue = declaration.modifiers, (matchValue == null) ? false : exists((modifier) => (modifier.kind === 138), matchValue)), (matchValue_1 = declaration.name, (matchValue_1 == null) ? (() => {
|
|
7
|
-
throw new Error("
|
|
8
|
+
throw new Error(generateReaderError("function declaration", "Missing name", declaration));
|
|
8
9
|
})() : ((name = matchValue_1, name.getText()))), reader["Glutinum.Converter.Reader.Types.TypeScriptReader.ReadTypeNodeZ64B23DD2"](declaration.type), reader["Glutinum.Converter.Reader.Types.TypeScriptReader.ReadParametersZ17143B5B"](declaration.parameters), reader["Glutinum.Converter.Reader.Types.TypeScriptReader.ReadTypeParameters4088FB9E"](declaration.typeParameters));
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/FunctionDeclaration.fs"],"names":["matchValue","name","declaration","modifier","reader"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/FunctionDeclaration.fs"],"names":["matchValue","name","declaration","modifier","reader"],"mappings":";;;;;QAccA,YASAA,cACCC;WASX,6BAnBUD,aAAA,AAAAE,uBAAA,CAAA,AAAAF,sBAMI,QAHH,sBACC,AAAAG,kBAAgB,MAFpBH,eAOEA,eAAA,AAAAE,kBAAA,CAAA,AAAAF;AAGF,wBACI,oBACI,wBACA,gBACAE;aANLD,OAAQD,cAAA,AAAAC,mBAYR,AAAAG,iFAAoB,AAAAF,mBACd,AAAAE,mFAAsB,AAAAF,yBAClB,AAAAE,sFAA0B,AAAAF","file":null,"sourcesContent":null,"sourceRoot":null}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { GlueIndexSignature, GlueCallSignature, GlueMethod, GlueMember, GlueProperty, GlueAccessor } from "../GlueAST.js";
|
|
2
2
|
import { exists } from "../../fable_modules/fable-library.4.5.0/Seq.js";
|
|
3
3
|
import { map, defaultArg } from "../../fable_modules/fable-library.4.5.0/Option.js";
|
|
4
|
+
import { generateReaderError } from "./Utils.js";
|
|
5
|
+
import { interpolate, toText } from "../../fable_modules/fable-library.4.5.0/String.js";
|
|
4
6
|
|
|
5
7
|
export function readNamedDeclaration(reader, declaration) {
|
|
6
8
|
const matchValue = declaration.kind | 0;
|
|
@@ -27,7 +29,7 @@ export function readNamedDeclaration(reader, declaration) {
|
|
|
27
29
|
return new GlueMember(3, [new GlueIndexSignature(reader["Glutinum.Converter.Reader.Types.TypeScriptReader.ReadParametersZ17143B5B"](indexSignature.parameters), reader["Glutinum.Converter.Reader.Types.TypeScriptReader.ReadTypeNodeZ64B23DD2"](indexSignature.type))]);
|
|
28
30
|
}
|
|
29
31
|
default:
|
|
30
|
-
throw new Error(
|
|
32
|
+
throw new Error(generateReaderError("named declaration", toText(interpolate("Unsupported kind %A%P()", [declaration.kind])), declaration));
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/NamedDeclaration.fs"],"names":["matchValue","declaration","propertySignature","name","accessor","modifier","reader","methodDeclaration","modifiers","callSignature","indexSignature"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/NamedDeclaration.fs"],"names":["matchValue","declaration","propertySignature","name","accessor","modifier","reader","methodDeclaration","modifiers","callSignature","indexSignature"],"mappings":";;;;;;;AAYUA,uBAAA,AAAAC;YAAAD;aAAA;AAGEE,sCAAoBD;AACpBE,yBAAsB,AAAAD;AAEtBE;AACMJ,iCAAA,AAAAE;AAAA,AADNE,wBACM,CAAA,AAAAJ,yBASI,4BAHH,AAHA,sBACC,AAAAK,kBAAgB,MAFpBL,iBAKc,4BACC;AASpB,mBAAA,mBANH,iBACW,AAAAG,gBACA,AAAAG,iFAAoB,AAAAJ,yBAChB,OACAE;;aAtBb;AAqCEG,sCAAoBN;AACpBE,2BAA4B,AAAAI;AAiB7B,mBAAA,mBAfH,eACW,AAAAJ,kBACM,AAAAG,mFAAsB,AAAAC,\u002BBAC5B,AAAAD,iFAAoB,AAAAC,yBACd,AAAAA,yCASN,WANA,qBAEI,wBACC,AAAAF,oBAAgB,MAFpBG,cAFJ,AAAAD,8BAOuB;;aArD7B;AA2BEE,kCAAgBR;AAOjB,mBAAA,mBALF,sBACgB,AAAAK,mFAAsB,AAAAG,2BAC5B,AAAAH,iFAAoB,AAAAG;;aA/B7B;AA0DEC,mCAAiBT;AAOlB,mBAAA,mBALF,uBACgB,AAAAK,mFAAsB,AAAAI,4BAC5B,AAAAJ,iFAAyB,AAAAI;;;AAMpC,4BACI,oBACI,qBACA,OAAA,YAAA,4BAAsB,AAAAT,qBACtBA","file":null,"sourcesContent":null,"sourceRoot":null}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generateReaderError } from "./Utils.js";
|
|
2
|
+
import { printf, toConsole, interpolate, toText } from "../../fable_modules/fable-library.4.5.0/String.js";
|
|
2
3
|
import { GlueType } from "../GlueAST.js";
|
|
3
4
|
|
|
4
5
|
export function readNode(reader, node) {
|
|
@@ -19,7 +20,8 @@ export function readNode(reader, node) {
|
|
|
19
20
|
case 267:
|
|
20
21
|
return reader["Glutinum.Converter.Reader.Types.TypeScriptReader.ReadModuleDeclarationC29C54F"](node);
|
|
21
22
|
default: {
|
|
22
|
-
|
|
23
|
+
const arg = generateReaderError("node", toText(interpolate("Unsupported node kind %A%P()", [matchValue])), node);
|
|
24
|
+
toConsole(printf("%s"))(arg);
|
|
23
25
|
return new GlueType(0, []);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/Node.fs"],"names":["matchValue","node","reader"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/Node.fs"],"names":["matchValue","node","reader","arg10"],"mappings":";;;;;AAOUA,uBAAA,AAAAC;YAAAD;aAAA;AAWF,mBAAA,AAAAE,0FAA6BD;aAX3B;AAcF,mBAAA,AAAAC,4FAA\u002BBD;aAd7B;AAoBF,mBAAA,AAAAC,yFAA4BD;aApB1B;AAQF,mBAAA,AAAAC,4FAAgCD;aAR9B;AAKF,mBAAA,AAAAC,6FAAgCD;aAL9B;AAEF,mBAAA,AAAAC,uFAA2BD;aAFzB;AAiBF,mBAAA,AAAAC,wFAA6BD;;AAM7BE,wBAEK,oBACG,QACA,OAAA,YAAA,iCAJRH,eAKQC;AALR,sBACI,OAAA,OADJE;AAOA,mBAAA","file":null,"sourcesContent":null,"sourceRoot":null}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GlueClassDeclaration, GlueFunctionType, GlueTypeReference, GlueInterface, GlueTypeUnion, GlueLiteral, GlueType, GluePrimitive } from "../GlueAST.js";
|
|
2
|
+
import { $007CHasSymbolFlags$007C_$007C, $007CHasTypeFlags$007C_$007C, generateReaderError } from "./Utils.js";
|
|
2
3
|
import { empty, map, choose } from "../../fable_modules/fable-library.4.5.0/List.js";
|
|
3
|
-
import { $007CHasSymbolFlags$007C_$007C, $007CHasTypeFlags$007C_$007C } from "./Utils.js";
|
|
4
4
|
import { head, toList } from "../../fable_modules/fable-library.4.5.0/Seq.js";
|
|
5
5
|
import { value as value_2 } from "../../fable_modules/fable-library.4.5.0/Option.js";
|
|
6
|
+
import { interpolate, toText } from "../../fable_modules/fable-library.4.5.0/String.js";
|
|
6
7
|
|
|
7
8
|
export function readTypeNode(reader, typeNode) {
|
|
8
9
|
const checker = reader["Glutinum.Converter.Reader.Types.TypeScriptReader.get_checker"]();
|
|
@@ -33,7 +34,7 @@ export function readTypeNode(reader, typeNode) {
|
|
|
33
34
|
fullName = checker.getFullyQualifiedName(symbol);
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
|
-
throw new Error("
|
|
37
|
+
throw new Error(generateReaderError("type node", "Missing symbol", typeReferenceNode));
|
|
37
38
|
}
|
|
38
39
|
switch (fullName) {
|
|
39
40
|
case "Exclude": {
|
|
@@ -120,7 +121,7 @@ export function readTypeNode(reader, typeNode) {
|
|
|
120
121
|
case 192:
|
|
121
122
|
return reader["Glutinum.Converter.Reader.Types.TypeScriptReader.ReadUnionTypeNodeZ5A082EC2"](typeNode);
|
|
122
123
|
default:
|
|
123
|
-
throw new Error(
|
|
124
|
+
throw new Error(generateReaderError("type node", toText(interpolate("Unsupported kind %A%P()", [typeNode.kind])), typeNode));
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/TypeNode.fs"],"names":["checker","reader","matchValue","typeNode","typeReferenceNode","symbolOpt","fullName","symbol","typ","literalType","aliasTypeArguments","patternInput","originalType","interfaceDeclaration","members","declaration","typeArguments","functionTypeNode","typeNodeQuery","arrayTypeNode"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/TypeNode.fs"],"names":["checker","reader","matchValue","typeNode","typeReferenceNode","symbolOpt","fullName","symbol","typ","literalType","aliasTypeArguments","patternInput","originalType","interfaceDeclaration","members","declaration","typeArguments","functionTypeNode","typeNodeQuery","arrayTypeNode"],"mappings":";;;;;;;;AAUQA,oBAAU,AAAAC;AAERC,uBAAA,AAAAC;YAAAD;aAAA;AAMyB,mBAAA,iBAAmB;aAN5C;AAGyB,mBAAA,iBAAmB;aAH5C;AAKwB,mBAAA,iBAAmB;aAL3C;AAI4B,mBAAA,iBAAmB;aAJ/C;AAC2B,mBAAA,iBAAmB;aAD9C;AAE2B,mBAAA,iBAAmB;aAF9C;AAQF,mBAAA,iBAAmB;aARjB;AA6I2B,mBAAA,iBAAmB;aA7I9C;AAaEE,sCAAoBD;AAEpBE,8BAAY,AAAAL,4BAA8B,AAAAI;AAE1CE;AACM,gBAAA,AAAAD;AAQCE,\u002BBAAUF;AAAA,AATjBC,2BASiB,AAAAN,8BAA8BO;;;AAN3C,gCACI,oBACI,aACA,kBACAH;;oBAMbE;qBAAW;AACNE,gCACA,AAAAR,4BAA4BI;AAgCN,2BAAA,iBAAjB,kBA1BF;AACOF,6CAAA,AAAAM;AACJ,4BADI,AACJ,6BAAa,KADTN;AAEEO,gDAAcD;AAIU,mCAAA,iBAA5B,oBAF0B,AAAAC;;6BAG5B,IAPI,AAOJ,6BAAa,KAPTP;AAQEO,kDAAcD;AAaT,mCAAA,iBAVL,AACI,qBACI,AAAAC,wBAEJ,oBAA2B,AAAAA,0BAE3B,oBACiB,AAAAA;;;AAItB,mCAAA;;uBAxBR,OADH,AAAAD;;qBA8BW;AACXA,kCAAM,AAAAR,4BAA4BI;AAOhCF,yCAAA,AAAAM;AAAA,wBAAA,AAAAN;AAECQ,mDACHR;AAAA,4BAAG,AAAAQ,8BAA4B;AAC3B,mCAAA;;;AAEIH,6CAAS,AAAAG,mBAAoB;AAEjC,gCAAG,AAAAH;AACC,uCAAA;;;AAIII,qDACmC,KAAnC,QAAA,AAAAJ;AAEAK,qDACA,QAAA,AAJA,AAAAD,8BAI6B;AAE3B,oCAAA,AAAAC,sBAAA;AAEEC,iEACAD;AAEAE,oDAGG,qBAAS,AAAAb,wFAAAc,cADT,OADH,AAAAF;AAUD,2CAAA,kBANF,kBACU,AAAAA,qCACGC,SACO;;;AAKlB,2CAAA;;;;;;AApCT,\u002BBAAA;;;;AAwCJZ,yCAAA,QAAAG;AACJ,wBADI,AACJ,\u002BBAAe,QADXH;AAEsB,\u002BBAAA,kBAAxB,QAAAG;;;AAEIW;AACMd,6CAAA,AAAAE;AAAA,AADNY,2CACM,CAAA,AAAAd,wBAKC,aAAkB,AAAAD,uFADlB,OADHC,iBAFM;AAWX,\u002BBAAA,kBALF,sBACU,AAAAE,sCACIE,UACKU;;;;;aAlI1B;AAgJEC,qCAAmBd;AAMpB,mBAAA,kBAJH,qBACW,AAAAF,gFAAoB,AAAAgB,wBACd,AAAAhB,mFAAsB,AAAAgB;;aApJrC;AAyJEC,kCAAgBf;AAEhBK,0BAAM,AAAAR,0BAA0BkB;AAE9BhB,iCAAA,AAAAM;AACJ,gBADI,AACJ,\u002BBAAe,IADXN;AAQC,uBAAA,kBANH,yBACW,AAAAM,mBACQ,SACL,SACO;;;AAGlB,uBAAA,iBAAmB;;;aAtKxB;AAuIEW,kCAAgBhB;AAIpB,mBAAA,kBAFkB,AAAAF,gFAAoB,AAAAkB;;aAzIpC;AAUF,mBAAA,AAAAlB,sFAAyBE;;AA\u002BJzB,4BACI,oBACI,aACA,OAAA,YAAA,4BAAsB,AAAAA,kBACtBA","file":null,"sourcesContent":null,"sourceRoot":null}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import typescript from "typescript";
|
|
2
|
+
import { generateReaderError } from "./Utils.js";
|
|
2
3
|
import { GlueType } from "../GlueAST.js";
|
|
4
|
+
import { interpolate, toText } from "../../fable_modules/fable-library.4.5.0/String.js";
|
|
3
5
|
|
|
4
6
|
export function readTypeOperatorNode(reader, node) {
|
|
5
7
|
if (node.operator === 143) {
|
|
@@ -10,7 +12,7 @@ export function readTypeOperatorNode(reader, node) {
|
|
|
10
12
|
const symbol = symbolOpt;
|
|
11
13
|
const matchValue_1 = symbol.declarations;
|
|
12
14
|
if (matchValue_1 == null) {
|
|
13
|
-
throw new Error("
|
|
15
|
+
throw new Error(generateReaderError("type operator (keyof)", "Missing declarations", node));
|
|
14
16
|
}
|
|
15
17
|
else {
|
|
16
18
|
const declarations = matchValue_1;
|
|
@@ -19,15 +21,15 @@ export function readTypeOperatorNode(reader, node) {
|
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
else {
|
|
22
|
-
throw new Error("
|
|
24
|
+
throw new Error(generateReaderError("type operator (keyof)", "Missing symbol", node));
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
26
|
-
throw new Error("
|
|
28
|
+
throw new Error(generateReaderError("type operator (keyof)", toText(interpolate("Was expecting a type reference instead got a Node of type %A%P()", [node.type.kind])), node));
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
else {
|
|
30
|
-
throw new Error(
|
|
32
|
+
throw new Error(generateReaderError("type operator", toText(interpolate("Unsupported operator %A%P()", [node.operator])), node));
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/TypeOperatorNode.fs"],"names":["node","typeReferenceNode","symbolOpt","reader","symbol","matchValue","declarations","interfaceDeclaration"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/TypeOperatorNode.fs"],"names":["node","typeReferenceNode","symbolOpt","reader","symbol","matchValue","declarations","interfaceDeclaration"],"mappings":";;;;;;AAYU,QAAA,AAAAA,kBAAA;AAEF,YAAG,\u002BBAAuB,AAAAA;AAClBC,sCAAoB,AAAAD;AAGpBE,8BACA,AAAAC,6FAAqC,AAAAF;AAEnC,gBAAA,AAAAC;AASCE,\u002BBACGF;AAAAG,qCAAA,AAAAD;AAAA,oBAAA,AAAAC;AASF,oCACI,oBACI,yBACA,wBACAL;;;AAZLM,yCACCD;AAAAE,iDACA,AAAAD,aAAa;AAGd,2BAAA,iBADH,AAAAH,4FAAgCI;;;;AAbpC,gCACI,oBACI,yBACA,kBACAP;;;;AAqBZ,4BACI,oBACI,yBACA,OAAA,YAAA,qEAA\u002BD,AAAAA,mBAC/DA;;;;AAIZ,wBACI,oBACI,iBACA,OAAA,YAAA,gCAA0B,AAAAA,kBAC1BA","file":null,"sourcesContent":null,"sourceRoot":null}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import typescript from "typescript";
|
|
2
2
|
import { map, empty, singleton, choose, concat } from "../../fable_modules/fable-library.4.5.0/List.js";
|
|
3
3
|
import { defaultArgWith } from "../../fable_modules/fable-library.4.5.0/Option.js";
|
|
4
|
-
import { $007CHasTypeFlags$007C_$007C, tryReadLiteral } from "./Utils.js";
|
|
4
|
+
import { $007CHasTypeFlags$007C_$007C, generateReaderError, tryReadLiteral } from "./Utils.js";
|
|
5
5
|
import { GlueTypeUnion, GlueTypeReference, GluePrimitive, GlueType } from "../GlueAST.js";
|
|
6
6
|
import { toList } from "../../fable_modules/fable-library.4.5.0/Seq.js";
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ function readUnionTypeCases(reader, unionTypeNode) {
|
|
|
45
45
|
else if (typescript.isTypeReferenceNode(node_1)) {
|
|
46
46
|
const typeReferenceNode = node_1;
|
|
47
47
|
const symbol = defaultArgWith(checker.getSymbolAtLocation(typeReferenceNode.typeName), () => {
|
|
48
|
-
throw new Error("
|
|
48
|
+
throw new Error(generateReaderError("union type cases", "Missing symbol", typeReferenceNode));
|
|
49
49
|
});
|
|
50
50
|
const matchValue_1 = symbol.declarations;
|
|
51
51
|
if (matchValue_1 == null) {
|
|
@@ -55,7 +55,7 @@ function readUnionTypeCases(reader, unionTypeNode) {
|
|
|
55
55
|
return singleton(new GlueType(3, [new GluePrimitive(6, [])]));
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
throw new Error("
|
|
58
|
+
throw new Error(generateReaderError("union type cases", "Unsupported type reference reach a point where it was expected to have flags like Any", typeReferenceNode));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/UnionTypeNode.fs"],"names":["checker","reader","removeParenthesizedType","node","parenthesizedTypeNode","literalTypeNode","literalExpression","matchValue","typeReferenceNode","symbol","typ","declarations","fullName","declaration","readUnionTypeCases","unionTypeNode"],"mappings":";;;;;;;;AAaQA,oBAAU,AAAAC;AAMNC;;;kBAAyBC;AAC7B,gBAAG,mCAA2BA;AACtBC,8CAAwBD;2BAGJ,AAAAC;AAAxB;;;uBAEAD;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/UnionTypeNode.fs"],"names":["checker","reader","removeParenthesizedType","node","parenthesizedTypeNode","literalTypeNode","literalExpression","matchValue","typeReferenceNode","symbol","typ","declarations","fullName","declaration","readUnionTypeCases","unionTypeNode"],"mappings":";;;;;;;;AAaQA,oBAAU,AAAAC;AAMNC;;;kBAAyBC;AAC7B,gBAAG,mCAA2BA;AACtBC,8CAAwBD;2BAGJ,AAAAC;AAAxB;;;uBAEAD;;;;;AAqHL,WAAA,kBADA,OA9GA;AACC,YAAG,6BAAqBA;AAChBE,oCAAkBF;AAElBG,sCAC4B,AAAAD;AAEhC,gBACI,2BAAmBC,qBAAnB,OACG,4BAAoBA;AAOR,uBAAA,UADZ,iBAHA,eADH,eAAeA;AAEX,oCAAS;;;;AAMPC,mCAAA,AAAAD;wBAAAC;yBAAA;yBAAA;AAIC,\u002BBAAA,UADH,iBAAmB;;AAGhB,\u002BBAAA;;;;aACV,IAAG,\u002BBAAuBJ;AACvBK,sCAAoBL;AAOpBM,2BACA,eAHA,AAAAT,4BAA8B,AAAAQ;AAKtB,gCACI,oBACI,oBACA,kBACAA;;AAOdD,iCAAA,AAAAE;AAAA,gBAAA,AAAAF;AAqBEG,4BAAM,AAAAV,wBAAwBS;AAE5BF,qCAAA,AAAAG;AACJ,oBADI,AACJ,6BAAa,GADTH;AAGC,2BAAA,UADH,iBAAmB;;;AAInB,oCACI,oBACI,oBACA,yFACAC;;;;AAhCTG,qCACHJ;AAAA,oBAAG,AAAAI,wBAAqB;AACpB,2BAAA;;qBACC,IAAG,AAAAA,sBAAqB;AACrBC,qCAAW,AAAAZ,8BAA8BS;AAQ1C,2BAAA,UADA,kBALF,sBACU,AAAAD,6BACII,UACK;;;AAMhBC,wCAAc,AAAAF,aAAc;AAED,2BAAA,UAA/B,AAAAV,4EAAgBY;;;;aA8BlB,IAAA,AAAAV,gBAAA;AAIE,mBAAA,AACA,AAAAW,mBAAmBb,QAHHE;;;AASjB,mBAAA,UADH,AAAAF,gFAAoBE;;OA3G7B,IAASD,yBAFT,OADH,AAAAa;;;;WA0H2C,iBAA3C,AAAAD,mBAAmBb,QAAOc","file":null,"sourcesContent":null,"sourceRoot":null}
|
|
@@ -3,6 +3,7 @@ import { tryParse } from "../../fable_modules/fable-library.4.5.0/Int32.js";
|
|
|
3
3
|
import { FSharpRef } from "../../fable_modules/fable-library.4.5.0/Types.js";
|
|
4
4
|
import { GlueLiteral } from "../GlueAST.js";
|
|
5
5
|
import { tryParse as tryParse_1 } from "../../fable_modules/fable-library.4.5.0/Double.js";
|
|
6
|
+
import { interpolate, toText } from "../../fable_modules/fable-library.4.5.0/String.js";
|
|
6
7
|
|
|
7
8
|
export function $007CHasTypeFlags$007C_$007C(flag, flags) {
|
|
8
9
|
if ((flags & flag) !== 0) {
|
|
@@ -76,4 +77,12 @@ export function tryReadLiteral(expression) {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
export function generateReaderError(errorContext, reason, node) {
|
|
81
|
+
const sourceFile = node.getSourceFile();
|
|
82
|
+
const lineAndChar = sourceFile.getLineAndCharacterOfPosition(node.pos);
|
|
83
|
+
const line = (~~lineAndChar.line + 1) | 0;
|
|
84
|
+
const column = (~~lineAndChar.character + 1) | 0;
|
|
85
|
+
return toText(interpolate("Error while reading %s%P() in\n%s%P()(%d%P(),%d%P())\n\n%s%P()\n\n--- Text ---\n%s%P()\n---\n\n--- Parent text ---\n%s%P()\n---", [errorContext, sourceFile.fileName, line, column, reason, node.getFullText(), node.parent.getFullText()]));
|
|
86
|
+
}
|
|
87
|
+
|
|
79
88
|
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/Utils.fs"],"names":["flags","flag","text","isNumericString","matchValue","outArg","expression","literal","tryReadNumericLiteral"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/Utils.fs"],"names":["flags","flag","text","isNumericString","matchValue","outArg","expression","literal","tryReadNumericLiteral","sourceFile","node","lineAndChar","line","column","errorContext","reason"],"mappings":";;;;;;;;AAQI,QAAG,CAAA,AAAIA,QAAcC,UAAQ;AACzB,eAAA,KAAI;;;AAEJ,eAAA;;;;;AAGJ,QAAG,CAAA,AAAID,QAAcC,UAAQ;AACzB,eAAA,KAAI;;;AAEJ,eAAA;;;;;AAGJ,QAAA,CAAA,OAASC,UAAO;AAAuD,eAAA,CAA7B,aAARA;;;eAAlC;;;;;AAGA,QAAG,AAAAC,gBAAgBD;AAETE;AAAAC;AAAAD,sBAAA,SAAsBF,sBAAtB,oBAAAG;AAAAA;aAAAA;AAAA,YAAA,AAAAD;AACS,mBAAA,oBAAA,AAAAA;;;AAGLA;AAAAC;AAAAD,4BAAA,WAAuBF,MAAvB,oBAAAG;AAAAA;iBAAAA;AAAA,gBAAA,AAAAD;AACS,uBAAA,oBAAA,AAAAA;;;AACR,uBAAA;;;;;AAEX,eAAA;;;;;AAGEA,uBAAA,AAAAE;YAAAF;aAAA;AAEEG,4BAAWD;AAEf,mBAAA,oBAAmB,AAAAC;;aAJjB;AAM0B,mBAAA,oBAAiB;aAN3C;AAKyB,mBAAA,oBAAiB;;AAM5C,mBAAA,AAAAC,sBAFW,AAAAF;;;;;AASXG,uBAAa,AAAAC;AACbC,wBAAc,AAAAF,yCAAyC,AAAAC;AACvDE,kBAAO,EAAI,AAAAD,mBAAmB;AAC9BE,oBAAS,EAAI,AAAAF,wBAAwB;AAEzC,WAAA,OAAA,YAAA,oIAA2BG,cAC5B,AAAAL,qBAAwBG,MAASC,QAEjCE,QAGA,AAAAL,oBAIA,AAAAA","file":null,"sourcesContent":null,"sourceRoot":null}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { map, defaultArg } from "../../fable_modules/fable-library.4.5.0/Option.js";
|
|
2
2
|
import { toList, exists } from "../../fable_modules/fable-library.4.5.0/Seq.js";
|
|
3
3
|
import { head } from "../../fable_modules/fable-library.4.5.0/List.js";
|
|
4
|
+
import { generateReaderError } from "./Utils.js";
|
|
4
5
|
import { GlueType, GlueVariable } from "../GlueAST.js";
|
|
5
6
|
|
|
6
7
|
export function readVariableStatement(reader, statement) {
|
|
@@ -8,7 +9,7 @@ export function readVariableStatement(reader, statement) {
|
|
|
8
9
|
if (defaultArg(map((modifiers) => exists((modifier) => (modifier.kind === 95), modifiers), statement.modifiers), false)) {
|
|
9
10
|
const declaration = head(toList(statement.declarationList.declarations));
|
|
10
11
|
return new GlueType(2, [new GlueVariable((declaration.name.kind === 80) ? ((id = declaration.name, id.getText())) : (() => {
|
|
11
|
-
throw new Error("
|
|
12
|
+
throw new Error(generateReaderError("variable statement", "Unable to read variable name", declaration));
|
|
12
13
|
})(), reader["Glutinum.Converter.Reader.Types.TypeScriptReader.ReadTypeNodeZ64B23DD2"](declaration.type))]);
|
|
13
14
|
}
|
|
14
15
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/VariableStatement.fs"],"names":["id","modifier","modifiers","statement","declaration","reader"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/Glutinum.Converter/Reader/VariableStatement.fs"],"names":["id","modifier","modifiers","statement","declaration","reader"],"mappings":";;;;;;;QA8BoBA;AAPhB,QAFO,WANA,mBAEI,sBACC,AAAAC,kBAAgB,KAFpBC,YAFJ,AAAAC,sBAOuB;AAGnBC,4BACwD,KAAd,OAA1C,AAAAD;AAoBD,eAAA,iBALF,iBAZS,CAAA,AAAAC,0BAAA,QAEEJ,KAAsB,AAAAI,kBAC1B,AAAAJ;AAEA,4BACI,oBACI,sBACA,gCACAI;cAKL,AAAAC,iFAAoB,AAAAD;;;AAM/B,eAAA","file":null,"sourcesContent":null,"sourceRoot":null}
|