@gi-tcg/gts-language-plugin 0.4.1 → 0.4.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/dist/index.d.ts +5 -2
- package/dist/index.js +3 -2
- package/package.json +3 -3
- package/src/language_plugin.ts +13 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { CodeMapping, LanguagePlugin, VirtualCode } from "@volar/language-core";
|
|
2
2
|
import { URI } from "vscode-uri";
|
|
3
|
-
import { GtsConfig, GtsTranspilerError } from "@gi-tcg/gts-transpiler";
|
|
3
|
+
import { GtsConfig, GtsTranspilerError, PathModule } from "@gi-tcg/gts-transpiler";
|
|
4
4
|
import * as ts$1 from "typescript";
|
|
5
5
|
import ts from "typescript";
|
|
6
6
|
|
|
7
7
|
//#region src/language_plugin.d.ts
|
|
8
8
|
type Ts = typeof ts;
|
|
9
|
-
|
|
9
|
+
interface GtsLanguagePluginInlineConfig extends GtsConfig {
|
|
10
|
+
pathModule?: PathModule;
|
|
11
|
+
}
|
|
12
|
+
declare function createGtsLanguagePlugin(ts: Ts, inlineConfig?: GtsLanguagePluginInlineConfig): LanguagePlugin<URI | string>;
|
|
10
13
|
//#endregion
|
|
11
14
|
//#region src/virtual_code.d.ts
|
|
12
15
|
declare class GtsVirtualCode implements VirtualCode {
|
package/dist/index.js
CHANGED
|
@@ -40,12 +40,13 @@ var GtsVirtualCode = class {
|
|
|
40
40
|
function createGtsLanguagePlugin(ts, inlineConfig = {}) {
|
|
41
41
|
return {
|
|
42
42
|
getLanguageId(uri) {
|
|
43
|
-
if ((typeof uri === "string" ? uri : uri.
|
|
43
|
+
if ((typeof uri === "string" ? uri : uri.fsPath).endsWith(".gts")) return "gaming-ts";
|
|
44
44
|
},
|
|
45
45
|
createVirtualCode(uri, languageId, snapshot) {
|
|
46
|
-
const filename = typeof uri === "string" ? uri : uri.
|
|
46
|
+
const filename = typeof uri === "string" ? uri : uri.fsPath;
|
|
47
47
|
if (languageId === "gaming-ts") return new GtsVirtualCode(filename, snapshot, resolveGtsConfigSync(filename, inlineConfig, {
|
|
48
48
|
cwd: ts.sys?.getCurrentDirectory?.(),
|
|
49
|
+
pathModule: inlineConfig.pathModule,
|
|
49
50
|
readFileFn: (path, encoding) => ts.sys?.readFile?.(path, encoding) || ""
|
|
50
51
|
}));
|
|
51
52
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gi-tcg/gts-language-plugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/piovium/gts.git"
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"@volar/language-core": "~2.4.0",
|
|
23
23
|
"@volar/typescript": "~2.4.0",
|
|
24
24
|
"vscode-uri": "^3.0.8",
|
|
25
|
-
"@gi-tcg/gts-transpiler": "0.4.
|
|
25
|
+
"@gi-tcg/gts-transpiler": "0.4.3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"typescript": "
|
|
28
|
+
"typescript": "npm:@typescript/typescript6@^6.0.1"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsdown --platform neutral"
|
package/src/language_plugin.ts
CHANGED
|
@@ -2,27 +2,36 @@ import { type LanguagePlugin } from "@volar/language-core";
|
|
|
2
2
|
import type {} from "@volar/typescript";
|
|
3
3
|
import type ts from "typescript";
|
|
4
4
|
import { URI } from "vscode-uri";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
resolveGtsConfigSync,
|
|
7
|
+
type GtsConfig,
|
|
8
|
+
type PathModule,
|
|
9
|
+
} from "@gi-tcg/gts-transpiler";
|
|
6
10
|
import { GtsVirtualCode } from "./virtual_code.ts";
|
|
7
11
|
|
|
8
12
|
type Ts = typeof ts;
|
|
9
13
|
|
|
14
|
+
export interface GtsLanguagePluginInlineConfig extends GtsConfig {
|
|
15
|
+
pathModule?: PathModule;
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
export function createGtsLanguagePlugin(
|
|
11
19
|
ts: Ts,
|
|
12
|
-
inlineConfig:
|
|
20
|
+
inlineConfig: GtsLanguagePluginInlineConfig = {},
|
|
13
21
|
): LanguagePlugin<URI | string> {
|
|
14
22
|
return {
|
|
15
23
|
getLanguageId(uri) {
|
|
16
|
-
const path = typeof uri === "string" ? uri : uri.
|
|
24
|
+
const path = typeof uri === "string" ? uri : uri.fsPath;
|
|
17
25
|
if (path.endsWith(".gts")) {
|
|
18
26
|
return "gaming-ts";
|
|
19
27
|
}
|
|
20
28
|
},
|
|
21
29
|
createVirtualCode(uri, languageId, snapshot) {
|
|
22
|
-
const filename = typeof uri === "string" ? uri : uri.
|
|
30
|
+
const filename = typeof uri === "string" ? uri : uri.fsPath;
|
|
23
31
|
if (languageId === "gaming-ts") {
|
|
24
32
|
const resolvedConfig = resolveGtsConfigSync(filename, inlineConfig, {
|
|
25
33
|
cwd: ts.sys?.getCurrentDirectory?.(),
|
|
34
|
+
pathModule: inlineConfig.pathModule,
|
|
26
35
|
readFileFn: (path, encoding) =>
|
|
27
36
|
ts.sys?.readFile?.(path, encoding) || "",
|
|
28
37
|
});
|