unplugin-kubb 4.0.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/astro.cjs +6 -6
  2. package/dist/astro.cjs.map +1 -1
  3. package/dist/astro.d.ts +4 -10
  4. package/dist/astro.js +6 -7
  5. package/dist/astro.js.map +1 -1
  6. package/dist/{chunk-CIm-hhu7.js → chunk-DKWOrOAv.js} +1 -1
  7. package/dist/esbuild.cjs +3 -2
  8. package/dist/esbuild.cjs.map +1 -1
  9. package/dist/esbuild.d.ts +5 -6
  10. package/dist/esbuild.js +1 -1
  11. package/dist/esbuild.js.map +1 -1
  12. package/dist/farm.cjs +10 -0
  13. package/dist/farm.cjs.map +1 -0
  14. package/dist/farm.d.ts +8 -0
  15. package/dist/farm.js +9 -0
  16. package/dist/farm.js.map +1 -0
  17. package/dist/index.cjs +12 -5
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.ts +6 -7
  20. package/dist/index.js +8 -2
  21. package/dist/index.js.map +1 -0
  22. package/dist/nuxt.cjs +5 -5
  23. package/dist/nuxt.cjs.map +1 -1
  24. package/dist/nuxt.d.ts +2 -2
  25. package/dist/nuxt.js +3 -3
  26. package/dist/nuxt.js.map +1 -1
  27. package/dist/package-ClLHpgT2.js +6 -0
  28. package/dist/package-ClLHpgT2.js.map +1 -0
  29. package/dist/package-uutExRPO.cjs +55 -0
  30. package/dist/package-uutExRPO.cjs.map +1 -0
  31. package/dist/rolldown.cjs +10 -0
  32. package/dist/rolldown.cjs.map +1 -0
  33. package/dist/rolldown.d.ts +8 -0
  34. package/dist/rolldown.js +9 -0
  35. package/dist/rolldown.js.map +1 -0
  36. package/dist/rollup.cjs +3 -2
  37. package/dist/rollup.cjs.map +1 -1
  38. package/dist/rollup.d.ts +5 -6
  39. package/dist/rollup.js +1 -1
  40. package/dist/rollup.js.map +1 -1
  41. package/dist/rspack.cjs +3 -2
  42. package/dist/rspack.cjs.map +1 -1
  43. package/dist/rspack.d.ts +3 -4
  44. package/dist/rspack.js +1 -1
  45. package/dist/rspack.js.map +1 -1
  46. package/dist/types.d.ts +13 -2
  47. package/dist/unpluginFactory.cjs +90 -0
  48. package/dist/unpluginFactory.cjs.map +1 -0
  49. package/dist/unpluginFactory.d.ts +9 -0
  50. package/dist/{src-CiUcBKSs.js → unpluginFactory.js} +14 -20
  51. package/dist/unpluginFactory.js.map +1 -0
  52. package/dist/vite.cjs +3 -2
  53. package/dist/vite.cjs.map +1 -1
  54. package/dist/vite.d.ts +5 -6
  55. package/dist/vite.js +1 -1
  56. package/dist/vite.js.map +1 -1
  57. package/dist/webpack.cjs +3 -2
  58. package/dist/webpack.cjs.map +1 -1
  59. package/dist/webpack.d.ts +4 -5
  60. package/dist/webpack.js +1 -1
  61. package/dist/webpack.js.map +1 -1
  62. package/package.json +66 -41
  63. package/src/astro.ts +4 -5
  64. package/src/esbuild.ts +1 -1
  65. package/src/farm.ts +5 -0
  66. package/src/index.ts +6 -133
  67. package/src/nuxt.ts +2 -2
  68. package/src/rolldown.ts +5 -0
  69. package/src/rollup.ts +1 -1
  70. package/src/rspack.ts +1 -1
  71. package/src/unpluginFactory.ts +132 -0
  72. package/src/vite.ts +1 -1
  73. package/src/webpack.ts +1 -2
  74. package/dist/astro.d.cts +0 -11
  75. package/dist/esbuild.d.cts +0 -7
  76. package/dist/index.d.cts +0 -10
  77. package/dist/nuxt.d.cts +0 -9
  78. package/dist/rollup.d.cts +0 -7
  79. package/dist/rspack.d.cts +0 -6
  80. package/dist/src-BiN2tznZ.cjs +0 -155
  81. package/dist/src-BiN2tznZ.cjs.map +0 -1
  82. package/dist/src-CiUcBKSs.js.map +0 -1
  83. package/dist/types-C-ZTDGdJ.d.cts +0 -650
  84. package/dist/types-CUVJ-CBJ.d.ts +0 -649
  85. package/dist/types.d.cts +0 -2
  86. package/dist/vite.d.cts +0 -7
  87. package/dist/webpack.d.cts +0 -8
@@ -0,0 +1,132 @@
1
+ import process from 'node:process'
2
+ import { type Config, type KubbEvents, safeBuild } from '@kubb/core'
3
+ import { AsyncEventEmitter } from '@kubb/core/utils'
4
+ import type { UnpluginFactory } from 'unplugin'
5
+ import { version as unpluginVersion } from '../package.json'
6
+ import type { Options } from './types.ts'
7
+
8
+ type RollupContext = {
9
+ info?: (message: string) => void
10
+ warn?: (message: string) => void
11
+ error?: (message: string) => void
12
+ }
13
+
14
+ export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, meta) => {
15
+ const name = 'unplugin-kubb' as const
16
+ const events = new AsyncEventEmitter<KubbEvents>()
17
+ const isVite = meta.framework === 'vite'
18
+ const hrStart = process.hrtime()
19
+
20
+ async function runBuild(ctx: RollupContext) {
21
+ if (!options?.config) {
22
+ if (ctx.error) {
23
+ ctx.error?.(`[${name}] Config is not set`)
24
+ } else {
25
+ console.error(`[${name}] Config is not set`)
26
+ }
27
+ return
28
+ }
29
+
30
+ events.on('lifecycle:start', (version) => {
31
+ console.log(`Kubb Unplugin ${version} 🧩`)
32
+ })
33
+
34
+ events.on('error', (error) => {
35
+ console.error(`✗ ${error?.message || 'failed'}`)
36
+ })
37
+
38
+ events.on('warn', (message) => {
39
+ console.warn(`⚠ ${message}`)
40
+ })
41
+
42
+ events.on('info', (message) => {
43
+ console.info(`ℹ ${message}`)
44
+ })
45
+
46
+ events.on('success', (message) => {
47
+ console.log(`✓ ${message}`)
48
+ })
49
+
50
+ events.on('plugin:end', (plugin, { duration }) => {
51
+ const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(2)}s` : `${duration}ms`
52
+
53
+ console.log(`✓ ${plugin.name} completed in ${durationStr}`)
54
+ })
55
+
56
+ events.on('files:processing:end', () => {
57
+ const text = '✓ Files written successfully'
58
+
59
+ console.log(text)
60
+ })
61
+
62
+ events.on('generation:end', (config) => {
63
+ console.log(config.name ? `✓ Generation completed for ${config.name}` : '✓ Generation completed')
64
+ })
65
+
66
+ events.on('generation:summary', (config, { status, failedPlugins }) => {
67
+ const pluginsCount = config.plugins?.length || 0
68
+ const successCount = pluginsCount - failedPlugins.size
69
+
70
+ console.log(
71
+ status === 'success'
72
+ ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total`
73
+ : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins.size} failed`}, ${pluginsCount} total`,
74
+ )
75
+ })
76
+
77
+ await events.emit('lifecycle:start', unpluginVersion)
78
+
79
+ const { root: _root, ...userConfig } = options.config as Config
80
+
81
+ await events.emit('generation:start', options.config as Config)
82
+
83
+ const { error, failedPlugins, pluginTimings, files, sources } = await safeBuild({
84
+ config: {
85
+ root: process.cwd(),
86
+ ...userConfig,
87
+ output: {
88
+ write: true,
89
+ ...userConfig.output,
90
+ },
91
+ },
92
+ events,
93
+ })
94
+
95
+ const hasFailures = failedPlugins.size > 0 || error
96
+ if (hasFailures) {
97
+ // Collect all errors from failed plugins and general error
98
+ const allErrors: Error[] = [
99
+ error,
100
+ ...Array.from(failedPlugins)
101
+ .filter((it) => it.error)
102
+ .map((it) => it.error),
103
+ ].filter(Boolean)
104
+
105
+ allErrors.forEach((err) => {
106
+ events.emit('error', err)
107
+ })
108
+ }
109
+
110
+ await events.emit('generation:end', options.config as Config, files, sources)
111
+ await events.emit('generation:summary', options.config as Config, {
112
+ failedPlugins,
113
+ filesCreated: files.length,
114
+ status: failedPlugins.size > 0 || error ? 'failed' : 'success',
115
+ hrStart,
116
+ pluginTimings,
117
+ })
118
+
119
+ await events.emit('lifecycle:end')
120
+ }
121
+
122
+ return {
123
+ name,
124
+ enforce: 'pre',
125
+ apply: isVite ? 'build' : undefined,
126
+ async buildStart() {
127
+ await runBuild(this as unknown as RollupContext)
128
+ },
129
+
130
+ vite: {},
131
+ }
132
+ }
package/src/vite.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createVitePlugin } from 'unplugin'
2
2
 
3
- import { unpluginFactory } from './index.ts'
3
+ import { unpluginFactory } from './unpluginFactory.ts'
4
4
 
5
5
  export default createVitePlugin(unpluginFactory)
package/src/webpack.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import type { UnpluginFactoryOutput } from 'unplugin'
2
2
  import { createWebpackPlugin } from 'unplugin'
3
3
  import type { WebpackPluginInstance } from 'webpack'
4
- import { unpluginFactory } from './index.ts'
5
4
  import type { Options } from './types.ts'
5
+ import { unpluginFactory } from './unpluginFactory.ts'
6
6
 
7
- // resolves issue for: The inferred type of 'default' cannot be named without a reference to 'node_modules/webpack'. This is likely not portable. A type annotation is necessary.
8
7
  export default createWebpackPlugin(unpluginFactory) as unknown as UnpluginFactoryOutput<Options, WebpackPluginInstance>
package/dist/astro.d.cts DELETED
@@ -1,11 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
-
3
- //#region src/astro.d.ts
4
- declare const _default: (options: Options) => {
5
- name: string;
6
- hooks: {
7
- 'astro:config:setup': (astro: any) => Promise<void>;
8
- };
9
- };
10
- export = _default;
11
- //# sourceMappingURL=astro.d.cts.map
@@ -1,7 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
- import * as esbuild0 from "esbuild";
3
-
4
- //#region src/esbuild.d.ts
5
- declare const _default: (options?: Options | undefined) => esbuild0.Plugin;
6
- export = _default;
7
- //# sourceMappingURL=esbuild.d.cts.map
package/dist/index.d.cts DELETED
@@ -1,10 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
- import * as unplugin0 from "unplugin";
3
- import { UnpluginFactory } from "unplugin";
4
-
5
- //#region src/index.d.ts
6
- declare const unpluginFactory: UnpluginFactory<Options | undefined>;
7
- declare const unplugin: unplugin0.UnpluginInstance<Options | undefined, boolean>;
8
- //#endregion
9
- export { unplugin as default, unplugin, unpluginFactory };
10
- //# sourceMappingURL=index.d.cts.map
package/dist/nuxt.d.cts DELETED
@@ -1,9 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
- import * as _nuxt_schema0 from "@nuxt/schema";
3
-
4
- //#region src/nuxt.d.ts
5
- interface ModuleOptions extends Options {}
6
- declare const _default: _nuxt_schema0.NuxtModule<ModuleOptions, ModuleOptions, false>;
7
- //#endregion
8
- export { ModuleOptions, _default as default };
9
- //# sourceMappingURL=nuxt.d.cts.map
package/dist/rollup.d.cts DELETED
@@ -1,7 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
- import * as rollup0 from "rollup";
3
-
4
- //#region src/rollup.d.ts
5
- declare const _default: (options?: Options | undefined) => rollup0.Plugin<any> | rollup0.Plugin<any>[];
6
- export = _default;
7
- //# sourceMappingURL=rollup.d.cts.map
package/dist/rspack.d.cts DELETED
@@ -1,6 +0,0 @@
1
- import { n as __name, t as Options } from "./types-C-ZTDGdJ.cjs";
2
-
3
- //#region src/rspack.d.ts
4
- declare const _default: (options?: Options | undefined) => RspackPluginInstance;
5
- export = _default;
6
- //# sourceMappingURL=rspack.d.cts.map
@@ -1,155 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", {
5
- value,
6
- configurable: true
7
- });
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __getOwnPropNames = Object.getOwnPropertyNames;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) {
17
- __defProp(to, key, {
18
- get: ((k) => from[k]).bind(null, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- }
23
- }
24
- return to;
25
- };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
- value: mod,
28
- enumerable: true
29
- }) : target, mod));
30
-
31
- //#endregion
32
- let node_process = require("node:process");
33
- node_process = __toESM(node_process);
34
- let _kubb_core = require("@kubb/core");
35
- let _kubb_core_utils = require("@kubb/core/utils");
36
- let unplugin = require("unplugin");
37
-
38
- //#region package.json
39
- var version = "4.0.2";
40
-
41
- //#endregion
42
- //#region src/index.ts
43
- const unpluginFactory = (options, meta) => {
44
- const name = "unplugin-kubb";
45
- const events = new _kubb_core_utils.AsyncEventEmitter();
46
- const isVite = meta.framework === "vite";
47
- const hrStart = node_process.default.hrtime();
48
- async function runBuild(ctx) {
49
- if (!options?.config) {
50
- if (ctx.error) ctx.error?.(`[${name}] Config is not set`);
51
- else console.error(`[${name}] Config is not set`);
52
- return;
53
- }
54
- events.on("lifecycle:start", (version$1) => {
55
- console.log(`Kubb Unplugin ${version$1} 🧩`);
56
- });
57
- events.on("error", (error$1) => {
58
- console.error(`✗ ${error$1?.message || "failed"}`);
59
- });
60
- events.on("warn", (message) => {
61
- console.warn(`⚠ ${message}`);
62
- });
63
- events.on("info", (message) => {
64
- console.info(`ℹ ${message}`);
65
- });
66
- events.on("success", (message) => {
67
- console.log(`✓ ${message}`);
68
- });
69
- events.on("plugin:end", (plugin, { duration }) => {
70
- const durationStr = duration >= 1e3 ? `${(duration / 1e3).toFixed(2)}s` : `${duration}ms`;
71
- console.log(`✓ ${plugin.name} completed in ${durationStr}`);
72
- });
73
- events.on("files:processing:end", () => {
74
- console.log("✓ Files written successfully");
75
- });
76
- events.on("generation:end", (config) => {
77
- console.log(config.name ? `✓ Generation completed for ${config.name}` : "✓ Generation completed");
78
- });
79
- events.on("generation:summary", (config, { status, failedPlugins: failedPlugins$1 }) => {
80
- const pluginsCount = config.plugins?.length || 0;
81
- const successCount = pluginsCount - failedPlugins$1.size;
82
- console.log(status === "success" ? `Kubb Summary: ✓ ${`${successCount} successful`}, ${pluginsCount} total` : `Kubb Summary: ✓ ${`${successCount} successful`}, ✗ ${`${failedPlugins$1.size} failed`}, ${pluginsCount} total`);
83
- });
84
- await events.emit("lifecycle:start", version);
85
- const { root: _root, ...userConfig } = options.config;
86
- await events.emit("generation:start", options.config);
87
- const { error, failedPlugins, pluginTimings, files } = await (0, _kubb_core.safeBuild)({
88
- config: {
89
- root: node_process.default.cwd(),
90
- ...userConfig,
91
- output: {
92
- write: true,
93
- ...userConfig.output
94
- }
95
- },
96
- events
97
- });
98
- if (failedPlugins.size > 0 || error) [error, ...Array.from(failedPlugins).filter((it) => it.error).map((it) => it.error)].filter(Boolean).forEach((err) => {
99
- events.emit("error", err);
100
- });
101
- await events.emit("generation:end", options.config);
102
- await events.emit("generation:summary", options.config, {
103
- failedPlugins,
104
- filesCreated: files.length,
105
- status: failedPlugins.size > 0 || error ? "failed" : "success",
106
- hrStart,
107
- pluginTimings
108
- });
109
- await events.emit("lifecycle:end");
110
- }
111
- return {
112
- name,
113
- enforce: "pre",
114
- apply: isVite ? "build" : void 0,
115
- async buildStart() {
116
- await runBuild(this);
117
- },
118
- vite: {}
119
- };
120
- };
121
- const unplugin$1 = /* @__PURE__ */ (0, unplugin.createUnplugin)(unpluginFactory);
122
- var src_default = unplugin$1;
123
-
124
- //#endregion
125
- Object.defineProperty(exports, '__name', {
126
- enumerable: true,
127
- get: function () {
128
- return __name;
129
- }
130
- });
131
- Object.defineProperty(exports, '__toESM', {
132
- enumerable: true,
133
- get: function () {
134
- return __toESM;
135
- }
136
- });
137
- Object.defineProperty(exports, 'src_default', {
138
- enumerable: true,
139
- get: function () {
140
- return src_default;
141
- }
142
- });
143
- Object.defineProperty(exports, 'unplugin', {
144
- enumerable: true,
145
- get: function () {
146
- return unplugin$1;
147
- }
148
- });
149
- Object.defineProperty(exports, 'unpluginFactory', {
150
- enumerable: true,
151
- get: function () {
152
- return unpluginFactory;
153
- }
154
- });
155
- //# sourceMappingURL=src-BiN2tznZ.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"src-BiN2tznZ.cjs","names":["AsyncEventEmitter","process","version","error","failedPlugins","unpluginVersion","unplugin"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["","import process from 'node:process'\nimport { type Config, type KubbEvents, safeBuild } from '@kubb/core'\nimport { AsyncEventEmitter } from '@kubb/core/utils'\nimport type { UnpluginFactory } from 'unplugin'\nimport { createUnplugin } 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 } = 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)\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\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory)\n\nexport default unplugin\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACcA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,SAAS,IAAIA,oCAA+B;CAClD,MAAM,SAAS,KAAK,cAAc;CAClC,MAAM,UAAUC,qBAAQ,QAAQ;CAEhC,eAAe,SAAS,KAAoB;AAC1C,MAAI,CAAC,SAAS,QAAQ;AACpB,OAAI,IAAI,MACN,KAAI,QAAQ,IAAI,KAAK,qBAAqB;OAE1C,SAAQ,MAAM,IAAI,KAAK,qBAAqB;AAE9C;;AAGF,S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AG;IACH,QAAQ;KACN,OAAO;KACP,GAAG,WAAW;KACf;IACF;GACD;GACD,CAAC;AAGF,MADoB,cAAc,OAAO,KAAK,MAU5C,CAP2B,CACzB,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,OAAiB;AAC7D,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;EAC1B,MAAM,aAAa;AACjB,SAAM,SAAS,KAAiC;;EAGlD,MAAM,EAAE;EACT;;AAGH,MAAaK,aAA2B,6CAAe,gBAAgB;AAEvE,kBAAeA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"src-CiUcBKSs.js","names":["version","error","failedPlugins","unpluginVersion"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["","import process from 'node:process'\nimport { type Config, type KubbEvents, safeBuild } from '@kubb/core'\nimport { AsyncEventEmitter } from '@kubb/core/utils'\nimport type { UnpluginFactory } from 'unplugin'\nimport { createUnplugin } 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 } = 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)\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\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory)\n\nexport default unplugin\n"],"mappings":";;;;;;;;;;;ACcA,MAAa,mBAAyD,SAAS,SAAS;CACtF,MAAM,OAAO;CACb,MAAM,SAAS,IAAI,mBAA+B;CAClD,MAAM,SAAS,KAAK,cAAc;CAClC,MAAM,UAAU,QAAQ,QAAQ;CAEhC,eAAe,SAAS,KAAoB;AAC1C,MAAI,CAAC,SAAS,QAAQ;AACpB,OAAI,IAAI,MACN,KAAI,QAAQ,IAAI,KAAK,qBAAqB;OAE1C,SAAQ,MAAM,IAAI,KAAK,qBAAqB;AAE9C;;AAGF,SAAO,GAAG,oBAAoB,cAAY;AACxC,WAAQ,IAAI,iBAAiBA,UAAQ,KAAK;IAC1C;AAEF,SAAO,GAAG,UAAU,YAAU;AAC5B,WAAQ,MAAM,KAAKC,SAAO,WAAW,WAAW;IAChD;AAEF,SAAO,GAAG,SAAS,YAAY;AAC7B,WAAQ,KAAK,KAAK,UAAU;IAC5B;AAEF,SAAO,GAAG,SAAS,YAAY;AAC7B,WAAQ,KAAK,KAAK,UAAU;IAC5B;AAEF,SAAO,GAAG,YAAY,YAAY;AAChC,WAAQ,IAAI,KAAK,UAAU;IAC3B;AAEF,SAAO,GAAG,eAAe,QAAQ,EAAE,eAAe;GAChD,MAAM,cAAc,YAAY,MAAO,IAAI,WAAW,KAAM,QAAQ,EAAE,CAAC,KAAK,GAAG,SAAS;AAExF,WAAQ,IAAI,KAAK,OAAO,KAAK,gBAAgB,cAAc;IAC3D;AAEF,SAAO,GAAG,8BAA8B;AAGtC,WAAQ,IAFK,+B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