@kubb/core 2.0.0-beta.4 → 2.0.0-beta.6
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/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/transformers.d.cts +55 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
- package/src/PluginManager.ts +1 -1
- package/src/utils/write.ts +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/build.ts","../src/utils/clean.ts","../src/utils/logger.ts","../src/utils/randomColour.ts","../src/utils/read.ts","../src/transformers/casing.ts","../src/transformers/combineCodes.ts","../src/transformers/createJSDocBlockText.ts","../src/transformers/escape.ts","../src/transformers/indent.ts","../src/transformers/nameSorter.ts","../src/transformers/searchAndReplace.ts","../src/transformers/transformReservedWord.ts","../src/transformers/trim.ts","../src/transformers/index.ts","../src/utils/URLPath.ts","../src/config.ts","../src/FileManager.ts","../src/utils/timeout.ts","../src/utils/write.ts","../src/BarrelManager.ts","../src/utils/TreeNode.ts","../src/utils/EventEmitter.ts","../src/utils/Queue.ts","../src/utils/uniqueName.ts","../src/errors.ts","../src/plugin.ts","../src/utils/cache.ts","../src/utils/executeStrategies.ts","../src/PromiseManager.ts","../src/PluginManager.ts","../src/Generator.ts","../src/PackageManager.ts","../../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js","../../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js","../../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js","../src/index.ts"],"names":["pc","path","default","extname","resolve","fs","switcher","files","KubbFile","name","crypto","_queue","factory","_options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AI,mBAAmB,SAAS;AAC9B,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,OAAO,cAAc;AAEpC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,GAAG,cAAc,eAAe;AAAA,IAClD;AAEA,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AAAA,EACA,YAAY,YAAqC,SAAqC;AACpF,UAAM,iBAAiB,KAAK,eAAe,UAAU;AAErD,QAAI,CAAC,gBAAgB;AACnB,aAAO;AAAA,IACT;AACA,UAAM,SAAS,OAAO,cAAc;AAEpC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,GAAG,cAAc,eAAe;AAAA,IAClD;AAEA,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AACF;AAhKSA,UAAA;AAEP;AACA;AAiFA;AAAA,WAAM,SAAC,aAA0B,YAAyD;AACxF,QAAM,eAAe;AAAA,IACnB,GAAG,YAAY,cAAc,KAAK,CAAC;AAAA,IACnC,GAAG,YAAY,iBAAiB,KAAK,CAAC;AAAA,EACxC;AAEA,MAAI,OAAO,eAAe,YAAY,aAAa,UAAU,GAAG;AAC9D,WAAO,aAAa,UAAU;AAAA,EAChC;AAEA,QAAM,oBAAoB,OAAO,KAAK,YAAY,EAAE,KAAK,SAAO,IAAI,MAAM,UAAU,CAAC;AAErF,SAAO,oBAAoB,aAAa,iBAAiB,IAAI;AAC/D;AAjGA,aADW,iBACJA,SAAoD,CAAC;AADvD,IAAM,iBAAN;;;AOUP,IAAO,cAAQ","sourcesContent":["import pc from 'picocolors'\n\nimport { clean } from './utils/clean.ts'\nimport { createLogger, LogLevel } from './utils/logger.ts'\nimport { randomPicoColour } from './utils/randomColour.ts'\nimport { read } from './utils/read.ts'\nimport { URLPath } from './utils/URLPath.ts'\nimport { isInputPath } from './config.ts'\nimport { FileManager } from './FileManager.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isPromise } from './PromiseManager.ts'\n\nimport type { KubbFile } from './FileManager.ts'\nimport type { KubbPlugin, PluginContext, PluginParameter, TransformResult } from './types.ts'\nimport type { Logger } from './utils/logger.ts'\nimport type { QueueJob } from './utils/Queue.ts'\n\ntype BuildOptions = {\n config: PluginContext['config']\n /**\n * @default Logger without the spinner\n */\n logger?: Logger\n}\n\ntype BuildOutput = {\n files: FileManager['files']\n pluginManager: PluginManager\n /**\n * Only for safeBuild\n */\n error?: Error\n}\n\nasync function transformReducer(\n this: PluginContext,\n _previousCode: string,\n result: TransformResult | Promise<TransformResult>,\n _plugin: KubbPlugin,\n): Promise<string | null> {\n return result\n}\n\nasync function setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger({ logLevel: LogLevel.silent }) } = options\n\n try {\n if (isInputPath(config) && !new URLPath(config.input.path).isURL) {\n await read(config.input.path)\n }\n } catch (e) {\n if (isInputPath(config)) {\n throw new Error(\n 'Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config ' + pc.dim(config.input.path),\n {\n cause: e,\n },\n )\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n const queueTask = async (file: KubbFile.File) => {\n const { path } = file\n\n let code: string | null = FileManager.getSource(file)\n\n const { result: loadedResult } = await pluginManager.hookFirst({\n hookName: 'load',\n parameters: [path],\n })\n if (loadedResult && isPromise(loadedResult)) {\n code = await loadedResult\n }\n if (loadedResult && !isPromise(loadedResult)) {\n code = loadedResult\n }\n\n if (code) {\n const transformedCode = await pluginManager.hookReduceArg0({\n hookName: 'transform',\n parameters: [code, path],\n reduce: transformReducer,\n })\n\n if (config.output.write || config.output.write === undefined) {\n if (file.meta?.pluginKey) {\n // run only for pluginKey defined in the meta of the file\n return pluginManager.hookForPlugin({\n pluginKey: file.meta?.pluginKey,\n hookName: 'writeFile',\n parameters: [transformedCode, path],\n })\n }\n\n return pluginManager.hookFirst({\n hookName: 'writeFile',\n parameters: [transformedCode, path],\n })\n }\n }\n }\n\n const pluginManager = new PluginManager(config, { logger, task: queueTask as QueueJob<KubbFile.ResolvedFile>, writeTimeout: 0 })\n\n pluginManager.on('execute', (executer) => {\n const { hookName, parameters, plugin } = executer\n\n if (hookName === 'writeFile' && logger.spinner) {\n const [code] = parameters as PluginParameter<'writeFile'>\n\n if (logger.logLevel === LogLevel.info) {\n logger.spinner.start(`💾 Writing`)\n }\n\n if (logger.logLevel === LogLevel.debug) {\n logger.info(`PluginKey ${pc.dim(JSON.stringify(plugin.key))} \\nwith source\\n\\n${code}`)\n }\n }\n })\n\n pluginManager.on('executed', (executer) => {\n const { hookName, plugin, output, parameters } = executer\n const messsage = `${randomPicoColour(plugin.name)} Executing ${hookName}`\n\n if (logger.logLevel === LogLevel.info && logger.spinner) {\n if (hookName === 'writeFile') {\n const [_code, path] = parameters as PluginParameter<'writeFile'>\n\n logger.spinner.suffixText = pc.dim(path)\n } else {\n logger.spinner.suffixText = messsage\n }\n }\n\n if (logger.logLevel === LogLevel.debug) {\n logger.info(messsage)\n const logs = [\n parameters && `${pc.bgWhite(`Parameters`)} ${randomPicoColour(plugin.name)} ${hookName}`,\n JSON.stringify(parameters, undefined, 2),\n output && `${pc.bgWhite('Output')} ${randomPicoColour(plugin.name)} ${hookName}`,\n output,\n ].filter(Boolean)\n\n console.log(logs.join('\\n'))\n }\n })\n\n return pluginManager\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n const { fileManager, logger } = pluginManager\n\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n if (!fileManager.isExecuting && logger.spinner) {\n logger.spinner.suffixText = ''\n logger.spinner.succeed(`💾 Writing completed`)\n }\n\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n const { fileManager, logger } = pluginManager\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n if (!fileManager.isExecuting && logger.spinner) {\n logger.spinner.suffixText = ''\n logger.spinner.succeed(`💾 Writing completed`)\n }\n } catch (e) {\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager, error: e as Error }\n }\n\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager }\n}\n","import { remove } from 'fs-extra'\n\nexport async function clean(path: string): Promise<void> {\n return remove(path)\n}\n","import pc from 'picocolors'\n\nimport type { Ora } from 'ora'\n\nexport const LogLevel = {\n silent: 'silent',\n info: 'info',\n debug: 'debug',\n} as const\n\nexport type LogLevel = keyof typeof LogLevel\n\nexport type Logger = {\n /**\n * Optional config name to show in CLI output\n */\n name?: string\n logLevel: LogLevel\n log: (message: string | null) => void\n error: (message: string | null) => void\n info: (message: string | null) => void\n warn: (message: string | null) => void\n spinner?: Ora\n logs: string[]\n}\n\ntype Props = {\n name?: string\n logLevel: LogLevel\n spinner?: Ora\n}\n\nexport function createLogger({ logLevel, name, spinner }: Props): Logger {\n const logs: string[] = []\n const log: Logger['log'] = (message) => {\n if (message && spinner) {\n spinner.text = message\n logs.push(message)\n }\n }\n\n const error: Logger['error'] = (message) => {\n if (message) {\n throw new Error(message || 'Something went wrong')\n }\n }\n\n const warn: Logger['warn'] = (message) => {\n if (message && spinner) {\n spinner.warn(pc.yellow(message))\n logs.push(message)\n }\n }\n\n const info: Logger['warn'] = (message) => {\n if (message && spinner && logLevel !== LogLevel.silent) {\n spinner.info(message)\n logs.push(message)\n }\n }\n\n const logger: Logger = {\n name,\n logLevel,\n log,\n error,\n warn,\n info,\n spinner,\n logs,\n }\n\n return logger\n}\n\nexport { default as pc } from 'picocolors'\n","import pc from 'picocolors'\nimport seedrandom from 'seedrandom'\n\nimport type { Formatter } from 'picocolors/types.ts'\n\nconst defaultColours = ['black', 'blue', 'darkBlue', 'cyan', 'gray', 'green', 'darkGreen', 'magenta', 'red', 'darkRed', 'yellow', 'darkYellow'] as const\n\nexport function randomColour(text?: string, colours = defaultColours): string {\n if (!text) {\n return 'white'\n }\n\n const random = seedrandom(text)\n const colour = colours.at(Math.floor(random() * colours.length)) || 'white'\n\n return colour\n}\n\nexport function randomPicoColour(text?: string, colors = defaultColours): string {\n const colours = pc.createColors(true)\n\n if (!text) {\n return colours.white(text)\n }\n\n const colour = randomColour(text, colors)\n const isDark = colour.includes('dark')\n const key = colour.replace('dark', '').toLowerCase() as keyof typeof colours\n const formatter: Formatter = colours[key] as Formatter\n\n if (isDark) {\n return pc.bold(formatter(text))\n }\n\n if (typeof formatter !== 'function') {\n throw new Error('Formatter for picoColor is not of type function/Formatter')\n }\n return formatter(text)\n}\n","import { basename, extname, relative } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return path.replaceAll(/\\\\/g, '/').replace('../', '').trimEnd()\n }\n\n // windows\n return path.replaceAll(/\\\\/g, '/').replace('../', '').trimEnd()\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath.replace(basename(slashedPath), basename(slashedPath, extname(filePath)))\n }\n\n return `./${slashedPath.replace(basename(slashedPath), basename(slashedPath, extname(filePath)))}`\n}\n\nconst reader = switcher(\n {\n node: async (path: string) => {\n return fs.readFile(path, { encoding: 'utf8' })\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.text()\n },\n },\n 'node',\n)\n\nconst syncReader = switcher(\n {\n node: (path: string) => {\n return fs.readFileSync(path, { encoding: 'utf8' })\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n)\n\nexport async function read(path: string): Promise<string> {\n return reader(path)\n}\n\nexport function readSync(path: string): string {\n return syncReader(path)\n}\n","import { camelCase as changeCaseCamel, camelCaseTransformMerge, pascalCase as changePascalCase, pascalCaseTransformMerge } from 'change-case'\n\nexport function camelCase(text: string): string {\n return changeCaseCamel(text, { delimiter: '', stripRegexp: /[^A-Z0-9$]/gi, transform: camelCaseTransformMerge })\n}\n\nexport function pascalCase(text: string): string {\n return changePascalCase(text, { delimiter: '', stripRegexp: /[^A-Z0-9$]/gi, transform: pascalCaseTransformMerge })\n}\n","export function combineCodes(codes: string[]): string {\n return codes.join('\\n')\n}\n","export function createJSDocBlockText({ comments }: { comments: Array<string> }): string {\n const filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return ''\n }\n\n return `/**\\n * ${filteredComments.join('\\n * ')}\\n */`\n}\n","export function escape(text?: string): string {\n return text ? text.replaceAll('`', '\\\\`') : ''\n}\n\n/**\n * Escape all characters not included in SingleStringCharacters and DoubleStringCharacters on\n * @link http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n * @link https://github.com/joliss/js-string-escape/blob/master/index.js\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function jsStringEscape(input: any): string {\n return `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n switch (character) {\n case '\"':\n case \"'\":\n case '\\\\':\n return '\\\\' + character\n // Four possible LineTerminator characters need to be escaped:\n case '\\n':\n return '\\\\n'\n case '\\r':\n return '\\\\r'\n case '\\u2028':\n return '\\\\u2028'\n case '\\u2029':\n return '\\\\u2029'\n default:\n return ''\n }\n })\n}\n","export function createIndent(size: number): string {\n return Array.from({ length: size + 1 }).join(' ')\n}\n","export function nameSorter<T extends { name: string }>(a: T, b: T): 0 | 1 | -1 {\n if (a.name < b.name) {\n return -1\n }\n if (a.name > b.name) {\n return 1\n }\n return 0\n}\n","type Options = {\n text: string\n replaceBy: string\n prefix?: string\n key: string\n searchValues?: (prefix: string, key: string) => Array<RegExp | string>\n}\n\nexport function searchAndReplace(options: Options): string {\n const { text, replaceBy, prefix = '', key } = options\n\n const searchValues = options.searchValues?.(prefix, key) || [\n `${prefix}[\"${key}\"]`,\n `${prefix}['${key}']`,\n `${prefix}[\\`${key}\\`]`,\n `${prefix}\"${key}\"`,\n `${prefix}'${key}'`,\n `${prefix}\\`${key}\\``,\n new RegExp(`${prefix}${key}`, 'g'),\n ]\n\n return searchValues.reduce((prev, searchValue) => {\n return prev.toString().replaceAll(searchValue, replaceBy)\n }, text) as string\n}\n","/**\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = [\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n\n 'Array',\n 'Date',\n 'eval',\n 'function',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n]\n\nexport function transformReservedWord(word: string): string {\n if ((word && reservedWords.includes(word)) || word?.match(/^\\d/)) {\n return `_${word}`\n }\n\n return word\n}\n","export function trim(text: string): string {\n return text.replaceAll(/\\n/g, '').trim()\n}\n\nexport function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import { camelCase, pascalCase } from './casing.ts'\nimport { combineCodes } from './combineCodes.ts'\nimport { createJSDocBlockText } from './createJSDocBlockText.ts'\nimport { escape, jsStringEscape } from './escape.ts'\nimport { createIndent } from './indent.ts'\nimport { nameSorter } from './nameSorter.ts'\nimport { searchAndReplace } from './searchAndReplace.ts'\nimport { transformReservedWord } from './transformReservedWord.ts'\nimport { trim, trimExtName } from './trim.ts'\n\nexport { camelCase, pascalCase } from './casing.ts'\nexport { combineCodes } from './combineCodes.ts'\nexport { createJSDocBlockText } from './createJSDocBlockText.ts'\nexport { escape, jsStringEscape } from './escape.ts'\nexport { createIndent } from './indent.ts'\nexport { nameSorter } from './nameSorter.ts'\nexport { searchAndReplace } from './searchAndReplace.ts'\nexport { transformReservedWord } from './transformReservedWord.ts'\nexport { trim, trimExtName } from './trim.ts'\n\nexport default {\n combineCodes,\n escape,\n jsStringEscape,\n createIndent,\n transformReservedWord,\n nameSorter,\n searchAndReplace,\n trim,\n trimExtName,\n JSDoc: {\n createJSDocBlockText,\n },\n camelCase,\n pascalCase,\n} as const\n","import transformers from '../transformers/index.ts'\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\nexport class URLPath {\n path: string\n\n constructor(path: string) {\n this.path = path\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(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, curr) => {\n const pathParam = replacer\n ? replacer(transformers.camelCase(curr))\n : transformers.camelCase(curr)\n const replacement = `\\${${pathParam}}`\n\n return prev.replace(curr, replacement)\n }, this.path)\n }\n\n return `\\`${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 const pathParam = replacer\n ? replacer(transformers.camelCase(item))\n : transformers.camelCase(item)\n\n params[pathParam] = pathParam\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 type { PossiblePromise } from '@kubb/types'\nimport type { CLIOptions, InputPath, KubbConfig, KubbUserConfig } from './types.ts'\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link KubbConfig} object, or a function that returns it.\n * The function receives a {@link ConfigEnv} object that exposes two properties:\n */\nexport function defineConfig(\n options:\n | PossiblePromise<KubbUserConfig | Array<KubbUserConfig>>\n | ((\n /** The options derived from the CLI flags */\n cliOptions: CLIOptions,\n ) => PossiblePromise<KubbUserConfig | Array<KubbUserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: KubbConfig | undefined): result is KubbConfig<InputPath> {\n return !!result && 'path' in (result as any)\n}\n","/* eslint-disable @typescript-eslint/no-namespace */\nimport crypto from 'node:crypto'\nimport { extname } from 'node:path'\n\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\n\nimport isEqual from 'lodash.isequal'\nimport { orderBy } from 'natural-orderby'\n\nimport transformers from './transformers/index.ts'\nimport { getRelativePath, read } from './utils/read.ts'\nimport { timeout } from './utils/timeout.ts'\nimport { write } from './utils/write.ts'\nimport { BarrelManager } from './BarrelManager.ts'\n\nimport type { GreaterThan } from '@kubb/types'\nimport type { BarrelManagerOptions } from './BarrelManager.ts'\nimport type { KubbPlugin } from './types.ts'\nimport type { Queue, QueueJob } from './utils/Queue.ts'\n\ntype BasePath<T extends string = string> = `${T}/`\n\nexport namespace KubbFile {\n export type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name:\n | string\n | Array<\n string | {\n propertyName: string\n name?: string\n }\n >\n /**\n * Path for the import\n * @xample '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * When root is set it will get the path with relative getRelativePath(root, path).\n */\n root?: string\n }\n\n export type Export = {\n /**\n * Export name to be used.\n * @example [\"useState\"]\n * @example \"React\"\n */\n name?: string | Array<string>\n /**\n * Path for the import.\n * @xample '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.\n */\n asAlias?: boolean\n }\n\n export declare const dataTagSymbol: unique symbol\n export type DataTag<Type, Value> = Type & {\n [dataTagSymbol]: Value\n }\n\n export type UUID = string\n export type Source = string\n\n export type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\n export type Mode = 'file' | 'directory'\n\n /**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n export type BaseName = `${string}${Extname}`\n\n /**\n * Path will be full qualified path to a specified file\n */\n export type Path = string\n\n export type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`\n\n export type OptionalPath = Path | undefined | null\n\n export type FileMetaBase = {\n pluginKey?: KubbPlugin['key']\n }\n\n export type File<\n TMeta extends FileMetaBase = FileMetaBase,\n TBaseName extends BaseName = BaseName,\n > = {\n /**\n * Unique identifier to reuse later\n * @default crypto.randomUUID()\n */\n id?: string\n /**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: TBaseName\n /**\n * Path will be full qualified path to a specified file\n */\n path: AdvancedPath<TBaseName> | Path\n source: Source\n imports?: Import[]\n exports?: Export[]\n /**\n * This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists\n * This will also ignore the combinefiles utils\n * @default `false`\n */\n override?: boolean\n /**\n * Use extra meta, this is getting used to generate the barrel/index files.\n */\n meta?: TMeta\n /**\n * This will override `process.env[key]` inside the `source`, see `getFileSource`.\n */\n env?: NodeJS.ProcessEnv\n }\n\n export type ResolvedFile<\n TMeta extends FileMetaBase = FileMetaBase,\n TBaseName extends BaseName = BaseName,\n > = KubbFile.File<TMeta, TBaseName> & {\n /**\n * @default crypto.randomUUID()\n */\n id: UUID\n }\n}\n\ntype CacheItem = KubbFile.ResolvedFile & {\n cancel?: () => void\n}\n\ntype AddResult<T extends Array<KubbFile.File>> = Promise<\n Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>\n>\n\ntype AddIndexesProps = {\n root: KubbFile.Path\n extName?: KubbFile.Extname\n options?: BarrelManagerOptions\n meta?: KubbFile.File['meta']\n}\n\ntype Options = {\n queue?: Queue\n task?: QueueJob<KubbFile.ResolvedFile>\n /**\n * Timeout between writes\n */\n timeout?: number\n}\n\nexport class FileManager {\n #cache: Map<KubbFile.Path, CacheItem[]> = new Map()\n\n #task?: QueueJob<KubbFile.ResolvedFile>\n #isWriting = false\n /**\n * Timeout between writes\n */\n #timeout: number = 0\n #queue?: Queue\n\n constructor(options?: Options) {\n if (options) {\n this.#task = options.task\n this.#queue = options.queue\n this.#timeout = options.timeout || 0\n }\n\n return this\n }\n\n get files(): Array<KubbFile.File> {\n const files: Array<KubbFile.File> = []\n this.#cache.forEach((item) => {\n files.push(...item.flat(1))\n })\n\n return files\n }\n get isExecuting(): boolean {\n return this.#queue?.hasJobs ?? this.#isWriting ?? false\n }\n\n #validate(file: KubbFile.File): void {\n if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {\n throw new Error(`${file.path} should end with the baseName ${file.baseName}`)\n }\n }\n\n async add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(\n ...files: T\n ): AddResult<T> {\n const promises = files.map((file) => {\n // this.#validate(file)\n\n if (file.override) {\n return this.#add(file)\n }\n\n return this.#addOrAppend(file)\n })\n\n const resolvedFiles = await Promise.all(promises)\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 #add(file: KubbFile.File): Promise<KubbFile.ResolvedFile> {\n const controller = new AbortController()\n const resolvedFile: KubbFile.ResolvedFile = { id: crypto.randomUUID(), ...file }\n\n this.#cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }])\n\n if (this.#queue) {\n await this.#queue.run(\n async () => {\n return this.#task?.(resolvedFile)\n },\n { controller },\n )\n }\n\n return resolvedFile\n }\n\n async #addOrAppend(file: KubbFile.File): Promise<KubbFile.ResolvedFile> {\n const previousCaches = this.#cache.get(file.path)\n const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : undefined\n\n if (previousCache) {\n this.#cache.delete(previousCache.path)\n\n return this.#add({\n ...file,\n source: previousCache.source && file.source ? `${previousCache.source}\\n${file.source}` : '',\n imports: [...(previousCache.imports || []), ...(file.imports || [])],\n exports: [...(previousCache.exports || []), ...(file.exports || [])],\n env: { ...(previousCache.env || {}), ...(file.env || {}) },\n })\n }\n return this.#add(file)\n }\n\n async addIndexes({ root, extName = '.ts', meta, options = {} }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined> {\n const barrelManager = new BarrelManager(options)\n\n const files = barrelManager.getIndexes(root, extName)\n\n if (!files) {\n return undefined\n }\n\n return await Promise.all(\n files.map((file) => {\n return this.#addOrAppend({\n ...file,\n meta: meta ? meta : file.meta,\n })\n }),\n )\n }\n\n getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined {\n let cache: KubbFile.File | undefined\n\n this.#cache.forEach((files) => {\n cache = files.find((item) => item.id === UUID)\n })\n return cache\n }\n\n get(path: KubbFile.Path): Array<KubbFile.File> | undefined {\n return this.#cache.get(path)\n }\n\n remove(path: KubbFile.Path): void {\n const cacheItem = this.get(path)\n if (!cacheItem) {\n return\n }\n\n this.#cache.delete(path)\n }\n\n async write(...params: Parameters<typeof write>): Promise<string | undefined> {\n if (!this.#isWriting) {\n this.#isWriting = true\n\n const text = await write(...params)\n\n this.#isWriting = false\n return text\n }\n\n await timeout(this.#timeout)\n\n return this.write(...params)\n }\n\n async read(...params: Parameters<typeof read>): Promise<string> {\n return read(...params)\n }\n\n // statics\n\n static getSource<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(file: KubbFile.File<TMeta>): string {\n if (!FileManager.isExtensionAllowed(file.baseName)) {\n return file.source\n }\n\n const exports = file.exports ? combineExports(file.exports) : []\n const imports = file.imports ? combineImports(file.imports, exports, file.source) : []\n\n const importNodes = imports.filter(item => {\n // isImportNotNeeded\n // trim extName\n return item.path !== transformers.trimExtName(file.path)\n }).map((item) => {\n return factory.createImportDeclaration({\n name: item.name,\n path: item.root ? getRelativePath(item.root, item.path) : item.path,\n isTypeOnly: item.isTypeOnly,\n })\n })\n const exportNodes = exports.map((item) =>\n factory.createExportDeclaration({\n name: item.name,\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n })\n )\n\n return [print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join('\\n')\n }\n static combineFiles<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(files: Array<KubbFile.File<TMeta> | null>): Array<KubbFile.File<TMeta>> {\n return files.filter(Boolean).reduce((acc, file: KubbFile.File<TMeta>) => {\n const prevIndex = acc.findIndex((item) => item.path === file.path)\n\n if (prevIndex === -1) {\n return [...acc, file]\n }\n\n const prev = acc[prevIndex]\n\n if (prev && file.override) {\n acc[prevIndex] = {\n imports: [],\n exports: [],\n ...file,\n }\n return acc\n }\n\n if (prev) {\n acc[prevIndex] = {\n ...file,\n source: prev.source && file.source ? `${prev.source}\\n${file.source}` : '',\n imports: [...(prev.imports || []), ...(file.imports || [])],\n exports: [...(prev.exports || []), ...(file.exports || [])],\n env: { ...(prev.env || {}), ...(file.env || {}) },\n }\n }\n\n return acc\n }, [] as Array<KubbFile.File<TMeta>>)\n }\n static getMode(path: string | undefined | null): KubbFile.Mode {\n if (!path) {\n return 'directory'\n }\n return extname(path) ? 'file' : 'directory'\n }\n\n static get extensions(): Array<KubbFile.Extname> {\n return ['.js', '.ts', '.tsx']\n }\n\n static isExtensionAllowed(baseName: string): boolean {\n return FileManager.extensions.some((extension) => baseName.endsWith(extension))\n }\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n const combinedExports = orderBy(exports, [(v) => !v.isTypeOnly], ['asc']).reduce((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 && isEqual(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 && isEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\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 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 }, [] as Array<KubbFile.Export>)\n\n return orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ['desc', 'desc'])\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n const combinedImports = orderBy(imports, [(v) => !v.isTypeOnly], ['asc']).reduce((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) => name && !!source.includes(name)\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\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 && isEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual(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 if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\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 if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n }, [] as Array<KubbFile.Import>)\n\n return orderBy(combinedImports, [(v) => !v.isTypeOnly], ['desc'])\n}\n\nfunction getEnvSource(source: string, env: NodeJS.ProcessEnv | undefined): string {\n if (!env) {\n return source\n }\n\n const keys = Object.keys(env)\n\n if (!keys.length) {\n return source\n }\n\n return keys.reduce((prev, key: string) => {\n const environmentValue = env[key]\n const replaceBy = environmentValue ? `'${environmentValue.replaceAll('\"', '')?.replaceAll(\"'\", '')}'` : 'undefined'\n\n if (key.toUpperCase() !== key) {\n throw new TypeError(`Environment should be in upperCase for ${key}`)\n }\n\n if (typeof replaceBy === 'string') {\n prev = transformers.searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: 'process.env', key })\n // removes `declare const ...`\n prev = transformers.searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*\\n`, 'ig'), ''), replaceBy, key })\n }\n\n return prev\n }, source)\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","import { dirname, resolve, extname } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nasync function saveCreateDirectory(path: string): Promise<void> {\n // resolve the full path and get just the directory, ignoring the file and extension\n const passedPath = dirname(resolve(path))\n // make the directory, recursively. Theoretically, if every directory in the path exists, this won't do anything.\n await fs.mkdir(passedPath, { recursive: true })\n}\n\nconst writer = switcher(\n {\n node: async (path: string, data: string) => {\n try {\n await fs.stat(resolve(path))\n const oldContent = await fs.readFile(resolve(path), { encoding: 'utf-8' })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await saveCreateDirectory(path)\n await fs.writeFile(resolve(path), data, { encoding: 'utf-8' })\n\n const savedData = await fs.readFile(resolve(path), { encoding: 'utf-8' })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n },\n bun: async (path: string, data: string) => {\n try {\n await saveCreateDirectory(path)\n await Bun.write(resolve(path), data)\n\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n } catch (e) {\n console.log(e, resolve(path))\n }\n },\n },\n 'node',\n)\n\nexport async function write(data: string, path: string): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n return writer(path, data.trim())\n}\n","import path from 'path'\n\nimport { TreeNode } from './utils/TreeNode.ts'\n\nimport type { DirectoryTreeOptions } from 'directory-tree'\nimport type { KubbFile } from './FileManager.ts'\n\ntype BarrelData = { type: KubbFile.Mode; path: KubbFile.Path; name: string }\n\nexport type BarrelManagerOptions = {\n treeNode?: DirectoryTreeOptions\n isTypeOnly?: boolean\n filter?: (file: KubbFile.File) => boolean\n map?: (file: KubbFile.File) => KubbFile.File\n includeExt?: boolean\n output?: string\n}\n\nexport class BarrelManager {\n #options: BarrelManagerOptions = {}\n\n constructor(options: BarrelManagerOptions = {}) {\n this.#options = options\n\n return this\n }\n\n getIndexes(\n root: string,\n extName?: KubbFile.Extname,\n ): Array<KubbFile.File> | null {\n const { treeNode = {}, isTypeOnly, filter, map, output, includeExt } = this.#options\n\n const extMapper: Record<KubbFile.Extname, DirectoryTreeOptions> = {\n '.ts': {\n extensions: /\\.ts/,\n exclude: [/schemas/, /json/],\n },\n '.json': {\n extensions: /\\.json/,\n exclude: [],\n },\n }\n const tree = TreeNode.build<BarrelData>(root, { ...(extMapper[extName as keyof typeof extMapper] || {}), ...treeNode })\n\n if (!tree) {\n return null\n }\n\n const fileReducer = (files: Array<KubbFile.File>, currentTree: typeof tree) => {\n if (!currentTree.children) {\n return []\n }\n\n if (currentTree.children?.length > 1) {\n const indexPath: KubbFile.Path = path.resolve(currentTree.data.path, 'index.ts')\n const exports: KubbFile.Export[] = currentTree.children\n .filter(Boolean)\n .map((file) => {\n const importPath: string = file.data.type === 'directory' ? `./${file.data.name}/index` : `./${file.data.name.replace(/\\.[^.]*$/, '')}`\n\n if (importPath.includes('index') && file.data.type === 'file') {\n return undefined\n }\n\n return {\n path: includeExt ? `${importPath}${extName}` : importPath,\n isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n\n files.push({\n path: indexPath,\n baseName: 'index.ts',\n source: '',\n exports: output\n ? exports?.filter((item) => {\n return item.path.endsWith(output.replace(/\\.[^.]*$/, ''))\n })\n : exports,\n })\n } else {\n currentTree.children?.forEach((child) => {\n const indexPath = path.resolve(currentTree.data.path, 'index.ts')\n const importPath = child.data.type === 'directory' ? `./${child.data.name}/index` : `./${child.data.name.replace(/\\.[^.]*$/, '')}`\n\n const exports = [\n {\n path: includeExt\n ? `${importPath}${extName}`\n : importPath,\n isTypeOnly,\n },\n ]\n\n files.push({\n path: indexPath,\n baseName: 'index.ts',\n source: '',\n exports: output\n ? exports?.filter((item) => {\n return item.path.endsWith(output.replace(/\\.[^.]*$/, ''))\n })\n : exports,\n })\n })\n }\n\n currentTree.children.forEach((childItem) => {\n fileReducer(files, childItem)\n })\n\n return files\n }\n\n const files = fileReducer([], tree).reverse()\n\n const filteredFiles = filter ? files.filter(filter) : files\n\n return map ? filteredFiles.map(map) : filteredFiles\n }\n}\n","import dirTree from 'directory-tree'\n\nimport { FileManager } from '../FileManager.ts'\n\nimport type { DirectoryTree, DirectoryTreeOptions } from 'directory-tree'\n\nexport type TreeNodeOptions = DirectoryTreeOptions\n\nexport class TreeNode<T = unknown> {\n public data: T\n\n public parent?: TreeNode<T>\n\n public children: Array<TreeNode<T>> = []\n\n constructor(data: T, parent?: TreeNode<T>) {\n this.data = data\n this.parent = parent\n return this\n }\n\n addChild(data: T): TreeNode<T> {\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 find(data?: T): TreeNode<T> | null {\n if (!data) {\n return null\n }\n\n if (data === this.data) {\n return this\n }\n\n if (this.children?.length) {\n for (let i = 0, { length } = this.children, target: TreeNode<T> | null = null; i < length; i++) {\n target = this.children[i]!.find(data)\n if (target) {\n return target\n }\n }\n }\n\n return null\n }\n\n get leaves(): TreeNode<T>[] {\n if (!this.children || this.children.length === 0) {\n // this is a leaf\n return [this]\n }\n\n // if not a leaf, return all children's leaves recursively\n const leaves: TreeNode<T>[] = []\n if (this.children) {\n for (let i = 0, { length } = this.children; i < length; i++) {\n // eslint-disable-next-line prefer-spread\n leaves.push.apply(leaves, this.children[i]!.leaves)\n }\n }\n return leaves\n }\n\n get root(): TreeNode<T> {\n if (!this.parent) {\n return this\n }\n return this.parent.root\n }\n\n forEach(callback: (treeNode: TreeNode<T>) => 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 public static build<T = unknown>(path: string, options: TreeNodeOptions = {}): TreeNode<T> | null {\n try {\n const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean)\n const filteredTree = dirTree(path, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] })\n\n if (!filteredTree) {\n return null\n }\n\n const treeNode = new TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || FileManager.getMode(filteredTree.path) })\n\n const recurse = (node: typeof treeNode, item: DirectoryTree) => {\n const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || FileManager.getMode(item.path) })\n\n if (item.children?.length) {\n item.children?.forEach((child) => {\n recurse(subNode, child)\n })\n }\n }\n\n filteredTree.children?.forEach((child) => recurse(treeNode, child))\n\n return treeNode as TreeNode<T>\n } catch (e) {\n throw new Error('Something went wrong with creating index files with the TreehNode class', { cause: e })\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-argument */\nimport { EventEmitter as NodeEventEmitter } from 'node:events'\n\nexport class EventEmitter<TEvents extends Record<string, any>> {\n constructor() {\n this.#emitter.setMaxListeners(100)\n }\n #emitter = new NodeEventEmitter()\n\n emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void {\n this.#emitter.emit(eventName, ...(eventArg as []))\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import crypto from 'node:crypto'\nimport { performance } from 'node:perf_hooks'\n\nimport { EventEmitter } from './EventEmitter.ts'\n\nexport type QueueJob<T = unknown> = {\n (...args: unknown[]): Promise<T | void>\n}\n\ntype RunOptions = {\n controller?: AbortController\n name?: string\n description?: string\n}\n\ntype QueueItem = {\n reject: <T>(reason?: T) => void\n resolve: <T>(value: T | PromiseLike<T>) => void\n job: QueueJob<unknown>\n} & Required<RunOptions>\n\ntype Events = {\n jobDone: [result: unknown]\n jobFailed: [error: Error]\n}\n\nexport class Queue {\n #queue: QueueItem[] = []\n readonly eventEmitter: EventEmitter<Events> = new EventEmitter()\n\n #workerCount = 0\n\n #maxParallel: number\n #debug = false\n\n constructor(maxParallel: number, debug = false) {\n this.#maxParallel = maxParallel\n this.#debug = debug\n }\n\n run<T>(job: QueueJob<T>, options: RunOptions = { controller: new AbortController(), name: crypto.randomUUID(), description: '' }): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const item = { reject, resolve, job, name: options.name, description: options.description || options.name } as QueueItem\n\n options.controller?.signal.addEventListener('abort', () => {\n this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name)\n\n reject('Aborted')\n })\n\n this.#queue.push(item)\n this.#work()\n })\n }\n\n runSync<T>(job: QueueJob<T>, options: RunOptions = { controller: new AbortController(), name: crypto.randomUUID(), description: '' }): void {\n new Promise<T>((resolve, reject) => {\n const item = { reject, resolve, job, name: options.name, description: options.description || options.name } as QueueItem\n\n options.controller?.signal.addEventListener('abort', () => {\n this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name)\n })\n\n this.#queue.push(item)\n this.#work()\n })\n }\n\n get hasJobs(): boolean {\n return this.#workerCount > 0 || this.#queue.length > 0\n }\n\n get count(): number {\n return this.#workerCount\n }\n\n #work(): void {\n if (this.#workerCount >= this.#maxParallel) {\n return\n }\n\n this.#workerCount++\n\n let entry: QueueItem | undefined\n while ((entry = this.#queue.shift())) {\n const { reject, resolve, job, name, description } = entry\n\n if (this.#debug) {\n performance.mark(name + '_start')\n }\n\n job()\n .then((result) => {\n this.eventEmitter.emit('jobDone', result)\n\n resolve(result)\n\n if (this.#debug) {\n performance.mark(name + '_stop')\n performance.measure(description, name + '_start', name + '_stop')\n }\n })\n .catch((err) => {\n this.eventEmitter.emit('jobFailed', err as Error)\n reject(err)\n })\n }\n this.#workerCount--\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","/**\n * Behaves as an Error to log a warning in the console(still stops the execution)\n */\nexport class Warning extends Error {\n constructor(message?: string, options?: { cause: Error }) {\n super(message, { cause: options?.cause })\n\n this.name = 'Warning'\n }\n}\n\nexport class ValidationPluginError extends Error {}\n","import path from 'node:path'\n\nimport { createPluginCache } from './utils/cache.ts'\n\nimport type { FileManager } from './FileManager.ts'\nimport type { PluginManager } from './PluginManager.ts'\nimport type { KubbPlugin, KubbUserPluginWithLifeCycle, PluginContext, PluginFactoryOptions } from './types.ts'\n\ntype KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => KubbUserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>) {\n return (options: T['options']): ReturnType<KubbPluginFactory<T>> => {\n return factory(options)\n }\n}\n\ntype Options = {\n config: PluginContext['config']\n fileManager: FileManager\n pluginManager: PluginManager\n resolvePath: PluginContext['resolvePath']\n resolveName: PluginContext['resolveName']\n logger: PluginContext['logger']\n getPlugins: () => KubbPlugin[]\n plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type CorePluginOptions = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginName = 'core' satisfies CorePluginOptions['name']\nexport const pluginKey: CorePluginOptions['key'] = [pluginName] satisfies CorePluginOptions['key']\n\nexport const definePlugin = createPlugin<CorePluginOptions>((options) => {\n const { fileManager, pluginManager, resolvePath, resolveName, logger } = options\n\n return {\n name: pluginName,\n options,\n key: ['core'],\n\n api() {\n return {\n get config() {\n return options.config\n },\n get plugins() {\n return options.getPlugins()\n },\n get plugin() {\n // see pluginManger.#execute where we override with `.call` the this with the correct plugin\n return options.plugin as NonNullable<Options['plugin']>\n },\n logger,\n fileManager,\n pluginManager,\n async addFile(...files) {\n const resolvedFiles = await fileManager.add(...files)\n\n if (!Array.isArray(resolvedFiles)) {\n return [resolvedFiles]\n }\n\n return resolvedFiles\n },\n resolvePath,\n resolveName,\n cache: createPluginCache(),\n }\n },\n resolvePath(baseName) {\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, baseName)\n },\n resolveName(name) {\n return name\n },\n }\n})\n","import type { PluginCache } from '../types.ts'\n\nexport interface Cache<TStore extends object = object> {\n delete(id: keyof TStore): boolean\n get(id: keyof TStore): TStore[keyof TStore] | null\n has(id: keyof TStore): boolean\n set(id: keyof TStore, value: unknown): void\n}\n\nexport function createPluginCache<TStore extends PluginCache>(Store: TStore = Object.create(null) as TStore): Cache<TStore> {\n return {\n set(id, value): void {\n Store[id] = [0, value] as TStore[keyof TStore]\n },\n get(id): TStore[keyof TStore] | null {\n const item = Store[id]\n if (!item) {\n return null\n }\n item[0] = 0\n return item[1] as TStore[keyof TStore]\n },\n has(id): boolean {\n const item = Store[id]\n if (!item) {\n return false\n }\n item[0] = 0\n return true\n },\n delete(id: keyof TStore): boolean {\n return delete Store[id]\n },\n }\n}\n","/* eslint-disable unused-imports/no-unused-vars */\n/* eslint-disable @typescript-eslint/no-unused-vars */\ntype PromiseFunc<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2\n\nexport type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc<infer X, infer Y>> ? X | Y : never\n\nexport function noReturn(): void {}\n\ntype SeqOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Array<Awaited<ValueOfPromiseFuncArray<TInput>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(\n promises: TInput,\n): TOutput {\n return promises.filter(Boolean).reduce(\n (promise, func) => {\n if (typeof func !== 'function') {\n throw new Error('HookSeq needs a function that returns a promise `() => Promise<unknown>`')\n }\n\n return promise.then((state) => {\n const calledFunc = func(state as TValue)\n\n if (calledFunc) {\n return calledFunc.then(Array.prototype.concat.bind(state))\n }\n })\n },\n Promise.resolve([] as unknown),\n ) as TOutput\n}\n\ntype HookFirstOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>\n\n/**\n * Chains promises, first non-null result stops and returns\n */\nexport function hookFirst<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookFirstOutput<TInput, TValue>>(\n promises: TInput,\n nullCheck = (state: any) => state !== null,\n): TOutput {\n let promise: Promise<unknown> = Promise.resolve(null) as Promise<unknown>\n\n for (const func of promises.filter(Boolean)) {\n promise = promise.then((state) => {\n if (nullCheck(state)) {\n return state\n }\n\n const calledFunc = func(state as TValue)\n\n return calledFunc\n })\n }\n\n return promise as TOutput\n}\n\ntype HookParallelOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>\n\n/**\n * Run promises in parallel with allSettled\n */\nexport function hookParallel<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookParallelOutput<TInput, TValue>>(\n promises: TInput,\n): TOutput {\n return Promise.allSettled(promises.filter(Boolean).map(promise => promise())) as TOutput\n}\n\nexport type Strategy = 'seq' | 'first' | 'parallel'\n\nexport type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc<TValue, null>>, TValue> = TStrategy extends 'first'\n ? HookFirstOutput<TInput, TValue>\n : TStrategy extends 'seq' ? SeqOutput<TInput, TValue>\n : TStrategy extends 'parallel' ? HookParallelOutput<TInput, TValue>\n : never\n\n// tests\n\ntype test = ValueOfPromiseFuncArray<Array<PromiseFunc<number, null>>>\n// ^?\n","import { hookFirst, hookParallel, hookSeq } from './utils/executeStrategies.ts'\n\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Strategy, StrategySwitch } from './utils/executeStrategies.ts'\n\ntype PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2\n\ntype Options<TState = any> = {\n nullCheck?: (state: TState) => boolean\n}\n\nexport class PromiseManager<TState = any> {\n #options: Options<TState> = {}\n\n constructor(options: Options<TState> = {}) {\n this.#options = options\n\n return this\n }\n\n run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(\n strategy: TStrategy,\n promises: TInput,\n ): TOutput {\n if (strategy === 'seq') {\n return hookSeq<TInput, TValue, TOutput>(promises)\n }\n\n if (strategy === 'first') {\n return hookFirst<TInput, TValue, TOutput>(promises, this.#options.nullCheck)\n }\n\n if (strategy === 'parallel') {\n return hookParallel<TInput, TValue, TOutput>(promises)\n }\n\n throw new Error(`${strategy} not implemented`)\n }\n}\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","/* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/no-unsafe-argument */\n\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { LogLevel } from './utils/logger.ts'\nimport { Queue } from './utils/Queue.ts'\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\nimport { ValidationPluginError } from './errors.ts'\nimport { FileManager } from './FileManager.ts'\nimport { definePlugin as defineCorePlugin } from './plugin.ts'\nimport { isPromise, isPromiseRejectedResult } from './PromiseManager.ts'\nimport { PromiseManager } from './PromiseManager.ts'\n\nimport type { PossiblePromise } from '@kubb/types'\nimport type { KubbFile } from './FileManager.ts'\nimport type { CorePluginOptions } from './plugin.ts'\nimport type {\n GetPluginFactoryOptions,\n KubbConfig,\n KubbPlugin,\n KubbPluginWithLifeCycle,\n KubbUserPlugin,\n KubbUserPluginWithLifeCycle,\n PluginFactoryOptions,\n PluginLifecycle,\n PluginLifecycleHooks,\n PluginParameter,\n ResolveNameParams,\n ResolvePathParams,\n} from './types.ts'\nimport type { Logger } from './utils/logger.ts'\nimport type { QueueJob } from './utils/Queue.ts'\n\ntype RequiredPluginLifecycle = Required<PluginLifecycle>\n\n/**\n * Get the type of the first argument in a function.\n * @example Arg0<(a: string, b: number) => void> -> string\n */\ntype Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0]\n\ntype Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq'\n\ntype Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {\n strategy: Strategy\n hookName: H\n plugin: KubbPlugin\n parameters?: unknown[] | undefined\n output?: unknown\n}\n\ntype ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H]\n\ntype SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {\n result: Result\n plugin: KubbPlugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n logger: Logger\n\n /**\n * Task for the FileManager\n */\n task: QueueJob<KubbFile.ResolvedFile>\n /**\n * Timeout between writes in the FileManager\n */\n writeTimeout?: number\n}\n\ntype Events = {\n execute: [executer: Executer]\n executed: [executer: Executer]\n error: [error: Error]\n}\n\nexport class PluginManager {\n readonly plugins: KubbPluginWithLifeCycle[]\n readonly fileManager: FileManager\n readonly eventEmitter: EventEmitter<Events> = new EventEmitter()\n\n readonly queue: Queue\n readonly config: KubbConfig\n\n readonly executed: Executer[] = []\n readonly logger: Logger\n readonly #core: KubbPlugin<CorePluginOptions>\n\n readonly #usedPluginNames: Record<string, number> = {}\n readonly #promiseManager: PromiseManager\n\n constructor(config: KubbConfig, options: Options) {\n this.config = config\n this.logger = options.logger\n this.queue = new Queue(100, this.logger.logLevel === LogLevel.debug)\n this.fileManager = new FileManager({ task: options.task, queue: this.queue, timeout: options.writeTimeout })\n this.#promiseManager = new PromiseManager({ nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result })\n\n const plugins = config.plugins || []\n\n const core = defineCorePlugin({\n config,\n logger: this.logger,\n pluginManager: this,\n fileManager: this.fileManager,\n resolvePath: this.resolvePath.bind(this),\n resolveName: this.resolveName.bind(this),\n getPlugins: this.#getSortedPlugins.bind(this),\n })\n\n // call core.api.call with empty context so we can transform `api()` to `api: {}`\n this.#core = this.#parse(core as unknown as KubbUserPlugin, this as any, core.api.call(null as any)) as KubbPlugin<CorePluginOptions>\n\n this.plugins = [this.#core, ...plugins].map((plugin) => {\n return this.#parse(plugin as KubbUserPlugin, this, this.#core.api)\n })\n\n return this\n }\n\n resolvePath = <TOptions = object>(params: ResolvePathParams<TOptions>): KubbFile.OptionalPath => {\n if (params.pluginKey) {\n const paths = this.hookForPluginSync({\n pluginKey: params.pluginKey,\n hookName: 'resolvePath',\n parameters: [params.baseName, params.directory, params.options as object],\n })\n\n if (paths && paths?.length > 1 && this.logger.logLevel === LogLevel.debug) {\n this.logger.warn(\n `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'} is not unique enough\\n\\nPaths: ${\n JSON.stringify(paths, undefined, 2)\n }\\n\\nFalling back on the first item.\\n`,\n )\n }\n\n return paths?.at(0)\n }\n return this.hookFirstSync({\n hookName: 'resolvePath',\n parameters: [params.baseName, params.directory, params.options as object],\n }).result\n }\n\n resolveName = (params: ResolveNameParams): string => {\n if (params.pluginKey) {\n const names = this.hookForPluginSync({\n pluginKey: params.pluginKey,\n hookName: 'resolveName',\n parameters: [params.name, params.type],\n })\n\n if (names && names?.length > 1 && this.logger.logLevel === LogLevel.debug) {\n this.logger.warn(\n `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'} is not unique enough\\n\\nNames: ${\n JSON.stringify(names, undefined, 2)\n }\\n\\nFalling back on the first item.\\n`,\n )\n }\n\n return transformReservedWord(names?.at(0) || params.name)\n }\n\n const name = this.hookFirstSync({\n hookName: 'resolveName',\n parameters: [params.name, params.type],\n }).result\n\n return transformReservedWord(name)\n }\n\n on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n this.eventEmitter.on(eventName, handler as any)\n }\n\n /**\n * Run only hook for a specific plugin name\n */\n hookForPlugin<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: KubbPlugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Promise<Array<ReturnType<ParseResult<H>> | null>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n const promises = plugins\n .map((plugin) => {\n return this.#execute<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n })\n .filter(Boolean)\n\n return Promise.all(promises)\n }\n\n hookForPluginSync<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: KubbPlugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Array<ReturnType<ParseResult<H>>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n return plugins\n .map((plugin) => {\n return this.#executeSync<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n })\n .filter(Boolean)\n }\n\n /**\n * Chains, first non-null result stops and returns\n */\n async hookFirst<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<KubbPlugin> | null\n }): Promise<SafeParseResult<H>> {\n const promises = this.#getSortedPlugins().filter(plugin => {\n return skipped ? skipped.has(plugin) : true\n }).map((plugin) => {\n return async () => {\n const value = await this.#execute<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n\n return Promise.resolve(\n {\n plugin,\n result: value,\n } as SafeParseResult<H>,\n )\n }\n })\n\n return this.#promiseManager.run('first', promises)\n }\n\n /**\n * Chains, first non-null result stops and returns\n */\n hookFirstSync<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<KubbPlugin> | null\n }): SafeParseResult<H> {\n let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n\n for (const plugin of this.#getSortedPlugins()) {\n if (skipped && skipped.has(plugin)) {\n continue\n }\n\n parseResult = {\n result: this.#executeSync<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n }),\n plugin,\n } as SafeParseResult<H>\n\n if (parseResult?.result != null) {\n break\n }\n }\n return parseResult\n }\n\n /**\n * Parallel, runs all plugins\n */\n async hookParallel<H extends PluginLifecycleHooks, TOuput = void>({\n hookName,\n parameters,\n }: {\n hookName: H\n parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined\n }): Promise<Awaited<TOuput>[]> {\n const promises = this.#getSortedPlugins().map((plugin) => {\n return () => this.#execute({ strategy: 'hookParallel', hookName, parameters, plugin }) as Promise<TOuput>\n })\n\n const results = await this.#promiseManager.run('parallel', promises)\n\n results\n .forEach((result, index) => {\n if (isPromiseRejectedResult<Error>(result)) {\n const plugin = this.#getSortedPlugins()[index]\n\n this.#catcher<H>(result.reason, plugin, hookName)\n }\n })\n\n return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n }\n\n /**\n * Chains, reduces returned value, handling the reduced value as the first hook argument\n */\n hookReduceArg0<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n reduce,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise<Argument0<H> | null>\n }): Promise<Argument0<H>> {\n const [argument0, ...rest] = parameters\n\n let promise: Promise<Argument0<H>> = Promise.resolve(argument0)\n for (const plugin of this.#getSortedPlugins()) {\n promise = promise\n .then((arg0) => {\n const value = this.#execute({\n strategy: 'hookReduceArg0',\n hookName,\n parameters: [arg0, ...rest] as PluginParameter<H>,\n plugin,\n })\n return value\n })\n .then((result) => reduce.call(this.#core.api, argument0, result as ReturnType<ParseResult<H>>, plugin)) as Promise<Argument0<H>>\n }\n\n return promise\n }\n\n /**\n * Chains plugins\n */\n async hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: { hookName: H; parameters?: PluginParameter<H> }): Promise<void> {\n const promises = this.#getSortedPlugins().map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookSeq',\n hookName,\n parameters,\n plugin,\n })\n })\n\n return this.#promiseManager.run('seq', promises)\n }\n\n #getSortedPlugins(hookName?: keyof PluginLifecycle): KubbPlugin[] {\n const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n if (hookName) {\n if (this.logger.logLevel === LogLevel.info) {\n const containsHookName = plugins.some((item) => item[hookName])\n if (!containsHookName) {\n this.logger.warn(`No hook ${hookName} found`)\n }\n }\n\n return plugins.filter((item) => item[hookName])\n }\n // TODO add test case for sorting with pre/post\n\n return plugins.map(plugin => {\n if (plugin.pre) {\n const isValid = plugin.pre.every(pluginName => plugins.find(pluginToFind => pluginToFind.name === pluginName))\n\n if (!isValid) {\n throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, undefined, 2)})`)\n }\n }\n\n return plugin\n }).sort((a, b) => {\n if (b.pre?.includes(a.name)) {\n return 1\n }\n if (b.post?.includes(a.name)) {\n return -1\n }\n return 0\n })\n }\n\n getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[] {\n const plugins = [...this.plugins]\n const [searchPluginName, searchIdentifier] = pluginKey\n\n const pluginByPluginName = plugins\n .filter((plugin) => plugin[hookName])\n .filter((item) => {\n const [name, identifier] = item.key\n\n const identifierCheck = identifier?.toString() === searchIdentifier?.toString()\n const nameCheck = name === searchPluginName\n\n if (searchIdentifier) {\n return identifierCheck && nameCheck\n }\n\n return nameCheck\n })\n\n if (!pluginByPluginName?.length) {\n // fallback on the core plugin when there is no match\n\n const corePlugin = plugins.find((plugin) => plugin.name === 'core' && plugin[hookName])\n\n if (this.logger.logLevel === LogLevel.debug) {\n if (corePlugin) {\n this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`)\n } else {\n this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`)\n }\n }\n\n return corePlugin ? [corePlugin] : []\n }\n\n return pluginByPluginName\n }\n\n #addExecutedToCallStack(executer: Executer | undefined) {\n if (executer) {\n this.eventEmitter.emit('executed', executer)\n this.executed.push(executer)\n }\n }\n\n /**\n * Run an async plugin hook and return the result.\n * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.\n * @param args Arguments passed to the plugin hook.\n * @param plugin The actual pluginObject to run.\n */\n // Implementation signature\n #execute<H extends PluginLifecycleHooks>({\n strategy,\n hookName,\n parameters,\n plugin,\n }: {\n strategy: Strategy\n hookName: H\n parameters: unknown[] | undefined\n plugin: KubbPluginWithLifeCycle\n }): Promise<ReturnType<ParseResult<H>> | null> | null {\n const hook = plugin[hookName]\n let output: unknown\n\n if (!hook) {\n return null\n }\n\n this.eventEmitter.emit('execute', { strategy, hookName, parameters, plugin })\n\n const task = Promise.resolve()\n .then(() => {\n if (typeof hook === 'function') {\n const possiblePromiseResult = (hook as Function).apply({ ...this.#core.api, plugin }, parameters) as Promise<ReturnType<ParseResult<H>>>\n\n if (isPromise(possiblePromiseResult)) {\n return Promise.resolve(possiblePromiseResult)\n }\n return possiblePromiseResult\n }\n\n return hook\n })\n .then((result) => {\n output = result\n\n this.#addExecutedToCallStack({\n parameters,\n output,\n strategy,\n hookName,\n plugin,\n })\n\n return result\n })\n .catch((e: Error) => {\n this.#catcher<H>(e, plugin, hookName)\n\n return null\n })\n\n return task\n }\n\n /**\n * Run a sync plugin hook and return the result.\n * @param hookName Name of the plugin hook. Must be in `PluginHooks`.\n * @param args Arguments passed to the plugin hook.\n * @param plugin The acutal plugin\n * @param replaceContext When passed, the plugin context can be overridden.\n */\n #executeSync<H extends PluginLifecycleHooks>({\n strategy,\n hookName,\n parameters,\n plugin,\n }: {\n strategy: Strategy\n hookName: H\n parameters: PluginParameter<H>\n plugin: KubbPluginWithLifeCycle\n }): ReturnType<ParseResult<H>> | null {\n const hook = plugin[hookName]\n let output: unknown\n\n if (!hook) {\n return null\n }\n\n this.eventEmitter.emit('execute', { strategy, hookName, parameters, plugin })\n\n try {\n if (typeof hook === 'function') {\n const fn = (hook as Function).apply({ ...this.#core.api, plugin }, parameters) as ReturnType<ParseResult<H>>\n\n output = fn\n return fn\n }\n\n output = hook\n\n this.#addExecutedToCallStack({\n parameters,\n output,\n strategy,\n hookName,\n plugin,\n })\n\n return hook\n } catch (e) {\n this.#catcher<H>(e as Error, plugin, hookName)\n\n return null\n }\n }\n\n #catcher<H extends PluginLifecycleHooks>(e: Error, plugin?: KubbPlugin, hookName?: H) {\n const text = `${e.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})\\n`\n\n this.logger.error(text)\n this.eventEmitter.emit('error', e)\n }\n\n #parse<TPlugin extends KubbUserPluginWithLifeCycle>(\n plugin: TPlugin,\n pluginManager: PluginManager,\n context: CorePluginOptions['api'] | undefined,\n ): KubbPlugin<GetPluginFactoryOptions<TPlugin>> {\n const usedPluginNames = pluginManager.#usedPluginNames\n\n setUniqueName(plugin.name, usedPluginNames)\n\n const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean) as [typeof plugin.name, string]\n\n if (plugin.name !== 'core' && usedPluginNames[plugin.name]! >= 2) {\n pluginManager.logger.warn('Using multiple of the same plugin is an experimental feature')\n }\n\n // default transform\n if (!plugin.transform) {\n plugin.transform = function transform(code) {\n return code\n }\n }\n\n if (plugin.api && typeof plugin.api === 'function') {\n const api = (plugin.api as Function).call(context) as typeof plugin.api\n\n return {\n ...plugin,\n key,\n api,\n } as unknown as KubbPlugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n return {\n ...plugin,\n key,\n } as unknown as KubbPlugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n static getDependedPlugins<\n T1 extends PluginFactoryOptions,\n T2 extends PluginFactoryOptions = never,\n T3 extends PluginFactoryOptions = never,\n TOutput = T3 extends never ? T2 extends never ? [T1: KubbPlugin<T1>]\n : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>]\n : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>, T3: KubbPlugin<T3>],\n >(plugins: Array<KubbPlugin>, dependedPluginNames: string | string[]): TOutput {\n let pluginNames: string[] = []\n if (typeof dependedPluginNames === 'string') {\n pluginNames = [dependedPluginNames]\n } else {\n pluginNames = dependedPluginNames\n }\n\n return pluginNames.map((pluginName) => {\n const plugin = plugins.find((plugin) => plugin.name === pluginName)\n if (!plugin) {\n throw new ValidationPluginError(`This plugin depends on the ${pluginName} plugin.`)\n }\n return plugin\n }) as TOutput\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static get hooks() {\n return ['buildStart', 'resolvePath', 'resolveName', 'load', 'transform', 'writeFile', 'buildEnd'] as const\n }\n}\n","/**\n * Abstract class that contains the building blocks for plugins to create their own Generator\n * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137\n */\nexport abstract class Generator<TOptions = unknown, TContext = unknown> {\n #options: TOptions = {} as TOptions\n #context: TContext = {} as TContext\n\n constructor(options?: TOptions, context?: TContext) {\n if (context) {\n this.#context = context\n }\n\n if (options) {\n this.#options = options\n }\n\n return this\n }\n\n get options(): TOptions {\n return this.#options\n }\n\n get context(): TContext {\n return this.#context\n }\n\n set options(options: TOptions) {\n this.#options = { ...this.#options, ...options }\n }\n\n abstract build(...params: unknown[]): unknown\n}\n","import mod from 'node:module'\nimport os from 'node:os'\nimport { pathToFileURL } from 'node:url'\n\nimport { findUp, findUpSync } from 'find-up'\nimport { coerce, satisfies } from 'semver'\n\ntype PackageJSON = {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n}\n\ntype DependencyName = string\n\ntype DependencyVersion = string\n\nexport class PackageManager {\n static #cache: Record<DependencyName, DependencyVersion> = {}\n\n #cwd?: string\n #SLASHES = new Set(['/', '\\\\'])\n constructor(workspace?: string) {\n if (workspace) {\n this.#cwd = workspace\n }\n\n return this\n }\n\n set workspace(workspace: string) {\n this.#cwd = workspace\n }\n\n get workspace(): string | undefined {\n return this.#cwd\n }\n\n normalizeDirectory(directory: string): string {\n if (!this.#SLASHES.has(directory[directory.length - 1]!)) {\n return `${directory}/`\n }\n\n return directory\n }\n\n getLocation(path: string): string {\n let location = path\n\n if (this.#cwd) {\n const require = mod.createRequire(this.normalizeDirectory(this.#cwd))\n location = require.resolve(path)\n }\n\n return location\n }\n\n async import(path: string): Promise<any | undefined> {\n try {\n let location = this.getLocation(path)\n\n if (os.platform() == 'win32') {\n location = pathToFileURL(location).href\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const module = await import(location)\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n return module?.default ?? module\n } catch (e) {\n console.log(e)\n return undefined\n }\n }\n\n async getPackageJSON(): Promise<PackageJSON | undefined> {\n const pkgPath = await findUp(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n return require(pkgPath) as PackageJSON\n }\n\n getPackageJSONSync(): PackageJSON | undefined {\n const pkgPath = findUpSync(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n return require(pkgPath) as PackageJSON\n }\n\n static setVersion(dependency: DependencyName, version: DependencyVersion): void {\n PackageManager.#cache[dependency] = version\n }\n\n #match(packageJSON: PackageJSON, dependency: DependencyName | RegExp): string | undefined {\n const dependencies = {\n ...packageJSON['dependencies'] || {},\n ...packageJSON['devDependencies'] || {},\n }\n\n if (typeof dependency === 'string' && dependencies[dependency]) {\n return dependencies[dependency]\n }\n\n const matchedDependency = Object.keys(dependencies).find(dep => dep.match(dependency))\n\n return matchedDependency ? dependencies[matchedDependency] : undefined\n }\n\n async getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined> {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = await this.getPackageJSON()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = this.getPackageJSONSync()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n async isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean> {\n const packageVersion = await this.getVersion(dependency)\n\n if (!packageVersion) {\n return false\n }\n\n if (packageVersion === version) {\n return true\n }\n\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean {\n const packageVersion = this.getVersionSync(dependency)\n\n if (!packageVersion) {\n return false\n }\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n}\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {locatePath, locatePathSync} from 'locate-path';\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, options.stopAt || root);\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = options.stopAt || root;\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","/*\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\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","import Queue from 'yocto-queue';\n\nexport default function pLimit(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\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\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});\n\n\treturn generator;\n}\n","import pLimit from 'p-limit';\n\nclass EndError extends Error {\n\tconstructor(value) {\n\t\tsuper();\n\t\tthis.value = value;\n\t}\n}\n\n// The input can also be a promise, so we await it.\nconst testElement = async (element, tester) => tester(await element);\n\n// The input can also be a promise, so we `Promise.all()` them both.\nconst finder = async element => {\n\tconst values = await Promise.all(element);\n\tif (values[1] === true) {\n\t\tthrow new EndError(values[0]);\n\t}\n\n\treturn false;\n};\n\nexport default async function pLocate(\n\titerable,\n\ttester,\n\t{\n\t\tconcurrency = Number.POSITIVE_INFINITY,\n\t\tpreserveOrder = true,\n\t} = {},\n) {\n\tconst limit = pLimit(concurrency);\n\n\t// Start all the promises concurrently with optional limit.\n\tconst items = [...iterable].map(element => [element, limit(testElement, element, tester)]);\n\n\t// Check the promises either serially or concurrently.\n\tconst checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);\n\n\ttry {\n\t\tawait Promise.all(items.map(element => checkLimit(finder, element)));\n\t} catch (error) {\n\t\tif (error instanceof EndError) {\n\t\t\treturn error.value;\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n","import fs, {promises as fsPromises} from 'node:fs';\n\nexport async function pathExists(path) {\n\ttry {\n\t\tawait fsPromises.access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function pathExistsSync(path) {\n\ttry {\n\t\tfs.accessSync(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n","import { build } from './build.ts'\n\nimport type { ObjValueTuple, TupleToUnion } from '@kubb/types'\n\nexport { build, safeBuild } from './build.ts'\nexport * from './config.ts'\nexport * from './errors.ts'\nexport * from './FileManager.ts'\nexport { Generator } from './Generator.ts'\nexport { PackageManager } from './PackageManager.ts'\n// dprint-ignore\nexport { createPlugin, pluginName as name, pluginName } from './plugin.ts'\nexport { PluginManager } from './PluginManager.ts'\nexport { PromiseManager } from './PromiseManager.ts'\nexport * from './types.ts'\n\nexport interface _Register {}\nexport type Plugins = _Register\nexport type OptionsPlugins = { [K in keyof Plugins]: Plugins[K]['options'] }\n\nexport type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options']\n\nexport type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>\n\nexport type Plugin = keyof Plugins\n\nexport default build\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/build.ts","../src/utils/clean.ts","../src/utils/logger.ts","../src/utils/randomColour.ts","../src/utils/read.ts","../src/transformers/casing.ts","../src/transformers/combineCodes.ts","../src/transformers/createJSDocBlockText.ts","../src/transformers/escape.ts","../src/transformers/indent.ts","../src/transformers/nameSorter.ts","../src/transformers/searchAndReplace.ts","../src/transformers/transformReservedWord.ts","../src/transformers/trim.ts","../src/transformers/index.ts","../src/utils/URLPath.ts","../src/config.ts","../src/FileManager.ts","../src/utils/timeout.ts","../src/utils/write.ts","../src/BarrelManager.ts","../src/utils/TreeNode.ts","../src/utils/EventEmitter.ts","../src/utils/Queue.ts","../src/utils/uniqueName.ts","../src/errors.ts","../src/plugin.ts","../src/utils/cache.ts","../src/utils/executeStrategies.ts","../src/PromiseManager.ts","../src/PluginManager.ts","../src/Generator.ts","../src/PackageManager.ts","../../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js","../../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js","../../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js","../src/index.ts"],"names":["pc","path","default","extname","resolve","fs","switcher","files","KubbFile","name","crypto","_queue","factory","_options","pluginName","plugin","fileURLToPath","Queue","fsPromises","toPath","_cache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AEA,UAAM,SAAS,OAAO,cAAc;AAEpC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,GAAG,cAAc,eAAe;AAAA,IAClD;AAEA,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AAAA,EACA,YAAY,YAAqC,SAAqC;AACpF,UAAM,iBAAiB,KAAK,eAAe,UAAU;AAErD,QAAI,CAAC,gBAAgB;AACnB,aAAO;AAAA,IACT;AACA,UAAM,SAAS,OAAO,cAAc;AAEpC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,GAAG,cAAc,eAAe;AAAA,IAClD;AAEA,WAAO,UAAU,QAAQ,OAAO;AAAA,EAClC;AACF;AAhKSA,UAAA;AAEP;AACA;AAiFA;AAAA,WAAM,SAAC,aAA0B,YAAyD;AACxF,QAAM,eAAe;AAAA,IACnB,GAAG,YAAY,cAAc,KAAK,CAAC;AAAA,IACnC,GAAG,YAAY,iBAAiB,KAAK,CAAC;AAAA,EACxC;AAEA,MAAI,OAAO,eAAe,YAAY,aAAa,UAAU,GAAG;AAC9D,WAAO,aAAa,UAAU;AAAA,EAChC;AAEA,QAAM,oBAAoB,OAAO,KAAK,YAAY,EAAE,KAAK,SAAO,IAAI,MAAM,UAAU,CAAC;AAErF,SAAO,oBAAoB,aAAa,iBAAiB,IAAI;AAC/D;AAjGA,aADW,iBACJA,SAAoD,CAAC;AADvD,IAAM,iBAAN;;;AOUP,IAAO,cAAQ","sourcesContent":["import pc from 'picocolors'\n\nimport { clean } from './utils/clean.ts'\nimport { createLogger, LogLevel } from './utils/logger.ts'\nimport { randomPicoColour } from './utils/randomColour.ts'\nimport { read } from './utils/read.ts'\nimport { URLPath } from './utils/URLPath.ts'\nimport { isInputPath } from './config.ts'\nimport { FileManager } from './FileManager.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isPromise } from './PromiseManager.ts'\n\nimport type { KubbFile } from './FileManager.ts'\nimport type { KubbPlugin, PluginContext, PluginParameter, TransformResult } from './types.ts'\nimport type { Logger } from './utils/logger.ts'\nimport type { QueueJob } from './utils/Queue.ts'\n\ntype BuildOptions = {\n config: PluginContext['config']\n /**\n * @default Logger without the spinner\n */\n logger?: Logger\n}\n\ntype BuildOutput = {\n files: FileManager['files']\n pluginManager: PluginManager\n /**\n * Only for safeBuild\n */\n error?: Error\n}\n\nasync function transformReducer(\n this: PluginContext,\n _previousCode: string,\n result: TransformResult | Promise<TransformResult>,\n _plugin: KubbPlugin,\n): Promise<string | null> {\n return result\n}\n\nasync function setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger({ logLevel: LogLevel.silent }) } = options\n\n try {\n if (isInputPath(config) && !new URLPath(config.input.path).isURL) {\n await read(config.input.path)\n }\n } catch (e) {\n if (isInputPath(config)) {\n throw new Error(\n 'Cannot read file/URL defined in `input.path` or set with `kubb generate PATH` in the CLI of your Kubb config ' + pc.dim(config.input.path),\n {\n cause: e,\n },\n )\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n const queueTask = async (file: KubbFile.File) => {\n const { path } = file\n\n let code: string | null = FileManager.getSource(file)\n\n const { result: loadedResult } = await pluginManager.hookFirst({\n hookName: 'load',\n parameters: [path],\n })\n if (loadedResult && isPromise(loadedResult)) {\n code = await loadedResult\n }\n if (loadedResult && !isPromise(loadedResult)) {\n code = loadedResult\n }\n\n if (code) {\n const transformedCode = await pluginManager.hookReduceArg0({\n hookName: 'transform',\n parameters: [code, path],\n reduce: transformReducer,\n })\n\n if (config.output.write || config.output.write === undefined) {\n if (file.meta?.pluginKey) {\n // run only for pluginKey defined in the meta of the file\n return pluginManager.hookForPlugin({\n pluginKey: file.meta?.pluginKey,\n hookName: 'writeFile',\n parameters: [transformedCode, path],\n })\n }\n\n return pluginManager.hookFirst({\n hookName: 'writeFile',\n parameters: [transformedCode, path],\n })\n }\n }\n }\n\n const pluginManager = new PluginManager(config, { logger, task: queueTask as QueueJob<KubbFile.ResolvedFile>, writeTimeout: 0 })\n\n pluginManager.on('execute', (executer) => {\n const { hookName, parameters, plugin } = executer\n\n if (hookName === 'writeFile' && logger.spinner) {\n const [code] = parameters as PluginParameter<'writeFile'>\n\n if (logger.logLevel === LogLevel.info) {\n logger.spinner.start(`💾 Writing`)\n }\n\n if (logger.logLevel === LogLevel.debug) {\n logger.info(`PluginKey ${pc.dim(JSON.stringify(plugin.key))} \\nwith source\\n\\n${code}`)\n }\n }\n })\n\n pluginManager.on('executed', (executer) => {\n const { hookName, plugin, output, parameters } = executer\n const messsage = `${randomPicoColour(plugin.name)} Executing ${hookName}`\n\n if (logger.logLevel === LogLevel.info && logger.spinner) {\n if (hookName === 'writeFile') {\n const [_code, path] = parameters as PluginParameter<'writeFile'>\n\n logger.spinner.suffixText = pc.dim(path)\n } else {\n logger.spinner.suffixText = messsage\n }\n }\n\n if (logger.logLevel === LogLevel.debug) {\n logger.info(messsage)\n const logs = [\n parameters && `${pc.bgWhite(`Parameters`)} ${randomPicoColour(plugin.name)} ${hookName}`,\n JSON.stringify(parameters, undefined, 2),\n output && `${pc.bgWhite('Output')} ${randomPicoColour(plugin.name)} ${hookName}`,\n output,\n ].filter(Boolean)\n\n console.log(logs.join('\\n'))\n }\n })\n\n return pluginManager\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n const { fileManager, logger } = pluginManager\n\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n if (!fileManager.isExecuting && logger.spinner) {\n logger.spinner.suffixText = ''\n logger.spinner.succeed(`💾 Writing completed`)\n }\n\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n\n const { fileManager, logger } = pluginManager\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n if (!fileManager.isExecuting && logger.spinner) {\n logger.spinner.suffixText = ''\n logger.spinner.succeed(`💾 Writing completed`)\n }\n } catch (e) {\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager, error: e as Error }\n }\n\n return { files: fileManager.files.map((file) => ({ ...file, source: FileManager.getSource(file) })), pluginManager }\n}\n","import { remove } from 'fs-extra'\n\nexport async function clean(path: string): Promise<void> {\n return remove(path)\n}\n","import pc from 'picocolors'\n\nimport type { Ora } from 'ora'\n\nexport const LogLevel = {\n silent: 'silent',\n info: 'info',\n debug: 'debug',\n} as const\n\nexport type LogLevel = keyof typeof LogLevel\n\nexport type Logger = {\n /**\n * Optional config name to show in CLI output\n */\n name?: string\n logLevel: LogLevel\n log: (message: string | null) => void\n error: (message: string | null) => void\n info: (message: string | null) => void\n warn: (message: string | null) => void\n spinner?: Ora\n logs: string[]\n}\n\ntype Props = {\n name?: string\n logLevel: LogLevel\n spinner?: Ora\n}\n\nexport function createLogger({ logLevel, name, spinner }: Props): Logger {\n const logs: string[] = []\n const log: Logger['log'] = (message) => {\n if (message && spinner) {\n spinner.text = message\n logs.push(message)\n }\n }\n\n const error: Logger['error'] = (message) => {\n if (message) {\n throw new Error(message || 'Something went wrong')\n }\n }\n\n const warn: Logger['warn'] = (message) => {\n if (message && spinner) {\n spinner.warn(pc.yellow(message))\n logs.push(message)\n }\n }\n\n const info: Logger['warn'] = (message) => {\n if (message && spinner && logLevel !== LogLevel.silent) {\n spinner.info(message)\n logs.push(message)\n }\n }\n\n const logger: Logger = {\n name,\n logLevel,\n log,\n error,\n warn,\n info,\n spinner,\n logs,\n }\n\n return logger\n}\n\nexport { default as pc } from 'picocolors'\n","import pc from 'picocolors'\nimport seedrandom from 'seedrandom'\n\nimport type { Formatter } from 'picocolors/types.ts'\n\nconst defaultColours = ['black', 'blue', 'darkBlue', 'cyan', 'gray', 'green', 'darkGreen', 'magenta', 'red', 'darkRed', 'yellow', 'darkYellow'] as const\n\nexport function randomColour(text?: string, colours = defaultColours): string {\n if (!text) {\n return 'white'\n }\n\n const random = seedrandom(text)\n const colour = colours.at(Math.floor(random() * colours.length)) || 'white'\n\n return colour\n}\n\nexport function randomPicoColour(text?: string, colors = defaultColours): string {\n const colours = pc.createColors(true)\n\n if (!text) {\n return colours.white(text)\n }\n\n const colour = randomColour(text, colors)\n const isDark = colour.includes('dark')\n const key = colour.replace('dark', '').toLowerCase() as keyof typeof colours\n const formatter: Formatter = colours[key] as Formatter\n\n if (isDark) {\n return pc.bold(formatter(text))\n }\n\n if (typeof formatter !== 'function') {\n throw new Error('Formatter for picoColor is not of type function/Formatter')\n }\n return formatter(text)\n}\n","import { basename, extname, relative } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nfunction slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {\n const isWindowsPath = /^\\\\\\\\\\?\\\\/.test(path)\n\n if (['linux', 'mac'].includes(platform) && !isWindowsPath) {\n // linux and mac\n return path.replaceAll(/\\\\/g, '/').replace('../', '').trimEnd()\n }\n\n // windows\n return path.replaceAll(/\\\\/g, '/').replace('../', '').trimEnd()\n}\n\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null, platform: 'windows' | 'mac' | 'linux' = 'linux'): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = relative(rootDir, filePath)\n\n // On Windows, paths are separated with a \"\\\"\n // However, web browsers use \"/\" no matter the platform\n const slashedPath = slash(relativePath, platform)\n\n if (slashedPath.startsWith('../')) {\n return slashedPath.replace(basename(slashedPath), basename(slashedPath, extname(filePath)))\n }\n\n return `./${slashedPath.replace(basename(slashedPath), basename(slashedPath, extname(filePath)))}`\n}\n\nconst reader = switcher(\n {\n node: async (path: string) => {\n return fs.readFile(path, { encoding: 'utf8' })\n },\n bun: async (path: string) => {\n const file = Bun.file(path)\n\n return file.text()\n },\n },\n 'node',\n)\n\nconst syncReader = switcher(\n {\n node: (path: string) => {\n return fs.readFileSync(path, { encoding: 'utf8' })\n },\n bun: () => {\n throw new Error('Bun cannot read sync')\n },\n },\n 'node',\n)\n\nexport async function read(path: string): Promise<string> {\n return reader(path)\n}\n\nexport function readSync(path: string): string {\n return syncReader(path)\n}\n","import { camelCase as changeCaseCamel, camelCaseTransformMerge, pascalCase as changePascalCase, pascalCaseTransformMerge } from 'change-case'\n\nexport function camelCase(text: string): string {\n return changeCaseCamel(text, { delimiter: '', stripRegexp: /[^A-Z0-9$]/gi, transform: camelCaseTransformMerge })\n}\n\nexport function pascalCase(text: string): string {\n return changePascalCase(text, { delimiter: '', stripRegexp: /[^A-Z0-9$]/gi, transform: pascalCaseTransformMerge })\n}\n","export function combineCodes(codes: string[]): string {\n return codes.join('\\n')\n}\n","export function createJSDocBlockText({ comments }: { comments: Array<string> }): string {\n const filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return ''\n }\n\n return `/**\\n * ${filteredComments.join('\\n * ')}\\n */`\n}\n","export function escape(text?: string): string {\n return text ? text.replaceAll('`', '\\\\`') : ''\n}\n\n/**\n * Escape all characters not included in SingleStringCharacters and DoubleStringCharacters on\n * @link http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n * @link https://github.com/joliss/js-string-escape/blob/master/index.js\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function jsStringEscape(input: any): string {\n return `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n switch (character) {\n case '\"':\n case \"'\":\n case '\\\\':\n return '\\\\' + character\n // Four possible LineTerminator characters need to be escaped:\n case '\\n':\n return '\\\\n'\n case '\\r':\n return '\\\\r'\n case '\\u2028':\n return '\\\\u2028'\n case '\\u2029':\n return '\\\\u2029'\n default:\n return ''\n }\n })\n}\n","export function createIndent(size: number): string {\n return Array.from({ length: size + 1 }).join(' ')\n}\n","export function nameSorter<T extends { name: string }>(a: T, b: T): 0 | 1 | -1 {\n if (a.name < b.name) {\n return -1\n }\n if (a.name > b.name) {\n return 1\n }\n return 0\n}\n","type Options = {\n text: string\n replaceBy: string\n prefix?: string\n key: string\n searchValues?: (prefix: string, key: string) => Array<RegExp | string>\n}\n\nexport function searchAndReplace(options: Options): string {\n const { text, replaceBy, prefix = '', key } = options\n\n const searchValues = options.searchValues?.(prefix, key) || [\n `${prefix}[\"${key}\"]`,\n `${prefix}['${key}']`,\n `${prefix}[\\`${key}\\`]`,\n `${prefix}\"${key}\"`,\n `${prefix}'${key}'`,\n `${prefix}\\`${key}\\``,\n new RegExp(`${prefix}${key}`, 'g'),\n ]\n\n return searchValues.reduce((prev, searchValue) => {\n return prev.toString().replaceAll(searchValue, replaceBy)\n }, text) as string\n}\n","/**\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = [\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n\n 'Array',\n 'Date',\n 'eval',\n 'function',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n]\n\nexport function transformReservedWord(word: string): string {\n if ((word && reservedWords.includes(word)) || word?.match(/^\\d/)) {\n return `_${word}`\n }\n\n return word\n}\n","export function trim(text: string): string {\n return text.replaceAll(/\\n/g, '').trim()\n}\n\nexport function trimExtName(text: string): string {\n return text.replace(/\\.[^/.]+$/, '')\n}\n","import { camelCase, pascalCase } from './casing.ts'\nimport { combineCodes } from './combineCodes.ts'\nimport { createJSDocBlockText } from './createJSDocBlockText.ts'\nimport { escape, jsStringEscape } from './escape.ts'\nimport { createIndent } from './indent.ts'\nimport { nameSorter } from './nameSorter.ts'\nimport { searchAndReplace } from './searchAndReplace.ts'\nimport { transformReservedWord } from './transformReservedWord.ts'\nimport { trim, trimExtName } from './trim.ts'\n\nexport { camelCase, pascalCase } from './casing.ts'\nexport { combineCodes } from './combineCodes.ts'\nexport { createJSDocBlockText } from './createJSDocBlockText.ts'\nexport { escape, jsStringEscape } from './escape.ts'\nexport { createIndent } from './indent.ts'\nexport { nameSorter } from './nameSorter.ts'\nexport { searchAndReplace } from './searchAndReplace.ts'\nexport { transformReservedWord } from './transformReservedWord.ts'\nexport { trim, trimExtName } from './trim.ts'\n\nexport default {\n combineCodes,\n escape,\n jsStringEscape,\n createIndent,\n transformReservedWord,\n nameSorter,\n searchAndReplace,\n trim,\n trimExtName,\n JSDoc: {\n createJSDocBlockText,\n },\n camelCase,\n pascalCase,\n} as const\n","import transformers from '../transformers/index.ts'\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\nexport class URLPath {\n path: string\n\n constructor(path: string) {\n this.path = path\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(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, curr) => {\n const pathParam = replacer\n ? replacer(transformers.camelCase(curr))\n : transformers.camelCase(curr)\n const replacement = `\\${${pathParam}}`\n\n return prev.replace(curr, replacement)\n }, this.path)\n }\n\n return `\\`${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 const pathParam = replacer\n ? replacer(transformers.camelCase(item))\n : transformers.camelCase(item)\n\n params[pathParam] = pathParam\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 type { PossiblePromise } from '@kubb/types'\nimport type { CLIOptions, InputPath, KubbConfig, KubbUserConfig } from './types.ts'\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link KubbConfig} object, or a function that returns it.\n * The function receives a {@link ConfigEnv} object that exposes two properties:\n */\nexport function defineConfig(\n options:\n | PossiblePromise<KubbUserConfig | Array<KubbUserConfig>>\n | ((\n /** The options derived from the CLI flags */\n cliOptions: CLIOptions,\n ) => PossiblePromise<KubbUserConfig | Array<KubbUserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: KubbConfig | undefined): result is KubbConfig<InputPath> {\n return !!result && 'path' in (result as any)\n}\n","/* eslint-disable @typescript-eslint/no-namespace */\nimport crypto from 'node:crypto'\nimport { extname } from 'node:path'\n\nimport { print } from '@kubb/parser'\nimport * as factory from '@kubb/parser/factory'\n\nimport isEqual from 'lodash.isequal'\nimport { orderBy } from 'natural-orderby'\n\nimport transformers from './transformers/index.ts'\nimport { getRelativePath, read } from './utils/read.ts'\nimport { timeout } from './utils/timeout.ts'\nimport { write } from './utils/write.ts'\nimport { BarrelManager } from './BarrelManager.ts'\n\nimport type { GreaterThan } from '@kubb/types'\nimport type { BarrelManagerOptions } from './BarrelManager.ts'\nimport type { KubbPlugin } from './types.ts'\nimport type { Queue, QueueJob } from './utils/Queue.ts'\n\ntype BasePath<T extends string = string> = `${T}/`\n\nexport namespace KubbFile {\n export type Import = {\n /**\n * Import name to be used\n * @example [\"useState\"]\n * @example \"React\"\n */\n name:\n | string\n | Array<\n string | {\n propertyName: string\n name?: string\n }\n >\n /**\n * Path for the import\n * @xample '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * When root is set it will get the path with relative getRelativePath(root, path).\n */\n root?: string\n }\n\n export type Export = {\n /**\n * Export name to be used.\n * @example [\"useState\"]\n * @example \"React\"\n */\n name?: string | Array<string>\n /**\n * Path for the import.\n * @xample '@kubb/core'\n */\n path: string\n /**\n * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.\n */\n isTypeOnly?: boolean\n /**\n * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.\n */\n asAlias?: boolean\n }\n\n export declare const dataTagSymbol: unique symbol\n export type DataTag<Type, Value> = Type & {\n [dataTagSymbol]: Value\n }\n\n export type UUID = string\n export type Source = string\n\n export type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`\n\n export type Mode = 'file' | 'directory'\n\n /**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n export type BaseName = `${string}${Extname}`\n\n /**\n * Path will be full qualified path to a specified file\n */\n export type Path = string\n\n export type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`\n\n export type OptionalPath = Path | undefined | null\n\n export type FileMetaBase = {\n pluginKey?: KubbPlugin['key']\n }\n\n export type File<\n TMeta extends FileMetaBase = FileMetaBase,\n TBaseName extends BaseName = BaseName,\n > = {\n /**\n * Unique identifier to reuse later\n * @default crypto.randomUUID()\n */\n id?: string\n /**\n * Name to be used to dynamicly create the baseName(based on input.path)\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: TBaseName\n /**\n * Path will be full qualified path to a specified file\n */\n path: AdvancedPath<TBaseName> | Path\n source: Source\n imports?: Import[]\n exports?: Export[]\n /**\n * This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists\n * This will also ignore the combinefiles utils\n * @default `false`\n */\n override?: boolean\n /**\n * Use extra meta, this is getting used to generate the barrel/index files.\n */\n meta?: TMeta\n /**\n * This will override `process.env[key]` inside the `source`, see `getFileSource`.\n */\n env?: NodeJS.ProcessEnv\n }\n\n export type ResolvedFile<\n TMeta extends FileMetaBase = FileMetaBase,\n TBaseName extends BaseName = BaseName,\n > = KubbFile.File<TMeta, TBaseName> & {\n /**\n * @default crypto.randomUUID()\n */\n id: UUID\n }\n}\n\ntype CacheItem = KubbFile.ResolvedFile & {\n cancel?: () => void\n}\n\ntype AddResult<T extends Array<KubbFile.File>> = Promise<\n Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>\n>\n\ntype AddIndexesProps = {\n root: KubbFile.Path\n extName?: KubbFile.Extname\n options?: BarrelManagerOptions\n meta?: KubbFile.File['meta']\n}\n\ntype Options = {\n queue?: Queue\n task?: QueueJob<KubbFile.ResolvedFile>\n /**\n * Timeout between writes\n */\n timeout?: number\n}\n\nexport class FileManager {\n #cache: Map<KubbFile.Path, CacheItem[]> = new Map()\n\n #task?: QueueJob<KubbFile.ResolvedFile>\n #isWriting = false\n /**\n * Timeout between writes\n */\n #timeout: number = 0\n #queue?: Queue\n\n constructor(options?: Options) {\n if (options) {\n this.#task = options.task\n this.#queue = options.queue\n this.#timeout = options.timeout || 0\n }\n\n return this\n }\n\n get files(): Array<KubbFile.File> {\n const files: Array<KubbFile.File> = []\n this.#cache.forEach((item) => {\n files.push(...item.flat(1))\n })\n\n return files\n }\n get isExecuting(): boolean {\n return this.#queue?.hasJobs ?? this.#isWriting ?? false\n }\n\n #validate(file: KubbFile.File): void {\n if (!file.path.toLowerCase().endsWith(file.baseName.toLowerCase())) {\n throw new Error(`${file.path} should end with the baseName ${file.baseName}`)\n }\n }\n\n async add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(\n ...files: T\n ): AddResult<T> {\n const promises = files.map((file) => {\n // this.#validate(file)\n\n if (file.override) {\n return this.#add(file)\n }\n\n return this.#addOrAppend(file)\n })\n\n const resolvedFiles = await Promise.all(promises)\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 #add(file: KubbFile.File): Promise<KubbFile.ResolvedFile> {\n const controller = new AbortController()\n const resolvedFile: KubbFile.ResolvedFile = { id: crypto.randomUUID(), ...file }\n\n this.#cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }])\n\n if (this.#queue) {\n await this.#queue.run(\n async () => {\n return this.#task?.(resolvedFile)\n },\n { controller },\n )\n }\n\n return resolvedFile\n }\n\n async #addOrAppend(file: KubbFile.File): Promise<KubbFile.ResolvedFile> {\n const previousCaches = this.#cache.get(file.path)\n const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : undefined\n\n if (previousCache) {\n this.#cache.delete(previousCache.path)\n\n return this.#add({\n ...file,\n source: previousCache.source && file.source ? `${previousCache.source}\\n${file.source}` : '',\n imports: [...(previousCache.imports || []), ...(file.imports || [])],\n exports: [...(previousCache.exports || []), ...(file.exports || [])],\n env: { ...(previousCache.env || {}), ...(file.env || {}) },\n })\n }\n return this.#add(file)\n }\n\n async addIndexes({ root, extName = '.ts', meta, options = {} }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined> {\n const barrelManager = new BarrelManager(options)\n\n const files = barrelManager.getIndexes(root, extName)\n\n if (!files) {\n return undefined\n }\n\n return await Promise.all(\n files.map((file) => {\n return this.#addOrAppend({\n ...file,\n meta: meta ? meta : file.meta,\n })\n }),\n )\n }\n\n getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined {\n let cache: KubbFile.File | undefined\n\n this.#cache.forEach((files) => {\n cache = files.find((item) => item.id === UUID)\n })\n return cache\n }\n\n get(path: KubbFile.Path): Array<KubbFile.File> | undefined {\n return this.#cache.get(path)\n }\n\n remove(path: KubbFile.Path): void {\n const cacheItem = this.get(path)\n if (!cacheItem) {\n return\n }\n\n this.#cache.delete(path)\n }\n\n async write(...params: Parameters<typeof write>): Promise<string | undefined> {\n if (!this.#isWriting) {\n this.#isWriting = true\n\n const text = await write(...params)\n\n this.#isWriting = false\n return text\n }\n\n await timeout(this.#timeout)\n\n return this.write(...params)\n }\n\n async read(...params: Parameters<typeof read>): Promise<string> {\n return read(...params)\n }\n\n // statics\n\n static getSource<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(file: KubbFile.File<TMeta>): string {\n if (!FileManager.isExtensionAllowed(file.baseName)) {\n return file.source\n }\n\n const exports = file.exports ? combineExports(file.exports) : []\n const imports = file.imports ? combineImports(file.imports, exports, file.source) : []\n\n const importNodes = imports.filter(item => {\n // isImportNotNeeded\n // trim extName\n return item.path !== transformers.trimExtName(file.path)\n }).map((item) => {\n return factory.createImportDeclaration({\n name: item.name,\n path: item.root ? getRelativePath(item.root, item.path) : item.path,\n isTypeOnly: item.isTypeOnly,\n })\n })\n const exportNodes = exports.map((item) =>\n factory.createExportDeclaration({\n name: item.name,\n path: item.path,\n isTypeOnly: item.isTypeOnly,\n asAlias: item.asAlias,\n })\n )\n\n return [print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join('\\n')\n }\n static combineFiles<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(files: Array<KubbFile.File<TMeta> | null>): Array<KubbFile.File<TMeta>> {\n return files.filter(Boolean).reduce((acc, file: KubbFile.File<TMeta>) => {\n const prevIndex = acc.findIndex((item) => item.path === file.path)\n\n if (prevIndex === -1) {\n return [...acc, file]\n }\n\n const prev = acc[prevIndex]\n\n if (prev && file.override) {\n acc[prevIndex] = {\n imports: [],\n exports: [],\n ...file,\n }\n return acc\n }\n\n if (prev) {\n acc[prevIndex] = {\n ...file,\n source: prev.source && file.source ? `${prev.source}\\n${file.source}` : '',\n imports: [...(prev.imports || []), ...(file.imports || [])],\n exports: [...(prev.exports || []), ...(file.exports || [])],\n env: { ...(prev.env || {}), ...(file.env || {}) },\n }\n }\n\n return acc\n }, [] as Array<KubbFile.File<TMeta>>)\n }\n static getMode(path: string | undefined | null): KubbFile.Mode {\n if (!path) {\n return 'directory'\n }\n return extname(path) ? 'file' : 'directory'\n }\n\n static get extensions(): Array<KubbFile.Extname> {\n return ['.js', '.ts', '.tsx']\n }\n\n static isExtensionAllowed(baseName: string): boolean {\n return FileManager.extensions.some((extension) => baseName.endsWith(extension))\n }\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n const combinedExports = orderBy(exports, [(v) => !v.isTypeOnly], ['asc']).reduce((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 && isEqual(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 && isEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\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 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 }, [] as Array<KubbFile.Export>)\n\n return orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ['desc', 'desc'])\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n const combinedImports = orderBy(imports, [(v) => !v.isTypeOnly], ['asc']).reduce((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) => name && !!source.includes(name)\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\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 && isEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isEqual(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 if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\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 if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n }, [] as Array<KubbFile.Import>)\n\n return orderBy(combinedImports, [(v) => !v.isTypeOnly], ['desc'])\n}\n\nfunction getEnvSource(source: string, env: NodeJS.ProcessEnv | undefined): string {\n if (!env) {\n return source\n }\n\n const keys = Object.keys(env)\n\n if (!keys.length) {\n return source\n }\n\n return keys.reduce((prev, key: string) => {\n const environmentValue = env[key]\n const replaceBy = environmentValue ? `'${environmentValue.replaceAll('\"', '')?.replaceAll(\"'\", '')}'` : 'undefined'\n\n if (key.toUpperCase() !== key) {\n throw new TypeError(`Environment should be in upperCase for ${key}`)\n }\n\n if (typeof replaceBy === 'string') {\n prev = transformers.searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: 'process.env', key })\n // removes `declare const ...`\n prev = transformers.searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*\\n`, 'ig'), ''), replaceBy, key })\n }\n\n return prev\n }, source)\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","import { dirname, resolve } from 'node:path'\n\nimport fs from 'fs-extra'\nimport { switcher } from 'js-runtime'\n\nasync function saveCreateDirectory(path: string): Promise<void> {\n // resolve the full path and get just the directory, ignoring the file and extension\n const passedPath = dirname(resolve(path))\n // make the directory, recursively. Theoretically, if every directory in the path exists, this won't do anything.\n await fs.mkdir(passedPath, { recursive: true })\n}\n\nconst writer = switcher(\n {\n node: async (path: string, data: string) => {\n try {\n await fs.stat(resolve(path))\n const oldContent = await fs.readFile(resolve(path), { encoding: 'utf-8' })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await saveCreateDirectory(path)\n await fs.writeFile(resolve(path), data, { encoding: 'utf-8' })\n\n const savedData = await fs.readFile(resolve(path), { encoding: 'utf-8' })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n },\n bun: async (path: string, data: string) => {\n try {\n await saveCreateDirectory(path)\n await Bun.write(resolve(path), data)\n\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n } catch (e) {\n console.log(e, resolve(path))\n }\n },\n },\n 'node',\n)\n\nexport async function write(data: string, path: string): Promise<string | undefined> {\n if (data.trim() === '') {\n return undefined\n }\n return writer(path, data.trim())\n}\n","import path from 'path'\n\nimport { TreeNode } from './utils/TreeNode.ts'\n\nimport type { DirectoryTreeOptions } from 'directory-tree'\nimport type { KubbFile } from './FileManager.ts'\n\ntype BarrelData = { type: KubbFile.Mode; path: KubbFile.Path; name: string }\n\nexport type BarrelManagerOptions = {\n treeNode?: DirectoryTreeOptions\n isTypeOnly?: boolean\n filter?: (file: KubbFile.File) => boolean\n map?: (file: KubbFile.File) => KubbFile.File\n includeExt?: boolean\n output?: string\n}\n\nexport class BarrelManager {\n #options: BarrelManagerOptions = {}\n\n constructor(options: BarrelManagerOptions = {}) {\n this.#options = options\n\n return this\n }\n\n getIndexes(\n root: string,\n extName?: KubbFile.Extname,\n ): Array<KubbFile.File> | null {\n const { treeNode = {}, isTypeOnly, filter, map, output, includeExt } = this.#options\n\n const extMapper: Record<KubbFile.Extname, DirectoryTreeOptions> = {\n '.ts': {\n extensions: /\\.ts/,\n exclude: [/schemas/, /json/],\n },\n '.json': {\n extensions: /\\.json/,\n exclude: [],\n },\n }\n const tree = TreeNode.build<BarrelData>(root, { ...(extMapper[extName as keyof typeof extMapper] || {}), ...treeNode })\n\n if (!tree) {\n return null\n }\n\n const fileReducer = (files: Array<KubbFile.File>, currentTree: typeof tree) => {\n if (!currentTree.children) {\n return []\n }\n\n if (currentTree.children?.length > 1) {\n const indexPath: KubbFile.Path = path.resolve(currentTree.data.path, 'index.ts')\n const exports: KubbFile.Export[] = currentTree.children\n .filter(Boolean)\n .map((file) => {\n const importPath: string = file.data.type === 'directory' ? `./${file.data.name}/index` : `./${file.data.name.replace(/\\.[^.]*$/, '')}`\n\n if (importPath.includes('index') && file.data.type === 'file') {\n return undefined\n }\n\n return {\n path: includeExt ? `${importPath}${extName}` : importPath,\n isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n\n files.push({\n path: indexPath,\n baseName: 'index.ts',\n source: '',\n exports: output\n ? exports?.filter((item) => {\n return item.path.endsWith(output.replace(/\\.[^.]*$/, ''))\n })\n : exports,\n })\n } else {\n currentTree.children?.forEach((child) => {\n const indexPath = path.resolve(currentTree.data.path, 'index.ts')\n const importPath = child.data.type === 'directory' ? `./${child.data.name}/index` : `./${child.data.name.replace(/\\.[^.]*$/, '')}`\n\n const exports = [\n {\n path: includeExt\n ? `${importPath}${extName}`\n : importPath,\n isTypeOnly,\n },\n ]\n\n files.push({\n path: indexPath,\n baseName: 'index.ts',\n source: '',\n exports: output\n ? exports?.filter((item) => {\n return item.path.endsWith(output.replace(/\\.[^.]*$/, ''))\n })\n : exports,\n })\n })\n }\n\n currentTree.children.forEach((childItem) => {\n fileReducer(files, childItem)\n })\n\n return files\n }\n\n const files = fileReducer([], tree).reverse()\n\n const filteredFiles = filter ? files.filter(filter) : files\n\n return map ? filteredFiles.map(map) : filteredFiles\n }\n}\n","import dirTree from 'directory-tree'\n\nimport { FileManager } from '../FileManager.ts'\n\nimport type { DirectoryTree, DirectoryTreeOptions } from 'directory-tree'\n\nexport type TreeNodeOptions = DirectoryTreeOptions\n\nexport class TreeNode<T = unknown> {\n public data: T\n\n public parent?: TreeNode<T>\n\n public children: Array<TreeNode<T>> = []\n\n constructor(data: T, parent?: TreeNode<T>) {\n this.data = data\n this.parent = parent\n return this\n }\n\n addChild(data: T): TreeNode<T> {\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 find(data?: T): TreeNode<T> | null {\n if (!data) {\n return null\n }\n\n if (data === this.data) {\n return this\n }\n\n if (this.children?.length) {\n for (let i = 0, { length } = this.children, target: TreeNode<T> | null = null; i < length; i++) {\n target = this.children[i]!.find(data)\n if (target) {\n return target\n }\n }\n }\n\n return null\n }\n\n get leaves(): TreeNode<T>[] {\n if (!this.children || this.children.length === 0) {\n // this is a leaf\n return [this]\n }\n\n // if not a leaf, return all children's leaves recursively\n const leaves: TreeNode<T>[] = []\n if (this.children) {\n for (let i = 0, { length } = this.children; i < length; i++) {\n // eslint-disable-next-line prefer-spread\n leaves.push.apply(leaves, this.children[i]!.leaves)\n }\n }\n return leaves\n }\n\n get root(): TreeNode<T> {\n if (!this.parent) {\n return this\n }\n return this.parent.root\n }\n\n forEach(callback: (treeNode: TreeNode<T>) => 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 public static build<T = unknown>(path: string, options: TreeNodeOptions = {}): TreeNode<T> | null {\n try {\n const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean)\n const filteredTree = dirTree(path, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] })\n\n if (!filteredTree) {\n return null\n }\n\n const treeNode = new TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || FileManager.getMode(filteredTree.path) })\n\n const recurse = (node: typeof treeNode, item: DirectoryTree) => {\n const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || FileManager.getMode(item.path) })\n\n if (item.children?.length) {\n item.children?.forEach((child) => {\n recurse(subNode, child)\n })\n }\n }\n\n filteredTree.children?.forEach((child) => recurse(treeNode, child))\n\n return treeNode as TreeNode<T>\n } catch (e) {\n throw new Error('Something went wrong with creating index files with the TreehNode class', { cause: e })\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-unsafe-argument */\nimport { EventEmitter as NodeEventEmitter } from 'node:events'\n\nexport class EventEmitter<TEvents extends Record<string, any>> {\n constructor() {\n this.#emitter.setMaxListeners(100)\n }\n #emitter = new NodeEventEmitter()\n\n emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void {\n this.#emitter.emit(eventName, ...(eventArg as []))\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import crypto from 'node:crypto'\nimport { performance } from 'node:perf_hooks'\n\nimport { EventEmitter } from './EventEmitter.ts'\n\nexport type QueueJob<T = unknown> = {\n (...args: unknown[]): Promise<T | void>\n}\n\ntype RunOptions = {\n controller?: AbortController\n name?: string\n description?: string\n}\n\ntype QueueItem = {\n reject: <T>(reason?: T) => void\n resolve: <T>(value: T | PromiseLike<T>) => void\n job: QueueJob<unknown>\n} & Required<RunOptions>\n\ntype Events = {\n jobDone: [result: unknown]\n jobFailed: [error: Error]\n}\n\nexport class Queue {\n #queue: QueueItem[] = []\n readonly eventEmitter: EventEmitter<Events> = new EventEmitter()\n\n #workerCount = 0\n\n #maxParallel: number\n #debug = false\n\n constructor(maxParallel: number, debug = false) {\n this.#maxParallel = maxParallel\n this.#debug = debug\n }\n\n run<T>(job: QueueJob<T>, options: RunOptions = { controller: new AbortController(), name: crypto.randomUUID(), description: '' }): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const item = { reject, resolve, job, name: options.name, description: options.description || options.name } as QueueItem\n\n options.controller?.signal.addEventListener('abort', () => {\n this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name)\n\n reject('Aborted')\n })\n\n this.#queue.push(item)\n this.#work()\n })\n }\n\n runSync<T>(job: QueueJob<T>, options: RunOptions = { controller: new AbortController(), name: crypto.randomUUID(), description: '' }): void {\n new Promise<T>((resolve, reject) => {\n const item = { reject, resolve, job, name: options.name, description: options.description || options.name } as QueueItem\n\n options.controller?.signal.addEventListener('abort', () => {\n this.#queue = this.#queue.filter((queueItem) => queueItem.name === item.name)\n })\n\n this.#queue.push(item)\n this.#work()\n })\n }\n\n get hasJobs(): boolean {\n return this.#workerCount > 0 || this.#queue.length > 0\n }\n\n get count(): number {\n return this.#workerCount\n }\n\n #work(): void {\n if (this.#workerCount >= this.#maxParallel) {\n return\n }\n\n this.#workerCount++\n\n let entry: QueueItem | undefined\n while ((entry = this.#queue.shift())) {\n const { reject, resolve, job, name, description } = entry\n\n if (this.#debug) {\n performance.mark(name + '_start')\n }\n\n job()\n .then((result) => {\n this.eventEmitter.emit('jobDone', result)\n\n resolve(result)\n\n if (this.#debug) {\n performance.mark(name + '_stop')\n performance.measure(description, name + '_start', name + '_stop')\n }\n })\n .catch((err) => {\n this.eventEmitter.emit('jobFailed', err as Error)\n reject(err)\n })\n }\n this.#workerCount--\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","/**\n * Behaves as an Error to log a warning in the console(still stops the execution)\n */\nexport class Warning extends Error {\n constructor(message?: string, options?: { cause: Error }) {\n super(message, { cause: options?.cause })\n\n this.name = 'Warning'\n }\n}\n\nexport class ValidationPluginError extends Error {}\n","import path from 'node:path'\n\nimport { createPluginCache } from './utils/cache.ts'\n\nimport type { FileManager } from './FileManager.ts'\nimport type { PluginManager } from './PluginManager.ts'\nimport type { KubbPlugin, KubbUserPluginWithLifeCycle, PluginContext, PluginFactoryOptions } from './types.ts'\n\ntype KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => KubbUserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>) {\n return (options: T['options']): ReturnType<KubbPluginFactory<T>> => {\n return factory(options)\n }\n}\n\ntype Options = {\n config: PluginContext['config']\n fileManager: FileManager\n pluginManager: PluginManager\n resolvePath: PluginContext['resolvePath']\n resolveName: PluginContext['resolveName']\n logger: PluginContext['logger']\n getPlugins: () => KubbPlugin[]\n plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type CorePluginOptions = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginName = 'core' satisfies CorePluginOptions['name']\nexport const pluginKey: CorePluginOptions['key'] = [pluginName] satisfies CorePluginOptions['key']\n\nexport const definePlugin = createPlugin<CorePluginOptions>((options) => {\n const { fileManager, pluginManager, resolvePath, resolveName, logger } = options\n\n return {\n name: pluginName,\n options,\n key: ['core'],\n\n api() {\n return {\n get config() {\n return options.config\n },\n get plugins() {\n return options.getPlugins()\n },\n get plugin() {\n // see pluginManger.#execute where we override with `.call` the this with the correct plugin\n return options.plugin as NonNullable<Options['plugin']>\n },\n logger,\n fileManager,\n pluginManager,\n async addFile(...files) {\n const resolvedFiles = await fileManager.add(...files)\n\n if (!Array.isArray(resolvedFiles)) {\n return [resolvedFiles]\n }\n\n return resolvedFiles\n },\n resolvePath,\n resolveName,\n cache: createPluginCache(),\n }\n },\n resolvePath(baseName) {\n const root = path.resolve(this.config.root, this.config.output.path)\n\n return path.resolve(root, baseName)\n },\n resolveName(name) {\n return name\n },\n }\n})\n","import type { PluginCache } from '../types.ts'\n\nexport interface Cache<TStore extends object = object> {\n delete(id: keyof TStore): boolean\n get(id: keyof TStore): TStore[keyof TStore] | null\n has(id: keyof TStore): boolean\n set(id: keyof TStore, value: unknown): void\n}\n\nexport function createPluginCache<TStore extends PluginCache>(Store: TStore = Object.create(null) as TStore): Cache<TStore> {\n return {\n set(id, value): void {\n Store[id] = [0, value] as TStore[keyof TStore]\n },\n get(id): TStore[keyof TStore] | null {\n const item = Store[id]\n if (!item) {\n return null\n }\n item[0] = 0\n return item[1] as TStore[keyof TStore]\n },\n has(id): boolean {\n const item = Store[id]\n if (!item) {\n return false\n }\n item[0] = 0\n return true\n },\n delete(id: keyof TStore): boolean {\n return delete Store[id]\n },\n }\n}\n","/* eslint-disable unused-imports/no-unused-vars */\n/* eslint-disable @typescript-eslint/no-unused-vars */\ntype PromiseFunc<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2\n\nexport type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc<infer X, infer Y>> ? X | Y : never\n\nexport function noReturn(): void {}\n\ntype SeqOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Array<Awaited<ValueOfPromiseFuncArray<TInput>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(\n promises: TInput,\n): TOutput {\n return promises.filter(Boolean).reduce(\n (promise, func) => {\n if (typeof func !== 'function') {\n throw new Error('HookSeq needs a function that returns a promise `() => Promise<unknown>`')\n }\n\n return promise.then((state) => {\n const calledFunc = func(state as TValue)\n\n if (calledFunc) {\n return calledFunc.then(Array.prototype.concat.bind(state))\n }\n })\n },\n Promise.resolve([] as unknown),\n ) as TOutput\n}\n\ntype HookFirstOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>\n\n/**\n * Chains promises, first non-null result stops and returns\n */\nexport function hookFirst<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookFirstOutput<TInput, TValue>>(\n promises: TInput,\n nullCheck = (state: any) => state !== null,\n): TOutput {\n let promise: Promise<unknown> = Promise.resolve(null) as Promise<unknown>\n\n for (const func of promises.filter(Boolean)) {\n promise = promise.then((state) => {\n if (nullCheck(state)) {\n return state\n }\n\n const calledFunc = func(state as TValue)\n\n return calledFunc\n })\n }\n\n return promise as TOutput\n}\n\ntype HookParallelOutput<TInput extends Array<PromiseFunc<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>\n\n/**\n * Run promises in parallel with allSettled\n */\nexport function hookParallel<TInput extends Array<PromiseFunc<TValue, null>>, TValue = unknown, TOutput = HookParallelOutput<TInput, TValue>>(\n promises: TInput,\n): TOutput {\n return Promise.allSettled(promises.filter(Boolean).map(promise => promise())) as TOutput\n}\n\nexport type Strategy = 'seq' | 'first' | 'parallel'\n\nexport type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc<TValue, null>>, TValue> = TStrategy extends 'first'\n ? HookFirstOutput<TInput, TValue>\n : TStrategy extends 'seq' ? SeqOutput<TInput, TValue>\n : TStrategy extends 'parallel' ? HookParallelOutput<TInput, TValue>\n : never\n\n// tests\n\ntype test = ValueOfPromiseFuncArray<Array<PromiseFunc<number, null>>>\n// ^?\n","import { hookFirst, hookParallel, hookSeq } from './utils/executeStrategies.ts'\n\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Strategy, StrategySwitch } from './utils/executeStrategies.ts'\n\ntype PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2\n\ntype Options<TState = any> = {\n nullCheck?: (state: TState) => boolean\n}\n\nexport class PromiseManager<TState = any> {\n #options: Options<TState> = {}\n\n constructor(options: Options<TState> = {}) {\n this.#options = options\n\n return this\n }\n\n run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(\n strategy: TStrategy,\n promises: TInput,\n ): TOutput {\n if (strategy === 'seq') {\n return hookSeq<TInput, TValue, TOutput>(promises)\n }\n\n if (strategy === 'first') {\n return hookFirst<TInput, TValue, TOutput>(promises, this.#options.nullCheck)\n }\n\n if (strategy === 'parallel') {\n return hookParallel<TInput, TValue, TOutput>(promises)\n }\n\n throw new Error(`${strategy} not implemented`)\n }\n}\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","/* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/no-unsafe-argument */\n\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { LogLevel } from './utils/logger.ts'\nimport { Queue } from './utils/Queue.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\nimport { ValidationPluginError } from './errors.ts'\nimport { FileManager } from './FileManager.ts'\nimport { definePlugin as defineCorePlugin } from './plugin.ts'\nimport { isPromise, isPromiseRejectedResult } from './PromiseManager.ts'\nimport { PromiseManager } from './PromiseManager.ts'\n\nimport type { PossiblePromise } from '@kubb/types'\nimport type { KubbFile } from './FileManager.ts'\nimport type { CorePluginOptions } from './plugin.ts'\nimport type {\n GetPluginFactoryOptions,\n KubbConfig,\n KubbPlugin,\n KubbPluginWithLifeCycle,\n KubbUserPlugin,\n KubbUserPluginWithLifeCycle,\n PluginFactoryOptions,\n PluginLifecycle,\n PluginLifecycleHooks,\n PluginParameter,\n ResolveNameParams,\n ResolvePathParams,\n} from './types.ts'\nimport type { Logger } from './utils/logger.ts'\nimport type { QueueJob } from './utils/Queue.ts'\n\ntype RequiredPluginLifecycle = Required<PluginLifecycle>\n\n/**\n * Get the type of the first argument in a function.\n * @example Arg0<(a: string, b: number) => void> -> string\n */\ntype Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0]\n\ntype Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq'\n\ntype Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {\n strategy: Strategy\n hookName: H\n plugin: KubbPlugin\n parameters?: unknown[] | undefined\n output?: unknown\n}\n\ntype ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H]\n\ntype SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {\n result: Result\n plugin: KubbPlugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n logger: Logger\n\n /**\n * Task for the FileManager\n */\n task: QueueJob<KubbFile.ResolvedFile>\n /**\n * Timeout between writes in the FileManager\n */\n writeTimeout?: number\n}\n\ntype Events = {\n execute: [executer: Executer]\n executed: [executer: Executer]\n error: [error: Error]\n}\n\nexport class PluginManager {\n readonly plugins: KubbPluginWithLifeCycle[]\n readonly fileManager: FileManager\n readonly eventEmitter: EventEmitter<Events> = new EventEmitter()\n\n readonly queue: Queue\n readonly config: KubbConfig\n\n readonly executed: Executer[] = []\n readonly logger: Logger\n readonly #core: KubbPlugin<CorePluginOptions>\n\n readonly #usedPluginNames: Record<string, number> = {}\n readonly #promiseManager: PromiseManager\n\n constructor(config: KubbConfig, options: Options) {\n this.config = config\n this.logger = options.logger\n this.queue = new Queue(100, this.logger.logLevel === LogLevel.debug)\n this.fileManager = new FileManager({ task: options.task, queue: this.queue, timeout: options.writeTimeout })\n this.#promiseManager = new PromiseManager({ nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result })\n\n const plugins = config.plugins || []\n\n const core = defineCorePlugin({\n config,\n logger: this.logger,\n pluginManager: this,\n fileManager: this.fileManager,\n resolvePath: this.resolvePath.bind(this),\n resolveName: this.resolveName.bind(this),\n getPlugins: this.#getSortedPlugins.bind(this),\n })\n\n // call core.api.call with empty context so we can transform `api()` to `api: {}`\n this.#core = this.#parse(core as unknown as KubbUserPlugin, this as any, core.api.call(null as any)) as KubbPlugin<CorePluginOptions>\n\n this.plugins = [this.#core, ...plugins].map((plugin) => {\n return this.#parse(plugin as KubbUserPlugin, this, this.#core.api)\n })\n\n return this\n }\n\n resolvePath = <TOptions = object>(params: ResolvePathParams<TOptions>): KubbFile.OptionalPath => {\n if (params.pluginKey) {\n const paths = this.hookForPluginSync({\n pluginKey: params.pluginKey,\n hookName: 'resolvePath',\n parameters: [params.baseName, params.directory, params.options as object],\n })\n\n if (paths && paths?.length > 1 && this.logger.logLevel === LogLevel.debug) {\n this.logger.warn(\n `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'} is not unique enough\\n\\nPaths: ${\n JSON.stringify(paths, undefined, 2)\n }\\n\\nFalling back on the first item.\\n`,\n )\n }\n\n return paths?.at(0)\n }\n return this.hookFirstSync({\n hookName: 'resolvePath',\n parameters: [params.baseName, params.directory, params.options as object],\n }).result\n }\n\n resolveName = (params: ResolveNameParams): string => {\n if (params.pluginKey) {\n const names = this.hookForPluginSync({\n pluginKey: params.pluginKey,\n hookName: 'resolveName',\n parameters: [params.name, params.type],\n })\n\n if (names && names?.length > 1 && this.logger.logLevel === LogLevel.debug) {\n this.logger.warn(\n `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'} is not unique enough\\n\\nNames: ${\n JSON.stringify(names, undefined, 2)\n }\\n\\nFalling back on the first item.\\n`,\n )\n }\n\n return transformReservedWord(names?.at(0) || params.name)\n }\n\n const name = this.hookFirstSync({\n hookName: 'resolveName',\n parameters: [params.name, params.type],\n }).result\n\n return transformReservedWord(name)\n }\n\n on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n this.eventEmitter.on(eventName, handler as any)\n }\n\n /**\n * Run only hook for a specific plugin name\n */\n hookForPlugin<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: KubbPlugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Promise<Array<ReturnType<ParseResult<H>> | null>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n const promises = plugins\n .map((plugin) => {\n return this.#execute<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n })\n .filter(Boolean)\n\n return Promise.all(promises)\n }\n\n hookForPluginSync<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: KubbPlugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Array<ReturnType<ParseResult<H>>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n return plugins\n .map((plugin) => {\n return this.#executeSync<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n })\n .filter(Boolean)\n }\n\n /**\n * Chains, first non-null result stops and returns\n */\n async hookFirst<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<KubbPlugin> | null\n }): Promise<SafeParseResult<H>> {\n const promises = this.#getSortedPlugins().filter(plugin => {\n return skipped ? skipped.has(plugin) : true\n }).map((plugin) => {\n return async () => {\n const value = await this.#execute<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n })\n\n return Promise.resolve(\n {\n plugin,\n result: value,\n } as SafeParseResult<H>,\n )\n }\n })\n\n return this.#promiseManager.run('first', promises)\n }\n\n /**\n * Chains, first non-null result stops and returns\n */\n hookFirstSync<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<KubbPlugin> | null\n }): SafeParseResult<H> {\n let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n\n for (const plugin of this.#getSortedPlugins()) {\n if (skipped && skipped.has(plugin)) {\n continue\n }\n\n parseResult = {\n result: this.#executeSync<H>({\n strategy: 'hookFirst',\n hookName,\n parameters,\n plugin,\n }),\n plugin,\n } as SafeParseResult<H>\n\n if (parseResult?.result != null) {\n break\n }\n }\n return parseResult\n }\n\n /**\n * Parallel, runs all plugins\n */\n async hookParallel<H extends PluginLifecycleHooks, TOuput = void>({\n hookName,\n parameters,\n }: {\n hookName: H\n parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined\n }): Promise<Awaited<TOuput>[]> {\n const promises = this.#getSortedPlugins().map((plugin) => {\n return () => this.#execute({ strategy: 'hookParallel', hookName, parameters, plugin }) as Promise<TOuput>\n })\n\n const results = await this.#promiseManager.run('parallel', promises)\n\n results\n .forEach((result, index) => {\n if (isPromiseRejectedResult<Error>(result)) {\n const plugin = this.#getSortedPlugins()[index]\n\n this.#catcher<H>(result.reason, plugin, hookName)\n }\n })\n\n return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n }\n\n /**\n * Chains, reduces returned value, handling the reduced value as the first hook argument\n */\n hookReduceArg0<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n reduce,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise<Argument0<H> | null>\n }): Promise<Argument0<H>> {\n const [argument0, ...rest] = parameters\n\n let promise: Promise<Argument0<H>> = Promise.resolve(argument0)\n for (const plugin of this.#getSortedPlugins()) {\n promise = promise\n .then((arg0) => {\n const value = this.#execute({\n strategy: 'hookReduceArg0',\n hookName,\n parameters: [arg0, ...rest] as PluginParameter<H>,\n plugin,\n })\n return value\n })\n .then((result) => reduce.call(this.#core.api, argument0, result as ReturnType<ParseResult<H>>, plugin)) as Promise<Argument0<H>>\n }\n\n return promise\n }\n\n /**\n * Chains plugins\n */\n async hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: { hookName: H; parameters?: PluginParameter<H> }): Promise<void> {\n const promises = this.#getSortedPlugins().map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookSeq',\n hookName,\n parameters,\n plugin,\n })\n })\n\n return this.#promiseManager.run('seq', promises)\n }\n\n #getSortedPlugins(hookName?: keyof PluginLifecycle): KubbPlugin[] {\n const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n if (hookName) {\n if (this.logger.logLevel === LogLevel.info) {\n const containsHookName = plugins.some((item) => item[hookName])\n if (!containsHookName) {\n this.logger.warn(`No hook ${hookName} found`)\n }\n }\n\n return plugins.filter((item) => item[hookName])\n }\n // TODO add test case for sorting with pre/post\n\n return plugins.map(plugin => {\n if (plugin.pre) {\n const isValid = plugin.pre.every(pluginName => plugins.find(pluginToFind => pluginToFind.name === pluginName))\n\n if (!isValid) {\n throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, undefined, 2)})`)\n }\n }\n\n return plugin\n }).sort((a, b) => {\n if (b.pre?.includes(a.name)) {\n return 1\n }\n if (b.post?.includes(a.name)) {\n return -1\n }\n return 0\n })\n }\n\n getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[] {\n const plugins = [...this.plugins]\n const [searchPluginName, searchIdentifier] = pluginKey\n\n const pluginByPluginName = plugins\n .filter((plugin) => plugin[hookName])\n .filter((item) => {\n const [name, identifier] = item.key\n\n const identifierCheck = identifier?.toString() === searchIdentifier?.toString()\n const nameCheck = name === searchPluginName\n\n if (searchIdentifier) {\n return identifierCheck && nameCheck\n }\n\n return nameCheck\n })\n\n if (!pluginByPluginName?.length) {\n // fallback on the core plugin when there is no match\n\n const corePlugin = plugins.find((plugin) => plugin.name === 'core' && plugin[hookName])\n\n if (this.logger.logLevel === LogLevel.debug) {\n if (corePlugin) {\n this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`)\n } else {\n this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`)\n }\n }\n\n return corePlugin ? [corePlugin] : []\n }\n\n return pluginByPluginName\n }\n\n #addExecutedToCallStack(executer: Executer | undefined) {\n if (executer) {\n this.eventEmitter.emit('executed', executer)\n this.executed.push(executer)\n }\n }\n\n /**\n * Run an async plugin hook and return the result.\n * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.\n * @param args Arguments passed to the plugin hook.\n * @param plugin The actual pluginObject to run.\n */\n // Implementation signature\n #execute<H extends PluginLifecycleHooks>({\n strategy,\n hookName,\n parameters,\n plugin,\n }: {\n strategy: Strategy\n hookName: H\n parameters: unknown[] | undefined\n plugin: KubbPluginWithLifeCycle\n }): Promise<ReturnType<ParseResult<H>> | null> | null {\n const hook = plugin[hookName]\n let output: unknown\n\n if (!hook) {\n return null\n }\n\n this.eventEmitter.emit('execute', { strategy, hookName, parameters, plugin })\n\n const task = Promise.resolve()\n .then(() => {\n if (typeof hook === 'function') {\n const possiblePromiseResult = (hook as Function).apply({ ...this.#core.api, plugin }, parameters) as Promise<ReturnType<ParseResult<H>>>\n\n if (isPromise(possiblePromiseResult)) {\n return Promise.resolve(possiblePromiseResult)\n }\n return possiblePromiseResult\n }\n\n return hook\n })\n .then((result) => {\n output = result\n\n this.#addExecutedToCallStack({\n parameters,\n output,\n strategy,\n hookName,\n plugin,\n })\n\n return result\n })\n .catch((e: Error) => {\n this.#catcher<H>(e, plugin, hookName)\n\n return null\n })\n\n return task\n }\n\n /**\n * Run a sync plugin hook and return the result.\n * @param hookName Name of the plugin hook. Must be in `PluginHooks`.\n * @param args Arguments passed to the plugin hook.\n * @param plugin The acutal plugin\n * @param replaceContext When passed, the plugin context can be overridden.\n */\n #executeSync<H extends PluginLifecycleHooks>({\n strategy,\n hookName,\n parameters,\n plugin,\n }: {\n strategy: Strategy\n hookName: H\n parameters: PluginParameter<H>\n plugin: KubbPluginWithLifeCycle\n }): ReturnType<ParseResult<H>> | null {\n const hook = plugin[hookName]\n let output: unknown\n\n if (!hook) {\n return null\n }\n\n this.eventEmitter.emit('execute', { strategy, hookName, parameters, plugin })\n\n try {\n if (typeof hook === 'function') {\n const fn = (hook as Function).apply({ ...this.#core.api, plugin }, parameters) as ReturnType<ParseResult<H>>\n\n output = fn\n return fn\n }\n\n output = hook\n\n this.#addExecutedToCallStack({\n parameters,\n output,\n strategy,\n hookName,\n plugin,\n })\n\n return hook\n } catch (e) {\n this.#catcher<H>(e as Error, plugin, hookName)\n\n return null\n }\n }\n\n #catcher<H extends PluginLifecycleHooks>(e: Error, plugin?: KubbPlugin, hookName?: H) {\n const text = `${e.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})\\n`\n\n this.logger.error(text)\n this.eventEmitter.emit('error', e)\n }\n\n #parse<TPlugin extends KubbUserPluginWithLifeCycle>(\n plugin: TPlugin,\n pluginManager: PluginManager,\n context: CorePluginOptions['api'] | undefined,\n ): KubbPlugin<GetPluginFactoryOptions<TPlugin>> {\n const usedPluginNames = pluginManager.#usedPluginNames\n\n setUniqueName(plugin.name, usedPluginNames)\n\n const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean) as [typeof plugin.name, string]\n\n if (plugin.name !== 'core' && usedPluginNames[plugin.name]! >= 2) {\n pluginManager.logger.warn('Using multiple of the same plugin is an experimental feature')\n }\n\n // default transform\n if (!plugin.transform) {\n plugin.transform = function transform(code) {\n return code\n }\n }\n\n if (plugin.api && typeof plugin.api === 'function') {\n const api = (plugin.api as Function).call(context) as typeof plugin.api\n\n return {\n ...plugin,\n key,\n api,\n } as unknown as KubbPlugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n return {\n ...plugin,\n key,\n } as unknown as KubbPlugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n static getDependedPlugins<\n T1 extends PluginFactoryOptions,\n T2 extends PluginFactoryOptions = never,\n T3 extends PluginFactoryOptions = never,\n TOutput = T3 extends never ? T2 extends never ? [T1: KubbPlugin<T1>]\n : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>]\n : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>, T3: KubbPlugin<T3>],\n >(plugins: Array<KubbPlugin>, dependedPluginNames: string | string[]): TOutput {\n let pluginNames: string[] = []\n if (typeof dependedPluginNames === 'string') {\n pluginNames = [dependedPluginNames]\n } else {\n pluginNames = dependedPluginNames\n }\n\n return pluginNames.map((pluginName) => {\n const plugin = plugins.find((plugin) => plugin.name === pluginName)\n if (!plugin) {\n throw new ValidationPluginError(`This plugin depends on the ${pluginName} plugin.`)\n }\n return plugin\n }) as TOutput\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static get hooks() {\n return ['buildStart', 'resolvePath', 'resolveName', 'load', 'transform', 'writeFile', 'buildEnd'] as const\n }\n}\n","/**\n * Abstract class that contains the building blocks for plugins to create their own Generator\n * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137\n */\nexport abstract class Generator<TOptions = unknown, TContext = unknown> {\n #options: TOptions = {} as TOptions\n #context: TContext = {} as TContext\n\n constructor(options?: TOptions, context?: TContext) {\n if (context) {\n this.#context = context\n }\n\n if (options) {\n this.#options = options\n }\n\n return this\n }\n\n get options(): TOptions {\n return this.#options\n }\n\n get context(): TContext {\n return this.#context\n }\n\n set options(options: TOptions) {\n this.#options = { ...this.#options, ...options }\n }\n\n abstract build(...params: unknown[]): unknown\n}\n","import mod from 'node:module'\nimport os from 'node:os'\nimport { pathToFileURL } from 'node:url'\n\nimport { findUp, findUpSync } from 'find-up'\nimport { coerce, satisfies } from 'semver'\n\ntype PackageJSON = {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n}\n\ntype DependencyName = string\n\ntype DependencyVersion = string\n\nexport class PackageManager {\n static #cache: Record<DependencyName, DependencyVersion> = {}\n\n #cwd?: string\n #SLASHES = new Set(['/', '\\\\'])\n constructor(workspace?: string) {\n if (workspace) {\n this.#cwd = workspace\n }\n\n return this\n }\n\n set workspace(workspace: string) {\n this.#cwd = workspace\n }\n\n get workspace(): string | undefined {\n return this.#cwd\n }\n\n normalizeDirectory(directory: string): string {\n if (!this.#SLASHES.has(directory[directory.length - 1]!)) {\n return `${directory}/`\n }\n\n return directory\n }\n\n getLocation(path: string): string {\n let location = path\n\n if (this.#cwd) {\n const require = mod.createRequire(this.normalizeDirectory(this.#cwd))\n location = require.resolve(path)\n }\n\n return location\n }\n\n async import(path: string): Promise<any | undefined> {\n try {\n let location = this.getLocation(path)\n\n if (os.platform() == 'win32') {\n location = pathToFileURL(location).href\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const module = await import(location)\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return\n return module?.default ?? module\n } catch (e) {\n console.log(e)\n return undefined\n }\n }\n\n async getPackageJSON(): Promise<PackageJSON | undefined> {\n const pkgPath = await findUp(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n return require(pkgPath) as PackageJSON\n }\n\n getPackageJSONSync(): PackageJSON | undefined {\n const pkgPath = findUpSync(['package.json'], {\n cwd: this.#cwd,\n })\n if (!pkgPath) {\n return undefined\n }\n\n return require(pkgPath) as PackageJSON\n }\n\n static setVersion(dependency: DependencyName, version: DependencyVersion): void {\n PackageManager.#cache[dependency] = version\n }\n\n #match(packageJSON: PackageJSON, dependency: DependencyName | RegExp): string | undefined {\n const dependencies = {\n ...packageJSON['dependencies'] || {},\n ...packageJSON['devDependencies'] || {},\n }\n\n if (typeof dependency === 'string' && dependencies[dependency]) {\n return dependencies[dependency]\n }\n\n const matchedDependency = Object.keys(dependencies).find(dep => dep.match(dependency))\n\n return matchedDependency ? dependencies[matchedDependency] : undefined\n }\n\n async getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined> {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = await this.getPackageJSON()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined {\n if (typeof dependency === 'string' && PackageManager.#cache[dependency]) {\n return PackageManager.#cache[dependency]\n }\n\n const packageJSON = this.getPackageJSONSync()\n\n if (!packageJSON) {\n return undefined\n }\n\n return this.#match(packageJSON, dependency)\n }\n\n async isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean> {\n const packageVersion = await this.getVersion(dependency)\n\n if (!packageVersion) {\n return false\n }\n\n if (packageVersion === version) {\n return true\n }\n\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean {\n const packageVersion = this.getVersionSync(dependency)\n\n if (!packageVersion) {\n return false\n }\n const semVer = coerce(packageVersion)\n\n if (!semVer) {\n throw new Error(`${packageVersion} is not valid`)\n }\n\n return satisfies(semVer, version)\n }\n}\n","import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {locatePath, locatePathSync} from 'locate-path';\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport const findUpStop = Symbol('findUpStop');\n\nexport async function findUpMultiple(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = path.resolve(directory, options.stopAt || root);\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = async locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePath(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = await name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePath([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst foundPath = await runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport function findUpMultipleSync(name, options = {}) {\n\tlet directory = path.resolve(toPath(options.cwd) || '');\n\tconst {root} = path.parse(directory);\n\tconst stopAt = options.stopAt || root;\n\tconst limit = options.limit || Number.POSITIVE_INFINITY;\n\tconst paths = [name].flat();\n\n\tconst runMatcher = locateOptions => {\n\t\tif (typeof name !== 'function') {\n\t\t\treturn locatePathSync(paths, locateOptions);\n\t\t}\n\n\t\tconst foundPath = name(locateOptions.cwd);\n\t\tif (typeof foundPath === 'string') {\n\t\t\treturn locatePathSync([foundPath], locateOptions);\n\t\t}\n\n\t\treturn foundPath;\n\t};\n\n\tconst matches = [];\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\tconst foundPath = runMatcher({...options, cwd: directory});\n\n\t\tif (foundPath === findUpStop) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (foundPath) {\n\t\t\tmatches.push(path.resolve(directory, foundPath));\n\t\t}\n\n\t\tif (directory === stopAt || matches.length >= limit) {\n\t\t\tbreak;\n\t\t}\n\n\t\tdirectory = path.dirname(directory);\n\t}\n\n\treturn matches;\n}\n\nexport async function findUp(name, options = {}) {\n\tconst matches = await findUpMultiple(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport function findUpSync(name, options = {}) {\n\tconst matches = findUpMultipleSync(name, {...options, limit: 1});\n\treturn matches[0];\n}\n\nexport {\n\tpathExists,\n\tpathExistsSync,\n} from 'path-exists';\n","import process from 'node:process';\nimport path from 'node:path';\nimport fs, {promises as fsPromises} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport pLocate from 'p-locate';\n\nconst typeMappings = {\n\tdirectory: 'isDirectory',\n\tfile: 'isFile',\n};\n\nfunction checkType(type) {\n\tif (Object.hasOwnProperty.call(typeMappings, type)) {\n\t\treturn;\n\t}\n\n\tthrow new Error(`Invalid type specified: ${type}`);\n}\n\nconst matchType = (type, stat) => stat[typeMappings[type]]();\n\nconst toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n\nexport async function locatePath(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t\tconcurrency,\n\t\tpreserveOrder,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;\n\n\treturn pLocate(paths, async path_ => {\n\t\ttry {\n\t\t\tconst stat = await statFunction(path.resolve(cwd, path_));\n\t\t\treturn matchType(type, stat);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, {concurrency, preserveOrder});\n}\n\nexport function locatePathSync(\n\tpaths,\n\t{\n\t\tcwd = process.cwd(),\n\t\ttype = 'file',\n\t\tallowSymlinks = true,\n\t} = {},\n) {\n\tcheckType(type);\n\tcwd = toPath(cwd);\n\n\tconst statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;\n\n\tfor (const path_ of paths) {\n\t\ttry {\n\t\t\tconst stat = statFunction(path.resolve(cwd, path_), {\n\t\t\t\tthrowIfNoEntry: false,\n\t\t\t});\n\n\t\t\tif (!stat) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (matchType(type, stat)) {\n\t\t\t\treturn path_;\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n","/*\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\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","import Queue from 'yocto-queue';\n\nexport default function pLimit(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\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\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});\n\n\treturn generator;\n}\n","import pLimit from 'p-limit';\n\nclass EndError extends Error {\n\tconstructor(value) {\n\t\tsuper();\n\t\tthis.value = value;\n\t}\n}\n\n// The input can also be a promise, so we await it.\nconst testElement = async (element, tester) => tester(await element);\n\n// The input can also be a promise, so we `Promise.all()` them both.\nconst finder = async element => {\n\tconst values = await Promise.all(element);\n\tif (values[1] === true) {\n\t\tthrow new EndError(values[0]);\n\t}\n\n\treturn false;\n};\n\nexport default async function pLocate(\n\titerable,\n\ttester,\n\t{\n\t\tconcurrency = Number.POSITIVE_INFINITY,\n\t\tpreserveOrder = true,\n\t} = {},\n) {\n\tconst limit = pLimit(concurrency);\n\n\t// Start all the promises concurrently with optional limit.\n\tconst items = [...iterable].map(element => [element, limit(testElement, element, tester)]);\n\n\t// Check the promises either serially or concurrently.\n\tconst checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);\n\n\ttry {\n\t\tawait Promise.all(items.map(element => checkLimit(finder, element)));\n\t} catch (error) {\n\t\tif (error instanceof EndError) {\n\t\t\treturn error.value;\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n","import fs, {promises as fsPromises} from 'node:fs';\n\nexport async function pathExists(path) {\n\ttry {\n\t\tawait fsPromises.access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function pathExistsSync(path) {\n\ttry {\n\t\tfs.accessSync(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n","import { build } from './build.ts'\n\nimport type { ObjValueTuple, TupleToUnion } from '@kubb/types'\n\nexport { build, safeBuild } from './build.ts'\nexport * from './config.ts'\nexport * from './errors.ts'\nexport * from './FileManager.ts'\nexport { Generator } from './Generator.ts'\nexport { PackageManager } from './PackageManager.ts'\n// dprint-ignore\nexport { createPlugin, pluginName as name, pluginName } from './plugin.ts'\nexport { PluginManager } from './PluginManager.ts'\nexport { PromiseManager } from './PromiseManager.ts'\nexport * from './types.ts'\n\nexport interface _Register {}\nexport type Plugins = _Register\nexport type OptionsPlugins = { [K in keyof Plugins]: Plugins[K]['options'] }\n\nexport type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options']\n\nexport type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>\n\nexport type Plugin = keyof Plugins\n\nexport default build\n"]}
|