@supsign/unplugin-interfaces 0.2.0 → 1.0.0

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/astro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
 
3
3
  //#region src/astro.d.ts
4
4
  declare const _default: (options: Options) => any;
package/dist/astro.js CHANGED
@@ -1,4 +1,4 @@
1
- import { src_default } from "./src-BKy9tiI6.js";
1
+ import { src_default } from "./src-xDGsFk9F.js";
2
2
 
3
3
  //#region src/astro.ts
4
4
  var astro_default = (options) => ({
package/dist/esbuild.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
  import * as esbuild0 from "esbuild";
3
3
 
4
4
  //#region src/esbuild.d.ts
package/dist/esbuild.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-BKy9tiI6.js";
1
+ import { unpluginFactory } from "./src-xDGsFk9F.js";
2
2
  import { createEsbuildPlugin } from "unplugin";
3
3
 
4
4
  //#region src/esbuild.ts
package/dist/farm.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
 
3
3
  //#region src/farm.d.ts
4
4
  declare const _default: (options?: Options | undefined) => JsPlugin;
package/dist/farm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-BKy9tiI6.js";
1
+ import { unpluginFactory } from "./src-xDGsFk9F.js";
2
2
  import { createFarmPlugin } from "unplugin";
3
3
 
4
4
  //#region src/farm.ts
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
  import * as unplugin0 from "unplugin";
3
3
  import { UnpluginFactory } from "unplugin";
4
4
  import * as esbuild0 from "esbuild";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { esbuild, rollup, src_default, unplugin, unpluginFactory, vite, webpack } from "./src-BKy9tiI6.js";
1
+ import { esbuild, rollup, src_default, unplugin, unpluginFactory, vite, webpack } from "./src-xDGsFk9F.js";
2
2
 
3
3
  export { src_default as default, esbuild, rollup, unplugin, unpluginFactory, vite, webpack };
package/dist/nuxt.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
  import * as _nuxt_schema0 from "@nuxt/schema";
3
3
 
4
4
  //#region src/nuxt.d.ts
package/dist/nuxt.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./src-BKy9tiI6.js";
2
- import { vite_default } from "./vite-gMMORSxX.js";
3
- import { webpack_default } from "./webpack-BsOsB8pU.js";
1
+ import "./src-xDGsFk9F.js";
2
+ import { vite_default } from "./vite-DJyRlrtA.js";
3
+ import { webpack_default } from "./webpack-Jk_mUGu2.js";
4
4
  import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
5
5
 
6
6
  //#region src/nuxt.ts
package/dist/rollup.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
  import * as rollup0 from "rollup";
3
3
 
4
4
  //#region src/rollup.d.ts
package/dist/rollup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-BKy9tiI6.js";
1
+ import { unpluginFactory } from "./src-xDGsFk9F.js";
2
2
  import { createRollupPlugin } from "unplugin";
3
3
 
4
4
  //#region src/rollup.ts
package/dist/rspack.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
 
3
3
  //#region src/rspack.d.ts
4
4
  declare const _default: (options?: Options | undefined) => RspackPluginInstance;
package/dist/rspack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-BKy9tiI6.js";
1
+ import { unpluginFactory } from "./src-xDGsFk9F.js";
2
2
  import { createRspackPlugin } from "unplugin";
3
3
 
4
4
  //#region src/rspack.ts
@@ -1561,27 +1561,29 @@ var esm_default = {
1561
1561
  //#endregion
1562
1562
  //#region src/core/generator.ts
1563
1563
  function generateInterfaces(opts) {
1564
- const { interfaceDir, indexFile, outputFile, excludeFiles } = opts;
1564
+ const { interfaceDir, outputFile, excludeFiles } = opts;
1565
1565
  const files = fs.readdirSync(interfaceDir).filter((file) => file.endsWith(".ts") && file !== "index.ts" && !excludeFiles.has(file));
1566
1566
  const interfaces = [];
1567
1567
  for (const file of files) {
1568
1568
  const filePath = path.join(interfaceDir, file);
1569
1569
  const content = fs.readFileSync(filePath, "utf-8");
1570
- const interfaceNames = [...content.matchAll(/export\s+interface\s+(\w+)/g)].map((m) => m[1]);
1571
- const namedExportNames = [...content.matchAll(/export\s*\{\s*([^}]+)\s*\}/g)].flatMap((m) => m[1].split(",").map((item) => item.trim().split(/\s+as\s+/)[0].trim()));
1572
- const names = [...interfaceNames, ...namedExportNames];
1570
+ const interfaceNames = [...content.matchAll(/^export\s+interface\s+([A-Za-z_$][\w$]*)/gm)].map((m) => m[1]);
1571
+ const namedExportNames = [...content.matchAll(/export\s*\{\s*([^}]+)\s*\}/g)].filter((m) => !content.substring(Math.max(0, m.index - 10), m.index).includes("type")).flatMap((m) => m[1].split(",").map((item) => item.trim().split(/\s+as\s+/)[0].trim()).filter((name) => name.length > 0));
1572
+ const typeExportNames = [...content.matchAll(/export\s+type\s*\{\s*([^}]+)\s*\}/g)].flatMap((m) => m[1].split(",").map((item) => item.trim().split(/\s+as\s+/)[0].trim()).filter((name) => name.length > 0));
1573
+ const allNames = [
1574
+ ...interfaceNames,
1575
+ ...namedExportNames,
1576
+ ...typeExportNames
1577
+ ];
1578
+ const names = [...new Set(allNames)].filter((name) => name && name !== "export");
1573
1579
  if (names.length) interfaces.push({
1574
1580
  file,
1575
1581
  names
1576
1582
  });
1577
1583
  }
1578
- const exportLines = interfaces.map((i) => `export * from './${path.basename(i.file, ".ts")}';`);
1579
- fs.writeFileSync(indexFile, exportLines.join("\n"), "utf-8");
1580
1584
  const globalLines = [
1581
- `import type * as Interfaces from '../interfaces';`,
1582
- "",
1583
1585
  "declare global {",
1584
- ...interfaces.flatMap((i) => i.names.map((name) => ` export interface ${name} extends Interfaces.${name} {}`)),
1586
+ ...interfaces.flatMap((i) => i.names.map((name) => ` type ${name} = import('../interfaces/${path.basename(i.file, ".ts")}').${name};`)),
1585
1587
  "}",
1586
1588
  "",
1587
1589
  "export {};"
@@ -1597,10 +1599,8 @@ function generateInterfaces(opts) {
1597
1599
  //#endregion
1598
1600
  //#region src/core/paths.ts
1599
1601
  function resolveOptions(root, options = {}) {
1600
- const interfaceDir = path.resolve(root, options.dir ?? "resources/js/interfaces");
1601
1602
  return {
1602
- interfaceDir,
1603
- indexFile: path.join(interfaceDir, "index.ts"),
1603
+ interfaceDir: path.resolve(root, options.dir ?? "resources/js/interfaces"),
1604
1604
  outputFile: path.resolve(root, options.out ?? "resources/js/types/interfaces.d.ts"),
1605
1605
  excludeFiles: new Set(options.exclude ?? [])
1606
1606
  };
@@ -9,7 +9,6 @@ interface Options {
9
9
  }
10
10
  interface ResolvedOptions {
11
11
  interfaceDir: string;
12
- indexFile: string;
13
12
  outputFile: string;
14
13
  excludeFiles: Set<string>;
15
14
  }
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Options, ResolvedOptions } from "./types-BVbGtSvv.js";
1
+ import { Options, ResolvedOptions } from "./types-DTqFymcy.js";
2
2
  export { Options, ResolvedOptions };
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-BKy9tiI6.js";
1
+ import { unpluginFactory } from "./src-xDGsFk9F.js";
2
2
  import { createVitePlugin } from "unplugin";
3
3
 
4
4
  //#region src/vite.ts
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
  import * as vite0 from "vite";
3
3
 
4
4
  //#region src/vite.d.ts
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./src-BKy9tiI6.js";
2
- import { vite_default } from "./vite-gMMORSxX.js";
1
+ import "./src-xDGsFk9F.js";
2
+ import { vite_default } from "./vite-DJyRlrtA.js";
3
3
 
4
4
  export { vite_default as default };
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-BKy9tiI6.js";
1
+ import { unpluginFactory } from "./src-xDGsFk9F.js";
2
2
  import { createWebpackPlugin } from "unplugin";
3
3
 
4
4
  //#region src/webpack.ts
package/dist/webpack.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Options } from "./types-BVbGtSvv.js";
1
+ import { Options } from "./types-DTqFymcy.js";
2
2
  import * as webpack0 from "webpack";
3
3
 
4
4
  //#region src/webpack.d.ts
package/dist/webpack.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./src-BKy9tiI6.js";
2
- import { webpack_default } from "./webpack-BsOsB8pU.js";
1
+ import "./src-xDGsFk9F.js";
2
+ import { webpack_default } from "./webpack-Jk_mUGu2.js";
3
3
 
4
4
  export { webpack_default as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@supsign/unplugin-interfaces",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "1.0.0",
5
5
  "packageManager": "pnpm@10.18.3",
6
6
  "description": "",
7
7
  "license": "MIT",