unplugin-kubb 6.0.0-alpha.3 → 6.0.0-alpha.31
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/esbuild.cjs +1 -1
- package/dist/esbuild.d.ts +2 -2
- package/dist/esbuild.js +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.d.ts +2 -2
- package/dist/farm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.d.ts +2 -2
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.d.ts +2 -2
- package/dist/rolldown.js +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.d.ts +2 -2
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{unpluginFactory-AvZEHRLs.js → unpluginFactory-BP6AWukk.js} +78 -27
- package/dist/unpluginFactory-BP6AWukk.js.map +1 -0
- package/dist/{unpluginFactory-DlKbJ1As.cjs → unpluginFactory-DJmw5N4X.cjs} +78 -27
- package/dist/unpluginFactory-DJmw5N4X.cjs.map +1 -0
- package/dist/unpluginFactory.cjs +1 -1
- package/dist/unpluginFactory.js +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +6 -4
- package/src/unpluginFactory.ts +13 -5
- package/dist/unpluginFactory-AvZEHRLs.js.map +0 -1
- package/dist/unpluginFactory-DlKbJ1As.cjs.map +0 -1
package/dist/astro.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
2
2
|
const require_vite = require("./vite.cjs");
|
|
3
3
|
//#region src/astro.ts
|
|
4
4
|
var astro_default = /* @__PURE__ */ require_unpluginFactory.__name((options) => ({
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
2
2
|
//#region src/esbuild.ts
|
|
3
3
|
var esbuild_default = (0, require("unplugin").createEsbuildPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
|
-
import * as esbuild from "esbuild";
|
|
3
|
+
import * as _$esbuild from "esbuild";
|
|
4
4
|
|
|
5
5
|
//#region src/esbuild.d.ts
|
|
6
|
-
declare const _default: (options?: Options | undefined) => esbuild.Plugin;
|
|
6
|
+
declare const _default: (options?: Options | undefined) => _$esbuild.Plugin;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { _default as default };
|
|
9
9
|
//# sourceMappingURL=esbuild.d.ts.map
|
package/dist/esbuild.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BP6AWukk.js";
|
|
2
2
|
import { createEsbuildPlugin } from "unplugin";
|
|
3
3
|
//#region src/esbuild.ts
|
|
4
4
|
var esbuild_default = createEsbuildPlugin(unpluginFactory);
|
package/dist/farm.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
2
2
|
//#region src/farm.ts
|
|
3
3
|
var farm_default = (0, require("unplugin").createFarmPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/farm.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
|
-
import * as _farmfe_core0 from "@farmfe/core";
|
|
3
|
+
import * as _$_farmfe_core0 from "@farmfe/core";
|
|
4
4
|
|
|
5
5
|
//#region src/farm.d.ts
|
|
6
|
-
declare const _default: (options?: Options | undefined) => _farmfe_core0.JsPlugin;
|
|
6
|
+
declare const _default: (options?: Options | undefined) => _$_farmfe_core0.JsPlugin;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { _default as default };
|
|
9
9
|
//# sourceMappingURL=farm.d.ts.map
|
package/dist/farm.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
5
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
6
6
|
//#region src/index.ts
|
|
7
7
|
const plugin = /* @__PURE__ */ (0, require("unplugin").createUnplugin)(require_unpluginFactory.unpluginFactory);
|
|
8
8
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
3
|
import { unpluginFactory } from "./unpluginFactory.js";
|
|
4
|
-
import * as unplugin from "unplugin";
|
|
4
|
+
import * as _$unplugin from "unplugin";
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
|
-
declare const plugin: unplugin.UnpluginInstance<Options | undefined, boolean>;
|
|
7
|
+
declare const plugin: _$unplugin.UnpluginInstance<Options | undefined, boolean>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { type Options, plugin as default, plugin as unplugin, unpluginFactory };
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BP6AWukk.js";
|
|
2
2
|
import { createUnplugin } from "unplugin";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
const plugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
package/dist/nuxt.cjs
CHANGED
package/dist/nuxt.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
|
-
import * as _nuxt_schema0 from "@nuxt/schema";
|
|
3
|
+
import * as _$_nuxt_schema0 from "@nuxt/schema";
|
|
4
4
|
|
|
5
5
|
//#region src/nuxt.d.ts
|
|
6
6
|
interface ModuleOptions extends Options {}
|
|
7
|
-
declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
7
|
+
declare const _default: _$_nuxt_schema0.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ModuleOptions, _default as default };
|
|
10
10
|
//# sourceMappingURL=nuxt.d.ts.map
|
package/dist/rolldown.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
2
2
|
//#region src/rolldown.ts
|
|
3
3
|
var rolldown_default = (0, require("unplugin").createRolldownPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rolldown.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
|
-
import * as rolldown from "rolldown";
|
|
3
|
+
import * as _$rolldown from "rolldown";
|
|
4
4
|
|
|
5
5
|
//#region src/rolldown.d.ts
|
|
6
|
-
declare const _default: (options?: Options | undefined) => rolldown.Plugin<any> | rolldown.Plugin<any>[];
|
|
6
|
+
declare const _default: (options?: Options | undefined) => _$rolldown.Plugin<any> | _$rolldown.Plugin<any>[];
|
|
7
7
|
//#endregion
|
|
8
8
|
export { _default as default };
|
|
9
9
|
//# sourceMappingURL=rolldown.d.ts.map
|
package/dist/rolldown.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BP6AWukk.js";
|
|
2
2
|
import { createRolldownPlugin } from "unplugin";
|
|
3
3
|
//#region src/rolldown.ts
|
|
4
4
|
var rolldown_default = createRolldownPlugin(unpluginFactory);
|
package/dist/rollup.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
2
2
|
//#region src/rollup.ts
|
|
3
3
|
var rollup_default = (0, require("unplugin").createRollupPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rollup.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
|
-
import * as rollup from "rollup";
|
|
3
|
+
import * as _$rollup from "rollup";
|
|
4
4
|
|
|
5
5
|
//#region src/rollup.d.ts
|
|
6
|
-
declare const _default: (options?: Options | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
|
|
6
|
+
declare const _default: (options?: Options | undefined) => _$rollup.Plugin<any> | _$rollup.Plugin<any>[];
|
|
7
7
|
//#endregion
|
|
8
8
|
export { _default as default };
|
|
9
9
|
//# sourceMappingURL=rollup.d.ts.map
|
package/dist/rollup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BP6AWukk.js";
|
|
2
2
|
import { createRollupPlugin } from "unplugin";
|
|
3
3
|
//#region src/rollup.ts
|
|
4
4
|
var rollup_default = createRollupPlugin(unpluginFactory);
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
2
2
|
//#region src/rspack.ts
|
|
3
3
|
var rspack_default = (0, require("unplugin").createRspackPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/rspack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BP6AWukk.js";
|
|
2
2
|
import { createRspackPlugin } from "unplugin";
|
|
3
3
|
//#region src/rspack.ts
|
|
4
4
|
var rspack_default = createRspackPlugin(unpluginFactory);
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { EventEmitter } from "node:events";
|
|
4
|
+
import { adapterOas } from "@kubb/adapter-oas";
|
|
4
5
|
import { safeBuild } from "@kubb/core";
|
|
6
|
+
import { parserTs } from "@kubb/parser-ts";
|
|
5
7
|
//#region ../../internals/utils/src/errors.ts
|
|
6
8
|
/**
|
|
7
9
|
* Coerces an unknown thrown value to an `Error` instance.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* try { ... } catch(err) {
|
|
15
|
+
* throw new BuildError('Build failed', { cause: toError(err), errors: [] })
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
10
18
|
*/
|
|
11
19
|
function toError(value) {
|
|
12
20
|
return value instanceof Error ? value : new Error(String(value));
|
|
@@ -14,12 +22,19 @@ function toError(value) {
|
|
|
14
22
|
//#endregion
|
|
15
23
|
//#region ../../internals/utils/src/asyncEventEmitter.ts
|
|
16
24
|
/**
|
|
17
|
-
*
|
|
25
|
+
* Typed `EventEmitter` that awaits all async listeners before resolving.
|
|
18
26
|
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const emitter = new AsyncEventEmitter<{ build: [name: string] }>()
|
|
31
|
+
* emitter.on('build', async (name) => { console.log(name) })
|
|
32
|
+
* await emitter.emit('build', 'petstore') // all listeners awaited
|
|
33
|
+
* ```
|
|
19
34
|
*/
|
|
20
35
|
var AsyncEventEmitter = class {
|
|
21
36
|
/**
|
|
22
|
-
*
|
|
37
|
+
* Maximum number of listeners per event before Node emits a memory-leak warning.
|
|
23
38
|
* @default 10
|
|
24
39
|
*/
|
|
25
40
|
constructor(maxListener = 10) {
|
|
@@ -27,31 +42,48 @@ var AsyncEventEmitter = class {
|
|
|
27
42
|
}
|
|
28
43
|
#emitter = new EventEmitter();
|
|
29
44
|
/**
|
|
30
|
-
* Emits
|
|
45
|
+
* Emits `eventName` and awaits all registered listeners sequentially.
|
|
31
46
|
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* await emitter.emit('build', 'petstore')
|
|
51
|
+
* ```
|
|
32
52
|
*/
|
|
33
53
|
async emit(eventName, ...eventArgs) {
|
|
34
54
|
const listeners = this.#emitter.listeners(eventName);
|
|
35
55
|
if (listeners.length === 0) return;
|
|
36
|
-
|
|
56
|
+
for (const listener of listeners) try {
|
|
57
|
+
await listener(...eventArgs);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
let serializedArgs;
|
|
37
60
|
try {
|
|
38
|
-
|
|
39
|
-
} catch
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
serializedArgs = JSON.stringify(eventArgs);
|
|
43
|
-
} catch {
|
|
44
|
-
serializedArgs = String(eventArgs);
|
|
45
|
-
}
|
|
46
|
-
throw new Error(`Error in async listener for "${eventName}" with eventArgs ${serializedArgs}`, { cause: toError(err) });
|
|
61
|
+
serializedArgs = JSON.stringify(eventArgs);
|
|
62
|
+
} catch {
|
|
63
|
+
serializedArgs = String(eventArgs);
|
|
47
64
|
}
|
|
48
|
-
|
|
65
|
+
throw new Error(`Error in async listener for "${eventName}" with eventArgs ${serializedArgs}`, { cause: toError(err) });
|
|
66
|
+
}
|
|
49
67
|
}
|
|
50
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Registers a persistent listener for `eventName`.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* emitter.on('build', async (name) => { console.log(name) })
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
51
76
|
on(eventName, handler) {
|
|
52
77
|
this.#emitter.on(eventName, handler);
|
|
53
78
|
}
|
|
54
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Registers a one-shot listener that removes itself after the first invocation.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* emitter.onOnce('build', async (name) => { console.log(name) })
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
55
87
|
onOnce(eventName, handler) {
|
|
56
88
|
const wrapper = (...args) => {
|
|
57
89
|
this.off(eventName, wrapper);
|
|
@@ -59,18 +91,32 @@ var AsyncEventEmitter = class {
|
|
|
59
91
|
};
|
|
60
92
|
this.on(eventName, wrapper);
|
|
61
93
|
}
|
|
62
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Removes a previously registered listener.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* emitter.off('build', handler)
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
63
102
|
off(eventName, handler) {
|
|
64
103
|
this.#emitter.off(eventName, handler);
|
|
65
104
|
}
|
|
66
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Removes all listeners from every event channel.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* emitter.removeAll()
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
67
113
|
removeAll() {
|
|
68
114
|
this.#emitter.removeAllListeners();
|
|
69
115
|
}
|
|
70
116
|
};
|
|
71
117
|
//#endregion
|
|
72
118
|
//#region package.json
|
|
73
|
-
var version = "6.0.0-alpha.
|
|
119
|
+
var version = "6.0.0-alpha.31";
|
|
74
120
|
//#endregion
|
|
75
121
|
//#region src/unpluginFactory.ts
|
|
76
122
|
const unpluginFactory = (options, meta) => {
|
|
@@ -84,6 +130,11 @@ const unpluginFactory = (options, meta) => {
|
|
|
84
130
|
else console.error(`[${name}] Config is not set`);
|
|
85
131
|
return;
|
|
86
132
|
}
|
|
133
|
+
const config = {
|
|
134
|
+
...options.config,
|
|
135
|
+
adapter: options.config.adapter ?? adapterOas(),
|
|
136
|
+
parsers: options.config.parsers?.length ? options.config.parsers : [parserTs]
|
|
137
|
+
};
|
|
87
138
|
events.on("lifecycle:start", (version) => {
|
|
88
139
|
console.log(`Kubb Unplugin ${version} 🧩`);
|
|
89
140
|
});
|
|
@@ -110,13 +161,13 @@ const unpluginFactory = (options, meta) => {
|
|
|
110
161
|
console.log(config.name ? `✓ Generation completed for ${config.name}` : "✓ Generation completed");
|
|
111
162
|
});
|
|
112
163
|
events.on("generation:summary", (config, { status, failedPlugins }) => {
|
|
113
|
-
const pluginsCount = config.plugins
|
|
164
|
+
const pluginsCount = config.plugins.length;
|
|
114
165
|
const successCount = pluginsCount - failedPlugins.size;
|
|
115
166
|
console.log(status === "success" ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total` : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`);
|
|
116
167
|
});
|
|
117
168
|
await events.emit("lifecycle:start", version);
|
|
118
|
-
const { root: _root, ...userConfig } =
|
|
119
|
-
await events.emit("generation:start",
|
|
169
|
+
const { root: _root, ...userConfig } = config;
|
|
170
|
+
await events.emit("generation:start", config);
|
|
120
171
|
const { error, failedPlugins, pluginTimings, files, sources } = await safeBuild({
|
|
121
172
|
config: {
|
|
122
173
|
root: process.cwd(),
|
|
@@ -131,8 +182,8 @@ const unpluginFactory = (options, meta) => {
|
|
|
131
182
|
if (failedPlugins.size > 0 || error) [error, ...Array.from(failedPlugins).filter((it) => it.error).map((it) => it.error)].filter(Boolean).forEach((err) => {
|
|
132
183
|
events.emit("error", err);
|
|
133
184
|
});
|
|
134
|
-
await events.emit("generation:end",
|
|
135
|
-
await events.emit("generation:summary",
|
|
185
|
+
await events.emit("generation:end", config, files, sources);
|
|
186
|
+
await events.emit("generation:summary", config, {
|
|
136
187
|
failedPlugins,
|
|
137
188
|
filesCreated: files.length,
|
|
138
189
|
status: failedPlugins.size > 0 || error ? "failed" : "success",
|
|
@@ -154,4 +205,4 @@ const unpluginFactory = (options, meta) => {
|
|
|
154
205
|
//#endregion
|
|
155
206
|
export { unpluginFactory as t };
|
|
156
207
|
|
|
157
|
-
//# sourceMappingURL=unpluginFactory-
|
|
208
|
+
//# sourceMappingURL=unpluginFactory-BP6AWukk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory-BP6AWukk.js","names":["#emitter","NodeEventEmitter","unpluginVersion"],"sources":["../../../internals/utils/src/errors.ts","../../../internals/utils/src/asyncEventEmitter.ts","../package.json","../src/unpluginFactory.ts"],"sourcesContent":["/** Thrown when a plugin's configuration or input fails validation.\n *\n * @example\n * ```ts\n * throw new ValidationPluginError('Invalid config: \"output.path\" is required')\n * ```\n */\nexport class ValidationPluginError extends Error {}\n\n/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport { toError } from './errors.ts'\n\n/**\n * A function that can be registered as an event listener, synchronous or async.\n */\ntype AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>\n\n/**\n * Typed `EventEmitter` that awaits all async listeners before resolving.\n * Wraps Node's `EventEmitter` with full TypeScript event-map inference.\n *\n * @example\n * ```ts\n * const emitter = new AsyncEventEmitter<{ build: [name: string] }>()\n * emitter.on('build', async (name) => { console.log(name) })\n * await emitter.emit('build', 'petstore') // all listeners awaited\n * ```\n */\nexport class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {\n /**\n * Maximum number of listeners per event before Node emits a memory-leak warning.\n * @default 10\n */\n constructor(maxListener = 10) {\n this.#emitter.setMaxListeners(maxListener)\n }\n\n #emitter = new NodeEventEmitter()\n\n /**\n * Emits `eventName` and awaits all registered listeners sequentially.\n * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.\n *\n * @example\n * ```ts\n * await emitter.emit('build', 'petstore')\n * ```\n */\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<AsyncListener<TEvents[TEventName]>>\n\n if (listeners.length === 0) {\n return\n }\n\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n let serializedArgs: string\n try {\n serializedArgs = JSON.stringify(eventArgs)\n } catch {\n serializedArgs = String(eventArgs)\n }\n throw new Error(`Error in async listener for \"${eventName}\" with eventArgs ${serializedArgs}`, { cause: toError(err) })\n }\n }\n }\n\n /**\n * Registers a persistent listener for `eventName`.\n *\n * @example\n * ```ts\n * emitter.on('build', async (name) => { console.log(name) })\n * ```\n */\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.on(eventName, handler as AsyncListener<unknown[]>)\n }\n\n /**\n * Registers a one-shot listener that removes itself after the first invocation.\n *\n * @example\n * ```ts\n * emitter.onOnce('build', async (name) => { console.log(name) })\n * ```\n */\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n const wrapper: AsyncListener<TEvents[TEventName]> = (...args) => {\n this.off(eventName, wrapper)\n return handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n /**\n * Removes a previously registered listener.\n *\n * @example\n * ```ts\n * emitter.off('build', handler)\n * ```\n */\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.off(eventName, handler as AsyncListener<unknown[]>)\n }\n\n /**\n * Removes all listeners from every event channel.\n *\n * @example\n * ```ts\n * emitter.removeAll()\n * ```\n */\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","","import process from 'node:process'\nimport { AsyncEventEmitter } from '@internals/utils'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport { type Config, type KubbEvents, safeBuild } from '@kubb/core'\nimport { parserTs } from '@kubb/parser-ts'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const events = new AsyncEventEmitter<KubbEvents>()\n const isVite = meta.framework === 'vite'\n const hrStart = process.hrtime()\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n if (ctx.error) {\n ctx.error?.(`[${name}] Config is not set`)\n } else {\n console.error(`[${name}] Config is not set`)\n }\n return\n }\n\n const config = {\n ...options.config,\n adapter: options.config.adapter ?? adapterOas(),\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs],\n }\n\n events.on('lifecycle:start', (version) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n events.on('error', (error) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n events.on('warn', (message) => {\n console.warn(`⚠ ${message}`)\n })\n\n events.on('info', (message) => {\n console.info(`ℹ ${message}`)\n })\n\n events.on('success', (message) => {\n console.log(`✓ ${message}`)\n })\n\n events.on('plugin:end', (plugin, { duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n events.on('files:processing:end', () => {\n const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n events.on('generation:end', (config) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n })\n\n events.on('generation:summary', (config, { status, failedPlugins }) => {\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedPlugins.size\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,\n )\n })\n\n await events.emit('lifecycle:start', unpluginVersion)\n\n const { root: _root, ...userConfig } = config as Config\n\n await events.emit('generation:start', config as Config)\n\n const { error, failedPlugins, pluginTimings, files, sources } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n events,\n })\n\n const hasFailures = failedPlugins.size > 0 || error\n if (hasFailures) {\n // Collect all errors from failed plugins and general error\n const allErrors: Error[] = [\n error,\n ...Array.from(failedPlugins)\n .filter((it) => it.error)\n .map((it) => it.error),\n ].filter(Boolean)\n\n allErrors.forEach((err) => {\n events.emit('error', err)\n })\n }\n\n await events.emit('generation:end', config as Config, files, sources)\n await events.emit('generation:summary', config as Config, {\n failedPlugins,\n filesCreated: files.length,\n status: failedPlugins.size > 0 || error ? 'failed' : 'success',\n hrStart,\n pluginTimings,\n })\n\n await events.emit('lifecycle:end')\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,SAAgB,QAAQ,OAAuB;AAC7C,QAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;;;;;;;;;;;;;;;ACrBlE,IAAa,oBAAb,MAAoF;;;;;CAKlF,YAAY,cAAc,IAAI;AAC5B,QAAA,QAAc,gBAAgB,YAAY;;CAG5C,WAAW,IAAIC,cAAkB;;;;;;;;;;CAWjC,MAAM,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AAW;KACf;IACF;GACD;GACD,CAAC;AAGF,MADoB,cAAc,OAAO,KAAK,MAGjB,EACzB,OACA,GAAG,MAAM,KAAK,cAAc,CACzB,QAAQ,OAAO,GAAG,MAAM,CACxB,KAAK,OAAO,GAAG,MAAM,CACzB,CAAC,OAAO,QAAQ,CAEP,SAAS,QAAQ;AACzB,UAAO,KAAK,SAAS,IAAI;IACzB;AAGJ,QAAM,OAAO,KAAK,kBAAkB,QAAkB,OAAO,QAAQ;AACrE,QAAM,OAAO,KAAK,sBAAsB,QAAkB;GACxD;GACA,cAAc,MAAM;GACpB,QAAQ,cAAc,OAAO,KAAK,QAAQ,WAAW;GACrD;GACA;GACD,CAAC;AAEF,QAAM,OAAO,KAAK,gBAAgB;;AAGpC,QAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;AACjB,SAAM,SAAS,KAAiC;;EAGlD,MAAM,EAAE;EACT"}
|
|
@@ -27,12 +27,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
let node_process = require("node:process");
|
|
28
28
|
node_process = __toESM(node_process);
|
|
29
29
|
let node_events = require("node:events");
|
|
30
|
+
let _kubb_adapter_oas = require("@kubb/adapter-oas");
|
|
30
31
|
let _kubb_core = require("@kubb/core");
|
|
32
|
+
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
31
33
|
//#region ../../internals/utils/src/errors.ts
|
|
32
34
|
/**
|
|
33
35
|
* Coerces an unknown thrown value to an `Error` instance.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
+
* Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* try { ... } catch(err) {
|
|
41
|
+
* throw new BuildError('Build failed', { cause: toError(err), errors: [] })
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
36
44
|
*/
|
|
37
45
|
function toError(value) {
|
|
38
46
|
return value instanceof Error ? value : new Error(String(value));
|
|
@@ -40,12 +48,19 @@ function toError(value) {
|
|
|
40
48
|
//#endregion
|
|
41
49
|
//#region ../../internals/utils/src/asyncEventEmitter.ts
|
|
42
50
|
/**
|
|
43
|
-
*
|
|
51
|
+
* Typed `EventEmitter` that awaits all async listeners before resolving.
|
|
44
52
|
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const emitter = new AsyncEventEmitter<{ build: [name: string] }>()
|
|
57
|
+
* emitter.on('build', async (name) => { console.log(name) })
|
|
58
|
+
* await emitter.emit('build', 'petstore') // all listeners awaited
|
|
59
|
+
* ```
|
|
45
60
|
*/
|
|
46
61
|
var AsyncEventEmitter = class {
|
|
47
62
|
/**
|
|
48
|
-
*
|
|
63
|
+
* Maximum number of listeners per event before Node emits a memory-leak warning.
|
|
49
64
|
* @default 10
|
|
50
65
|
*/
|
|
51
66
|
constructor(maxListener = 10) {
|
|
@@ -53,31 +68,48 @@ var AsyncEventEmitter = class {
|
|
|
53
68
|
}
|
|
54
69
|
#emitter = new node_events.EventEmitter();
|
|
55
70
|
/**
|
|
56
|
-
* Emits
|
|
71
|
+
* Emits `eventName` and awaits all registered listeners sequentially.
|
|
57
72
|
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* await emitter.emit('build', 'petstore')
|
|
77
|
+
* ```
|
|
58
78
|
*/
|
|
59
79
|
async emit(eventName, ...eventArgs) {
|
|
60
80
|
const listeners = this.#emitter.listeners(eventName);
|
|
61
81
|
if (listeners.length === 0) return;
|
|
62
|
-
|
|
82
|
+
for (const listener of listeners) try {
|
|
83
|
+
await listener(...eventArgs);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
let serializedArgs;
|
|
63
86
|
try {
|
|
64
|
-
|
|
65
|
-
} catch
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
serializedArgs = JSON.stringify(eventArgs);
|
|
69
|
-
} catch {
|
|
70
|
-
serializedArgs = String(eventArgs);
|
|
71
|
-
}
|
|
72
|
-
throw new Error(`Error in async listener for "${eventName}" with eventArgs ${serializedArgs}`, { cause: toError(err) });
|
|
87
|
+
serializedArgs = JSON.stringify(eventArgs);
|
|
88
|
+
} catch {
|
|
89
|
+
serializedArgs = String(eventArgs);
|
|
73
90
|
}
|
|
74
|
-
|
|
91
|
+
throw new Error(`Error in async listener for "${eventName}" with eventArgs ${serializedArgs}`, { cause: toError(err) });
|
|
92
|
+
}
|
|
75
93
|
}
|
|
76
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Registers a persistent listener for `eventName`.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* emitter.on('build', async (name) => { console.log(name) })
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
77
102
|
on(eventName, handler) {
|
|
78
103
|
this.#emitter.on(eventName, handler);
|
|
79
104
|
}
|
|
80
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Registers a one-shot listener that removes itself after the first invocation.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* emitter.onOnce('build', async (name) => { console.log(name) })
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
81
113
|
onOnce(eventName, handler) {
|
|
82
114
|
const wrapper = (...args) => {
|
|
83
115
|
this.off(eventName, wrapper);
|
|
@@ -85,18 +117,32 @@ var AsyncEventEmitter = class {
|
|
|
85
117
|
};
|
|
86
118
|
this.on(eventName, wrapper);
|
|
87
119
|
}
|
|
88
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Removes a previously registered listener.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* emitter.off('build', handler)
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
89
128
|
off(eventName, handler) {
|
|
90
129
|
this.#emitter.off(eventName, handler);
|
|
91
130
|
}
|
|
92
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Removes all listeners from every event channel.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* emitter.removeAll()
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
93
139
|
removeAll() {
|
|
94
140
|
this.#emitter.removeAllListeners();
|
|
95
141
|
}
|
|
96
142
|
};
|
|
97
143
|
//#endregion
|
|
98
144
|
//#region package.json
|
|
99
|
-
var version = "6.0.0-alpha.
|
|
145
|
+
var version = "6.0.0-alpha.31";
|
|
100
146
|
//#endregion
|
|
101
147
|
//#region src/unpluginFactory.ts
|
|
102
148
|
const unpluginFactory = (options, meta) => {
|
|
@@ -110,6 +156,11 @@ const unpluginFactory = (options, meta) => {
|
|
|
110
156
|
else console.error(`[${name}] Config is not set`);
|
|
111
157
|
return;
|
|
112
158
|
}
|
|
159
|
+
const config = {
|
|
160
|
+
...options.config,
|
|
161
|
+
adapter: options.config.adapter ?? (0, _kubb_adapter_oas.adapterOas)(),
|
|
162
|
+
parsers: options.config.parsers?.length ? options.config.parsers : [_kubb_parser_ts.parserTs]
|
|
163
|
+
};
|
|
113
164
|
events.on("lifecycle:start", (version) => {
|
|
114
165
|
console.log(`Kubb Unplugin ${version} 🧩`);
|
|
115
166
|
});
|
|
@@ -136,13 +187,13 @@ const unpluginFactory = (options, meta) => {
|
|
|
136
187
|
console.log(config.name ? `✓ Generation completed for ${config.name}` : "✓ Generation completed");
|
|
137
188
|
});
|
|
138
189
|
events.on("generation:summary", (config, { status, failedPlugins }) => {
|
|
139
|
-
const pluginsCount = config.plugins
|
|
190
|
+
const pluginsCount = config.plugins.length;
|
|
140
191
|
const successCount = pluginsCount - failedPlugins.size;
|
|
141
192
|
console.log(status === "success" ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total` : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`);
|
|
142
193
|
});
|
|
143
194
|
await events.emit("lifecycle:start", version);
|
|
144
|
-
const { root: _root, ...userConfig } =
|
|
145
|
-
await events.emit("generation:start",
|
|
195
|
+
const { root: _root, ...userConfig } = config;
|
|
196
|
+
await events.emit("generation:start", config);
|
|
146
197
|
const { error, failedPlugins, pluginTimings, files, sources } = await (0, _kubb_core.safeBuild)({
|
|
147
198
|
config: {
|
|
148
199
|
root: node_process.default.cwd(),
|
|
@@ -157,8 +208,8 @@ const unpluginFactory = (options, meta) => {
|
|
|
157
208
|
if (failedPlugins.size > 0 || error) [error, ...Array.from(failedPlugins).filter((it) => it.error).map((it) => it.error)].filter(Boolean).forEach((err) => {
|
|
158
209
|
events.emit("error", err);
|
|
159
210
|
});
|
|
160
|
-
await events.emit("generation:end",
|
|
161
|
-
await events.emit("generation:summary",
|
|
211
|
+
await events.emit("generation:end", config, files, sources);
|
|
212
|
+
await events.emit("generation:summary", config, {
|
|
162
213
|
failedPlugins,
|
|
163
214
|
filesCreated: files.length,
|
|
164
215
|
status: failedPlugins.size > 0 || error ? "failed" : "success",
|
|
@@ -197,4 +248,4 @@ Object.defineProperty(exports, "unpluginFactory", {
|
|
|
197
248
|
}
|
|
198
249
|
});
|
|
199
250
|
|
|
200
|
-
//# sourceMappingURL=unpluginFactory-
|
|
251
|
+
//# sourceMappingURL=unpluginFactory-DJmw5N4X.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory-DJmw5N4X.cjs","names":["#emitter","NodeEventEmitter","process","parserTs","unpluginVersion"],"sources":["../../../internals/utils/src/errors.ts","../../../internals/utils/src/asyncEventEmitter.ts","../package.json","../src/unpluginFactory.ts"],"sourcesContent":["/** Thrown when a plugin's configuration or input fails validation.\n *\n * @example\n * ```ts\n * throw new ValidationPluginError('Invalid config: \"output.path\" is required')\n * ```\n */\nexport class ValidationPluginError extends Error {}\n\n/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport { toError } from './errors.ts'\n\n/**\n * A function that can be registered as an event listener, synchronous or async.\n */\ntype AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>\n\n/**\n * Typed `EventEmitter` that awaits all async listeners before resolving.\n * Wraps Node's `EventEmitter` with full TypeScript event-map inference.\n *\n * @example\n * ```ts\n * const emitter = new AsyncEventEmitter<{ build: [name: string] }>()\n * emitter.on('build', async (name) => { console.log(name) })\n * await emitter.emit('build', 'petstore') // all listeners awaited\n * ```\n */\nexport class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {\n /**\n * Maximum number of listeners per event before Node emits a memory-leak warning.\n * @default 10\n */\n constructor(maxListener = 10) {\n this.#emitter.setMaxListeners(maxListener)\n }\n\n #emitter = new NodeEventEmitter()\n\n /**\n * Emits `eventName` and awaits all registered listeners sequentially.\n * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.\n *\n * @example\n * ```ts\n * await emitter.emit('build', 'petstore')\n * ```\n */\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<AsyncListener<TEvents[TEventName]>>\n\n if (listeners.length === 0) {\n return\n }\n\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n let serializedArgs: string\n try {\n serializedArgs = JSON.stringify(eventArgs)\n } catch {\n serializedArgs = String(eventArgs)\n }\n throw new Error(`Error in async listener for \"${eventName}\" with eventArgs ${serializedArgs}`, { cause: toError(err) })\n }\n }\n }\n\n /**\n * Registers a persistent listener for `eventName`.\n *\n * @example\n * ```ts\n * emitter.on('build', async (name) => { console.log(name) })\n * ```\n */\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.on(eventName, handler as AsyncListener<unknown[]>)\n }\n\n /**\n * Registers a one-shot listener that removes itself after the first invocation.\n *\n * @example\n * ```ts\n * emitter.onOnce('build', async (name) => { console.log(name) })\n * ```\n */\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n const wrapper: AsyncListener<TEvents[TEventName]> = (...args) => {\n this.off(eventName, wrapper)\n return handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n /**\n * Removes a previously registered listener.\n *\n * @example\n * ```ts\n * emitter.off('build', handler)\n * ```\n */\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.off(eventName, handler as AsyncListener<unknown[]>)\n }\n\n /**\n * Removes all listeners from every event channel.\n *\n * @example\n * ```ts\n * emitter.removeAll()\n * ```\n */\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","","import process from 'node:process'\nimport { AsyncEventEmitter } from '@internals/utils'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport { type Config, type KubbEvents, safeBuild } from '@kubb/core'\nimport { parserTs } from '@kubb/parser-ts'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const events = new AsyncEventEmitter<KubbEvents>()\n const isVite = meta.framework === 'vite'\n const hrStart = process.hrtime()\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n if (ctx.error) {\n ctx.error?.(`[${name}] Config is not set`)\n } else {\n console.error(`[${name}] Config is not set`)\n }\n return\n }\n\n const config = {\n ...options.config,\n adapter: options.config.adapter ?? adapterOas(),\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs],\n }\n\n events.on('lifecycle:start', (version) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n events.on('error', (error) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n events.on('warn', (message) => {\n console.warn(`⚠ ${message}`)\n })\n\n events.on('info', (message) => {\n console.info(`ℹ ${message}`)\n })\n\n events.on('success', (message) => {\n console.log(`✓ ${message}`)\n })\n\n events.on('plugin:end', (plugin, { duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n events.on('files:processing:end', () => {\n const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n events.on('generation:end', (config) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n })\n\n events.on('generation:summary', (config, { status, failedPlugins }) => {\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedPlugins.size\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,\n )\n })\n\n await events.emit('lifecycle:start', unpluginVersion)\n\n const { root: _root, ...userConfig } = config as Config\n\n await events.emit('generation:start', config as Config)\n\n const { error, failedPlugins, pluginTimings, files, sources } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n events,\n })\n\n const hasFailures = failedPlugins.size > 0 || error\n if (hasFailures) {\n // Collect all errors from failed plugins and general error\n const allErrors: Error[] = [\n error,\n ...Array.from(failedPlugins)\n .filter((it) => it.error)\n .map((it) => it.error),\n ].filter(Boolean)\n\n allErrors.forEach((err) => {\n events.emit('error', err)\n })\n }\n\n await events.emit('generation:end', config as Config, files, sources)\n await events.emit('generation:summary', config as Config, {\n failedPlugins,\n filesCreated: files.length,\n status: failedPlugins.size > 0 || error ? 'failed' : 'success',\n hrStart,\n pluginTimings,\n })\n\n await events.emit('lifecycle:end')\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,QAAQ,OAAuB;AAC7C,QAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;;;;;;;;;;;;;;;ACrBlE,IAAa,oBAAb,MAAoF;;;;;CAKlF,YAAY,cAAc,IAAI;AAC5B,QAAA,QAAc,gBAAgB,YAAY;;CAG5C,WAAW,IAAIC,YAAAA,cAAkB;;;;;;;;;;CAWjC,MAAM,KAAgD,WAAuB,GAAG,WAA+C;E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;KACN,OAAO;KACP,GAAG,WAAW;KACf;IACF;GACD;GACD,CAAC;AAGF,MADoB,cAAc,OAAO,KAAK,MAGjB,EACzB,OACA,GAAG,MAAM,KAAK,cAAc,CACzB,QAAQ,OAAO,GAAG,MAAM,CACxB,KAAK,OAAO,GAAG,MAAM,CACzB,CAAC,OAAO,QAAQ,CAEP,SAAS,QAAQ;AACzB,UAAO,KAAK,SAAS,IAAI;IACzB;AAGJ,QAAM,OAAO,KAAK,kBAAkB,QAAkB,OAAO,QAAQ;AACrE,QAAM,OAAO,KAAK,sBAAsB,QAAkB;GACxD;GACA,cAAc,MAAM;GACpB,QAAQ,cAAc,OAAO,KAAK,QAAQ,WAAW;GACrD;GACA;GACD,CAAC;AAEF,QAAM,OAAO,KAAK,gBAAgB;;AAGpC,QAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;AACjB,SAAM,SAAS,KAAiC;;EAGlD,MAAM,EAAE;EACT"}
|
package/dist/unpluginFactory.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
2
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
3
3
|
exports.unpluginFactory = require_unpluginFactory.unpluginFactory;
|
package/dist/unpluginFactory.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BP6AWukk.js";
|
|
2
2
|
export { unpluginFactory };
|
package/dist/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
2
2
|
//#region src/vite.ts
|
|
3
3
|
var vite_default = (0, require("unplugin").createVitePlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
|
-
import * as vite from "vite";
|
|
3
|
+
import * as _$vite from "vite";
|
|
4
4
|
|
|
5
5
|
//#region src/vite.d.ts
|
|
6
|
-
declare const _default: (options?: Options | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
|
|
6
|
+
declare const _default: (options?: Options | undefined) => _$vite.Plugin<any> | _$vite.Plugin<any>[];
|
|
7
7
|
//#endregion
|
|
8
8
|
export { _default as default };
|
|
9
9
|
//# sourceMappingURL=vite.d.ts.map
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DJmw5N4X.cjs");
|
|
2
2
|
//#region src/webpack.ts
|
|
3
3
|
var webpack_default = (0, require("unplugin").createWebpackPlugin)(require_unpluginFactory.unpluginFactory);
|
|
4
4
|
//#endregion
|
package/dist/webpack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-BP6AWukk.js";
|
|
2
2
|
import { createWebpackPlugin } from "unplugin";
|
|
3
3
|
//#region src/webpack.ts
|
|
4
4
|
var webpack_default = createWebpackPlugin(unpluginFactory);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-kubb",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.31",
|
|
4
4
|
"description": "Universal build plugin for Kubb, integrating OpenAPI code generation into Vite, Webpack, Rollup, esbuild, Rspack, Nuxt, and Astro build processes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unplugin",
|
|
@@ -98,15 +98,17 @@
|
|
|
98
98
|
],
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"unplugin": "^3.0.0",
|
|
101
|
-
"@kubb/
|
|
101
|
+
"@kubb/adapter-oas": "5.0.0-alpha.31",
|
|
102
|
+
"@kubb/core": "5.0.0-alpha.31",
|
|
103
|
+
"@kubb/parser-ts": "5.0.0-alpha.31"
|
|
102
104
|
},
|
|
103
105
|
"devDependencies": {
|
|
104
106
|
"@farmfe/core": "^1.7.11",
|
|
105
107
|
"@nuxt/kit": "^4.4.2",
|
|
106
108
|
"@nuxt/schema": "^4.4.2",
|
|
107
109
|
"esbuild": "*",
|
|
108
|
-
"rolldown": "~1.0.0-rc.
|
|
109
|
-
"rollup": "^4.
|
|
110
|
+
"rolldown": "~1.0.0-rc.13",
|
|
111
|
+
"rollup": "^4.60.1",
|
|
110
112
|
"vite": "^7.3.1",
|
|
111
113
|
"webpack": "^5.105.4",
|
|
112
114
|
"@internals/utils": "0.0.0"
|
package/src/unpluginFactory.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import { AsyncEventEmitter } from '@internals/utils'
|
|
3
|
+
import { adapterOas } from '@kubb/adapter-oas'
|
|
3
4
|
import { type Config, type KubbEvents, safeBuild } from '@kubb/core'
|
|
5
|
+
import { parserTs } from '@kubb/parser-ts'
|
|
4
6
|
import type { UnpluginFactory } from 'unplugin'
|
|
5
7
|
import { version as unpluginVersion } from '../package.json'
|
|
6
8
|
import type { Options } from './types.ts'
|
|
@@ -27,6 +29,12 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, m
|
|
|
27
29
|
return
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
const config = {
|
|
33
|
+
...options.config,
|
|
34
|
+
adapter: options.config.adapter ?? adapterOas(),
|
|
35
|
+
parsers: options.config.parsers?.length ? options.config.parsers : [parserTs],
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
events.on('lifecycle:start', (version) => {
|
|
31
39
|
console.log(`Kubb Unplugin ${version} 🧩`)
|
|
32
40
|
})
|
|
@@ -64,7 +72,7 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, m
|
|
|
64
72
|
})
|
|
65
73
|
|
|
66
74
|
events.on('generation:summary', (config, { status, failedPlugins }) => {
|
|
67
|
-
const pluginsCount = config.plugins
|
|
75
|
+
const pluginsCount = config.plugins.length
|
|
68
76
|
const successCount = pluginsCount - failedPlugins.size
|
|
69
77
|
|
|
70
78
|
console.log(
|
|
@@ -76,9 +84,9 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, m
|
|
|
76
84
|
|
|
77
85
|
await events.emit('lifecycle:start', unpluginVersion)
|
|
78
86
|
|
|
79
|
-
const { root: _root, ...userConfig } =
|
|
87
|
+
const { root: _root, ...userConfig } = config as Config
|
|
80
88
|
|
|
81
|
-
await events.emit('generation:start',
|
|
89
|
+
await events.emit('generation:start', config as Config)
|
|
82
90
|
|
|
83
91
|
const { error, failedPlugins, pluginTimings, files, sources } = await safeBuild({
|
|
84
92
|
config: {
|
|
@@ -107,8 +115,8 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, m
|
|
|
107
115
|
})
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
await events.emit('generation:end',
|
|
111
|
-
await events.emit('generation:summary',
|
|
118
|
+
await events.emit('generation:end', config as Config, files, sources)
|
|
119
|
+
await events.emit('generation:summary', config as Config, {
|
|
112
120
|
failedPlugins,
|
|
113
121
|
filesCreated: files.length,
|
|
114
122
|
status: failedPlugins.size > 0 || error ? 'failed' : 'success',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpluginFactory-AvZEHRLs.js","names":["#emitter","NodeEventEmitter","unpluginVersion"],"sources":["../../../internals/utils/src/errors.ts","../../../internals/utils/src/asyncEventEmitter.ts","../package.json","../src/unpluginFactory.ts"],"sourcesContent":["/** Thrown when a plugin's configuration or input fails validation. */\nexport class ValidationPluginError extends Error {}\n\n/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * When the value is already an `Error` it is returned as-is;\n * otherwise a new `Error` is created whose message is `String(value)`.\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Safely extracts a human-readable message from any thrown value.\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error | undefined`.\n * Returns `undefined` when the cause is absent or is not an `Error`.\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport { toError } from './errors.ts'\n\n/** A function that can be registered as an event listener, synchronous or async. */\ntype AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>\n\n/**\n * A typed EventEmitter that awaits all async listeners before resolving.\n * Wraps Node's `EventEmitter` with full TypeScript event-map inference.\n */\nexport class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {\n /**\n * `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.\n * @default 10\n */\n constructor(maxListener = 10) {\n this.#emitter.setMaxListeners(maxListener)\n }\n\n #emitter = new NodeEventEmitter()\n\n /**\n * Emits an event and awaits all registered listeners in parallel.\n * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.\n */\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<AsyncListener<TEvents[TEventName]>>\n\n if (listeners.length === 0) {\n return undefined\n }\n\n await Promise.all(\n listeners.map(async (listener) => {\n try {\n return await listener(...eventArgs)\n } catch (err) {\n let serializedArgs: string\n try {\n serializedArgs = JSON.stringify(eventArgs)\n } catch {\n serializedArgs = String(eventArgs)\n }\n throw new Error(`Error in async listener for \"${eventName}\" with eventArgs ${serializedArgs}`, { cause: toError(err) })\n }\n }),\n )\n }\n\n /** Registers a persistent listener for the given event. */\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.on(eventName, handler as AsyncListener<unknown[]>)\n }\n\n /** Registers a one-shot listener that removes itself after the first invocation. */\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n const wrapper: AsyncListener<TEvents[TEventName]> = (...args) => {\n this.off(eventName, wrapper)\n return handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n /** Removes a previously registered listener. */\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.off(eventName, handler as AsyncListener<unknown[]>)\n }\n\n /** Removes all listeners from every event channel. */\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","","import process from 'node:process'\nimport { AsyncEventEmitter } from '@internals/utils'\nimport { type Config, type KubbEvents, safeBuild } from '@kubb/core'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const events = new AsyncEventEmitter<KubbEvents>()\n const isVite = meta.framework === 'vite'\n const hrStart = process.hrtime()\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n if (ctx.error) {\n ctx.error?.(`[${name}] Config is not set`)\n } else {\n console.error(`[${name}] Config is not set`)\n }\n return\n }\n\n events.on('lifecycle:start', (version) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n events.on('error', (error) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n events.on('warn', (message) => {\n console.warn(`⚠ ${message}`)\n })\n\n events.on('info', (message) => {\n console.info(`ℹ ${message}`)\n })\n\n events.on('success', (message) => {\n console.log(`✓ ${message}`)\n })\n\n events.on('plugin:end', (plugin, { duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n events.on('files:processing:end', () => {\n const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n events.on('generation:end', (config) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n })\n\n events.on('generation:summary', (config, { status, failedPlugins }) => {\n const pluginsCount = config.plugins?.length || 0\n const successCount = pluginsCount - failedPlugins.size\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,\n )\n })\n\n await events.emit('lifecycle:start', unpluginVersion)\n\n const { root: _root, ...userConfig } = options.config as Config\n\n await events.emit('generation:start', options.config as Config)\n\n const { error, failedPlugins, pluginTimings, files, sources } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n events,\n })\n\n const hasFailures = failedPlugins.size > 0 || error\n if (hasFailures) {\n // Collect all errors from failed plugins and general error\n const allErrors: Error[] = [\n error,\n ...Array.from(failedPlugins)\n .filter((it) => it.error)\n .map((it) => it.error),\n ].filter(Boolean)\n\n allErrors.forEach((err) => {\n events.emit('error', err)\n })\n }\n\n await events.emit('generation:end', options.config as Config, files, sources)\n await events.emit('generation:summary', options.config as Config, {\n failedPlugins,\n filesCreated: files.length,\n status: failedPlugins.size > 0 || error ? 'failed' : 'success',\n hrStart,\n pluginTimings,\n })\n\n await events.emit('lifecycle:end')\n }\n\n return {\n name,\n enforce: 'pre',\n apply: isVite ? 'build' : undefined,\n async buildStart() {\n await runBuild(this as unknown as RollupContext)\n },\n\n vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;AAsBA,SAAgB,QAAQ,OAAuB;AAC7C,QAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;;;;;;;;ACblE,IAAa,oBAAb,MAAoF;;;;;CAKlF,YAAY,cAAc,IAAI;AAC5B,QAAA,QAAc,gBAAgB,YAAY;;CAG5C,WAAW,IAAIC,cAAkB;;;;;CAMjC,MAAM,KAAgD,WAAuB,GAAG,WAA+C;EAC7H,MAAM,YAAY,MAAA,QAAc,UAAU,UAAU;AAEpD,MAAI,UAAU,WAAW,EACvB;AAGF,QAAM,QAAQ,IACZ,UAAU,IAAI,OAAO,aAAa;AAChC,OAAI;AACF,WAAO,MAAM,SAAS,GAAG,UAAU;YAC5B,KAAK;IACZ,IAAI;AACJ,QAAI;AACF,sBAAiB,KAAK,UAAU,UAAU;YACpC;AACN,sBAAiB,OAAO,UAAU;;AAEpC,UAAM,IAAI,MAAM,gCAAgC,UAAU,mBAAmB,kBAAkB,EAAE,OAAO,QAAQ,IAAI,EAAE,CAAC;;IAEzH,CACH;;;CAIH,GAA8C,WAAuB,SAAmD;AACtH,QAAA,QAAc,GAAG,WAAW,QAAoC;;;CAIlE,OAAkD,WAAuB,SAAmD;EAC1H,MAAM,WAA+C,GAAG,SAAS;AAC/D,QAAK,IAAI,WAAW,QAAQ;AAC5B,UAAO,QAAQ,GAAG,KAAK;;AAEzB,OAAK,GAAG,WAAW,QAAQ;;;CAI7B,IAA+C,WAAuB,SAAmD;AACvH,QAAA,QAAc,IAAI,WAAW,QAAoC;;;CAInE,YAAkB;AAChB,QAAA,QAAc,oBAAoB;;;;;;;;AEzDtC,MAAa,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Aa,MAAM,GAAG,cAAc,KAAK,SAAS,IAAI,aAAa,QAC3G;IACD;AAEF,QAAM,OAAO,KAAK,mBAAmBC,QAAgB;EAErD,MAAM,EAAE,MAAM,OAAO,GAAG,eAAe,QAAQ;AAE/C,QAAM,OAAO,KAAK,oBAAoB,QAAQ,OAAiB;EAE/D,MAAM,EAAE,OAAO,eAAe,eAAe,OAAO,YAAY,MAAM,UAAU;GAC9E,QAAQ;IACN,MAAM,QAAQ,KAAK;IACnB,GAAG;IACH,QAAQ;KACN,OAAO;KACP,GAAG,WAAW;KACf;IACF;GACD;GACD,CAAC;AAGF,MADoB,cAAc,OAAO,KAAK,MAGjB,EACzB,OACA,GAAG,MAAM,KAAK,cAAc,CACzB,QAAQ,OAAO,GAAG,MAAM,CACxB,KAAK,OAAO,GAAG,MAAM,CACzB,CAAC,OAAO,QAAQ,CAEP,SAAS,QAAQ;AACzB,UAAO,KAAK,SAAS,IAAI;IACzB;AAGJ,QAAM,OAAO,KAAK,kBAAkB,QAAQ,QAAkB,OAAO,QAAQ;AAC7E,QAAM,OAAO,KAAK,sBAAsB,QAAQ,QAAkB;GAChE;GACA,cAAc,MAAM;GACpB,QAAQ,cAAc,OAAO,KAAK,QAAQ,WAAW;GACrD;GACA;GACD,CAAC;AAEF,QAAM,OAAO,KAAK,gBAAgB;;AAGpC,QAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;AACjB,SAAM,SAAS,KAAiC;;EAGlD,MAAM,EAAE;EACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpluginFactory-DlKbJ1As.cjs","names":["#emitter","NodeEventEmitter","process","unpluginVersion"],"sources":["../../../internals/utils/src/errors.ts","../../../internals/utils/src/asyncEventEmitter.ts","../package.json","../src/unpluginFactory.ts"],"sourcesContent":["/** Thrown when a plugin's configuration or input fails validation. */\nexport class ValidationPluginError extends Error {}\n\n/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * When the value is already an `Error` it is returned as-is;\n * otherwise a new `Error` is created whose message is `String(value)`.\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Safely extracts a human-readable message from any thrown value.\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error | undefined`.\n * Returns `undefined` when the cause is absent or is not an `Error`.\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport { toError } from './errors.ts'\n\n/** A function that can be registered as an event listener, synchronous or async. */\ntype AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>\n\n/**\n * A typed EventEmitter that awaits all async listeners before resolving.\n * Wraps Node's `EventEmitter` with full TypeScript event-map inference.\n */\nexport class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {\n /**\n * `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.\n * @default 10\n */\n constructor(maxListener = 10) {\n this.#emitter.setMaxListeners(maxListener)\n }\n\n #emitter = new NodeEventEmitter()\n\n /**\n * Emits an event and awaits all registered listeners in parallel.\n * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.\n */\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<AsyncListener<TEvents[TEventName]>>\n\n if (listeners.length === 0) {\n return undefined\n }\n\n await Promise.all(\n listeners.map(async (listener) => {\n try {\n return await listener(...eventArgs)\n } catch (err) {\n let serializedArgs: string\n try {\n serializedArgs = JSON.stringify(eventArgs)\n } catch {\n serializedArgs = String(eventArgs)\n }\n throw new Error(`Error in async listener for \"${eventName}\" with eventArgs ${serializedArgs}`, { cause: toError(err) })\n }\n }),\n )\n }\n\n /** Registers a persistent listener for the given event. */\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.on(eventName, handler as AsyncListener<unknown[]>)\n }\n\n /** Registers a one-shot listener that removes itself after the first invocation. */\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n const wrapper: AsyncListener<TEvents[TEventName]> = (...args) => {\n this.off(eventName, wrapper)\n return handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n /** Removes a previously registered listener. */\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.off(eventName, handler as AsyncListener<unknown[]>)\n }\n\n /** Removes all listeners from every event channel. */\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","","import process from 'node:process'\nimport { AsyncEventEmitter } from '@internals/utils'\nimport { type Config, type KubbEvents, safeBuild } from '@kubb/core'\nimport type { UnpluginFactory } from 'unplugin'\nimport { version as unpluginVersion } from '../package.json'\nimport type { Options } from './types.ts'\n\ntype RollupContext = {\n info?: (message: string) => void\n warn?: (message: string) => void\n error?: (message: string) => void\n}\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const events = new AsyncEventEmitter<KubbEvents>()\n const isVite = meta.framework === 'vite'\n const hrStart = process.hrtime()\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n if (ctx.error) {\n ctx.error?.(`[${name}] Config is not set`)\n } else {\n console.error(`[${name}] Config is not set`)\n }\n return\n }\n\n events.on('lifecycle:start', (version) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n events.on('error', (error) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n events.on('warn', (message) => {\n console.warn(`⚠ ${message}`)\n })\n\n events.on('info', (message) => {\n console.info(`ℹ ${message}`)\n })\n\n events.on('success', (message) => {\n console.log(`✓ ${message}`)\n })\n\n events.on('plugin:end', (plugin, { duration }) => {\n const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`\n\n console.log(`✓ ${plugin.name} completed in ${durationStr}`)\n })\n\n events.on('files:processing:end', () => {\n const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n events.on('generation:end', (config) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n })\n\n events.on('generation:summary', (config, { status, failedPlugins }) => {\n const pluginsCount = config.plugins?.length || 0\n const successCount = pluginsCount - failedPlugins.size\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,\n )\n })\n\n await events.emit('lifecycle:start', unpluginVersion)\n\n const { root: _root, ...userConfig } = options.config as Config\n\n await events.emit('generation:start', options.config as Config)\n\n const { error, failedPlugins, pluginTimings, files, sources } = await safeBuild({\n config: {\n root: process.cwd(),\n ...userConfig,\n output: {\n write: true,\n ...userConfig.output,\n },\n },\n events,\n })\n\n const hasFailures = failedPlugins.size > 0 || error\n if (hasFailures) {\n // Collect all errors from failed plugins and general error\n const allErrors: Error[] = [\n error,\n ...Array.from(failedPlugins)\n .filter((it) => it.error)\n .map((it) => it.error),\n ].filter(Boolean)\n\n allErrors.forEach((err) => {\n events.emit('error', err)\n })\n }\n\n await events.emit('generation:end', options.config as Config, files, sources)\n await events.emit('generation:summary', options.config as Config, {\n failedPlugins,\n filesCreated: files.length,\n status: failedPlugins.size > 0 || error ? 'failed' : 'success',\n hrStart,\n pluginTimings,\n })\n\n await events.emit('lifecycle:end')\n }\n\n return {\n name,\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