@kubb/core 3.15.0 → 3.16.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 (66) hide show
  1. package/dist/{FileManager-HxsypMy8.d.cts → PluginManager-E3SghPP9.d.cts} +125 -161
  2. package/dist/{FileManager-Cm7Iylcx.d.ts → PluginManager-PDmRCu9k.d.ts} +125 -161
  3. package/dist/{chunk-7P6FFVGF.js → chunk-4V7HK7PT.js} +3 -3
  4. package/dist/{chunk-7P6FFVGF.js.map → chunk-4V7HK7PT.js.map} +1 -1
  5. package/dist/{chunk-TEEWO6UV.cjs → chunk-BHSTNFNQ.cjs} +2 -23
  6. package/dist/chunk-BHSTNFNQ.cjs.map +1 -0
  7. package/dist/{chunk-XTSQKCYI.js → chunk-CAZ37TGB.js} +93 -114
  8. package/dist/chunk-CAZ37TGB.js.map +1 -0
  9. package/dist/{chunk-MKN7YSK2.cjs → chunk-E4XLCCPK.cjs} +2 -20
  10. package/dist/chunk-E4XLCCPK.cjs.map +1 -0
  11. package/dist/{chunk-TJJOSCFA.cjs → chunk-MCNA6SYG.cjs} +5 -24
  12. package/dist/chunk-MCNA6SYG.cjs.map +1 -0
  13. package/dist/chunk-QR7CQIA3.cjs +943 -0
  14. package/dist/chunk-QR7CQIA3.cjs.map +1 -0
  15. package/dist/{chunk-CMKZBNCX.js → chunk-YRPOID7E.js} +2 -2
  16. package/dist/{chunk-CMKZBNCX.js.map → chunk-YRPOID7E.js.map} +1 -1
  17. package/dist/fs.cjs +9 -10
  18. package/dist/fs.d.cts +10 -2
  19. package/dist/fs.d.ts +10 -2
  20. package/dist/fs.js +1 -1
  21. package/dist/index.cjs +109 -260
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +9 -7
  24. package/dist/index.d.ts +9 -7
  25. package/dist/index.js +88 -83
  26. package/dist/index.js.map +1 -1
  27. package/dist/logger.cjs +6 -7
  28. package/dist/logger.js +2 -2
  29. package/dist/mocks.cjs +8 -11
  30. package/dist/mocks.cjs.map +1 -1
  31. package/dist/mocks.d.cts +2 -2
  32. package/dist/mocks.d.ts +2 -2
  33. package/dist/mocks.js +2 -2
  34. package/dist/{parser-CcELSk43.d.ts → parser-C1vOjVEd.d.ts} +2 -2
  35. package/dist/{parser-Dwb7eMU3.d.cts → parser-D6vU1kA9.d.cts} +2 -2
  36. package/dist/{prompt-55FJQYBV.cjs → prompt-U7M5G25C.cjs} +2 -4
  37. package/dist/prompt-U7M5G25C.cjs.map +1 -0
  38. package/dist/transformers.cjs +21 -22
  39. package/dist/{types-CX9JVw2n.d.cts → types-CA8nQKwM.d.cts} +1 -15
  40. package/dist/{types-CX9JVw2n.d.ts → types-CA8nQKwM.d.ts} +1 -15
  41. package/dist/utils.cjs +22 -19
  42. package/dist/utils.d.cts +15 -4
  43. package/dist/utils.d.ts +15 -4
  44. package/dist/utils.js +2 -2
  45. package/package.json +6 -6
  46. package/src/BarrelManager.ts +1 -20
  47. package/src/FileManager.ts +78 -121
  48. package/src/PluginManager.ts +40 -33
  49. package/src/PromiseManager.ts +2 -1
  50. package/src/__snapshots__/barrel.json +80 -6
  51. package/src/build.ts +57 -55
  52. package/src/fs/types.ts +0 -6
  53. package/src/index.ts +1 -1
  54. package/src/utils/Cache.ts +31 -0
  55. package/src/utils/executeStrategies.ts +9 -2
  56. package/src/utils/index.ts +1 -0
  57. package/src/utils/parser.ts +6 -7
  58. package/dist/chunk-FAQ7SBKL.cjs +0 -1636
  59. package/dist/chunk-FAQ7SBKL.cjs.map +0 -1
  60. package/dist/chunk-KZOJCFA7.cjs +0 -42
  61. package/dist/chunk-KZOJCFA7.cjs.map +0 -1
  62. package/dist/chunk-MKN7YSK2.cjs.map +0 -1
  63. package/dist/chunk-TEEWO6UV.cjs.map +0 -1
  64. package/dist/chunk-TJJOSCFA.cjs.map +0 -1
  65. package/dist/chunk-XTSQKCYI.js.map +0 -1
  66. package/dist/prompt-55FJQYBV.cjs.map +0 -1
@@ -1,117 +1,10 @@
1
- import { M as Mode, E as Extname, F as File, O as OptionalPath, B as BaseName, R as ResolvedFile, P as Path, w as write, r as read } from './types-CX9JVw2n.cjs';
2
- import { E as EventEmitter, L as Logger } from './logger-BWq-oJU_.cjs';
1
+ import { E as Extname, B as BaseName, M as Mode, O as OptionalPath, F as File, R as ResolvedFile, P as Path } from './types-CA8nQKwM.cjs';
2
+ import { L as Logger, E as EventEmitter } from './logger-BWq-oJU_.cjs';
3
3
 
4
4
  type PossiblePromise<T> = Promise<T> | T;
5
5
  type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
6
6
  type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
7
7
 
8
- type RequiredPluginLifecycle = Required<PluginLifecycle>;
9
- type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
10
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
11
- message: string;
12
- strategy: Strategy;
13
- hookName: H;
14
- plugin: Plugin;
15
- parameters?: unknown[] | undefined;
16
- output?: unknown;
17
- };
18
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
19
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
20
- result: Result;
21
- plugin: Plugin;
22
- };
23
- type Options = {
24
- logger: Logger;
25
- };
26
- type Events = {
27
- executing: [executer: Executer];
28
- executed: [executer: Executer];
29
- error: [error: Error];
30
- };
31
- type GetFileProps<TOptions = object> = {
32
- name: string;
33
- mode?: Mode;
34
- extname: Extname;
35
- pluginKey: Plugin['key'];
36
- options?: TOptions;
37
- };
38
- declare class PluginManager {
39
- #private;
40
- readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
41
- readonly fileManager: FileManager;
42
- readonly events: EventEmitter<Events>;
43
- readonly config: Config;
44
- readonly executed: Array<Executer>;
45
- readonly logger: Logger;
46
- readonly options: Options;
47
- constructor(config: Config, options: Options);
48
- getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): File<{
49
- pluginKey: Plugin['key'];
50
- }>;
51
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
52
- resolveName: (params: ResolveNameParams) => string;
53
- /**
54
- * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
55
- */
56
- on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
57
- /**
58
- * Run a specific hookName for plugin x.
59
- */
60
- hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
61
- pluginKey: Plugin['key'];
62
- hookName: H;
63
- parameters: PluginParameter<H>;
64
- message: string;
65
- }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
66
- /**
67
- * Run a specific hookName for plugin x.
68
- */
69
- hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
70
- pluginKey: Plugin['key'];
71
- hookName: H;
72
- parameters: PluginParameter<H>;
73
- message: string;
74
- }): Array<ReturnType<ParseResult<H>>> | null;
75
- /**
76
- * First non-null result stops and will return it's value.
77
- */
78
- hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
79
- hookName: H;
80
- parameters: PluginParameter<H>;
81
- skipped?: ReadonlySet<Plugin> | null;
82
- message: string;
83
- }): Promise<SafeParseResult<H>>;
84
- /**
85
- * First non-null result stops and will return it's value.
86
- */
87
- hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
88
- hookName: H;
89
- parameters: PluginParameter<H>;
90
- skipped?: ReadonlySet<Plugin> | null;
91
- message: string;
92
- }): SafeParseResult<H>;
93
- /**
94
- * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
95
- */
96
- hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, message, }: {
97
- hookName: H;
98
- parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
99
- message: string;
100
- }): Promise<Awaited<TOuput>[]>;
101
- /**
102
- * Chains plugins
103
- */
104
- hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters, message, }: {
105
- hookName: H;
106
- parameters?: PluginParameter<H>;
107
- message: string;
108
- }): Promise<void>;
109
- getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
110
- getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
111
- 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;
112
- static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
113
- }
114
-
115
8
  /**
116
9
  * Config used in `kubb.config.ts`
117
10
  *
@@ -404,38 +297,6 @@ type Group = {
404
297
  name?: (context: GroupContext) => string;
405
298
  };
406
299
 
407
- type BarrelData = {
408
- file?: File;
409
- /**
410
- * @deprecated use file instead
411
- */
412
- type: Mode;
413
- path: string;
414
- name: string;
415
- };
416
- declare class TreeNode {
417
- #private;
418
- data: BarrelData;
419
- parent?: TreeNode;
420
- children: Array<TreeNode>;
421
- constructor(data: BarrelData, parent?: TreeNode);
422
- addChild(data: BarrelData): TreeNode;
423
- get root(): TreeNode;
424
- get leaves(): Array<TreeNode>;
425
- forEach(callback: (treeNode: TreeNode) => void): this;
426
- findDeep(predicate?: (value: TreeNode, index: number, obj: TreeNode[]) => boolean): TreeNode | undefined;
427
- forEachDeep(callback: (treeNode: TreeNode) => void): void;
428
- filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode>;
429
- mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T>;
430
- static build(files: File[], root?: string): TreeNode | null;
431
- }
432
- type DirectoryTree = {
433
- name: string;
434
- path: string;
435
- file?: File;
436
- children: Array<DirectoryTree>;
437
- };
438
-
439
300
  type FileMetaBase = {
440
301
  pluginKey?: Plugin['key'];
441
302
  };
@@ -446,7 +307,6 @@ type AddIndexesProps = {
446
307
  * Root based on root and output.path specified in the config
447
308
  */
448
309
  root: string;
449
- files: File[];
450
310
  /**
451
311
  * Output for plugin
452
312
  */
@@ -460,21 +320,22 @@ type AddIndexesProps = {
460
320
  logger?: Logger;
461
321
  meta?: FileMetaBase;
462
322
  };
323
+ type WriteFilesProps = {
324
+ root: Config['root'];
325
+ extension?: Record<Extname, Extname | ''>;
326
+ logger?: Logger;
327
+ dryRun?: boolean;
328
+ };
463
329
  declare class FileManager {
464
330
  #private;
465
331
  constructor();
466
- get files(): Array<ResolvedFile>;
467
- get orderedFiles(): Array<ResolvedFile>;
468
- get groupedFiles(): DirectoryTree | null;
469
- get treeNode(): TreeNode | null;
470
332
  add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
471
- clear(): void;
472
- getCacheById(id: string): File | undefined;
473
- getByPath(path: Path): ResolvedFile | undefined;
474
- deleteByPath(path: Path): void;
475
- getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<File[]>;
476
- write(...params: Parameters<typeof write>): ReturnType<typeof write>;
477
- read(...params: Parameters<typeof read>): ReturnType<typeof read>;
333
+ getByPath(path: Path): Promise<ResolvedFile | null>;
334
+ deleteByPath(path: Path): Promise<void>;
335
+ clear(): Promise<void>;
336
+ getFiles(): Promise<Array<ResolvedFile>>;
337
+ processFiles({ dryRun, root, extension, logger }: WriteFilesProps): Promise<Array<ResolvedFile>>;
338
+ getBarrelFiles({ type, meta, root, output, logger }: AddIndexesProps): Promise<File[]>;
478
339
  static getMode(path: string | undefined | null): Mode;
479
340
  }
480
341
  type GetSourceOptions = {
@@ -482,13 +343,116 @@ type GetSourceOptions = {
482
343
  logger?: Logger;
483
344
  };
484
345
  declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
485
- type WriteFilesProps = {
486
- root: Config['root'];
487
- files: Array<ResolvedFile>;
488
- extension?: Record<Extname, Extname | ''>;
489
- logger?: Logger;
490
- dryRun?: boolean;
346
+
347
+ type RequiredPluginLifecycle = Required<PluginLifecycle>;
348
+ type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
349
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
350
+ message: string;
351
+ strategy: Strategy;
352
+ hookName: H;
353
+ plugin: Plugin;
354
+ parameters?: unknown[] | undefined;
355
+ output?: unknown;
356
+ };
357
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
358
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
359
+ result: Result;
360
+ plugin: Plugin;
361
+ };
362
+ type Options = {
363
+ logger: Logger;
364
+ /**
365
+ * @default Number.POSITIVE_INFINITY
366
+ */
367
+ concurrency?: number;
491
368
  };
492
- declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<ResolvedFile<object>[]>;
369
+ type Events = {
370
+ executing: [executer: Executer];
371
+ executed: [executer: Executer];
372
+ error: [error: Error];
373
+ };
374
+ type GetFileProps<TOptions = object> = {
375
+ name: string;
376
+ mode?: Mode;
377
+ extname: Extname;
378
+ pluginKey: Plugin['key'];
379
+ options?: TOptions;
380
+ };
381
+ declare class PluginManager {
382
+ #private;
383
+ readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
384
+ readonly fileManager: FileManager;
385
+ readonly events: EventEmitter<Events>;
386
+ readonly config: Config;
387
+ readonly executed: Array<Executer>;
388
+ readonly logger: Logger;
389
+ readonly options: Options;
390
+ constructor(config: Config, options: Options);
391
+ getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): File<{
392
+ pluginKey: Plugin['key'];
393
+ }>;
394
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
395
+ resolveName: (params: ResolveNameParams) => string;
396
+ /**
397
+ * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
398
+ */
399
+ on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
400
+ /**
401
+ * Run a specific hookName for plugin x.
402
+ */
403
+ hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
404
+ pluginKey: Plugin['key'];
405
+ hookName: H;
406
+ parameters: PluginParameter<H>;
407
+ message: string;
408
+ }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
409
+ /**
410
+ * Run a specific hookName for plugin x.
411
+ */
412
+ hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
413
+ pluginKey: Plugin['key'];
414
+ hookName: H;
415
+ parameters: PluginParameter<H>;
416
+ message: string;
417
+ }): Array<ReturnType<ParseResult<H>>> | null;
418
+ /**
419
+ * First non-null result stops and will return it's value.
420
+ */
421
+ hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
422
+ hookName: H;
423
+ parameters: PluginParameter<H>;
424
+ skipped?: ReadonlySet<Plugin> | null;
425
+ message: string;
426
+ }): Promise<SafeParseResult<H>>;
427
+ /**
428
+ * First non-null result stops and will return it's value.
429
+ */
430
+ hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
431
+ hookName: H;
432
+ parameters: PluginParameter<H>;
433
+ skipped?: ReadonlySet<Plugin> | null;
434
+ message: string;
435
+ }): SafeParseResult<H>;
436
+ /**
437
+ * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
438
+ */
439
+ hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, message, }: {
440
+ hookName: H;
441
+ parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
442
+ message: string;
443
+ }): Promise<Awaited<TOuput>[]>;
444
+ /**
445
+ * Chains plugins
446
+ */
447
+ hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters, message, }: {
448
+ hookName: H;
449
+ parameters?: PluginParameter<H>;
450
+ message: string;
451
+ }): Promise<void>;
452
+ getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
453
+ getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
454
+ 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;
455
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
456
+ }
493
457
 
494
- export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PossiblePromise as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type PluginContext as o, processFiles as p, type Group as q };
458
+ export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PossiblePromise as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type PluginContext as o, type Group as p };
@@ -1,117 +1,10 @@
1
- import { M as Mode, E as Extname, F as File, O as OptionalPath, B as BaseName, R as ResolvedFile, P as Path, w as write, r as read } from './types-CX9JVw2n.js';
2
- import { E as EventEmitter, L as Logger } from './logger-BWq-oJU_.js';
1
+ import { E as Extname, B as BaseName, M as Mode, O as OptionalPath, F as File, R as ResolvedFile, P as Path } from './types-CA8nQKwM.js';
2
+ import { L as Logger, E as EventEmitter } from './logger-BWq-oJU_.js';
3
3
 
4
4
  type PossiblePromise<T> = Promise<T> | T;
5
5
  type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
6
6
  type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
7
7
 
8
- type RequiredPluginLifecycle = Required<PluginLifecycle>;
9
- type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
10
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
11
- message: string;
12
- strategy: Strategy;
13
- hookName: H;
14
- plugin: Plugin;
15
- parameters?: unknown[] | undefined;
16
- output?: unknown;
17
- };
18
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
19
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
20
- result: Result;
21
- plugin: Plugin;
22
- };
23
- type Options = {
24
- logger: Logger;
25
- };
26
- type Events = {
27
- executing: [executer: Executer];
28
- executed: [executer: Executer];
29
- error: [error: Error];
30
- };
31
- type GetFileProps<TOptions = object> = {
32
- name: string;
33
- mode?: Mode;
34
- extname: Extname;
35
- pluginKey: Plugin['key'];
36
- options?: TOptions;
37
- };
38
- declare class PluginManager {
39
- #private;
40
- readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
41
- readonly fileManager: FileManager;
42
- readonly events: EventEmitter<Events>;
43
- readonly config: Config;
44
- readonly executed: Array<Executer>;
45
- readonly logger: Logger;
46
- readonly options: Options;
47
- constructor(config: Config, options: Options);
48
- getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): File<{
49
- pluginKey: Plugin['key'];
50
- }>;
51
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
52
- resolveName: (params: ResolveNameParams) => string;
53
- /**
54
- * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
55
- */
56
- on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
57
- /**
58
- * Run a specific hookName for plugin x.
59
- */
60
- hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
61
- pluginKey: Plugin['key'];
62
- hookName: H;
63
- parameters: PluginParameter<H>;
64
- message: string;
65
- }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
66
- /**
67
- * Run a specific hookName for plugin x.
68
- */
69
- hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
70
- pluginKey: Plugin['key'];
71
- hookName: H;
72
- parameters: PluginParameter<H>;
73
- message: string;
74
- }): Array<ReturnType<ParseResult<H>>> | null;
75
- /**
76
- * First non-null result stops and will return it's value.
77
- */
78
- hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
79
- hookName: H;
80
- parameters: PluginParameter<H>;
81
- skipped?: ReadonlySet<Plugin> | null;
82
- message: string;
83
- }): Promise<SafeParseResult<H>>;
84
- /**
85
- * First non-null result stops and will return it's value.
86
- */
87
- hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
88
- hookName: H;
89
- parameters: PluginParameter<H>;
90
- skipped?: ReadonlySet<Plugin> | null;
91
- message: string;
92
- }): SafeParseResult<H>;
93
- /**
94
- * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
95
- */
96
- hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, message, }: {
97
- hookName: H;
98
- parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
99
- message: string;
100
- }): Promise<Awaited<TOuput>[]>;
101
- /**
102
- * Chains plugins
103
- */
104
- hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters, message, }: {
105
- hookName: H;
106
- parameters?: PluginParameter<H>;
107
- message: string;
108
- }): Promise<void>;
109
- getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
110
- getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
111
- 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;
112
- static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
113
- }
114
-
115
8
  /**
116
9
  * Config used in `kubb.config.ts`
117
10
  *
@@ -404,38 +297,6 @@ type Group = {
404
297
  name?: (context: GroupContext) => string;
405
298
  };
406
299
 
407
- type BarrelData = {
408
- file?: File;
409
- /**
410
- * @deprecated use file instead
411
- */
412
- type: Mode;
413
- path: string;
414
- name: string;
415
- };
416
- declare class TreeNode {
417
- #private;
418
- data: BarrelData;
419
- parent?: TreeNode;
420
- children: Array<TreeNode>;
421
- constructor(data: BarrelData, parent?: TreeNode);
422
- addChild(data: BarrelData): TreeNode;
423
- get root(): TreeNode;
424
- get leaves(): Array<TreeNode>;
425
- forEach(callback: (treeNode: TreeNode) => void): this;
426
- findDeep(predicate?: (value: TreeNode, index: number, obj: TreeNode[]) => boolean): TreeNode | undefined;
427
- forEachDeep(callback: (treeNode: TreeNode) => void): void;
428
- filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode>;
429
- mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T>;
430
- static build(files: File[], root?: string): TreeNode | null;
431
- }
432
- type DirectoryTree = {
433
- name: string;
434
- path: string;
435
- file?: File;
436
- children: Array<DirectoryTree>;
437
- };
438
-
439
300
  type FileMetaBase = {
440
301
  pluginKey?: Plugin['key'];
441
302
  };
@@ -446,7 +307,6 @@ type AddIndexesProps = {
446
307
  * Root based on root and output.path specified in the config
447
308
  */
448
309
  root: string;
449
- files: File[];
450
310
  /**
451
311
  * Output for plugin
452
312
  */
@@ -460,21 +320,22 @@ type AddIndexesProps = {
460
320
  logger?: Logger;
461
321
  meta?: FileMetaBase;
462
322
  };
323
+ type WriteFilesProps = {
324
+ root: Config['root'];
325
+ extension?: Record<Extname, Extname | ''>;
326
+ logger?: Logger;
327
+ dryRun?: boolean;
328
+ };
463
329
  declare class FileManager {
464
330
  #private;
465
331
  constructor();
466
- get files(): Array<ResolvedFile>;
467
- get orderedFiles(): Array<ResolvedFile>;
468
- get groupedFiles(): DirectoryTree | null;
469
- get treeNode(): TreeNode | null;
470
332
  add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
471
- clear(): void;
472
- getCacheById(id: string): File | undefined;
473
- getByPath(path: Path): ResolvedFile | undefined;
474
- deleteByPath(path: Path): void;
475
- getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<File[]>;
476
- write(...params: Parameters<typeof write>): ReturnType<typeof write>;
477
- read(...params: Parameters<typeof read>): ReturnType<typeof read>;
333
+ getByPath(path: Path): Promise<ResolvedFile | null>;
334
+ deleteByPath(path: Path): Promise<void>;
335
+ clear(): Promise<void>;
336
+ getFiles(): Promise<Array<ResolvedFile>>;
337
+ processFiles({ dryRun, root, extension, logger }: WriteFilesProps): Promise<Array<ResolvedFile>>;
338
+ getBarrelFiles({ type, meta, root, output, logger }: AddIndexesProps): Promise<File[]>;
478
339
  static getMode(path: string | undefined | null): Mode;
479
340
  }
480
341
  type GetSourceOptions = {
@@ -482,13 +343,116 @@ type GetSourceOptions = {
482
343
  logger?: Logger;
483
344
  };
484
345
  declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
485
- type WriteFilesProps = {
486
- root: Config['root'];
487
- files: Array<ResolvedFile>;
488
- extension?: Record<Extname, Extname | ''>;
489
- logger?: Logger;
490
- dryRun?: boolean;
346
+
347
+ type RequiredPluginLifecycle = Required<PluginLifecycle>;
348
+ type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
349
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
350
+ message: string;
351
+ strategy: Strategy;
352
+ hookName: H;
353
+ plugin: Plugin;
354
+ parameters?: unknown[] | undefined;
355
+ output?: unknown;
356
+ };
357
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
358
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
359
+ result: Result;
360
+ plugin: Plugin;
361
+ };
362
+ type Options = {
363
+ logger: Logger;
364
+ /**
365
+ * @default Number.POSITIVE_INFINITY
366
+ */
367
+ concurrency?: number;
491
368
  };
492
- declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<ResolvedFile<object>[]>;
369
+ type Events = {
370
+ executing: [executer: Executer];
371
+ executed: [executer: Executer];
372
+ error: [error: Error];
373
+ };
374
+ type GetFileProps<TOptions = object> = {
375
+ name: string;
376
+ mode?: Mode;
377
+ extname: Extname;
378
+ pluginKey: Plugin['key'];
379
+ options?: TOptions;
380
+ };
381
+ declare class PluginManager {
382
+ #private;
383
+ readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
384
+ readonly fileManager: FileManager;
385
+ readonly events: EventEmitter<Events>;
386
+ readonly config: Config;
387
+ readonly executed: Array<Executer>;
388
+ readonly logger: Logger;
389
+ readonly options: Options;
390
+ constructor(config: Config, options: Options);
391
+ getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): File<{
392
+ pluginKey: Plugin['key'];
393
+ }>;
394
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
395
+ resolveName: (params: ResolveNameParams) => string;
396
+ /**
397
+ * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
398
+ */
399
+ on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
400
+ /**
401
+ * Run a specific hookName for plugin x.
402
+ */
403
+ hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
404
+ pluginKey: Plugin['key'];
405
+ hookName: H;
406
+ parameters: PluginParameter<H>;
407
+ message: string;
408
+ }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
409
+ /**
410
+ * Run a specific hookName for plugin x.
411
+ */
412
+ hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
413
+ pluginKey: Plugin['key'];
414
+ hookName: H;
415
+ parameters: PluginParameter<H>;
416
+ message: string;
417
+ }): Array<ReturnType<ParseResult<H>>> | null;
418
+ /**
419
+ * First non-null result stops and will return it's value.
420
+ */
421
+ hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
422
+ hookName: H;
423
+ parameters: PluginParameter<H>;
424
+ skipped?: ReadonlySet<Plugin> | null;
425
+ message: string;
426
+ }): Promise<SafeParseResult<H>>;
427
+ /**
428
+ * First non-null result stops and will return it's value.
429
+ */
430
+ hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
431
+ hookName: H;
432
+ parameters: PluginParameter<H>;
433
+ skipped?: ReadonlySet<Plugin> | null;
434
+ message: string;
435
+ }): SafeParseResult<H>;
436
+ /**
437
+ * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
438
+ */
439
+ hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, message, }: {
440
+ hookName: H;
441
+ parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
442
+ message: string;
443
+ }): Promise<Awaited<TOuput>[]>;
444
+ /**
445
+ * Chains plugins
446
+ */
447
+ hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters, message, }: {
448
+ hookName: H;
449
+ parameters?: PluginParameter<H>;
450
+ message: string;
451
+ }): Promise<void>;
452
+ getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
453
+ getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
454
+ 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;
455
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
456
+ }
493
457
 
494
- export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PossiblePromise as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type PluginContext as o, processFiles as p, type Group as q };
458
+ export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PossiblePromise as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type PluginContext as o, type Group as p };
@@ -1,4 +1,4 @@
1
- import { write } from './chunk-CMKZBNCX.js';
1
+ import { write } from './chunk-YRPOID7E.js';
2
2
  import seedrandom from 'seedrandom';
3
3
  import * as tty from 'tty';
4
4
  import { EventEmitter as EventEmitter$1 } from 'events';
@@ -1195,5 +1195,5 @@ function randomCliColour(text) {
1195
1195
  }
1196
1196
 
1197
1197
  export { EventEmitter, LogMapper, colors, consola, createLogger, randomCliColour, randomColour };
1198
- //# sourceMappingURL=chunk-7P6FFVGF.js.map
1199
- //# sourceMappingURL=chunk-7P6FFVGF.js.map
1198
+ //# sourceMappingURL=chunk-4V7HK7PT.js.map
1199
+ //# sourceMappingURL=chunk-4V7HK7PT.js.map