@supsign/unplugin-interfaces 0.1.1 → 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 +1 -1
- package/dist/astro.js +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.d.ts +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +3 -3
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{src-DyBB0CwK.js → src-xDGsFk9F.js} +13 -10
- package/dist/{types-BVbGtSvv.d.ts → types-DTqFymcy.d.ts} +0 -1
- package/dist/types.d.ts +1 -1
- package/dist/{vite-Bc6kO4Bd.js → vite-DJyRlrtA.js} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/dist/{webpack-7x38_B5C.js → webpack-Jk_mUGu2.js} +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +2 -2
- package/package.json +13 -11
package/dist/astro.d.ts
CHANGED
package/dist/astro.js
CHANGED
package/dist/esbuild.d.ts
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/farm.d.ts
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.d.ts
CHANGED
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-xDGsFk9F.js";
|
|
2
2
|
|
|
3
3
|
export { src_default as default, esbuild, rollup, unplugin, unpluginFactory, vite, webpack };
|
package/dist/nuxt.d.ts
CHANGED
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-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
package/dist/rollup.js
CHANGED
package/dist/rspack.d.ts
CHANGED
package/dist/rspack.js
CHANGED
|
@@ -1561,24 +1561,29 @@ var esm_default = {
|
|
|
1561
1561
|
//#endregion
|
|
1562
1562
|
//#region src/core/generator.ts
|
|
1563
1563
|
function generateInterfaces(opts) {
|
|
1564
|
-
const { interfaceDir,
|
|
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
|
-
const
|
|
1569
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
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");
|
|
1570
1579
|
if (names.length) interfaces.push({
|
|
1571
1580
|
file,
|
|
1572
1581
|
names
|
|
1573
1582
|
});
|
|
1574
1583
|
}
|
|
1575
|
-
const exportLines = interfaces.map((i) => `export * from './${path.basename(i.file, ".ts")}';`);
|
|
1576
|
-
fs.writeFileSync(indexFile, exportLines.join("\n"), "utf-8");
|
|
1577
1584
|
const globalLines = [
|
|
1578
|
-
`import type * as Interfaces from '../interfaces';`,
|
|
1579
|
-
"",
|
|
1580
1585
|
"declare global {",
|
|
1581
|
-
...interfaces.flatMap((i) => i.names.map((name) => `
|
|
1586
|
+
...interfaces.flatMap((i) => i.names.map((name) => ` type ${name} = import('../interfaces/${path.basename(i.file, ".ts")}').${name};`)),
|
|
1582
1587
|
"}",
|
|
1583
1588
|
"",
|
|
1584
1589
|
"export {};"
|
|
@@ -1594,10 +1599,8 @@ function generateInterfaces(opts) {
|
|
|
1594
1599
|
//#endregion
|
|
1595
1600
|
//#region src/core/paths.ts
|
|
1596
1601
|
function resolveOptions(root, options = {}) {
|
|
1597
|
-
const interfaceDir = path.resolve(root, options.dir ?? "resources/js/interfaces");
|
|
1598
1602
|
return {
|
|
1599
|
-
interfaceDir,
|
|
1600
|
-
indexFile: path.join(interfaceDir, "index.ts"),
|
|
1603
|
+
interfaceDir: path.resolve(root, options.dir ?? "resources/js/interfaces"),
|
|
1601
1604
|
outputFile: path.resolve(root, options.out ?? "resources/js/types/interfaces.d.ts"),
|
|
1602
1605
|
excludeFiles: new Set(options.exclude ?? [])
|
|
1603
1606
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Options, ResolvedOptions } from "./types-
|
|
1
|
+
import { Options, ResolvedOptions } from "./types-DTqFymcy.js";
|
|
2
2
|
export { Options, ResolvedOptions };
|
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
package/dist/webpack.d.ts
CHANGED
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supsign/unplugin-interfaces",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"packageManager": "pnpm@10.18.3",
|
|
5
6
|
"description": "",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"homepage": "https://github.com/supsign/unplugin-interfaces#readme",
|
|
@@ -46,6 +47,16 @@
|
|
|
46
47
|
"files": [
|
|
47
48
|
"dist"
|
|
48
49
|
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsdown",
|
|
52
|
+
"dev": "tsdown -w",
|
|
53
|
+
"lint": "eslint .",
|
|
54
|
+
"play": "npm -C playground run dev",
|
|
55
|
+
"prepublishOnly": "npm run build",
|
|
56
|
+
"release": "bumpp && pnpm publish",
|
|
57
|
+
"start": "tsx src/index.ts",
|
|
58
|
+
"test": "vitest"
|
|
59
|
+
},
|
|
49
60
|
"peerDependencies": {
|
|
50
61
|
"@farmfe/core": ">=1",
|
|
51
62
|
"@nuxt/kit": "^3",
|
|
@@ -97,14 +108,5 @@
|
|
|
97
108
|
"vite": "^6.4.0",
|
|
98
109
|
"vitest": "^3.2.4",
|
|
99
110
|
"webpack": "^5.102.1"
|
|
100
|
-
},
|
|
101
|
-
"scripts": {
|
|
102
|
-
"build": "tsdown",
|
|
103
|
-
"dev": "tsdown -w",
|
|
104
|
-
"lint": "eslint .",
|
|
105
|
-
"play": "npm -C playground run dev",
|
|
106
|
-
"release": "bumpp && pnpm publish",
|
|
107
|
-
"start": "tsx src/index.ts",
|
|
108
|
-
"test": "vitest"
|
|
109
111
|
}
|
|
110
|
-
}
|
|
112
|
+
}
|