@kubb/core 4.1.4 → 4.2.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.
- package/dist/URLPath-8WVzHBnA.cjs +134 -0
- package/dist/URLPath-8WVzHBnA.cjs.map +1 -0
- package/dist/URLPath-BYceu_vY.js +117 -0
- package/dist/URLPath-BYceu_vY.js.map +1 -0
- package/dist/{acorn-Cg_eXN51.cjs → acorn-BAVXZMtK.cjs} +17 -21
- package/dist/{acorn-Cg_eXN51.cjs.map → acorn-BAVXZMtK.cjs.map} +1 -1
- package/dist/{acorn-Z0oy0vSt.js → acorn-D-VhIOLw.js} +17 -21
- package/dist/{acorn-Z0oy0vSt.js.map → acorn-D-VhIOLw.js.map} +1 -1
- package/dist/{angular-nBly58h0.cjs → angular-Bp0XO9db.cjs} +24 -29
- package/dist/{angular-nBly58h0.cjs.map → angular-Bp0XO9db.cjs.map} +1 -1
- package/dist/{angular-BUlb_iaU.js → angular-Czhp4eq5.js} +24 -29
- package/dist/{angular-BUlb_iaU.js.map → angular-Czhp4eq5.js.map} +1 -1
- package/dist/{babel-DfXTN9QX.js → babel-DCR_B4Qn.js} +27 -37
- package/dist/{babel-DfXTN9QX.js.map → babel-DCR_B4Qn.js.map} +1 -1
- package/dist/{babel-5qXjvTGO.cjs → babel-NI0v59ga.cjs} +27 -37
- package/dist/{babel-5qXjvTGO.cjs.map → babel-NI0v59ga.cjs.map} +1 -1
- package/dist/casing-BSeq_teY.js +100 -0
- package/dist/casing-BSeq_teY.js.map +1 -0
- package/dist/casing-CP-9GGdK.cjs +112 -0
- package/dist/casing-CP-9GGdK.cjs.map +1 -0
- package/dist/{chunk-kPDogv7o.js → chunk-1SJ2vVWa.js} +1 -1
- package/dist/{estree-DyiFjXDy.cjs → estree-C3BZPlpU.cjs} +49 -64
- package/dist/{estree-DyiFjXDy.cjs.map → estree-C3BZPlpU.cjs.map} +1 -1
- package/dist/{estree-Bt3vRtV3.js → estree-DU2NummP.js} +49 -64
- package/dist/{estree-Bt3vRtV3.js.map → estree-DU2NummP.js.map} +1 -1
- package/dist/{flow-DdtBrX0O.cjs → flow-CWUBUkoi.cjs} +978 -1038
- package/dist/{flow-DdtBrX0O.cjs.map → flow-CWUBUkoi.cjs.map} +1 -1
- package/dist/{flow-Bb8_yYns.js → flow-JiEbweKj.js} +978 -1038
- package/dist/{flow-Bb8_yYns.js.map → flow-JiEbweKj.js.map} +1 -1
- package/dist/{fs-BNC5Fj6t.js → fs-BIPMUfpW.js} +3 -4
- package/dist/{fs-BNC5Fj6t.js.map → fs-BIPMUfpW.js.map} +1 -1
- package/dist/{fs-Bi2kuxAm.cjs → fs-RSVoUw3S.cjs} +2 -3
- package/dist/{fs-Bi2kuxAm.cjs.map → fs-RSVoUw3S.cjs.map} +1 -1
- package/dist/fs.cjs +1 -1
- package/dist/fs.d.cts +1 -1
- package/dist/fs.d.ts +1 -1
- package/dist/fs.js +2 -2
- package/dist/{glimmer-BuCRLjbI.cjs → glimmer-CX9OqG1j.cjs} +27 -41
- package/dist/{glimmer-BuCRLjbI.cjs.map → glimmer-CX9OqG1j.cjs.map} +1 -1
- package/dist/{glimmer-By8WZPkK.js → glimmer-t9nWn9aE.js} +27 -41
- package/dist/{glimmer-By8WZPkK.js.map → glimmer-t9nWn9aE.js.map} +1 -1
- package/dist/{graphql-DsrNefXx.js → graphql-DjErlIi5.js} +16 -20
- package/dist/{graphql-DsrNefXx.js.map → graphql-DjErlIi5.js.map} +1 -1
- package/dist/{graphql-TN0hv-fx.cjs → graphql-GOxQAKxM.cjs} +16 -20
- package/dist/{graphql-TN0hv-fx.cjs.map → graphql-GOxQAKxM.cjs.map} +1 -1
- package/dist/hooks.cjs +29 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +16 -0
- package/dist/hooks.d.ts +16 -0
- package/dist/hooks.js +25 -0
- package/dist/hooks.js.map +1 -0
- package/dist/{html-1W4-2_9J.cjs → html-CWrdYAhQ.cjs} +26 -27
- package/dist/{html-1W4-2_9J.cjs.map → html-CWrdYAhQ.cjs.map} +1 -1
- package/dist/{html-Y5KDc150.js → html-_apcbx34.js} +26 -27
- package/dist/{html-Y5KDc150.js.map → html-_apcbx34.js.map} +1 -1
- package/dist/{index-CGJ3tdk-.d.ts → index-BTe91LHd.d.ts} +7 -2
- package/dist/{index-CWX6_-da.d.cts → index-BmQIxvw0.d.cts} +5 -2
- package/dist/index.cjs +383 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -10
- package/dist/index.d.ts +43 -10
- package/dist/index.js +376 -23
- package/dist/index.js.map +1 -1
- package/dist/{logger-OWS6fqk0.d.cts → logger-BA-za85-.d.ts} +2 -2
- package/dist/{logger-DBJsdlpZ.cjs → logger-BXL0YCrv.cjs} +8 -12
- package/dist/{logger-DBJsdlpZ.cjs.map → logger-BXL0YCrv.cjs.map} +1 -1
- package/dist/{logger-BKPT4rkB.js → logger-CDxSrFkR.js} +10 -14
- package/dist/{logger-BKPT4rkB.js.map → logger-CDxSrFkR.js.map} +1 -1
- package/dist/{logger-B-4AXUmB.d.ts → logger-DpoDtxfo.d.cts} +2 -2
- package/dist/logger.cjs +1 -1
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +2 -2
- package/dist/{markdown-Drl4Cbq5.js → markdown-ckUc3Q6q.js} +25 -29
- package/dist/{markdown-Drl4Cbq5.js.map → markdown-ckUc3Q6q.js.map} +1 -1
- package/dist/{markdown-Bltb-uzO.cjs → markdown-pzqiRmft.cjs} +25 -29
- package/dist/{markdown-Bltb-uzO.cjs.map → markdown-pzqiRmft.cjs.map} +1 -1
- package/dist/{meriyah-Cz9whwp-.js → meriyah-BjnGqpUs.js} +21 -29
- package/dist/{meriyah-Cz9whwp-.js.map → meriyah-BjnGqpUs.js.map} +1 -1
- package/dist/{meriyah-CdG8HPS2.cjs → meriyah-D_x7itbT.cjs} +21 -29
- package/dist/{meriyah-CdG8HPS2.cjs.map → meriyah-D_x7itbT.cjs.map} +1 -1
- package/dist/mocks.cjs +87 -144
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +4 -3
- package/dist/mocks.d.ts +4 -3
- package/dist/mocks.js +83 -141
- package/dist/mocks.js.map +1 -1
- package/dist/{postcss-B7n9zUIy.cjs → postcss-B_c2wbFu.cjs} +41 -54
- package/dist/{postcss-B7n9zUIy.cjs.map → postcss-B_c2wbFu.cjs.map} +1 -1
- package/dist/{postcss-Dfx_9buT.js → postcss-v7BP6SZ-.js} +41 -54
- package/dist/{postcss-Dfx_9buT.js.map → postcss-v7BP6SZ-.js.map} +1 -1
- package/dist/{prompt-BMs_Y-vT.js → prompt-DBVnG4Me.js} +30 -32
- package/dist/{prompt-BMs_Y-vT.js.map → prompt-DBVnG4Me.js.map} +1 -1
- package/dist/{prompt-BXlYKArM.cjs → prompt-DgONOpPH.cjs} +29 -31
- package/dist/{prompt-BXlYKArM.cjs.map → prompt-DgONOpPH.cjs.map} +1 -1
- package/dist/{transformers-DZ22lE-S.cjs → transformers-BH0KLJJP.cjs} +130 -248
- package/dist/transformers-BH0KLJJP.cjs.map +1 -0
- package/dist/{transformers-BllSzdDt.js → transformers-DzHGqYO2.js} +130 -236
- package/dist/transformers-DzHGqYO2.js.map +1 -0
- package/dist/transformers.cjs +4 -3
- package/dist/transformers.js +2 -1
- package/dist/types-BzI9JlV8.d.ts +5 -0
- package/dist/types-C3ea5qNG.d.cts +5 -0
- package/dist/{PluginManager-BSUDeUfP.d.ts → types-DNxlynJr.d.cts} +187 -246
- package/dist/{PluginManager-a3RiDAFC.d.cts → types-DPeNK0FO.d.ts} +187 -246
- package/dist/{typescript-Evf8GXVW.cjs → typescript-6kMN6Wqz.cjs} +100 -152
- package/dist/{typescript-Evf8GXVW.cjs.map → typescript-6kMN6Wqz.cjs.map} +1 -1
- package/dist/{typescript-C8iCxnaF.js → typescript-B_IBfKSe.js} +101 -153
- package/dist/{typescript-C8iCxnaF.js.map → typescript-B_IBfKSe.js.map} +1 -1
- package/dist/typescript-C5hce4HG.cjs +4 -0
- package/dist/typescript-Cas1XcNz.js +3 -0
- package/dist/utils.cjs +165 -20
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +136 -5
- package/dist/utils.d.ts +136 -5
- package/dist/utils.js +156 -5
- package/dist/utils.js.map +1 -0
- package/dist/{write-O9QWtBJ_.js → write-CxO1CDML.js} +2 -2
- package/dist/{write-O9QWtBJ_.js.map → write-CxO1CDML.js.map} +1 -1
- package/dist/{yaml-Bi_nSoU_.js → yaml-BfWM_B73.js} +141 -157
- package/dist/{yaml-Bi_nSoU_.js.map → yaml-BfWM_B73.js.map} +1 -1
- package/dist/{yaml-B2qeXFgu.cjs → yaml-DZs6MhV1.cjs} +141 -157
- package/dist/{yaml-B2qeXFgu.cjs.map → yaml-DZs6MhV1.cjs.map} +1 -1
- package/package.json +15 -3
- package/src/FileManager.ts +34 -302
- package/src/PluginManager.ts +9 -8
- package/src/__snapshots__/barrel.json +5 -5
- package/src/build.ts +19 -5
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useMode.ts +8 -0
- package/src/hooks/usePlugin.ts +8 -0
- package/src/hooks/usePluginManager.ts +8 -0
- package/src/index.ts +1 -2
- package/src/mocks/index.ts +4 -3
- package/src/plugin.ts +1 -1
- package/src/types.ts +4 -1
- package/src/utils/TreeNode.ts +3 -3
- package/src/utils/index.ts +2 -4
- package/dist/FileManager-B0V0rX5Z.js +0 -881
- package/dist/FileManager-B0V0rX5Z.js.map +0 -1
- package/dist/FileManager-COJW0Zp4.cjs +0 -1003
- package/dist/FileManager-COJW0Zp4.cjs.map +0 -1
- package/dist/index-B7KKQHG8.d.cts +0 -179
- package/dist/index-BhFFCWR1.d.ts +0 -179
- package/dist/transformers-BllSzdDt.js.map +0 -1
- package/dist/transformers-DZ22lE-S.cjs.map +0 -1
- package/dist/typescript-BY9-7pw9.js +0 -3
- package/dist/typescript-PxlX-TH7.cjs +0 -4
- package/src/utils/parser.ts +0 -199
|
@@ -1,10 +1,156 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as Mode, i as File, n as BaseName, o as OptionalPath, r as Extname, s as ResolvedFile } from "./index-BTe91LHd.js";
|
|
2
|
+
import { n as Logger, o as EventEmitter } from "./logger-BA-za85-.js";
|
|
3
|
+
import { t as PossiblePromise } from "./types-BzI9JlV8.js";
|
|
4
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
3
5
|
|
|
4
|
-
//#region src/
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
6
|
+
//#region src/PluginManager.d.ts
|
|
7
|
+
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
8
|
+
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
9
|
+
type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
10
|
+
message: string;
|
|
11
|
+
strategy: Strategy;
|
|
12
|
+
hookName: H$1;
|
|
13
|
+
plugin: Plugin;
|
|
14
|
+
parameters?: unknown[] | undefined;
|
|
15
|
+
output?: unknown;
|
|
16
|
+
};
|
|
17
|
+
type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
|
|
18
|
+
type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
|
|
19
|
+
result: Result;
|
|
20
|
+
plugin: Plugin;
|
|
21
|
+
};
|
|
22
|
+
type Options = {
|
|
23
|
+
logger: Logger;
|
|
24
|
+
/**
|
|
25
|
+
* @default Number.POSITIVE_INFINITY
|
|
26
|
+
*/
|
|
27
|
+
concurrency?: number;
|
|
28
|
+
};
|
|
29
|
+
type Events = {
|
|
30
|
+
executing: [executer: Executer];
|
|
31
|
+
executed: [executer: Executer];
|
|
32
|
+
error: [error: Error];
|
|
33
|
+
};
|
|
34
|
+
type GetFileProps<TOptions$1 = object> = {
|
|
35
|
+
name: string;
|
|
36
|
+
mode?: Mode;
|
|
37
|
+
extname: Extname;
|
|
38
|
+
pluginKey: Plugin['key'];
|
|
39
|
+
options?: TOptions$1;
|
|
40
|
+
};
|
|
41
|
+
declare class PluginManager {
|
|
42
|
+
#private;
|
|
43
|
+
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated do not use from pluginManager
|
|
46
|
+
*/
|
|
47
|
+
readonly fileManager: FileManager;
|
|
48
|
+
readonly events: EventEmitter<Events>;
|
|
49
|
+
readonly config: Config;
|
|
50
|
+
readonly executed: Array<Executer>;
|
|
51
|
+
readonly logger: Logger;
|
|
52
|
+
readonly options: Options;
|
|
53
|
+
constructor(config: Config, options: Options);
|
|
54
|
+
getFile<TOptions = object>({
|
|
55
|
+
name,
|
|
56
|
+
mode,
|
|
57
|
+
extname,
|
|
58
|
+
pluginKey,
|
|
59
|
+
options
|
|
60
|
+
}: GetFileProps<TOptions>): File<{
|
|
61
|
+
pluginKey: Plugin['key'];
|
|
62
|
+
}>;
|
|
63
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
64
|
+
resolveName: (params: ResolveNameParams) => string;
|
|
65
|
+
/**
|
|
66
|
+
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
67
|
+
*/
|
|
68
|
+
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
69
|
+
/**
|
|
70
|
+
* Run a specific hookName for plugin x.
|
|
71
|
+
*/
|
|
72
|
+
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
73
|
+
pluginKey,
|
|
74
|
+
hookName,
|
|
75
|
+
parameters,
|
|
76
|
+
message
|
|
77
|
+
}: {
|
|
78
|
+
pluginKey: Plugin['key'];
|
|
79
|
+
hookName: H;
|
|
80
|
+
parameters: PluginParameter<H>;
|
|
81
|
+
message: string;
|
|
82
|
+
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
83
|
+
/**
|
|
84
|
+
* Run a specific hookName for plugin x.
|
|
85
|
+
*/
|
|
86
|
+
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
87
|
+
pluginKey,
|
|
88
|
+
hookName,
|
|
89
|
+
parameters,
|
|
90
|
+
message
|
|
91
|
+
}: {
|
|
92
|
+
pluginKey: Plugin['key'];
|
|
93
|
+
hookName: H;
|
|
94
|
+
parameters: PluginParameter<H>;
|
|
95
|
+
message: string;
|
|
96
|
+
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
97
|
+
/**
|
|
98
|
+
* First non-null result stops and will return it's value.
|
|
99
|
+
*/
|
|
100
|
+
hookFirst<H extends PluginLifecycleHooks>({
|
|
101
|
+
hookName,
|
|
102
|
+
parameters,
|
|
103
|
+
skipped,
|
|
104
|
+
message
|
|
105
|
+
}: {
|
|
106
|
+
hookName: H;
|
|
107
|
+
parameters: PluginParameter<H>;
|
|
108
|
+
skipped?: ReadonlySet<Plugin> | null;
|
|
109
|
+
message: string;
|
|
110
|
+
}): Promise<SafeParseResult<H>>;
|
|
111
|
+
/**
|
|
112
|
+
* First non-null result stops and will return it's value.
|
|
113
|
+
*/
|
|
114
|
+
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
115
|
+
hookName,
|
|
116
|
+
parameters,
|
|
117
|
+
skipped,
|
|
118
|
+
message
|
|
119
|
+
}: {
|
|
120
|
+
hookName: H;
|
|
121
|
+
parameters: PluginParameter<H>;
|
|
122
|
+
skipped?: ReadonlySet<Plugin> | null;
|
|
123
|
+
message: string;
|
|
124
|
+
}): SafeParseResult<H>;
|
|
125
|
+
/**
|
|
126
|
+
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
127
|
+
*/
|
|
128
|
+
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
129
|
+
hookName,
|
|
130
|
+
parameters,
|
|
131
|
+
message
|
|
132
|
+
}: {
|
|
133
|
+
hookName: H;
|
|
134
|
+
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
135
|
+
message: string;
|
|
136
|
+
}): Promise<Awaited<TOuput>[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Chains plugins
|
|
139
|
+
*/
|
|
140
|
+
hookSeq<H extends PluginLifecycleHooks>({
|
|
141
|
+
hookName,
|
|
142
|
+
parameters,
|
|
143
|
+
message
|
|
144
|
+
}: {
|
|
145
|
+
hookName: H;
|
|
146
|
+
parameters?: PluginParameter<H>;
|
|
147
|
+
message: string;
|
|
148
|
+
}): Promise<void>;
|
|
149
|
+
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
150
|
+
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
151
|
+
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;
|
|
152
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
153
|
+
}
|
|
8
154
|
//#endregion
|
|
9
155
|
//#region src/types.d.ts
|
|
10
156
|
/**
|
|
@@ -137,11 +283,11 @@ TName extends string = string,
|
|
|
137
283
|
/**
|
|
138
284
|
* Options of the plugin.
|
|
139
285
|
*/
|
|
140
|
-
TOptions extends object = object,
|
|
286
|
+
TOptions$1 extends object = object,
|
|
141
287
|
/**
|
|
142
288
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
143
289
|
*/
|
|
144
|
-
TResolvedOptions extends object = TOptions,
|
|
290
|
+
TResolvedOptions extends object = TOptions$1,
|
|
145
291
|
/**
|
|
146
292
|
* Context that you want to expose to other plugins.
|
|
147
293
|
*/
|
|
@@ -155,24 +301,24 @@ TResolvePathOptions extends object = object> = {
|
|
|
155
301
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
156
302
|
*/
|
|
157
303
|
key: PluginKey<TName | string>;
|
|
158
|
-
options: TOptions;
|
|
304
|
+
options: TOptions$1;
|
|
159
305
|
resolvedOptions: TResolvedOptions;
|
|
160
306
|
context: TContext;
|
|
161
307
|
resolvePathOptions: TResolvePathOptions;
|
|
162
308
|
};
|
|
163
309
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
164
310
|
type GetPluginFactoryOptions<TPlugin extends UserPlugin> = TPlugin extends UserPlugin<infer X> ? X : never;
|
|
165
|
-
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
311
|
+
type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
166
312
|
/**
|
|
167
313
|
* Unique name used for the plugin
|
|
168
314
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
169
315
|
* @example @kubb/typescript
|
|
170
316
|
*/
|
|
171
|
-
name: TOptions['name'];
|
|
317
|
+
name: TOptions$1['name'];
|
|
172
318
|
/**
|
|
173
319
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
174
320
|
*/
|
|
175
|
-
options: TOptions['resolvedOptions'];
|
|
321
|
+
options: TOptions$1['resolvedOptions'];
|
|
176
322
|
/**
|
|
177
323
|
* 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.
|
|
178
324
|
* Can be used to validate dependent plugins.
|
|
@@ -182,24 +328,24 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
182
328
|
* 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.
|
|
183
329
|
*/
|
|
184
330
|
post?: Array<string>;
|
|
185
|
-
} & (TOptions['context'] extends never ? {
|
|
331
|
+
} & (TOptions$1['context'] extends never ? {
|
|
186
332
|
context?: never;
|
|
187
333
|
} : {
|
|
188
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
334
|
+
context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
|
|
189
335
|
});
|
|
190
|
-
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
336
|
+
type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
191
337
|
type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
|
|
192
|
-
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
338
|
+
type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
193
339
|
/**
|
|
194
340
|
* Unique name used for the plugin
|
|
195
341
|
* @example @kubb/typescript
|
|
196
342
|
*/
|
|
197
|
-
name: TOptions['name'];
|
|
343
|
+
name: TOptions$1['name'];
|
|
198
344
|
/**
|
|
199
345
|
* Internal key used when a developer uses more than one of the same plugin
|
|
200
346
|
* @private
|
|
201
347
|
*/
|
|
202
|
-
key: TOptions['key'];
|
|
348
|
+
key: TOptions$1['key'];
|
|
203
349
|
/**
|
|
204
350
|
* 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.
|
|
205
351
|
* Can be used to validate dependent plugins.
|
|
@@ -212,49 +358,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
212
358
|
/**
|
|
213
359
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
214
360
|
*/
|
|
215
|
-
options: TOptions['resolvedOptions'];
|
|
216
|
-
} & (TOptions['context'] extends never ? {
|
|
361
|
+
options: TOptions$1['resolvedOptions'];
|
|
362
|
+
} & (TOptions$1['context'] extends never ? {
|
|
217
363
|
context?: never;
|
|
218
364
|
} : {
|
|
219
|
-
context: TOptions['context'];
|
|
365
|
+
context: TOptions$1['context'];
|
|
220
366
|
});
|
|
221
|
-
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
222
|
-
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
367
|
+
type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
368
|
+
type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
223
369
|
/**
|
|
224
370
|
* Start of the lifecycle of a plugin.
|
|
225
371
|
* @type hookParallel
|
|
226
372
|
*/
|
|
227
|
-
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
373
|
+
buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
|
|
228
374
|
/**
|
|
229
375
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
230
376
|
* Options can als be included.
|
|
231
377
|
* @type hookFirst
|
|
232
378
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
233
379
|
*/
|
|
234
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
380
|
+
resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
|
|
235
381
|
/**
|
|
236
382
|
* Resolve to a name based on a string.
|
|
237
383
|
* Useful when converting to PascalCase or camelCase.
|
|
238
384
|
* @type hookFirst
|
|
239
385
|
* @example ('pet') => 'Pet'
|
|
240
386
|
*/
|
|
241
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
387
|
+
resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
242
388
|
/**
|
|
243
389
|
* End of the plugin lifecycle.
|
|
244
390
|
* @type hookParallel
|
|
245
391
|
*/
|
|
246
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
392
|
+
buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
|
|
247
393
|
};
|
|
248
394
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
249
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
250
|
-
type ResolvePathParams<TOptions = object> = {
|
|
395
|
+
type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
|
|
396
|
+
type ResolvePathParams<TOptions$1 = object> = {
|
|
251
397
|
pluginKey?: Plugin['key'];
|
|
252
398
|
baseName: BaseName;
|
|
253
399
|
mode?: Mode;
|
|
254
400
|
/**
|
|
255
401
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
256
402
|
*/
|
|
257
|
-
options?: TOptions;
|
|
403
|
+
options?: TOptions$1;
|
|
258
404
|
};
|
|
259
405
|
type ResolveNameParams = {
|
|
260
406
|
name: string;
|
|
@@ -267,12 +413,15 @@ type ResolveNameParams = {
|
|
|
267
413
|
*/
|
|
268
414
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
269
415
|
};
|
|
270
|
-
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
416
|
+
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
271
417
|
config: Config;
|
|
418
|
+
/**
|
|
419
|
+
* @deprecated
|
|
420
|
+
*/
|
|
272
421
|
fileManager: FileManager;
|
|
273
422
|
pluginManager: PluginManager;
|
|
274
423
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
275
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
424
|
+
resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
|
|
276
425
|
resolveName: (params: ResolveNameParams) => string;
|
|
277
426
|
logger: Logger;
|
|
278
427
|
/**
|
|
@@ -282,12 +431,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
282
431
|
/**
|
|
283
432
|
* Current plugin
|
|
284
433
|
*/
|
|
285
|
-
plugin: Plugin<TOptions>;
|
|
434
|
+
plugin: Plugin<TOptions$1>;
|
|
286
435
|
};
|
|
287
436
|
/**
|
|
288
437
|
* Specify the export location for the files and define the behavior of the output
|
|
289
438
|
*/
|
|
290
|
-
type Output<TOptions> = {
|
|
439
|
+
type Output<TOptions$1> = {
|
|
291
440
|
/**
|
|
292
441
|
* Path to the output folder or file that will contain the generated code
|
|
293
442
|
*/
|
|
@@ -300,11 +449,11 @@ type Output<TOptions> = {
|
|
|
300
449
|
/**
|
|
301
450
|
* Add a banner text in the beginning of every file
|
|
302
451
|
*/
|
|
303
|
-
banner?: string | ((options: TOptions) => string);
|
|
452
|
+
banner?: string | ((options: TOptions$1) => string);
|
|
304
453
|
/**
|
|
305
454
|
* Add a footer text in the beginning of every file
|
|
306
455
|
*/
|
|
307
|
-
footer?: string | ((options: TOptions) => string);
|
|
456
|
+
footer?: string | ((options: TOptions$1) => string);
|
|
308
457
|
};
|
|
309
458
|
type GroupContext = {
|
|
310
459
|
group: string;
|
|
@@ -320,213 +469,5 @@ type Group = {
|
|
|
320
469
|
name?: (context: GroupContext) => string;
|
|
321
470
|
};
|
|
322
471
|
//#endregion
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
pluginKey?: Plugin['key'];
|
|
326
|
-
};
|
|
327
|
-
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
328
|
-
type AddIndexesProps = {
|
|
329
|
-
type: BarrelType | false | undefined;
|
|
330
|
-
/**
|
|
331
|
-
* Root based on root and output.path specified in the config
|
|
332
|
-
*/
|
|
333
|
-
root: string;
|
|
334
|
-
/**
|
|
335
|
-
* Output for plugin
|
|
336
|
-
*/
|
|
337
|
-
output: {
|
|
338
|
-
path: string;
|
|
339
|
-
};
|
|
340
|
-
group?: {
|
|
341
|
-
output: string;
|
|
342
|
-
exportAs: string;
|
|
343
|
-
};
|
|
344
|
-
logger?: Logger;
|
|
345
|
-
meta?: FileMetaBase;
|
|
346
|
-
};
|
|
347
|
-
type WriteFilesProps = {
|
|
348
|
-
root: Config['root'];
|
|
349
|
-
extension?: Record<Extname, Extname | ''>;
|
|
350
|
-
logger?: Logger;
|
|
351
|
-
dryRun?: boolean;
|
|
352
|
-
};
|
|
353
|
-
declare class FileManager {
|
|
354
|
-
#private;
|
|
355
|
-
constructor();
|
|
356
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
357
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
358
|
-
deleteByPath(path: Path): Promise<void>;
|
|
359
|
-
clear(): Promise<void>;
|
|
360
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
361
|
-
processFiles({
|
|
362
|
-
dryRun,
|
|
363
|
-
root,
|
|
364
|
-
extension,
|
|
365
|
-
logger
|
|
366
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
367
|
-
getBarrelFiles({
|
|
368
|
-
type,
|
|
369
|
-
meta,
|
|
370
|
-
root,
|
|
371
|
-
output,
|
|
372
|
-
logger
|
|
373
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
374
|
-
static getMode(path: string | undefined | null): Mode;
|
|
375
|
-
}
|
|
376
|
-
type GetSourceOptions = {
|
|
377
|
-
extname?: Extname;
|
|
378
|
-
logger?: Logger;
|
|
379
|
-
};
|
|
380
|
-
declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, {
|
|
381
|
-
logger,
|
|
382
|
-
extname
|
|
383
|
-
}?: GetSourceOptions): Promise<string>;
|
|
384
|
-
//#endregion
|
|
385
|
-
//#region src/PluginManager.d.ts
|
|
386
|
-
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
387
|
-
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
388
|
-
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
389
|
-
message: string;
|
|
390
|
-
strategy: Strategy;
|
|
391
|
-
hookName: H;
|
|
392
|
-
plugin: Plugin;
|
|
393
|
-
parameters?: unknown[] | undefined;
|
|
394
|
-
output?: unknown;
|
|
395
|
-
};
|
|
396
|
-
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
397
|
-
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
398
|
-
result: Result;
|
|
399
|
-
plugin: Plugin;
|
|
400
|
-
};
|
|
401
|
-
type Options = {
|
|
402
|
-
logger: Logger;
|
|
403
|
-
/**
|
|
404
|
-
* @default Number.POSITIVE_INFINITY
|
|
405
|
-
*/
|
|
406
|
-
concurrency?: number;
|
|
407
|
-
};
|
|
408
|
-
type Events = {
|
|
409
|
-
executing: [executer: Executer];
|
|
410
|
-
executed: [executer: Executer];
|
|
411
|
-
error: [error: Error];
|
|
412
|
-
};
|
|
413
|
-
type GetFileProps<TOptions = object> = {
|
|
414
|
-
name: string;
|
|
415
|
-
mode?: Mode;
|
|
416
|
-
extname: Extname;
|
|
417
|
-
pluginKey: Plugin['key'];
|
|
418
|
-
options?: TOptions;
|
|
419
|
-
};
|
|
420
|
-
declare class PluginManager {
|
|
421
|
-
#private;
|
|
422
|
-
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
423
|
-
readonly fileManager: FileManager;
|
|
424
|
-
readonly events: EventEmitter<Events>;
|
|
425
|
-
readonly config: Config;
|
|
426
|
-
readonly executed: Array<Executer>;
|
|
427
|
-
readonly logger: Logger;
|
|
428
|
-
readonly options: Options;
|
|
429
|
-
constructor(config: Config, options: Options);
|
|
430
|
-
getFile<TOptions = object>({
|
|
431
|
-
name,
|
|
432
|
-
mode,
|
|
433
|
-
extname,
|
|
434
|
-
pluginKey,
|
|
435
|
-
options
|
|
436
|
-
}: GetFileProps<TOptions>): File<{
|
|
437
|
-
pluginKey: Plugin['key'];
|
|
438
|
-
}>;
|
|
439
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
440
|
-
resolveName: (params: ResolveNameParams) => string;
|
|
441
|
-
/**
|
|
442
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
443
|
-
*/
|
|
444
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
445
|
-
/**
|
|
446
|
-
* Run a specific hookName for plugin x.
|
|
447
|
-
*/
|
|
448
|
-
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
449
|
-
pluginKey,
|
|
450
|
-
hookName,
|
|
451
|
-
parameters,
|
|
452
|
-
message
|
|
453
|
-
}: {
|
|
454
|
-
pluginKey: Plugin['key'];
|
|
455
|
-
hookName: H;
|
|
456
|
-
parameters: PluginParameter<H>;
|
|
457
|
-
message: string;
|
|
458
|
-
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
459
|
-
/**
|
|
460
|
-
* Run a specific hookName for plugin x.
|
|
461
|
-
*/
|
|
462
|
-
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
463
|
-
pluginKey,
|
|
464
|
-
hookName,
|
|
465
|
-
parameters,
|
|
466
|
-
message
|
|
467
|
-
}: {
|
|
468
|
-
pluginKey: Plugin['key'];
|
|
469
|
-
hookName: H;
|
|
470
|
-
parameters: PluginParameter<H>;
|
|
471
|
-
message: string;
|
|
472
|
-
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
473
|
-
/**
|
|
474
|
-
* First non-null result stops and will return it's value.
|
|
475
|
-
*/
|
|
476
|
-
hookFirst<H extends PluginLifecycleHooks>({
|
|
477
|
-
hookName,
|
|
478
|
-
parameters,
|
|
479
|
-
skipped,
|
|
480
|
-
message
|
|
481
|
-
}: {
|
|
482
|
-
hookName: H;
|
|
483
|
-
parameters: PluginParameter<H>;
|
|
484
|
-
skipped?: ReadonlySet<Plugin> | null;
|
|
485
|
-
message: string;
|
|
486
|
-
}): Promise<SafeParseResult<H>>;
|
|
487
|
-
/**
|
|
488
|
-
* First non-null result stops and will return it's value.
|
|
489
|
-
*/
|
|
490
|
-
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
491
|
-
hookName,
|
|
492
|
-
parameters,
|
|
493
|
-
skipped,
|
|
494
|
-
message
|
|
495
|
-
}: {
|
|
496
|
-
hookName: H;
|
|
497
|
-
parameters: PluginParameter<H>;
|
|
498
|
-
skipped?: ReadonlySet<Plugin> | null;
|
|
499
|
-
message: string;
|
|
500
|
-
}): SafeParseResult<H>;
|
|
501
|
-
/**
|
|
502
|
-
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
503
|
-
*/
|
|
504
|
-
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
505
|
-
hookName,
|
|
506
|
-
parameters,
|
|
507
|
-
message
|
|
508
|
-
}: {
|
|
509
|
-
hookName: H;
|
|
510
|
-
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
511
|
-
message: string;
|
|
512
|
-
}): Promise<Awaited<TOuput>[]>;
|
|
513
|
-
/**
|
|
514
|
-
* Chains plugins
|
|
515
|
-
*/
|
|
516
|
-
hookSeq<H extends PluginLifecycleHooks>({
|
|
517
|
-
hookName,
|
|
518
|
-
parameters,
|
|
519
|
-
message
|
|
520
|
-
}: {
|
|
521
|
-
hookName: H;
|
|
522
|
-
parameters?: PluginParameter<H>;
|
|
523
|
-
message: string;
|
|
524
|
-
}): Promise<void>;
|
|
525
|
-
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
526
|
-
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
527
|
-
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;
|
|
528
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
529
|
-
}
|
|
530
|
-
//#endregion
|
|
531
|
-
export { BarrelType, Config, FileManager, FileMetaBase, GetPluginFactoryOptions, Group, InputData, InputPath, Output, Plugin, PluginContext, PluginFactoryOptions, PluginKey, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, PossiblePromise, ResolveNameParams, ResolvePathParams, UserConfig, UserPlugin, UserPluginWithLifeCycle, getSource };
|
|
532
|
-
//# sourceMappingURL=PluginManager-a3RiDAFC.d.cts.map
|
|
472
|
+
export { ResolvePathParams as _, InputData as a, UserPluginWithLifeCycle as b, Plugin as c, PluginKey as d, PluginLifecycle as f, ResolveNameParams as g, PluginWithLifeCycle as h, Group as i, PluginContext as l, PluginParameter as m, Config as n, InputPath as o, PluginLifecycleHooks as p, GetPluginFactoryOptions as r, Output as s, BarrelType as t, PluginFactoryOptions as u, UserConfig as v, PluginManager as x, UserPlugin as y };
|
|
473
|
+
//# sourceMappingURL=types-DPeNK0FO.d.ts.map
|