@kubb/core 5.9.2 → 5.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{KubbDriver-D2Jn4i3J.cjs → Hookable-BEzKPyQH.cjs} +144 -308
- package/dist/Hookable-BEzKPyQH.cjs.map +1 -0
- package/dist/{KubbDriver-DiYRWgxN.js → Hookable-C4PGA4hT.js} +147 -293
- package/dist/Hookable-C4PGA4hT.js.map +1 -0
- package/dist/{createAdapter-DfbfcqcJ.d.ts → createAdapter-D55JE9lX.d.ts} +16 -76
- package/dist/index.cjs +91 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -28
- package/dist/index.js +33 -81
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +9 -9
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +2 -2
- package/dist/KubbDriver-D2Jn4i3J.cjs.map +0 -1
- package/dist/KubbDriver-DiYRWgxN.js.map +0 -1
|
@@ -70,14 +70,8 @@ type ParserBuild<TOptions extends object, TMeta extends object, TNode> = (option
|
|
|
70
70
|
*/
|
|
71
71
|
type ParserDefinition<TOptions extends object = object, TMeta extends object = object, TNode = unknown> = {
|
|
72
72
|
meta: ExtensionMeta;
|
|
73
|
-
} & ({
|
|
74
73
|
build: ParserBuild<TOptions, TMeta, TNode>;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* @deprecated Renamed to `build`.
|
|
78
|
-
*/
|
|
79
|
-
setup: ParserBuild<TOptions, TMeta, TNode>;
|
|
80
|
-
});
|
|
74
|
+
};
|
|
81
75
|
/**
|
|
82
76
|
* The function `defineExtension` returns for a parser. Call it with user options to get a `Parser`.
|
|
83
77
|
*/
|
|
@@ -89,14 +83,6 @@ type ParserFactory<TOptions extends object = object, TMeta extends object = obje
|
|
|
89
83
|
* @deprecated Use `defineExtension` with `kind: 'parser'` instead.
|
|
90
84
|
*/
|
|
91
85
|
declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(definition: ParserDefinition<TOptions, TMeta, TNode>): ParserFactory<TOptions, TMeta, TNode>;
|
|
92
|
-
/**
|
|
93
|
-
* Wraps a factory function that returns a `Parser`. Without `meta`, the parser gets `{ name }`.
|
|
94
|
-
*
|
|
95
|
-
* @deprecated Pass a definition object with `kind: 'parser'`, `meta`, and `build` to `defineExtension` instead. The factory form is removed in the next major.
|
|
96
|
-
*/
|
|
97
|
-
declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(factory: (options: TOptions) => Parser<TMeta, TNode>): ((options?: TOptions) => Parser<TMeta, TNode>) & {
|
|
98
|
-
kind: 'parser';
|
|
99
|
-
};
|
|
100
86
|
//#endregion
|
|
101
87
|
//#region src/createRenderer.d.ts
|
|
102
88
|
/**
|
|
@@ -312,7 +298,6 @@ type DiagnosticCode = (typeof diagnosticCode)[keyof typeof diagnosticCode];
|
|
|
312
298
|
type AsyncListener<TArgs extends Array<unknown>> = (...args: TArgs) => unknown;
|
|
313
299
|
/**
|
|
314
300
|
* Typed hook emitter that awaits all async listeners before resolving.
|
|
315
|
-
* Wraps Node's `EventEmitter` with full TypeScript hook-map inference.
|
|
316
301
|
*
|
|
317
302
|
* @example
|
|
318
303
|
* ```ts
|
|
@@ -323,11 +308,6 @@ type AsyncListener<TArgs extends Array<unknown>> = (...args: TArgs) => unknown;
|
|
|
323
308
|
*/
|
|
324
309
|
declare class Hookable<THooks extends { [K in keyof THooks]: Array<unknown>; }> {
|
|
325
310
|
#private;
|
|
326
|
-
/**
|
|
327
|
-
* Maximum number of listeners per hook before Node emits a memory-leak warning.
|
|
328
|
-
* @default 10
|
|
329
|
-
*/
|
|
330
|
-
constructor(maxListener?: number);
|
|
331
311
|
/**
|
|
332
312
|
* Calls `hookName` and awaits all registered listeners sequentially.
|
|
333
313
|
* Throws if any listener rejects, wrapping the cause in an error that names the hook.
|
|
@@ -379,15 +359,11 @@ declare class Hookable<THooks extends { [K in keyof THooks]: Array<unknown>; }>
|
|
|
379
359
|
*/
|
|
380
360
|
listenerCount<THookName extends keyof THooks & string>(hookName: THookName): number;
|
|
381
361
|
/**
|
|
382
|
-
*
|
|
383
|
-
* Set this above the expected listener count when many listeners attach by design.
|
|
362
|
+
* No-op kept for callers written against the `EventEmitter`-backed version. Listeners are unbounded.
|
|
384
363
|
*
|
|
385
|
-
* @
|
|
386
|
-
* ```ts
|
|
387
|
-
* hooks.setMaxListeners(40)
|
|
388
|
-
* ```
|
|
364
|
+
* @deprecated There is no listener ceiling anymore.
|
|
389
365
|
*/
|
|
390
|
-
setMaxListeners(
|
|
366
|
+
setMaxListeners(_max: number): void;
|
|
391
367
|
/**
|
|
392
368
|
* Removes all listeners from every hook channel.
|
|
393
369
|
*
|
|
@@ -838,7 +814,6 @@ type Reporter = {
|
|
|
838
814
|
* Whether the host should collect files from `kubb:plugin:end` hooks.
|
|
839
815
|
*/
|
|
840
816
|
needsPluginFiles?: boolean;
|
|
841
|
-
[Symbol.dispose](): void;
|
|
842
817
|
};
|
|
843
818
|
/**
|
|
844
819
|
* Reporter definition passed to {@link createReporter}. `report` returns the value to collect for
|
|
@@ -891,10 +866,6 @@ type Storage = {
|
|
|
891
866
|
* Identifier used in logs and diagnostics (`'fs'`, `'memory'`, `'s3'`).
|
|
892
867
|
*/
|
|
893
868
|
readonly name: string;
|
|
894
|
-
/**
|
|
895
|
-
* Returns `true` when an entry for `key` exists.
|
|
896
|
-
*/
|
|
897
|
-
existsItem(key: string): Promise<boolean>;
|
|
898
869
|
/**
|
|
899
870
|
* Reads the stored string. Returns `null` when the key is missing.
|
|
900
871
|
*/
|
|
@@ -941,9 +912,6 @@ type Storage = {
|
|
|
941
912
|
*
|
|
942
913
|
* return {
|
|
943
914
|
* name: 'memory',
|
|
944
|
-
* async existsItem(key) {
|
|
945
|
-
* return store.has(key)
|
|
946
|
-
* },
|
|
947
915
|
* async readItem(key) {
|
|
948
916
|
* return store.get(key) ?? null
|
|
949
917
|
* },
|
|
@@ -964,7 +932,7 @@ type Storage = {
|
|
|
964
932
|
* })
|
|
965
933
|
* ```
|
|
966
934
|
*/
|
|
967
|
-
declare
|
|
935
|
+
declare const createStorage: <TOptions = Record<string, never>>(build: (options: TOptions) => Storage) => (options?: TOptions) => Storage;
|
|
968
936
|
//#endregion
|
|
969
937
|
//#region src/outputManifest.d.ts
|
|
970
938
|
/**
|
|
@@ -1000,20 +968,6 @@ type OutputManifest = {
|
|
|
1000
968
|
};
|
|
1001
969
|
//#endregion
|
|
1002
970
|
//#region src/FileManager.d.ts
|
|
1003
|
-
/**
|
|
1004
|
-
* Hooks fired around a `FileManager#write` batch: `start` before it, `update` per file, `end` after.
|
|
1005
|
-
*/
|
|
1006
|
-
type FileManagerHooks = {
|
|
1007
|
-
start: [files: Array<FileNode>];
|
|
1008
|
-
update: [params: {
|
|
1009
|
-
file: FileNode;
|
|
1010
|
-
source?: string;
|
|
1011
|
-
processed: number;
|
|
1012
|
-
total: number;
|
|
1013
|
-
percentage: number;
|
|
1014
|
-
}];
|
|
1015
|
-
end: [files: Array<FileNode>];
|
|
1016
|
-
};
|
|
1017
971
|
type ParseOptions = {
|
|
1018
972
|
parsers?: Map<FileNode['extname'], Parser>;
|
|
1019
973
|
};
|
|
@@ -1025,6 +979,11 @@ type WriteOptions = ParseOptions & {
|
|
|
1025
979
|
* unchanged. Omitted when no formatter, linter, or `postGenerate` step is configured.
|
|
1026
980
|
*/
|
|
1027
981
|
manifest?: OutputManifest;
|
|
982
|
+
/**
|
|
983
|
+
* Receives `kubb:files:processing:start`, `:update` (one batch, in input order) and `:end` for the write. `config` fills the update rows.
|
|
984
|
+
*/
|
|
985
|
+
hooks?: Hookable<KubbHooks>;
|
|
986
|
+
config?: Config;
|
|
1028
987
|
};
|
|
1029
988
|
/**
|
|
1030
989
|
* In-memory file store for generated files, and the writer that turns them into source
|
|
@@ -1042,7 +1001,6 @@ type WriteOptions = ParseOptions & {
|
|
|
1042
1001
|
*/
|
|
1043
1002
|
declare class FileManager {
|
|
1044
1003
|
#private;
|
|
1045
|
-
readonly hooks: Hookable<FileManagerHooks>;
|
|
1046
1004
|
add(...files: Array<FileNode>): Array<FileNode>;
|
|
1047
1005
|
upsert(...files: Array<FileNode>): Array<FileNode>;
|
|
1048
1006
|
/** Stores a generator result: a file array is upserted as is, an element renders through `renderer` first, falsy is a no-op. */
|
|
@@ -1051,8 +1009,7 @@ declare class FileManager {
|
|
|
1051
1009
|
renderer?: RendererFactory<TElement> | null;
|
|
1052
1010
|
}): Promise<void>;
|
|
1053
1011
|
/**
|
|
1054
|
-
* Releases all stored files
|
|
1055
|
-
* `kubb:build:end`.
|
|
1012
|
+
* Releases all stored files. Called by the core after `kubb:build:end`.
|
|
1056
1013
|
*/
|
|
1057
1014
|
dispose(): void;
|
|
1058
1015
|
/**
|
|
@@ -1068,13 +1025,13 @@ declare class FileManager {
|
|
|
1068
1025
|
* Parses and writes every file through a bounded pool of workers. A small spec runs all its files
|
|
1069
1026
|
* at once; a spec with thousands of files keeps at most {@link FILE_CONCURRENCY} parsed sources in
|
|
1070
1027
|
* memory rather than holding every source, while still overlapping each file's write with the
|
|
1071
|
-
* next file's parse.
|
|
1072
|
-
*
|
|
1028
|
+
* next file's parse. Files finish in whatever order they parse, so the update rows are sorted back
|
|
1029
|
+
* into input order before `kubb:files:processing:update` fires once with the whole batch.
|
|
1073
1030
|
*
|
|
1074
1031
|
* A file the storage already holds is skipped, so a rebuild that generates identical output
|
|
1075
1032
|
* writes nothing and leaves every mtime where it was.
|
|
1076
1033
|
*/
|
|
1077
|
-
write(files: Array<FileNode>, { storage, parsers, manifest, signal }: WriteOptions): Promise<void>;
|
|
1034
|
+
write(files: Array<FileNode>, { storage, parsers, manifest, signal, hooks, config }: WriteOptions): Promise<void>;
|
|
1078
1035
|
}
|
|
1079
1036
|
//#endregion
|
|
1080
1037
|
//#region src/KubbDriver.d.ts
|
|
@@ -2836,14 +2793,6 @@ type KubbPluginEndContext = FilesContext & {
|
|
|
2836
2793
|
* @deprecated Use `defineExtension` with `kind: 'plugin'` instead.
|
|
2837
2794
|
*/
|
|
2838
2795
|
declare function definePlugin<TFactory extends PluginType = PluginType>(definition: PluginDefinition<TFactory>): PluginFactory<TFactory>;
|
|
2839
|
-
/**
|
|
2840
|
-
* Wraps a factory function that returns a `Plugin`. Without `meta`, the plugin gets `{ name }`.
|
|
2841
|
-
*
|
|
2842
|
-
* @deprecated Pass a definition object with `kind: 'plugin'`, `meta`, and `setup` to `defineExtension` instead. The factory form is removed in the next major.
|
|
2843
|
-
*/
|
|
2844
|
-
declare function definePlugin<TFactory extends PluginType = PluginType>(factory: (options: TFactory['options']) => Plugin<TFactory>): ((options?: TFactory['options']) => Plugin<TFactory>) & {
|
|
2845
|
-
kind: 'plugin';
|
|
2846
|
-
};
|
|
2847
2796
|
//#endregion
|
|
2848
2797
|
//#region src/defineExtension.d.ts
|
|
2849
2798
|
/**
|
|
@@ -3044,7 +2993,6 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
3044
2993
|
throwOnError?: boolean;
|
|
3045
2994
|
}) => Promise<void>;
|
|
3046
2995
|
};
|
|
3047
|
-
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
|
|
3048
2996
|
/**
|
|
3049
2997
|
* The object passed to `defineExtension` with `kind: 'adapter'`.
|
|
3050
2998
|
*/
|
|
@@ -3075,14 +3023,6 @@ type AdapterFactory<T extends AdapterFactoryOptions = AdapterFactoryOptions> = E
|
|
|
3075
3023
|
* @deprecated Use `defineExtension` with `kind: 'adapter'` instead.
|
|
3076
3024
|
*/
|
|
3077
3025
|
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(definition: AdapterDefinition<T>): AdapterFactory<T>;
|
|
3078
|
-
/**
|
|
3079
|
-
* Wraps a factory function that returns an `Adapter`.
|
|
3080
|
-
*
|
|
3081
|
-
* @deprecated Pass a definition object with `kind: 'adapter'`, `meta`, and `build` to `defineExtension` instead. The factory form is removed in the next major.
|
|
3082
|
-
*/
|
|
3083
|
-
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): ((options?: T['options']) => Adapter<T>) & {
|
|
3084
|
-
kind: 'adapter';
|
|
3085
|
-
};
|
|
3086
3026
|
//#endregion
|
|
3087
|
-
export { NodeCache as $,
|
|
3088
|
-
//# sourceMappingURL=createAdapter-
|
|
3027
|
+
export { NodeCache as $, UpdateDiagnostic as $t, PluginFactory as A, RunHookOptions as At, ResolveImportsOptions as B, UserReporter as Bt, NormalizedPlugin as C, KubbPluginsEndContext as Ct, Override as D, PostGenerateCommand as Dt, OutputOptions as E, PossibleConfig as Et, definePlugin as F, GenerationResult as Ft, ResolverFile as G, DiagnosticKind as Gt, ResolvePathOptions as H, logLevel as Ht, BannerMeta as I, Reporter as It, ResolverPatch as J, Diagnostics as Jt, ResolverFileParams as K, DiagnosticLocation as Kt, ResolveBannerContext as L, ReporterContext as Lt, PluginType as M, KubbDriver as Mt, ResolvePluginOptions as N, Storage as Nt, Plugin as O, UserConfig as Ot, assertPluginOption as P, createStorage as Pt, defineGenerator as Q, SerializedDiagnostic as Qt, ResolveBannerFile as R, ReporterName as Rt, KubbPluginStartContext as S, KubbMessageContext as St, OutputMode as T, KubbWarnContext as Tt, Resolver as U, Diagnostic as Ut, ResolveOptionsContext as V, createReporter as Vt, ResolverDefault as W, DiagnosticDoc as Wt, Generator as X, ProblemCode as Xt, ResolverPathParams as Y, PerformanceDiagnostic as Yt, GeneratorContext as Z, ProblemDiagnostic as Zt, Filter as _, KubbHookLineContext as _t, AdapterSource as a, ParserDefinition as an, KubbBuildEndContext as at, KubbPluginEndContext as b, KubbInfoContext as bt, ExtensionDependency as c, KubbErrorContext as ct, ExtensionKind as d, KubbFilesProcessingStartContext as dt, Hookable as en, BuildOutput as et, ExtensionMeta as f, KubbFilesProcessingUpdateContext as ft, Exclude$1 as g, KubbHookEndContext as gt, resolveMeta as h, KubbGenerationSummaryContext as ht, AdapterFactoryOptions as i, Parser as in, Input as it, PluginName as j, runHook as jt, PluginDefinition as k, HookResult as kt, ExtensionDependencyRecord as l, KubbFileProcessingUpdate as lt, defineExtension as m, KubbGenerationStartContext as mt, AdapterDefinition as n, RendererFactory as nn, Config as nt, createAdapter as o, ParserFactory as on, KubbBuildStartContext as ot, checkCompatibility as p, KubbGenerationEndContext as pt, ResolverFilePathParams as q, DiagnosticSeverity as qt, AdapterFactory as r, createRenderer as rn, FilesContext as rt, ExtensionDependencies as s, defineParser as sn, KubbDiagnosticContext as st, Adapter as t, Renderer as tn, CLIOptions as tt, ExtensionFactory as u, KubbFilesProcessingEndContext as ut, Group as v, KubbHookStartContext as vt, Output as w, KubbSuccessContext as wt, KubbPluginSetupContext as x, KubbLifecycleStartContext as xt, Include as y, KubbHooks as yt, ResolveFileOptions as z, ReporterPluginFiles as zt };
|
|
3028
|
+
//# sourceMappingURL=createAdapter-D55JE9lX.d.ts.map
|