@kubb/core 5.0.0-alpha.3 → 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,8 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
2
  import { EventEmitter } from "node:events";
3
- import { Fabric } from "@kubb/react-fabric";
4
- import { Printer, PrinterFactoryOptions, RootNode, SchemaNode } from "@kubb/ast/types";
5
- import { KubbFile } from "@kubb/fabric-core/types";
3
+ import { Fabric, KubbFile } from "@kubb/fabric-core/types";
4
+ import { OperationNode, Printer, PrinterFactoryOptions, RootNode, SchemaNode } from "@kubb/ast/types";
5
+ import { FabricReactNode } from "@kubb/react-fabric/types";
6
6
 
7
7
  //#region ../../internals/utils/dist/index.d.ts
8
8
  /**
@@ -193,127 +193,6 @@ interface DefineStorage {
193
193
  */
194
194
  declare function defineStorage<TOptions = Record<string, never>>(build: (options: TOptions) => DefineStorage): (options?: TOptions) => DefineStorage;
195
195
  //#endregion
196
- //#region src/PluginManager.d.ts
197
- type RequiredPluginLifecycle = Required<PluginLifecycle>;
198
- type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
199
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
200
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
201
- result: Result;
202
- plugin: Plugin;
203
- };
204
- type Options = {
205
- fabric: Fabric;
206
- events: AsyncEventEmitter<KubbEvents>;
207
- /**
208
- * @default Number.POSITIVE_INFINITY
209
- */
210
- concurrency?: number;
211
- };
212
- type GetFileProps<TOptions = object> = {
213
- name: string;
214
- mode?: KubbFile.Mode;
215
- extname: KubbFile.Extname;
216
- pluginName: string;
217
- options?: TOptions;
218
- };
219
- declare function getMode(fileOrFolder: string | undefined | null): KubbFile.Mode;
220
- declare class PluginManager {
221
- #private;
222
- readonly config: Config;
223
- readonly options: Options;
224
- /**
225
- * The universal `@kubb/ast` `RootNode` produced by the adapter, set by
226
- * the build pipeline after the adapter's `parse()` resolves.
227
- */
228
- rootNode: RootNode | undefined;
229
- adapter: Adapter | undefined;
230
- constructor(config: Config, options: Options);
231
- get events(): AsyncEventEmitter<KubbEvents>;
232
- getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, unknown>;
233
- get plugins(): Array<Plugin>;
234
- getFile<TOptions = object>({
235
- name,
236
- mode,
237
- extname,
238
- pluginName,
239
- options
240
- }: GetFileProps<TOptions>): KubbFile.File<{
241
- pluginName: string;
242
- }>;
243
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
244
- resolveName: (params: ResolveNameParams) => string;
245
- /**
246
- * Run a specific hookName for plugin x.
247
- */
248
- hookForPlugin<H extends PluginLifecycleHooks>({
249
- pluginName,
250
- hookName,
251
- parameters
252
- }: {
253
- pluginName: string;
254
- hookName: H;
255
- parameters: PluginParameter<H>;
256
- }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
257
- /**
258
- * Run a specific hookName for plugin x.
259
- */
260
- hookForPluginSync<H extends PluginLifecycleHooks>({
261
- pluginName,
262
- hookName,
263
- parameters
264
- }: {
265
- pluginName: string;
266
- hookName: H;
267
- parameters: PluginParameter<H>;
268
- }): Array<ReturnType<ParseResult<H>>> | null;
269
- /**
270
- * Returns the first non-null result.
271
- */
272
- hookFirst<H extends PluginLifecycleHooks>({
273
- hookName,
274
- parameters,
275
- skipped
276
- }: {
277
- hookName: H;
278
- parameters: PluginParameter<H>;
279
- skipped?: ReadonlySet<Plugin> | null;
280
- }): Promise<SafeParseResult<H>>;
281
- /**
282
- * Returns the first non-null result.
283
- */
284
- hookFirstSync<H extends PluginLifecycleHooks>({
285
- hookName,
286
- parameters,
287
- skipped
288
- }: {
289
- hookName: H;
290
- parameters: PluginParameter<H>;
291
- skipped?: ReadonlySet<Plugin> | null;
292
- }): SafeParseResult<H> | null;
293
- /**
294
- * Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
295
- */
296
- hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
297
- hookName,
298
- parameters
299
- }: {
300
- hookName: H;
301
- parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
302
- }): Promise<Awaited<TOutput>[]>;
303
- /**
304
- * Chains plugins
305
- */
306
- hookSeq<H extends PluginLifecycleHooks>({
307
- hookName,
308
- parameters
309
- }: {
310
- hookName: H;
311
- parameters?: PluginParameter<H>;
312
- }): Promise<void>;
313
- getPluginByName(pluginName: string): Plugin | undefined;
314
- getPluginsByName(hookName: keyof PluginWithLifeCycle, pluginName: string): Plugin[];
315
- }
316
- //#endregion
317
196
  //#region src/Kubb.d.ts
318
197
  type DebugEvent = {
319
198
  date: Date;
@@ -530,6 +409,61 @@ interface KubbEvents {
530
409
  'plugins:hook:processing:end': [meta: ExecutedMeta];
531
410
  }
532
411
  //#endregion
412
+ //#region src/defineGenerator.d.ts
413
+ type OperationsV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
414
+ config: Config;
415
+ adapter: Adapter;
416
+ options: Plugin<TPlugin>['options'];
417
+ nodes: Array<OperationNode>;
418
+ };
419
+ type OperationV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
420
+ config: Config;
421
+ adapter: Adapter;
422
+ options: Plugin<TPlugin>['options'];
423
+ node: OperationNode;
424
+ };
425
+ type SchemaV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
426
+ config: Config;
427
+ adapter: Adapter;
428
+ options: Plugin<TPlugin>['options'];
429
+ node: SchemaNode;
430
+ };
431
+ type UserCoreGeneratorV2<TPlugin extends PluginFactoryOptions> = {
432
+ name: string;
433
+ type: 'core';
434
+ version?: '2';
435
+ operations?(props: OperationsV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
436
+ operation?(props: OperationV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
437
+ schema?(props: SchemaV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
438
+ };
439
+ type UserReactGeneratorV2<TPlugin extends PluginFactoryOptions> = {
440
+ name: string;
441
+ type: 'react';
442
+ version?: '2';
443
+ Operations?(props: OperationsV2Props<TPlugin>): FabricReactNode;
444
+ Operation?(props: OperationV2Props<TPlugin>): FabricReactNode;
445
+ Schema?(props: SchemaV2Props<TPlugin>): FabricReactNode;
446
+ };
447
+ type CoreGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
448
+ name: string;
449
+ type: 'core';
450
+ version: '2';
451
+ operations(props: OperationsV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
452
+ operation(props: OperationV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
453
+ schema(props: SchemaV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
454
+ };
455
+ type ReactGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
456
+ name: string;
457
+ type: 'react';
458
+ version: '2';
459
+ Operations(props: OperationsV2Props<TPlugin>): FabricReactNode;
460
+ Operation(props: OperationV2Props<TPlugin>): FabricReactNode;
461
+ Schema(props: SchemaV2Props<TPlugin>): FabricReactNode;
462
+ };
463
+ type Generator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = UserCoreGeneratorV2<TPlugin> | UserReactGeneratorV2<TPlugin>;
464
+ declare function defineGenerator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>(generator: UserReactGeneratorV2<TPlugin>): ReactGeneratorV2<TPlugin>;
465
+ declare function defineGenerator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>(generator: UserCoreGeneratorV2<TPlugin>): CoreGeneratorV2<TPlugin>;
466
+ //#endregion
533
467
  //#region src/types.d.ts
534
468
  declare global {
535
469
  namespace Kubb {
@@ -997,5 +931,126 @@ type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
997
931
  };
998
932
  type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Omit<Logger<TOptions>, 'logLevel'>;
999
933
  //#endregion
1000
- export { UserPluginWithLifeCycle as A, URLPath as B, PrinterFactoryOptions as C, UserConfig as D, UnknownUserPlugin as E, defineStorage as F, formatters as I, linters as L, PluginManager as M, getMode as N, UserLogger as O, DefineStorage as P, logLevel as R, Printer as S, ResolvePathParams as T, 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, KubbEvents 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, AsyncEventEmitter as z };
1001
- //# sourceMappingURL=types-CiPWLv-5.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 { M as PluginManager, T as ResolvePathParams, _ as PluginFactoryOptions, a as Config, h as Plugin, w as ResolveNameParams } from "./types-CiPWLv-5.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"}