@supsign/unplugin-interfaces 0.1.0 → 0.2.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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { src_default } from "./src-CskmyrvV.js";
1
+ import { src_default } from "./src-BKy9tiI6.js";
2
2
 
3
3
  //#region src/astro.ts
4
4
  var astro_default = (options) => ({
package/dist/esbuild.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-CskmyrvV.js";
1
+ import { unpluginFactory } from "./src-BKy9tiI6.js";
2
2
  import { createEsbuildPlugin } from "unplugin";
3
3
 
4
4
  //#region src/esbuild.ts
package/dist/farm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-CskmyrvV.js";
1
+ import { unpluginFactory } from "./src-BKy9tiI6.js";
2
2
  import { createFarmPlugin } from "unplugin";
3
3
 
4
4
  //#region src/farm.ts
package/dist/index.d.ts CHANGED
@@ -2,15 +2,15 @@ import { Options } from "./types-BVbGtSvv.js";
2
2
  import * as unplugin0 from "unplugin";
3
3
  import { UnpluginFactory } from "unplugin";
4
4
  import * as esbuild0 from "esbuild";
5
- import * as vite0 from "vite";
6
- import * as rollup0 from "rollup";
5
+ import * as vite1 from "vite";
6
+ import * as rollup1 from "rollup";
7
7
  import * as webpack0 from "webpack";
8
8
 
9
9
  //#region src/index.d.ts
10
10
  declare const unpluginFactory: UnpluginFactory<Options | undefined>;
11
11
  declare const unplugin: unplugin0.UnpluginInstance<Options | undefined, boolean>;
12
- declare const vite: (options?: Options | undefined) => vite0.Plugin<any> | vite0.Plugin<any>[];
13
- declare const rollup: (options?: Options | undefined) => rollup0.Plugin<any> | rollup0.Plugin<any>[];
12
+ declare const vite: (options?: Options | undefined) => vite1.Plugin<any> | vite1.Plugin<any>[];
13
+ declare const rollup: (options?: Options | undefined) => rollup1.Plugin<any> | rollup1.Plugin<any>[];
14
14
  declare const webpack: (options?: Options | undefined) => webpack0.WebpackPluginInstance;
15
15
  declare const esbuild: (options?: Options | undefined) => esbuild0.Plugin;
16
16
  //#endregion
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { esbuild, rollup, src_default, unplugin, unpluginFactory, vite, webpack } from "./src-CskmyrvV.js";
1
+ import { esbuild, rollup, src_default, unplugin, unpluginFactory, vite, webpack } from "./src-BKy9tiI6.js";
2
2
 
3
3
  export { src_default as default, esbuild, rollup, unplugin, unpluginFactory, vite, webpack };
package/dist/nuxt.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./src-CskmyrvV.js";
2
- import { vite_default } from "./vite-B3qRJmDz.js";
3
- import { webpack_default } from "./webpack-Do7Ul9CV.js";
1
+ import "./src-BKy9tiI6.js";
2
+ import { vite_default } from "./vite-gMMORSxX.js";
3
+ import { webpack_default } from "./webpack-BsOsB8pU.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,7 +1,7 @@
1
1
  import { Options } from "./types-BVbGtSvv.js";
2
- import * as rollup1 from "rollup";
2
+ import * as rollup0 from "rollup";
3
3
 
4
4
  //#region src/rollup.d.ts
5
- declare const _default: (options?: Options | undefined) => rollup1.Plugin<any> | rollup1.Plugin<any>[];
5
+ declare const _default: (options?: Options | undefined) => rollup0.Plugin<any> | rollup0.Plugin<any>[];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/rollup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-CskmyrvV.js";
1
+ import { unpluginFactory } from "./src-BKy9tiI6.js";
2
2
  import { createRollupPlugin } from "unplugin";
3
3
 
4
4
  //#region src/rollup.ts
package/dist/rspack.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-CskmyrvV.js";
1
+ import { unpluginFactory } from "./src-BKy9tiI6.js";
2
2
  import { createRspackPlugin } from "unplugin";
3
3
 
4
4
  //#region src/rspack.ts
@@ -1566,7 +1566,10 @@ function generateInterfaces(opts) {
1566
1566
  const interfaces = [];
1567
1567
  for (const file of files) {
1568
1568
  const filePath = path.join(interfaceDir, file);
1569
- const names = [...fs.readFileSync(filePath, "utf-8").matchAll(/export\s+interface\s+(\w+)/g)].map((m) => m[1]);
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
1573
  if (names.length) interfaces.push({
1571
1574
  file,
1572
1575
  names
@@ -1585,6 +1588,10 @@ function generateInterfaces(opts) {
1585
1588
  ];
1586
1589
  fs.mkdirSync(path.dirname(outputFile), { recursive: true });
1587
1590
  fs.writeFileSync(outputFile, globalLines.join("\n"), "utf-8");
1591
+ return {
1592
+ files: files.length,
1593
+ interfaces: interfaces.flatMap((i) => i.names).length
1594
+ };
1588
1595
  }
1589
1596
 
1590
1597
  //#endregion
@@ -1603,18 +1610,22 @@ function resolveOptions(root, options = {}) {
1603
1610
  //#region src/index.ts
1604
1611
  const unpluginFactory = (userOptions = {}, meta) => {
1605
1612
  const opts = resolveOptions(meta.framework === "vite" ? meta?.vite?.server?.config?.root ?? process.cwd() : process.cwd(), userOptions);
1606
- const generate = () => generateInterfaces(opts);
1607
1613
  return {
1608
1614
  name: "@supsign/unplugin-interfaces",
1609
1615
  buildStart() {
1610
- generate();
1616
+ const result = generateInterfaces(opts);
1617
+ this.info(`Generated ${result.interfaces} interfaces from ${result.files} files`);
1611
1618
  },
1612
1619
  vite: { configureServer(server) {
1613
1620
  const watcher = esm_default.watch(opts.interfaceDir, {
1614
1621
  ignored: (filePath) => filePath.endsWith("index.ts") || filePath.endsWith(".d.ts") || [...opts.excludeFiles].some((f) => filePath.endsWith(f)),
1615
1622
  ignoreInitial: true
1616
1623
  });
1617
- watcher.on("add", generate).on("change", generate).on("unlink", generate);
1624
+ const log = (action) => {
1625
+ const result = generateInterfaces(opts);
1626
+ server.config.logger.info(`${action}: ${result.interfaces} interfaces from ${result.files} files`, { timestamp: true });
1627
+ };
1628
+ watcher.on("add", () => log("Added file, regenerated")).on("change", () => log("Updated file, regenerated")).on("unlink", () => log("Removed file, regenerated"));
1618
1629
  server.watcher.on("close", () => watcher.close());
1619
1630
  } },
1620
1631
  transformInclude(id) {
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-CskmyrvV.js";
1
+ import { unpluginFactory } from "./src-BKy9tiI6.js";
2
2
  import { createVitePlugin } from "unplugin";
3
3
 
4
4
  //#region src/vite.ts
package/dist/vite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./types-BVbGtSvv.js";
2
- import * as vite1 from "vite";
2
+ import * as vite0 from "vite";
3
3
 
4
4
  //#region src/vite.d.ts
5
- declare const _default: (options?: Options | undefined) => vite1.Plugin<any> | vite1.Plugin<any>[];
5
+ declare const _default: (options?: Options | undefined) => vite0.Plugin<any> | vite0.Plugin<any>[];
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./src-CskmyrvV.js";
2
- import { vite_default } from "./vite-B3qRJmDz.js";
1
+ import "./src-BKy9tiI6.js";
2
+ import { vite_default } from "./vite-gMMORSxX.js";
3
3
 
4
4
  export { vite_default as default };
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-CskmyrvV.js";
1
+ import { unpluginFactory } from "./src-BKy9tiI6.js";
2
2
  import { createWebpackPlugin } from "unplugin";
3
3
 
4
4
  //#region src/webpack.ts
package/dist/webpack.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./src-CskmyrvV.js";
2
- import { webpack_default } from "./webpack-Do7Ul9CV.js";
1
+ import "./src-BKy9tiI6.js";
2
+ import { webpack_default } from "./webpack-BsOsB8pU.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.1.0",
4
+ "version": "0.2.0",
5
5
  "packageManager": "pnpm@10.18.3",
6
6
  "description": "",
7
7
  "license": "MIT",