@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 +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/nuxt.js +3 -3
- package/dist/rollup.d.ts +2 -2
- package/dist/rollup.js +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{src-CskmyrvV.js → src-BKy9tiI6.js} +15 -4
- package/dist/{vite-B3qRJmDz.js → vite-gMMORSxX.js} +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +2 -2
- package/dist/{webpack-Do7Ul9CV.js → webpack-BsOsB8pU.js} +1 -1
- package/dist/webpack.js +2 -2
- package/package.json +1 -1
package/dist/astro.js
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/farm.js
CHANGED
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
|
|
6
|
-
import * as
|
|
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) =>
|
|
13
|
-
declare const rollup: (options?: Options | undefined) =>
|
|
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-
|
|
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-
|
|
2
|
-
import { vite_default } from "./vite-
|
|
3
|
-
import { webpack_default } from "./webpack-
|
|
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
|
|
2
|
+
import * as rollup0 from "rollup";
|
|
3
3
|
|
|
4
4
|
//#region src/rollup.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
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
package/dist/rspack.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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) {
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options } from "./types-BVbGtSvv.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vite0 from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/vite.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
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
package/dist/webpack.js
CHANGED