@kubb/core 5.0.0-alpha.4 → 5.0.0-alpha.5

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.
@@ -1,8 +1,7 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
2
  import { EventEmitter } from "node:events";
3
- import { Fabric } from "@kubb/react-fabric";
3
+ import { Fabric, KubbFile } from "@kubb/fabric-core/types";
4
4
  import { OperationNode, Printer, PrinterFactoryOptions, RootNode, SchemaNode } from "@kubb/ast/types";
5
- import { KubbFile } from "@kubb/fabric-core/types";
6
5
  import { FabricReactNode } from "@kubb/react-fabric/types";
7
6
 
8
7
  //#region ../../internals/utils/dist/index.d.ts
@@ -194,127 +193,6 @@ interface DefineStorage {
194
193
  */
195
194
  declare function defineStorage<TOptions = Record<string, never>>(build: (options: TOptions) => DefineStorage): (options?: TOptions) => DefineStorage;
196
195
  //#endregion
197
- //#region src/PluginManager.d.ts
198
- type RequiredPluginLifecycle = Required<PluginLifecycle>;
199
- type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
200
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
201
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
202
- result: Result;
203
- plugin: Plugin;
204
- };
205
- type Options = {
206
- fabric: Fabric;
207
- events: AsyncEventEmitter<KubbEvents>;
208
- /**
209
- * @default Number.POSITIVE_INFINITY
210
- */
211
- concurrency?: number;
212
- };
213
- type GetFileProps<TOptions = object> = {
214
- name: string;
215
- mode?: KubbFile.Mode;
216
- extname: KubbFile.Extname;
217
- pluginName: string;
218
- options?: TOptions;
219
- };
220
- declare function getMode(fileOrFolder: string | undefined | null): KubbFile.Mode;
221
- declare class PluginManager {
222
- #private;
223
- readonly config: Config;
224
- readonly options: Options;
225
- /**
226
- * The universal `@kubb/ast` `RootNode` produced by the adapter, set by
227
- * the build pipeline after the adapter's `parse()` resolves.
228
- */
229
- rootNode: RootNode | undefined;
230
- adapter: Adapter | undefined;
231
- constructor(config: Config, options: Options);
232
- get events(): AsyncEventEmitter<KubbEvents>;
233
- getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, unknown>;
234
- get plugins(): Array<Plugin>;
235
- getFile<TOptions = object>({
236
- name,
237
- mode,
238
- extname,
239
- pluginName,
240
- options
241
- }: GetFileProps<TOptions>): KubbFile.File<{
242
- pluginName: string;
243
- }>;
244
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
245
- resolveName: (params: ResolveNameParams) => string;
246
- /**
247
- * Run a specific hookName for plugin x.
248
- */
249
- hookForPlugin<H extends PluginLifecycleHooks>({
250
- pluginName,
251
- hookName,
252
- parameters
253
- }: {
254
- pluginName: string;
255
- hookName: H;
256
- parameters: PluginParameter<H>;
257
- }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
258
- /**
259
- * Run a specific hookName for plugin x.
260
- */
261
- hookForPluginSync<H extends PluginLifecycleHooks>({
262
- pluginName,
263
- hookName,
264
- parameters
265
- }: {
266
- pluginName: string;
267
- hookName: H;
268
- parameters: PluginParameter<H>;
269
- }): Array<ReturnType<ParseResult<H>>> | null;
270
- /**
271
- * Returns the first non-null result.
272
- */
273
- hookFirst<H extends PluginLifecycleHooks>({
274
- hookName,
275
- parameters,
276
- skipped
277
- }: {
278
- hookName: H;
279
- parameters: PluginParameter<H>;
280
- skipped?: ReadonlySet<Plugin> | null;
281
- }): Promise<SafeParseResult<H>>;
282
- /**
283
- * Returns the first non-null result.
284
- */
285
- hookFirstSync<H extends PluginLifecycleHooks>({
286
- hookName,
287
- parameters,
288
- skipped
289
- }: {
290
- hookName: H;
291
- parameters: PluginParameter<H>;
292
- skipped?: ReadonlySet<Plugin> | null;
293
- }): SafeParseResult<H> | null;
294
- /**
295
- * Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
296
- */
297
- hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
298
- hookName,
299
- parameters
300
- }: {
301
- hookName: H;
302
- parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
303
- }): Promise<Awaited<TOutput>[]>;
304
- /**
305
- * Chains plugins
306
- */
307
- hookSeq<H extends PluginLifecycleHooks>({
308
- hookName,
309
- parameters
310
- }: {
311
- hookName: H;
312
- parameters?: PluginParameter<H>;
313
- }): Promise<void>;
314
- getPluginByName(pluginName: string): Plugin | undefined;
315
- getPluginsByName(hookName: keyof PluginWithLifeCycle, pluginName: string): Plugin[];
316
- }
317
- //#endregion
318
196
  //#region src/Kubb.d.ts
319
197
  type DebugEvent = {
320
198
  date: Date;
@@ -1053,5 +931,126 @@ type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
1053
931
  };
1054
932
  type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Omit<Logger<TOptions>, 'logLevel'>;
1055
933
  //#endregion
1056
- export { UserPluginWithLifeCycle as A, formatters as B, PrinterFactoryOptions as C, UserConfig as D, UnknownUserPlugin as E, KubbEvents as F, logLevel as H, PluginManager as I, getMode as L, Generator as M, ReactGeneratorV2 as N, UserLogger as O, defineGenerator as P, DefineStorage as R, Printer as S, ResolvePathParams as T, AsyncEventEmitter as U, linters as V, URLPath as W, PluginFactoryOptions as _, Config as a, PluginParameter as b, Group as c, Logger as d, LoggerContext as f, PluginContext as g, Plugin as h, BarrelType as i, CoreGeneratorV2 as j, UserPlugin as k, InputData as l, Output as m, AdapterFactoryOptions as n, DevtoolsOptions as o, LoggerOptions as p, AdapterSource as r, GetPluginFactoryOptions as s, Adapter as t, InputPath as u, PluginLifecycle as v, ResolveNameParams as w, PluginWithLifeCycle as x, PluginLifecycleHooks as y, defineStorage as z };
1057
- //# sourceMappingURL=types-Bbh1o0yW.d.ts.map
934
+ //#region src/PluginManager.d.ts
935
+ type RequiredPluginLifecycle = Required<PluginLifecycle>;
936
+ type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
937
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
938
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
939
+ result: Result;
940
+ plugin: Plugin;
941
+ };
942
+ type Options = {
943
+ fabric: Fabric;
944
+ events: AsyncEventEmitter<KubbEvents>;
945
+ /**
946
+ * @default Number.POSITIVE_INFINITY
947
+ */
948
+ concurrency?: number;
949
+ };
950
+ type GetFileOptions<TOptions = object> = {
951
+ name: string;
952
+ mode?: KubbFile.Mode;
953
+ extname: KubbFile.Extname;
954
+ pluginName: string;
955
+ options?: TOptions;
956
+ };
957
+ declare function getMode(fileOrFolder: string | undefined | null): KubbFile.Mode;
958
+ declare class PluginManager {
959
+ #private;
960
+ readonly config: Config;
961
+ readonly options: Options;
962
+ /**
963
+ * The universal `@kubb/ast` `RootNode` produced by the adapter, set by
964
+ * the build pipeline after the adapter's `parse()` resolves.
965
+ */
966
+ rootNode: RootNode | undefined;
967
+ adapter: Adapter | undefined;
968
+ constructor(config: Config, options: Options);
969
+ get events(): AsyncEventEmitter<KubbEvents>;
970
+ getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, unknown>;
971
+ get plugins(): Array<Plugin>;
972
+ getFile<TOptions = object>({
973
+ name,
974
+ mode,
975
+ extname,
976
+ pluginName,
977
+ options
978
+ }: GetFileOptions<TOptions>): KubbFile.File<{
979
+ pluginName: string;
980
+ }>;
981
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
982
+ resolveName: (params: ResolveNameParams) => string;
983
+ /**
984
+ * Run a specific hookName for plugin x.
985
+ */
986
+ hookForPlugin<H extends PluginLifecycleHooks>({
987
+ pluginName,
988
+ hookName,
989
+ parameters
990
+ }: {
991
+ pluginName: string;
992
+ hookName: H;
993
+ parameters: PluginParameter<H>;
994
+ }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
995
+ /**
996
+ * Run a specific hookName for plugin x.
997
+ */
998
+ hookForPluginSync<H extends PluginLifecycleHooks>({
999
+ pluginName,
1000
+ hookName,
1001
+ parameters
1002
+ }: {
1003
+ pluginName: string;
1004
+ hookName: H;
1005
+ parameters: PluginParameter<H>;
1006
+ }): Array<ReturnType<ParseResult<H>>> | null;
1007
+ /**
1008
+ * Returns the first non-null result.
1009
+ */
1010
+ hookFirst<H extends PluginLifecycleHooks>({
1011
+ hookName,
1012
+ parameters,
1013
+ skipped
1014
+ }: {
1015
+ hookName: H;
1016
+ parameters: PluginParameter<H>;
1017
+ skipped?: ReadonlySet<Plugin> | null;
1018
+ }): Promise<SafeParseResult<H>>;
1019
+ /**
1020
+ * Returns the first non-null result.
1021
+ */
1022
+ hookFirstSync<H extends PluginLifecycleHooks>({
1023
+ hookName,
1024
+ parameters,
1025
+ skipped
1026
+ }: {
1027
+ hookName: H;
1028
+ parameters: PluginParameter<H>;
1029
+ skipped?: ReadonlySet<Plugin> | null;
1030
+ }): SafeParseResult<H> | null;
1031
+ /**
1032
+ * Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
1033
+ */
1034
+ hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
1035
+ hookName,
1036
+ parameters
1037
+ }: {
1038
+ hookName: H;
1039
+ parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
1040
+ }): Promise<Awaited<TOutput>[]>;
1041
+ /**
1042
+ * Chains plugins
1043
+ */
1044
+ hookSeq<H extends PluginLifecycleHooks>({
1045
+ hookName,
1046
+ parameters
1047
+ }: {
1048
+ hookName: H;
1049
+ parameters?: PluginParameter<H>;
1050
+ }): Promise<void>;
1051
+ getPluginByName(pluginName: string): Plugin | undefined;
1052
+ getPluginsByName(hookName: keyof PluginWithLifeCycle, pluginName: string): Plugin[];
1053
+ }
1054
+ //#endregion
1055
+ export { UserConfig as A, defineStorage as B, PluginParameter as C, ResolveNameParams as D, PrinterFactoryOptions as E, Generator as F, URLPath as G, linters as H, ReactGeneratorV2 as I, defineGenerator as L, UserPlugin as M, UserPluginWithLifeCycle as N, ResolvePathParams as O, CoreGeneratorV2 as P, KubbEvents as R, PluginLifecycleHooks as S, Printer as T, logLevel as U, formatters as V, AsyncEventEmitter as W, Output as _, AdapterFactoryOptions as a, PluginFactoryOptions as b, Config as c, Group as d, InputData as f, LoggerOptions as g, LoggerContext as h, Adapter as i, UserLogger as j, UnknownUserPlugin as k, DevtoolsOptions as l, Logger as m, PluginManager as n, AdapterSource as o, InputPath as p, getMode as r, BarrelType as s, GetFileOptions as t, GetPluginFactoryOptions as u, Plugin as v, PluginWithLifeCycle as w, PluginLifecycle as x, PluginContext as y, DefineStorage as z };
1056
+ //# sourceMappingURL=PluginManager-vZodFEMe.d.ts.map
package/dist/hooks.cjs CHANGED
@@ -3,15 +3,25 @@ require("./chunk-ByKO4r7w.cjs");
3
3
  let _kubb_react_fabric = require("@kubb/react-fabric");
4
4
  //#region src/hooks/useKubb.ts
5
5
  function useKubb() {
6
- const { meta } = (0, _kubb_react_fabric.useApp)();
6
+ const { meta } = (0, _kubb_react_fabric.useFabric)();
7
+ const defaultPluginName = meta.plugin.name;
7
8
  return {
8
9
  plugin: meta.plugin,
9
10
  mode: meta.mode,
10
11
  config: meta.pluginManager.config,
11
- getPluginByName: meta.pluginManager.getPluginByName.bind(meta.pluginManager),
12
- getFile: meta.pluginManager.getFile.bind(meta.pluginManager),
13
- resolveName: meta.pluginManager.resolveName.bind(meta.pluginManager),
14
- resolvePath: meta.pluginManager.resolvePath.bind(meta.pluginManager)
12
+ getPluginByName: (pluginName = defaultPluginName) => meta.pluginManager.getPluginByName.call(meta.pluginManager, pluginName),
13
+ getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.getFile.call(meta.pluginManager, {
14
+ pluginName,
15
+ ...rest
16
+ }),
17
+ resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolveName.call(meta.pluginManager, {
18
+ pluginName,
19
+ ...rest
20
+ }),
21
+ resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolvePath.call(meta.pluginManager, {
22
+ pluginName,
23
+ ...rest
24
+ })
15
25
  };
16
26
  }
17
27
  //#endregion
@@ -20,16 +30,16 @@ function useKubb() {
20
30
  * @deprecated use `useKubb` instead
21
31
  */
22
32
  function useMode() {
23
- const { meta } = (0, _kubb_react_fabric.useApp)();
33
+ const { meta } = (0, _kubb_react_fabric.useFabric)();
24
34
  return meta.mode;
25
35
  }
26
36
  //#endregion
27
37
  //#region src/hooks/usePlugin.ts
28
38
  /**
29
- * @deprecated use useApp instead
39
+ * @deprecated use useKubb instead
30
40
  */
31
41
  function usePlugin() {
32
- const { meta } = (0, _kubb_react_fabric.useApp)();
42
+ const { meta } = (0, _kubb_react_fabric.useFabric)();
33
43
  return meta.plugin;
34
44
  }
35
45
  //#endregion
@@ -38,7 +48,7 @@ function usePlugin() {
38
48
  * @deprecated use `useKubb` instead
39
49
  */
40
50
  function usePluginManager() {
41
- const { meta } = (0, _kubb_react_fabric.useApp)();
51
+ const { meta } = (0, _kubb_react_fabric.useFabric)();
42
52
  return meta.pluginManager;
43
53
  }
44
54
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useKubb.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp as useAppBase } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>() {\n const { meta } = useAppBase<{\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n pluginManager: PluginManager\n }>()\n\n return {\n plugin: meta.plugin as Plugin<TOptions>,\n mode: meta.mode,\n config: meta.pluginManager.config,\n getPluginByName: meta.pluginManager.getPluginByName.bind(meta.pluginManager),\n getFile: meta.pluginManager.getFile.bind(meta.pluginManager),\n resolveName: meta.pluginManager.resolveName.bind(meta.pluginManager),\n resolvePath: meta.pluginManager.resolvePath.bind(meta.pluginManager),\n }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use useApp instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;;AAKA,SAAgB,UAAwE;CACtF,MAAM,EAAE,UAAA,GAAA,mBAAA,SAIJ;AAEJ,QAAO;EACL,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,QAAQ,KAAK,cAAc;EAC3B,iBAAiB,KAAK,cAAc,gBAAgB,KAAK,KAAK,cAAc;EAC5E,SAAS,KAAK,cAAc,QAAQ,KAAK,KAAK,cAAc;EAC5D,aAAa,KAAK,cAAc,YAAY,KAAK,KAAK,cAAc;EACpE,aAAa,KAAK,cAAc,YAAY,KAAK,KAAK,cAAc;EACrE;;;;;;;ACdH,SAAgB,UAAyB;CACvC,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA0C;AAElD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,UAAA,GAAA,mBAAA,SAA+C;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,UAAA,GAAA,mBAAA,SAAmD;AAE3D,QAAO,KAAK"}
1
+ {"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useKubb.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\nimport type { GetFileOptions, PluginManager } from '../PluginManager.ts'\nimport type { Config, Plugin, PluginFactoryOptions, ResolveNameParams, ResolvePathParams } from '../types.ts'\n\ntype UseKubbReturn<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n config: Config\n /**\n * Returns the plugin whose `name` matches `pluginName`, defaulting to the current plugin.\n */\n getPluginByName: (pluginName?: string) => Plugin | undefined\n /**\n * Resolves a file reference, defaulting `pluginName` to the current plugin.\n */\n getFile: <TFileOptions = object>(params: Omit<GetFileOptions<TFileOptions>, 'pluginName'> & { pluginName?: string }) => KubbFile.File<{ pluginName: string }>\n /**\n * Resolves a name, defaulting `pluginName` to the current plugin.\n */\n resolveName: (params: Omit<ResolveNameParams, 'pluginName'> & { pluginName?: string }) => string\n /**\n * Resolves a path, defaulting `pluginName` to the current plugin.\n */\n resolvePath: <TPathOptions = object>(params: Omit<ResolvePathParams<TPathOptions>, 'pluginName'> & { pluginName?: string }) => KubbFile.Path\n}\n\nexport function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): UseKubbReturn<TOptions> {\n const { meta } = useFabric<{\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n pluginManager: PluginManager\n }>()\n\n const defaultPluginName = meta.plugin.name\n\n return {\n plugin: meta.plugin as Plugin<TOptions>,\n mode: meta.mode,\n config: meta.pluginManager.config,\n getPluginByName: (pluginName = defaultPluginName) => meta.pluginManager.getPluginByName.call(meta.pluginManager, pluginName),\n getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.getFile.call(meta.pluginManager, { pluginName, ...rest }),\n resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolveName.call(meta.pluginManager, { pluginName, ...rest }),\n resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolvePath.call(meta.pluginManager, { pluginName, ...rest }),\n }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function useMode(): KubbFile.Mode {\n const { meta } = useFabric<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useFabric } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use useKubb instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useFabric<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useFabric } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function usePluginManager(): PluginManager {\n const { meta } = useFabric<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;;AA2BA,SAAgB,UAAiG;CAC/G,MAAM,EAAE,UAAA,GAAA,mBAAA,YAIJ;CAEJ,MAAM,oBAAoB,KAAK,OAAO;AAEtC,QAAO;EACL,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,QAAQ,KAAK,cAAc;EAC3B,kBAAkB,aAAa,sBAAsB,KAAK,cAAc,gBAAgB,KAAK,KAAK,eAAe,WAAW;EAC5H,UAAU,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,cAAc,QAAQ,KAAK,KAAK,eAAe;GAAE;GAAY,GAAG;GAAM,CAAC;EACtI,cAAc,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,cAAc,YAAY,KAAK,KAAK,eAAe;GAAE;GAAY,GAAG;GAAM,CAAC;EAC9I,cAAc,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,cAAc,YAAY,KAAK,KAAK,eAAe;GAAE;GAAY,GAAG;GAAM,CAAC;EAC/I;;;;;;;ACtCH,SAAgB,UAAyB;CACvC,MAAM,EAAE,UAAA,GAAA,mBAAA,YAA6C;AAErD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,UAAA,GAAA,mBAAA,YAAkD;AAE1D,QAAO,KAAK;;;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,UAAA,GAAA,mBAAA,YAAsD;AAE9D,QAAO,KAAK"}
package/dist/hooks.d.ts CHANGED
@@ -1,31 +1,38 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { I as PluginManager, T as ResolvePathParams, _ as PluginFactoryOptions, a as Config, h as Plugin, w as ResolveNameParams } from "./types-Bbh1o0yW.js";
2
+ import { D as ResolveNameParams, O as ResolvePathParams, b as PluginFactoryOptions, c as Config, n as PluginManager, t as GetFileOptions, v as Plugin } from "./PluginManager-vZodFEMe.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
 
5
5
  //#region src/hooks/useKubb.d.ts
6
- declare function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): {
6
+ type UseKubbReturn<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
7
7
  plugin: Plugin<TOptions>;
8
8
  mode: KubbFile.Mode;
9
9
  config: Config;
10
- getPluginByName: (pluginName: string) => Plugin | undefined;
11
- getFile: <TOptions_1 = object>({
12
- name,
13
- mode,
14
- extname,
15
- pluginName,
16
- options
17
- }: {
18
- name: string;
19
- mode?: KubbFile.Mode;
20
- extname: KubbFile.Extname;
21
- pluginName: string;
22
- options?: TOptions_1 | undefined;
10
+ /**
11
+ * Returns the plugin whose `name` matches `pluginName`, defaulting to the current plugin.
12
+ */
13
+ getPluginByName: (pluginName?: string) => Plugin | undefined;
14
+ /**
15
+ * Resolves a file reference, defaulting `pluginName` to the current plugin.
16
+ */
17
+ getFile: <TFileOptions = object>(params: Omit<GetFileOptions<TFileOptions>, 'pluginName'> & {
18
+ pluginName?: string;
23
19
  }) => KubbFile.File<{
24
20
  pluginName: string;
25
21
  }>;
26
- resolveName: (params: ResolveNameParams) => string;
27
- resolvePath: <TOptions_1 = object>(params: ResolvePathParams<TOptions_1>) => KubbFile.Path;
22
+ /**
23
+ * Resolves a name, defaulting `pluginName` to the current plugin.
24
+ */
25
+ resolveName: (params: Omit<ResolveNameParams, 'pluginName'> & {
26
+ pluginName?: string;
27
+ }) => string;
28
+ /**
29
+ * Resolves a path, defaulting `pluginName` to the current plugin.
30
+ */
31
+ resolvePath: <TPathOptions = object>(params: Omit<ResolvePathParams<TPathOptions>, 'pluginName'> & {
32
+ pluginName?: string;
33
+ }) => KubbFile.Path;
28
34
  };
35
+ declare function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): UseKubbReturn<TOptions>;
29
36
  //#endregion
30
37
  //#region src/hooks/useMode.d.ts
31
38
  /**
@@ -35,7 +42,7 @@ declare function useMode(): KubbFile.Mode;
35
42
  //#endregion
36
43
  //#region src/hooks/usePlugin.d.ts
37
44
  /**
38
- * @deprecated use useApp instead
45
+ * @deprecated use useKubb instead
39
46
  */
40
47
  declare function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions>;
41
48
  //#endregion
package/dist/hooks.js CHANGED
@@ -1,16 +1,26 @@
1
1
  import "./chunk--u3MIqq1.js";
2
- import { useApp } from "@kubb/react-fabric";
2
+ import { useFabric } from "@kubb/react-fabric";
3
3
  //#region src/hooks/useKubb.ts
4
4
  function useKubb() {
5
- const { meta } = useApp();
5
+ const { meta } = useFabric();
6
+ const defaultPluginName = meta.plugin.name;
6
7
  return {
7
8
  plugin: meta.plugin,
8
9
  mode: meta.mode,
9
10
  config: meta.pluginManager.config,
10
- getPluginByName: meta.pluginManager.getPluginByName.bind(meta.pluginManager),
11
- getFile: meta.pluginManager.getFile.bind(meta.pluginManager),
12
- resolveName: meta.pluginManager.resolveName.bind(meta.pluginManager),
13
- resolvePath: meta.pluginManager.resolvePath.bind(meta.pluginManager)
11
+ getPluginByName: (pluginName = defaultPluginName) => meta.pluginManager.getPluginByName.call(meta.pluginManager, pluginName),
12
+ getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.getFile.call(meta.pluginManager, {
13
+ pluginName,
14
+ ...rest
15
+ }),
16
+ resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolveName.call(meta.pluginManager, {
17
+ pluginName,
18
+ ...rest
19
+ }),
20
+ resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolvePath.call(meta.pluginManager, {
21
+ pluginName,
22
+ ...rest
23
+ })
14
24
  };
15
25
  }
16
26
  //#endregion
@@ -19,16 +29,16 @@ function useKubb() {
19
29
  * @deprecated use `useKubb` instead
20
30
  */
21
31
  function useMode() {
22
- const { meta } = useApp();
32
+ const { meta } = useFabric();
23
33
  return meta.mode;
24
34
  }
25
35
  //#endregion
26
36
  //#region src/hooks/usePlugin.ts
27
37
  /**
28
- * @deprecated use useApp instead
38
+ * @deprecated use useKubb instead
29
39
  */
30
40
  function usePlugin() {
31
- const { meta } = useApp();
41
+ const { meta } = useFabric();
32
42
  return meta.plugin;
33
43
  }
34
44
  //#endregion
@@ -37,7 +47,7 @@ function usePlugin() {
37
47
  * @deprecated use `useKubb` instead
38
48
  */
39
49
  function usePluginManager() {
40
- const { meta } = useApp();
50
+ const { meta } = useFabric();
41
51
  return meta.pluginManager;
42
52
  }
43
53
  //#endregion
package/dist/hooks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","names":["useAppBase"],"sources":["../src/hooks/useKubb.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp as useAppBase } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\nexport function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>() {\n const { meta } = useAppBase<{\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n pluginManager: PluginManager\n }>()\n\n return {\n plugin: meta.plugin as Plugin<TOptions>,\n mode: meta.mode,\n config: meta.pluginManager.config,\n getPluginByName: meta.pluginManager.getPluginByName.bind(meta.pluginManager),\n getFile: meta.pluginManager.getFile.bind(meta.pluginManager),\n resolveName: meta.pluginManager.resolveName.bind(meta.pluginManager),\n resolvePath: meta.pluginManager.resolvePath.bind(meta.pluginManager),\n }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useApp } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function useMode(): KubbFile.Mode {\n const { meta } = useApp<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use useApp instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useApp<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useApp } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function usePluginManager(): PluginManager {\n const { meta } = useApp<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;AAKA,SAAgB,UAAwE;CACtF,MAAM,EAAE,SAASA,QAIb;AAEJ,QAAO;EACL,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,QAAQ,KAAK,cAAc;EAC3B,iBAAiB,KAAK,cAAc,gBAAgB,KAAK,KAAK,cAAc;EAC5E,SAAS,KAAK,cAAc,QAAQ,KAAK,KAAK,cAAc;EAC5D,aAAa,KAAK,cAAc,YAAY,KAAK,KAAK,cAAc;EACpE,aAAa,KAAK,cAAc,YAAY,KAAK,KAAK,cAAc;EACrE;;;;;;;ACdH,SAAgB,UAAyB;CACvC,MAAM,EAAE,SAAS,QAAiC;AAElD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,QAAsC;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,SAAS,QAA0C;AAE3D,QAAO,KAAK"}
1
+ {"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useKubb.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts","../src/hooks/usePluginManager.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\nimport type { GetFileOptions, PluginManager } from '../PluginManager.ts'\nimport type { Config, Plugin, PluginFactoryOptions, ResolveNameParams, ResolvePathParams } from '../types.ts'\n\ntype UseKubbReturn<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n config: Config\n /**\n * Returns the plugin whose `name` matches `pluginName`, defaulting to the current plugin.\n */\n getPluginByName: (pluginName?: string) => Plugin | undefined\n /**\n * Resolves a file reference, defaulting `pluginName` to the current plugin.\n */\n getFile: <TFileOptions = object>(params: Omit<GetFileOptions<TFileOptions>, 'pluginName'> & { pluginName?: string }) => KubbFile.File<{ pluginName: string }>\n /**\n * Resolves a name, defaulting `pluginName` to the current plugin.\n */\n resolveName: (params: Omit<ResolveNameParams, 'pluginName'> & { pluginName?: string }) => string\n /**\n * Resolves a path, defaulting `pluginName` to the current plugin.\n */\n resolvePath: <TPathOptions = object>(params: Omit<ResolvePathParams<TPathOptions>, 'pluginName'> & { pluginName?: string }) => KubbFile.Path\n}\n\nexport function useKubb<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): UseKubbReturn<TOptions> {\n const { meta } = useFabric<{\n plugin: Plugin<TOptions>\n mode: KubbFile.Mode\n pluginManager: PluginManager\n }>()\n\n const defaultPluginName = meta.plugin.name\n\n return {\n plugin: meta.plugin as Plugin<TOptions>,\n mode: meta.mode,\n config: meta.pluginManager.config,\n getPluginByName: (pluginName = defaultPluginName) => meta.pluginManager.getPluginByName.call(meta.pluginManager, pluginName),\n getFile: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.getFile.call(meta.pluginManager, { pluginName, ...rest }),\n resolveName: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolveName.call(meta.pluginManager, { pluginName, ...rest }),\n resolvePath: ({ pluginName = defaultPluginName, ...rest }) => meta.pluginManager.resolvePath.call(meta.pluginManager, { pluginName, ...rest }),\n }\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function useMode(): KubbFile.Mode {\n const { meta } = useFabric<{ mode: KubbFile.Mode }>()\n\n return meta.mode\n}\n","import { useFabric } from '@kubb/react-fabric'\nimport type { Plugin, PluginFactoryOptions } from '../types.ts'\n\n/**\n * @deprecated use useKubb instead\n */\nexport function usePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(): Plugin<TOptions> {\n const { meta } = useFabric<{ plugin: Plugin<TOptions> }>()\n\n return meta.plugin\n}\n","import { useFabric } from '@kubb/react-fabric'\nimport type { PluginManager } from '../PluginManager.ts'\n\n/**\n * @deprecated use `useKubb` instead\n */\nexport function usePluginManager(): PluginManager {\n const { meta } = useFabric<{ pluginManager: PluginManager }>()\n\n return meta.pluginManager\n}\n"],"mappings":";;;AA2BA,SAAgB,UAAiG;CAC/G,MAAM,EAAE,SAAS,WAIb;CAEJ,MAAM,oBAAoB,KAAK,OAAO;AAEtC,QAAO;EACL,QAAQ,KAAK;EACb,MAAM,KAAK;EACX,QAAQ,KAAK,cAAc;EAC3B,kBAAkB,aAAa,sBAAsB,KAAK,cAAc,gBAAgB,KAAK,KAAK,eAAe,WAAW;EAC5H,UAAU,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,cAAc,QAAQ,KAAK,KAAK,eAAe;GAAE;GAAY,GAAG;GAAM,CAAC;EACtI,cAAc,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,cAAc,YAAY,KAAK,KAAK,eAAe;GAAE;GAAY,GAAG;GAAM,CAAC;EAC9I,cAAc,EAAE,aAAa,mBAAmB,GAAG,WAAW,KAAK,cAAc,YAAY,KAAK,KAAK,eAAe;GAAE;GAAY,GAAG;GAAM,CAAC;EAC/I;;;;;;;ACtCH,SAAgB,UAAyB;CACvC,MAAM,EAAE,SAAS,WAAoC;AAErD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,WAAyC;AAE1D,QAAO,KAAK;;;;;;;ACHd,SAAgB,mBAAkC;CAChD,MAAM,EAAE,SAAS,WAA6C;AAE9D,QAAO,KAAK"}
package/dist/index.cjs CHANGED
@@ -1464,7 +1464,7 @@ const fsStorage = defineStorage(() => ({
1464
1464
  }));
1465
1465
  //#endregion
1466
1466
  //#region package.json
1467
- var version = "5.0.0-alpha.4";
1467
+ var version = "5.0.0-alpha.5";
1468
1468
  //#endregion
1469
1469
  //#region src/utils/diagnostics.ts
1470
1470
  /**