@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,7 +1,7 @@
|
|
|
1
1
|
/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
import { getRelativePath } from '@internals/utils'
|
|
4
|
-
import type {
|
|
4
|
+
import type { FabricFile } from '@kubb/fabric-core/types'
|
|
5
5
|
import type { BarrelType } from '../types.ts'
|
|
6
6
|
import { TreeNode } from './TreeNode.ts'
|
|
7
7
|
|
|
@@ -29,16 +29,16 @@ type AddIndexesProps = {
|
|
|
29
29
|
meta?: FileMetaBase
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function getBarrelFilesByRoot(root: string | undefined, files: Array<
|
|
33
|
-
const cachedFiles = new Map<
|
|
32
|
+
function getBarrelFilesByRoot(root: string | undefined, files: Array<FabricFile.ResolvedFile>): Array<FabricFile.File> {
|
|
33
|
+
const cachedFiles = new Map<FabricFile.Path, FabricFile.File>()
|
|
34
34
|
|
|
35
35
|
TreeNode.build(files, root)?.forEach((treeNode) => {
|
|
36
36
|
if (!treeNode?.children || !treeNode.parent?.data.path) {
|
|
37
37
|
return
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const barrelFilePath = join(treeNode.parent?.data.path, 'index.ts') as
|
|
41
|
-
const barrelFile:
|
|
40
|
+
const barrelFilePath = join(treeNode.parent?.data.path, 'index.ts') as FabricFile.Path
|
|
41
|
+
const barrelFile: FabricFile.File = {
|
|
42
42
|
path: barrelFilePath,
|
|
43
43
|
baseName: 'index.ts',
|
|
44
44
|
exports: [],
|
|
@@ -113,7 +113,10 @@ function trimExtName(text: string): string {
|
|
|
113
113
|
* - When `type` is `'all'`, strips named exports so every re-export becomes a wildcard (`export * from`).
|
|
114
114
|
* - Attaches `meta` to each barrel file for downstream plugin identification.
|
|
115
115
|
*/
|
|
116
|
-
export async function getBarrelFiles(
|
|
116
|
+
export async function getBarrelFiles(
|
|
117
|
+
files: Array<FabricFile.ResolvedFile>,
|
|
118
|
+
{ type, meta = {}, root, output }: AddIndexesProps,
|
|
119
|
+
): Promise<Array<FabricFile.File>> {
|
|
117
120
|
if (!type || type === 'propagate') {
|
|
118
121
|
return []
|
|
119
122
|
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { Resolver } from '../types.ts'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Merges an
|
|
4
|
+
* Merges an ordered list of resolvers into a single resolver by shallow-merging each entry left to right.
|
|
5
|
+
*
|
|
6
|
+
* Later entries win when keys conflict, so the last resolver in the list takes highest precedence.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const resolver = mergeResolvers(resolverTs, resolverTsLegacy)
|
|
11
|
+
* // resolverTsLegacy methods override resolverTs where they overlap
|
|
12
|
+
* ```
|
|
5
13
|
*/
|
|
6
14
|
export function mergeResolvers<T extends Resolver>(...resolvers: Array<T>): T {
|
|
7
15
|
return resolvers.reduce<T>((acc, curr) => ({ ...acc, ...curr }), resolvers[0]!)
|