unplugin-kubb 2.0.2 → 3.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 (65) hide show
  1. package/LICENSE +1 -1
  2. package/dist/astro.cjs +11 -87
  3. package/dist/astro.cjs.map +1 -0
  4. package/dist/astro.d.cts +8 -8
  5. package/dist/astro.d.ts +8 -7
  6. package/dist/astro.js +11 -14
  7. package/dist/astro.js.map +1 -0
  8. package/dist/esbuild.cjs +8 -79
  9. package/dist/esbuild.cjs.map +1 -0
  10. package/dist/esbuild.d.cts +6 -6
  11. package/dist/esbuild.d.ts +6 -5
  12. package/dist/esbuild.js +7 -8
  13. package/dist/esbuild.js.map +1 -0
  14. package/dist/index.cjs +5 -83
  15. package/dist/index.d.cts +7 -6
  16. package/dist/index.d.ts +7 -6
  17. package/dist/index.js +3 -10
  18. package/dist/nuxt.cjs +20 -99
  19. package/dist/nuxt.cjs.map +1 -0
  20. package/dist/nuxt.d.cts +8 -8
  21. package/dist/nuxt.d.ts +8 -8
  22. package/dist/nuxt.js +18 -21
  23. package/dist/nuxt.js.map +1 -0
  24. package/dist/rollup.cjs +8 -79
  25. package/dist/rollup.cjs.map +1 -0
  26. package/dist/rollup.d.cts +6 -6
  27. package/dist/rollup.d.ts +6 -5
  28. package/dist/rollup.js +7 -8
  29. package/dist/rollup.js.map +1 -0
  30. package/dist/rspack.cjs +8 -79
  31. package/dist/rspack.cjs.map +1 -0
  32. package/dist/rspack.d.cts +4 -4
  33. package/dist/rspack.d.ts +4 -3
  34. package/dist/rspack.js +7 -8
  35. package/dist/rspack.js.map +1 -0
  36. package/dist/src-DnCwQQFX.js +50 -0
  37. package/dist/src-DnCwQQFX.js.map +1 -0
  38. package/dist/src-INEri0Ub.cjs +99 -0
  39. package/dist/src-INEri0Ub.cjs.map +1 -0
  40. package/dist/types-BHypkRQJ.d.cts +660 -0
  41. package/dist/types-CFQIMFRS.d.ts +660 -0
  42. package/dist/types.cjs +0 -18
  43. package/dist/types.d.cts +2 -10
  44. package/dist/types.d.ts +2 -10
  45. package/dist/types.js +1 -0
  46. package/dist/vite-D_U2l8No.js +9 -0
  47. package/dist/vite-D_U2l8No.js.map +1 -0
  48. package/dist/vite-Df2FT-jf.cjs +15 -0
  49. package/dist/vite-Df2FT-jf.cjs.map +1 -0
  50. package/dist/vite.cjs +3 -80
  51. package/dist/vite.d.cts +6 -6
  52. package/dist/vite.d.ts +6 -5
  53. package/dist/vite.js +4 -7
  54. package/dist/webpack-CQIEgBNc.js +9 -0
  55. package/dist/webpack-CQIEgBNc.js.map +1 -0
  56. package/dist/webpack-D2VoiCsm.cjs +15 -0
  57. package/dist/webpack-D2VoiCsm.cjs.map +1 -0
  58. package/dist/webpack.cjs +3 -80
  59. package/dist/webpack.d.cts +6 -6
  60. package/dist/webpack.d.ts +6 -5
  61. package/dist/webpack.js +4 -7
  62. package/package.json +43 -55
  63. package/dist/chunk-4WNCII7J.js +0 -11
  64. package/dist/chunk-6YF7O2R7.js +0 -59
  65. package/dist/chunk-EJWH3EPL.js +0 -11
@@ -0,0 +1,660 @@
1
+ import { ConsolaInstance, LogLevel } from "consola";
2
+
3
+ //#region ../core/src/fs/types.d.ts
4
+ type BasePath<T extends string = string> = `${T}/`;
5
+ type Import = {
6
+ /**
7
+ * Import name to be used
8
+ * @example ["useState"]
9
+ * @example "React"
10
+ */
11
+ name: string | Array<string | {
12
+ propertyName: string;
13
+ name?: string;
14
+ }>;
15
+ /**
16
+ * Path for the import
17
+ * @example '@kubb/core'
18
+ */
19
+ path: string;
20
+ /**
21
+ * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
22
+ */
23
+ isTypeOnly?: boolean;
24
+ isNameSpace?: boolean;
25
+ /**
26
+ * When root is set it will get the path with relative getRelativePath(root, path).
27
+ */
28
+ root?: string;
29
+ };
30
+ type Source = {
31
+ name?: string;
32
+ value?: string;
33
+ isTypeOnly?: boolean;
34
+ /**
35
+ * Has const or type 'export'
36
+ * @default false
37
+ */
38
+ isExportable?: boolean;
39
+ /**
40
+ * When set, barrel generation will add this
41
+ * @default false
42
+ */
43
+ isIndexable?: boolean;
44
+ };
45
+ type Export = {
46
+ /**
47
+ * Export name to be used.
48
+ * @example ["useState"]
49
+ * @example "React"
50
+ */
51
+ name?: string | Array<string>;
52
+ /**
53
+ * Path for the import.
54
+ * @example '@kubb/core'
55
+ */
56
+ path: string;
57
+ /**
58
+ * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
59
+ */
60
+ isTypeOnly?: boolean;
61
+ /**
62
+ * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
63
+ */
64
+ asAlias?: boolean;
65
+ };
66
+ type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
67
+ type Mode = 'single' | 'split';
68
+ /**
69
+ * Name to be used to dynamicly create the baseName(based on input.path)
70
+ * Based on UNIX basename
71
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
72
+ */
73
+ type BaseName = `${string}.${string}`;
74
+ /**
75
+ * Path will be full qualified path to a specified file
76
+ */
77
+ type Path = string;
78
+ type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
79
+ type OptionalPath = Path | undefined | null;
80
+ type File<TMeta extends object = object> = {
81
+ /**
82
+ * Name to be used to create the path
83
+ * Based on UNIX basename, `${name}.extname`
84
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
85
+ */
86
+ baseName: BaseName;
87
+ /**
88
+ * Path will be full qualified path to a specified file
89
+ */
90
+ path: AdvancedPath<BaseName> | Path;
91
+ sources: Array<Source>;
92
+ imports?: Array<Import>;
93
+ exports?: Array<Export>;
94
+ /**
95
+ * Use extra meta, this is getting used to generate the barrel/index files.
96
+ */
97
+ meta?: TMeta;
98
+ banner?: string;
99
+ footer?: string;
100
+ };
101
+ type ResolvedImport = Import;
102
+ type ResolvedExport = Export;
103
+ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
104
+ /**
105
+ * @default object-hash
106
+ */
107
+ id: string;
108
+ /**
109
+ * Contains the first part of the baseName, generated based on baseName
110
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
111
+ */
112
+ name: string;
113
+ extname: Extname;
114
+ imports: Array<ResolvedImport>;
115
+ exports: Array<ResolvedExport>;
116
+ };
117
+ //#endregion
118
+ //#region ../core/src/utils/EventEmitter.d.ts
119
+ declare class EventEmitter<TEvents extends Record<string, any>> {
120
+ #private;
121
+ constructor();
122
+ emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
123
+ on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
124
+ off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
125
+ removeAll(): void;
126
+ }
127
+ //#endregion
128
+ //#region ../core/src/logger.d.ts
129
+ type DebugEvent = {
130
+ date: Date;
131
+ logs: string[];
132
+ fileName?: string;
133
+ };
134
+ type Events$1 = {
135
+ start: [message: string];
136
+ success: [message: string];
137
+ error: [message: string, cause: Error];
138
+ warning: [message: string];
139
+ debug: [DebugEvent];
140
+ info: [message: string];
141
+ progress_start: [{
142
+ id: string;
143
+ size: number;
144
+ message?: string;
145
+ }];
146
+ progressed: [{
147
+ id: string;
148
+ message?: string;
149
+ }];
150
+ progress_stop: [{
151
+ id: string;
152
+ }];
153
+ };
154
+ type Logger = {
155
+ /**
156
+ * Optional config name to show in CLI output
157
+ */
158
+ name?: string;
159
+ logLevel: LogLevel;
160
+ consola?: ConsolaInstance;
161
+ on: EventEmitter<Events$1>['on'];
162
+ emit: EventEmitter<Events$1>['emit'];
163
+ writeLogs: () => Promise<string[]>;
164
+ };
165
+ //#endregion
166
+ //#region ../core/src/utils/types.d.ts
167
+ type PossiblePromise<T> = Promise<T> | T;
168
+ type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
169
+ type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
170
+ //#endregion
171
+ //#region ../core/src/types.d.ts
172
+ /**
173
+ * Config used in `kubb.config.ts`
174
+ *
175
+ * @example
176
+ * import { defineConfig } from '@kubb/core'
177
+ * export default defineConfig({
178
+ * ...
179
+ * })
180
+ */
181
+ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
182
+ /**
183
+ * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
184
+ * @default process.cwd()
185
+ */
186
+ root?: string;
187
+ /**
188
+ * 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.
189
+ */
190
+ plugins?: Array<Omit<UnknownUserPlugin, 'context'>>;
191
+ };
192
+ type InputPath = {
193
+ /**
194
+ * Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
195
+ */
196
+ path: string;
197
+ };
198
+ type InputData = {
199
+ /**
200
+ * A `string` or `object` that contains your Swagger/OpenAPI data.
201
+ */
202
+ data: string | unknown;
203
+ };
204
+ type Input = InputPath | InputData | Array<InputPath>;
205
+ type BarrelType = 'all' | 'named' | 'propagate';
206
+ /**
207
+ * @private
208
+ */
209
+ type Config<TInput = Input> = {
210
+ /**
211
+ * The name to display in the CLI output.
212
+ */
213
+ name?: string;
214
+ /**
215
+ * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
216
+ * @default process.cwd()
217
+ */
218
+ root: string;
219
+ /**
220
+ * You can use either `input.path` or `input.data`, depending on your specific needs.
221
+ */
222
+ input: TInput;
223
+ output: {
224
+ /**
225
+ * The path where all generated files will be exported.
226
+ * This can be an absolute path or a path relative to the specified root option.
227
+ */
228
+ path: string;
229
+ /**
230
+ * Clean the output directory before each build.
231
+ */
232
+ clean?: boolean;
233
+ /**
234
+ * Save files to the file system.
235
+ * @default true
236
+ */
237
+ write?: boolean;
238
+ /**
239
+ * Specifies the formatting tool to be used.
240
+ * @default prettier
241
+ *
242
+ * Possible values:
243
+ * - 'prettier': Uses Prettier for code formatting.
244
+ * - 'biome': Uses Biome for code formatting.
245
+ *
246
+ */
247
+ format?: 'prettier' | 'biome' | false;
248
+ /**
249
+ * Specifies the linter that should be used to analyze the code.
250
+ * The accepted values indicate different linting tools.
251
+ *
252
+ * Possible values:
253
+ * - 'eslint': Represents the use of ESLint, a widely used JavaScript linter.
254
+ * - 'biome': Represents the Biome linter, a modern tool for code scanning.
255
+ * - 'oxlint': Represents the Oxlint tool for linting purposes.
256
+ *
257
+ */
258
+ lint?: 'eslint' | 'biome' | 'oxlint' | false;
259
+ /**
260
+ * Override the extension to the generated imports and exports, by default each plugin will add an extension
261
+ * @default { '.ts': '.ts'}
262
+ */
263
+ extension?: Record<Extname, Extname | ''>;
264
+ /**
265
+ * 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`.
266
+ * @default 'named'
267
+ */
268
+ barrelType?: Exclude<BarrelType, 'propagate'> | false;
269
+ /**
270
+ * Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
271
+ * - 'simple': will only add banner with link to Kubb
272
+ * - 'full': will add source, title, description and the OpenAPI version used
273
+ * @default 'simple'
274
+ */
275
+ defaultBanner?: 'simple' | 'full' | false;
276
+ };
277
+ /**
278
+ * An array of Kubb plugins that will be used in the generation.
279
+ * Each plugin may include additional configurable options(defined in the plugin itself).
280
+ * If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
281
+ */
282
+ plugins?: Array<Plugin>;
283
+ /**
284
+ * Hooks that will be called when a specific action is triggered in Kubb.
285
+ */
286
+ hooks?: {
287
+ /**
288
+ * Hook that will be triggered at the end of all executions.
289
+ * Useful for running Prettier or ESLint to format/lint your code.
290
+ */
291
+ done?: string | Array<string>;
292
+ };
293
+ };
294
+ type PluginFactoryOptions<
295
+ /**
296
+ * Name to be used for the plugin, this will also be used for they key.
297
+ */
298
+ TName extends string = string,
299
+ /**
300
+ * Options of the plugin.
301
+ */
302
+ TOptions extends object = object,
303
+ /**
304
+ * Options of the plugin that can be used later on, see `options` inside your plugin config.
305
+ */
306
+ TResolvedOptions extends object = TOptions,
307
+ /**
308
+ * Context that you want to expose to other plugins.
309
+ */
310
+ TContext = any,
311
+ /**
312
+ * When calling `resolvePath` you can specify better types.
313
+ */
314
+ TResolvePathOptions extends object = object> = {
315
+ name: TName;
316
+ /**
317
+ * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
318
+ */
319
+ key: PluginKey<TName | string>;
320
+ options: TOptions;
321
+ resolvedOptions: TResolvedOptions;
322
+ context: TContext;
323
+ resolvePathOptions: TResolvePathOptions;
324
+ };
325
+ type PluginKey<TName> = [name: TName, identifier?: string | number];
326
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
327
+ /**
328
+ * Unique name used for the plugin
329
+ * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
330
+ * @example @kubb/typescript
331
+ */
332
+ name: TOptions['name'];
333
+ /**
334
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
335
+ */
336
+ options: TOptions['resolvedOptions'];
337
+ /**
338
+ * 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.
339
+ * Can be used to validate dependent plugins.
340
+ */
341
+ pre?: Array<string>;
342
+ /**
343
+ * 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.
344
+ */
345
+ post?: Array<string>;
346
+ } & (TOptions['context'] extends never ? {
347
+ context?: never;
348
+ } : {
349
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
350
+ });
351
+ type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
352
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
353
+ /**
354
+ * Unique name used for the plugin
355
+ * @example @kubb/typescript
356
+ */
357
+ name: TOptions['name'];
358
+ /**
359
+ * Internal key used when a developer uses more than one of the same plugin
360
+ * @private
361
+ */
362
+ key: TOptions['key'];
363
+ /**
364
+ * 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.
365
+ * Can be used to validate dependent plugins.
366
+ */
367
+ pre?: Array<string>;
368
+ /**
369
+ * 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.
370
+ */
371
+ post?: Array<string>;
372
+ /**
373
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
374
+ */
375
+ options: TOptions['resolvedOptions'];
376
+ } & (TOptions['context'] extends never ? {
377
+ context?: never;
378
+ } : {
379
+ context: TOptions['context'];
380
+ });
381
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
382
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
383
+ /**
384
+ * Start of the lifecycle of a plugin.
385
+ * @type hookParallel
386
+ */
387
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
388
+ /**
389
+ * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
390
+ * Options can als be included.
391
+ * @type hookFirst
392
+ * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
393
+ */
394
+ resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
395
+ /**
396
+ * Resolve to a name based on a string.
397
+ * Useful when converting to PascalCase or camelCase.
398
+ * @type hookFirst
399
+ * @example ('pet') => 'Pet'
400
+ */
401
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
402
+ /**
403
+ * End of the plugin lifecycle.
404
+ * @type hookParallel
405
+ */
406
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
407
+ };
408
+ type PluginLifecycleHooks = keyof PluginLifecycle;
409
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
410
+ type ResolvePathParams<TOptions = object> = {
411
+ pluginKey?: Plugin['key'];
412
+ baseName: BaseName;
413
+ mode?: Mode;
414
+ /**
415
+ * Options to be passed to 'resolvePath' 3th parameter
416
+ */
417
+ options?: TOptions;
418
+ };
419
+ type ResolveNameParams = {
420
+ name: string;
421
+ pluginKey?: Plugin['key'];
422
+ /**
423
+ * `file` will be used to customize the name of the created file(use of camelCase)
424
+ * `function` can be used to customize the exported functions(use of camelCase)
425
+ * `type` is a special type for TypeScript(use of PascalCase)
426
+ * `const` can be used for variables(use of camelCase)
427
+ */
428
+ type?: 'file' | 'function' | 'type' | 'const';
429
+ };
430
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
431
+ config: Config;
432
+ fileManager: FileManager;
433
+ pluginManager: PluginManager;
434
+ addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
435
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
436
+ resolveName: (params: ResolveNameParams) => string;
437
+ logger: Logger;
438
+ /**
439
+ * All plugins
440
+ */
441
+ plugins: Plugin[];
442
+ /**
443
+ * Current plugin
444
+ */
445
+ plugin: Plugin<TOptions>;
446
+ };
447
+ /**
448
+ * Specify the export location for the files and define the behavior of the output
449
+ */
450
+ //#endregion
451
+ //#region ../core/src/FileManager.d.ts
452
+ type FileMetaBase = {
453
+ pluginKey?: Plugin['key'];
454
+ };
455
+ type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
456
+ type AddIndexesProps = {
457
+ type: BarrelType | false | undefined;
458
+ /**
459
+ * Root based on root and output.path specified in the config
460
+ */
461
+ root: string;
462
+ /**
463
+ * Output for plugin
464
+ */
465
+ output: {
466
+ path: string;
467
+ };
468
+ group?: {
469
+ output: string;
470
+ exportAs: string;
471
+ };
472
+ logger?: Logger;
473
+ meta?: FileMetaBase;
474
+ };
475
+ type WriteFilesProps = {
476
+ root: Config['root'];
477
+ extension?: Record<Extname, Extname | ''>;
478
+ logger?: Logger;
479
+ dryRun?: boolean;
480
+ };
481
+ declare class FileManager {
482
+ #private;
483
+ constructor();
484
+ add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
485
+ getByPath(path: Path): Promise<ResolvedFile | null>;
486
+ deleteByPath(path: Path): Promise<void>;
487
+ clear(): Promise<void>;
488
+ getFiles(): Promise<Array<ResolvedFile>>;
489
+ processFiles({
490
+ dryRun,
491
+ root,
492
+ extension,
493
+ logger
494
+ }: WriteFilesProps): Promise<Array<ResolvedFile>>;
495
+ getBarrelFiles({
496
+ type,
497
+ meta,
498
+ root,
499
+ output,
500
+ logger
501
+ }: AddIndexesProps): Promise<File[]>;
502
+ static getMode(path: string | undefined | null): Mode;
503
+ }
504
+ //#endregion
505
+ //#region ../core/src/PluginManager.d.ts
506
+ type RequiredPluginLifecycle = Required<PluginLifecycle>;
507
+ type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
508
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
509
+ message: string;
510
+ strategy: Strategy;
511
+ hookName: H;
512
+ plugin: Plugin;
513
+ parameters?: unknown[] | undefined;
514
+ output?: unknown;
515
+ };
516
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
517
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
518
+ result: Result;
519
+ plugin: Plugin;
520
+ };
521
+ type Options$1 = {
522
+ logger: Logger;
523
+ /**
524
+ * @default Number.POSITIVE_INFINITY
525
+ */
526
+ concurrency?: number;
527
+ };
528
+ type Events = {
529
+ executing: [executer: Executer];
530
+ executed: [executer: Executer];
531
+ error: [error: Error];
532
+ };
533
+ type GetFileProps<TOptions = object> = {
534
+ name: string;
535
+ mode?: Mode;
536
+ extname: Extname;
537
+ pluginKey: Plugin['key'];
538
+ options?: TOptions;
539
+ };
540
+ declare class PluginManager {
541
+ #private;
542
+ readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
543
+ readonly fileManager: FileManager;
544
+ readonly events: EventEmitter<Events>;
545
+ readonly config: Config;
546
+ readonly executed: Array<Executer>;
547
+ readonly logger: Logger;
548
+ readonly options: Options$1;
549
+ constructor(config: Config, options: Options$1);
550
+ getFile<TOptions = object>({
551
+ name,
552
+ mode,
553
+ extname,
554
+ pluginKey,
555
+ options
556
+ }: GetFileProps<TOptions>): File<{
557
+ pluginKey: Plugin['key'];
558
+ }>;
559
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
560
+ resolveName: (params: ResolveNameParams) => string;
561
+ /**
562
+ * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
563
+ */
564
+ on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
565
+ /**
566
+ * Run a specific hookName for plugin x.
567
+ */
568
+ hookForPlugin<H extends PluginLifecycleHooks>({
569
+ pluginKey,
570
+ hookName,
571
+ parameters,
572
+ message
573
+ }: {
574
+ pluginKey: Plugin['key'];
575
+ hookName: H;
576
+ parameters: PluginParameter<H>;
577
+ message: string;
578
+ }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
579
+ /**
580
+ * Run a specific hookName for plugin x.
581
+ */
582
+ hookForPluginSync<H extends PluginLifecycleHooks>({
583
+ pluginKey,
584
+ hookName,
585
+ parameters,
586
+ message
587
+ }: {
588
+ pluginKey: Plugin['key'];
589
+ hookName: H;
590
+ parameters: PluginParameter<H>;
591
+ message: string;
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
+ message
601
+ }: {
602
+ hookName: H;
603
+ parameters: PluginParameter<H>;
604
+ skipped?: ReadonlySet<Plugin> | null;
605
+ message: string;
606
+ }): Promise<SafeParseResult<H>>;
607
+ /**
608
+ * First non-null result stops and will return it's value.
609
+ */
610
+ hookFirstSync<H extends PluginLifecycleHooks>({
611
+ hookName,
612
+ parameters,
613
+ skipped,
614
+ message
615
+ }: {
616
+ hookName: H;
617
+ parameters: PluginParameter<H>;
618
+ skipped?: ReadonlySet<Plugin> | null;
619
+ message: string;
620
+ }): SafeParseResult<H>;
621
+ /**
622
+ * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
623
+ */
624
+ hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
625
+ hookName,
626
+ parameters,
627
+ message
628
+ }: {
629
+ hookName: H;
630
+ parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
631
+ message: string;
632
+ }): Promise<Awaited<TOuput>[]>;
633
+ /**
634
+ * Chains plugins
635
+ */
636
+ hookSeq<H extends PluginLifecycleHooks>({
637
+ hookName,
638
+ parameters,
639
+ message
640
+ }: {
641
+ hookName: H;
642
+ parameters?: PluginParameter<H>;
643
+ message: string;
644
+ }): Promise<void>;
645
+ getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
646
+ getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
647
+ static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
648
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
649
+ }
650
+ //#endregion
651
+ //#region src/types.d.ts
652
+ type Options = {
653
+ /**
654
+ * Kubb config without the Hooks.
655
+ */
656
+ config?: Omit<UserConfig, 'hooks'>;
657
+ };
658
+ //#endregion
659
+ export { Options };
660
+ //# sourceMappingURL=types-BHypkRQJ.d.cts.map