@gi-tcg/unplugin-gts 0.3.5 → 0.3.6

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/bun.d.ts CHANGED
@@ -2,6 +2,6 @@ import { UnpluginInstance } from "unplugin";
2
2
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
4
  //#region src/bun.d.ts
5
- declare const _default: UnpluginInstance<TranspileOption | undefined>["bun"];
5
+ declare const _default: UnpluginInstance<TranspileOption | undefined, false>["bun"];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/bun.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./unplugin-DDqvnght.js";
1
+ import { t as unpluginFactory } from "./unplugin-C0MRSp4g.js";
2
2
  import { createBunPlugin } from "unplugin";
3
3
  //#region src/bun.ts
4
4
  var bun_default = createBunPlugin(unpluginFactory);
package/dist/esbuild.d.ts CHANGED
@@ -2,6 +2,6 @@ import { UnpluginInstance } from "unplugin";
2
2
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
4
  //#region src/esbuild.d.ts
5
- declare const _default: UnpluginInstance<TranspileOption | undefined>["esbuild"];
5
+ declare const _default: UnpluginInstance<TranspileOption | undefined, false>["esbuild"];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/esbuild.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./unplugin-DDqvnght.js";
1
+ import { t as unpluginFactory } from "./unplugin-C0MRSp4g.js";
2
2
  import { createEsbuildPlugin } from "unplugin";
3
3
  //#region src/esbuild.ts
4
4
  var esbuild_default = createEsbuildPlugin(unpluginFactory);
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import { TranspileSyncOption } from "./unplugin.js";
1
2
  import { UnpluginInstance } from "unplugin";
2
3
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
4
  export * from "@gi-tcg/gts-transpiler";
4
5
 
5
6
  //#region src/index.d.ts
6
- declare const _default: UnpluginInstance<TranspileOption | undefined>;
7
+ declare const _default: UnpluginInstance<TranspileOption | undefined, false>;
7
8
  //#endregion
8
- export { _default as default };
9
+ export { type TranspileSyncOption, _default as default };
@@ -2,6 +2,6 @@ import { UnpluginInstance } from "unplugin";
2
2
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
4
  //#region src/rolldown.d.ts
5
- declare const _default: UnpluginInstance<TranspileOption | undefined>["rolldown"];
5
+ declare const _default: UnpluginInstance<TranspileOption | undefined, false>["rolldown"];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -2,6 +2,6 @@ import { UnpluginInstance } from "unplugin";
2
2
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
4
  //#region src/rollup.d.ts
5
- declare const _default: UnpluginInstance<TranspileOption | undefined>["rollup"];
5
+ declare const _default: UnpluginInstance<TranspileOption | undefined, false>["rollup"];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/rspack.d.ts CHANGED
@@ -2,6 +2,6 @@ import { UnpluginInstance } from "unplugin";
2
2
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
4
  //#region src/rspack.d.ts
5
- declare const _default: UnpluginInstance<TranspileOption | undefined>["rspack"];
5
+ declare const _default: UnpluginInstance<TranspileOption | undefined, false>["rspack"];
6
6
  //#endregion
7
7
  export { _default as default };
@@ -1,7 +1,12 @@
1
1
  import { UnpluginInstance } from "unplugin";
2
2
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
+ //#region src/unplugin.d.ts
5
+ interface TranspileSyncOption extends TranspileOption {
6
+ readFileFn: (path: string, encoding: "utf8") => string;
7
+ }
8
+ //#endregion
4
9
  //#region src/unloader.d.ts
5
- declare const _default: UnpluginInstance<TranspileOption | undefined>["unloader"];
10
+ declare const _default: UnpluginInstance<TranspileSyncOption, false>["unloader"];
6
11
  //#endregion
7
12
  export { _default as default };
package/dist/unloader.js CHANGED
@@ -1,6 +1,6 @@
1
- import { t as unpluginFactory } from "./unplugin-DDqvnght.js";
1
+ import { n as unpluginSyncFactory } from "./unplugin-C0MRSp4g.js";
2
2
  import { createUnloaderPlugin } from "unplugin";
3
3
  //#region src/unloader.ts
4
- var unloader_default = createUnloaderPlugin(unpluginFactory);
4
+ var unloader_default = createUnloaderPlugin(unpluginSyncFactory);
5
5
  //#endregion
6
6
  export { unloader_default as default };
@@ -0,0 +1,41 @@
1
+ import { resolveGtsConfig, resolveGtsConfigSync, transpile } from "@gi-tcg/gts-transpiler";
2
+ //#region src/unplugin.ts
3
+ const unpluginFactory = (option) => {
4
+ return {
5
+ name: "unplugin-gaming-ts",
6
+ transform: {
7
+ filter: { id: /\.gts$/ },
8
+ async handler(source, id) {
9
+ const { code, sourceMap } = transpile(source, id, await resolveGtsConfig(id, option ?? {}, { readFileFn: (path, encoding) => this.fs.readFile(path, { encoding }) }));
10
+ return {
11
+ code,
12
+ map: sourceMap
13
+ };
14
+ }
15
+ }
16
+ };
17
+ };
18
+ const unpluginSyncFactory = (option) => {
19
+ return {
20
+ name: "unplugin-gaming-ts",
21
+ load: {
22
+ filter: { id: /\.gts$/ },
23
+ handler(id) {
24
+ return option.readFileFn(id, "utf8");
25
+ }
26
+ },
27
+ transform: {
28
+ filter: { id: /\.gts$/ },
29
+ handler(source, id) {
30
+ const { readFileFn, ...restOption } = option;
31
+ const { code, sourceMap } = transpile(source, id, resolveGtsConfigSync(id, restOption, { readFileFn }));
32
+ return {
33
+ code,
34
+ map: sourceMap
35
+ };
36
+ }
37
+ }
38
+ };
39
+ };
40
+ //#endregion
41
+ export { unpluginSyncFactory as n, unpluginFactory as t };
@@ -3,5 +3,9 @@ import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
4
  //#region src/unplugin.d.ts
5
5
  declare const unpluginFactory: UnpluginFactory<TranspileOption | undefined>;
6
+ interface TranspileSyncOption extends TranspileOption {
7
+ readFileFn: (path: string, encoding: "utf8") => string;
8
+ }
9
+ declare const unpluginSyncFactory: UnpluginFactory<TranspileSyncOption>;
6
10
  //#endregion
7
- export { unpluginFactory };
11
+ export { TranspileSyncOption, unpluginFactory, unpluginSyncFactory };
package/dist/unplugin.js CHANGED
@@ -1,4 +1,4 @@
1
- import { resolveGtsConfig, transpile } from "@gi-tcg/gts-transpiler";
1
+ import { resolveGtsConfig, resolveGtsConfigSync, transpile } from "@gi-tcg/gts-transpiler";
2
2
  //#region src/unplugin.ts
3
3
  const unpluginFactory = (option) => {
4
4
  return {
@@ -15,5 +15,27 @@ const unpluginFactory = (option) => {
15
15
  }
16
16
  };
17
17
  };
18
+ const unpluginSyncFactory = (option) => {
19
+ return {
20
+ name: "unplugin-gaming-ts",
21
+ load: {
22
+ filter: { id: /\.gts$/ },
23
+ handler(id) {
24
+ return option.readFileFn(id, "utf8");
25
+ }
26
+ },
27
+ transform: {
28
+ filter: { id: /\.gts$/ },
29
+ handler(source, id) {
30
+ const { readFileFn, ...restOption } = option;
31
+ const { code, sourceMap } = transpile(source, id, resolveGtsConfigSync(id, restOption, { readFileFn }));
32
+ return {
33
+ code,
34
+ map: sourceMap
35
+ };
36
+ }
37
+ }
38
+ };
39
+ };
18
40
  //#endregion
19
- export { unpluginFactory };
41
+ export { unpluginFactory, unpluginSyncFactory };
package/dist/vite.d.ts CHANGED
@@ -2,6 +2,6 @@ import { UnpluginInstance } from "unplugin";
2
2
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
4
  //#region src/vite.d.ts
5
- declare const _default: UnpluginInstance<TranspileOption | undefined>["vite"];
5
+ declare const _default: UnpluginInstance<TranspileOption | undefined, false>["vite"];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./unplugin-DDqvnght.js";
1
+ import { t as unpluginFactory } from "./unplugin-C0MRSp4g.js";
2
2
  import { createVitePlugin } from "unplugin";
3
3
  //#region src/vite.ts
4
4
  var vite_default = createVitePlugin(unpluginFactory);
package/dist/webpack.d.ts CHANGED
@@ -2,6 +2,6 @@ import { UnpluginInstance } from "unplugin";
2
2
  import { TranspileOption } from "@gi-tcg/gts-transpiler";
3
3
 
4
4
  //#region src/webpack.d.ts
5
- declare const _default: UnpluginInstance<TranspileOption | undefined>["webpack"];
5
+ declare const _default: UnpluginInstance<TranspileOption | undefined, false>["webpack"];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/webpack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as unpluginFactory } from "./unplugin-DDqvnght.js";
1
+ import { t as unpluginFactory } from "./unplugin-C0MRSp4g.js";
2
2
  import { createWebpackPlugin } from "unplugin";
3
3
  //#region src/webpack.ts
4
4
  var webpack_default = createWebpackPlugin(unpluginFactory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gi-tcg/unplugin-gts",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/piovium/gts.git"
@@ -127,7 +127,7 @@
127
127
  "dependencies": {
128
128
  "@types/bun": "^1.3.6",
129
129
  "unplugin": "npm:@gytx/unplugin@3.1.0-patch.2",
130
- "@gi-tcg/gts-transpiler": "0.3.5"
130
+ "@gi-tcg/gts-transpiler": "0.3.6"
131
131
  },
132
132
  "devDependencies": {
133
133
  "@types/node": "^24.3.0"
package/src/bun.ts CHANGED
@@ -4,4 +4,4 @@ import type { TranspileOption } from "@gi-tcg/gts-transpiler";
4
4
 
5
5
  export default createBunPlugin(
6
6
  unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>["bun"];
7
+ ) as UnpluginInstance<TranspileOption | undefined, false>["bun"];
package/src/esbuild.ts CHANGED
@@ -4,4 +4,4 @@ import type { TranspileOption } from "@gi-tcg/gts-transpiler";
4
4
 
5
5
  export default createEsbuildPlugin(
6
6
  unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>["esbuild"];
7
+ ) as UnpluginInstance<TranspileOption | undefined, false>["esbuild"];
package/src/index.ts CHANGED
@@ -2,8 +2,10 @@ import { createUnplugin, type UnpluginInstance } from "unplugin";
2
2
  import { unpluginFactory } from "./unplugin.ts";
3
3
  import type { TranspileOption } from "@gi-tcg/gts-transpiler";
4
4
 
5
- export default createUnplugin(
6
- unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>;
5
+ export default createUnplugin(unpluginFactory) as UnpluginInstance<
6
+ TranspileOption | undefined,
7
+ false
8
+ >;
8
9
 
10
+ export type { TranspileSyncOption } from "./unplugin.ts";
9
11
  export type * from "@gi-tcg/gts-transpiler";
package/src/rolldown.ts CHANGED
@@ -4,4 +4,4 @@ import type { TranspileOption } from "@gi-tcg/gts-transpiler";
4
4
 
5
5
  export default createRolldownPlugin(
6
6
  unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>["rolldown"];
7
+ ) as UnpluginInstance<TranspileOption | undefined, false>["rolldown"];
package/src/rollup.ts CHANGED
@@ -4,4 +4,4 @@ import type { TranspileOption } from "@gi-tcg/gts-transpiler";
4
4
 
5
5
  export default createRollupPlugin(
6
6
  unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>["rollup"];
7
+ ) as UnpluginInstance<TranspileOption | undefined, false>["rollup"];
package/src/rspack.ts CHANGED
@@ -4,4 +4,4 @@ import type { TranspileOption } from "@gi-tcg/gts-transpiler";
4
4
 
5
5
  export default createRspackPlugin(
6
6
  unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>["rspack"];
7
+ ) as UnpluginInstance<TranspileOption | undefined, false>["rspack"];
package/src/unloader.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { createUnloaderPlugin, type UnpluginInstance } from "unplugin";
2
- import { unpluginFactory } from "./unplugin.ts";
3
- import type { TranspileOption } from "@gi-tcg/gts-transpiler";
2
+ import { unpluginSyncFactory, type TranspileSyncOption } from "./unplugin.ts";
4
3
 
5
4
  export default createUnloaderPlugin(
6
- unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>["unloader"];
5
+ unpluginSyncFactory,
6
+ ) as UnpluginInstance<TranspileSyncOption, false>["unloader"];
package/src/unplugin.ts CHANGED
@@ -2,16 +2,17 @@ import {
2
2
  transpile,
3
3
  type TranspileOption,
4
4
  resolveGtsConfig,
5
+ resolveGtsConfigSync,
5
6
  } from "@gi-tcg/gts-transpiler";
6
7
  import type { UnpluginFactory } from "unplugin";
7
8
 
8
- export const unpluginFactory: UnpluginFactory<TranspileOption | undefined> = (option) => {
9
+ export const unpluginFactory: UnpluginFactory<TranspileOption | undefined> = (
10
+ option,
11
+ ) => {
9
12
  return {
10
13
  name: "unplugin-gaming-ts",
11
14
  transform: {
12
- filter: {
13
- id: /\.gts$/,
14
- },
15
+ filter: { id: /\.gts$/ },
15
16
  async handler(source, id) {
16
17
  const resolvedOption = await resolveGtsConfig(id, option ?? {}, {
17
18
  readFileFn: (path, encoding) =>
@@ -26,3 +27,38 @@ export const unpluginFactory: UnpluginFactory<TranspileOption | undefined> = (op
26
27
  },
27
28
  };
28
29
  };
30
+
31
+ export interface TranspileSyncOption extends TranspileOption {
32
+ readFileFn: (path: string, encoding: "utf8") => string;
33
+ }
34
+
35
+ export const unpluginSyncFactory: UnpluginFactory<TranspileSyncOption> = (
36
+ option,
37
+ ) => {
38
+ return {
39
+ name: "unplugin-gaming-ts",
40
+ // The sync version used in unloader, have a following issue:
41
+ // https://github.com/sxzz/unloader/issues/52
42
+ // that requires an explicit load function. Lets define it now.
43
+ load: {
44
+ filter: { id: /\.gts$/ },
45
+ handler(id) {
46
+ return option.readFileFn(id, "utf8");
47
+ },
48
+ },
49
+ transform: {
50
+ filter: { id: /\.gts$/ },
51
+ handler(source, id) {
52
+ const { readFileFn, ...restOption } = option;
53
+ const resolvedOption = resolveGtsConfigSync(id, restOption, {
54
+ readFileFn,
55
+ });
56
+ const { code, sourceMap } = transpile(source, id, resolvedOption);
57
+ return {
58
+ code,
59
+ map: sourceMap,
60
+ };
61
+ },
62
+ },
63
+ };
64
+ };
package/src/vite.ts CHANGED
@@ -4,4 +4,4 @@ import type { TranspileOption } from "@gi-tcg/gts-transpiler";
4
4
 
5
5
  export default createVitePlugin(
6
6
  unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>["vite"];
7
+ ) as UnpluginInstance<TranspileOption | undefined, false>["vite"];
package/src/webpack.ts CHANGED
@@ -2,6 +2,7 @@ import { createWebpackPlugin, type UnpluginInstance } from "unplugin";
2
2
  import { unpluginFactory } from "./unplugin.ts";
3
3
  import type { TranspileOption } from "@gi-tcg/gts-transpiler";
4
4
 
5
- export default createWebpackPlugin(
6
- unpluginFactory,
7
- ) as UnpluginInstance<TranspileOption | undefined>["webpack"];
5
+ export default createWebpackPlugin(unpluginFactory) as UnpluginInstance<
6
+ TranspileOption | undefined,
7
+ false
8
+ >["webpack"];
@@ -1,19 +0,0 @@
1
- import { resolveGtsConfig, transpile } from "@gi-tcg/gts-transpiler";
2
- //#region src/unplugin.ts
3
- const unpluginFactory = (option) => {
4
- return {
5
- name: "unplugin-gaming-ts",
6
- transform: {
7
- filter: { id: /\.gts$/ },
8
- async handler(source, id) {
9
- const { code, sourceMap } = transpile(source, id, await resolveGtsConfig(id, option ?? {}, { readFileFn: (path, encoding) => this.fs.readFile(path, { encoding }) }));
10
- return {
11
- code,
12
- map: sourceMap
13
- };
14
- }
15
- }
16
- };
17
- };
18
- //#endregion
19
- export { unpluginFactory as t };