unplugin-kubb 5.0.0-beta.75 → 5.0.0-beta.76
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/LICENSE +17 -10
- package/README.md +32 -38
- package/dist/astro.cjs +1 -1
- package/dist/astro.cjs.map +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/astro.js.map +1 -1
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.d.ts +2 -3
- package/dist/esbuild.js +1 -1
- package/dist/esbuild.js.map +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.cjs.map +1 -1
- package/dist/farm.d.ts +2 -3
- package/dist/farm.js +1 -1
- package/dist/farm.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.ts +2 -4
- package/dist/nuxt.js +1 -1
- package/dist/nuxt.js.map +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.cjs.map +1 -1
- package/dist/rolldown.d.ts +2 -3
- package/dist/rolldown.js +1 -1
- package/dist/rolldown.js.map +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.ts +2 -3
- package/dist/rollup.js +1 -1
- package/dist/rollup.js.map +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.cjs.map +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/rspack.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{unpluginFactory-B9g6Ykbq.cjs → unpluginFactory-DHcOBm75.cjs} +89 -86
- package/dist/unpluginFactory-DHcOBm75.cjs.map +1 -0
- package/dist/unpluginFactory-DU0kzxw_.js +240 -0
- package/dist/unpluginFactory-DU0kzxw_.js.map +1 -0
- package/dist/unpluginFactory.cjs +1 -1
- package/dist/unpluginFactory.d.ts +8 -1
- package/dist/unpluginFactory.js +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +2 -3
- package/dist/vite.js +1 -1
- package/dist/vite.js.map +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.cjs.map +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +1 -1
- package/dist/webpack.js.map +1 -1
- package/package.json +17 -20
- package/dist/unpluginFactory-B9g6Ykbq.cjs.map +0 -1
- package/dist/unpluginFactory-BWwh02eg.js +0 -231
- package/dist/unpluginFactory-BWwh02eg.js.map +0 -1
- package/src/astro.ts +0 -12
- package/src/esbuild.ts +0 -5
- package/src/farm.ts +0 -5
- package/src/index.ts +0 -10
- package/src/nuxt.ts +0 -22
- package/src/rolldown.ts +0 -5
- package/src/rollup.ts +0 -5
- package/src/rspack.ts +0 -5
- package/src/types.ts +0 -8
- package/src/unpluginFactory.ts +0 -157
- package/src/vite.ts +0 -5
- package/src/webpack.ts +0 -7
- /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
|
@@ -29,7 +29,7 @@ node_process = __toESM(node_process, 1);
|
|
|
29
29
|
let node_events = require("node:events");
|
|
30
30
|
let _kubb_adapter_oas = require("@kubb/adapter-oas");
|
|
31
31
|
let _kubb_core = require("@kubb/core");
|
|
32
|
-
let
|
|
32
|
+
let _kubb_plugin_barrel = require("@kubb/plugin-barrel");
|
|
33
33
|
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
34
34
|
//#region ../../internals/utils/src/errors.ts
|
|
35
35
|
/**
|
|
@@ -77,9 +77,12 @@ var AsyncEventEmitter = class {
|
|
|
77
77
|
* await emitter.emit('build', 'petstore')
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
emit(eventName, ...eventArgs) {
|
|
81
81
|
const listeners = this.#emitter.listeners(eventName);
|
|
82
82
|
if (listeners.length === 0) return;
|
|
83
|
+
return this.#emitAll(eventName, listeners, eventArgs);
|
|
84
|
+
}
|
|
85
|
+
async #emitAll(eventName, listeners, eventArgs) {
|
|
83
86
|
for (const listener of listeners) try {
|
|
84
87
|
await listener(...eventArgs);
|
|
85
88
|
} catch (err) {
|
|
@@ -104,21 +107,6 @@ var AsyncEventEmitter = class {
|
|
|
104
107
|
this.#emitter.on(eventName, handler);
|
|
105
108
|
}
|
|
106
109
|
/**
|
|
107
|
-
* Registers a one-shot listener that removes itself after the first invocation.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* emitter.onOnce('build', async (name) => { console.log(name) })
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
onOnce(eventName, handler) {
|
|
115
|
-
const wrapper = (...args) => {
|
|
116
|
-
this.off(eventName, wrapper);
|
|
117
|
-
return handler(...args);
|
|
118
|
-
};
|
|
119
|
-
this.on(eventName, wrapper);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
110
|
* Removes a previously registered listener.
|
|
123
111
|
*
|
|
124
112
|
* @example
|
|
@@ -142,6 +130,18 @@ var AsyncEventEmitter = class {
|
|
|
142
130
|
return this.#emitter.listenerCount(eventName);
|
|
143
131
|
}
|
|
144
132
|
/**
|
|
133
|
+
* Raises or lowers the per-event listener ceiling before Node warns about a memory leak.
|
|
134
|
+
* Set this above the expected listener count when many listeners attach by design.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* emitter.setMaxListeners(40)
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
setMaxListeners(max) {
|
|
142
|
+
this.#emitter.setMaxListeners(max);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
145
|
* Removes all listeners from every event channel.
|
|
146
146
|
*
|
|
147
147
|
* @example
|
|
@@ -155,91 +155,100 @@ var AsyncEventEmitter = class {
|
|
|
155
155
|
};
|
|
156
156
|
//#endregion
|
|
157
157
|
//#region package.json
|
|
158
|
-
var version = "5.0.0-beta.
|
|
158
|
+
var version = "5.0.0-beta.76";
|
|
159
159
|
//#endregion
|
|
160
160
|
//#region src/unpluginFactory.ts
|
|
161
|
+
/**
|
|
162
|
+
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
163
|
+
*
|
|
164
|
+
* Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs
|
|
165
|
+
* the Kubb build during `buildStart`. When the config omits them, it fills in defaults: the OAS
|
|
166
|
+
* adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `build`.
|
|
167
|
+
*/
|
|
161
168
|
const unpluginFactory = (options, meta) => {
|
|
162
169
|
const name = "unplugin-kubb";
|
|
163
170
|
const hooks = new AsyncEventEmitter();
|
|
164
171
|
const isVite = meta.framework === "vite";
|
|
165
|
-
|
|
172
|
+
hooks.on("kubb:lifecycle:start", ({ version }) => {
|
|
173
|
+
console.log(`Kubb Unplugin ${version} 🧩`);
|
|
174
|
+
});
|
|
175
|
+
hooks.on("kubb:error", ({ error }) => {
|
|
176
|
+
console.error(`✗ ${error?.message || "failed"}`);
|
|
177
|
+
});
|
|
178
|
+
hooks.on("kubb:warn", ({ message }) => {
|
|
179
|
+
console.warn(`⚠ ${message}`);
|
|
180
|
+
});
|
|
181
|
+
hooks.on("kubb:info", ({ message }) => {
|
|
182
|
+
console.info(`ℹ ${message}`);
|
|
183
|
+
});
|
|
184
|
+
hooks.on("kubb:success", ({ message }) => {
|
|
185
|
+
console.log(`✓ ${message}`);
|
|
186
|
+
});
|
|
187
|
+
hooks.on("kubb:plugin:end", ({ plugin, duration }) => {
|
|
188
|
+
const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
|
|
189
|
+
console.log(`✓ ${plugin.name} completed in ${durationStr}`);
|
|
190
|
+
});
|
|
191
|
+
hooks.on("kubb:files:processing:end", () => {
|
|
192
|
+
console.log("✓ Files written successfully");
|
|
193
|
+
});
|
|
194
|
+
hooks.on("kubb:generation:end", ({ config, status, diagnostics }) => {
|
|
195
|
+
console.log(config.name ? `✓ Generation completed for ${config.name}` : "✓ Generation completed");
|
|
196
|
+
if (!diagnostics || !status) return;
|
|
197
|
+
const failedCount = _kubb_core.Diagnostics.failedPlugins(diagnostics).length;
|
|
198
|
+
const pluginsCount = config.plugins.length;
|
|
199
|
+
const successCount = pluginsCount - failedCount;
|
|
200
|
+
console.log(status === "success" ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total` : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedCount} failed`}, ${pluginsCount} total`);
|
|
201
|
+
});
|
|
166
202
|
async function runBuild(ctx) {
|
|
167
203
|
if (!options?.config) {
|
|
168
|
-
|
|
169
|
-
else console.error(`[${name}] Config is not set`);
|
|
204
|
+
(ctx.error ?? console.error)(`[${name}] Config is not set`);
|
|
170
205
|
return;
|
|
171
206
|
}
|
|
172
|
-
const
|
|
173
|
-
const
|
|
207
|
+
const plugins = options.config.plugins?.some((p) => p.name === _kubb_plugin_barrel.pluginBarrelName) ? options.config.plugins ?? [] : [...options.config.plugins ?? [], (0, _kubb_plugin_barrel.pluginBarrel)()];
|
|
208
|
+
const hasBarrelPlugin = plugins.some((p) => p.name === _kubb_plugin_barrel.pluginBarrelName);
|
|
174
209
|
const output = { ...options.config.output };
|
|
175
|
-
if (
|
|
210
|
+
if (hasBarrelPlugin && output.barrel === void 0) output.barrel = { type: "named" };
|
|
176
211
|
if (output.format === void 0) output.format = false;
|
|
177
212
|
if (output.lint === void 0) output.lint = false;
|
|
178
213
|
const config = {
|
|
179
214
|
...options.config,
|
|
180
215
|
adapter: options.config.adapter ?? (0, _kubb_adapter_oas.adapterOas)(),
|
|
181
|
-
parsers: options.config.parsers?.length ? options.config.parsers : [_kubb_parser_ts.parserTs],
|
|
182
|
-
|
|
216
|
+
parsers: options.config.parsers?.length ? options.config.parsers : [_kubb_parser_ts.parserTs, _kubb_parser_ts.parserTsx],
|
|
217
|
+
plugins,
|
|
183
218
|
output
|
|
184
219
|
};
|
|
185
|
-
|
|
186
|
-
console.log(`Kubb Unplugin ${version} 🧩`);
|
|
187
|
-
});
|
|
188
|
-
hooks.on("kubb:error", ({ error }) => {
|
|
189
|
-
console.error(`✗ ${error?.message || "failed"}`);
|
|
190
|
-
});
|
|
191
|
-
hooks.on("kubb:warn", ({ message }) => {
|
|
192
|
-
console.warn(`⚠ ${message}`);
|
|
193
|
-
});
|
|
194
|
-
hooks.on("kubb:info", ({ message }) => {
|
|
195
|
-
console.info(`ℹ ${message}`);
|
|
196
|
-
});
|
|
197
|
-
hooks.on("kubb:success", ({ message }) => {
|
|
198
|
-
console.log(`✓ ${message}`);
|
|
199
|
-
});
|
|
200
|
-
hooks.on("kubb:plugin:end", ({ plugin, duration }) => {
|
|
201
|
-
const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
|
|
202
|
-
console.log(`✓ ${plugin.name} completed in ${durationStr}`);
|
|
203
|
-
});
|
|
204
|
-
hooks.on("kubb:files:processing:end", () => {
|
|
205
|
-
console.log("✓ Files written successfully");
|
|
206
|
-
});
|
|
207
|
-
hooks.on("kubb:generation:end", ({ config }) => {
|
|
208
|
-
console.log(config.name ? `✓ Generation completed for ${config.name}` : "✓ Generation completed");
|
|
209
|
-
});
|
|
210
|
-
hooks.on("kubb:generation:summary", ({ config, status, failedPlugins }) => {
|
|
211
|
-
const pluginsCount = config.plugins.length;
|
|
212
|
-
const successCount = pluginsCount - failedPlugins.size;
|
|
213
|
-
console.log(status === "success" ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total` : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`);
|
|
214
|
-
});
|
|
220
|
+
const hrStart = node_process.default.hrtime();
|
|
215
221
|
await hooks.emit("kubb:lifecycle:start", { version });
|
|
216
|
-
const
|
|
217
|
-
await
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
hooks.emit("kubb:error", { error: err });
|
|
228
|
-
});
|
|
222
|
+
const kubb = (0, _kubb_core.createKubb)(config, { hooks });
|
|
223
|
+
await kubb.setup();
|
|
224
|
+
await hooks.emit("kubb:generation:start", { config: kubb.config });
|
|
225
|
+
const { diagnostics, files, storage } = await kubb.safeBuild();
|
|
226
|
+
const hasFailures = _kubb_core.Diagnostics.hasError(diagnostics);
|
|
227
|
+
for (const diagnostic of diagnostics) {
|
|
228
|
+
if (!_kubb_core.Diagnostics.isProblem(diagnostic)) continue;
|
|
229
|
+
if (diagnostic.severity === "error") hooks.emit("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
|
|
230
|
+
else if (diagnostic.severity === "warning") hooks.emit("kubb:warn", { message: diagnostic.message });
|
|
231
|
+
else hooks.emit("kubb:info", { message: diagnostic.message });
|
|
232
|
+
}
|
|
229
233
|
await hooks.emit("kubb:generation:end", {
|
|
230
|
-
config,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
234
|
-
await hooks.emit("kubb:generation:summary", {
|
|
235
|
-
config,
|
|
236
|
-
failedPlugins,
|
|
234
|
+
config: kubb.config,
|
|
235
|
+
storage,
|
|
236
|
+
diagnostics,
|
|
237
237
|
filesCreated: files.length,
|
|
238
|
-
status:
|
|
239
|
-
hrStart
|
|
240
|
-
pluginTimings
|
|
238
|
+
status: hasFailures ? "failed" : "success",
|
|
239
|
+
hrStart
|
|
241
240
|
});
|
|
242
241
|
await hooks.emit("kubb:lifecycle:end");
|
|
242
|
+
if (hasFailures) {
|
|
243
|
+
const failedCount = _kubb_core.Diagnostics.failedPlugins(diagnostics).length;
|
|
244
|
+
const firstError = diagnostics.filter(_kubb_core.Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
245
|
+
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
246
|
+
if (ctx.error) {
|
|
247
|
+
ctx.error(`[${name}] ${message}`);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
throw new Error(`[${name}] ${message}`, { cause: firstError?.cause });
|
|
251
|
+
}
|
|
243
252
|
}
|
|
244
253
|
return {
|
|
245
254
|
name,
|
|
@@ -258,12 +267,6 @@ Object.defineProperty(exports, "__name", {
|
|
|
258
267
|
return __name;
|
|
259
268
|
}
|
|
260
269
|
});
|
|
261
|
-
Object.defineProperty(exports, "__toESM", {
|
|
262
|
-
enumerable: true,
|
|
263
|
-
get: function() {
|
|
264
|
-
return __toESM;
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
270
|
Object.defineProperty(exports, "unpluginFactory", {
|
|
268
271
|
enumerable: true,
|
|
269
272
|
get: function() {
|
|
@@ -271,4 +274,4 @@ Object.defineProperty(exports, "unpluginFactory", {
|
|
|
271
274
|
}
|
|
272
275
|
});
|
|
273
276
|
|
|
274
|
-
//# sourceMappingURL=unpluginFactory-
|
|
277
|
+
//# sourceMappingURL=unpluginFactory-DHcOBm75.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory-DHcOBm75.cjs","names":["#emitter","NodeEventEmitter","#emitAll","Diagnostics","pluginBarrelName","parserTs","parserTsx","process","unpluginVersion","userConfig"],"sources":["../../../internals/utils/src/errors.ts","../../../internals/utils/src/asyncEventEmitter.ts","../package.json","../src/unpluginFactory.ts"],"sourcesContent":["/**\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 Array<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]: Array<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 emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> | void {\n const listeners = this.#emitter.listeners(eventName) as Array<AsyncListener<TEvents[TEventName]>>\n\n if (listeners.length === 0) {\n return\n }\n\n return this.#emitAll(eventName, listeners, eventArgs)\n }\n\n async #emitAll<TEventName extends keyof TEvents & string>(\n eventName: TEventName,\n listeners: Array<AsyncListener<TEvents[TEventName]>>,\n eventArgs: TEvents[TEventName],\n ): Promise<void> {\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<Array<unknown>>)\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<Array<unknown>>)\n }\n\n /**\n * Returns the number of listeners registered for `eventName`.\n *\n * @example\n * ```ts\n * emitter.on('build', handler)\n * emitter.listenerCount('build') // 1\n * ```\n */\n listenerCount<TEventName extends keyof TEvents & string>(eventName: TEventName): number {\n return this.#emitter.listenerCount(eventName)\n }\n\n /**\n * Raises or lowers the per-event listener ceiling before Node warns about a memory leak.\n * Set this above the expected listener count when many listeners attach by design.\n *\n * @example\n * ```ts\n * emitter.setMaxListeners(40)\n * ```\n */\n setMaxListeners(max: number): void {\n this.#emitter.setMaxListeners(max)\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, createKubb, Diagnostics, type KubbHooks } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } 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\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs\n * the Kubb build during `buildStart`. When the config omits them, it fills in defaults: the OAS\n * adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `build`.\n */\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const hooks = new AsyncEventEmitter<KubbHooks>()\n const isVite = meta.framework === 'vite'\n\n hooks.on('kubb:lifecycle:start', ({ version }) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n hooks.on('kubb:error', ({ error }) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n hooks.on('kubb:warn', ({ message }) => {\n console.warn(`⚠ ${message}`)\n })\n\n hooks.on('kubb:info', ({ message }) => {\n console.info(`ℹ ${message}`)\n })\n\n hooks.on('kubb:success', ({ message }) => {\n console.log(`✓ ${message}`)\n })\n\n hooks.on('kubb: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 hooks.on('kubb:files:processing:end', () => {\n const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n hooks.on('kubb:generation:end', ({ config, status, diagnostics }) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedCount\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedCount} failed`}, ${pluginsCount} total`,\n )\n })\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ;(ctx.error ?? console.error)(`[${name}] Config is not set`)\n return\n }\n\n const alreadyHasBarrel = options.config.plugins?.some((p) => p.name === pluginBarrelName)\n const plugins = alreadyHasBarrel ? (options.config.plugins ?? []) : [...(options.config.plugins ?? []), pluginBarrel()]\n const hasBarrelPlugin = plugins.some((p) => p.name === pluginBarrelName)\n const output = { ...options.config.output }\n if (hasBarrelPlugin && output.barrel === undefined) {\n output.barrel = { type: 'named' }\n }\n if (output.format === undefined) {\n output.format = false\n }\n if (output.lint === undefined) {\n output.lint = false\n }\n\n const config = {\n ...options.config,\n adapter: options.config.adapter ?? adapterOas(),\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs, parserTsx],\n plugins,\n output,\n }\n const hrStart = process.hrtime()\n\n await hooks.emit('kubb:lifecycle:start', { version: unpluginVersion })\n\n const userConfig = config as Config\n\n const kubb = createKubb(userConfig, { hooks })\n await kubb.setup()\n\n await hooks.emit('kubb:generation:start', { config: kubb.config })\n\n const { diagnostics, files, storage } = await kubb.safeBuild()\n\n const hasFailures = Diagnostics.hasError(diagnostics)\n\n // Surface every problem by severity. Unplugin has no diagnostic renderer, so route\n // errors/warnings/info to the channels it does listen on. Non-problem diagnostics are skipped.\n for (const diagnostic of diagnostics) {\n if (!Diagnostics.isProblem(diagnostic)) {\n continue\n }\n if (diagnostic.severity === 'error') {\n hooks.emit('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n } else if (diagnostic.severity === 'warning') {\n hooks.emit('kubb:warn', { message: diagnostic.message })\n } else {\n hooks.emit('kubb:info', { message: diagnostic.message })\n }\n }\n\n await hooks.emit('kubb:generation:end', {\n config: kubb.config,\n storage,\n diagnostics,\n filesCreated: files.length,\n status: hasFailures ? 'failed' : 'success',\n hrStart,\n })\n\n await hooks.emit('kubb:lifecycle:end')\n\n if (hasFailures) {\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const firstError = diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === 'error')\n const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : (firstError?.message ?? 'Build failed')\n if (ctx.error) {\n ctx.error(`[${name}] ${message}`)\n return\n }\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\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 vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;;;;;;ACbA,IAAa,oBAAb,MAAyF;;;;;CAKvF,YAAY,cAAc,IAAI;EAC5B,KAAKA,SAAS,gBAAgB,WAAW;CAC3C;CAEA,WAAW,IAAIC,YAAAA,aAAiB;;;;;;;;;;CAWhC,KAAgD,WAAuB,GAAG,WAAsD;EAC9H,MAAM,YAAY,KAAKD,SAAS,UAAU,SAAS;EAEnD,IAAI,UAAU,WAAW,GACvB;EAGF,OAAO,KAAKE,SAAS,WAAW,WAAW,SAAS;CACtD;CAEA,MAAMA,SACJ,WACA,WACA,W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AC,MAAM,eAAe,WAAW,aAAa,OAAO;GACjH,MAAM,UAAU,cAAc,IAAI,oBAAoB,YAAY,mBAAoB,YAAY,WAAW;GAC7G,IAAI,IAAI,OAAO;IACb,IAAI,MAAM,IAAI,KAAK,IAAI,SAAS;IAChC;GACF;GAEA,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,WAAW,EAAE,OAAO,YAAY,MAAM,CAAC;EACtE;CACF;CAEA,OAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;GACjB,MAAM,SAAS,IAAgC;EACjD;EACA,MAAM,CAAC;CACT;AACF"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { EventEmitter } from "node:events";
|
|
4
|
+
import { adapterOas } from "@kubb/adapter-oas";
|
|
5
|
+
import { Diagnostics, createKubb } from "@kubb/core";
|
|
6
|
+
import { pluginBarrel, pluginBarrelName } from "@kubb/plugin-barrel";
|
|
7
|
+
import { parserTs, parserTsx } from "@kubb/parser-ts";
|
|
8
|
+
//#region ../../internals/utils/src/errors.ts
|
|
9
|
+
/**
|
|
10
|
+
* Coerces an unknown thrown value to an `Error` instance.
|
|
11
|
+
* Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* try { ... } catch(err) {
|
|
16
|
+
* throw new BuildError('Build failed', { cause: toError(err), errors: [] })
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function toError(value) {
|
|
21
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../../internals/utils/src/asyncEventEmitter.ts
|
|
25
|
+
/**
|
|
26
|
+
* Typed `EventEmitter` that awaits all async listeners before resolving.
|
|
27
|
+
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const emitter = new AsyncEventEmitter<{ build: [name: string] }>()
|
|
32
|
+
* emitter.on('build', async (name) => { console.log(name) })
|
|
33
|
+
* await emitter.emit('build', 'petstore') // all listeners awaited
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
var AsyncEventEmitter = class {
|
|
37
|
+
/**
|
|
38
|
+
* Maximum number of listeners per event before Node emits a memory-leak warning.
|
|
39
|
+
* @default 10
|
|
40
|
+
*/
|
|
41
|
+
constructor(maxListener = 10) {
|
|
42
|
+
this.#emitter.setMaxListeners(maxListener);
|
|
43
|
+
}
|
|
44
|
+
#emitter = new EventEmitter();
|
|
45
|
+
/**
|
|
46
|
+
* Emits `eventName` and awaits all registered listeners sequentially.
|
|
47
|
+
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* await emitter.emit('build', 'petstore')
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
emit(eventName, ...eventArgs) {
|
|
55
|
+
const listeners = this.#emitter.listeners(eventName);
|
|
56
|
+
if (listeners.length === 0) return;
|
|
57
|
+
return this.#emitAll(eventName, listeners, eventArgs);
|
|
58
|
+
}
|
|
59
|
+
async #emitAll(eventName, listeners, eventArgs) {
|
|
60
|
+
for (const listener of listeners) try {
|
|
61
|
+
await listener(...eventArgs);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
let serializedArgs;
|
|
64
|
+
try {
|
|
65
|
+
serializedArgs = JSON.stringify(eventArgs);
|
|
66
|
+
} catch {
|
|
67
|
+
serializedArgs = String(eventArgs);
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`Error in async listener for "${eventName}" with eventArgs ${serializedArgs}`, { cause: toError(err) });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Registers a persistent listener for `eventName`.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* emitter.on('build', async (name) => { console.log(name) })
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
on(eventName, handler) {
|
|
81
|
+
this.#emitter.on(eventName, handler);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Removes a previously registered listener.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* emitter.off('build', handler)
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
off(eventName, handler) {
|
|
92
|
+
this.#emitter.off(eventName, handler);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns the number of listeners registered for `eventName`.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* emitter.on('build', handler)
|
|
100
|
+
* emitter.listenerCount('build') // 1
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
listenerCount(eventName) {
|
|
104
|
+
return this.#emitter.listenerCount(eventName);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Raises or lowers the per-event listener ceiling before Node warns about a memory leak.
|
|
108
|
+
* Set this above the expected listener count when many listeners attach by design.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* emitter.setMaxListeners(40)
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
setMaxListeners(max) {
|
|
116
|
+
this.#emitter.setMaxListeners(max);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Removes all listeners from every event channel.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* emitter.removeAll()
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
removeAll() {
|
|
127
|
+
this.#emitter.removeAllListeners();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region package.json
|
|
132
|
+
var version = "5.0.0-beta.76";
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/unpluginFactory.ts
|
|
135
|
+
/**
|
|
136
|
+
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
137
|
+
*
|
|
138
|
+
* Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs
|
|
139
|
+
* the Kubb build during `buildStart`. When the config omits them, it fills in defaults: the OAS
|
|
140
|
+
* adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `build`.
|
|
141
|
+
*/
|
|
142
|
+
const unpluginFactory = (options, meta) => {
|
|
143
|
+
const name = "unplugin-kubb";
|
|
144
|
+
const hooks = new AsyncEventEmitter();
|
|
145
|
+
const isVite = meta.framework === "vite";
|
|
146
|
+
hooks.on("kubb:lifecycle:start", ({ version }) => {
|
|
147
|
+
console.log(`Kubb Unplugin ${version} 🧩`);
|
|
148
|
+
});
|
|
149
|
+
hooks.on("kubb:error", ({ error }) => {
|
|
150
|
+
console.error(`✗ ${error?.message || "failed"}`);
|
|
151
|
+
});
|
|
152
|
+
hooks.on("kubb:warn", ({ message }) => {
|
|
153
|
+
console.warn(`⚠ ${message}`);
|
|
154
|
+
});
|
|
155
|
+
hooks.on("kubb:info", ({ message }) => {
|
|
156
|
+
console.info(`ℹ ${message}`);
|
|
157
|
+
});
|
|
158
|
+
hooks.on("kubb:success", ({ message }) => {
|
|
159
|
+
console.log(`✓ ${message}`);
|
|
160
|
+
});
|
|
161
|
+
hooks.on("kubb:plugin:end", ({ plugin, duration }) => {
|
|
162
|
+
const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
|
|
163
|
+
console.log(`✓ ${plugin.name} completed in ${durationStr}`);
|
|
164
|
+
});
|
|
165
|
+
hooks.on("kubb:files:processing:end", () => {
|
|
166
|
+
console.log("✓ Files written successfully");
|
|
167
|
+
});
|
|
168
|
+
hooks.on("kubb:generation:end", ({ config, status, diagnostics }) => {
|
|
169
|
+
console.log(config.name ? `✓ Generation completed for ${config.name}` : "✓ Generation completed");
|
|
170
|
+
if (!diagnostics || !status) return;
|
|
171
|
+
const failedCount = Diagnostics.failedPlugins(diagnostics).length;
|
|
172
|
+
const pluginsCount = config.plugins.length;
|
|
173
|
+
const successCount = pluginsCount - failedCount;
|
|
174
|
+
console.log(status === "success" ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total` : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedCount} failed`}, ${pluginsCount} total`);
|
|
175
|
+
});
|
|
176
|
+
async function runBuild(ctx) {
|
|
177
|
+
if (!options?.config) {
|
|
178
|
+
(ctx.error ?? console.error)(`[${name}] Config is not set`);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const plugins = options.config.plugins?.some((p) => p.name === pluginBarrelName) ? options.config.plugins ?? [] : [...options.config.plugins ?? [], pluginBarrel()];
|
|
182
|
+
const hasBarrelPlugin = plugins.some((p) => p.name === pluginBarrelName);
|
|
183
|
+
const output = { ...options.config.output };
|
|
184
|
+
if (hasBarrelPlugin && output.barrel === void 0) output.barrel = { type: "named" };
|
|
185
|
+
if (output.format === void 0) output.format = false;
|
|
186
|
+
if (output.lint === void 0) output.lint = false;
|
|
187
|
+
const config = {
|
|
188
|
+
...options.config,
|
|
189
|
+
adapter: options.config.adapter ?? adapterOas(),
|
|
190
|
+
parsers: options.config.parsers?.length ? options.config.parsers : [parserTs, parserTsx],
|
|
191
|
+
plugins,
|
|
192
|
+
output
|
|
193
|
+
};
|
|
194
|
+
const hrStart = process.hrtime();
|
|
195
|
+
await hooks.emit("kubb:lifecycle:start", { version });
|
|
196
|
+
const kubb = createKubb(config, { hooks });
|
|
197
|
+
await kubb.setup();
|
|
198
|
+
await hooks.emit("kubb:generation:start", { config: kubb.config });
|
|
199
|
+
const { diagnostics, files, storage } = await kubb.safeBuild();
|
|
200
|
+
const hasFailures = Diagnostics.hasError(diagnostics);
|
|
201
|
+
for (const diagnostic of diagnostics) {
|
|
202
|
+
if (!Diagnostics.isProblem(diagnostic)) continue;
|
|
203
|
+
if (diagnostic.severity === "error") hooks.emit("kubb:error", { error: diagnostic.cause ?? new Error(diagnostic.message) });
|
|
204
|
+
else if (diagnostic.severity === "warning") hooks.emit("kubb:warn", { message: diagnostic.message });
|
|
205
|
+
else hooks.emit("kubb:info", { message: diagnostic.message });
|
|
206
|
+
}
|
|
207
|
+
await hooks.emit("kubb:generation:end", {
|
|
208
|
+
config: kubb.config,
|
|
209
|
+
storage,
|
|
210
|
+
diagnostics,
|
|
211
|
+
filesCreated: files.length,
|
|
212
|
+
status: hasFailures ? "failed" : "success",
|
|
213
|
+
hrStart
|
|
214
|
+
});
|
|
215
|
+
await hooks.emit("kubb:lifecycle:end");
|
|
216
|
+
if (hasFailures) {
|
|
217
|
+
const failedCount = Diagnostics.failedPlugins(diagnostics).length;
|
|
218
|
+
const firstError = diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === "error");
|
|
219
|
+
const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : firstError?.message ?? "Build failed";
|
|
220
|
+
if (ctx.error) {
|
|
221
|
+
ctx.error(`[${name}] ${message}`);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
throw new Error(`[${name}] ${message}`, { cause: firstError?.cause });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
name,
|
|
229
|
+
enforce: "pre",
|
|
230
|
+
apply: isVite ? "build" : void 0,
|
|
231
|
+
async buildStart() {
|
|
232
|
+
await runBuild(this);
|
|
233
|
+
},
|
|
234
|
+
vite: {}
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
//#endregion
|
|
238
|
+
export { unpluginFactory as t };
|
|
239
|
+
|
|
240
|
+
//# sourceMappingURL=unpluginFactory-DU0kzxw_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpluginFactory-DU0kzxw_.js","names":["#emitter","NodeEventEmitter","#emitAll","unpluginVersion","userConfig"],"sources":["../../../internals/utils/src/errors.ts","../../../internals/utils/src/asyncEventEmitter.ts","../package.json","../src/unpluginFactory.ts"],"sourcesContent":["/**\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 Array<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]: Array<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 emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> | void {\n const listeners = this.#emitter.listeners(eventName) as Array<AsyncListener<TEvents[TEventName]>>\n\n if (listeners.length === 0) {\n return\n }\n\n return this.#emitAll(eventName, listeners, eventArgs)\n }\n\n async #emitAll<TEventName extends keyof TEvents & string>(\n eventName: TEventName,\n listeners: Array<AsyncListener<TEvents[TEventName]>>,\n eventArgs: TEvents[TEventName],\n ): Promise<void> {\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<Array<unknown>>)\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<Array<unknown>>)\n }\n\n /**\n * Returns the number of listeners registered for `eventName`.\n *\n * @example\n * ```ts\n * emitter.on('build', handler)\n * emitter.listenerCount('build') // 1\n * ```\n */\n listenerCount<TEventName extends keyof TEvents & string>(eventName: TEventName): number {\n return this.#emitter.listenerCount(eventName)\n }\n\n /**\n * Raises or lowers the per-event listener ceiling before Node warns about a memory leak.\n * Set this above the expected listener count when many listeners attach by design.\n *\n * @example\n * ```ts\n * emitter.setMaxListeners(40)\n * ```\n */\n setMaxListeners(max: number): void {\n this.#emitter.setMaxListeners(max)\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, createKubb, Diagnostics, type KubbHooks } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } 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\n/**\n * Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).\n *\n * Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs\n * the Kubb build during `buildStart`. When the config omits them, it fills in defaults: the OAS\n * adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `build`.\n */\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {\n const name = 'unplugin-kubb' as const\n const hooks = new AsyncEventEmitter<KubbHooks>()\n const isVite = meta.framework === 'vite'\n\n hooks.on('kubb:lifecycle:start', ({ version }) => {\n console.log(`Kubb Unplugin ${version} 🧩`)\n })\n\n hooks.on('kubb:error', ({ error }) => {\n console.error(`✗ ${error?.message || 'failed'}`)\n })\n\n hooks.on('kubb:warn', ({ message }) => {\n console.warn(`⚠ ${message}`)\n })\n\n hooks.on('kubb:info', ({ message }) => {\n console.info(`ℹ ${message}`)\n })\n\n hooks.on('kubb:success', ({ message }) => {\n console.log(`✓ ${message}`)\n })\n\n hooks.on('kubb: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 hooks.on('kubb:files:processing:end', () => {\n const text = '✓ Files written successfully'\n\n console.log(text)\n })\n\n hooks.on('kubb:generation:end', ({ config, status, diagnostics }) => {\n console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')\n\n if (!diagnostics || !status) return\n\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const pluginsCount = config.plugins.length\n const successCount = pluginsCount - failedCount\n\n console.log(\n status === 'success'\n ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`\n : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedCount} failed`}, ${pluginsCount} total`,\n )\n })\n\n async function runBuild(ctx: RollupContext) {\n if (!options?.config) {\n ;(ctx.error ?? console.error)(`[${name}] Config is not set`)\n return\n }\n\n const alreadyHasBarrel = options.config.plugins?.some((p) => p.name === pluginBarrelName)\n const plugins = alreadyHasBarrel ? (options.config.plugins ?? []) : [...(options.config.plugins ?? []), pluginBarrel()]\n const hasBarrelPlugin = plugins.some((p) => p.name === pluginBarrelName)\n const output = { ...options.config.output }\n if (hasBarrelPlugin && output.barrel === undefined) {\n output.barrel = { type: 'named' }\n }\n if (output.format === undefined) {\n output.format = false\n }\n if (output.lint === undefined) {\n output.lint = false\n }\n\n const config = {\n ...options.config,\n adapter: options.config.adapter ?? adapterOas(),\n parsers: options.config.parsers?.length ? options.config.parsers : [parserTs, parserTsx],\n plugins,\n output,\n }\n const hrStart = process.hrtime()\n\n await hooks.emit('kubb:lifecycle:start', { version: unpluginVersion })\n\n const userConfig = config as Config\n\n const kubb = createKubb(userConfig, { hooks })\n await kubb.setup()\n\n await hooks.emit('kubb:generation:start', { config: kubb.config })\n\n const { diagnostics, files, storage } = await kubb.safeBuild()\n\n const hasFailures = Diagnostics.hasError(diagnostics)\n\n // Surface every problem by severity. Unplugin has no diagnostic renderer, so route\n // errors/warnings/info to the channels it does listen on. Non-problem diagnostics are skipped.\n for (const diagnostic of diagnostics) {\n if (!Diagnostics.isProblem(diagnostic)) {\n continue\n }\n if (diagnostic.severity === 'error') {\n hooks.emit('kubb:error', { error: diagnostic.cause ?? new Error(diagnostic.message) })\n } else if (diagnostic.severity === 'warning') {\n hooks.emit('kubb:warn', { message: diagnostic.message })\n } else {\n hooks.emit('kubb:info', { message: diagnostic.message })\n }\n }\n\n await hooks.emit('kubb:generation:end', {\n config: kubb.config,\n storage,\n diagnostics,\n filesCreated: files.length,\n status: hasFailures ? 'failed' : 'success',\n hrStart,\n })\n\n await hooks.emit('kubb:lifecycle:end')\n\n if (hasFailures) {\n const failedCount = Diagnostics.failedPlugins(diagnostics).length\n const firstError = diagnostics.filter(Diagnostics.isProblem).find((diagnostic) => diagnostic.severity === 'error')\n const message = failedCount > 0 ? `Build Error with ${failedCount} failed plugins` : (firstError?.message ?? 'Build failed')\n if (ctx.error) {\n ctx.error(`[${name}] ${message}`)\n return\n }\n\n throw new Error(`[${name}] ${message}`, { cause: firstError?.cause })\n }\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 vite: {},\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAC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AAc,MAAM;GACpB,QAAQ,cAAc,WAAW;GACjC;EACF,CAAC;EAED,MAAM,MAAM,KAAK,oBAAoB;EAErC,IAAI,aAAa;GACf,MAAM,cAAc,YAAY,cAAc,WAAW,CAAC,CAAC;GAC3D,MAAM,aAAa,YAAY,OAAO,YAAY,SAAS,CAAC,CAAC,MAAM,eAAe,WAAW,aAAa,OAAO;GACjH,MAAM,UAAU,cAAc,IAAI,oBAAoB,YAAY,mBAAoB,YAAY,WAAW;GAC7G,IAAI,IAAI,OAAO;IACb,IAAI,MAAM,IAAI,KAAK,IAAI,SAAS;IAChC;GACF;GAEA,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,WAAW,EAAE,OAAO,YAAY,MAAM,CAAC;EACtE;CACF;CAEA,OAAO;EACL;EACA,SAAS;EACT,OAAO,SAAS,UAAU,KAAA;EAC1B,MAAM,aAAa;GACjB,MAAM,SAAS,IAAgC;EACjD;EACA,MAAM,CAAC;CACT;AACF"}
|
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-DHcOBm75.cjs");
|
|
3
3
|
exports.unpluginFactory = require_unpluginFactory.unpluginFactory;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { t as __name } from "./
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
3
|
import { UnpluginFactory } from "unplugin";
|
|
4
4
|
|
|
5
5
|
//#region src/unpluginFactory.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Builds the Kubb unplugin for any unplugin-supported bundler (Vite, Rollup, Webpack, esbuild).
|
|
8
|
+
*
|
|
9
|
+
* Registers hook handlers that log lifecycle, diagnostics, and a per-plugin summary, then runs
|
|
10
|
+
* the Kubb build during `buildStart`. When the config omits them, it fills in defaults: the OAS
|
|
11
|
+
* adapter, the TS and TSX parsers, and a barrel plugin. Under Vite it only applies during `build`.
|
|
12
|
+
*/
|
|
6
13
|
declare const unpluginFactory: UnpluginFactory<Options | undefined>;
|
|
7
14
|
//#endregion
|
|
8
15
|
export { unpluginFactory };
|
package/dist/unpluginFactory.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as unpluginFactory } from "./unpluginFactory-
|
|
1
|
+
import { t as unpluginFactory } from "./unpluginFactory-DU0kzxw_.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-DHcOBm75.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.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.cjs","names":["unpluginFactory"],"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createVitePlugin(unpluginFactory)\n"],"mappings":";;AAIA,IAAA,gBAAA,
|
|
1
|
+
{"version":3,"file":"vite.cjs","names":["unpluginFactory"],"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createVitePlugin(unpluginFactory)\n"],"mappings":";;AAIA,IAAA,gBAAA,qBAAA,CAAA,CAAA,iBAAA,CAAgCA,wBAAAA,eAAe"}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { t as __name } from "./
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
import { Options } from "./types.js";
|
|
3
|
-
import * as _$vite from "vite";
|
|
4
3
|
|
|
5
4
|
//#region src/vite.d.ts
|
|
6
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
|
|
7
6
|
//#endregion
|
|
8
7
|
export { _default as default };
|
|
9
8
|
//# sourceMappingURL=vite.d.ts.map
|
package/dist/vite.js
CHANGED
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createVitePlugin(unpluginFactory)\n"],"mappings":";;;AAIA,IAAA,eAAe,iBAAiB,
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createVitePlugin(unpluginFactory)\n"],"mappings":";;;AAIA,IAAA,eAAe,iBAAiB,eAAe"}
|
package/dist/webpack.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_unpluginFactory = require("./unpluginFactory-
|
|
1
|
+
const require_unpluginFactory = require("./unpluginFactory-DHcOBm75.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.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.cjs","names":["unpluginFactory"],"sources":["../src/webpack.ts"],"sourcesContent":["import type { UnpluginFactoryOutput } from 'unplugin'\nimport { createWebpackPlugin } from 'unplugin'\nimport type { WebpackPluginInstance } from 'webpack'\nimport type { Options } from './types.ts'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createWebpackPlugin(unpluginFactory) as unknown as UnpluginFactoryOutput<Options, WebpackPluginInstance>\n"],"mappings":";;AAMA,IAAA,mBAAA,
|
|
1
|
+
{"version":3,"file":"webpack.cjs","names":["unpluginFactory"],"sources":["../src/webpack.ts"],"sourcesContent":["import type { UnpluginFactoryOutput } from 'unplugin'\nimport { createWebpackPlugin } from 'unplugin'\nimport type { WebpackPluginInstance } from 'webpack'\nimport type { Options } from './types.ts'\nimport { unpluginFactory } from './unpluginFactory.ts'\n\nexport default createWebpackPlugin(unpluginFactory) as unknown as UnpluginFactoryOutput<Options, WebpackPluginInstance>\n"],"mappings":";;AAMA,IAAA,mBAAA,qBAAA,CAAA,CAAA,oBAAA,CAAmCA,wBAAAA,eAAe"}
|
package/dist/webpack.d.ts
CHANGED