@kubb/core 5.0.0-alpha.21 → 5.0.0-alpha.22
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/{PluginDriver-CEQPafXV.d.ts → PluginDriver-DZdEyCoa.d.ts} +87 -33
- package/dist/hooks.cjs +5 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +8 -3
- package/dist/hooks.js +5 -0
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -12
- package/dist/index.js +37 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Kubb.ts +5 -5
- package/src/PluginDriver.ts +29 -9
- package/src/build.ts +9 -9
- package/src/constants.ts +2 -2
- package/src/defineGenerator.ts +22 -7
- package/src/defineResolver.ts +13 -10
- package/src/hooks/useDriver.ts +5 -0
- package/src/hooks/useMode.ts +3 -3
- package/src/types.ts +39 -18
- package/src/utils/TreeNode.ts +22 -7
- package/src/utils/getBarrelFiles.ts +9 -6
- package/src/utils/mergeResolvers.ts +9 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { Node, OperationNode, Printer, PrinterFactoryOptions, RootNode, SchemaNode, Visitor } from "@kubb/ast/types";
|
|
3
|
-
import { Fabric,
|
|
3
|
+
import { Fabric, FabricFile } from "@kubb/fabric-core/types";
|
|
4
4
|
import { HttpMethod } from "@kubb/oas";
|
|
5
5
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
6
6
|
|
|
@@ -242,14 +242,20 @@ type SchemaV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
242
242
|
options: Plugin<TPlugin>['options'];
|
|
243
243
|
node: SchemaNode;
|
|
244
244
|
};
|
|
245
|
+
/**
|
|
246
|
+
* Input shape for a core v2 async generator — lifecycle methods are optional.
|
|
247
|
+
*/
|
|
245
248
|
type UserCoreGeneratorV2<TPlugin extends PluginFactoryOptions> = {
|
|
246
249
|
name: string;
|
|
247
250
|
type: 'core';
|
|
248
251
|
version?: '2';
|
|
249
|
-
operations?(props: OperationsV2Props<TPlugin>): Promise<Array<
|
|
250
|
-
operation?(props: OperationV2Props<TPlugin>): Promise<Array<
|
|
251
|
-
schema?(props: SchemaV2Props<TPlugin>): Promise<Array<
|
|
252
|
+
operations?(props: OperationsV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
253
|
+
operation?(props: OperationV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
254
|
+
schema?(props: SchemaV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
252
255
|
};
|
|
256
|
+
/**
|
|
257
|
+
* Input shape for a React v2 generator — component methods are optional.
|
|
258
|
+
*/
|
|
253
259
|
type UserReactGeneratorV2<TPlugin extends PluginFactoryOptions> = {
|
|
254
260
|
name: string;
|
|
255
261
|
type: 'react';
|
|
@@ -258,14 +264,20 @@ type UserReactGeneratorV2<TPlugin extends PluginFactoryOptions> = {
|
|
|
258
264
|
Operation?(props: OperationV2Props<TPlugin>): FabricReactNode;
|
|
259
265
|
Schema?(props: SchemaV2Props<TPlugin>): FabricReactNode;
|
|
260
266
|
};
|
|
267
|
+
/**
|
|
268
|
+
* A fully resolved core v2 generator with `version: '2'` and guaranteed async lifecycle methods.
|
|
269
|
+
*/
|
|
261
270
|
type CoreGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
262
271
|
name: string;
|
|
263
272
|
type: 'core';
|
|
264
273
|
version: '2';
|
|
265
|
-
operations(props: OperationsV2Props<TPlugin>): Promise<Array<
|
|
266
|
-
operation(props: OperationV2Props<TPlugin>): Promise<Array<
|
|
267
|
-
schema(props: SchemaV2Props<TPlugin>): Promise<Array<
|
|
274
|
+
operations(props: OperationsV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
275
|
+
operation(props: OperationV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
276
|
+
schema(props: SchemaV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
268
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* A fully resolved React v2 generator with `version: '2'` and guaranteed component methods.
|
|
280
|
+
*/
|
|
269
281
|
type ReactGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
270
282
|
name: string;
|
|
271
283
|
type: 'react';
|
|
@@ -274,6 +286,9 @@ type ReactGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOption
|
|
|
274
286
|
Operation(props: OperationV2Props<TPlugin>): FabricReactNode;
|
|
275
287
|
Schema(props: SchemaV2Props<TPlugin>): FabricReactNode;
|
|
276
288
|
};
|
|
289
|
+
/**
|
|
290
|
+
* Union of all v2 generator shapes accepted by the plugin system.
|
|
291
|
+
*/
|
|
277
292
|
type Generator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = UserCoreGeneratorV2<TPlugin> | UserReactGeneratorV2<TPlugin>;
|
|
278
293
|
/**
|
|
279
294
|
* Defines a generator with no-op defaults for any omitted lifecycle methods.
|
|
@@ -368,7 +383,7 @@ interface KubbEvents {
|
|
|
368
383
|
/**
|
|
369
384
|
* Emitted when code generation phase completes.
|
|
370
385
|
*/
|
|
371
|
-
'generation:end': [config: Config, files: Array<
|
|
386
|
+
'generation:end': [config: Config, files: Array<FabricFile.ResolvedFile>, sources: Map<FabricFile.Path, string>];
|
|
372
387
|
/**
|
|
373
388
|
* Emitted with a summary of the generation results.
|
|
374
389
|
* Contains summary lines, title, and success status.
|
|
@@ -455,7 +470,7 @@ interface KubbEvents {
|
|
|
455
470
|
* Emitted when file processing starts.
|
|
456
471
|
* Contains the list of files to be processed.
|
|
457
472
|
*/
|
|
458
|
-
'files:processing:start': [files: Array<
|
|
473
|
+
'files:processing:start': [files: Array<FabricFile.ResolvedFile>];
|
|
459
474
|
/**
|
|
460
475
|
* Emitted for each file being processed, providing progress updates.
|
|
461
476
|
* Contains processed count, total count, percentage, and file details.
|
|
@@ -480,7 +495,7 @@ interface KubbEvents {
|
|
|
480
495
|
/**
|
|
481
496
|
* The file being processed.
|
|
482
497
|
*/
|
|
483
|
-
file:
|
|
498
|
+
file: FabricFile.ResolvedFile;
|
|
484
499
|
/**
|
|
485
500
|
* Kubb configuration (not present in Fabric).
|
|
486
501
|
* Provides access to the current config during file processing.
|
|
@@ -491,7 +506,7 @@ interface KubbEvents {
|
|
|
491
506
|
* Emitted when file processing completes.
|
|
492
507
|
* Contains the list of processed files.
|
|
493
508
|
*/
|
|
494
|
-
'files:processing:end': [files: Array<
|
|
509
|
+
'files:processing:end': [files: Array<FabricFile.ResolvedFile>];
|
|
495
510
|
/**
|
|
496
511
|
* Emitted when a plugin starts executing.
|
|
497
512
|
*/
|
|
@@ -635,7 +650,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
635
650
|
*/
|
|
636
651
|
parse: (source: AdapterSource) => PossiblePromise<RootNode>;
|
|
637
652
|
/**
|
|
638
|
-
* Extracts `
|
|
653
|
+
* Extracts `FabricFile.Import` entries needed by a `SchemaNode` tree.
|
|
639
654
|
* Populated after the first `parse()` call. Returns an empty array before that.
|
|
640
655
|
*
|
|
641
656
|
* The `resolve` callback receives the collision-corrected schema name and must
|
|
@@ -644,7 +659,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
644
659
|
getImports: (node: SchemaNode, resolve: (schemaName: string) => {
|
|
645
660
|
name: string;
|
|
646
661
|
path: string;
|
|
647
|
-
}) => Array<
|
|
662
|
+
}) => Array<FabricFile.Import>;
|
|
648
663
|
};
|
|
649
664
|
type BarrelType = 'all' | 'named' | 'propagate';
|
|
650
665
|
type DevtoolsOptions = {
|
|
@@ -743,7 +758,7 @@ type Config<TInput = Input> = {
|
|
|
743
758
|
* Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
|
|
744
759
|
* @default { '.ts': '.ts'}
|
|
745
760
|
*/
|
|
746
|
-
extension?: Record<
|
|
761
|
+
extension?: Record<FabricFile.Extname, FabricFile.Extname | ''>;
|
|
747
762
|
/**
|
|
748
763
|
* Configures how `index.ts` files are created, including disabling barrel file generation. Each plugin has its own `barrelType` option; this setting controls the root barrel file (e.g., `src/gen/index.ts`).
|
|
749
764
|
* @default 'named'
|
|
@@ -792,13 +807,23 @@ type Config<TInput = Input> = {
|
|
|
792
807
|
done?: string | Array<string>;
|
|
793
808
|
};
|
|
794
809
|
};
|
|
810
|
+
/**
|
|
811
|
+
* A type/string-pattern filter used for `include`, `exclude`, and `override` matching.
|
|
812
|
+
*/
|
|
795
813
|
type PatternFilter = {
|
|
796
814
|
type: string;
|
|
797
815
|
pattern: string | RegExp;
|
|
798
816
|
};
|
|
817
|
+
/**
|
|
818
|
+
* A pattern filter paired with partial option overrides to apply when the pattern matches.
|
|
819
|
+
*/
|
|
799
820
|
type PatternOverride<TOptions> = PatternFilter & {
|
|
800
821
|
options: Omit<Partial<TOptions>, 'override'>;
|
|
801
822
|
};
|
|
823
|
+
/**
|
|
824
|
+
* Context passed to `resolver.resolveOptions` to apply include/exclude/override filtering
|
|
825
|
+
* for a given operation or schema node.
|
|
826
|
+
*/
|
|
802
827
|
type ResolveOptionsContext<TOptions> = {
|
|
803
828
|
options: TOptions;
|
|
804
829
|
exclude?: Array<PatternFilter>;
|
|
@@ -825,8 +850,8 @@ type Resolver = {
|
|
|
825
850
|
pluginName: Plugin['name'];
|
|
826
851
|
default(name: ResolveNameParams['name'], type?: ResolveNameParams['type']): string;
|
|
827
852
|
resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null;
|
|
828
|
-
resolvePath(params: ResolverPathParams, context: ResolverContext):
|
|
829
|
-
resolveFile(params: ResolverFileParams, context: ResolverContext):
|
|
853
|
+
resolvePath(params: ResolverPathParams, context: ResolverContext): FabricFile.Path;
|
|
854
|
+
resolveFile(params: ResolverFileParams, context: ResolverContext): FabricFile.File;
|
|
830
855
|
resolveBanner(node: RootNode | null, context: ResolveBannerContext): string | undefined;
|
|
831
856
|
resolveFooter(node: RootNode | null, context: ResolveBannerContext): string | undefined;
|
|
832
857
|
};
|
|
@@ -955,7 +980,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
955
980
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
956
981
|
* @deprecated this will be replaced by resolvers
|
|
957
982
|
*/
|
|
958
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName:
|
|
983
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: FabricFile.BaseName, mode?: FabricFile.Mode, options?: TOptions['resolvePathOptions']) => FabricFile.Path;
|
|
959
984
|
/**
|
|
960
985
|
* Resolve to a name based on a string.
|
|
961
986
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -969,8 +994,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
|
969
994
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
970
995
|
type ResolvePathParams<TOptions = object> = {
|
|
971
996
|
pluginName?: string;
|
|
972
|
-
baseName:
|
|
973
|
-
mode?:
|
|
997
|
+
baseName: FabricFile.BaseName;
|
|
998
|
+
mode?: FabricFile.Mode;
|
|
974
999
|
/**
|
|
975
1000
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
976
1001
|
*/
|
|
@@ -996,13 +1021,13 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
996
1021
|
/**
|
|
997
1022
|
* Only add when the file does not exist yet
|
|
998
1023
|
*/
|
|
999
|
-
addFile: (...file: Array<
|
|
1024
|
+
addFile: (...file: Array<FabricFile.File>) => Promise<void>;
|
|
1000
1025
|
/**
|
|
1001
1026
|
* merging multiple sources into the same output file
|
|
1002
1027
|
*/
|
|
1003
|
-
upsertFile: (...file: Array<
|
|
1028
|
+
upsertFile: (...file: Array<FabricFile.File>) => Promise<void>;
|
|
1004
1029
|
events: AsyncEventEmitter<KubbEvents>;
|
|
1005
|
-
mode:
|
|
1030
|
+
mode: FabricFile.Mode;
|
|
1006
1031
|
/**
|
|
1007
1032
|
* Current plugin
|
|
1008
1033
|
*/
|
|
@@ -1175,8 +1200,8 @@ type ResolvePathOptions = {
|
|
|
1175
1200
|
* ```
|
|
1176
1201
|
*/
|
|
1177
1202
|
type ResolverPathParams = {
|
|
1178
|
-
baseName:
|
|
1179
|
-
pathMode?:
|
|
1203
|
+
baseName: FabricFile.BaseName;
|
|
1204
|
+
pathMode?: FabricFile.Mode;
|
|
1180
1205
|
/**
|
|
1181
1206
|
* Tag value used when `group.type === 'tag'`.
|
|
1182
1207
|
*/
|
|
@@ -1204,7 +1229,10 @@ type ResolverPathParams = {
|
|
|
1204
1229
|
type ResolverContext = {
|
|
1205
1230
|
root: string;
|
|
1206
1231
|
output: Output;
|
|
1207
|
-
group?: Group;
|
|
1232
|
+
group?: Group;
|
|
1233
|
+
/**
|
|
1234
|
+
* Plugin name used to populate `meta.pluginName` on the resolved file.
|
|
1235
|
+
*/
|
|
1208
1236
|
pluginName?: string;
|
|
1209
1237
|
};
|
|
1210
1238
|
/**
|
|
@@ -1224,8 +1252,14 @@ type ResolverContext = {
|
|
|
1224
1252
|
*/
|
|
1225
1253
|
type ResolverFileParams = {
|
|
1226
1254
|
name: string;
|
|
1227
|
-
extname:
|
|
1228
|
-
|
|
1255
|
+
extname: FabricFile.Extname;
|
|
1256
|
+
/**
|
|
1257
|
+
* Tag value used when `group.type === 'tag'`.
|
|
1258
|
+
*/
|
|
1259
|
+
tag?: string;
|
|
1260
|
+
/**
|
|
1261
|
+
* Path value used when `group.type === 'path'`.
|
|
1262
|
+
*/
|
|
1229
1263
|
path?: string;
|
|
1230
1264
|
};
|
|
1231
1265
|
/**
|
|
@@ -1247,6 +1281,14 @@ type ResolveBannerContext = {
|
|
|
1247
1281
|
//#endregion
|
|
1248
1282
|
//#region src/PluginDriver.d.ts
|
|
1249
1283
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Hook dispatch strategy used by the `PluginDriver`.
|
|
1286
|
+
*
|
|
1287
|
+
* - `hookFirst` — stops at the first non-null result.
|
|
1288
|
+
* - `hookForPlugin` — calls only the matching plugin.
|
|
1289
|
+
* - `hookParallel` — calls all plugins concurrently.
|
|
1290
|
+
* - `hookSeq` — calls all plugins in order, threading the result.
|
|
1291
|
+
*/
|
|
1250
1292
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
1251
1293
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
1252
1294
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
@@ -1261,14 +1303,26 @@ type Options = {
|
|
|
1261
1303
|
*/
|
|
1262
1304
|
concurrency?: number;
|
|
1263
1305
|
};
|
|
1306
|
+
/**
|
|
1307
|
+
* Parameters accepted by `PluginDriver.getFile` to resolve a generated file descriptor.
|
|
1308
|
+
*/
|
|
1264
1309
|
type GetFileOptions<TOptions = object> = {
|
|
1265
1310
|
name: string;
|
|
1266
|
-
mode?:
|
|
1267
|
-
extname:
|
|
1311
|
+
mode?: FabricFile.Mode;
|
|
1312
|
+
extname: FabricFile.Extname;
|
|
1268
1313
|
pluginName: string;
|
|
1269
1314
|
options?: TOptions;
|
|
1270
1315
|
};
|
|
1271
|
-
|
|
1316
|
+
/**
|
|
1317
|
+
* Returns `'single'` when `fileOrFolder` has a file extension, `'split'` otherwise.
|
|
1318
|
+
*
|
|
1319
|
+
* @example
|
|
1320
|
+
* ```ts
|
|
1321
|
+
* getMode('src/gen/types.ts') // 'single'
|
|
1322
|
+
* getMode('src/gen/types') // 'split'
|
|
1323
|
+
* ```
|
|
1324
|
+
*/
|
|
1325
|
+
declare function getMode(fileOrFolder: string | undefined | null): FabricFile.Mode;
|
|
1272
1326
|
declare class PluginDriver {
|
|
1273
1327
|
#private;
|
|
1274
1328
|
readonly config: Config;
|
|
@@ -1289,10 +1343,10 @@ declare class PluginDriver {
|
|
|
1289
1343
|
extname,
|
|
1290
1344
|
pluginName,
|
|
1291
1345
|
options
|
|
1292
|
-
}: GetFileOptions<TOptions>):
|
|
1346
|
+
}: GetFileOptions<TOptions>): FabricFile.File<{
|
|
1293
1347
|
pluginName: string;
|
|
1294
1348
|
}>;
|
|
1295
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) =>
|
|
1349
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => FabricFile.Path;
|
|
1296
1350
|
resolveName: (params: ResolveNameParams) => string;
|
|
1297
1351
|
/**
|
|
1298
1352
|
* Run a specific hookName for plugin x.
|
|
@@ -1367,4 +1421,4 @@ declare class PluginDriver {
|
|
|
1367
1421
|
}
|
|
1368
1422
|
//#endregion
|
|
1369
1423
|
export { formatters as $, Printer as A, ResolverPathParams as B, PluginFactoryOptions as C, PluginWithLifeCycle as D, PluginParameter as E, ResolvePathOptions as F, UserResolver as G, UserLogger as H, ResolvePathParams as I, Generator as J, KubbEvents as K, Resolver as L, ResolveBannerContext as M, ResolveNameParams as N, Preset as O, ResolveOptionsContext as P, createStorage as Q, ResolverContext as R, PluginContext as S, PluginLifecycleHooks as T, UserPlugin as U, UserConfig as V, UserPluginWithLifeCycle as W, defineGenerator as X, ReactGeneratorV2 as Y, Storage as Z, LoggerContext as _, AdapterSource as a, Override as b, CompatibilityPreset as c, Exclude as d, linters as et, Group as f, Logger as g, InputPath as h, AdapterFactoryOptions as i, PrinterFactoryOptions as j, Presets as k, Config as l, InputData as m, getMode as n, PossiblePromise as nt, BarrelType as o, Include as p, CoreGeneratorV2 as q, Adapter as r, AsyncEventEmitter as rt, Builder as s, PluginDriver as t, logLevel as tt, DevtoolsOptions as u, LoggerOptions as v, PluginLifecycle as w, Plugin as x, Output as y, ResolverFileParams as z };
|
|
1370
|
-
//# sourceMappingURL=PluginDriver-
|
|
1424
|
+
//# sourceMappingURL=PluginDriver-DZdEyCoa.d.ts.map
|
package/dist/hooks.cjs
CHANGED
|
@@ -2,6 +2,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
require("./chunk-ByKO4r7w.cjs");
|
|
3
3
|
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
4
4
|
//#region src/hooks/useDriver.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns the `PluginDriver` instance from Fabric context.
|
|
7
|
+
*
|
|
8
|
+
* Use this inside React generator components to access the driver, config, and adapter.
|
|
9
|
+
*/
|
|
5
10
|
function useDriver() {
|
|
6
11
|
const { meta } = (0, _kubb_react_fabric.useFabric)();
|
|
7
12
|
return meta.driver;
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\nexport function useDriver(): PluginDriver {\n const { meta } = useFabric<{ driver: PluginDriver }>()\n\n return meta.driver\n}\n","import type {
|
|
1
|
+
{"version":3,"file":"hooks.cjs","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n * Returns the `PluginDriver` instance from Fabric context.\n *\n * Use this inside React generator components to access the driver, config, and adapter.\n */\nexport function useDriver(): PluginDriver {\n const { meta } = useFabric<{ driver: PluginDriver }>()\n\n return meta.driver\n}\n","import type { FabricFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `mode` from the generator component props instead\n */\nexport function useMode(): FabricFile.Mode {\n const { meta } = useFabric<{ mode: FabricFile.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 `plugin` from the generator component props 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"],"mappings":";;;;;;;;;AAQA,SAAgB,YAA0B;CACxC,MAAM,EAAE,UAAA,GAAA,mBAAA,YAA8C;AAEtD,QAAO,KAAK;;;;;;;ACLd,SAAgB,UAA2B;CACzC,MAAM,EAAE,UAAA,GAAA,mBAAA,YAA+C;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,UAAA,GAAA,mBAAA,YAAkD;AAE1D,QAAO,KAAK"}
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { C as PluginFactoryOptions, t as PluginDriver, x as Plugin } from "./PluginDriver-
|
|
3
|
-
import {
|
|
2
|
+
import { C as PluginFactoryOptions, t as PluginDriver, x as Plugin } from "./PluginDriver-DZdEyCoa.js";
|
|
3
|
+
import { FabricFile } from "@kubb/fabric-core/types";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useDriver.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Returns the `PluginDriver` instance from Fabric context.
|
|
8
|
+
*
|
|
9
|
+
* Use this inside React generator components to access the driver, config, and adapter.
|
|
10
|
+
*/
|
|
6
11
|
declare function useDriver(): PluginDriver;
|
|
7
12
|
//#endregion
|
|
8
13
|
//#region src/hooks/useMode.d.ts
|
|
9
14
|
/**
|
|
10
15
|
* @deprecated use `mode` from the generator component props instead
|
|
11
16
|
*/
|
|
12
|
-
declare function useMode():
|
|
17
|
+
declare function useMode(): FabricFile.Mode;
|
|
13
18
|
//#endregion
|
|
14
19
|
//#region src/hooks/usePlugin.d.ts
|
|
15
20
|
/**
|
package/dist/hooks.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
2
|
import { useFabric } from "@kubb/react-fabric";
|
|
3
3
|
//#region src/hooks/useDriver.ts
|
|
4
|
+
/**
|
|
5
|
+
* Returns the `PluginDriver` instance from Fabric context.
|
|
6
|
+
*
|
|
7
|
+
* Use this inside React generator components to access the driver, config, and adapter.
|
|
8
|
+
*/
|
|
4
9
|
function useDriver() {
|
|
5
10
|
const { meta } = useFabric();
|
|
6
11
|
return meta.driver;
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\nexport function useDriver(): PluginDriver {\n const { meta } = useFabric<{ driver: PluginDriver }>()\n\n return meta.driver\n}\n","import type {
|
|
1
|
+
{"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks/useDriver.ts","../src/hooks/useMode.ts","../src/hooks/usePlugin.ts"],"sourcesContent":["import { useFabric } from '@kubb/react-fabric'\nimport type { PluginDriver } from '../PluginDriver.ts'\n\n/**\n * Returns the `PluginDriver` instance from Fabric context.\n *\n * Use this inside React generator components to access the driver, config, and adapter.\n */\nexport function useDriver(): PluginDriver {\n const { meta } = useFabric<{ driver: PluginDriver }>()\n\n return meta.driver\n}\n","import type { FabricFile } from '@kubb/fabric-core/types'\nimport { useFabric } from '@kubb/react-fabric'\n\n/**\n * @deprecated use `mode` from the generator component props instead\n */\nexport function useMode(): FabricFile.Mode {\n const { meta } = useFabric<{ mode: FabricFile.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 `plugin` from the generator component props 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"],"mappings":";;;;;;;;AAQA,SAAgB,YAA0B;CACxC,MAAM,EAAE,SAAS,WAAqC;AAEtD,QAAO,KAAK;;;;;;;ACLd,SAAgB,UAA2B;CACzC,MAAM,EAAE,SAAS,WAAsC;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,WAAyC;AAE1D,QAAO,KAAK"}
|
package/dist/index.cjs
CHANGED
|
@@ -971,6 +971,15 @@ function hookParallel(promises, concurrency = Number.POSITIVE_INFINITY) {
|
|
|
971
971
|
}
|
|
972
972
|
//#endregion
|
|
973
973
|
//#region src/PluginDriver.ts
|
|
974
|
+
/**
|
|
975
|
+
* Returns `'single'` when `fileOrFolder` has a file extension, `'split'` otherwise.
|
|
976
|
+
*
|
|
977
|
+
* @example
|
|
978
|
+
* ```ts
|
|
979
|
+
* getMode('src/gen/types.ts') // 'single'
|
|
980
|
+
* getMode('src/gen/types') // 'split'
|
|
981
|
+
* ```
|
|
982
|
+
*/
|
|
974
983
|
function getMode(fileOrFolder) {
|
|
975
984
|
if (!fileOrFolder) return "split";
|
|
976
985
|
return (0, node_path.extname)(fileOrFolder) ? "single" : "split";
|
|
@@ -1469,7 +1478,7 @@ const fsStorage = createStorage(() => ({
|
|
|
1469
1478
|
}));
|
|
1470
1479
|
//#endregion
|
|
1471
1480
|
//#region package.json
|
|
1472
|
-
var version = "5.0.0-alpha.
|
|
1481
|
+
var version = "5.0.0-alpha.22";
|
|
1473
1482
|
//#endregion
|
|
1474
1483
|
//#region src/utils/diagnostics.ts
|
|
1475
1484
|
/**
|
|
@@ -2110,7 +2119,7 @@ function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root
|
|
|
2110
2119
|
/**
|
|
2111
2120
|
* Default file resolver used by `defineResolver`.
|
|
2112
2121
|
*
|
|
2113
|
-
* Resolves a `
|
|
2122
|
+
* Resolves a `FabricFile.File` by combining name resolution (`resolver.default`) with
|
|
2114
2123
|
* path resolution (`resolver.resolvePath`). The resolved file always has empty
|
|
2115
2124
|
* `sources`, `imports`, and `exports` arrays — consumers populate those separately.
|
|
2116
2125
|
*
|
|
@@ -2246,7 +2255,7 @@ function defaultResolveFooter(node, { output }) {
|
|
|
2246
2255
|
* - `default` — name casing strategy (camelCase / PascalCase)
|
|
2247
2256
|
* - `resolveOptions` — include/exclude/override filtering
|
|
2248
2257
|
* - `resolvePath` — output path computation
|
|
2249
|
-
* - `resolveFile` — full `
|
|
2258
|
+
* - `resolveFile` — full `FabricFile.File` construction
|
|
2250
2259
|
*
|
|
2251
2260
|
* Methods in the builder have access to `this` (the full resolver object), so they
|
|
2252
2261
|
* can call other resolver methods without circular imports.
|
|
@@ -2533,7 +2542,7 @@ async function detectFormatter() {
|
|
|
2533
2542
|
//#region src/utils/TreeNode.ts
|
|
2534
2543
|
/**
|
|
2535
2544
|
* Tree structure used to build per-directory barrel (`index.ts`) files from a
|
|
2536
|
-
* flat list of generated {@link
|
|
2545
|
+
* flat list of generated {@link FabricFile.File} entries.
|
|
2537
2546
|
*
|
|
2538
2547
|
* Each node represents either a directory or a file within the output tree.
|
|
2539
2548
|
* Use {@link TreeNode.build} to construct a root node from a file list, then
|
|
@@ -2575,24 +2584,39 @@ var TreeNode = class TreeNode {
|
|
|
2575
2584
|
this.#cachedLeaves = leaves;
|
|
2576
2585
|
return leaves;
|
|
2577
2586
|
}
|
|
2587
|
+
/**
|
|
2588
|
+
* Visits this node and every descendant in depth-first order.
|
|
2589
|
+
*/
|
|
2578
2590
|
forEach(callback) {
|
|
2579
2591
|
if (typeof callback !== "function") throw new TypeError("forEach() callback must be a function");
|
|
2580
2592
|
callback(this);
|
|
2581
2593
|
for (const child of this.children) child.forEach(callback);
|
|
2582
2594
|
return this;
|
|
2583
2595
|
}
|
|
2596
|
+
/**
|
|
2597
|
+
* Finds the first leaf that satisfies `predicate`, or `undefined` when none match.
|
|
2598
|
+
*/
|
|
2584
2599
|
findDeep(predicate) {
|
|
2585
2600
|
if (typeof predicate !== "function") throw new TypeError("find() predicate must be a function");
|
|
2586
2601
|
return this.leaves.find(predicate);
|
|
2587
2602
|
}
|
|
2603
|
+
/**
|
|
2604
|
+
* Calls `callback` for every leaf of this node.
|
|
2605
|
+
*/
|
|
2588
2606
|
forEachDeep(callback) {
|
|
2589
2607
|
if (typeof callback !== "function") throw new TypeError("forEach() callback must be a function");
|
|
2590
2608
|
this.leaves.forEach(callback);
|
|
2591
2609
|
}
|
|
2610
|
+
/**
|
|
2611
|
+
* Returns all leaves that satisfy `callback`.
|
|
2612
|
+
*/
|
|
2592
2613
|
filterDeep(callback) {
|
|
2593
2614
|
if (typeof callback !== "function") throw new TypeError("filter() callback must be a function");
|
|
2594
2615
|
return this.leaves.filter(callback);
|
|
2595
2616
|
}
|
|
2617
|
+
/**
|
|
2618
|
+
* Maps every leaf through `callback` and returns the resulting array.
|
|
2619
|
+
*/
|
|
2596
2620
|
mapDeep(callback) {
|
|
2597
2621
|
if (typeof callback !== "function") throw new TypeError("map() callback must be a function");
|
|
2598
2622
|
return this.leaves.map(callback);
|
|
@@ -2765,7 +2789,15 @@ async function getConfigs(config, args) {
|
|
|
2765
2789
|
//#endregion
|
|
2766
2790
|
//#region src/utils/mergeResolvers.ts
|
|
2767
2791
|
/**
|
|
2768
|
-
* Merges an
|
|
2792
|
+
* Merges an ordered list of resolvers into a single resolver by shallow-merging each entry left to right.
|
|
2793
|
+
*
|
|
2794
|
+
* Later entries win when keys conflict, so the last resolver in the list takes highest precedence.
|
|
2795
|
+
*
|
|
2796
|
+
* @example
|
|
2797
|
+
* ```ts
|
|
2798
|
+
* const resolver = mergeResolvers(resolverTs, resolverTsLegacy)
|
|
2799
|
+
* // resolverTsLegacy methods override resolverTs where they overlap
|
|
2800
|
+
* ```
|
|
2769
2801
|
*/
|
|
2770
2802
|
function mergeResolvers(...resolvers) {
|
|
2771
2803
|
return resolvers.reduce((acc, curr) => ({
|