@gi-tcg/gts-transpiler 0.7.1 → 0.7.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/dist/index.d.ts +5 -1
- package/dist/index.js +13 -2
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/utils/index.ts +13 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as acorn from "acorn";
|
|
2
2
|
import { Options as Options$1, Parser as Parser$1 } from "acorn";
|
|
3
|
+
import { AST as AST$1 } from "espolar";
|
|
3
4
|
import * as AST from "estree";
|
|
4
5
|
import { Program, SourceLocation } from "estree";
|
|
5
6
|
import { SourceMap } from "magic-string";
|
|
@@ -1528,8 +1529,11 @@ interface ResolveGtsConfigAsyncOptions extends ResolveGtsConfigBaseOptions {
|
|
|
1528
1529
|
declare function resolveGtsConfig(filePath: string, inlineConfig: GtsConfig, options: ResolveGtsConfigAsyncOptions): Promise<Required<GtsConfig>>;
|
|
1529
1530
|
declare function resolveGtsConfigSync(filePath: string, inlineConfig: GtsConfig, options: ResolveGtsConfigSyncOptions): Required<GtsConfig>;
|
|
1530
1531
|
//#endregion
|
|
1532
|
+
//#region src/utils/index.d.ts
|
|
1533
|
+
declare function isGtsShortcutArgumentStartingConciseBody(node: AST$1.Expression | AST$1.BlockStatement | AST$1.PrivateIdentifier): boolean;
|
|
1534
|
+
//#endregion
|
|
1531
1535
|
//#region src/index.d.ts
|
|
1532
1536
|
declare function transpile(source: string, filename: string, option: TranspileOption): TranspileResult;
|
|
1533
1537
|
declare function transpileForVolar(source: string, filename: string, option: TranspileOption): VolarMappingResult;
|
|
1534
1538
|
//#endregion
|
|
1535
|
-
export { type AST, type GtsConfig, type ParseLooseOptions as GtsParseLooseOptions, type ParseOptions as GtsParseOptions, GtsTranspilerError, type PathModule, type ResolveGtsConfigAsyncOptions, type ResolveGtsConfigSyncOptions, type TranspileOption, type TranspileResult, type VolarMappingResult, parse, parseLoose, resolveGtsConfig, resolveGtsConfigSync, transpile, transpileForVolar };
|
|
1539
|
+
export { type AST, type GtsConfig, type ParseLooseOptions as GtsParseLooseOptions, type ParseOptions as GtsParseOptions, GtsTranspilerError, type PathModule, type ResolveGtsConfigAsyncOptions, type ResolveGtsConfigSyncOptions, type TranspileOption, type TranspileResult, type VolarMappingResult, isGtsShortcutArgumentStartingConciseBody, parse, parseLoose, resolveGtsConfig, resolveGtsConfigSync, transpile, transpileForVolar };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { tsPlugin } from "@sveltejs/acorn-typescript";
|
|
|
3
3
|
import { walk } from "zimmerframe";
|
|
4
4
|
import { print } from "esrap";
|
|
5
5
|
import jsPrinter from "esrap/languages/ts";
|
|
6
|
-
import { defaultPrinters, print as print$1 } from "espolar";
|
|
6
|
+
import { canStartConciseBody, defaultPrinters, print as print$1 } from "espolar";
|
|
7
7
|
import dedent from "dedent";
|
|
8
8
|
import browserPath from "path-browserify-esm";
|
|
9
9
|
//#region src/keywords.ts
|
|
@@ -2037,6 +2037,17 @@ function* readPackageConfig(readFileFn, pkgPath) {
|
|
|
2037
2037
|
}
|
|
2038
2038
|
}
|
|
2039
2039
|
//#endregion
|
|
2040
|
+
//#region src/utils/index.ts
|
|
2041
|
+
function isGtsShortcutArgument(node) {
|
|
2042
|
+
return node.type === "GTSShortcutArgumentExpression";
|
|
2043
|
+
}
|
|
2044
|
+
function canStartConciseBodyGts(node) {
|
|
2045
|
+
return canStartConciseBody(node, isGtsShortcutArgument);
|
|
2046
|
+
}
|
|
2047
|
+
function isGtsShortcutArgumentStartingConciseBody(node) {
|
|
2048
|
+
return !canStartConciseBodyGts(node) && canStartConciseBody(node);
|
|
2049
|
+
}
|
|
2050
|
+
//#endregion
|
|
2040
2051
|
//#region src/index.ts
|
|
2041
2052
|
function transpile(source, filename, option) {
|
|
2042
2053
|
return transform(parse(source), option, {
|
|
@@ -2051,4 +2062,4 @@ function transpileForVolar(source, filename, option) {
|
|
|
2051
2062
|
});
|
|
2052
2063
|
}
|
|
2053
2064
|
//#endregion
|
|
2054
|
-
export { GtsTranspilerError, parse, parseLoose, resolveGtsConfig, resolveGtsConfigSync, transpile, transpileForVolar };
|
|
2065
|
+
export { GtsTranspilerError, isGtsShortcutArgumentStartingConciseBody, parse, parseLoose, resolveGtsConfig, resolveGtsConfigSync, transpile, transpileForVolar };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gi-tcg/gts-transpiler",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/piovium/gts.git"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@sveltejs/acorn-typescript": "^1.0.8",
|
|
23
23
|
"acorn": "^8.15.0",
|
|
24
24
|
"dedent": "^1.7.2",
|
|
25
|
-
"espolar": "^0.6.
|
|
25
|
+
"espolar": "^0.6.5",
|
|
26
26
|
"esrap": "2.2.1",
|
|
27
27
|
"magic-string": "^0.30.21",
|
|
28
28
|
"path-browserify-esm": "^1.0.6",
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { canStartConciseBody, type AST } from "espolar";
|
|
2
|
+
|
|
3
|
+
function isGtsShortcutArgument(node: AST.Node) {
|
|
4
|
+
return (node.type as string) === "GTSShortcutArgumentExpression";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function canStartConciseBodyGts(node: AST.Expression | AST.BlockStatement | AST.PrivateIdentifier): boolean {
|
|
8
|
+
return canStartConciseBody(node, isGtsShortcutArgument);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isGtsShortcutArgumentStartingConciseBody(node: AST.Expression | AST.BlockStatement | AST.PrivateIdentifier): boolean {
|
|
12
|
+
return !canStartConciseBodyGts(node) && canStartConciseBody(node);
|
|
13
|
+
}
|