unplugin-kubb 3.2.0 → 4.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.cjs +1 -1
- package/dist/astro.d.cts +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/{chunk-BybIe9x4.js → chunk-Bwj0kw0m.js} +10 -6
- package/dist/esbuild.cjs +1 -2
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +3 -4
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +1 -2
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +1 -2
- package/dist/rspack.cjs.map +1 -1
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/src-CV35pUck.cjs +116 -0
- package/dist/src-CV35pUck.cjs.map +1 -0
- package/dist/src-wEqIY2rq.js +65 -0
- package/dist/src-wEqIY2rq.js.map +1 -0
- package/dist/{types-Bt9ZCbPy.d.ts → types-BNmRHGEx.d.cts} +24 -36
- package/dist/{types-DpTGv8q2.d.cts → types-D54bCl1u.d.ts} +24 -36
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{vite-CEW_QLtL.js → vite-DkSw2hsC.js} +2 -2
- package/dist/{vite-CEW_QLtL.js.map → vite-DkSw2hsC.js.map} +1 -1
- package/dist/{vite-Df2FT-jf.cjs → vite-DruCA3WT.cjs} +2 -3
- package/dist/{vite-Df2FT-jf.cjs.map → vite-DruCA3WT.cjs.map} +1 -1
- package/dist/vite.cjs +2 -2
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/dist/{webpack-D2VoiCsm.cjs → webpack-NglPEtfi.cjs} +2 -3
- package/dist/{webpack-D2VoiCsm.cjs.map → webpack-NglPEtfi.cjs.map} +1 -1
- package/dist/{webpack-gtaz7qKH.js → webpack-kTaImLW0.js} +2 -2
- package/dist/{webpack-gtaz7qKH.js.map → webpack-kTaImLW0.js.map} +1 -1
- package/dist/webpack.cjs +2 -2
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +2 -2
- package/package.json +8 -8
- package/src/index.ts +65 -43
- package/dist/src-Dn-CzqNK.js +0 -50
- package/dist/src-Dn-CzqNK.js.map +0 -1
- package/dist/src-INEri0Ub.cjs +0 -99
- package/dist/src-INEri0Ub.cjs.map +0 -1
package/dist/astro.cjs
CHANGED
package/dist/astro.d.cts
CHANGED
package/dist/astro.d.ts
CHANGED
package/dist/astro.js
CHANGED
|
@@ -8,12 +8,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
+
key = keys[i];
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
15
|
+
__defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
return to;
|
|
19
23
|
};
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_src = require('./src-
|
|
1
|
+
const require_src = require('./src-CV35pUck.cjs');
|
|
2
2
|
let unplugin = require("unplugin");
|
|
3
|
-
unplugin = require_src.__toESM(unplugin);
|
|
4
3
|
|
|
5
4
|
//#region src/esbuild.ts
|
|
6
5
|
var esbuild_default = (0, unplugin.createEsbuildPlugin)(require_src.unpluginFactory);
|
package/dist/esbuild.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.cjs","names":["unpluginFactory"],"sources":["../src/esbuild.ts"],"sourcesContent":["import { createEsbuildPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './index.ts'\n\nexport default createEsbuildPlugin(unpluginFactory)\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"esbuild.cjs","names":["unpluginFactory"],"sources":["../src/esbuild.ts"],"sourcesContent":["import { createEsbuildPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './index.ts'\n\nexport default createEsbuildPlugin(unpluginFactory)\n"],"mappings":";;;;AAIA,wDAAmCA,4BAAgB"}
|
package/dist/esbuild.d.cts
CHANGED
package/dist/esbuild.d.ts
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as Options } from "./types-
|
|
2
|
-
import * as
|
|
1
|
+
import { t as Options } from "./types-D54bCl1u.js";
|
|
2
|
+
import * as unplugin1 from "unplugin";
|
|
3
3
|
import { UnpluginFactory } from "unplugin";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
declare const unpluginFactory: UnpluginFactory<Options | undefined>;
|
|
7
|
-
declare const unplugin:
|
|
7
|
+
declare const unplugin: unplugin1.UnpluginInstance<Options | undefined, boolean>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { unplugin as default, unplugin, unpluginFactory };
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const require_src = require('./src-
|
|
2
|
-
const require_vite = require('./vite-
|
|
3
|
-
const require_webpack = require('./webpack-
|
|
1
|
+
const require_src = require('./src-CV35pUck.cjs');
|
|
2
|
+
const require_vite = require('./vite-DruCA3WT.cjs');
|
|
3
|
+
const require_webpack = require('./webpack-NglPEtfi.cjs');
|
|
4
4
|
let __nuxt_kit = require("@nuxt/kit");
|
|
5
|
-
__nuxt_kit = require_src.__toESM(__nuxt_kit);
|
|
6
5
|
require("@nuxt/schema");
|
|
7
6
|
|
|
8
7
|
//#region src/nuxt.ts
|
package/dist/nuxt.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nuxt.cjs","names":["vite","webpack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport type { Options } from './types.ts'\nimport vite from './vite.ts'\nimport webpack from './webpack.ts'\n\nexport interface ModuleOptions extends Options {}\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: 'nuxt-unplugin-starter',\n configKey: 'unpluginStarter',\n },\n defaults: undefined,\n setup(options, _nuxt) {\n addVitePlugin(() => vite(options))\n addWebpackPlugin(() => webpack(options))\n\n // ...\n },\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"nuxt.cjs","names":["vite","webpack"],"sources":["../src/nuxt.ts"],"sourcesContent":["import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit'\nimport '@nuxt/schema'\n\nimport type { Options } from './types.ts'\nimport vite from './vite.ts'\nimport webpack from './webpack.ts'\n\nexport interface ModuleOptions extends Options {}\n\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: 'nuxt-unplugin-starter',\n configKey: 'unpluginStarter',\n },\n defaults: undefined,\n setup(options, _nuxt) {\n addVitePlugin(() => vite(options))\n addWebpackPlugin(() => webpack(options))\n\n // ...\n },\n})\n"],"mappings":";;;;;;;AASA,oDAA+C;CAC7C,MAAM;EACJ,MAAM;EACN,WAAW;EACZ;CACD,UAAU;CACV,MAAM,SAAS,OAAO;AACpB,sCAAoBA,0BAAK,QAAQ,CAAC;AAClC,yCAAuBC,gCAAQ,QAAQ,CAAC;;CAI3C,CAAC"}
|
package/dist/nuxt.d.cts
CHANGED
package/dist/nuxt.d.ts
CHANGED
package/dist/nuxt.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./src-
|
|
2
|
-
import { t as vite_default } from "./vite-
|
|
3
|
-
import { t as webpack_default } from "./webpack-
|
|
1
|
+
import "./src-wEqIY2rq.js";
|
|
2
|
+
import { t as vite_default } from "./vite-DkSw2hsC.js";
|
|
3
|
+
import { t as webpack_default } from "./webpack-kTaImLW0.js";
|
|
4
4
|
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
|
5
5
|
import "@nuxt/schema";
|
|
6
6
|
|
package/dist/rollup.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_src = require('./src-
|
|
1
|
+
const require_src = require('./src-CV35pUck.cjs');
|
|
2
2
|
let unplugin = require("unplugin");
|
|
3
|
-
unplugin = require_src.__toESM(unplugin);
|
|
4
3
|
|
|
5
4
|
//#region src/rollup.ts
|
|
6
5
|
var rollup_default = (0, unplugin.createRollupPlugin)(require_src.unpluginFactory);
|
package/dist/rollup.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.cjs","names":["unpluginFactory"],"sources":["../src/rollup.ts"],"sourcesContent":["import { createRollupPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './index.ts'\n\nexport default createRollupPlugin(unpluginFactory)\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rollup.cjs","names":["unpluginFactory"],"sources":["../src/rollup.ts"],"sourcesContent":["import { createRollupPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './index.ts'\n\nexport default createRollupPlugin(unpluginFactory)\n"],"mappings":";;;;AAIA,sDAAkCA,4BAAgB"}
|
package/dist/rollup.d.cts
CHANGED
package/dist/rollup.d.ts
CHANGED
package/dist/rollup.js
CHANGED
package/dist/rspack.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_src = require('./src-
|
|
1
|
+
const require_src = require('./src-CV35pUck.cjs');
|
|
2
2
|
let unplugin = require("unplugin");
|
|
3
|
-
unplugin = require_src.__toESM(unplugin);
|
|
4
3
|
|
|
5
4
|
//#region src/rspack.ts
|
|
6
5
|
var rspack_default = (0, unplugin.createRspackPlugin)(require_src.unpluginFactory);
|
package/dist/rspack.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rspack.cjs","names":["unpluginFactory"],"sources":["../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './index.ts'\n\nexport default createRspackPlugin(unpluginFactory)\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rspack.cjs","names":["unpluginFactory"],"sources":["../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin'\n\nimport { unpluginFactory } from './index.ts'\n\nexport default createRspackPlugin(unpluginFactory)\n"],"mappings":";;;;AAIA,sDAAkCA,4BAAgB"}
|
package/dist/rspack.d.cts
CHANGED
package/dist/rspack.d.ts
CHANGED
package/dist/rspack.js
CHANGED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let node_process = require("node:process");
|
|
29
|
+
node_process = __toESM(node_process);
|
|
30
|
+
let __kubb_core = require("@kubb/core");
|
|
31
|
+
let __kubb_core_logger = require("@kubb/core/logger");
|
|
32
|
+
let unplugin = require("unplugin");
|
|
33
|
+
|
|
34
|
+
//#region src/index.ts
|
|
35
|
+
const unpluginFactory = (options, meta) => {
|
|
36
|
+
const name = "unplugin-kubb";
|
|
37
|
+
const logger = (0, __kubb_core_logger.createLogger)({ name });
|
|
38
|
+
const isVite = meta.framework === "vite";
|
|
39
|
+
function setupLogger(viteLogger, rollupCtx) {
|
|
40
|
+
if (viteLogger) {
|
|
41
|
+
logger.on("start", (message) => viteLogger.info(`${name}: ${message}`));
|
|
42
|
+
logger.on("success", (message) => viteLogger.info(`${name}: ${message}`));
|
|
43
|
+
logger.on("warning", (message) => viteLogger.warn(`${name}: ${message}`));
|
|
44
|
+
logger.on("error", (message) => viteLogger.error(`${name}: ${message}`));
|
|
45
|
+
} else if (rollupCtx) {
|
|
46
|
+
logger.on("start", (message) => rollupCtx.warn?.(`${name}: ${message}`));
|
|
47
|
+
logger.on("success", (message) => rollupCtx.warn?.(`${name}: ${message}`));
|
|
48
|
+
logger.on("warning", (message) => rollupCtx.warn?.(`${name}: ${message}`));
|
|
49
|
+
logger.on("error", (message) => {
|
|
50
|
+
rollupCtx.error?.(`${name}: ${message}`) || console.error(`${name}: ${message}`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function runBuild(ctx) {
|
|
55
|
+
if (!options?.config) {
|
|
56
|
+
ctx.error?.(`[${name}] Config is not set`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const { root: _root, ...userConfig } = options.config;
|
|
60
|
+
logger.emit("start", "Building");
|
|
61
|
+
const { error } = await (0, __kubb_core.safeBuild)({
|
|
62
|
+
config: {
|
|
63
|
+
root: node_process.default.cwd(),
|
|
64
|
+
...userConfig,
|
|
65
|
+
output: {
|
|
66
|
+
write: true,
|
|
67
|
+
...userConfig.output
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
logger
|
|
71
|
+
});
|
|
72
|
+
if (error) ctx.error?.(error);
|
|
73
|
+
else logger.emit("success", "Build finished");
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
name,
|
|
77
|
+
enforce: "pre",
|
|
78
|
+
apply: isVite ? "build" : void 0,
|
|
79
|
+
async buildStart() {
|
|
80
|
+
if (!isVite) setupLogger(void 0, this);
|
|
81
|
+
await runBuild(this);
|
|
82
|
+
},
|
|
83
|
+
vite: { configResolved(config) {
|
|
84
|
+
setupLogger(config.logger);
|
|
85
|
+
} }
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const unplugin$1 = /* @__PURE__ */ (0, unplugin.createUnplugin)(unpluginFactory);
|
|
89
|
+
var src_default = unplugin$1;
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
Object.defineProperty(exports, '__toESM', {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () {
|
|
95
|
+
return __toESM;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, 'src_default', {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return src_default;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, 'unplugin', {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () {
|
|
107
|
+
return unplugin$1;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(exports, 'unpluginFactory', {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: function () {
|
|
113
|
+
return unpluginFactory;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=src-CV35pUck.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-CV35pUck.cjs","names":["unpluginFactory: UnpluginFactory<Options | undefined>","process","unplugin"],"sources":["../src/index.ts"],"sourcesContent":["import process from 'node:process'\nimport type { Config } from '@kubb/core'\nimport { safeBuild } from '@kubb/core'\nimport { createLogger } from '@kubb/core/logger'\nimport type { UnpluginFactory } from 'unplugin'\nimport { createUnplugin } from 'unplugin'\nimport type { Logger } from 'vite'\nimport type { Options } from './types.ts'\n\ntype RollupContext = {\n warn?: (message: string) => void\n error?: (message: string | Error) => void\n}\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const logger = createLogger({ name })\n const isVite = meta.framework === 'vite'\n\n function setupLogger(viteLogger?: Logger, rollupCtx?: RollupContext) {\n if (viteLogger) {\n // Vite integration\n logger.on('start', (message: string) => viteLogger.info(`${name}: ${message}`))\n logger.on('success', (message: string) => viteLogger.info(`${name}: ${message}`))\n logger.on('warning', (message: string) => viteLogger.warn(`${name}: ${message}`))\n logger.on('error', (message: string) => viteLogger.error(`${name}: ${message}`))\n } else if (rollupCtx) {\n // Rollup-like bundlers (Rollup, Webpack, Rspack, esbuild, etc.)\n logger.on('start', (message: string) => rollupCtx.warn?.(`${name}: ${message}`))\n logger.on('success', (message: string) => rollupCtx.warn?.(`${name}: ${message}`))\n logger.on('warning', (message: string) => rollupCtx.warn?.(`${name}: ${message}`))\n logger.on('error', (message: string) => {\n rollupCtx.error?.(`${name}: ${message}`) || console.error(`${name}: ${message}`)\n })\n }\n }\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ctx.error?.(`[${name}] Config is not set`)\n return\n }\n\n const { root: _root, ...userConfig } = options.config as Config\n\n logger.emit('start', 'Building')\n\n const { error } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n if (error) {\n ctx.error?.(error)\n } else {\n logger.emit('success', 'Build finished')\n }\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n\n async buildStart() {\n if (!isVite) {\n setupLogger(undefined, this as unknown as RollupContext)\n }\n await runBuild(this as unknown as RollupContext)\n },\n\n vite: {\n configResolved(config) {\n setupLogger(config.logger)\n },\n },\n }\n}\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory)\n\nexport default unplugin\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAaA,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,8CAAsB,EAAE,MAAM,CAAC;CACrC,MAAM,SAAS,KAAK,cAAc;CAElC,SAAS,YAAY,YAAqB,WAA2B;AACnE,MAAI,YAAY;AAEd,UAAO,GAAG,UAAU,YAAoB,WAAW,KAAK,GAAG,KAAK,I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2B,6CAAe,gBAAgB;AAEvE,kBAAeA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { safeBuild } from "@kubb/core";
|
|
3
|
+
import { createLogger } from "@kubb/core/logger";
|
|
4
|
+
import { createUnplugin } from "unplugin";
|
|
5
|
+
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
const unpluginFactory = (options, meta) => {
|
|
8
|
+
const name = "unplugin-kubb";
|
|
9
|
+
const logger = createLogger({ name });
|
|
10
|
+
const isVite = meta.framework === "vite";
|
|
11
|
+
function setupLogger(viteLogger, rollupCtx) {
|
|
12
|
+
if (viteLogger) {
|
|
13
|
+
logger.on("start", (message) => viteLogger.info(`${name}: ${message}`));
|
|
14
|
+
logger.on("success", (message) => viteLogger.info(`${name}: ${message}`));
|
|
15
|
+
logger.on("warning", (message) => viteLogger.warn(`${name}: ${message}`));
|
|
16
|
+
logger.on("error", (message) => viteLogger.error(`${name}: ${message}`));
|
|
17
|
+
} else if (rollupCtx) {
|
|
18
|
+
logger.on("start", (message) => rollupCtx.warn?.(`${name}: ${message}`));
|
|
19
|
+
logger.on("success", (message) => rollupCtx.warn?.(`${name}: ${message}`));
|
|
20
|
+
logger.on("warning", (message) => rollupCtx.warn?.(`${name}: ${message}`));
|
|
21
|
+
logger.on("error", (message) => {
|
|
22
|
+
rollupCtx.error?.(`${name}: ${message}`) || console.error(`${name}: ${message}`);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function runBuild(ctx) {
|
|
27
|
+
if (!options?.config) {
|
|
28
|
+
ctx.error?.(`[${name}] Config is not set`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { root: _root, ...userConfig } = options.config;
|
|
32
|
+
logger.emit("start", "Building");
|
|
33
|
+
const { error } = await safeBuild({
|
|
34
|
+
config: {
|
|
35
|
+
root: process.cwd(),
|
|
36
|
+
...userConfig,
|
|
37
|
+
output: {
|
|
38
|
+
write: true,
|
|
39
|
+
...userConfig.output
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
logger
|
|
43
|
+
});
|
|
44
|
+
if (error) ctx.error?.(error);
|
|
45
|
+
else logger.emit("success", "Build finished");
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
name,
|
|
49
|
+
enforce: "pre",
|
|
50
|
+
apply: isVite ? "build" : void 0,
|
|
51
|
+
async buildStart() {
|
|
52
|
+
if (!isVite) setupLogger(void 0, this);
|
|
53
|
+
await runBuild(this);
|
|
54
|
+
},
|
|
55
|
+
vite: { configResolved(config) {
|
|
56
|
+
setupLogger(config.logger);
|
|
57
|
+
} }
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
61
|
+
var src_default = unplugin;
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { unplugin as n, unpluginFactory as r, src_default as t };
|
|
65
|
+
//# sourceMappingURL=src-wEqIY2rq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-wEqIY2rq.js","names":["unpluginFactory: UnpluginFactory<Options | undefined>"],"sources":["../src/index.ts"],"sourcesContent":["import process from 'node:process'\nimport type { Config } from '@kubb/core'\nimport { safeBuild } from '@kubb/core'\nimport { createLogger } from '@kubb/core/logger'\nimport type { UnpluginFactory } from 'unplugin'\nimport { createUnplugin } from 'unplugin'\nimport type { Logger } from 'vite'\nimport type { Options } from './types.ts'\n\ntype RollupContext = {\n warn?: (message: string) => void\n error?: (message: string | Error) => void\n}\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const logger = createLogger({ name })\n const isVite = meta.framework === 'vite'\n\n function setupLogger(viteLogger?: Logger, rollupCtx?: RollupContext) {\n if (viteLogger) {\n // Vite integration\n logger.on('start', (message: string) => viteLogger.info(`${name}: ${message}`))\n logger.on('success', (message: string) => viteLogger.info(`${name}: ${message}`))\n logger.on('warning', (message: string) => viteLogger.warn(`${name}: ${message}`))\n logger.on('error', (message: string) => viteLogger.error(`${name}: ${message}`))\n } else if (rollupCtx) {\n // Rollup-like bundlers (Rollup, Webpack, Rspack, esbuild, etc.)\n logger.on('start', (message: string) => rollupCtx.warn?.(`${name}: ${message}`))\n logger.on('success', (message: string) => rollupCtx.warn?.(`${name}: ${message}`))\n logger.on('warning', (message: string) => rollupCtx.warn?.(`${name}: ${message}`))\n logger.on('error', (message: string) => {\n rollupCtx.error?.(`${name}: ${message}`) || console.error(`${name}: ${message}`)\n })\n }\n }\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ctx.error?.(`[${name}] Config is not set`)\n return\n }\n\n const { root: _root, ...userConfig } = options.config as Config\n\n logger.emit('start', 'Building')\n\n const { error } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n logger,\n })\n\n if (error) {\n ctx.error?.(error)\n } else {\n logger.emit('success', 'Build finished')\n }\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n\n async buildStart() {\n if (!isVite) {\n setupLogger(undefined, this as unknown as RollupContext)\n }\n await runBuild(this as unknown as RollupContext)\n },\n\n vite: {\n configResolved(config) {\n setupLogger(config.logger)\n },\n },\n }\n}\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory)\n\nexport default unplugin\n"],"mappings":";;;;;;AAcA,MAAaA,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,SAAS,aAAa,EAAE,MAAM,CAAC;CACrC,MAAM,SAAS,KAAK,cAAc;CAElC,SAAS,YAAY,YAAqB,WAA2B;AACnE,MAAI,YAAY;AAEd,UAAO,GAAG,UAAU,YAAoB,WAAW,KAAK,GAAG,KAAK,IAAI,UAAU,CAAC;AAC/E,UAAO,GAAG,YAAY,YAAoB,WAAW,KAAK,GAAG,KAAK,IAAI,UAAU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from "@kubb/fabric-core/types";
|
|
2
|
-
import { Fabric
|
|
2
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
3
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
4
4
|
|
|
5
5
|
//#region ../core/src/utils/EventEmitter.d.ts
|
|
@@ -54,6 +54,11 @@ type Logger = {
|
|
|
54
54
|
type PossiblePromise<T> = Promise<T> | T;
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region ../core/src/types.d.ts
|
|
57
|
+
declare global {
|
|
58
|
+
namespace Kubb {
|
|
59
|
+
interface PluginContext {}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
57
62
|
/**
|
|
58
63
|
* Config used in `kubb.config.ts`
|
|
59
64
|
*
|
|
@@ -72,7 +77,7 @@ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
|
|
|
72
77
|
/**
|
|
73
78
|
* An array of Kubb plugins used for generation. Each plugin may have additional configurable options (defined within the plugin itself). If a plugin relies on another plugin, an error will occur if the required dependency is missing. Refer to “pre” for more details.
|
|
74
79
|
*/
|
|
75
|
-
plugins?: Array<Omit<UnknownUserPlugin, '
|
|
80
|
+
plugins?: Array<Omit<UnknownUserPlugin, 'inject'>>;
|
|
76
81
|
};
|
|
77
82
|
type InputPath = {
|
|
78
83
|
/**
|
|
@@ -228,11 +233,8 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
228
233
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
229
234
|
*/
|
|
230
235
|
post?: Array<string>;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
} : {
|
|
234
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
235
|
-
});
|
|
236
|
+
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
237
|
+
};
|
|
236
238
|
type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
|
|
237
239
|
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
238
240
|
/**
|
|
@@ -258,25 +260,26 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
258
260
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
259
261
|
*/
|
|
260
262
|
options: TOptions['resolvedOptions'];
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `definePlugin`).
|
|
266
|
+
*/
|
|
267
|
+
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
268
|
+
};
|
|
266
269
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
267
270
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
268
271
|
/**
|
|
269
272
|
* Start of the lifecycle of a plugin.
|
|
270
273
|
* @type hookParallel
|
|
271
274
|
*/
|
|
272
|
-
|
|
275
|
+
install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
273
276
|
/**
|
|
274
277
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
275
278
|
* Options can als be included.
|
|
276
279
|
* @type hookFirst
|
|
277
280
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
278
281
|
*/
|
|
279
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.
|
|
282
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
|
|
280
283
|
/**
|
|
281
284
|
* Resolve to a name based on a string.
|
|
282
285
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -284,11 +287,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
284
287
|
* @example ('pet') => 'Pet'
|
|
285
288
|
*/
|
|
286
289
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
287
|
-
/**
|
|
288
|
-
* End of the plugin lifecycle.
|
|
289
|
-
* @type hookParallel
|
|
290
|
-
*/
|
|
291
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
292
290
|
};
|
|
293
291
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
294
292
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
@@ -315,24 +313,15 @@ type ResolveNameParams = {
|
|
|
315
313
|
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
316
314
|
fabric: Fabric;
|
|
317
315
|
config: Config;
|
|
318
|
-
/**
|
|
319
|
-
* @deprecated
|
|
320
|
-
*/
|
|
321
|
-
fileManager: FileManager;
|
|
322
316
|
pluginManager: PluginManager;
|
|
323
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<
|
|
324
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
325
|
-
resolveName: (params: ResolveNameParams) => string;
|
|
317
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
326
318
|
logger: Logger;
|
|
327
|
-
|
|
328
|
-
* All plugins
|
|
329
|
-
*/
|
|
330
|
-
plugins: Plugin[];
|
|
319
|
+
mode: KubbFile.Mode;
|
|
331
320
|
/**
|
|
332
321
|
* Current plugin
|
|
333
322
|
*/
|
|
334
323
|
plugin: Plugin<TOptions>;
|
|
335
|
-
};
|
|
324
|
+
} & Kubb.PluginContext;
|
|
336
325
|
//#endregion
|
|
337
326
|
//#region ../core/src/PluginManager.d.ts
|
|
338
327
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
@@ -372,13 +361,14 @@ type GetFileProps<TOptions = object> = {
|
|
|
372
361
|
};
|
|
373
362
|
declare class PluginManager {
|
|
374
363
|
#private;
|
|
375
|
-
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
376
364
|
readonly events: EventEmitter<Events>;
|
|
377
365
|
readonly config: Config;
|
|
378
366
|
readonly executed: Array<Executer>;
|
|
379
367
|
readonly logger: Logger;
|
|
380
368
|
readonly options: Options$1;
|
|
381
369
|
constructor(config: Config, options: Options$1);
|
|
370
|
+
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
371
|
+
get plugins(): Array<Plugin>;
|
|
382
372
|
getFile<TOptions = object>({
|
|
383
373
|
name,
|
|
384
374
|
mode,
|
|
@@ -388,7 +378,7 @@ declare class PluginManager {
|
|
|
388
378
|
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
389
379
|
pluginKey: Plugin['key'];
|
|
390
380
|
}>;
|
|
391
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.
|
|
381
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
392
382
|
resolveName: (params: ResolveNameParams) => string;
|
|
393
383
|
/**
|
|
394
384
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -476,8 +466,6 @@ declare class PluginManager {
|
|
|
476
466
|
}): Promise<void>;
|
|
477
467
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
478
468
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
479
|
-
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
480
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
481
469
|
}
|
|
482
470
|
//#endregion
|
|
483
471
|
//#region src/types.d.ts
|
|
@@ -489,4 +477,4 @@ type Options = {
|
|
|
489
477
|
};
|
|
490
478
|
//#endregion
|
|
491
479
|
export { Options as t };
|
|
492
|
-
//# sourceMappingURL=types-
|
|
480
|
+
//# sourceMappingURL=types-BNmRHGEx.d.cts.map
|