@kubb/core 5.0.0-alpha.21 → 5.0.0-alpha.23
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-P920mak9.d.ts} +135 -54
- package/dist/hooks.cjs +3 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +6 -3
- package/dist/hooks.js +3 -0
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +135 -228
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -69
- package/dist/index.js +136 -227
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Kubb.ts +5 -5
- package/src/PluginDriver.ts +110 -154
- package/src/build.ts +11 -11
- package/src/constants.ts +2 -12
- package/src/defineGenerator.ts +29 -7
- package/src/defineResolver.ts +13 -19
- package/src/hooks/useDriver.ts +3 -0
- package/src/hooks/useMode.ts +3 -3
- package/src/index.ts +0 -2
- package/src/renderNode.tsx +9 -6
- package/src/types.ts +67 -35
- package/src/utils/TreeNode.ts +22 -7
- package/src/utils/getBarrelFiles.ts +9 -6
- package/src/utils/getConfigs.ts +1 -1
- package/src/utils/getPreset.ts +3 -3
- package/src/utils/mergeResolvers.ts +9 -1
- package/src/defineBuilder.ts +0 -26
- package/src/definePreset.ts +0 -27
|
@@ -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
|
|
|
@@ -219,7 +219,9 @@ type OperationsV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
219
219
|
config: Config;
|
|
220
220
|
plugin: Plugin<TPlugin>;
|
|
221
221
|
adapter: Adapter;
|
|
222
|
+
driver: PluginDriver;
|
|
222
223
|
options: Plugin<TPlugin>['options'];
|
|
224
|
+
resolver: TPlugin['resolver'];
|
|
223
225
|
nodes: Array<OperationNode>;
|
|
224
226
|
};
|
|
225
227
|
/**
|
|
@@ -228,8 +230,10 @@ type OperationsV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
228
230
|
type OperationV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
229
231
|
config: Config;
|
|
230
232
|
adapter: Adapter;
|
|
233
|
+
driver: PluginDriver;
|
|
231
234
|
plugin: Plugin<TPlugin>;
|
|
232
235
|
options: Plugin<TPlugin>['options'];
|
|
236
|
+
resolver: TPlugin['resolver'];
|
|
233
237
|
node: OperationNode;
|
|
234
238
|
};
|
|
235
239
|
/**
|
|
@@ -238,18 +242,26 @@ type OperationV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOption
|
|
|
238
242
|
type SchemaV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
239
243
|
config: Config;
|
|
240
244
|
adapter: Adapter;
|
|
245
|
+
driver: PluginDriver;
|
|
241
246
|
plugin: Plugin<TPlugin>;
|
|
242
247
|
options: Plugin<TPlugin>['options'];
|
|
248
|
+
resolver: TPlugin['resolver'];
|
|
243
249
|
node: SchemaNode;
|
|
244
250
|
};
|
|
251
|
+
/**
|
|
252
|
+
* Input shape for a core v2 async generator — lifecycle methods are optional.
|
|
253
|
+
*/
|
|
245
254
|
type UserCoreGeneratorV2<TPlugin extends PluginFactoryOptions> = {
|
|
246
255
|
name: string;
|
|
247
256
|
type: 'core';
|
|
248
257
|
version?: '2';
|
|
249
|
-
operations?(props: OperationsV2Props<TPlugin>): Promise<Array<
|
|
250
|
-
operation?(props: OperationV2Props<TPlugin>): Promise<Array<
|
|
251
|
-
schema?(props: SchemaV2Props<TPlugin>): Promise<Array<
|
|
258
|
+
operations?(props: OperationsV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
259
|
+
operation?(props: OperationV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
260
|
+
schema?(props: SchemaV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
252
261
|
};
|
|
262
|
+
/**
|
|
263
|
+
* Input shape for a React v2 generator — component methods are optional.
|
|
264
|
+
*/
|
|
253
265
|
type UserReactGeneratorV2<TPlugin extends PluginFactoryOptions> = {
|
|
254
266
|
name: string;
|
|
255
267
|
type: 'react';
|
|
@@ -258,14 +270,20 @@ type UserReactGeneratorV2<TPlugin extends PluginFactoryOptions> = {
|
|
|
258
270
|
Operation?(props: OperationV2Props<TPlugin>): FabricReactNode;
|
|
259
271
|
Schema?(props: SchemaV2Props<TPlugin>): FabricReactNode;
|
|
260
272
|
};
|
|
273
|
+
/**
|
|
274
|
+
* A fully resolved core v2 generator with `version: '2'` and guaranteed async lifecycle methods.
|
|
275
|
+
*/
|
|
261
276
|
type CoreGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
262
277
|
name: string;
|
|
263
278
|
type: 'core';
|
|
264
279
|
version: '2';
|
|
265
|
-
operations(props: OperationsV2Props<TPlugin>): Promise<Array<
|
|
266
|
-
operation(props: OperationV2Props<TPlugin>): Promise<Array<
|
|
267
|
-
schema(props: SchemaV2Props<TPlugin>): Promise<Array<
|
|
280
|
+
operations(props: OperationsV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
281
|
+
operation(props: OperationV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
282
|
+
schema(props: SchemaV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
|
|
268
283
|
};
|
|
284
|
+
/**
|
|
285
|
+
* A fully resolved React v2 generator with `version: '2'` and guaranteed component methods.
|
|
286
|
+
*/
|
|
269
287
|
type ReactGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
270
288
|
name: string;
|
|
271
289
|
type: 'react';
|
|
@@ -274,6 +292,9 @@ type ReactGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOption
|
|
|
274
292
|
Operation(props: OperationV2Props<TPlugin>): FabricReactNode;
|
|
275
293
|
Schema(props: SchemaV2Props<TPlugin>): FabricReactNode;
|
|
276
294
|
};
|
|
295
|
+
/**
|
|
296
|
+
* Union of all v2 generator shapes accepted by the plugin system.
|
|
297
|
+
*/
|
|
277
298
|
type Generator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = UserCoreGeneratorV2<TPlugin> | UserReactGeneratorV2<TPlugin>;
|
|
278
299
|
/**
|
|
279
300
|
* Defines a generator with no-op defaults for any omitted lifecycle methods.
|
|
@@ -368,7 +389,7 @@ interface KubbEvents {
|
|
|
368
389
|
/**
|
|
369
390
|
* Emitted when code generation phase completes.
|
|
370
391
|
*/
|
|
371
|
-
'generation:end': [config: Config, files: Array<
|
|
392
|
+
'generation:end': [config: Config, files: Array<FabricFile.ResolvedFile>, sources: Map<FabricFile.Path, string>];
|
|
372
393
|
/**
|
|
373
394
|
* Emitted with a summary of the generation results.
|
|
374
395
|
* Contains summary lines, title, and success status.
|
|
@@ -455,7 +476,7 @@ interface KubbEvents {
|
|
|
455
476
|
* Emitted when file processing starts.
|
|
456
477
|
* Contains the list of files to be processed.
|
|
457
478
|
*/
|
|
458
|
-
'files:processing:start': [files: Array<
|
|
479
|
+
'files:processing:start': [files: Array<FabricFile.ResolvedFile>];
|
|
459
480
|
/**
|
|
460
481
|
* Emitted for each file being processed, providing progress updates.
|
|
461
482
|
* Contains processed count, total count, percentage, and file details.
|
|
@@ -480,7 +501,7 @@ interface KubbEvents {
|
|
|
480
501
|
/**
|
|
481
502
|
* The file being processed.
|
|
482
503
|
*/
|
|
483
|
-
file:
|
|
504
|
+
file: FabricFile.ResolvedFile;
|
|
484
505
|
/**
|
|
485
506
|
* Kubb configuration (not present in Fabric).
|
|
486
507
|
* Provides access to the current config during file processing.
|
|
@@ -491,7 +512,7 @@ interface KubbEvents {
|
|
|
491
512
|
* Emitted when file processing completes.
|
|
492
513
|
* Contains the list of processed files.
|
|
493
514
|
*/
|
|
494
|
-
'files:processing:end': [files: Array<
|
|
515
|
+
'files:processing:end': [files: Array<FabricFile.ResolvedFile>];
|
|
495
516
|
/**
|
|
496
517
|
* Emitted when a plugin starts executing.
|
|
497
518
|
*/
|
|
@@ -635,7 +656,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
635
656
|
*/
|
|
636
657
|
parse: (source: AdapterSource) => PossiblePromise<RootNode>;
|
|
637
658
|
/**
|
|
638
|
-
* Extracts `
|
|
659
|
+
* Extracts `FabricFile.Import` entries needed by a `SchemaNode` tree.
|
|
639
660
|
* Populated after the first `parse()` call. Returns an empty array before that.
|
|
640
661
|
*
|
|
641
662
|
* The `resolve` callback receives the collision-corrected schema name and must
|
|
@@ -644,7 +665,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
644
665
|
getImports: (node: SchemaNode, resolve: (schemaName: string) => {
|
|
645
666
|
name: string;
|
|
646
667
|
path: string;
|
|
647
|
-
}) => Array<
|
|
668
|
+
}) => Array<FabricFile.Import>;
|
|
648
669
|
};
|
|
649
670
|
type BarrelType = 'all' | 'named' | 'propagate';
|
|
650
671
|
type DevtoolsOptions = {
|
|
@@ -743,7 +764,7 @@ type Config<TInput = Input> = {
|
|
|
743
764
|
* Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
|
|
744
765
|
* @default { '.ts': '.ts'}
|
|
745
766
|
*/
|
|
746
|
-
extension?: Record<
|
|
767
|
+
extension?: Record<FabricFile.Extname, FabricFile.Extname | ''>;
|
|
747
768
|
/**
|
|
748
769
|
* 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
770
|
* @default 'named'
|
|
@@ -770,7 +791,7 @@ type Config<TInput = Input> = {
|
|
|
770
791
|
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
771
792
|
* If a plugin depends on another plugin, an error is returned if the required dependency is missing. See pre for more details.
|
|
772
793
|
*/
|
|
773
|
-
plugins
|
|
794
|
+
plugins: Array<Plugin>;
|
|
774
795
|
/**
|
|
775
796
|
* Devtools configuration for Kubb Studio integration.
|
|
776
797
|
*/
|
|
@@ -792,13 +813,23 @@ type Config<TInput = Input> = {
|
|
|
792
813
|
done?: string | Array<string>;
|
|
793
814
|
};
|
|
794
815
|
};
|
|
816
|
+
/**
|
|
817
|
+
* A type/string-pattern filter used for `include`, `exclude`, and `override` matching.
|
|
818
|
+
*/
|
|
795
819
|
type PatternFilter = {
|
|
796
820
|
type: string;
|
|
797
821
|
pattern: string | RegExp;
|
|
798
822
|
};
|
|
823
|
+
/**
|
|
824
|
+
* A pattern filter paired with partial option overrides to apply when the pattern matches.
|
|
825
|
+
*/
|
|
799
826
|
type PatternOverride<TOptions> = PatternFilter & {
|
|
800
827
|
options: Omit<Partial<TOptions>, 'override'>;
|
|
801
828
|
};
|
|
829
|
+
/**
|
|
830
|
+
* Context passed to `resolver.resolveOptions` to apply include/exclude/override filtering
|
|
831
|
+
* for a given operation or schema node.
|
|
832
|
+
*/
|
|
802
833
|
type ResolveOptionsContext<TOptions> = {
|
|
803
834
|
options: TOptions;
|
|
804
835
|
exclude?: Array<PatternFilter>;
|
|
@@ -825,8 +856,8 @@ type Resolver = {
|
|
|
825
856
|
pluginName: Plugin['name'];
|
|
826
857
|
default(name: ResolveNameParams['name'], type?: ResolveNameParams['type']): string;
|
|
827
858
|
resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null;
|
|
828
|
-
resolvePath(params: ResolverPathParams, context: ResolverContext):
|
|
829
|
-
resolveFile(params: ResolverFileParams, context: ResolverContext):
|
|
859
|
+
resolvePath(params: ResolverPathParams, context: ResolverContext): FabricFile.Path;
|
|
860
|
+
resolveFile(params: ResolverFileParams, context: ResolverContext): FabricFile.File;
|
|
830
861
|
resolveBanner(node: RootNode | null, context: ResolveBannerContext): string | undefined;
|
|
831
862
|
resolveFooter(node: RootNode | null, context: ResolveBannerContext): string | undefined;
|
|
832
863
|
};
|
|
@@ -845,14 +876,6 @@ type Resolver = {
|
|
|
845
876
|
* ```
|
|
846
877
|
*/
|
|
847
878
|
type UserResolver = Omit<Resolver, 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>;
|
|
848
|
-
/**
|
|
849
|
-
* Base type for plugin builder objects.
|
|
850
|
-
* Concrete plugin builder types extend this with their own schema-building helpers.
|
|
851
|
-
* Use `defineBuilder` to define a builder object and export it alongside the plugin.
|
|
852
|
-
*/
|
|
853
|
-
type Builder = {
|
|
854
|
-
name: string;
|
|
855
|
-
};
|
|
856
879
|
type PluginFactoryOptions<
|
|
857
880
|
/**
|
|
858
881
|
* Name to be used for the plugin.
|
|
@@ -878,19 +901,13 @@ TResolvePathOptions extends object = object,
|
|
|
878
901
|
* Resolver object that encapsulates the naming and path-resolution helpers used by this plugin.
|
|
879
902
|
* Use `defineResolver` to define the resolver object and export it alongside the plugin.
|
|
880
903
|
*/
|
|
881
|
-
TResolver extends Resolver = Resolver
|
|
882
|
-
/**
|
|
883
|
-
* Builder object that encapsulates the schema-building helpers used by this plugin.
|
|
884
|
-
* Use `defineBuilder` to define the builder object and export it alongside the plugin.
|
|
885
|
-
*/
|
|
886
|
-
TBuilder extends Builder = Builder> = {
|
|
904
|
+
TResolver extends Resolver = Resolver> = {
|
|
887
905
|
name: TName;
|
|
888
906
|
options: TOptions;
|
|
889
907
|
resolvedOptions: TResolvedOptions;
|
|
890
908
|
context: TContext;
|
|
891
909
|
resolvePathOptions: TResolvePathOptions;
|
|
892
910
|
resolver: TResolver;
|
|
893
|
-
builder: TBuilder;
|
|
894
911
|
};
|
|
895
912
|
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
896
913
|
/**
|
|
@@ -903,6 +920,10 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
903
920
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
904
921
|
*/
|
|
905
922
|
options: TOptions['resolvedOptions'];
|
|
923
|
+
/**
|
|
924
|
+
* The resolver for this plugin, accessible via `driver.getPluginByName(name)?.resolver`.
|
|
925
|
+
*/
|
|
926
|
+
resolver?: TOptions['resolver'];
|
|
906
927
|
/**
|
|
907
928
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin is executed after these plugins.
|
|
908
929
|
* Can be used to validate dependent plugins.
|
|
@@ -935,6 +956,10 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
935
956
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
936
957
|
*/
|
|
937
958
|
options: TOptions['resolvedOptions'];
|
|
959
|
+
/**
|
|
960
|
+
* The resolver for this plugin, accessible via `driver.getPluginByName(name)?.resolver`.
|
|
961
|
+
*/
|
|
962
|
+
resolver: TOptions['resolver'];
|
|
938
963
|
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
939
964
|
/**
|
|
940
965
|
* Defines a context that can be used by other plugins, see `PluginDriver` where we convert from `UserPlugin` to `Plugin` (used when calling `createPlugin`).
|
|
@@ -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
|
*/
|
|
@@ -993,20 +1018,24 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
993
1018
|
fabric: Fabric;
|
|
994
1019
|
config: Config;
|
|
995
1020
|
driver: PluginDriver;
|
|
1021
|
+
getPlugin: PluginDriver['getPlugin'];
|
|
996
1022
|
/**
|
|
997
1023
|
* Only add when the file does not exist yet
|
|
998
1024
|
*/
|
|
999
|
-
addFile: (...file: Array<
|
|
1025
|
+
addFile: (...file: Array<FabricFile.File>) => Promise<void>;
|
|
1000
1026
|
/**
|
|
1001
1027
|
* merging multiple sources into the same output file
|
|
1002
1028
|
*/
|
|
1003
|
-
upsertFile: (...file: Array<
|
|
1029
|
+
upsertFile: (...file: Array<FabricFile.File>) => Promise<void>;
|
|
1004
1030
|
events: AsyncEventEmitter<KubbEvents>;
|
|
1005
|
-
mode: KubbFile.Mode;
|
|
1006
1031
|
/**
|
|
1007
1032
|
* Current plugin
|
|
1008
1033
|
*/
|
|
1009
1034
|
plugin: Plugin<TOptions>;
|
|
1035
|
+
/**
|
|
1036
|
+
* Resolver for the current plugin. Shorthand for `plugin.resolver`.
|
|
1037
|
+
*/
|
|
1038
|
+
resolver: TOptions['resolver'];
|
|
1010
1039
|
/**
|
|
1011
1040
|
* Opens the Kubb Studio URL for the current `rootNode` in the default browser.
|
|
1012
1041
|
* Falls back to printing the URL if the browser cannot be launched.
|
|
@@ -1054,7 +1083,7 @@ type Output<_TOptions = unknown> = {
|
|
|
1054
1083
|
*/
|
|
1055
1084
|
override?: boolean;
|
|
1056
1085
|
};
|
|
1057
|
-
type
|
|
1086
|
+
type UserGroup = {
|
|
1058
1087
|
/**
|
|
1059
1088
|
* Defines the type where to group the files.
|
|
1060
1089
|
* - 'tag' groups files by OpenAPI tags.
|
|
@@ -1069,6 +1098,21 @@ type Group = {
|
|
|
1069
1098
|
group: string;
|
|
1070
1099
|
}) => string;
|
|
1071
1100
|
};
|
|
1101
|
+
type Group = {
|
|
1102
|
+
/**
|
|
1103
|
+
* Defines the type where to group the files.
|
|
1104
|
+
* - 'tag' groups files by OpenAPI tags.
|
|
1105
|
+
* - 'path' groups files by OpenAPI paths.
|
|
1106
|
+
* @default undefined
|
|
1107
|
+
*/
|
|
1108
|
+
type: 'tag' | 'path';
|
|
1109
|
+
/**
|
|
1110
|
+
* Return the name of a group based on the group name, this is used for the file and name generation.
|
|
1111
|
+
*/
|
|
1112
|
+
name: (context: {
|
|
1113
|
+
group: string;
|
|
1114
|
+
}) => string;
|
|
1115
|
+
};
|
|
1072
1116
|
type LoggerOptions = {
|
|
1073
1117
|
/**
|
|
1074
1118
|
* @default 3
|
|
@@ -1175,8 +1219,8 @@ type ResolvePathOptions = {
|
|
|
1175
1219
|
* ```
|
|
1176
1220
|
*/
|
|
1177
1221
|
type ResolverPathParams = {
|
|
1178
|
-
baseName:
|
|
1179
|
-
pathMode?:
|
|
1222
|
+
baseName: FabricFile.BaseName;
|
|
1223
|
+
pathMode?: FabricFile.Mode;
|
|
1180
1224
|
/**
|
|
1181
1225
|
* Tag value used when `group.type === 'tag'`.
|
|
1182
1226
|
*/
|
|
@@ -1204,7 +1248,10 @@ type ResolverPathParams = {
|
|
|
1204
1248
|
type ResolverContext = {
|
|
1205
1249
|
root: string;
|
|
1206
1250
|
output: Output;
|
|
1207
|
-
group?: Group;
|
|
1251
|
+
group?: Group;
|
|
1252
|
+
/**
|
|
1253
|
+
* Plugin name used to populate `meta.pluginName` on the resolved file.
|
|
1254
|
+
*/
|
|
1208
1255
|
pluginName?: string;
|
|
1209
1256
|
};
|
|
1210
1257
|
/**
|
|
@@ -1224,8 +1271,14 @@ type ResolverContext = {
|
|
|
1224
1271
|
*/
|
|
1225
1272
|
type ResolverFileParams = {
|
|
1226
1273
|
name: string;
|
|
1227
|
-
extname:
|
|
1228
|
-
|
|
1274
|
+
extname: FabricFile.Extname;
|
|
1275
|
+
/**
|
|
1276
|
+
* Tag value used when `group.type === 'tag'`.
|
|
1277
|
+
*/
|
|
1278
|
+
tag?: string;
|
|
1279
|
+
/**
|
|
1280
|
+
* Path value used when `group.type === 'path'`.
|
|
1281
|
+
*/
|
|
1229
1282
|
path?: string;
|
|
1230
1283
|
};
|
|
1231
1284
|
/**
|
|
@@ -1247,6 +1300,14 @@ type ResolveBannerContext = {
|
|
|
1247
1300
|
//#endregion
|
|
1248
1301
|
//#region src/PluginDriver.d.ts
|
|
1249
1302
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Hook dispatch strategy used by the `PluginDriver`.
|
|
1305
|
+
*
|
|
1306
|
+
* - `hookFirst` — stops at the first non-null result.
|
|
1307
|
+
* - `hookForPlugin` — calls only the matching plugin.
|
|
1308
|
+
* - `hookParallel` — calls all plugins concurrently.
|
|
1309
|
+
* - `hookSeq` — calls all plugins in order, threading the result.
|
|
1310
|
+
*/
|
|
1250
1311
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
1251
1312
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
1252
1313
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
@@ -1261,14 +1322,26 @@ type Options = {
|
|
|
1261
1322
|
*/
|
|
1262
1323
|
concurrency?: number;
|
|
1263
1324
|
};
|
|
1325
|
+
/**
|
|
1326
|
+
* Parameters accepted by `PluginDriver.getFile` to resolve a generated file descriptor.
|
|
1327
|
+
*/
|
|
1264
1328
|
type GetFileOptions<TOptions = object> = {
|
|
1265
1329
|
name: string;
|
|
1266
|
-
mode?:
|
|
1267
|
-
extname:
|
|
1330
|
+
mode?: FabricFile.Mode;
|
|
1331
|
+
extname: FabricFile.Extname;
|
|
1268
1332
|
pluginName: string;
|
|
1269
1333
|
options?: TOptions;
|
|
1270
1334
|
};
|
|
1271
|
-
|
|
1335
|
+
/**
|
|
1336
|
+
* Returns `'single'` when `fileOrFolder` has a file extension, `'split'` otherwise.
|
|
1337
|
+
*
|
|
1338
|
+
* @example
|
|
1339
|
+
* ```ts
|
|
1340
|
+
* getMode('src/gen/types.ts') // 'single'
|
|
1341
|
+
* getMode('src/gen/types') // 'split'
|
|
1342
|
+
* ```
|
|
1343
|
+
*/
|
|
1344
|
+
declare function getMode(fileOrFolder: string | undefined | null): FabricFile.Mode;
|
|
1272
1345
|
declare class PluginDriver {
|
|
1273
1346
|
#private;
|
|
1274
1347
|
readonly config: Config;
|
|
@@ -1279,20 +1352,29 @@ declare class PluginDriver {
|
|
|
1279
1352
|
*/
|
|
1280
1353
|
rootNode: RootNode | undefined;
|
|
1281
1354
|
adapter: Adapter | undefined;
|
|
1355
|
+
readonly plugins: Map<string, Plugin>;
|
|
1282
1356
|
constructor(config: Config, options: Options);
|
|
1283
1357
|
get events(): AsyncEventEmitter<KubbEvents>;
|
|
1284
1358
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, unknown>;
|
|
1285
|
-
|
|
1359
|
+
/**
|
|
1360
|
+
* @deprecated use resolvers context instead
|
|
1361
|
+
*/
|
|
1286
1362
|
getFile<TOptions = object>({
|
|
1287
1363
|
name,
|
|
1288
1364
|
mode,
|
|
1289
1365
|
extname,
|
|
1290
1366
|
pluginName,
|
|
1291
1367
|
options
|
|
1292
|
-
}: GetFileOptions<TOptions>):
|
|
1368
|
+
}: GetFileOptions<TOptions>): FabricFile.File<{
|
|
1293
1369
|
pluginName: string;
|
|
1294
1370
|
}>;
|
|
1295
|
-
|
|
1371
|
+
/**
|
|
1372
|
+
* @deprecated use resolvers context instead
|
|
1373
|
+
*/
|
|
1374
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => FabricFile.Path;
|
|
1375
|
+
/**
|
|
1376
|
+
* @deprecated use resolvers context instead
|
|
1377
|
+
*/
|
|
1296
1378
|
resolveName: (params: ResolveNameParams) => string;
|
|
1297
1379
|
/**
|
|
1298
1380
|
* Run a specific hookName for plugin x.
|
|
@@ -1362,9 +1444,8 @@ declare class PluginDriver {
|
|
|
1362
1444
|
hookName: H;
|
|
1363
1445
|
parameters?: PluginParameter<H>;
|
|
1364
1446
|
}): Promise<void>;
|
|
1365
|
-
|
|
1366
|
-
getPluginsByName(hookName: keyof PluginWithLifeCycle, pluginName: string): Plugin[];
|
|
1447
|
+
getPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions> | undefined;
|
|
1367
1448
|
}
|
|
1368
1449
|
//#endregion
|
|
1369
|
-
export { formatters as $,
|
|
1370
|
-
//# sourceMappingURL=PluginDriver-
|
|
1450
|
+
export { formatters as $, PrinterFactoryOptions as A, UserConfig as B, PluginLifecycle as C, Preset as D, PluginWithLifeCycle as E, ResolvePathParams as F, UserResolver as G, UserLogger as H, Resolver as I, Generator as J, KubbEvents as K, ResolverContext as L, ResolveNameParams as M, ResolveOptionsContext as N, Presets as O, ResolvePathOptions as P, createStorage as Q, ResolverFileParams as R, PluginFactoryOptions as S, PluginParameter as T, UserPlugin as U, UserGroup as V, UserPluginWithLifeCycle as W, defineGenerator as X, ReactGeneratorV2 as Y, Storage as Z, LoggerOptions as _, AdapterSource as a, Plugin as b, Config as c, Group as d, linters as et, Include as f, LoggerContext as g, Logger as h, AdapterFactoryOptions as i, ResolveBannerContext as j, Printer as k, DevtoolsOptions as l, InputPath as m, getMode as n, PossiblePromise as nt, BarrelType as o, InputData as p, CoreGeneratorV2 as q, Adapter as r, AsyncEventEmitter as rt, CompatibilityPreset as s, PluginDriver as t, logLevel as tt, Exclude as u, Output as v, PluginLifecycleHooks as w, PluginContext as x, Override as y, ResolverPathParams as z };
|
|
1451
|
+
//# sourceMappingURL=PluginDriver-P920mak9.d.ts.map
|
package/dist/hooks.cjs
CHANGED
|
@@ -2,6 +2,9 @@ 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
|
+
* @deprecated use `driver` from the generator component props instead
|
|
7
|
+
*/
|
|
5
8
|
function useDriver() {
|
|
6
9
|
const { meta } = (0, _kubb_react_fabric.useFabric)();
|
|
7
10
|
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 * @deprecated use `driver` from the generator component props instead\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":";;;;;;;AAMA,SAAgB,YAA0B;CACxC,MAAM,EAAE,UAAA,GAAA,mBAAA,YAA8C;AAEtD,QAAO,KAAK;;;;;;;ACHd,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,18 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { S as PluginFactoryOptions, b as Plugin, t as PluginDriver } from "./PluginDriver-P920mak9.js";
|
|
3
|
+
import { FabricFile } from "@kubb/fabric-core/types";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useDriver.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use `driver` from the generator component props instead
|
|
8
|
+
*/
|
|
6
9
|
declare function useDriver(): PluginDriver;
|
|
7
10
|
//#endregion
|
|
8
11
|
//#region src/hooks/useMode.d.ts
|
|
9
12
|
/**
|
|
10
13
|
* @deprecated use `mode` from the generator component props instead
|
|
11
14
|
*/
|
|
12
|
-
declare function useMode():
|
|
15
|
+
declare function useMode(): FabricFile.Mode;
|
|
13
16
|
//#endregion
|
|
14
17
|
//#region src/hooks/usePlugin.d.ts
|
|
15
18
|
/**
|
package/dist/hooks.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
2
|
import { useFabric } from "@kubb/react-fabric";
|
|
3
3
|
//#region src/hooks/useDriver.ts
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use `driver` from the generator component props instead
|
|
6
|
+
*/
|
|
4
7
|
function useDriver() {
|
|
5
8
|
const { meta } = useFabric();
|
|
6
9
|
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 * @deprecated use `driver` from the generator component props instead\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":";;;;;;AAMA,SAAgB,YAA0B;CACxC,MAAM,EAAE,SAAS,WAAqC;AAEtD,QAAO,KAAK;;;;;;;ACHd,SAAgB,UAA2B;CACzC,MAAM,EAAE,SAAS,WAAsC;AAEvD,QAAO,KAAK;;;;;;;ACHd,SAAgB,YAA4F;CAC1G,MAAM,EAAE,SAAS,WAAyC;AAE1D,QAAO,KAAK"}
|