@gi-tcg/gts-transpiler 0.3.1 → 0.3.2
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/LICENSE +201 -0
- package/dist/index.d.ts +109 -20
- package/dist/index.js +1983 -2154
- package/package.json +7 -5
- package/src/config.ts +1 -1
- package/src/error.ts +3 -4
- package/src/index.ts +6 -6
- package/src/parse/gts_plugin.ts +3 -3
- package/src/parse/index.ts +4 -4
- package/src/parse/record_call_lparen_plugin.ts +1 -1
- package/src/transform/erase_ts.ts +2 -2
- package/src/transform/gts.ts +2 -2
- package/src/transform/index.ts +3 -3
- package/src/transform/volar/index.ts +9 -9
- package/src/transform/volar/mappings.ts +1 -1
- package/src/transform/volar/printer.ts +1 -1
- package/src/transform/volar/replacements.ts +1 -1
- package/src/transform/volar/walker.ts +3 -3
- package/src/types.ts +2 -2
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gi-tcg/gts-transpiler",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"repository": "https://github.com/piovium/gts.git",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
|
-
"
|
|
10
|
+
"development": "./src/index.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
"src",
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
-
"scripts": {},
|
|
19
18
|
"dependencies": {
|
|
20
19
|
"@jridgewell/sourcemap-codec": "^1.5.5",
|
|
21
20
|
"@sveltejs/acorn-typescript": "^1.0.8",
|
|
22
|
-
"acorn": "8.15.0",
|
|
21
|
+
"acorn": "^8.15.0",
|
|
23
22
|
"esrap": "2.2.1",
|
|
24
23
|
"magic-string": "^0.30.21",
|
|
25
24
|
"path-browserify-esm": "^1.0.6",
|
|
@@ -29,5 +28,8 @@
|
|
|
29
28
|
"@types/node": "^24.3.0",
|
|
30
29
|
"@types/estree": "^1.0.8",
|
|
31
30
|
"@volar/language-core": "^2.4.27"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsdown --platform neutral"
|
|
32
34
|
}
|
|
33
|
-
}
|
|
35
|
+
}
|
package/src/config.ts
CHANGED
package/src/error.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { SourceLocation } from "estree";
|
|
2
2
|
|
|
3
3
|
export class GtsTranspilerError extends Error {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
public readonly position: SourceLocation | null,
|
|
7
|
-
) {
|
|
4
|
+
public readonly position: SourceLocation | null;
|
|
5
|
+
constructor(message: string, position: SourceLocation | null) {
|
|
8
6
|
super(message);
|
|
9
7
|
this.name = "GtsTranspilerError";
|
|
8
|
+
this.position = position;
|
|
10
9
|
}
|
|
11
10
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { parse, parseLoose } from "./parse";
|
|
1
|
+
import { parse, parseLoose } from "./parse/index.ts";
|
|
2
2
|
import {
|
|
3
3
|
transform,
|
|
4
4
|
transformForVolar,
|
|
5
5
|
type TranspileResult,
|
|
6
|
-
} from "./transform";
|
|
7
|
-
import type { TranspileOption } from "./transform/gts";
|
|
8
|
-
import type { VolarMappingResult } from "./transform/volar";
|
|
9
|
-
export { GtsTranspilerError } from "./error";
|
|
6
|
+
} from "./transform/index.ts";
|
|
7
|
+
import type { TranspileOption } from "./transform/gts.ts";
|
|
8
|
+
import type { VolarMappingResult } from "./transform/volar/index.ts";
|
|
9
|
+
export { GtsTranspilerError } from "./error.ts";
|
|
10
10
|
|
|
11
11
|
export function transpile(
|
|
12
12
|
source: string,
|
|
@@ -39,4 +39,4 @@ export {
|
|
|
39
39
|
resolveGtsConfig,
|
|
40
40
|
resolveGtsConfigSync,
|
|
41
41
|
type GtsConfig,
|
|
42
|
-
} from "./config";
|
|
42
|
+
} from "./config.ts";
|
package/src/parse/gts_plugin.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { tokTypes, type Parser as ParserClass } from "acorn";
|
|
2
|
-
import type { Parse, AST } from "../types";
|
|
3
|
-
import { specialIdentifiers } from "../keywords";
|
|
4
|
-
import { DUMMY_PLACEHOLDER } from "./loose_plugin";
|
|
2
|
+
import type { Parse, AST } from "../types.ts";
|
|
3
|
+
import { specialIdentifiers } from "../keywords.ts";
|
|
4
|
+
import { DUMMY_PLACEHOLDER } from "./loose_plugin.ts";
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
|
package/src/parse/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Parser } from "acorn";
|
|
2
2
|
import type { Position, Program } from "estree";
|
|
3
3
|
import { tsPlugin } from "@sveltejs/acorn-typescript";
|
|
4
|
-
import { gtsPlugin, type GtsPluginOption } from "./gts_plugin.
|
|
5
|
-
import { loosePlugin } from "./loose_plugin.
|
|
4
|
+
import { gtsPlugin, type GtsPluginOption } from "./gts_plugin.ts";
|
|
5
|
+
import { loosePlugin } from "./loose_plugin.ts";
|
|
6
6
|
import { getCommentHandlers } from "./comment.js";
|
|
7
|
-
import { GtsTranspilerError } from "../error.
|
|
8
|
-
import { recordCallLParenPlugin } from "./record_call_lparen_plugin.
|
|
7
|
+
import { GtsTranspilerError } from "../error.ts";
|
|
8
|
+
import { recordCallLParenPlugin } from "./record_call_lparen_plugin.ts";
|
|
9
9
|
|
|
10
10
|
const TsParser = Parser.extend(tsPlugin());
|
|
11
11
|
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
Node,
|
|
8
8
|
EmptyStatement,
|
|
9
9
|
} from "estree";
|
|
10
|
-
import { GtsTranspilerError } from "../error";
|
|
10
|
+
import { GtsTranspilerError } from "../error.ts";
|
|
11
11
|
|
|
12
12
|
const empty: EmptyStatement = {
|
|
13
13
|
type: "EmptyStatement",
|
|
@@ -201,4 +201,4 @@ const eraseTsVisitor: Visitors<any, null> = {
|
|
|
201
201
|
|
|
202
202
|
export const eraseTs = <T>(ast: T): T => {
|
|
203
203
|
return walk(ast, null, eraseTsVisitor);
|
|
204
|
-
}
|
|
204
|
+
}
|
package/src/transform/gts.ts
CHANGED
|
@@ -16,11 +16,11 @@ import type {
|
|
|
16
16
|
Statement,
|
|
17
17
|
} from "estree";
|
|
18
18
|
import { walk, type Visitors } from "zimmerframe";
|
|
19
|
-
import { GtsTranspilerError } from "../error";
|
|
19
|
+
import { GtsTranspilerError } from "../error.ts";
|
|
20
20
|
import {
|
|
21
21
|
DEFAULT_QUERY_BINDINGS,
|
|
22
22
|
DEFAULT_SHORTCUT_FUNCTION_PRELUDES,
|
|
23
|
-
} from "./constants";
|
|
23
|
+
} from "./constants.ts";
|
|
24
24
|
|
|
25
25
|
export interface ExternalizedBinding {
|
|
26
26
|
bindingName: Identifier;
|
package/src/transform/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Program } from "estree";
|
|
2
|
-
import { eraseTs } from "./erase_ts";
|
|
2
|
+
import { eraseTs } from "./erase_ts.ts";
|
|
3
3
|
import { print } from "esrap";
|
|
4
4
|
import jsPrinter from "esrap/languages/ts";
|
|
5
5
|
import type { SourceMap } from "magic-string";
|
|
6
|
-
import { gtsToTs, type TranspileOption } from "./gts";
|
|
6
|
+
import { gtsToTs, type TranspileOption } from "./gts.ts";
|
|
7
7
|
|
|
8
8
|
export interface TranspileResult {
|
|
9
9
|
code: string;
|
|
@@ -33,4 +33,4 @@ export function transform(
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export { transformForVolar } from "./volar";
|
|
36
|
+
export { transformForVolar } from "./volar/index.ts";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { AST } from "../../types";
|
|
1
|
+
import type { AST } from "../../types.ts";
|
|
2
2
|
import { walk } from "zimmerframe";
|
|
3
|
-
import type { SourceInfo, TranspileResult } from "
|
|
3
|
+
import type { SourceInfo, TranspileResult } from "../index.ts";
|
|
4
4
|
import { print } from "esrap";
|
|
5
5
|
import {
|
|
6
6
|
initialTranspileState,
|
|
7
7
|
type TranspileOption,
|
|
8
8
|
type TranspileState,
|
|
9
|
-
} from "../gts";
|
|
10
|
-
import { gtsToTypingsWalker, type TypingTranspileState } from "./walker";
|
|
11
|
-
import { applyReplacements } from "./replacements";
|
|
9
|
+
} from "../gts.ts";
|
|
10
|
+
import { gtsToTypingsWalker, type TypingTranspileState } from "./walker.ts";
|
|
11
|
+
import { applyReplacements } from "./replacements.ts";
|
|
12
12
|
import type { Program } from "estree";
|
|
13
|
-
import { convertToVolarMappings, type VolarMappingResult } from "./mappings";
|
|
14
|
-
import { collectLeafTokens, type LeafToken } from "./collect_tokens";
|
|
15
|
-
import { patchedPrinter } from "./printer";
|
|
13
|
+
import { convertToVolarMappings, type VolarMappingResult } from "./mappings.ts";
|
|
14
|
+
import { collectLeafTokens, type LeafToken } from "./collect_tokens.ts";
|
|
15
|
+
import { patchedPrinter } from "./printer.ts";
|
|
16
16
|
|
|
17
17
|
interface TypingTranspileOption extends TranspileOption {
|
|
18
18
|
leafTokens: LeafToken[];
|
|
@@ -81,4 +81,4 @@ export function transformForVolar(
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
export type { VolarMappingResult } from "./mappings";
|
|
84
|
+
export type { VolarMappingResult } from "./mappings.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decode } from "@jridgewell/sourcemap-codec";
|
|
2
2
|
import type { CodeInformation, CodeMapping } from "@volar/language-core";
|
|
3
|
-
import type { LeafToken } from "./collect_tokens";
|
|
3
|
+
import type { LeafToken } from "./collect_tokens.ts";
|
|
4
4
|
|
|
5
5
|
export interface VolarMappingResult {
|
|
6
6
|
code: string;
|
|
@@ -24,9 +24,9 @@ import {
|
|
|
24
24
|
commonGtsVisitor,
|
|
25
25
|
type ExternalizedBinding,
|
|
26
26
|
type TranspileState,
|
|
27
|
-
} from "../gts";
|
|
28
|
-
import type { LeafToken } from "./collect_tokens";
|
|
29
|
-
import { createReplacementHolder } from "./replacements";
|
|
27
|
+
} from "../gts.ts";
|
|
28
|
+
import type { LeafToken } from "./collect_tokens.ts";
|
|
29
|
+
import { createReplacementHolder } from "./replacements.ts";
|
|
30
30
|
|
|
31
31
|
interface ExternalizedTypedBinding extends ExternalizedBinding {
|
|
32
32
|
typingId: Identifier;
|
package/src/types.ts
CHANGED
|
@@ -107,7 +107,7 @@ declare module "acorn" {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
export namespace Parse {
|
|
110
|
+
export declare namespace Parse {
|
|
111
111
|
/**
|
|
112
112
|
* Destructuring errors object used during expression parsing
|
|
113
113
|
* See: https://github.com/acornjs/acorn/blob/main/acorn/src/parseutil.js
|
|
@@ -365,7 +365,7 @@ export namespace Parse {
|
|
|
365
365
|
* They are accessed by Ripple's custom parser plugin for whitespace handling,
|
|
366
366
|
* JSX parsing, and other advanced features.
|
|
367
367
|
*/
|
|
368
|
-
export
|
|
368
|
+
export class Parser extends acorn.Parser {
|
|
369
369
|
// ============================================================
|
|
370
370
|
// Position and Location Tracking
|
|
371
371
|
// ============================================================
|