@gi-tcg/gts-language-plugin 0.2.0 → 0.3.1

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 CHANGED
@@ -1,8 +1,9 @@
1
1
  import { LanguagePlugin } from "@volar/language-core";
2
2
  import { URI } from "vscode-uri";
3
+ import { GtsConfig } from "@gi-tcg/gts-transpiler";
3
4
  import * as import_8myeez from "typescript";
4
- declare function createGtsLanguagePlugin(ts: typeof import_8myeez): LanguagePlugin<URI | string>;
5
- import { GtsTranspilerError, GtsConfig } from "@gi-tcg/gts-transpiler";
5
+ declare function createGtsLanguagePlugin(ts: typeof import_8myeez, inlineConfig?: GtsConfig): LanguagePlugin<URI | string>;
6
+ import { GtsTranspilerError, GtsConfig as GtsConfig2 } from "@gi-tcg/gts-transpiler";
6
7
  import { CodeMapping, VirtualCode } from "@volar/language-core";
7
8
  import * as ts from "typescript";
8
9
  declare class GtsVirtualCode implements VirtualCode {
@@ -11,6 +12,6 @@ declare class GtsVirtualCode implements VirtualCode {
11
12
  mappings: CodeMapping[];
12
13
  snapshot: ts.IScriptSnapshot;
13
14
  errors: GtsTranspilerError[];
14
- constructor(filename: string, snapshot: ts.IScriptSnapshot, config: Required<GtsConfig>);
15
+ constructor(filename: string, snapshot: ts.IScriptSnapshot, config: Required<GtsConfig2>);
15
16
  }
16
17
  export { createGtsLanguagePlugin, GtsVirtualCode };
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ class GtsVirtualCode {
57
57
  }
58
58
 
59
59
  // packages/language-plugin/src/language_plugin.ts
60
- function createGtsLanguagePlugin(ts) {
60
+ function createGtsLanguagePlugin(ts, inlineConfig = {}) {
61
61
  return {
62
62
  getLanguageId(uri) {
63
63
  const path = typeof uri === "string" ? uri : uri.path;
@@ -68,9 +68,9 @@ function createGtsLanguagePlugin(ts) {
68
68
  createVirtualCode(uri, languageId, snapshot) {
69
69
  const filename = typeof uri === "string" ? uri : uri.path;
70
70
  if (languageId === "gaming-ts") {
71
- const resolvedConfig = resolveGtsConfigSync(filename, {}, {
72
- cwd: ts.sys.getCurrentDirectory(),
73
- readFileFn: (path, encoding) => ts.sys.readFile(path, encoding) || ""
71
+ const resolvedConfig = resolveGtsConfigSync(filename, inlineConfig, {
72
+ cwd: ts.sys?.getCurrentDirectory?.(),
73
+ readFileFn: (path, encoding) => ts.sys?.readFile?.(path, encoding) || ""
74
74
  });
75
75
  return new GtsVirtualCode(filename, snapshot, resolvedConfig);
76
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gi-tcg/gts-language-plugin",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "repository": "https://github.com/piovium/gts.git",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@gi-tcg/gts-transpiler": "0.2.0",
19
+ "@gi-tcg/gts-transpiler": "0.3.1",
20
20
  "@volar/language-core": "~2.4.0",
21
21
  "@volar/typescript": "~2.4.0",
22
22
  "vscode-uri": "^3.0.8"
@@ -7,6 +7,7 @@ import { GtsVirtualCode } from "./virtual_code";
7
7
 
8
8
  export function createGtsLanguagePlugin(
9
9
  ts: typeof import("typescript"),
10
+ inlineConfig: GtsConfig = {},
10
11
  ): LanguagePlugin<URI | string> {
11
12
  return {
12
13
  getLanguageId(uri) {
@@ -18,15 +19,11 @@ export function createGtsLanguagePlugin(
18
19
  createVirtualCode(uri, languageId, snapshot) {
19
20
  const filename = typeof uri === "string" ? uri : uri.path;
20
21
  if (languageId === "gaming-ts") {
21
- const resolvedConfig = resolveGtsConfigSync(
22
- filename,
23
- {},
24
- {
25
- cwd: ts.sys.getCurrentDirectory(),
26
- readFileFn: (path, encoding) =>
27
- ts.sys.readFile(path, encoding) || "",
28
- },
29
- );
22
+ const resolvedConfig = resolveGtsConfigSync(filename, inlineConfig, {
23
+ cwd: ts.sys?.getCurrentDirectory?.(),
24
+ readFileFn: (path, encoding) =>
25
+ ts.sys?.readFile?.(path, encoding) || "",
26
+ });
30
27
  return new GtsVirtualCode(filename, snapshot, resolvedConfig);
31
28
  }
32
29
  },