unplugin-kubb 4.0.2 → 5.0.1

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 (88) hide show
  1. package/LICENSE +10 -17
  2. package/dist/astro.cjs +7 -8
  3. package/dist/astro.cjs.map +1 -1
  4. package/dist/astro.d.ts +3 -8
  5. package/dist/astro.js +7 -9
  6. package/dist/astro.js.map +1 -1
  7. package/dist/{chunk-CIm-hhu7.js → chunk--u3MIqq1.js} +2 -3
  8. package/dist/esbuild.cjs +3 -5
  9. package/dist/esbuild.cjs.map +1 -1
  10. package/dist/esbuild.d.ts +4 -4
  11. package/dist/esbuild.js +2 -3
  12. package/dist/esbuild.js.map +1 -1
  13. package/dist/farm.cjs +7 -0
  14. package/dist/farm.cjs.map +1 -0
  15. package/dist/farm.d.ts +9 -0
  16. package/dist/farm.js +8 -0
  17. package/dist/farm.js.map +1 -0
  18. package/dist/index.cjs +12 -5
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.ts +6 -7
  21. package/dist/index.js +7 -2
  22. package/dist/index.js.map +1 -0
  23. package/dist/nuxt.cjs +8 -9
  24. package/dist/nuxt.cjs.map +1 -1
  25. package/dist/nuxt.d.ts +2 -2
  26. package/dist/nuxt.js +4 -5
  27. package/dist/nuxt.js.map +1 -1
  28. package/dist/rolldown.cjs +7 -0
  29. package/dist/rolldown.cjs.map +1 -0
  30. package/dist/rolldown.d.ts +9 -0
  31. package/dist/rolldown.js +8 -0
  32. package/dist/rolldown.js.map +1 -0
  33. package/dist/rollup.cjs +3 -5
  34. package/dist/rollup.cjs.map +1 -1
  35. package/dist/rollup.d.ts +4 -4
  36. package/dist/rollup.js +2 -3
  37. package/dist/rollup.js.map +1 -1
  38. package/dist/rspack.cjs +3 -5
  39. package/dist/rspack.cjs.map +1 -1
  40. package/dist/rspack.d.ts +2 -2
  41. package/dist/rspack.js +2 -3
  42. package/dist/rspack.js.map +1 -1
  43. package/dist/types.d.ts +13 -2
  44. package/dist/types.js +1 -1
  45. package/dist/unpluginFactory-0sYXb5x6.js +157 -0
  46. package/dist/unpluginFactory-0sYXb5x6.js.map +1 -0
  47. package/dist/unpluginFactory-BpZ2psBF.cjs +200 -0
  48. package/dist/unpluginFactory-BpZ2psBF.cjs.map +1 -0
  49. package/dist/unpluginFactory.cjs +3 -0
  50. package/dist/unpluginFactory.d.ts +9 -0
  51. package/dist/unpluginFactory.js +2 -0
  52. package/dist/vite.cjs +3 -5
  53. package/dist/vite.cjs.map +1 -1
  54. package/dist/vite.d.ts +4 -4
  55. package/dist/vite.js +2 -3
  56. package/dist/vite.js.map +1 -1
  57. package/dist/webpack.cjs +3 -5
  58. package/dist/webpack.cjs.map +1 -1
  59. package/dist/webpack.d.ts +2 -2
  60. package/dist/webpack.js +2 -3
  61. package/dist/webpack.js.map +1 -1
  62. package/package.json +69 -42
  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 +0 -95
  83. package/dist/src-CiUcBKSs.js.map +0 -1
  84. package/dist/types-C-ZTDGdJ.d.cts +0 -650
  85. package/dist/types-CUVJ-CBJ.d.ts +0 -649
  86. package/dist/types.d.cts +0 -2
  87. package/dist/vite.d.cts +0 -7
  88. package/dist/webpack.d.cts +0 -8
@@ -1,650 +0,0 @@
1
- import { KubbFile } from "@kubb/fabric-core/types";
2
- import { Fabric } from "@kubb/react-fabric";
3
-
4
- //#region rolldown:runtime
5
- //#endregion
6
- //#region ../core/src/Kubb.d.ts
7
- type DebugEvent = {
8
- date: Date;
9
- logs: string[];
10
- fileName?: string;
11
- };
12
- type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
13
- hookName: H;
14
- plugins: Array<Plugin>;
15
- };
16
- type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
17
- hookName: H;
18
- };
19
- type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
20
- strategy: Strategy;
21
- hookName: H;
22
- plugin: Plugin;
23
- parameters?: unknown[] | undefined;
24
- output?: unknown;
25
- };
26
- type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
27
- duration: number;
28
- strategy: Strategy;
29
- hookName: H;
30
- plugin: Plugin;
31
- parameters?: unknown[] | undefined;
32
- output?: unknown;
33
- };
34
- /**
35
- * Events emitted during the Kubb code generation lifecycle.
36
- * These events can be listened to for logging, progress tracking, and custom integrations.
37
- *
38
- * @example
39
- * ```typescript
40
- * import type { AsyncEventEmitter } from '@kubb/core'
41
- * import type { KubbEvents } from '@kubb/core'
42
- *
43
- * const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
44
- *
45
- * events.on('lifecycle:start', () => {
46
- * console.log('Starting Kubb generation')
47
- * })
48
- *
49
- * events.on('plugin:end', (plugin, { duration }) => {
50
- * console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
51
- * })
52
- * ```
53
- */
54
- interface KubbEvents {
55
- /**
56
- * Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
57
- */
58
- 'lifecycle:start': [version: string];
59
- /**
60
- * Emitted at the end of the Kubb lifecycle, after all code generation is complete.
61
- */
62
- 'lifecycle:end': [];
63
- /**
64
- * Emitted when configuration loading starts.
65
- */
66
- 'config:start': [];
67
- /**
68
- * Emitted when configuration loading is complete.
69
- */
70
- 'config:end': [configs: Array<Config>];
71
- /**
72
- * Emitted when code generation phase starts.
73
- */
74
- 'generation:start': [config: Config];
75
- /**
76
- * Emitted when code generation phase completes.
77
- */
78
- 'generation:end': [Config: Config];
79
- /**
80
- * Emitted with a summary of the generation results.
81
- * Contains summary lines, title, and success status.
82
- */
83
- 'generation:summary': [Config: Config, {
84
- failedPlugins: Set<{
85
- plugin: Plugin;
86
- error: Error;
87
- }>;
88
- status: 'success' | 'failed';
89
- hrStart: [number, number];
90
- filesCreated: number;
91
- pluginTimings?: Map<string, number>;
92
- }];
93
- /**
94
- * Emitted when code formatting starts (e.g., running Biome or Prettier).
95
- */
96
- 'format:start': [];
97
- /**
98
- * Emitted when code formatting completes.
99
- */
100
- 'format:end': [];
101
- /**
102
- * Emitted when linting starts.
103
- */
104
- 'lint:start': [];
105
- /**
106
- * Emitted when linting completes.
107
- */
108
- 'lint:end': [];
109
- /**
110
- * Emitted when plugin hooks execution starts.
111
- */
112
- 'hooks:start': [];
113
- /**
114
- * Emitted when plugin hooks execution completes.
115
- */
116
- 'hooks:end': [];
117
- /**
118
- * Emitted when a single hook execution starts. (e.g., format or lint).
119
- * The callback should be invoked when the command completes.
120
- */
121
- 'hook:start': [{
122
- id?: string;
123
- command: string;
124
- args?: readonly string[];
125
- }];
126
- /**
127
- * Emitted when a single hook execution completes.
128
- */
129
- 'hook:end': [{
130
- id?: string;
131
- command: string;
132
- args?: readonly string[];
133
- success: boolean;
134
- error: Error | null;
135
- }];
136
- /**
137
- * Emitted when a new version of Kubb is available.
138
- */
139
- 'version:new': [currentVersion: string, latestVersion: string];
140
- /**
141
- * Informational message event.
142
- */
143
- info: [message: string, info?: string];
144
- /**
145
- * Error event. Emitted when an error occurs during code generation.
146
- */
147
- error: [error: Error, meta?: Record<string, unknown>];
148
- /**
149
- * Success message event.
150
- */
151
- success: [message: string, info?: string];
152
- /**
153
- * Warning message event.
154
- */
155
- warn: [message: string, info?: string];
156
- /**
157
- * Debug event for detailed logging.
158
- * Contains timestamp, log messages, and optional filename.
159
- */
160
- debug: [meta: DebugEvent];
161
- /**
162
- * Emitted when file processing starts.
163
- * Contains the list of files to be processed.
164
- */
165
- 'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
166
- /**
167
- * Emitted for each file being processed, providing progress updates.
168
- * Contains processed count, total count, percentage, and file details.
169
- */
170
- 'file:processing:update': [{
171
- /** Number of files processed so far */
172
- processed: number;
173
- /** Total number of files to process */
174
- total: number;
175
- /** Processing percentage (0-100) */
176
- percentage: number;
177
- /** Optional source identifier */
178
- source?: string;
179
- /** The file being processed */
180
- file: KubbFile.ResolvedFile;
181
- /**
182
- * Kubb configuration (not present in Fabric).
183
- * Provides access to the current config during file processing.
184
- */
185
- config: Config;
186
- }];
187
- /**
188
- * Emitted when file processing completes.
189
- * Contains the list of processed files.
190
- */
191
- 'files:processing:end': [files: KubbFile.ResolvedFile[]];
192
- /**
193
- * Emitted when a plugin starts executing.
194
- */
195
- 'plugin:start': [plugin: Plugin];
196
- /**
197
- * Emitted when a plugin completes execution.
198
- * Duration in ms
199
- */
200
- 'plugin:end': [plugin: Plugin, meta: {
201
- duration: number;
202
- success: boolean;
203
- error?: Error;
204
- }];
205
- /**
206
- * Emitted when plugin hook progress tracking starts.
207
- * Contains the hook name and list of plugins to execute.
208
- */
209
- 'plugins:hook:progress:start': [meta: ProgressStartMeta];
210
- /**
211
- * Emitted when plugin hook progress tracking ends.
212
- * Contains the hook name that completed.
213
- */
214
- 'plugins:hook:progress:end': [meta: ProgressStopMeta];
215
- /**
216
- * Emitted when a plugin hook starts processing.
217
- * Contains strategy, hook name, plugin, parameters, and output.
218
- */
219
- 'plugins:hook:processing:start': [meta: ExecutingMeta];
220
- /**
221
- * Emitted when a plugin hook completes processing.
222
- * Contains duration, strategy, hook name, plugin, parameters, and output.
223
- */
224
- 'plugins:hook:processing:end': [meta: ExecutedMeta];
225
- }
226
- //#endregion
227
- //#region ../core/src/utils/AsyncEventEmitter.d.ts
228
- declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
229
- #private;
230
- constructor(maxListener?: number);
231
- emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
232
- on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
233
- onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
234
- off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
235
- removeAll(): void;
236
- }
237
- //#endregion
238
- //#region ../core/src/utils/types.d.ts
239
- type PossiblePromise<T> = Promise<T> | T;
240
- //#endregion
241
- //#region ../core/src/types.d.ts
242
- declare global {
243
- namespace Kubb {
244
- interface PluginContext {}
245
- }
246
- }
247
- /**
248
- * Config used in `kubb.config.ts`
249
- *
250
- * @example
251
- * import { defineConfig } from '@kubb/core'
252
- * export default defineConfig({
253
- * ...
254
- * })
255
- */
256
- type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
257
- /**
258
- * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
259
- * @default process.cwd()
260
- */
261
- root?: string;
262
- /**
263
- * An array of Kubb plugins used for generation. Each plugin may have additional configurable options (defined within the plugin itself). If a plugin relies on another plugin, an error will occur if the required dependency is missing. Refer to “pre” for more details.
264
- */
265
- plugins?: Array<Omit<UnknownUserPlugin, 'inject'>>;
266
- };
267
- type InputPath = {
268
- /**
269
- * Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
270
- */
271
- path: string;
272
- };
273
- type InputData = {
274
- /**
275
- * A `string` or `object` that contains your Swagger/OpenAPI data.
276
- */
277
- data: string | unknown;
278
- };
279
- type Input = InputPath | InputData | Array<InputPath>;
280
- type BarrelType = 'all' | 'named' | 'propagate';
281
- /**
282
- * @private
283
- */
284
- type Config<TInput = Input> = {
285
- /**
286
- * The name to display in the CLI output.
287
- */
288
- name?: string;
289
- /**
290
- * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
291
- * @default process.cwd()
292
- */
293
- root: string;
294
- /**
295
- * You can use either `input.path` or `input.data`, depending on your specific needs.
296
- */
297
- input: TInput;
298
- output: {
299
- /**
300
- * The path where all generated files will be exported.
301
- * This can be an absolute path or a path relative to the specified root option.
302
- */
303
- path: string;
304
- /**
305
- * Clean the output directory before each build.
306
- */
307
- clean?: boolean;
308
- /**
309
- * Save files to the file system.
310
- * @default true
311
- */
312
- write?: boolean;
313
- /**
314
- * Specifies the formatting tool to be used.
315
- * @default prettier
316
- *
317
- * Possible values:
318
- * - 'auto': Automatically detects and uses biome or prettier (in that order of preference).
319
- * - 'prettier': Uses Prettier for code formatting.
320
- * - 'biome': Uses Biome for code formatting.
321
- *
322
- */
323
- format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
324
- /**
325
- * Specifies the linter that should be used to analyze the code.
326
- * The accepted values indicate different linting tools.
327
- *
328
- * Possible values:
329
- * - 'auto': Automatically detects and uses biome, oxlint, or eslint (in that order of preference).
330
- * - 'eslint': Represents the use of ESLint, a widely used JavaScript linter.
331
- * - 'biome': Represents the Biome linter, a modern tool for code scanning.
332
- * - 'oxlint': Represents the Oxlint tool for linting purposes.
333
- *
334
- */
335
- lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
336
- /**
337
- * Override the extension to the generated imports and exports, by default each plugin will add an extension
338
- * @default { '.ts': '.ts'}
339
- */
340
- extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
341
- /**
342
- * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
343
- * @default 'named'
344
- */
345
- barrelType?: Exclude<BarrelType, 'propagate'> | false;
346
- /**
347
- * Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
348
- * - 'simple': will only add banner with link to Kubb
349
- * - 'full': will add source, title, description and the OpenAPI version used
350
- * @default 'simple'
351
- */
352
- defaultBanner?: 'simple' | 'full' | false;
353
- /**
354
- * Whether to override existing external files if they already exist.
355
- * When setting the option in the global configuration, all plugins inherit the same behavior by default.
356
- * However, all plugins also have an `output.override` option, which can be used to override the behavior for a specific plugin.
357
- * @default false
358
- */
359
- override?: boolean;
360
- };
361
- /**
362
- * An array of Kubb plugins that will be used in the generation.
363
- * Each plugin may include additional configurable options(defined in the plugin itself).
364
- * If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
365
- */
366
- plugins?: Array<Plugin>;
367
- /**
368
- * Hooks that will be called when a specific action is triggered in Kubb.
369
- */
370
- hooks?: {
371
- /**
372
- * Hook that will be triggered at the end of all executions.
373
- * Useful for running Prettier or ESLint to format/lint your code.
374
- */
375
- done?: string | Array<string>;
376
- };
377
- };
378
- type PluginFactoryOptions<
379
- /**
380
- * Name to be used for the plugin, this will also be used for they key.
381
- */
382
- TName extends string = string,
383
- /**
384
- * Options of the plugin.
385
- */
386
- TOptions extends object = object,
387
- /**
388
- * Options of the plugin that can be used later on, see `options` inside your plugin config.
389
- */
390
- TResolvedOptions extends object = TOptions,
391
- /**
392
- * Context that you want to expose to other plugins.
393
- */
394
- TContext = any,
395
- /**
396
- * When calling `resolvePath` you can specify better types.
397
- */
398
- TResolvePathOptions extends object = object> = {
399
- name: TName;
400
- /**
401
- * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
402
- */
403
- key: PluginKey<TName | string>;
404
- options: TOptions;
405
- resolvedOptions: TResolvedOptions;
406
- context: TContext;
407
- resolvePathOptions: TResolvePathOptions;
408
- };
409
- type PluginKey<TName> = [name: TName, identifier?: string | number];
410
- type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
411
- /**
412
- * Unique name used for the plugin
413
- * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
414
- * @example @kubb/typescript
415
- */
416
- name: TOptions['name'];
417
- /**
418
- * Options set for a specific plugin(see kubb.config.js), passthrough of options.
419
- */
420
- options: TOptions['resolvedOptions'];
421
- /**
422
- * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
423
- * Can be used to validate dependent plugins.
424
- */
425
- pre?: Array<string>;
426
- /**
427
- * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
428
- */
429
- post?: Array<string>;
430
- inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
431
- };
432
- type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
433
- type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
434
- /**
435
- * Unique name used for the plugin
436
- * @example @kubb/typescript
437
- */
438
- name: TOptions['name'];
439
- /**
440
- * Internal key used when a developer uses more than one of the same plugin
441
- * @private
442
- */
443
- key: TOptions['key'];
444
- /**
445
- * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
446
- * Can be used to validate dependent plugins.
447
- */
448
- pre?: Array<string>;
449
- /**
450
- * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
451
- */
452
- post?: Array<string>;
453
- /**
454
- * Options set for a specific plugin(see kubb.config.js), passthrough of options.
455
- */
456
- options: TOptions['resolvedOptions'];
457
- install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
458
- /**
459
- * Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `definePlugin`).
460
- */
461
- inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
462
- };
463
- type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
464
- type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
465
- /**
466
- * Start of the lifecycle of a plugin.
467
- * @type hookParallel
468
- */
469
- install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
470
- /**
471
- * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
472
- * Options can als be included.
473
- * @type hookFirst
474
- * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
475
- */
476
- resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
477
- /**
478
- * Resolve to a name based on a string.
479
- * Useful when converting to PascalCase or camelCase.
480
- * @type hookFirst
481
- * @example ('pet') => 'Pet'
482
- */
483
- resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
484
- };
485
- type PluginLifecycleHooks = keyof PluginLifecycle;
486
- type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
487
- type ResolvePathParams<TOptions = object> = {
488
- pluginKey?: Plugin['key'];
489
- baseName: KubbFile.BaseName;
490
- mode?: KubbFile.Mode;
491
- /**
492
- * Options to be passed to 'resolvePath' 3th parameter
493
- */
494
- options?: TOptions;
495
- };
496
- type ResolveNameParams = {
497
- name: string;
498
- pluginKey?: Plugin['key'];
499
- /**
500
- * `file` will be used to customize the name of the created file(use of camelCase)
501
- * `function` can be used to customize the exported functions(use of camelCase)
502
- * `type` is a special type for TypeScript(use of PascalCase)
503
- * `const` can be used for variables(use of camelCase)
504
- */
505
- type?: 'file' | 'function' | 'type' | 'const';
506
- };
507
- type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
508
- fabric: Fabric;
509
- config: Config;
510
- pluginManager: PluginManager;
511
- /**
512
- * Only add when the file does not exist yet
513
- */
514
- addFile: (...file: Array<KubbFile.File>) => Promise<void>;
515
- /**
516
- * merging multiple sources into the same output file
517
- */
518
- upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
519
- events: AsyncEventEmitter<KubbEvents>;
520
- mode: KubbFile.Mode;
521
- /**
522
- * Current plugin
523
- */
524
- plugin: Plugin<TOptions>;
525
- } & Kubb.PluginContext;
526
- //#endregion
527
- //#region ../core/src/PluginManager.d.ts
528
- type RequiredPluginLifecycle = Required<PluginLifecycle>;
529
- type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
530
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
531
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
532
- result: Result;
533
- plugin: Plugin;
534
- };
535
- type Options$1 = {
536
- fabric: Fabric;
537
- events: AsyncEventEmitter<KubbEvents>;
538
- /**
539
- * @default Number.POSITIVE_INFINITY
540
- */
541
- concurrency?: number;
542
- };
543
- type GetFileProps<TOptions = object> = {
544
- name: string;
545
- mode?: KubbFile.Mode;
546
- extname: KubbFile.Extname;
547
- pluginKey: Plugin['key'];
548
- options?: TOptions;
549
- };
550
- declare class PluginManager {
551
- #private;
552
- readonly config: Config;
553
- readonly options: Options$1;
554
- constructor(config: Config, options: Options$1);
555
- get events(): AsyncEventEmitter<KubbEvents>;
556
- getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
557
- get plugins(): Array<Plugin>;
558
- getFile<TOptions = object>({
559
- name,
560
- mode,
561
- extname,
562
- pluginKey,
563
- options
564
- }: GetFileProps<TOptions>): KubbFile.File<{
565
- pluginKey: Plugin['key'];
566
- }>;
567
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
568
- resolveName: (params: ResolveNameParams) => string;
569
- /**
570
- * Run a specific hookName for plugin x.
571
- */
572
- hookForPlugin<H extends PluginLifecycleHooks>({
573
- pluginKey,
574
- hookName,
575
- parameters
576
- }: {
577
- pluginKey: Plugin['key'];
578
- hookName: H;
579
- parameters: PluginParameter<H>;
580
- }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
581
- /**
582
- * Run a specific hookName for plugin x.
583
- */
584
- hookForPluginSync<H extends PluginLifecycleHooks>({
585
- pluginKey,
586
- hookName,
587
- parameters
588
- }: {
589
- pluginKey: Plugin['key'];
590
- hookName: H;
591
- parameters: PluginParameter<H>;
592
- }): Array<ReturnType<ParseResult<H>>> | null;
593
- /**
594
- * First non-null result stops and will return it's value.
595
- */
596
- hookFirst<H extends PluginLifecycleHooks>({
597
- hookName,
598
- parameters,
599
- skipped
600
- }: {
601
- hookName: H;
602
- parameters: PluginParameter<H>;
603
- skipped?: ReadonlySet<Plugin> | null;
604
- }): Promise<SafeParseResult<H>>;
605
- /**
606
- * First non-null result stops and will return it's value.
607
- */
608
- hookFirstSync<H extends PluginLifecycleHooks>({
609
- hookName,
610
- parameters,
611
- skipped
612
- }: {
613
- hookName: H;
614
- parameters: PluginParameter<H>;
615
- skipped?: ReadonlySet<Plugin> | null;
616
- }): SafeParseResult<H>;
617
- /**
618
- * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
619
- */
620
- hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
621
- hookName,
622
- parameters
623
- }: {
624
- hookName: H;
625
- parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
626
- }): Promise<Awaited<TOuput>[]>;
627
- /**
628
- * Chains plugins
629
- */
630
- hookSeq<H extends PluginLifecycleHooks>({
631
- hookName,
632
- parameters
633
- }: {
634
- hookName: H;
635
- parameters?: PluginParameter<H>;
636
- }): Promise<void>;
637
- getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
638
- getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
639
- }
640
- //#endregion
641
- //#region src/types.d.ts
642
- type Options = {
643
- /**
644
- * Kubb config without the Hooks.
645
- */
646
- config?: Omit<UserConfig, 'hooks'>;
647
- };
648
- //#endregion
649
- export { __name as n, Options as t };
650
- //# sourceMappingURL=types-C-ZTDGdJ.d.cts.map