@supsign/unplugin-interfaces 1.1.1 → 1.1.2
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.mjs +1 -1
- package/dist/esbuild.mjs +1 -1
- package/dist/farm.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/nuxt.mjs +1 -1
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{src-BBWM3Bz4.mjs → src-75zMdGMB.mjs} +37 -27
- package/dist/vite.mjs +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +120 -122
package/dist/astro.mjs
CHANGED
package/dist/esbuild.mjs
CHANGED
package/dist/farm.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as vite, i as unpluginFactory, n as rollup, o as webpack, r as unplugin, t as esbuild } from "./src-
|
|
1
|
+
import { a as vite, i as unpluginFactory, n as rollup, o as webpack, r as unplugin, t as esbuild } from "./src-75zMdGMB.mjs";
|
|
2
2
|
export { unplugin as default, unplugin, esbuild, rollup, unpluginFactory, vite, webpack };
|
package/dist/nuxt.mjs
CHANGED
package/dist/rollup.mjs
CHANGED
package/dist/rspack.mjs
CHANGED
|
@@ -1603,22 +1603,31 @@ const RE_INTERFACE = /^export\s+interface\s+([A-Za-z_$][\w$]*)/gm;
|
|
|
1603
1603
|
const RE_NAMED_EXPORT = /export\s*\{([^}]+)\}/g;
|
|
1604
1604
|
const RE_TYPE_EXPORT = /export\s+type\s*\{([^}]+)\}/g;
|
|
1605
1605
|
const RE_AS_SPLIT = /\s+as\s+/;
|
|
1606
|
-
function
|
|
1606
|
+
function parseNames(content) {
|
|
1607
|
+
const interfaceNames = [...content.matchAll(RE_INTERFACE)].map((match) => match[1]);
|
|
1608
|
+
const namedExportNames = [...content.matchAll(RE_NAMED_EXPORT)].filter((match) => !content.substring(Math.max(0, match.index - 10), match.index).includes("type")).flatMap((match) => match[1].split(",").map((item) => item.trim().split(RE_AS_SPLIT)[0].trim()).filter((name) => name.length > 0));
|
|
1609
|
+
const typeExportNames = [...content.matchAll(RE_TYPE_EXPORT)].flatMap((match) => match[1].split(",").map((item) => item.trim().split(RE_AS_SPLIT)[0].trim()).filter((name) => name.length > 0));
|
|
1610
|
+
return [...new Set([
|
|
1611
|
+
...interfaceNames,
|
|
1612
|
+
...namedExportNames,
|
|
1613
|
+
...typeExportNames
|
|
1614
|
+
])].filter((name) => name && name !== "export");
|
|
1615
|
+
}
|
|
1616
|
+
async function generateInterfaces(opts) {
|
|
1607
1617
|
const { interfaceDir, outputFile, excludeFiles } = opts;
|
|
1608
|
-
const files = fs.
|
|
1618
|
+
const files = (await fs.promises.readdir(interfaceDir)).filter((file) => file.endsWith(".ts") && file !== "index.ts" && !excludeFiles.has(file));
|
|
1619
|
+
try {
|
|
1620
|
+
const outputMtime = (await fs.promises.stat(outputFile)).mtimeMs;
|
|
1621
|
+
if ((await Promise.all(files.map((file) => fs.promises.stat(path.join(interfaceDir, file)).then((stat) => stat.mtimeMs)))).every((mtime) => mtime <= outputMtime)) return {
|
|
1622
|
+
files: files.length,
|
|
1623
|
+
interfaces: 0,
|
|
1624
|
+
skipped: true
|
|
1625
|
+
};
|
|
1626
|
+
} catch {}
|
|
1627
|
+
const contents = await Promise.all(files.map((file) => fs.promises.readFile(path.join(interfaceDir, file), "utf8")));
|
|
1609
1628
|
const interfaces = [];
|
|
1610
|
-
for (const file of files) {
|
|
1611
|
-
const
|
|
1612
|
-
const content = fs.readFileSync(filePath, "utf8");
|
|
1613
|
-
const interfaceNames = [...content.matchAll(RE_INTERFACE)].map((match) => match[1]);
|
|
1614
|
-
const namedExportNames = [...content.matchAll(RE_NAMED_EXPORT)].filter((match) => !content.substring(Math.max(0, match.index - 10), match.index).includes("type")).flatMap((match) => match[1].split(",").map((item) => item.trim().split(RE_AS_SPLIT)[0].trim()).filter((name) => name.length > 0));
|
|
1615
|
-
const typeExportNames = [...content.matchAll(RE_TYPE_EXPORT)].flatMap((match) => match[1].split(",").map((item) => item.trim().split(RE_AS_SPLIT)[0].trim()).filter((name) => name.length > 0));
|
|
1616
|
-
const allNames = [
|
|
1617
|
-
...interfaceNames,
|
|
1618
|
-
...namedExportNames,
|
|
1619
|
-
...typeExportNames
|
|
1620
|
-
];
|
|
1621
|
-
const names = [...new Set(allNames)].filter((name) => name && name !== "export");
|
|
1629
|
+
for (const [idx, file] of files.entries()) {
|
|
1630
|
+
const names = parseNames(contents[idx]);
|
|
1622
1631
|
if (names.length) interfaces.push({
|
|
1623
1632
|
file,
|
|
1624
1633
|
names
|
|
@@ -1632,8 +1641,8 @@ function generateInterfaces(opts) {
|
|
|
1632
1641
|
"export {};",
|
|
1633
1642
|
""
|
|
1634
1643
|
];
|
|
1635
|
-
fs.
|
|
1636
|
-
fs.
|
|
1644
|
+
await fs.promises.mkdir(path.dirname(outputFile), { recursive: true });
|
|
1645
|
+
await fs.promises.writeFile(outputFile, globalLines.join("\n"), "utf8");
|
|
1637
1646
|
return {
|
|
1638
1647
|
files: files.length,
|
|
1639
1648
|
interfaces: interfaces.flatMap((iface) => iface.names).length
|
|
@@ -1652,30 +1661,31 @@ function resolveOptions(root, options = {}) {
|
|
|
1652
1661
|
//#region src/index.ts
|
|
1653
1662
|
const unpluginFactory = (userOptions = {}, meta) => {
|
|
1654
1663
|
const opts = resolveOptions(meta.framework === "vite" ? meta?.vite?.server?.config?.root ?? process$1.cwd() : process$1.cwd(), userOptions);
|
|
1664
|
+
let isDevServer = false;
|
|
1655
1665
|
return {
|
|
1656
1666
|
name: "@supsign/unplugin-interfaces",
|
|
1657
|
-
buildStart() {
|
|
1658
|
-
|
|
1667
|
+
async buildStart() {
|
|
1668
|
+
if (isDevServer) return;
|
|
1669
|
+
const result = await generateInterfaces(opts);
|
|
1659
1670
|
this.info(`Generated ${result.interfaces} interfaces from ${result.files} files`);
|
|
1660
1671
|
},
|
|
1661
1672
|
vite: { configureServer(server) {
|
|
1673
|
+
isDevServer = true;
|
|
1674
|
+
generateInterfaces(opts).then((result) => {
|
|
1675
|
+
server.config.logger.info(`@supsign/unplugin-interfaces: Generated ${result.interfaces} interfaces from ${result.files} files`, { timestamp: true });
|
|
1676
|
+
});
|
|
1662
1677
|
const watcher = chokidar_default.watch(opts.interfaceDir, {
|
|
1663
1678
|
ignored: (filePath) => filePath.endsWith("index.ts") || filePath.endsWith(".d.ts") || [...opts.excludeFiles].some((filename) => filePath.endsWith(filename)),
|
|
1664
1679
|
ignoreInitial: true
|
|
1665
1680
|
});
|
|
1666
1681
|
const log = (action) => {
|
|
1667
|
-
|
|
1668
|
-
|
|
1682
|
+
generateInterfaces(opts).then((result) => {
|
|
1683
|
+
server.config.logger.info(`${action}: ${result.interfaces} interfaces from ${result.files} files`, { timestamp: true });
|
|
1684
|
+
});
|
|
1669
1685
|
};
|
|
1670
1686
|
watcher.on("add", () => log("Added file, regenerated")).on("change", () => log("Updated file, regenerated")).on("unlink", () => log("Removed file, regenerated"));
|
|
1671
1687
|
server.watcher.on("close", () => watcher.close());
|
|
1672
|
-
} }
|
|
1673
|
-
transformInclude(id) {
|
|
1674
|
-
return id.endsWith("main.ts");
|
|
1675
|
-
},
|
|
1676
|
-
transform(code) {
|
|
1677
|
-
return code.replace("__UNPLUGIN__", "Hello Unplugin!");
|
|
1678
|
-
}
|
|
1688
|
+
} }
|
|
1679
1689
|
};
|
|
1680
1690
|
};
|
|
1681
1691
|
const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
package/dist/vite.mjs
CHANGED
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,122 +1,120 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@supsign/unplugin-interfaces",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"rollup",
|
|
7
|
-
"transform",
|
|
8
|
-
"unplugin",
|
|
9
|
-
"vite",
|
|
10
|
-
"webpack"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://github.com/supsign/unplugin-interfaces#readme",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/supsign/unplugin-interfaces/issues"
|
|
15
|
-
},
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/supsign/unplugin-interfaces.git"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
|
-
"type": "module",
|
|
25
|
-
"main": "./dist/index.mjs",
|
|
26
|
-
"module": "./dist/index.mjs",
|
|
27
|
-
"types": "./dist/index.d.mts",
|
|
28
|
-
"typesVersions": {
|
|
29
|
-
"*": {
|
|
30
|
-
"*": [
|
|
31
|
-
"./dist/*",
|
|
32
|
-
"./*"
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"exports": {
|
|
37
|
-
".": "./dist/index.mjs",
|
|
38
|
-
"./astro": "./dist/astro.mjs",
|
|
39
|
-
"./esbuild": "./dist/esbuild.mjs",
|
|
40
|
-
"./farm": "./dist/farm.mjs",
|
|
41
|
-
"./nuxt": "./dist/nuxt.mjs",
|
|
42
|
-
"./rollup": "./dist/rollup.mjs",
|
|
43
|
-
"./rspack": "./dist/rspack.mjs",
|
|
44
|
-
"./types": "./dist/types.mjs",
|
|
45
|
-
"./vite": "./dist/vite.mjs",
|
|
46
|
-
"./webpack": "./dist/webpack.mjs",
|
|
47
|
-
"./package.json": "./package.json"
|
|
48
|
-
},
|
|
49
|
-
"publishConfig": {
|
|
50
|
-
"access": "public"
|
|
51
|
-
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"@
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
"optional": true
|
|
97
|
-
},
|
|
98
|
-
"
|
|
99
|
-
"optional": true
|
|
100
|
-
},
|
|
101
|
-
"
|
|
102
|
-
"optional": true
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"packageManager": "pnpm@10.18.3"
|
|
122
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@supsign/unplugin-interfaces",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rollup",
|
|
7
|
+
"transform",
|
|
8
|
+
"unplugin",
|
|
9
|
+
"vite",
|
|
10
|
+
"webpack"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/supsign/unplugin-interfaces#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/supsign/unplugin-interfaces/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/supsign/unplugin-interfaces.git"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.mjs",
|
|
26
|
+
"module": "./dist/index.mjs",
|
|
27
|
+
"types": "./dist/index.d.mts",
|
|
28
|
+
"typesVersions": {
|
|
29
|
+
"*": {
|
|
30
|
+
"*": [
|
|
31
|
+
"./dist/*",
|
|
32
|
+
"./*"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
".": "./dist/index.mjs",
|
|
38
|
+
"./astro": "./dist/astro.mjs",
|
|
39
|
+
"./esbuild": "./dist/esbuild.mjs",
|
|
40
|
+
"./farm": "./dist/farm.mjs",
|
|
41
|
+
"./nuxt": "./dist/nuxt.mjs",
|
|
42
|
+
"./rollup": "./dist/rollup.mjs",
|
|
43
|
+
"./rspack": "./dist/rspack.mjs",
|
|
44
|
+
"./types": "./dist/types.mjs",
|
|
45
|
+
"./vite": "./dist/vite.mjs",
|
|
46
|
+
"./webpack": "./dist/webpack.mjs",
|
|
47
|
+
"./package.json": "./package.json"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"unplugin": "^3.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@nuxt/kit": "^4.4.2",
|
|
57
|
+
"@nuxt/schema": "^4.4.2",
|
|
58
|
+
"@types/node": "^25.5.0",
|
|
59
|
+
"bumpp": "^11.0.1",
|
|
60
|
+
"chokidar": "^5.0.0",
|
|
61
|
+
"esbuild": "^0.27.0",
|
|
62
|
+
"nodemon": "^3.1.14",
|
|
63
|
+
"oxfmt": "^0.40.0",
|
|
64
|
+
"oxlint": "^1.55.0",
|
|
65
|
+
"rollup": "^4.59.0",
|
|
66
|
+
"tsdown": "^0.21.3",
|
|
67
|
+
"tsx": "^4.21.0",
|
|
68
|
+
"typescript": "^5.9.3",
|
|
69
|
+
"vite": "^8.0.0",
|
|
70
|
+
"vitest": "^4.1.0",
|
|
71
|
+
"webpack": "^5.105.4"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"@farmfe/core": ">=1",
|
|
75
|
+
"@nuxt/kit": "^3",
|
|
76
|
+
"@nuxt/schema": "^3",
|
|
77
|
+
"esbuild": "*",
|
|
78
|
+
"rollup": "^3 || ^4",
|
|
79
|
+
"vite": ">=3",
|
|
80
|
+
"webpack": "^4 || ^5"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"@farmfe/core": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
86
|
+
"@nuxt/kit": {
|
|
87
|
+
"optional": true
|
|
88
|
+
},
|
|
89
|
+
"@nuxt/schema": {
|
|
90
|
+
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"esbuild": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"rollup": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"vite": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"webpack": {
|
|
102
|
+
"optional": true
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"overrides": {
|
|
106
|
+
"esbuild": "^0.27.0",
|
|
107
|
+
"vite": "^8.0.0"
|
|
108
|
+
},
|
|
109
|
+
"scripts": {
|
|
110
|
+
"build": "tsdown",
|
|
111
|
+
"dev": "tsdown -w",
|
|
112
|
+
"format": "oxfmt .",
|
|
113
|
+
"format:check": "oxfmt --check .",
|
|
114
|
+
"lint": "oxlint .",
|
|
115
|
+
"play": "npm -C playground run dev",
|
|
116
|
+
"release": "bumpp && pnpm publish",
|
|
117
|
+
"start": "tsx src/index.ts",
|
|
118
|
+
"test": "vitest"
|
|
119
|
+
}
|
|
120
|
+
}
|