@kubb/core 3.10.6 → 3.10.8
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/{FileManager-D2fUBfwx.d.cts → FileManager-3ug7EyFN.d.cts} +29 -31
- package/dist/{FileManager-B14BOfNb.d.ts → FileManager-Zd55TEM3.d.ts} +29 -31
- package/dist/{chunk-PEVYXGYF.cjs → chunk-4FC3UQ2A.cjs} +49 -47
- package/dist/chunk-4FC3UQ2A.cjs.map +1 -0
- package/dist/chunk-533OTQHD.js +131 -0
- package/dist/chunk-533OTQHD.js.map +1 -0
- package/dist/chunk-56YJEKS3.cjs +155 -0
- package/dist/chunk-56YJEKS3.cjs.map +1 -0
- package/dist/{chunk-4ESUQQVB.js → chunk-7TZ5IOVL.js} +3 -4
- package/dist/chunk-7TZ5IOVL.js.map +1 -0
- package/dist/{chunk-FO6OOIML.cjs → chunk-ASNFY2P2.cjs} +13 -13
- package/dist/chunk-ASNFY2P2.cjs.map +1 -0
- package/dist/{chunk-NGF5XEJP.cjs → chunk-GGXWIE3Q.cjs} +4 -4
- package/dist/{chunk-NGF5XEJP.cjs.map → chunk-GGXWIE3Q.cjs.map} +1 -1
- package/dist/{chunk-XICDTA6N.js → chunk-IMO6IX7W.js} +5 -3
- package/dist/chunk-IMO6IX7W.js.map +1 -0
- package/dist/{chunk-5UFNQWFW.cjs → chunk-XFTBW3ZJ.cjs} +17 -17
- package/dist/{chunk-5UFNQWFW.cjs.map → chunk-XFTBW3ZJ.cjs.map} +1 -1
- package/dist/fs.cjs +37 -0
- package/dist/fs.cjs.map +1 -0
- package/dist/fs.d.cts +7 -0
- package/dist/fs.d.ts +7 -0
- package/dist/fs.js +3 -0
- package/dist/fs.js.map +1 -0
- package/dist/index.cjs +45 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +7 -6
- package/dist/logger.js +2 -1
- package/dist/mocks.cjs +10 -9
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +2 -3
- package/dist/mocks.d.ts +2 -3
- package/dist/mocks.js +2 -1
- package/dist/mocks.js.map +1 -1
- package/dist/{parser-CYKQRXlL.d.ts → parser--5gRW-zL.d.ts} +8 -8
- package/dist/{parser-fbk23k1t.d.cts → parser-t_YKG02d.d.cts} +8 -8
- package/dist/{prompt-5L3BUBG6.cjs → prompt-SB4H4DMO.cjs} +4 -4
- package/dist/{prompt-5L3BUBG6.cjs.map → prompt-SB4H4DMO.cjs.map} +1 -1
- package/dist/transformers.cjs +22 -22
- package/dist/types-CFmeCPcR.d.cts +147 -0
- package/dist/types-CFmeCPcR.d.ts +147 -0
- package/dist/utils.cjs +19 -18
- package/dist/utils.d.cts +3 -4
- package/dist/utils.d.ts +3 -4
- package/dist/utils.js +2 -1
- package/package.json +15 -5
- package/src/BarrelManager.ts +2 -2
- package/src/FileManager.ts +4 -4
- package/src/PackageManager.ts +1 -1
- package/src/PluginManager.ts +1 -1
- package/src/build.ts +3 -3
- package/src/fs/clean.ts +5 -0
- package/src/fs/index.ts +9 -0
- package/src/fs/read.ts +69 -0
- package/src/fs/types.ts +138 -0
- package/src/fs/write.ts +67 -0
- package/src/logger.ts +1 -1
- package/src/types.ts +1 -1
- package/src/utils/TreeNode.ts +1 -1
- package/src/utils/parser.ts +2 -2
- package/dist/chunk-4ESUQQVB.js.map +0 -1
- package/dist/chunk-FO6OOIML.cjs.map +0 -1
- package/dist/chunk-PEVYXGYF.cjs.map +0 -1
- package/dist/chunk-XICDTA6N.js.map +0 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { write, read } from '
|
|
2
|
-
import * as KubbFile from '@kubb/fs/types';
|
|
3
|
-
import { ResolvedFile } from '@kubb/fs/types';
|
|
1
|
+
import { M as Mode, E as Extname, F as File, O as OptionalPath, B as BaseName, R as ResolvedFile, P as Path, w as write, r as read } from './types-CFmeCPcR.cjs';
|
|
4
2
|
import { E as EventEmitter, L as Logger } from './logger-BWq-oJU_.cjs';
|
|
5
3
|
|
|
6
4
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -32,8 +30,8 @@ type Events = {
|
|
|
32
30
|
};
|
|
33
31
|
type GetFileProps<TOptions = object> = {
|
|
34
32
|
name: string;
|
|
35
|
-
mode?:
|
|
36
|
-
extname:
|
|
33
|
+
mode?: Mode;
|
|
34
|
+
extname: Extname;
|
|
37
35
|
pluginKey: Plugin['key'];
|
|
38
36
|
options?: TOptions;
|
|
39
37
|
};
|
|
@@ -47,10 +45,10 @@ declare class PluginManager {
|
|
|
47
45
|
readonly logger: Logger;
|
|
48
46
|
readonly options: Options;
|
|
49
47
|
constructor(config: Config, options: Options);
|
|
50
|
-
getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>):
|
|
48
|
+
getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): File<{
|
|
51
49
|
pluginKey: Plugin['key'];
|
|
52
50
|
}>;
|
|
53
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) =>
|
|
51
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
54
52
|
resolveName: (params: ResolveNameParams) => string;
|
|
55
53
|
/**
|
|
56
54
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -184,7 +182,7 @@ type Config<TInput = Input> = {
|
|
|
184
182
|
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
185
183
|
* @default { '.ts': '.ts'}
|
|
186
184
|
*/
|
|
187
|
-
extension?: Record<
|
|
185
|
+
extension?: Record<Extname, Extname | ''>;
|
|
188
186
|
/**
|
|
189
187
|
* Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
|
|
190
188
|
* @default 'named'
|
|
@@ -317,7 +315,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
317
315
|
* @type hookFirst
|
|
318
316
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
319
317
|
*/
|
|
320
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName:
|
|
318
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
321
319
|
/**
|
|
322
320
|
* Resolve to a name based on a string.
|
|
323
321
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -335,8 +333,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
|
335
333
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
336
334
|
type ResolvePathParams<TOptions = object> = {
|
|
337
335
|
pluginKey?: Plugin['key'];
|
|
338
|
-
baseName:
|
|
339
|
-
mode?:
|
|
336
|
+
baseName: BaseName;
|
|
337
|
+
mode?: Mode;
|
|
340
338
|
/**
|
|
341
339
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
342
340
|
*/
|
|
@@ -357,8 +355,8 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
357
355
|
config: Config;
|
|
358
356
|
fileManager: FileManager;
|
|
359
357
|
pluginManager: PluginManager;
|
|
360
|
-
addFile: (...file: Array<
|
|
361
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) =>
|
|
358
|
+
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
359
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
362
360
|
resolveName: (params: ResolveNameParams) => string;
|
|
363
361
|
logger: Logger;
|
|
364
362
|
/**
|
|
@@ -407,11 +405,11 @@ type Group = {
|
|
|
407
405
|
};
|
|
408
406
|
|
|
409
407
|
type BarrelData = {
|
|
410
|
-
file?:
|
|
408
|
+
file?: File;
|
|
411
409
|
/**
|
|
412
410
|
* @deprecated use file instead
|
|
413
411
|
*/
|
|
414
|
-
type:
|
|
412
|
+
type: Mode;
|
|
415
413
|
path: string;
|
|
416
414
|
name: string;
|
|
417
415
|
};
|
|
@@ -429,26 +427,26 @@ declare class TreeNode {
|
|
|
429
427
|
forEachDeep(callback: (treeNode: TreeNode) => void): void;
|
|
430
428
|
filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode>;
|
|
431
429
|
mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T>;
|
|
432
|
-
static build(files:
|
|
430
|
+
static build(files: File[], root?: string): TreeNode | null;
|
|
433
431
|
}
|
|
434
432
|
type DirectoryTree = {
|
|
435
433
|
name: string;
|
|
436
434
|
path: string;
|
|
437
|
-
file?:
|
|
435
|
+
file?: File;
|
|
438
436
|
children: Array<DirectoryTree>;
|
|
439
437
|
};
|
|
440
438
|
|
|
441
439
|
type FileMetaBase = {
|
|
442
440
|
pluginKey?: Plugin['key'];
|
|
443
441
|
};
|
|
444
|
-
type AddResult<T extends Array<
|
|
442
|
+
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
445
443
|
type AddIndexesProps = {
|
|
446
444
|
type: BarrelType | false | undefined;
|
|
447
445
|
/**
|
|
448
446
|
* Root based on root and output.path specified in the config
|
|
449
447
|
*/
|
|
450
448
|
root: string;
|
|
451
|
-
files:
|
|
449
|
+
files: File[];
|
|
452
450
|
/**
|
|
453
451
|
* Output for plugin
|
|
454
452
|
*/
|
|
@@ -465,32 +463,32 @@ type AddIndexesProps = {
|
|
|
465
463
|
declare class FileManager {
|
|
466
464
|
#private;
|
|
467
465
|
constructor();
|
|
468
|
-
get files(): Array<
|
|
469
|
-
get orderedFiles(): Array<
|
|
466
|
+
get files(): Array<ResolvedFile>;
|
|
467
|
+
get orderedFiles(): Array<ResolvedFile>;
|
|
470
468
|
get groupedFiles(): DirectoryTree | null;
|
|
471
469
|
get treeNode(): TreeNode | null;
|
|
472
|
-
add<T extends Array<
|
|
470
|
+
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
473
471
|
clear(): void;
|
|
474
|
-
getCacheById(id: string):
|
|
475
|
-
getByPath(path:
|
|
476
|
-
deleteByPath(path:
|
|
477
|
-
getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<
|
|
472
|
+
getCacheById(id: string): File | undefined;
|
|
473
|
+
getByPath(path: Path): ResolvedFile | undefined;
|
|
474
|
+
deleteByPath(path: Path): void;
|
|
475
|
+
getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<File[]>;
|
|
478
476
|
write(...params: Parameters<typeof write>): ReturnType<typeof write>;
|
|
479
477
|
read(...params: Parameters<typeof read>): ReturnType<typeof read>;
|
|
480
|
-
static getMode(path: string | undefined | null):
|
|
478
|
+
static getMode(path: string | undefined | null): Mode;
|
|
481
479
|
}
|
|
482
480
|
type GetSourceOptions = {
|
|
483
|
-
extname?:
|
|
481
|
+
extname?: Extname;
|
|
484
482
|
logger?: Logger;
|
|
485
483
|
};
|
|
486
484
|
declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
|
|
487
485
|
type WriteFilesProps = {
|
|
488
486
|
root: Config['root'];
|
|
489
|
-
files: Array<
|
|
490
|
-
extension?: Record<
|
|
487
|
+
files: Array<ResolvedFile>;
|
|
488
|
+
extension?: Record<Extname, Extname | ''>;
|
|
491
489
|
logger?: Logger;
|
|
492
490
|
dryRun?: boolean;
|
|
493
491
|
};
|
|
494
|
-
declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<
|
|
492
|
+
declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<ResolvedFile<object>[]>;
|
|
495
493
|
|
|
496
494
|
export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PossiblePromise as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type PluginContext as o, processFiles as p, type Group as q };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { write, read } from '
|
|
2
|
-
import * as KubbFile from '@kubb/fs/types';
|
|
3
|
-
import { ResolvedFile } from '@kubb/fs/types';
|
|
1
|
+
import { M as Mode, E as Extname, F as File, O as OptionalPath, B as BaseName, R as ResolvedFile, P as Path, w as write, r as read } from './types-CFmeCPcR.js';
|
|
4
2
|
import { E as EventEmitter, L as Logger } from './logger-BWq-oJU_.js';
|
|
5
3
|
|
|
6
4
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -32,8 +30,8 @@ type Events = {
|
|
|
32
30
|
};
|
|
33
31
|
type GetFileProps<TOptions = object> = {
|
|
34
32
|
name: string;
|
|
35
|
-
mode?:
|
|
36
|
-
extname:
|
|
33
|
+
mode?: Mode;
|
|
34
|
+
extname: Extname;
|
|
37
35
|
pluginKey: Plugin['key'];
|
|
38
36
|
options?: TOptions;
|
|
39
37
|
};
|
|
@@ -47,10 +45,10 @@ declare class PluginManager {
|
|
|
47
45
|
readonly logger: Logger;
|
|
48
46
|
readonly options: Options;
|
|
49
47
|
constructor(config: Config, options: Options);
|
|
50
|
-
getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>):
|
|
48
|
+
getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): File<{
|
|
51
49
|
pluginKey: Plugin['key'];
|
|
52
50
|
}>;
|
|
53
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) =>
|
|
51
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
54
52
|
resolveName: (params: ResolveNameParams) => string;
|
|
55
53
|
/**
|
|
56
54
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -184,7 +182,7 @@ type Config<TInput = Input> = {
|
|
|
184
182
|
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
185
183
|
* @default { '.ts': '.ts'}
|
|
186
184
|
*/
|
|
187
|
-
extension?: Record<
|
|
185
|
+
extension?: Record<Extname, Extname | ''>;
|
|
188
186
|
/**
|
|
189
187
|
* Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
|
|
190
188
|
* @default 'named'
|
|
@@ -317,7 +315,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
317
315
|
* @type hookFirst
|
|
318
316
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
319
317
|
*/
|
|
320
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName:
|
|
318
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
321
319
|
/**
|
|
322
320
|
* Resolve to a name based on a string.
|
|
323
321
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -335,8 +333,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
|
335
333
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
336
334
|
type ResolvePathParams<TOptions = object> = {
|
|
337
335
|
pluginKey?: Plugin['key'];
|
|
338
|
-
baseName:
|
|
339
|
-
mode?:
|
|
336
|
+
baseName: BaseName;
|
|
337
|
+
mode?: Mode;
|
|
340
338
|
/**
|
|
341
339
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
342
340
|
*/
|
|
@@ -357,8 +355,8 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
357
355
|
config: Config;
|
|
358
356
|
fileManager: FileManager;
|
|
359
357
|
pluginManager: PluginManager;
|
|
360
|
-
addFile: (...file: Array<
|
|
361
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) =>
|
|
358
|
+
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
359
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
362
360
|
resolveName: (params: ResolveNameParams) => string;
|
|
363
361
|
logger: Logger;
|
|
364
362
|
/**
|
|
@@ -407,11 +405,11 @@ type Group = {
|
|
|
407
405
|
};
|
|
408
406
|
|
|
409
407
|
type BarrelData = {
|
|
410
|
-
file?:
|
|
408
|
+
file?: File;
|
|
411
409
|
/**
|
|
412
410
|
* @deprecated use file instead
|
|
413
411
|
*/
|
|
414
|
-
type:
|
|
412
|
+
type: Mode;
|
|
415
413
|
path: string;
|
|
416
414
|
name: string;
|
|
417
415
|
};
|
|
@@ -429,26 +427,26 @@ declare class TreeNode {
|
|
|
429
427
|
forEachDeep(callback: (treeNode: TreeNode) => void): void;
|
|
430
428
|
filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode>;
|
|
431
429
|
mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T>;
|
|
432
|
-
static build(files:
|
|
430
|
+
static build(files: File[], root?: string): TreeNode | null;
|
|
433
431
|
}
|
|
434
432
|
type DirectoryTree = {
|
|
435
433
|
name: string;
|
|
436
434
|
path: string;
|
|
437
|
-
file?:
|
|
435
|
+
file?: File;
|
|
438
436
|
children: Array<DirectoryTree>;
|
|
439
437
|
};
|
|
440
438
|
|
|
441
439
|
type FileMetaBase = {
|
|
442
440
|
pluginKey?: Plugin['key'];
|
|
443
441
|
};
|
|
444
|
-
type AddResult<T extends Array<
|
|
442
|
+
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
445
443
|
type AddIndexesProps = {
|
|
446
444
|
type: BarrelType | false | undefined;
|
|
447
445
|
/**
|
|
448
446
|
* Root based on root and output.path specified in the config
|
|
449
447
|
*/
|
|
450
448
|
root: string;
|
|
451
|
-
files:
|
|
449
|
+
files: File[];
|
|
452
450
|
/**
|
|
453
451
|
* Output for plugin
|
|
454
452
|
*/
|
|
@@ -465,32 +463,32 @@ type AddIndexesProps = {
|
|
|
465
463
|
declare class FileManager {
|
|
466
464
|
#private;
|
|
467
465
|
constructor();
|
|
468
|
-
get files(): Array<
|
|
469
|
-
get orderedFiles(): Array<
|
|
466
|
+
get files(): Array<ResolvedFile>;
|
|
467
|
+
get orderedFiles(): Array<ResolvedFile>;
|
|
470
468
|
get groupedFiles(): DirectoryTree | null;
|
|
471
469
|
get treeNode(): TreeNode | null;
|
|
472
|
-
add<T extends Array<
|
|
470
|
+
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
473
471
|
clear(): void;
|
|
474
|
-
getCacheById(id: string):
|
|
475
|
-
getByPath(path:
|
|
476
|
-
deleteByPath(path:
|
|
477
|
-
getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<
|
|
472
|
+
getCacheById(id: string): File | undefined;
|
|
473
|
+
getByPath(path: Path): ResolvedFile | undefined;
|
|
474
|
+
deleteByPath(path: Path): void;
|
|
475
|
+
getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<File[]>;
|
|
478
476
|
write(...params: Parameters<typeof write>): ReturnType<typeof write>;
|
|
479
477
|
read(...params: Parameters<typeof read>): ReturnType<typeof read>;
|
|
480
|
-
static getMode(path: string | undefined | null):
|
|
478
|
+
static getMode(path: string | undefined | null): Mode;
|
|
481
479
|
}
|
|
482
480
|
type GetSourceOptions = {
|
|
483
|
-
extname?:
|
|
481
|
+
extname?: Extname;
|
|
484
482
|
logger?: Logger;
|
|
485
483
|
};
|
|
486
484
|
declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
|
|
487
485
|
type WriteFilesProps = {
|
|
488
486
|
root: Config['root'];
|
|
489
|
-
files: Array<
|
|
490
|
-
extension?: Record<
|
|
487
|
+
files: Array<ResolvedFile>;
|
|
488
|
+
extension?: Record<Extname, Extname | ''>;
|
|
491
489
|
logger?: Logger;
|
|
492
490
|
dryRun?: boolean;
|
|
493
491
|
};
|
|
494
|
-
declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<
|
|
492
|
+
declare function processFiles({ dryRun, root, extension, logger, files }: WriteFilesProps): Promise<ResolvedFile<object>[]>;
|
|
495
493
|
|
|
496
494
|
export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, PluginManager as P, type ResolvePathParams as R, type UserConfig as U, type PossiblePromise as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n, type PluginContext as o, processFiles as p, type Group as q };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkXFTBW3ZJ_cjs = require('./chunk-XFTBW3ZJ.cjs');
|
|
4
|
+
var chunk56YJEKS3_cjs = require('./chunk-56YJEKS3.cjs');
|
|
5
|
+
var chunkGGXWIE3Q_cjs = require('./chunk-GGXWIE3Q.cjs');
|
|
5
6
|
var path = require('path');
|
|
6
|
-
var fs = require('@kubb/fs');
|
|
7
7
|
var hash = require('object-hash');
|
|
8
8
|
var remeda = require('remeda');
|
|
9
9
|
|
|
@@ -13,9 +13,9 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
13
13
|
var hash__default = /*#__PURE__*/_interopDefault(hash);
|
|
14
14
|
|
|
15
15
|
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js
|
|
16
|
-
var require_eventemitter3 =
|
|
16
|
+
var require_eventemitter3 = chunkGGXWIE3Q_cjs.__commonJS({
|
|
17
17
|
"../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
|
|
18
|
-
|
|
18
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
19
19
|
var has = Object.prototype.hasOwnProperty;
|
|
20
20
|
var prefix = "~";
|
|
21
21
|
function Events() {
|
|
@@ -175,10 +175,10 @@ var require_eventemitter3 = chunkNGF5XEJP_cjs.__commonJS({
|
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
// src/utils/index.ts
|
|
178
|
-
|
|
178
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
179
179
|
|
|
180
180
|
// src/utils/FunctionParams.ts
|
|
181
|
-
|
|
181
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
182
182
|
var FunctionParams = class _FunctionParams {
|
|
183
183
|
#items = [];
|
|
184
184
|
constructor() {
|
|
@@ -199,7 +199,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
199
199
|
return this;
|
|
200
200
|
}
|
|
201
201
|
static #orderItems(items) {
|
|
202
|
-
return
|
|
202
|
+
return chunkXFTBW3ZJ_cjs.orderBy(
|
|
203
203
|
items.filter(Boolean),
|
|
204
204
|
[
|
|
205
205
|
(v) => {
|
|
@@ -227,7 +227,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
227
227
|
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
228
228
|
return acc;
|
|
229
229
|
}
|
|
230
|
-
const parameterName = name.startsWith("{") ? name :
|
|
230
|
+
const parameterName = name.startsWith("{") ? name : chunkXFTBW3ZJ_cjs.camelCase(name);
|
|
231
231
|
if (type) {
|
|
232
232
|
if (required) {
|
|
233
233
|
acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
@@ -282,7 +282,7 @@ var FunctionParams = class _FunctionParams {
|
|
|
282
282
|
};
|
|
283
283
|
|
|
284
284
|
// src/utils/promise.ts
|
|
285
|
-
|
|
285
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
286
286
|
function isPromise(result) {
|
|
287
287
|
return !!result && typeof result?.then === "function";
|
|
288
288
|
}
|
|
@@ -294,7 +294,7 @@ function isPromiseRejectedResult(result) {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
// src/utils/renderTemplate.ts
|
|
297
|
-
|
|
297
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
298
298
|
function renderTemplate(template, data = void 0) {
|
|
299
299
|
if (!data || !Object.keys(data).length) {
|
|
300
300
|
return template.replace(/{{(.*?)}}/g, "");
|
|
@@ -319,7 +319,7 @@ function renderTemplate(template, data = void 0) {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
// src/utils/timeout.ts
|
|
322
|
-
|
|
322
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
323
323
|
async function timeout(ms) {
|
|
324
324
|
return new Promise((resolve) => {
|
|
325
325
|
setTimeout(() => {
|
|
@@ -329,7 +329,7 @@ async function timeout(ms) {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
// src/utils/uniqueName.ts
|
|
332
|
-
|
|
332
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
333
333
|
function getUniqueName(originalName, data) {
|
|
334
334
|
let used = data[originalName] || 0;
|
|
335
335
|
if (used) {
|
|
@@ -350,7 +350,7 @@ function setUniqueName(originalName, data) {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
// src/utils/URLPath.ts
|
|
353
|
-
|
|
353
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
354
354
|
var URLPath = class {
|
|
355
355
|
path;
|
|
356
356
|
#options;
|
|
@@ -421,9 +421,9 @@ var URLPath = class {
|
|
|
421
421
|
if (found) {
|
|
422
422
|
newPath = found.reduce((prev, path2) => {
|
|
423
423
|
const pathWithoutBrackets = path2.replaceAll("{", "").replaceAll("}", "");
|
|
424
|
-
let param =
|
|
424
|
+
let param = chunkXFTBW3ZJ_cjs.isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets : chunkXFTBW3ZJ_cjs.camelCase(pathWithoutBrackets);
|
|
425
425
|
if (this.#options.casing === "camelcase") {
|
|
426
|
-
param =
|
|
426
|
+
param = chunkXFTBW3ZJ_cjs.camelCase(param);
|
|
427
427
|
}
|
|
428
428
|
return prev.replace(path2, `\${${replacer ? replacer(param) : param}}`);
|
|
429
429
|
}, this.path);
|
|
@@ -439,9 +439,9 @@ var URLPath = class {
|
|
|
439
439
|
const params = {};
|
|
440
440
|
found.forEach((item) => {
|
|
441
441
|
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
442
|
-
let param =
|
|
442
|
+
let param = chunkXFTBW3ZJ_cjs.isValidVarName(item) ? item : chunkXFTBW3ZJ_cjs.camelCase(item);
|
|
443
443
|
if (this.#options.casing === "camelcase") {
|
|
444
|
-
param =
|
|
444
|
+
param = chunkXFTBW3ZJ_cjs.camelCase(param);
|
|
445
445
|
}
|
|
446
446
|
const key = replacer ? replacer(param) : param;
|
|
447
447
|
params[key] = key;
|
|
@@ -458,16 +458,16 @@ var URLPath = class {
|
|
|
458
458
|
};
|
|
459
459
|
|
|
460
460
|
// src/utils/parser.ts
|
|
461
|
-
|
|
461
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
462
462
|
|
|
463
463
|
// src/FileManager.ts
|
|
464
|
-
|
|
464
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
465
465
|
|
|
466
466
|
// src/BarrelManager.ts
|
|
467
|
-
|
|
467
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
468
468
|
|
|
469
469
|
// src/utils/TreeNode.ts
|
|
470
|
-
|
|
470
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
471
471
|
var TreeNode = class _TreeNode {
|
|
472
472
|
data;
|
|
473
473
|
parent;
|
|
@@ -622,6 +622,8 @@ function buildDirectoryTree(files, rootFolder = "") {
|
|
|
622
622
|
});
|
|
623
623
|
return root;
|
|
624
624
|
}
|
|
625
|
+
|
|
626
|
+
// src/BarrelManager.ts
|
|
625
627
|
var BarrelManager = class {
|
|
626
628
|
#options;
|
|
627
629
|
constructor(options = {}) {
|
|
@@ -671,7 +673,7 @@ File: ${JSON.stringify(item.data.file, void 0, 2)}`
|
|
|
671
673
|
if (isSubExport) {
|
|
672
674
|
barrelFile.exports.push({
|
|
673
675
|
name: [source.name],
|
|
674
|
-
path:
|
|
676
|
+
path: chunk56YJEKS3_cjs.getRelativePath(treeNode.parent?.data.path, item.data.path),
|
|
675
677
|
isTypeOnly: source.isTypeOnly
|
|
676
678
|
});
|
|
677
679
|
} else {
|
|
@@ -694,13 +696,13 @@ File: ${JSON.stringify(item.data.file, void 0, 2)}`
|
|
|
694
696
|
logger?.emit("debug", {
|
|
695
697
|
date: /* @__PURE__ */ new Date(),
|
|
696
698
|
logs: [
|
|
697
|
-
`Generating barrelFile '${
|
|
699
|
+
`Generating barrelFile '${chunk56YJEKS3_cjs.getRelativePath(root, barrelFile.path)}' for '${chunk56YJEKS3_cjs.getRelativePath(root, treeNode.data?.path)}' with ${barrelFile.sources.length} indexable exports: '${barrelFile.sources?.map((source) => source.name).join(", ")}'`
|
|
698
700
|
]
|
|
699
701
|
});
|
|
700
702
|
logger?.emit("debug", {
|
|
701
703
|
date: /* @__PURE__ */ new Date(),
|
|
702
704
|
logs: [
|
|
703
|
-
`Generated barrelFile '${
|
|
705
|
+
`Generated barrelFile '${chunk56YJEKS3_cjs.getRelativePath(root, barrelFile.path)}' for '${chunk56YJEKS3_cjs.getRelativePath(root, treeNode.data?.path)}' with exports: '${cachedFiles.get(barrelFile.path)?.sources?.map((source) => source.name).join(", ")}'`
|
|
704
706
|
]
|
|
705
707
|
});
|
|
706
708
|
if (previousBarrelFile) {
|
|
@@ -715,14 +717,14 @@ File: ${JSON.stringify(item.data.file, void 0, 2)}`
|
|
|
715
717
|
};
|
|
716
718
|
|
|
717
719
|
// ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/index.js
|
|
718
|
-
|
|
720
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
719
721
|
|
|
720
722
|
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
|
|
721
|
-
|
|
722
|
-
var import_index =
|
|
723
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
724
|
+
var import_index = chunkGGXWIE3Q_cjs.__toESM(require_eventemitter3(), 1);
|
|
723
725
|
|
|
724
726
|
// ../../node_modules/.pnpm/p-timeout@6.1.3/node_modules/p-timeout/index.js
|
|
725
|
-
|
|
727
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
726
728
|
var TimeoutError = class extends Error {
|
|
727
729
|
constructor(message) {
|
|
728
730
|
super(message);
|
|
@@ -811,10 +813,10 @@ function pTimeout(promise, options) {
|
|
|
811
813
|
}
|
|
812
814
|
|
|
813
815
|
// ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/priority-queue.js
|
|
814
|
-
|
|
816
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
815
817
|
|
|
816
818
|
// ../../node_modules/.pnpm/p-queue@8.1.0/node_modules/p-queue/dist/lower-bound.js
|
|
817
|
-
|
|
819
|
+
chunkGGXWIE3Q_cjs.init_cjs_shims();
|
|
818
820
|
function lowerBound(array, value, comparator) {
|
|
819
821
|
let first = 0;
|
|
820
822
|
let count = array.length;
|
|
@@ -1216,13 +1218,13 @@ var FileManager = class {
|
|
|
1216
1218
|
return [...this.#filesByPath.values()];
|
|
1217
1219
|
}
|
|
1218
1220
|
get orderedFiles() {
|
|
1219
|
-
return
|
|
1221
|
+
return chunkXFTBW3ZJ_cjs.orderBy(
|
|
1220
1222
|
[...this.#filesByPath.values()],
|
|
1221
1223
|
[
|
|
1222
1224
|
(v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
|
|
1223
1225
|
(v) => v.path.length,
|
|
1224
|
-
(v) =>
|
|
1225
|
-
(v) =>
|
|
1226
|
+
(v) => chunk56YJEKS3_cjs.trimExtName(v.path).endsWith("index"),
|
|
1227
|
+
(v) => chunk56YJEKS3_cjs.trimExtName(v.baseName),
|
|
1226
1228
|
(v) => v.path.split(".").pop()
|
|
1227
1229
|
]
|
|
1228
1230
|
);
|
|
@@ -1281,7 +1283,7 @@ var FileManager = class {
|
|
|
1281
1283
|
}
|
|
1282
1284
|
const barrelManager = new BarrelManager({ logger });
|
|
1283
1285
|
const pathToBuildFrom = path.join(root, output.path);
|
|
1284
|
-
if (
|
|
1286
|
+
if (chunk56YJEKS3_cjs.trimExtName(pathToBuildFrom).endsWith("index")) {
|
|
1285
1287
|
logger?.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
|
|
1286
1288
|
return [];
|
|
1287
1289
|
}
|
|
@@ -1307,10 +1309,10 @@ var FileManager = class {
|
|
|
1307
1309
|
});
|
|
1308
1310
|
}
|
|
1309
1311
|
async write(...params) {
|
|
1310
|
-
return
|
|
1312
|
+
return chunk56YJEKS3_cjs.write(...params);
|
|
1311
1313
|
}
|
|
1312
1314
|
async read(...params) {
|
|
1313
|
-
return
|
|
1315
|
+
return chunk56YJEKS3_cjs.read(...params);
|
|
1314
1316
|
}
|
|
1315
1317
|
// statics
|
|
1316
1318
|
static getMode(path2) {
|
|
@@ -1357,12 +1359,12 @@ function combineSources(sources) {
|
|
|
1357
1359
|
);
|
|
1358
1360
|
}
|
|
1359
1361
|
function combineExports(exports) {
|
|
1360
|
-
return
|
|
1362
|
+
return chunkXFTBW3ZJ_cjs.orderBy(exports, [
|
|
1361
1363
|
(v) => !!Array.isArray(v.name),
|
|
1362
1364
|
(v) => !v.isTypeOnly,
|
|
1363
1365
|
(v) => v.path,
|
|
1364
1366
|
(v) => !!v.name,
|
|
1365
|
-
(v) => Array.isArray(v.name) ?
|
|
1367
|
+
(v) => Array.isArray(v.name) ? chunkXFTBW3ZJ_cjs.orderBy(v.name) : v.name
|
|
1366
1368
|
]).reduce(
|
|
1367
1369
|
(prev, curr) => {
|
|
1368
1370
|
const name = curr.name;
|
|
@@ -1396,12 +1398,12 @@ function combineExports(exports) {
|
|
|
1396
1398
|
);
|
|
1397
1399
|
}
|
|
1398
1400
|
function combineImports(imports, exports, source) {
|
|
1399
|
-
return
|
|
1401
|
+
return chunkXFTBW3ZJ_cjs.orderBy(imports, [
|
|
1400
1402
|
(v) => !!Array.isArray(v.name),
|
|
1401
1403
|
(v) => !v.isTypeOnly,
|
|
1402
1404
|
(v) => v.path,
|
|
1403
1405
|
(v) => !!v.name,
|
|
1404
|
-
(v) => Array.isArray(v.name) ?
|
|
1406
|
+
(v) => Array.isArray(v.name) ? chunkXFTBW3ZJ_cjs.orderBy(v.name) : v.name
|
|
1405
1407
|
]).reduce(
|
|
1406
1408
|
(prev, curr) => {
|
|
1407
1409
|
let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
|
|
@@ -1452,10 +1454,10 @@ function combineImports(imports, exports, source) {
|
|
|
1452
1454
|
}
|
|
1453
1455
|
var queue = new PQueue({ concurrency: 100 });
|
|
1454
1456
|
async function processFiles({ dryRun, root, extension, logger, files }) {
|
|
1455
|
-
const orderedFiles =
|
|
1457
|
+
const orderedFiles = chunkXFTBW3ZJ_cjs.orderBy(files, [
|
|
1456
1458
|
(v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
|
|
1457
1459
|
(v) => v.path.length,
|
|
1458
|
-
(v) =>
|
|
1460
|
+
(v) => chunk56YJEKS3_cjs.trimExtName(v.path).endsWith("index")
|
|
1459
1461
|
]);
|
|
1460
1462
|
logger?.emit("debug", {
|
|
1461
1463
|
date: /* @__PURE__ */ new Date(),
|
|
@@ -1470,7 +1472,7 @@ async function processFiles({ dryRun, root, extension, logger, files }) {
|
|
|
1470
1472
|
const message = file ? `Writing ${path.relative(root, file.path)}` : "";
|
|
1471
1473
|
const extname2 = extension?.[file.extname] || void 0;
|
|
1472
1474
|
const source = await getSource(file, { logger, extname: extname2 });
|
|
1473
|
-
await
|
|
1475
|
+
await chunk56YJEKS3_cjs.write(file.path, source, { sanity: false });
|
|
1474
1476
|
logger?.emit("progressed", { id: "files", message });
|
|
1475
1477
|
});
|
|
1476
1478
|
});
|
|
@@ -1562,7 +1564,7 @@ var typeScriptParser = createFileParser({
|
|
|
1562
1564
|
const module = await import('@kubb/parser-ts');
|
|
1563
1565
|
const source = file.sources.map((item) => item.value).join("\n\n");
|
|
1564
1566
|
const importNodes = file.imports.map((item) => {
|
|
1565
|
-
const importPath = item.root ?
|
|
1567
|
+
const importPath = item.root ? chunk56YJEKS3_cjs.getRelativePath(item.root, item.path) : item.path;
|
|
1566
1568
|
const hasExtname = !!path__default.default.extname(importPath);
|
|
1567
1569
|
return module.factory.createImportDeclaration({
|
|
1568
1570
|
name: item.name,
|
|
@@ -1640,5 +1642,5 @@ exports.processFiles = processFiles;
|
|
|
1640
1642
|
exports.renderTemplate = renderTemplate;
|
|
1641
1643
|
exports.setUniqueName = setUniqueName;
|
|
1642
1644
|
exports.timeout = timeout;
|
|
1643
|
-
//# sourceMappingURL=chunk-
|
|
1644
|
-
//# sourceMappingURL=chunk-
|
|
1645
|
+
//# sourceMappingURL=chunk-4FC3UQ2A.cjs.map
|
|
1646
|
+
//# sourceMappingURL=chunk-4FC3UQ2A.cjs.map
|