@kubb/core 3.16.2 → 3.16.4
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-Dk759iZ3.js +918 -0
- package/dist/FileManager-Dk759iZ3.js.map +1 -0
- package/dist/FileManager-DsRjYJa_.cjs +1031 -0
- package/dist/FileManager-DsRjYJa_.cjs.map +1 -0
- package/dist/PluginManager-1jPxuyQK.d.ts +511 -0
- package/dist/PluginManager-Cvj5AlsU.d.cts +511 -0
- package/dist/chunk-DWy1uDak.cjs +39 -0
- package/dist/chunk-DbvY3SJr.js +33 -0
- package/dist/fs-BacxV1CO.js +87 -0
- package/dist/fs-BacxV1CO.js.map +1 -0
- package/dist/fs-BazSaf2y.cjs +129 -0
- package/dist/fs-BazSaf2y.cjs.map +1 -0
- package/dist/fs.cjs +15 -39
- package/dist/fs.d.cts +2 -19
- package/dist/fs.d.ts +2 -19
- package/dist/fs.js +4 -3
- package/dist/index-BKHQGQVq.d.ts +140 -0
- package/dist/index-BfD6z1P5.d.cts +141 -0
- package/dist/index-Cb4pChs8.d.ts +180 -0
- package/dist/index-D2ptHzfn.d.cts +180 -0
- package/dist/index.cjs +997 -1077
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +107 -89
- package/dist/index.d.ts +107 -89
- package/dist/index.js +1020 -864
- package/dist/index.js.map +1 -1
- package/dist/logger-BxvJpQMX.cjs +1115 -0
- package/dist/logger-BxvJpQMX.cjs.map +1 -0
- package/dist/logger-Cs45J4yy.js +1085 -0
- package/dist/logger-Cs45J4yy.js.map +1 -0
- package/dist/logger-OWS6fqk0.d.cts +69 -0
- package/dist/logger-xcdTETKy.d.ts +69 -0
- package/dist/logger.cjs +6 -24
- package/dist/logger.d.cts +2 -3
- package/dist/logger.d.ts +2 -3
- package/dist/logger.js +4 -4
- package/dist/mocks.cjs +49 -65
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +6 -6
- package/dist/mocks.d.ts +6 -6
- package/dist/mocks.js +48 -59
- package/dist/mocks.js.map +1 -1
- package/dist/prompt-DwEAzq0q.js +853 -0
- package/dist/prompt-DwEAzq0q.js.map +1 -0
- package/dist/prompt-qiwl6Be9.cjs +855 -0
- package/dist/prompt-qiwl6Be9.cjs.map +1 -0
- package/dist/transformers-B3CHtwuB.cjs +948 -0
- package/dist/transformers-B3CHtwuB.cjs.map +1 -0
- package/dist/transformers-CJqBQFIl.js +829 -0
- package/dist/transformers-CJqBQFIl.js.map +1 -0
- package/dist/transformers.cjs +33 -88
- package/dist/transformers.d.cts +75 -54
- package/dist/transformers.d.ts +75 -54
- package/dist/transformers.js +4 -3
- package/dist/utils.cjs +20 -73
- package/dist/utils.d.cts +5 -126
- package/dist/utils.d.ts +5 -126
- package/dist/utils.js +6 -5
- package/dist/write-CLTPlucv.js +42 -0
- package/dist/write-CLTPlucv.js.map +1 -0
- package/dist/write-l_NzIqyy.cjs +48 -0
- package/dist/write-l_NzIqyy.cjs.map +1 -0
- package/package.json +25 -32
- package/src/BarrelManager.ts +1 -0
- package/src/PromiseManager.ts +1 -7
- package/src/build.ts +9 -11
- package/src/index.ts +5 -5
- package/src/logger.ts +10 -10
- package/src/utils/FunctionParams.ts +3 -1
- package/src/utils/TreeNode.ts +3 -1
- package/dist/PluginManager-E3SghPP9.d.cts +0 -458
- package/dist/PluginManager-PDmRCu9k.d.ts +0 -458
- package/dist/chunk-4V7HK7PT.js +0 -1199
- package/dist/chunk-4V7HK7PT.js.map +0 -1
- package/dist/chunk-BHSTNFNQ.cjs +0 -701
- package/dist/chunk-BHSTNFNQ.cjs.map +0 -1
- package/dist/chunk-CAZ37TGB.js +0 -918
- package/dist/chunk-CAZ37TGB.js.map +0 -1
- package/dist/chunk-E4XLCCPK.cjs +0 -170
- package/dist/chunk-E4XLCCPK.cjs.map +0 -1
- package/dist/chunk-GBYHPDPK.js +0 -595
- package/dist/chunk-GBYHPDPK.js.map +0 -1
- package/dist/chunk-L3A3DTAX.cjs +0 -1074
- package/dist/chunk-L3A3DTAX.cjs.map +0 -1
- package/dist/chunk-MCNA6SYG.cjs +0 -1231
- package/dist/chunk-MCNA6SYG.cjs.map +0 -1
- package/dist/chunk-YRPOID7E.js +0 -157
- package/dist/chunk-YRPOID7E.js.map +0 -1
- package/dist/fs.cjs.map +0 -1
- package/dist/fs.js.map +0 -1
- package/dist/logger-BWq-oJU_.d.cts +0 -63
- package/dist/logger-BWq-oJU_.d.ts +0 -63
- package/dist/logger.cjs.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/parser-C1vOjVEd.d.ts +0 -41
- package/dist/parser-D6vU1kA9.d.cts +0 -41
- package/dist/prompt-ELTHGQK6.js +0 -753
- package/dist/prompt-ELTHGQK6.js.map +0 -1
- package/dist/prompt-U7M5G25C.cjs +0 -761
- package/dist/prompt-U7M5G25C.cjs.map +0 -1
- package/dist/transformers.cjs.map +0 -1
- package/dist/transformers.js.map +0 -1
- package/dist/types-CA8nQKwM.d.cts +0 -132
- package/dist/types-CA8nQKwM.d.ts +0 -132
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileManager-DsRjYJa_.cjs","names":["#head","#tail","#size","data: BarrelData","parent?: TreeNode","#cachedLeaves","leaves: TreeNode[]","callback: (treeNode: TreeNode) => void","predicate?: (value: TreeNode, index: number, obj: TreeNode[]) => boolean","callback: (treeNode: TreeNode) => boolean","callback: (treeNode: TreeNode) => T","files: KubbFile.File[]","root?: string","node: typeof treeNode","item: DirectoryTree","p: string","files: Array<KubbFile.File>","root: DirectoryTree","path","currentLevel: DirectoryTree[]","options: BarrelManagerOptions","#options","barrelFile: KubbFile.File","item","getRelativePath","#items","item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined","#orderItems","items: Array<FunctionParamsAST | FunctionParamsAST[]>","#addParams","acc: string[]","item: FunctionParamsAST","camelCase","items: FunctionParamsAST[]","type: string[]","name: string[]","item","items: (FunctionParamsAST | FunctionParamsAST[])[]","result: PossiblePromise<T>","result: PromiseSettledResult<unknown>","template: string","data: TData | undefined","ms: number","originalName: string","data: Record<string, number>","path: string","options: Options","path","#options","isValidVarName","camelCase","replacer?: (pathParam: string) => string","params: Record<string, string>","path","file: KubbFile.File<TMeta>","extname","exports","trimExtName","source: KubbFile.Source","imp: KubbFile.Import","exp: KubbFile.Export","parser: ParserModule<TMeta>","module","getRelativePath","parsers: Record<KubbFile.Extname, ParserModule<any>>","extname: KubbFile.Extname | undefined","text: string","key: string","#buffer","value: T","resolvedFiles: KubbFile.ResolvedFile[]","#cache","path: KubbFile.Path","path","trimExtName","#limit","extname","write","path: string | undefined | null","file: ResolvedFile<TMeta>","a: KubbFile.File<TMeta>","b: KubbFile.File<TMeta>","sources: Array<KubbFile.Source>","exports: Array<KubbFile.Export>","exports","imports: Array<KubbFile.Import>","source?: string","importName: string","name?: string","name"],"sources":["../../../node_modules/.pnpm/yocto-queue@1.2.1/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/p-limit@7.0.0/node_modules/p-limit/index.js","../src/utils/TreeNode.ts","../src/BarrelManager.ts","../src/utils/FunctionParams.ts","../src/utils/promise.ts","../src/utils/renderTemplate.ts","../src/utils/timeout.ts","../src/utils/uniqueName.ts","../src/utils/URLPath.ts","../src/utils/parser.ts","../src/utils/Cache.ts","../src/FileManager.ts"],"sourcesContent":["/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tpeek() {\n\t\tif (!this.#head) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.#head.value;\n\n\t\t// TODO: Node.js 18.\n\t\t// return this.#head?.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n\n\t* drain() {\n\t\twhile (this.#head) {\n\t\t\tyield this.dequeue();\n\t\t}\n\t}\n}\n","import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tvalidateConcurrency(concurrency);\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst resumeNext = () => {\n\t\t// Process the next queued function if we're under the concurrency limit\n\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\tactiveCount++;\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst next = () => {\n\t\tactiveCount--;\n\t\tresumeNext();\n\t};\n\n\tconst run = async (function_, resolve, arguments_) => {\n\t\t// Execute the function and capture the result promise\n\t\tconst result = (async () => function_(...arguments_))();\n\n\t\t// Resolve immediately with the promise (don't wait for completion)\n\t\tresolve(result);\n\n\t\t// Wait for the function to complete (success or failure)\n\t\t// We catch errors here to prevent unhandled rejections,\n\t\t// but the original promise rejection is preserved for the caller\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\t// Decrement active count and process next queued function\n\t\tnext();\n\t};\n\n\tconst enqueue = (function_, resolve, arguments_) => {\n\t\t// Queue the internal resolve function instead of the run function\n\t\t// to preserve the asynchronous execution context.\n\t\tnew Promise(internalResolve => { // eslint-disable-line promise/param-names\n\t\t\tqueue.enqueue(internalResolve);\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_)); // eslint-disable-line promise/prefer-await-to-then\n\n\t\t// Start processing immediately if we haven't reached the concurrency limit\n\t\tif (activeCount < concurrency) {\n\t\t\tresumeNext();\n\t\t}\n\t};\n\n\tconst generator = (function_, ...arguments_) => new Promise(resolve => {\n\t\tenqueue(function_, resolve, arguments_);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue() {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t\tconcurrency: {\n\t\t\tget: () => concurrency,\n\n\t\t\tset(newConcurrency) {\n\t\t\t\tvalidateConcurrency(newConcurrency);\n\t\t\t\tconcurrency = newConcurrency;\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t// eslint-disable-next-line no-unmodified-loop-condition\n\t\t\t\t\twhile (activeCount < concurrency && queue.size > 0) {\n\t\t\t\t\t\tresumeNext();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tmap: {\n\t\t\tasync value(array, function_) {\n\t\t\t\tconst promises = array.map(value => this(function_, value));\n\t\t\t\treturn Promise.all(promises);\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n\nexport function limitFunction(function_, options) {\n\tconst {concurrency} = options;\n\tconst limit = pLimit(concurrency);\n\n\treturn (...arguments_) => limit(() => function_(...arguments_));\n}\n\nfunction validateConcurrency(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n}\n","import { FileManager } from '../FileManager.ts'\nimport type { KubbFile } from '../fs/index.ts'\n\ntype BarrelData = {\n file?: KubbFile.File\n /**\n * @deprecated use file instead\n */\n type: KubbFile.Mode\n path: string\n name: string\n}\n\nexport class TreeNode {\n data: BarrelData\n parent?: TreeNode\n children: Array<TreeNode> = []\n #cachedLeaves?: Array<TreeNode> = undefined\n\n constructor(data: BarrelData, parent?: TreeNode) {\n this.data = data\n this.parent = parent\n return this\n }\n\n addChild(data: BarrelData): TreeNode {\n const child = new TreeNode(data, this)\n if (!this.children) {\n this.children = []\n }\n this.children.push(child)\n return child\n }\n\n get root(): TreeNode {\n if (!this.parent) {\n return this\n }\n return this.parent.root\n }\n\n get leaves(): Array<TreeNode> {\n if (!this.children || this.children.length === 0) {\n // this is a leaf\n return [this]\n }\n\n if (this.#cachedLeaves) {\n return this.#cachedLeaves\n }\n\n // if not a leaf, return all children's leaves recursively\n const leaves: TreeNode[] = []\n if (this.children) {\n for (let i = 0, { length } = this.children; i < length; i++) {\n leaves.push.apply(leaves, this.children[i]!.leaves)\n }\n }\n\n this.#cachedLeaves = leaves\n\n return leaves\n }\n\n forEach(callback: (treeNode: TreeNode) => void): this {\n if (typeof callback !== 'function') {\n throw new TypeError('forEach() callback must be a function')\n }\n\n // run this node through function\n callback(this)\n\n // do the same for all children\n if (this.children) {\n for (let i = 0, { length } = this.children; i < length; i++) {\n this.children[i]?.forEach(callback)\n }\n }\n\n return this\n }\n\n findDeep(predicate?: (value: TreeNode, index: number, obj: TreeNode[]) => boolean): TreeNode | undefined {\n if (typeof predicate !== 'function') {\n throw new TypeError('find() predicate must be a function')\n }\n\n return this.leaves.find(predicate)\n }\n\n forEachDeep(callback: (treeNode: TreeNode) => void): void {\n if (typeof callback !== 'function') {\n throw new TypeError('forEach() callback must be a function')\n }\n\n this.leaves.forEach(callback)\n }\n\n filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode> {\n if (typeof callback !== 'function') {\n throw new TypeError('filter() callback must be a function')\n }\n\n return this.leaves.filter(callback)\n }\n\n mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T> {\n if (typeof callback !== 'function') {\n throw new TypeError('map() callback must be a function')\n }\n\n return this.leaves.map(callback)\n }\n\n public static build(files: KubbFile.File[], root?: string): TreeNode | null {\n try {\n const filteredTree = buildDirectoryTree(files, root)\n\n if (!filteredTree) {\n return null\n }\n\n const treeNode = new TreeNode({\n name: filteredTree.name,\n path: filteredTree.path,\n file: filteredTree.file,\n type: FileManager.getMode(filteredTree.path),\n })\n\n const recurse = (node: typeof treeNode, item: DirectoryTree) => {\n const subNode = node.addChild({\n name: item.name,\n path: item.path,\n file: item.file,\n type: FileManager.getMode(item.path),\n })\n\n if (item.children?.length) {\n item.children?.forEach((child) => {\n recurse(subNode, child)\n })\n }\n }\n\n filteredTree.children?.forEach((child) => {\n recurse(treeNode, child)\n })\n\n return treeNode\n } catch (e) {\n throw new Error('Something went wrong with creating barrel files with the TreeNode class', { cause: e })\n }\n }\n}\n\nexport type DirectoryTree = {\n name: string\n path: string\n file?: KubbFile.File\n children: Array<DirectoryTree>\n}\n\nconst normalizePath = (p: string): string => p.replace(/\\\\/g, '/')\n\nexport function buildDirectoryTree(files: Array<KubbFile.File>, rootFolder = ''): DirectoryTree | null {\n const normalizedRootFolder = normalizePath(rootFolder)\n const rootPrefix = normalizedRootFolder.endsWith('/') ? normalizedRootFolder : `${normalizedRootFolder}/`\n\n const filteredFiles = files.filter((file) => {\n const normalizedFilePath = normalizePath(file.path)\n return rootFolder ? normalizedFilePath.startsWith(rootPrefix) && !normalizedFilePath.endsWith('.json') : !normalizedFilePath.endsWith('.json')\n })\n\n if (filteredFiles.length === 0) {\n return null // No files match the root folder\n }\n\n const root: DirectoryTree = {\n name: rootFolder || '',\n path: rootFolder || '',\n children: [],\n }\n\n filteredFiles.forEach((file) => {\n const path = file.path.slice(rootFolder.length)\n const parts = path.split('/')\n let currentLevel: DirectoryTree[] = root.children\n let currentPath = rootFolder\n\n parts.forEach((part, index) => {\n if (index !== 0) {\n currentPath += `/${part}`\n } else {\n currentPath += `${part}`\n }\n\n let existingNode = currentLevel.find((node) => node.name === part)\n\n if (!existingNode) {\n if (index === parts.length - 1) {\n // If it's the last part, it's a file\n existingNode = {\n name: part,\n file,\n path: currentPath,\n } as DirectoryTree\n } else {\n // Otherwise, it's a folder\n existingNode = {\n name: part,\n path: currentPath,\n children: [],\n } as DirectoryTree\n }\n currentLevel.push(existingNode)\n }\n\n // Move to the next level if it's a folder\n if (!existingNode.file) {\n currentLevel = existingNode.children\n }\n })\n })\n\n return root\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\nimport { join } from 'node:path'\nimport type { FileMetaBase } from './FileManager.ts'\nimport type { KubbFile } from './fs/index.ts'\nimport { getRelativePath } from './fs/index.ts'\nimport type { Logger } from './logger.ts'\nimport { TreeNode } from './utils/TreeNode.ts'\n\ntype BarrelManagerOptions = {\n logger?: Logger\n}\n\nexport class BarrelManager {\n #options: BarrelManagerOptions\n\n constructor(options: BarrelManagerOptions = {}) {\n this.#options = options\n\n return this\n }\n\n getFiles({ files: generatedFiles, root }: { files: KubbFile.File[]; root?: string; meta?: FileMetaBase | undefined }): Array<KubbFile.File> {\n const { logger } = this.#options\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n\n TreeNode.build(generatedFiles, root)?.forEach((treeNode) => {\n if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) {\n return undefined\n }\n\n const barrelFile: KubbFile.File = {\n path: join(treeNode.parent?.data.path, 'index.ts') as KubbFile.Path,\n baseName: 'index.ts',\n exports: [],\n sources: [],\n }\n const previousBarrelFile = cachedFiles.get(barrelFile.path)\n const leaves = treeNode.leaves\n\n leaves.forEach((item) => {\n if (!item.data.name) {\n return undefined\n }\n\n const sources = item.data.file?.sources || []\n\n if (!sources.some((source) => source.isIndexable)) {\n logger?.emit(\n 'warning',\n `No isIndexable source found(source should have a name and isIndexable):\\nFile: ${JSON.stringify(item.data.file, undefined, 2)}`,\n )\n }\n\n sources.forEach((source) => {\n if (!item.data.file?.path || !source.isIndexable || !source.name) {\n return undefined\n }\n const alreadyContainInPreviousBarrelFile = previousBarrelFile?.sources.some(\n (item) => item.name === source.name && item.isTypeOnly === source.isTypeOnly,\n )\n\n if (alreadyContainInPreviousBarrelFile) {\n return undefined\n }\n\n if (!barrelFile.exports) {\n barrelFile.exports = []\n }\n\n // true when we have a subdirectory that also contains barrel files\n const isSubExport = !!treeNode.parent?.data.path?.split?.('/')?.length\n\n if (isSubExport) {\n barrelFile.exports.push({\n name: [source.name],\n path: getRelativePath(treeNode.parent?.data.path, item.data.path),\n isTypeOnly: source.isTypeOnly,\n })\n } else {\n barrelFile.exports.push({\n name: [source.name],\n path: `./${item.data.file.baseName}`,\n isTypeOnly: source.isTypeOnly,\n })\n }\n\n barrelFile.sources.push({\n name: source.name,\n isTypeOnly: source.isTypeOnly,\n //TODO use parser to generate import\n value: '',\n isExportable: false,\n isIndexable: false,\n })\n })\n })\n\n if (previousBarrelFile) {\n previousBarrelFile.sources.push(...barrelFile.sources)\n previousBarrelFile.exports?.push(...(barrelFile.exports || []))\n } else {\n cachedFiles.set(barrelFile.path, barrelFile)\n }\n })\n\n return [...cachedFiles.values()]\n }\n}\n","import { orderBy } from 'natural-orderby'\n\nimport { camelCase } from '../transformers/casing.ts'\n\ntype FunctionParamsASTWithoutType = {\n name?: string\n type?: string\n /**\n * @default true\n */\n required?: boolean\n /**\n * @default true\n */\n enabled?: boolean\n default?: string\n}\n\ntype FunctionParamsASTWithType = {\n name?: never\n type: string\n /**\n * @default true\n */\n required?: boolean\n /**\n * @default true\n */\n enabled?: boolean\n default?: string\n}\n/**\n * @deprecated\n */\nexport type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType\n\n/**\n * @deprecated\n */\nexport class FunctionParams {\n #items: Array<FunctionParamsAST | FunctionParamsAST[]> = []\n constructor() {\n return this\n }\n\n get items(): FunctionParamsAST[] {\n return this.#items.flat()\n }\n\n add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams {\n if (!item) {\n return this\n }\n\n if (Array.isArray(item)) {\n item.filter(Boolean).forEach((it) => {\n this.#items.push(it)\n })\n return this\n }\n this.#items.push(item)\n\n return this\n }\n static #orderItems(items: Array<FunctionParamsAST | FunctionParamsAST[]>) {\n return orderBy(\n items.filter(Boolean),\n [\n (v) => {\n if (Array.isArray(v)) {\n return undefined\n }\n return !v.default\n },\n (v) => {\n if (Array.isArray(v)) {\n return undefined\n }\n return v.required ?? true\n },\n ],\n ['desc', 'desc'],\n )\n }\n\n static #addParams(acc: string[], item: FunctionParamsAST) {\n const { enabled = true, name, type, required = true, ...rest } = item\n\n if (!enabled) {\n return acc\n }\n\n if (!name) {\n // when name is not se we will use TypeScript generics\n acc.push(`${type}${rest.default ? ` = ${rest.default}` : ''}`)\n\n return acc\n }\n // TODO check whey we still need the camelcase here\n const parameterName = name.startsWith('{') ? name : camelCase(name)\n\n if (type) {\n if (required) {\n acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ''}`)\n } else {\n acc.push(`${parameterName}?: ${type}`)\n }\n } else {\n acc.push(`${parameterName}`)\n }\n\n return acc\n }\n\n static toObject(items: FunctionParamsAST[]): FunctionParamsAST {\n let type: string[] = []\n let name: string[] = []\n\n const enabled = items.every((item) => item.enabled) ? items.at(0)?.enabled : true\n const required = items.every((item) => item.required) ?? true\n\n items.forEach((item) => {\n name = FunctionParams.#addParams(name, { ...item, type: undefined })\n if (items.some((item) => item.type)) {\n type = FunctionParams.#addParams(type, item)\n }\n })\n\n return {\n name: `{ ${name.join(', ')} }`,\n type: type.length ? `{ ${type.join('; ')} }` : undefined,\n enabled,\n required,\n }\n }\n\n static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string {\n const sortedData = FunctionParams.#orderItems(items)\n\n return sortedData\n .reduce((acc, item) => {\n if (Array.isArray(item)) {\n if (item.length <= 0) {\n return acc\n }\n const subItems = FunctionParams.#orderItems(item) as FunctionParamsAST[]\n const objectItem = FunctionParams.toObject(subItems)\n\n return FunctionParams.#addParams(acc, objectItem)\n }\n\n return FunctionParams.#addParams(acc, item)\n }, [] as string[])\n .join(', ')\n }\n\n toObject(): FunctionParamsAST {\n const items = FunctionParams.#orderItems(this.#items).flat()\n\n return FunctionParams.toObject(items)\n }\n\n toString(): string {\n const items = FunctionParams.#orderItems(this.#items)\n\n return FunctionParams.toString(items)\n }\n}\n","import type { PossiblePromise } from './types.ts'\n\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return !!result && typeof (result as Promise<unknown>)?.then === 'function'\n}\n\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","export function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data: TData | undefined = undefined): string {\n if (!data || !Object.keys(data).length) {\n return template.replace(/{{(.*?)}}/g, '')\n }\n\n const matches = template.match(/{{(.*?)}}/g)\n\n return (\n matches?.reduce((prev, curr) => {\n const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim()\n if (index === undefined) {\n return prev\n }\n const value = data[index]\n\n if (value === undefined) {\n return prev\n }\n\n return prev\n .replace(curr, () => {\n if (typeof value === 'boolean') {\n return `${value.toString()}` || 'false'\n }\n\n return (value as string) || ''\n })\n .trim()\n }, template) || ''\n )\n}\n","export async function timeout(ms: number): Promise<unknown> {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(true)\n }, ms)\n })\n}\n","export function getUniqueName(originalName: string, data: Record<string, number>): string {\n let used = data[originalName] || 0\n if (used) {\n data[originalName] = ++used\n originalName += used\n }\n data[originalName] = 1\n return originalName\n}\n\nexport function setUniqueName(originalName: string, data: Record<string, number>): string {\n let used = data[originalName] || 0\n if (used) {\n data[originalName] = ++used\n\n return originalName\n }\n data[originalName] = 1\n return originalName\n}\n","import { camelCase, isValidVarName } from '../transformers'\n\nexport type URLObject = {\n url: string\n params?: Record<string, string>\n}\n\ntype ObjectOptions = {\n type?: 'path' | 'template'\n replacer?: (pathParam: string) => string\n stringify?: boolean\n}\n\ntype Options = {\n casing?: 'camelcase'\n}\n\nexport class URLPath {\n path: string\n #options: Options\n\n constructor(path: string, options: Options = {}) {\n this.path = path\n this.#options = options\n\n return this\n }\n\n /**\n * Convert Swagger path to URLPath(syntax of Express)\n * @example /pet/{petId} => /pet/:petId\n */\n get URL(): string {\n return this.toURLPath()\n }\n get isURL(): boolean {\n try {\n const url = new URL(this.path)\n if (url?.href) {\n return true\n }\n } catch (_error) {\n return false\n }\n return false\n }\n\n /**\n * Convert Swagger path to template literals/ template strings(camelcase)\n * @example /pet/{petId} => `/pet/${petId}`\n * @example /account/monetary-accountID => `/account/${monetaryAccountId}`\n * @example /account/userID => `/account/${userId}`\n */\n get template(): string {\n return this.toTemplateString()\n }\n get object(): URLObject | string {\n return this.toObject()\n }\n get params(): Record<string, string> | undefined {\n return this.getParams()\n }\n\n toObject({ type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object = {\n url: type === 'path' ? this.toURLPath() : this.toTemplateString({ replacer }),\n params: this.getParams(),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n\n /**\n * Convert Swagger path to template literals/ template strings(camelcase)\n * @example /pet/{petId} => `/pet/${petId}`\n * @example /account/monetary-accountID => `/account/${monetaryAccountId}`\n * @example /account/userID => `/account/${userId}`\n */\n toTemplateString({ prefix = '', replacer }: { prefix?: string; replacer?: (pathParam: string) => string } = {}): string {\n const regex = /{(\\w|-)*}/g\n const found = this.path.match(regex)\n let newPath = this.path.replaceAll('{', '${')\n\n if (found) {\n newPath = found.reduce((prev, path) => {\n const pathWithoutBrackets = path.replaceAll('{', '').replaceAll('}', '')\n\n let param = isValidVarName(pathWithoutBrackets) ? pathWithoutBrackets : camelCase(pathWithoutBrackets)\n\n if (this.#options.casing === 'camelcase') {\n param = camelCase(param)\n }\n\n return prev.replace(path, `\\${${replacer ? replacer(param) : param}}`)\n }, this.path)\n }\n\n return `\\`${prefix}${newPath}\\``\n }\n\n getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined {\n const regex = /{(\\w|-)*}/g\n const found = this.path.match(regex)\n\n if (!found) {\n return undefined\n }\n\n const params: Record<string, string> = {}\n found.forEach((item) => {\n item = item.replaceAll('{', '').replaceAll('}', '')\n\n let param = isValidVarName(item) ? item : camelCase(item)\n\n if (this.#options.casing === 'camelcase') {\n param = camelCase(param)\n }\n\n const key = replacer ? replacer(param) : param\n\n params[key] = key\n }, this.path)\n\n return params\n }\n\n /**\n * Convert Swagger path to URLPath(syntax of Express)\n * @example /pet/{petId} => /pet/:petId\n */\n toURLPath(): string {\n return this.path.replaceAll('{', ':').replaceAll('}', '')\n }\n}\n","import path from 'node:path'\nimport type { KubbFile } from '../fs/index.ts'\n\nimport { getRelativePath } from '../fs/index.ts'\nimport hash from 'object-hash'\nimport { combineExports, combineImports, combineSources } from '../FileManager.ts'\nimport type { Logger } from '../logger.ts'\nimport type { Config } from '../types.ts'\n\n/**\n * Generate a default banner for files created by Kubb\n * @returns A string with the default banner\n */\nexport function getDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {\n try {\n let source = ''\n if ('path' in config.input) {\n source = path.basename(config.input.path)\n } else if ('data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n // If there's any error in parsing the Oas data, return a simpler banner\n return '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n*/'\n }\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: hash({ path: file.path }),\n name: trimExtName(file.baseName),\n extname,\n imports: imports.map(createFileImport),\n exports: exports.map(createFileExport),\n sources: sources.map(createFileSource),\n meta: file.meta || ({} as TMeta),\n }\n}\n\n/**\n * Helper to create a fileImport with extname set\n */\nfunction createFileSource(source: KubbFile.Source): KubbFile.Source {\n return source\n}\n\n/**\n * Helper to create a fileImport with extname set\n */\nexport function createFileImport(imp: KubbFile.Import): KubbFile.ResolvedImport {\n return {\n ...imp,\n }\n}\n\n/**\n * Helper to create a fileExport with extname set\n */\nexport function createFileExport(exp: KubbFile.Export): KubbFile.ResolvedExport {\n return {\n ...exp,\n }\n}\n\nexport type ParserModule<TMeta extends object = object> = {\n format: (source: string) => Promise<string>\n /**\n * Convert a file to string\n */\n print: (file: KubbFile.ResolvedFile<TMeta>, options: PrintOptions) => Promise<string>\n}\n\nexport function createFileParser<TMeta extends object = object>(parser: ParserModule<TMeta>): ParserModule<TMeta> {\n return parser\n}\n\ntype PrintOptions = {\n extname?: KubbFile.Extname\n logger?: Logger\n}\n\nconst typeScriptParser = createFileParser({\n async format(source) {\n const module = await import('@kubb/parser-ts')\n\n return module.format(source)\n },\n async print(file, options = { extname: '.ts' }) {\n const module = await import('@kubb/parser-ts')\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n\n const importNodes = file.imports\n .map((item) => {\n const importPath = item.root ? getRelativePath(item.root, item.path) : item.path\n const hasExtname = !!path.extname(importPath)\n\n return module.factory.createImportDeclaration({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,\n isTypeOnly: item.isTypeOnly,\n })\n })\n .filter(Boolean)\n\n const exportNodes = file.exports\n .map((item) => {\n const exportPath = item.path\n\n const hasExtname = !!path.extname(exportPath)\n\n return module.factory.createExportDeclaration({\n name: item.name,\n path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n })\n })\n .filter(Boolean)\n\n return [file.banner, module.print([...importNodes, ...exportNodes]), source, file.footer].join('\\n')\n },\n})\n\nconst tsxParser = createFileParser({\n async format(source) {\n const module = await import('@kubb/parser-ts')\n //4 = tsx\n return module.format(source)\n },\n async print(file, options = { extname: '.tsx' }) {\n return typeScriptParser.print(file, options)\n },\n})\n\nconst defaultParser = createFileParser({\n async format(source) {\n return source\n },\n async print(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n\nconst parsers: Record<KubbFile.Extname, ParserModule<any>> = {\n '.ts': typeScriptParser,\n '.js': typeScriptParser,\n '.jsx': tsxParser,\n '.tsx': tsxParser,\n '.json': defaultParser,\n}\n\nexport async function getFileParser<TMeta extends object = object>(extname: KubbFile.Extname | undefined): Promise<ParserModule<TMeta>> {\n if (!extname) {\n return defaultParser\n }\n\n const parser = parsers[extname]\n\n if (!parser) {\n console.warn(`[parser] No parser found for ${extname}, default parser will be used`)\n }\n\n return parser || defaultParser\n}\n\nfunction trimExtName(text: string): string {\n const extname = text.split('.').pop()\n\n return text.replace(`.${extname}`, '')\n}\n","export class Cache<T> {\n #buffer = new Map<string, T>()\n\n async get(key: string): Promise<T | null> {\n return this.#buffer.get(key) ?? null\n }\n\n async set(key: string, value: T): Promise<void> {\n this.#buffer.set(key, value)\n }\n\n async delete(key: string): Promise<void> {\n this.#buffer.delete(key)\n }\n\n async clear(): Promise<void> {\n this.#buffer.clear()\n }\n\n async keys(): Promise<string[]> {\n return [...this.#buffer.keys()]\n }\n\n async values(): Promise<T[]> {\n return [...this.#buffer.values()]\n }\n\n async flush(): Promise<void> {\n // No-op for base cache\n }\n}\n","import { extname, join, relative } from 'node:path'\n\nimport { orderBy } from 'natural-orderby'\nimport { isDeepEqual, uniqueBy } from 'remeda'\nimport pLimit from 'p-limit'\n\nimport { BarrelManager } from './BarrelManager.ts'\n\nimport type { KubbFile } from './fs/index.ts'\nimport { trimExtName, write } from './fs/index.ts'\nimport type { ResolvedFile } from './fs/types.ts'\nimport type { Logger } from './logger.ts'\nimport type { BarrelType, Config, Plugin } from './types.ts'\nimport { createFile, getFileParser } from './utils'\nimport type { GreaterThan } from './utils/types.ts'\nimport { Cache } from './utils/Cache.ts'\n\nexport type FileMetaBase = {\n pluginKey?: Plugin['key']\n}\n\ntype AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>\n\ntype AddIndexesProps = {\n type: BarrelType | false | undefined\n /**\n * Root based on root and output.path specified in the config\n */\n root: string\n /**\n * Output for plugin\n */\n output: {\n path: string\n }\n group?: {\n output: string\n exportAs: string\n }\n logger?: Logger\n\n meta?: FileMetaBase\n}\n\ntype WriteFilesProps = {\n root: Config['root']\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n logger?: Logger\n dryRun?: boolean\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #limit = pLimit(100)\n\n constructor() {\n return this\n }\n\n async add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T> {\n const resolvedFiles: KubbFile.ResolvedFile[] = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (const file of mergedFiles.values()) {\n const existing = await this.#cache.get(file.path)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n await this.#cache.set(resolvedFile.path, resolvedFile)\n await this.#cache.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n if (files.length > 1) {\n return resolvedFiles as unknown as AddResult<T>\n }\n\n return resolvedFiles[0] as unknown as AddResult<T>\n }\n\n async getByPath(path: KubbFile.Path): Promise<KubbFile.ResolvedFile | null> {\n return this.#cache.get(path)\n }\n\n async deleteByPath(path: KubbFile.Path): Promise<void> {\n await this.#cache.delete(path)\n }\n\n async clear(): Promise<void> {\n await this.#cache.clear()\n }\n\n async getFiles(): Promise<Array<KubbFile.ResolvedFile>> {\n const cachedKeys = await this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const filesTasks = keys.map((key) =>\n this.#limit(async () => {\n const file = await this.#cache.get(key)\n return file as KubbFile.ResolvedFile\n }),\n )\n\n const files = await Promise.all(filesTasks)\n\n return files.filter(Boolean)\n }\n\n async processFiles({ dryRun, root, extension, logger }: WriteFilesProps): Promise<Array<KubbFile.ResolvedFile>> {\n const files = await this.getFiles()\n\n logger?.emit('progress_start', { id: 'files', size: files.length, message: 'Writing files ...' })\n\n const promises = files.map((file) => {\n return this.#limit(async () => {\n const message = file ? `Writing ${relative(root, file.path)}` : ''\n const extname = extension?.[file.extname] || undefined\n\n if (!dryRun) {\n const source = await getSource(file, { logger, extname })\n await write(file.path, source, { sanity: false })\n }\n\n logger?.emit('progressed', { id: 'files', message })\n })\n })\n\n await Promise.all(promises)\n\n logger?.emit('progress_stop', { id: 'files' })\n\n return files\n }\n async getBarrelFiles({ type, meta = {}, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]> {\n if (!type || type === 'propagate') {\n return []\n }\n\n const barrelManager = new BarrelManager({ logger })\n const files = await this.getFiles()\n\n const pathToBuildFrom = join(root, output.path)\n\n if (trimExtName(pathToBuildFrom).endsWith('index')) {\n logger?.emit('warning', 'Output has the same fileName as the barrelFiles, please disable barrel generation')\n\n return []\n }\n\n const barrelFiles = barrelManager.getFiles({ files, root: pathToBuildFrom, meta })\n\n if (type === 'all') {\n return barrelFiles.map((file) => {\n return {\n ...file,\n exports: file.exports?.map((exportItem) => {\n return {\n ...exportItem,\n name: undefined,\n }\n }),\n }\n })\n }\n\n return barrelFiles.map((indexFile) => {\n return {\n ...indexFile,\n meta,\n }\n })\n }\n\n // statics\n static getMode(path: string | undefined | null): KubbFile.Mode {\n if (!path) {\n return 'split'\n }\n return extname(path) ? 'single' : 'split'\n }\n}\n\ntype GetSourceOptions = {\n extname?: KubbFile.Extname\n logger?: Logger\n}\n\nexport async function getSource<TMeta extends FileMetaBase = FileMetaBase>(\n file: ResolvedFile<TMeta>,\n { logger, extname }: GetSourceOptions = {},\n): Promise<string> {\n const parser = await getFileParser(file.extname)\n const source = await parser.print(file, { logger, extname })\n\n return parser.format(source).catch((err) => {\n console.warn(err)\n return source\n })\n}\n\nfunction mergeFile<TMeta extends FileMetaBase = FileMetaBase>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\n}\n"],"x_google_ignoreList":[0,1],"mappings":";;;;;;;;;AAKA,IAAM,OAAN,MAAW;CACV;CACA;CAEA,YA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AAK,YAAY;GACpH,WAAW,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,WAAW,MAAM,GAAG,IAAK,EAAE;AAE7D,UAAO;EACR;AAGD,MAAI,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,kBAAkB,KAAK,CAC1D,QAAO;AAGT,SAAO,CAAC,GAAG,MAAM,IAAK;CACvB,GACD,CAAE,EACH;AACF"}
|
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import { BaseName, Extname, File, Mode, OptionalPath, Path, ResolvedFile } from "./index-BKHQGQVq.js";
|
|
2
|
+
import { EventEmitter, Logger } from "./logger-xcdTETKy.js";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/types.d.ts
|
|
5
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
6
|
+
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
7
|
+
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/types.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Config used in `kubb.config.ts`
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { defineConfig } from '@kubb/core'
|
|
15
|
+
* export default defineConfig({
|
|
16
|
+
* ...
|
|
17
|
+
* })
|
|
18
|
+
*/
|
|
19
|
+
type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
|
|
20
|
+
/**
|
|
21
|
+
* The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
|
|
22
|
+
* @default process.cwd()
|
|
23
|
+
*/
|
|
24
|
+
root?: string;
|
|
25
|
+
/**
|
|
26
|
+
* An array of Kubb plugins used for generation. Each plugin may have additional configurable options (defined within the plugin itself). If a plugin relies on another plugin, an error will occur if the required dependency is missing. Refer to “pre” for more details.
|
|
27
|
+
*/
|
|
28
|
+
plugins?: Array<Omit<UnknownUserPlugin, 'context'>>;
|
|
29
|
+
};
|
|
30
|
+
type InputPath = {
|
|
31
|
+
/**
|
|
32
|
+
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
33
|
+
*/
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
type InputData = {
|
|
37
|
+
/**
|
|
38
|
+
* A `string` or `object` that contains your Swagger/OpenAPI data.
|
|
39
|
+
*/
|
|
40
|
+
data: string | unknown;
|
|
41
|
+
};
|
|
42
|
+
type Input = InputPath | InputData | Array<InputPath>;
|
|
43
|
+
type BarrelType = 'all' | 'named' | 'propagate';
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
type Config<TInput = Input> = {
|
|
48
|
+
/**
|
|
49
|
+
* The name to display in the CLI output.
|
|
50
|
+
*/
|
|
51
|
+
name?: string;
|
|
52
|
+
/**
|
|
53
|
+
* The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
|
|
54
|
+
* @default process.cwd()
|
|
55
|
+
*/
|
|
56
|
+
root: string;
|
|
57
|
+
/**
|
|
58
|
+
* You can use either `input.path` or `input.data`, depending on your specific needs.
|
|
59
|
+
*/
|
|
60
|
+
input: TInput;
|
|
61
|
+
output: {
|
|
62
|
+
/**
|
|
63
|
+
* The path where all generated files will be exported.
|
|
64
|
+
* This can be an absolute path or a path relative to the specified root option.
|
|
65
|
+
*/
|
|
66
|
+
path: string;
|
|
67
|
+
/**
|
|
68
|
+
* Clean the output directory before each build.
|
|
69
|
+
*/
|
|
70
|
+
clean?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Save files to the file system.
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
write?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
78
|
+
* @default { '.ts': '.ts'}
|
|
79
|
+
*/
|
|
80
|
+
extension?: Record<Extname, Extname | ''>;
|
|
81
|
+
/**
|
|
82
|
+
* 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`.
|
|
83
|
+
* @default 'named'
|
|
84
|
+
*/
|
|
85
|
+
barrelType?: Exclude<BarrelType, 'propagate'> | false;
|
|
86
|
+
/**
|
|
87
|
+
* Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
|
|
88
|
+
* - 'simple': will only add banner with link to Kubb
|
|
89
|
+
* - 'full': will add source, title, description and the OpenAPI version used
|
|
90
|
+
* @default 'simple'
|
|
91
|
+
*/
|
|
92
|
+
defaultBanner?: 'simple' | 'full' | false;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* An array of Kubb plugins that will be used in the generation.
|
|
96
|
+
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
97
|
+
* If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
|
|
98
|
+
*/
|
|
99
|
+
plugins?: Array<Plugin>;
|
|
100
|
+
/**
|
|
101
|
+
* Hooks that will be called when a specific action is triggered in Kubb.
|
|
102
|
+
*/
|
|
103
|
+
hooks?: {
|
|
104
|
+
/**
|
|
105
|
+
* Hook that will be triggered at the end of all executions.
|
|
106
|
+
* Useful for running Prettier or ESLint to format/lint your code.
|
|
107
|
+
*/
|
|
108
|
+
done?: string | Array<string>;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
type PluginFactoryOptions<
|
|
112
|
+
/**
|
|
113
|
+
* Name to be used for the plugin, this will also be used for they key.
|
|
114
|
+
*/
|
|
115
|
+
TName extends string = string,
|
|
116
|
+
/**
|
|
117
|
+
* Options of the plugin.
|
|
118
|
+
*/
|
|
119
|
+
TOptions extends object = object,
|
|
120
|
+
/**
|
|
121
|
+
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
122
|
+
*/
|
|
123
|
+
TResolvedOptions extends object = TOptions,
|
|
124
|
+
/**
|
|
125
|
+
* Context that you want to expose to other plugins.
|
|
126
|
+
*/
|
|
127
|
+
TContext = any,
|
|
128
|
+
/**
|
|
129
|
+
* When calling `resolvePath` you can specify better types.
|
|
130
|
+
*/
|
|
131
|
+
TResolvePathOptions extends object = object> = {
|
|
132
|
+
name: TName;
|
|
133
|
+
/**
|
|
134
|
+
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
135
|
+
*/
|
|
136
|
+
key: PluginKey<TName | string>;
|
|
137
|
+
options: TOptions;
|
|
138
|
+
resolvedOptions: TResolvedOptions;
|
|
139
|
+
context: TContext;
|
|
140
|
+
resolvePathOptions: TResolvePathOptions;
|
|
141
|
+
};
|
|
142
|
+
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
143
|
+
type GetPluginFactoryOptions<TPlugin extends UserPlugin> = TPlugin extends UserPlugin<infer X> ? X : never;
|
|
144
|
+
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
145
|
+
/**
|
|
146
|
+
* Unique name used for the plugin
|
|
147
|
+
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
148
|
+
* @example @kubb/typescript
|
|
149
|
+
*/
|
|
150
|
+
name: TOptions['name'];
|
|
151
|
+
/**
|
|
152
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
153
|
+
*/
|
|
154
|
+
options: TOptions['resolvedOptions'];
|
|
155
|
+
/**
|
|
156
|
+
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
157
|
+
* Can be used to validate dependent plugins.
|
|
158
|
+
*/
|
|
159
|
+
pre?: Array<string>;
|
|
160
|
+
/**
|
|
161
|
+
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
162
|
+
*/
|
|
163
|
+
post?: Array<string>;
|
|
164
|
+
} & (TOptions['context'] extends never ? {
|
|
165
|
+
context?: never;
|
|
166
|
+
} : {
|
|
167
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
168
|
+
});
|
|
169
|
+
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
170
|
+
type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
|
|
171
|
+
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
172
|
+
/**
|
|
173
|
+
* Unique name used for the plugin
|
|
174
|
+
* @example @kubb/typescript
|
|
175
|
+
*/
|
|
176
|
+
name: TOptions['name'];
|
|
177
|
+
/**
|
|
178
|
+
* Internal key used when a developer uses more than one of the same plugin
|
|
179
|
+
* @private
|
|
180
|
+
*/
|
|
181
|
+
key: TOptions['key'];
|
|
182
|
+
/**
|
|
183
|
+
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
184
|
+
* Can be used to validate dependent plugins.
|
|
185
|
+
*/
|
|
186
|
+
pre?: Array<string>;
|
|
187
|
+
/**
|
|
188
|
+
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
189
|
+
*/
|
|
190
|
+
post?: Array<string>;
|
|
191
|
+
/**
|
|
192
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
193
|
+
*/
|
|
194
|
+
options: TOptions['resolvedOptions'];
|
|
195
|
+
} & (TOptions['context'] extends never ? {
|
|
196
|
+
context?: never;
|
|
197
|
+
} : {
|
|
198
|
+
context: TOptions['context'];
|
|
199
|
+
});
|
|
200
|
+
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
201
|
+
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
202
|
+
/**
|
|
203
|
+
* Start of the lifecycle of a plugin.
|
|
204
|
+
* @type hookParallel
|
|
205
|
+
*/
|
|
206
|
+
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
209
|
+
* Options can als be included.
|
|
210
|
+
* @type hookFirst
|
|
211
|
+
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
212
|
+
*/
|
|
213
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
214
|
+
/**
|
|
215
|
+
* Resolve to a name based on a string.
|
|
216
|
+
* Useful when converting to PascalCase or camelCase.
|
|
217
|
+
* @type hookFirst
|
|
218
|
+
* @example ('pet') => 'Pet'
|
|
219
|
+
*/
|
|
220
|
+
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
221
|
+
/**
|
|
222
|
+
* End of the plugin lifecycle.
|
|
223
|
+
* @type hookParallel
|
|
224
|
+
*/
|
|
225
|
+
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
226
|
+
};
|
|
227
|
+
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
228
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
229
|
+
type ResolvePathParams<TOptions = object> = {
|
|
230
|
+
pluginKey?: Plugin['key'];
|
|
231
|
+
baseName: BaseName;
|
|
232
|
+
mode?: Mode;
|
|
233
|
+
/**
|
|
234
|
+
* Options to be passed to 'resolvePath' 3th parameter
|
|
235
|
+
*/
|
|
236
|
+
options?: TOptions;
|
|
237
|
+
};
|
|
238
|
+
type ResolveNameParams = {
|
|
239
|
+
name: string;
|
|
240
|
+
pluginKey?: Plugin['key'];
|
|
241
|
+
/**
|
|
242
|
+
* `file` will be used to customize the name of the created file(use of camelCase)
|
|
243
|
+
* `function` can be used to customize the exported functions(use of camelCase)
|
|
244
|
+
* `type` is a special type for TypeScript(use of PascalCase)
|
|
245
|
+
* `const` can be used for variables(use of camelCase)
|
|
246
|
+
*/
|
|
247
|
+
type?: 'file' | 'function' | 'type' | 'const';
|
|
248
|
+
};
|
|
249
|
+
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
250
|
+
config: Config;
|
|
251
|
+
fileManager: FileManager;
|
|
252
|
+
pluginManager: PluginManager;
|
|
253
|
+
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
254
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
255
|
+
resolveName: (params: ResolveNameParams) => string;
|
|
256
|
+
logger: Logger;
|
|
257
|
+
/**
|
|
258
|
+
* All plugins
|
|
259
|
+
*/
|
|
260
|
+
plugins: Plugin[];
|
|
261
|
+
/**
|
|
262
|
+
* Current plugin
|
|
263
|
+
*/
|
|
264
|
+
plugin: Plugin<TOptions>;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Specify the export location for the files and define the behavior of the output
|
|
268
|
+
*/
|
|
269
|
+
type Output<TOptions> = {
|
|
270
|
+
/**
|
|
271
|
+
* Path to the output folder or file that will contain the generated code
|
|
272
|
+
*/
|
|
273
|
+
path: string;
|
|
274
|
+
/**
|
|
275
|
+
* Define what needs to be exported, here you can also disable the export of barrel files
|
|
276
|
+
* @default 'named'
|
|
277
|
+
*/
|
|
278
|
+
barrelType?: BarrelType | false;
|
|
279
|
+
/**
|
|
280
|
+
* Add a banner text in the beginning of every file
|
|
281
|
+
*/
|
|
282
|
+
banner?: string | ((options: TOptions) => string);
|
|
283
|
+
/**
|
|
284
|
+
* Add a footer text in the beginning of every file
|
|
285
|
+
*/
|
|
286
|
+
footer?: string | ((options: TOptions) => string);
|
|
287
|
+
};
|
|
288
|
+
type GroupContext = {
|
|
289
|
+
group: string;
|
|
290
|
+
};
|
|
291
|
+
type Group = {
|
|
292
|
+
/**
|
|
293
|
+
* Define a type where to group the files on
|
|
294
|
+
*/
|
|
295
|
+
type: 'tag' | 'path';
|
|
296
|
+
/**
|
|
297
|
+
* Return the name of a group based on the group name, this will be used for the file and name generation
|
|
298
|
+
*/
|
|
299
|
+
name?: (context: GroupContext) => string;
|
|
300
|
+
};
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/FileManager.d.ts
|
|
303
|
+
type FileMetaBase = {
|
|
304
|
+
pluginKey?: Plugin['key'];
|
|
305
|
+
};
|
|
306
|
+
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
307
|
+
type AddIndexesProps = {
|
|
308
|
+
type: BarrelType | false | undefined;
|
|
309
|
+
/**
|
|
310
|
+
* Root based on root and output.path specified in the config
|
|
311
|
+
*/
|
|
312
|
+
root: string;
|
|
313
|
+
/**
|
|
314
|
+
* Output for plugin
|
|
315
|
+
*/
|
|
316
|
+
output: {
|
|
317
|
+
path: string;
|
|
318
|
+
};
|
|
319
|
+
group?: {
|
|
320
|
+
output: string;
|
|
321
|
+
exportAs: string;
|
|
322
|
+
};
|
|
323
|
+
logger?: Logger;
|
|
324
|
+
meta?: FileMetaBase;
|
|
325
|
+
};
|
|
326
|
+
type WriteFilesProps = {
|
|
327
|
+
root: Config['root'];
|
|
328
|
+
extension?: Record<Extname, Extname | ''>;
|
|
329
|
+
logger?: Logger;
|
|
330
|
+
dryRun?: boolean;
|
|
331
|
+
};
|
|
332
|
+
declare class FileManager {
|
|
333
|
+
#private;
|
|
334
|
+
constructor();
|
|
335
|
+
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
336
|
+
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
337
|
+
deleteByPath(path: Path): Promise<void>;
|
|
338
|
+
clear(): Promise<void>;
|
|
339
|
+
getFiles(): Promise<Array<ResolvedFile>>;
|
|
340
|
+
processFiles({
|
|
341
|
+
dryRun,
|
|
342
|
+
root,
|
|
343
|
+
extension,
|
|
344
|
+
logger
|
|
345
|
+
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
346
|
+
getBarrelFiles({
|
|
347
|
+
type,
|
|
348
|
+
meta,
|
|
349
|
+
root,
|
|
350
|
+
output,
|
|
351
|
+
logger
|
|
352
|
+
}: AddIndexesProps): Promise<File[]>;
|
|
353
|
+
static getMode(path: string | undefined | null): Mode;
|
|
354
|
+
}
|
|
355
|
+
type GetSourceOptions = {
|
|
356
|
+
extname?: Extname;
|
|
357
|
+
logger?: Logger;
|
|
358
|
+
};
|
|
359
|
+
declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, {
|
|
360
|
+
logger,
|
|
361
|
+
extname
|
|
362
|
+
}?: GetSourceOptions): Promise<string>;
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/PluginManager.d.ts
|
|
365
|
+
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
366
|
+
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
367
|
+
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
368
|
+
message: string;
|
|
369
|
+
strategy: Strategy;
|
|
370
|
+
hookName: H;
|
|
371
|
+
plugin: Plugin;
|
|
372
|
+
parameters?: unknown[] | undefined;
|
|
373
|
+
output?: unknown;
|
|
374
|
+
};
|
|
375
|
+
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
376
|
+
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
377
|
+
result: Result;
|
|
378
|
+
plugin: Plugin;
|
|
379
|
+
};
|
|
380
|
+
type Options = {
|
|
381
|
+
logger: Logger;
|
|
382
|
+
/**
|
|
383
|
+
* @default Number.POSITIVE_INFINITY
|
|
384
|
+
*/
|
|
385
|
+
concurrency?: number;
|
|
386
|
+
};
|
|
387
|
+
type Events = {
|
|
388
|
+
executing: [executer: Executer];
|
|
389
|
+
executed: [executer: Executer];
|
|
390
|
+
error: [error: Error];
|
|
391
|
+
};
|
|
392
|
+
type GetFileProps<TOptions = object> = {
|
|
393
|
+
name: string;
|
|
394
|
+
mode?: Mode;
|
|
395
|
+
extname: Extname;
|
|
396
|
+
pluginKey: Plugin['key'];
|
|
397
|
+
options?: TOptions;
|
|
398
|
+
};
|
|
399
|
+
declare class PluginManager {
|
|
400
|
+
#private;
|
|
401
|
+
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
402
|
+
readonly fileManager: FileManager;
|
|
403
|
+
readonly events: EventEmitter<Events>;
|
|
404
|
+
readonly config: Config;
|
|
405
|
+
readonly executed: Array<Executer>;
|
|
406
|
+
readonly logger: Logger;
|
|
407
|
+
readonly options: Options;
|
|
408
|
+
constructor(config: Config, options: Options);
|
|
409
|
+
getFile<TOptions = object>({
|
|
410
|
+
name,
|
|
411
|
+
mode,
|
|
412
|
+
extname,
|
|
413
|
+
pluginKey,
|
|
414
|
+
options
|
|
415
|
+
}: GetFileProps<TOptions>): File<{
|
|
416
|
+
pluginKey: Plugin['key'];
|
|
417
|
+
}>;
|
|
418
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
419
|
+
resolveName: (params: ResolveNameParams) => string;
|
|
420
|
+
/**
|
|
421
|
+
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
422
|
+
*/
|
|
423
|
+
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
424
|
+
/**
|
|
425
|
+
* Run a specific hookName for plugin x.
|
|
426
|
+
*/
|
|
427
|
+
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
428
|
+
pluginKey,
|
|
429
|
+
hookName,
|
|
430
|
+
parameters,
|
|
431
|
+
message
|
|
432
|
+
}: {
|
|
433
|
+
pluginKey: Plugin['key'];
|
|
434
|
+
hookName: H;
|
|
435
|
+
parameters: PluginParameter<H>;
|
|
436
|
+
message: string;
|
|
437
|
+
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
438
|
+
/**
|
|
439
|
+
* Run a specific hookName for plugin x.
|
|
440
|
+
*/
|
|
441
|
+
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
442
|
+
pluginKey,
|
|
443
|
+
hookName,
|
|
444
|
+
parameters,
|
|
445
|
+
message
|
|
446
|
+
}: {
|
|
447
|
+
pluginKey: Plugin['key'];
|
|
448
|
+
hookName: H;
|
|
449
|
+
parameters: PluginParameter<H>;
|
|
450
|
+
message: string;
|
|
451
|
+
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
452
|
+
/**
|
|
453
|
+
* First non-null result stops and will return it's value.
|
|
454
|
+
*/
|
|
455
|
+
hookFirst<H extends PluginLifecycleHooks>({
|
|
456
|
+
hookName,
|
|
457
|
+
parameters,
|
|
458
|
+
skipped,
|
|
459
|
+
message
|
|
460
|
+
}: {
|
|
461
|
+
hookName: H;
|
|
462
|
+
parameters: PluginParameter<H>;
|
|
463
|
+
skipped?: ReadonlySet<Plugin> | null;
|
|
464
|
+
message: string;
|
|
465
|
+
}): Promise<SafeParseResult<H>>;
|
|
466
|
+
/**
|
|
467
|
+
* First non-null result stops and will return it's value.
|
|
468
|
+
*/
|
|
469
|
+
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
470
|
+
hookName,
|
|
471
|
+
parameters,
|
|
472
|
+
skipped,
|
|
473
|
+
message
|
|
474
|
+
}: {
|
|
475
|
+
hookName: H;
|
|
476
|
+
parameters: PluginParameter<H>;
|
|
477
|
+
skipped?: ReadonlySet<Plugin> | null;
|
|
478
|
+
message: string;
|
|
479
|
+
}): SafeParseResult<H>;
|
|
480
|
+
/**
|
|
481
|
+
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
482
|
+
*/
|
|
483
|
+
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
484
|
+
hookName,
|
|
485
|
+
parameters,
|
|
486
|
+
message
|
|
487
|
+
}: {
|
|
488
|
+
hookName: H;
|
|
489
|
+
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
490
|
+
message: string;
|
|
491
|
+
}): Promise<Awaited<TOuput>[]>;
|
|
492
|
+
/**
|
|
493
|
+
* Chains plugins
|
|
494
|
+
*/
|
|
495
|
+
hookSeq<H extends PluginLifecycleHooks>({
|
|
496
|
+
hookName,
|
|
497
|
+
parameters,
|
|
498
|
+
message
|
|
499
|
+
}: {
|
|
500
|
+
hookName: H;
|
|
501
|
+
parameters?: PluginParameter<H>;
|
|
502
|
+
message: string;
|
|
503
|
+
}): Promise<void>;
|
|
504
|
+
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
505
|
+
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
506
|
+
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
507
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
508
|
+
}
|
|
509
|
+
//#endregion
|
|
510
|
+
export { BarrelType, Config, FileManager, FileMetaBase, GetPluginFactoryOptions, Group, InputData, InputPath, Output, Plugin, PluginContext, PluginFactoryOptions, PluginKey, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, PossiblePromise, ResolveNameParams, ResolvePathParams, UserConfig, UserPlugin, UserPluginWithLifeCycle, getSource };
|
|
511
|
+
//# sourceMappingURL=PluginManager-1jPxuyQK.d.ts.map
|