@kubb/core 3.0.0-alpha.8 → 3.0.0-alpha.9

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 CHANGED
@@ -514,7 +514,7 @@ Falling back on the first item.
514
514
  if (executer) {
515
515
  this.events.emit("executed", executer);
516
516
  this.executed.push(executer);
517
- this.logger.emit("progress", { id: executer.hookName, data: `${executer.plugin.name} ${_optionalChain([executer, 'access', _27 => _27.parameters, 'optionalAccess', _28 => _28.join, 'call', _29 => _29(", ")]) || ""}` });
517
+ this.logger.emit("progress", { id: executer.hookName, data: `${executer.plugin.name}` });
518
518
  }
519
519
  }
520
520
  /**
@@ -604,7 +604,7 @@ Falling back on the first item.
604
604
  }
605
605
  }
606
606
  #catcher(cause, plugin, hookName) {
607
- const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _30 => _30.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
607
+ const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _27 => _27.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
608
608
  this.logger.emit("error", text, cause);
609
609
  this.events.emit("error", cause);
610
610
  }
@@ -700,18 +700,18 @@ async function safeBuild(options) {
700
700
  path: rootPath,
701
701
  baseName: "index.ts",
702
702
  exports: barrelFiles.flatMap((file) => {
703
- return _optionalChain([file, 'access', _31 => _31.sources, 'optionalAccess', _32 => _32.map, 'call', _33 => _33((source) => {
703
+ return _optionalChain([file, 'access', _28 => _28.sources, 'optionalAccess', _29 => _29.map, 'call', _30 => _30((source) => {
704
704
  if (!file.path || !source.isIndexable) {
705
705
  return void 0;
706
706
  }
707
707
  const plugin = pluginManager.plugins.find((item) => {
708
708
  const meta = file.meta;
709
- return item.name === _optionalChain([meta, 'optionalAccess', _34 => _34.pluginKey, 'optionalAccess', _35 => _35[0]]);
709
+ return item.name === _optionalChain([meta, 'optionalAccess', _31 => _31.pluginKey, 'optionalAccess', _32 => _32[0]]);
710
710
  });
711
- if (_optionalChain([plugin, 'optionalAccess', _36 => _36.output, 'optionalAccess', _37 => _37.exportType]) === false) {
711
+ if (_optionalChain([plugin, 'optionalAccess', _33 => _33.output, 'optionalAccess', _34 => _34.exportType]) === false) {
712
712
  return void 0;
713
713
  }
714
- if (_chunk5IGANEGEcjs.FileManager.getMode(_optionalChain([plugin, 'optionalAccess', _38 => _38.output, 'optionalAccess', _39 => _39.path])) === "single") {
714
+ if (_chunk5IGANEGEcjs.FileManager.getMode(_optionalChain([plugin, 'optionalAccess', _35 => _35.output, 'optionalAccess', _36 => _36.path])) === "single") {
715
715
  return void 0;
716
716
  }
717
717
  return {
@@ -719,7 +719,7 @@ async function safeBuild(options) {
719
719
  path: _fs.getRelativePath.call(void 0, rootPath, file.path),
720
720
  isTypeOnly: source.isTypeOnly
721
721
  };
722
- }), 'access', _40 => _40.filter, 'call', _41 => _41(Boolean)]);
722
+ }), 'access', _37 => _37.filter, 'call', _38 => _38(Boolean)]);
723
723
  }).filter(Boolean),
724
724
  sources: [],
725
725
  meta: {}
@@ -748,9 +748,9 @@ async function safeBuild(options) {
748
748
  };
749
749
  }
750
750
 
751
- // src/Generator.ts
751
+ // src/BaseGenerator.ts
752
752
  _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
753
- var Generator = class {
753
+ var BaseGenerator = class {
754
754
  #options = {};
755
755
  #context = {};
756
756
  constructor(options, context) {
@@ -1114,7 +1114,7 @@ var PackageManager = class _PackageManager {
1114
1114
  location = _url.pathToFileURL.call(void 0, location).href;
1115
1115
  }
1116
1116
  const module = await Promise.resolve().then(() => _interopRequireWildcard(require(location)));
1117
- return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _42 => _42.default]), () => ( module));
1117
+ return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _39 => _39.default]), () => ( module));
1118
1118
  } catch (e) {
1119
1119
  console.error(e);
1120
1120
  return void 0;
@@ -1212,5 +1212,5 @@ var PackageManager = class _PackageManager {
1212
1212
 
1213
1213
 
1214
1214
 
1215
- exports.FileManager = _chunk5IGANEGEcjs.FileManager; exports.Generator = Generator; exports.PackageManager = PackageManager; exports.PluginManager = PluginManager; exports.PromiseManager = PromiseManager; exports.build = build; exports.createPlugin = createPlugin; exports.default = build; exports.defineConfig = defineConfig; exports.isInputPath = isInputPath; exports.safeBuild = safeBuild;
1215
+ exports.BaseGenerator = BaseGenerator; exports.FileManager = _chunk5IGANEGEcjs.FileManager; exports.PackageManager = PackageManager; exports.PluginManager = PluginManager; exports.PromiseManager = PromiseManager; exports.build = build; exports.createPlugin = createPlugin; exports.default = build; exports.defineConfig = defineConfig; exports.isInputPath = isInputPath; exports.safeBuild = safeBuild;
1216
1216
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/core/dist/index.cjs","../src/index.ts","../src/build.ts","../src/PluginManager.ts","../src/PromiseManager.ts","../src/utils/executeStrategies.ts","../src/errors.ts","../src/plugin.ts","../src/utils/cache.ts","../src/config.ts","../src/Generator.ts","../src/PackageManager.ts","../../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js","../../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js","../../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js"],"names":["path","resolve","read","require"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACnBA,8CAAA,CAAA;ADqB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AA;AAEM,IAAA;AAEC,IAAA;AACT,EAAA;AAEiB,EAAA;AACJ,IAAA;AACF,MAAA;AACT,IAAA;AAEM,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AAEY,IAAA;AACd,EAAA;AAEe,EAAA;AACF,IAAA;AACF,MAAA;AACT,IAAA;AAEM,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AAEY,IAAA;AACd,EAAA;AAEc,EAAA;AACN,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AAEI,IAAA;AACK,MAAA;AACT,IAAA;AAEe,IAAA;AAEF,IAAA;AACD,MAAA;AACZ,IAAA;AAEiB,IAAA;AACnB,EAAA;AACY,EAAA;AACJ,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AACe,IAAA;AAEF,IAAA;AACD,MAAA;AACZ,IAAA;AAEiB,IAAA;AACnB,EAAA;AACF;AX6/BqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/core/dist/index.cjs","sourcesContent":[null,"export { build, build as default, safeBuild } from './build.ts'\nexport { defineConfig, isInputPath } from './config.ts'\nexport { FileManager } from './FileManager.ts'\nexport type { FileMetaBase } from './FileManager.ts'\nexport { Generator } from './Generator.ts'\nexport { PackageManager } from './PackageManager.ts'\nexport { createPlugin } from './plugin.ts'\nexport { PluginManager } from './PluginManager.ts'\nexport { PromiseManager } from './PromiseManager.ts'\nexport type * from './types.ts'\n","import { clean, read } from '@kubb/fs'\nimport type * as KubbFile from '@kubb/fs/types'\nimport { FileManager, processFiles } from './FileManager.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isInputPath } from './config.ts'\nimport { createLogger } from './logger.ts'\nimport { URLPath } from './utils/URLPath.ts'\n\nimport { resolve } from 'node:path'\nimport { getRelativePath } from '@kubb/fs'\nimport type { Logger } from './logger.ts'\nimport type { PluginContext } from './types.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 setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger() } = 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(`Cannot read file/URL defined in \\`input.path\\` or set with \\`kubb generate PATH\\` in the CLI of your Kubb config ${config.input.path}`, {\n cause: e,\n })\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n return new PluginManager(config, { logger })\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const { files, pluginManager, error } = await safeBuild(options)\n\n if (error) throw error\n\n return {\n files,\n pluginManager,\n error,\n }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n let files = []\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n // create root barrel file\n const root = resolve(options.config.root)\n const rootPath = resolve(root, options.config.output.path, 'index.ts')\n const barrelFiles = pluginManager.fileManager.files.filter((file) => {\n return file.sources.some((source) => source.isIndexable)\n })\n\n const rootFile: KubbFile.File = {\n path: rootPath,\n baseName: 'index.ts',\n exports: barrelFiles\n .flatMap((file) => {\n return file.sources\n ?.map((source) => {\n if (!file.path || !source.isIndexable) {\n return undefined\n }\n\n // validate of the file is coming from plugin x, needs pluginKey on every file TODO update typing\n const plugin = pluginManager.plugins.find((item) => {\n const meta = file.meta as any\n return item.name === meta?.pluginKey?.[0]\n })\n\n if (plugin?.output?.exportType === false) {\n return undefined\n }\n\n if (FileManager.getMode(plugin?.output?.path) === 'single') {\n return undefined\n }\n return {\n name: options.config.output.exportType === 'barrel' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: source.isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n })\n .filter(Boolean),\n sources: [],\n meta: {},\n }\n\n if (options.config.output.exportType) {\n await pluginManager.fileManager.add(rootFile)\n }\n\n //TODO set extName here instead of the files, extName is private. All exports will have extName, it's up the the process to hide.override the name\n files = await processFiles({\n config: options.config,\n dryRun: !options.config.output.write,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n pluginManager.fileManager.clear()\n } catch (e) {\n return {\n files: [],\n pluginManager,\n error: e as Error,\n }\n }\n\n return {\n files,\n pluginManager,\n }\n}\n","import { FileManager } from './FileManager.ts'\nimport { isPromise, isPromiseRejectedResult } from './PromiseManager.ts'\nimport { PromiseManager } from './PromiseManager.ts'\nimport { ValidationPluginError } from './errors.ts'\nimport { pluginCore } from './plugin.ts'\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Logger } from './logger.ts'\nimport type { PluginCore } from './plugin.ts'\nimport type {\n Config,\n GetPluginFactoryOptions,\n Plugin,\n PluginFactoryOptions,\n PluginLifecycle,\n PluginLifecycleHooks,\n PluginParameter,\n PluginWithLifeCycle,\n ResolveNameParams,\n ResolvePathParams,\n UserPlugin,\n UserPluginWithLifeCycle,\n} from './types.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: Plugin\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: Plugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n logger: Logger\n}\n\ntype Events = {\n execute: [executer: Executer]\n executed: [executer: Executer]\n error: [error: Error]\n}\n\ntype GetFileProps<TOptions = object> = {\n name: string\n mode?: KubbFile.Mode\n extName: KubbFile.Extname\n pluginKey: Plugin['key']\n options?: TOptions\n}\n\nexport class PluginManager {\n readonly plugins: PluginWithLifeCycle[]\n readonly fileManager: FileManager\n readonly events: EventEmitter<Events> = new EventEmitter()\n\n readonly config: Config\n\n readonly executed: Array<Executer> = []\n readonly logger: Logger\n readonly options: Options\n readonly #core: Plugin<PluginCore>\n\n readonly #usedPluginNames: Record<string, number> = {}\n readonly #promiseManager: PromiseManager\n\n constructor(config: Config, options: Options) {\n this.config = config\n this.options = options\n this.logger = options.logger\n this.fileManager = new FileManager()\n this.#promiseManager = new PromiseManager({\n nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result,\n })\n\n const plugins = config.plugins || []\n\n const core = pluginCore({\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.context.call with empty context so we can transform `context()` to `context: {}`\n this.#core = this.#parse(core as unknown as UserPlugin, this as any, core.context.call(null as any)) as Plugin<PluginCore>\n\n this.plugins = [this.#core, ...plugins].map((plugin) => {\n return this.#parse(plugin as UserPlugin, this, this.#core.context)\n })\n\n return this\n }\n\n getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {\n const baseName = `${name}${extName}` as const\n const path = this.resolvePath({ baseName, mode, pluginKey, options })\n\n if (!path) {\n throw new Error(`Filepath should be defined for resolvedName \"${name}\" and pluginKey [${JSON.stringify(pluginKey)}]`)\n }\n\n return {\n path,\n baseName,\n meta: {\n pluginKey,\n },\n sources: [],\n }\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.mode, params.options as object],\n })\n\n if (paths && paths?.length > 1) {\n this.logger.emit('debug', {\n logs: [\n `Cannot return a path where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nPaths: ${JSON.stringify(paths, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n ],\n })\n }\n\n return paths?.at(0)\n }\n return this.hookFirstSync({\n hookName: 'resolvePath',\n parameters: [params.baseName, params.mode, params.options as object],\n }).result\n }\n //TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path\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) {\n this.logger.emit('debug', {\n logs: [\n `Cannot return a name where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nNames: ${JSON.stringify(names, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\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 /**\n * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.\n */\n on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n this.events.on(eventName, handler as any)\n }\n\n /**\n * Run a specific hookName for plugin x.\n */\n async hookForPlugin<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Promise<Array<ReturnType<ParseResult<H>> | null>> {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\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 const items = await Promise.all(promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return items\n }\n /**\n * Run a specific hookName for plugin x.\n */\n\n hookForPluginSync<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Array<ReturnType<ParseResult<H>>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n const result = 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 return result\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n async hookFirst<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): Promise<SafeParseResult<H>> {\n const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.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 plugin,\n result: value,\n } as SafeParseResult<H>)\n }\n })\n\n const result = await this.#promiseManager.run('first', promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return result\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n hookFirstSync<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): SafeParseResult<H> {\n let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n\n for (const plugin of plugins) {\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\n return parseResult\n }\n\n /**\n * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).\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 plugins = this.#getSortedPlugins(hookName)\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookParallel',\n hookName,\n parameters,\n plugin,\n }) as Promise<TOuput>\n })\n\n const results = await this.#promiseManager.run('parallel', promises)\n\n results.forEach((result, index) => {\n if (isPromiseRejectedResult<Error>(result)) {\n const plugin = this.#getSortedPlugins(hookName)[index]\n\n this.#catcher<H>(result.reason, plugin, hookName)\n }\n })\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n }\n\n /**\n * Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.\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: Plugin) => PossiblePromise<Argument0<H> | null>\n }): Promise<Argument0<H>> {\n const [argument0, ...rest] = parameters\n const plugins = this.#getSortedPlugins(hookName)\n\n let promise: Promise<Argument0<H>> = Promise.resolve(argument0)\n for (const plugin of plugins) {\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.context, 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 plugins = this.#getSortedPlugins(hookName)\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookSeq',\n hookName,\n parameters,\n plugin,\n })\n })\n\n await this.#promiseManager.run('seq', promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n }\n\n #getSortedPlugins(hookName?: keyof PluginLifecycle): Plugin[] {\n const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n if (hookName) {\n const containsHookName = plugins.some((item) => item[hookName])\n if (!containsHookName) {\n this.logger.emit('debug', { logs: [`No hook ${hookName} found`] })\n }\n\n return plugins.filter((item) => item[hookName])\n }\n // TODO add test case for sorting with pre/post\n\n return plugins\n .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 })\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: Plugin['key']): Plugin[] {\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 (corePlugin) {\n this.logger.emit('debug', {\n logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`],\n })\n } else {\n this.logger.emit('debug', {\n logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`],\n })\n }\n return corePlugin ? [corePlugin] : []\n }\n\n return pluginByPluginName\n }\n\n #addExecutedToCallStack(executer: Executer | undefined) {\n if (executer) {\n this.events.emit('executed', executer)\n this.executed.push(executer)\n\n this.logger.emit('progress', { id: executer.hookName, data: `${executer.plugin.name} ${executer.parameters?.join(', ') || ''}` })\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: PluginWithLifeCycle\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.events.emit('execute', { strategy, hookName, parameters, plugin })\n const promise = new Promise((resolve) => {\n resolve(undefined)\n })\n\n const task = promise\n .then(() => {\n if (typeof hook === 'function') {\n const possiblePromiseResult = (hook as Function).apply({ ...this.#core.context, 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: PluginWithLifeCycle\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.events.emit('execute', { strategy, hookName, parameters, plugin })\n\n try {\n if (typeof hook === 'function') {\n const fn = (hook as Function).apply({ ...this.#core.context, 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>(cause: Error, plugin?: Plugin, hookName?: H) {\n const text = `${cause.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})`\n\n this.logger.emit('error', text, cause)\n this.events.emit('error', cause)\n }\n\n #parse<TPlugin extends UserPluginWithLifeCycle>(\n plugin: TPlugin,\n pluginManager: PluginManager,\n context: PluginCore['context'] | undefined,\n ): Plugin<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.context && typeof plugin.context === 'function') {\n return {\n ...plugin,\n key,\n context: (plugin.context as Function).call(context) as typeof plugin.context,\n } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n return {\n ...plugin,\n key,\n } as unknown as Plugin<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: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>],\n >(plugins: Array<Plugin>, 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 static get hooks() {\n return ['buildStart', 'resolvePath', 'resolveName', 'buildEnd'] as const\n }\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","type 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> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(promises: TInput): 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'\n ? SeqOutput<TInput, TValue>\n : TStrategy extends 'parallel'\n ? HookParallelOutput<TInput, TValue>\n : never\n\n// tests\n\ntype test = ValueOfPromiseFuncArray<Array<PromiseFunc<number, null>>>\n// ^?\n","export 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 { Plugin, PluginContext, PluginFactoryOptions, UserPluginWithLifeCycle } from './types.ts'\n\ntype PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>\n\ntype OptionalPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options?: T['options']) => UserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): OptionalPluginFactory<T> {\n return (options = {}) => {\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: () => Array<Plugin>\n plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type PluginCore = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginCore = createPlugin<PluginCore>((options) => {\n const { fileManager, pluginManager, resolvePath, resolveName, logger } = options\n\n return {\n name: 'core',\n options,\n key: ['core'],\n context() {\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 context 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(options.config.root, options.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","import type { PossiblePromise } from '@kubb/types'\nimport type { Config, InputPath, UserConfig } from './types.ts'\n\ntype Args = {\n /**\n * Path to `kubb.config.js`\n */\n config?: string\n /**\n * Watch changes on input\n */\n watch?: boolean\n\n /**\n * Log level to report when using the CLI\n *\n * `silent` will hide all information that is not relevant\n *\n * `info` will show all information possible(not related to the PluginManager)\n *\n * `debug` will show all information possible(related to the PluginManager), handy for seeing logs\n * @default `silent`\n */\n logLevel?: string\n /**\n * Run Kubb with Bun\n */\n bun?: boolean\n}\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link Config} 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<UserConfig | Array<UserConfig>>\n | ((\n /** The options derived from the CLI flags */\n args: Args,\n ) => PossiblePromise<UserConfig | Array<UserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: Config | undefined): result is Config<InputPath> {\n return !!result && 'path' in (result as any)\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\nimport { read, readSync } from '@kubb/fs'\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 const module = await import(location)\n\n return module?.default ?? module\n } catch (e) {\n console.error(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 const json = await read(pkgPath)\n\n return JSON.parse(json) 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 const json = readSync(pkgPath)\n\n return JSON.parse(json) 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 {locatePath, locatePathSync} from 'locate-path';\nimport {toPath} from 'unicorn-magic';\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, toPath(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 = path.resolve(directory, toPath(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","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 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","/*\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 {fileURLToPath} from 'node:url';\n\nexport function toPath(urlOrPath) {\n\treturn urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n}\n\nexport * from './default.js';\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"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/core/dist/index.cjs","../src/index.ts","../src/build.ts","../src/PluginManager.ts","../src/PromiseManager.ts","../src/utils/executeStrategies.ts","../src/errors.ts","../src/plugin.ts","../src/utils/cache.ts","../src/config.ts","../src/BaseGenerator.ts","../src/PackageManager.ts","../../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js","../../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js","../../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js","../../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js","../../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js","../../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js","../../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js"],"names":["path","resolve","read","require"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;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IAAA;AACF,MAAA;AACT,IAAA;AAEM,IAAA;AAEC,IAAA;AACT,EAAA;AAEiB,EAAA;AACJ,IAAA;AACF,MAAA;AACT,IAAA;AAEM,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AAEY,IAAA;AACd,EAAA;AAEe,EAAA;AACF,IAAA;AACF,MAAA;AACT,IAAA;AAEM,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AAEY,IAAA;AACd,EAAA;AAEc,EAAA;AACN,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AAEI,IAAA;AACK,MAAA;AACT,IAAA;AAEe,IAAA;AAEF,IAAA;AACD,MAAA;AACZ,IAAA;AAEiB,IAAA;AACnB,EAAA;AACY,EAAA;AACJ,IAAA;AAED,IAAA;AACI,MAAA;AACT,IAAA;AACe,IAAA;AAEF,IAAA;AACD,MAAA;AACZ,IAAA;AAEiB,IAAA;AACnB,EAAA;AACF;AX6/BqB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/core/dist/index.cjs","sourcesContent":[null,"export { build, build as default, safeBuild } from './build.ts'\nexport { defineConfig, isInputPath } from './config.ts'\nexport { FileManager } from './FileManager.ts'\nexport type { FileMetaBase } from './FileManager.ts'\nexport { BaseGenerator } from './BaseGenerator.ts'\nexport { PackageManager } from './PackageManager.ts'\nexport { createPlugin } from './plugin.ts'\nexport { PluginManager } from './PluginManager.ts'\nexport { PromiseManager } from './PromiseManager.ts'\nexport type * from './types.ts'\n","import { clean, read } from '@kubb/fs'\nimport type * as KubbFile from '@kubb/fs/types'\nimport { FileManager, processFiles } from './FileManager.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isInputPath } from './config.ts'\nimport { createLogger } from './logger.ts'\nimport { URLPath } from './utils/URLPath.ts'\n\nimport { resolve } from 'node:path'\nimport { getRelativePath } from '@kubb/fs'\nimport type { Logger } from './logger.ts'\nimport type { PluginContext } from './types.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 setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger() } = 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(`Cannot read file/URL defined in \\`input.path\\` or set with \\`kubb generate PATH\\` in the CLI of your Kubb config ${config.input.path}`, {\n cause: e,\n })\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n return new PluginManager(config, { logger })\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const { files, pluginManager, error } = await safeBuild(options)\n\n if (error) throw error\n\n return {\n files,\n pluginManager,\n error,\n }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n let files = []\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n // create root barrel file\n const root = resolve(options.config.root)\n const rootPath = resolve(root, options.config.output.path, 'index.ts')\n const barrelFiles = pluginManager.fileManager.files.filter((file) => {\n return file.sources.some((source) => source.isIndexable)\n })\n\n const rootFile: KubbFile.File = {\n path: rootPath,\n baseName: 'index.ts',\n exports: barrelFiles\n .flatMap((file) => {\n return file.sources\n ?.map((source) => {\n if (!file.path || !source.isIndexable) {\n return undefined\n }\n\n // validate of the file is coming from plugin x, needs pluginKey on every file TODO update typing\n const plugin = pluginManager.plugins.find((item) => {\n const meta = file.meta as any\n return item.name === meta?.pluginKey?.[0]\n })\n\n if (plugin?.output?.exportType === false) {\n return undefined\n }\n\n if (FileManager.getMode(plugin?.output?.path) === 'single') {\n return undefined\n }\n return {\n name: options.config.output.exportType === 'barrel' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: source.isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n })\n .filter(Boolean),\n sources: [],\n meta: {},\n }\n\n if (options.config.output.exportType) {\n await pluginManager.fileManager.add(rootFile)\n }\n\n //TODO set extName here instead of the files, extName is private. All exports will have extName, it's up the the process to hide.override the name\n files = await processFiles({\n config: options.config,\n dryRun: !options.config.output.write,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n pluginManager.fileManager.clear()\n } catch (e) {\n return {\n files: [],\n pluginManager,\n error: e as Error,\n }\n }\n\n return {\n files,\n pluginManager,\n }\n}\n","import { FileManager } from './FileManager.ts'\nimport { isPromise, isPromiseRejectedResult } from './PromiseManager.ts'\nimport { PromiseManager } from './PromiseManager.ts'\nimport { ValidationPluginError } from './errors.ts'\nimport { pluginCore } from './plugin.ts'\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Logger } from './logger.ts'\nimport type { PluginCore } from './plugin.ts'\nimport type {\n Config,\n GetPluginFactoryOptions,\n Plugin,\n PluginFactoryOptions,\n PluginLifecycle,\n PluginLifecycleHooks,\n PluginParameter,\n PluginWithLifeCycle,\n ResolveNameParams,\n ResolvePathParams,\n UserPlugin,\n UserPluginWithLifeCycle,\n} from './types.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: Plugin\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: Plugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n logger: Logger\n}\n\ntype Events = {\n execute: [executer: Executer]\n executed: [executer: Executer]\n error: [error: Error]\n}\n\ntype GetFileProps<TOptions = object> = {\n name: string\n mode?: KubbFile.Mode\n extName: KubbFile.Extname\n pluginKey: Plugin['key']\n options?: TOptions\n}\n\nexport class PluginManager {\n readonly plugins: PluginWithLifeCycle[]\n readonly fileManager: FileManager\n readonly events: EventEmitter<Events> = new EventEmitter()\n\n readonly config: Config\n\n readonly executed: Array<Executer> = []\n readonly logger: Logger\n readonly options: Options\n readonly #core: Plugin<PluginCore>\n\n readonly #usedPluginNames: Record<string, number> = {}\n readonly #promiseManager: PromiseManager\n\n constructor(config: Config, options: Options) {\n this.config = config\n this.options = options\n this.logger = options.logger\n this.fileManager = new FileManager()\n this.#promiseManager = new PromiseManager({\n nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result,\n })\n\n const plugins = config.plugins || []\n\n const core = pluginCore({\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.context.call with empty context so we can transform `context()` to `context: {}`\n this.#core = this.#parse(core as unknown as UserPlugin, this as any, core.context.call(null as any)) as Plugin<PluginCore>\n\n this.plugins = [this.#core, ...plugins].map((plugin) => {\n return this.#parse(plugin as UserPlugin, this, this.#core.context)\n })\n\n return this\n }\n\n getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {\n const baseName = `${name}${extName}` as const\n const path = this.resolvePath({ baseName, mode, pluginKey, options })\n\n if (!path) {\n throw new Error(`Filepath should be defined for resolvedName \"${name}\" and pluginKey [${JSON.stringify(pluginKey)}]`)\n }\n\n return {\n path,\n baseName,\n meta: {\n pluginKey,\n },\n sources: [],\n }\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.mode, params.options as object],\n })\n\n if (paths && paths?.length > 1) {\n this.logger.emit('debug', {\n logs: [\n `Cannot return a path where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nPaths: ${JSON.stringify(paths, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n ],\n })\n }\n\n return paths?.at(0)\n }\n return this.hookFirstSync({\n hookName: 'resolvePath',\n parameters: [params.baseName, params.mode, params.options as object],\n }).result\n }\n //TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path\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) {\n this.logger.emit('debug', {\n logs: [\n `Cannot return a name where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nNames: ${JSON.stringify(names, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\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 /**\n * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.\n */\n on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n this.events.on(eventName, handler as any)\n }\n\n /**\n * Run a specific hookName for plugin x.\n */\n async hookForPlugin<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Promise<Array<ReturnType<ParseResult<H>> | null>> {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\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 const items = await Promise.all(promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return items\n }\n /**\n * Run a specific hookName for plugin x.\n */\n\n hookForPluginSync<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Array<ReturnType<ParseResult<H>>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n const result = 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 return result\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n async hookFirst<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): Promise<SafeParseResult<H>> {\n const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.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 plugin,\n result: value,\n } as SafeParseResult<H>)\n }\n })\n\n const result = await this.#promiseManager.run('first', promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return result\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n hookFirstSync<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): SafeParseResult<H> {\n let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n\n for (const plugin of plugins) {\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\n return parseResult\n }\n\n /**\n * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).\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 plugins = this.#getSortedPlugins(hookName)\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookParallel',\n hookName,\n parameters,\n plugin,\n }) as Promise<TOuput>\n })\n\n const results = await this.#promiseManager.run('parallel', promises)\n\n results.forEach((result, index) => {\n if (isPromiseRejectedResult<Error>(result)) {\n const plugin = this.#getSortedPlugins(hookName)[index]\n\n this.#catcher<H>(result.reason, plugin, hookName)\n }\n })\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n }\n\n /**\n * Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.\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: Plugin) => PossiblePromise<Argument0<H> | null>\n }): Promise<Argument0<H>> {\n const [argument0, ...rest] = parameters\n const plugins = this.#getSortedPlugins(hookName)\n\n let promise: Promise<Argument0<H>> = Promise.resolve(argument0)\n for (const plugin of plugins) {\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.context, 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 plugins = this.#getSortedPlugins(hookName)\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookSeq',\n hookName,\n parameters,\n plugin,\n })\n })\n\n await this.#promiseManager.run('seq', promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n }\n\n #getSortedPlugins(hookName?: keyof PluginLifecycle): Plugin[] {\n const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n if (hookName) {\n const containsHookName = plugins.some((item) => item[hookName])\n if (!containsHookName) {\n this.logger.emit('debug', { logs: [`No hook ${hookName} found`] })\n }\n\n return plugins.filter((item) => item[hookName])\n }\n // TODO add test case for sorting with pre/post\n\n return plugins\n .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 })\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: Plugin['key']): Plugin[] {\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 (corePlugin) {\n this.logger.emit('debug', {\n logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`],\n })\n } else {\n this.logger.emit('debug', {\n logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`],\n })\n }\n return corePlugin ? [corePlugin] : []\n }\n\n return pluginByPluginName\n }\n\n #addExecutedToCallStack(executer: Executer | undefined) {\n if (executer) {\n this.events.emit('executed', executer)\n this.executed.push(executer)\n\n this.logger.emit('progress', { id: executer.hookName, data: `${executer.plugin.name}` })\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: PluginWithLifeCycle\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.events.emit('execute', { strategy, hookName, parameters, plugin })\n const promise = new Promise((resolve) => {\n resolve(undefined)\n })\n\n const task = promise\n .then(() => {\n if (typeof hook === 'function') {\n const possiblePromiseResult = (hook as Function).apply({ ...this.#core.context, 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: PluginWithLifeCycle\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.events.emit('execute', { strategy, hookName, parameters, plugin })\n\n try {\n if (typeof hook === 'function') {\n const fn = (hook as Function).apply({ ...this.#core.context, 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>(cause: Error, plugin?: Plugin, hookName?: H) {\n const text = `${cause.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})`\n\n this.logger.emit('error', text, cause)\n this.events.emit('error', cause)\n }\n\n #parse<TPlugin extends UserPluginWithLifeCycle>(\n plugin: TPlugin,\n pluginManager: PluginManager,\n context: PluginCore['context'] | undefined,\n ): Plugin<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.context && typeof plugin.context === 'function') {\n return {\n ...plugin,\n key,\n context: (plugin.context as Function).call(context) as typeof plugin.context,\n } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n return {\n ...plugin,\n key,\n } as unknown as Plugin<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: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>],\n >(plugins: Array<Plugin>, 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 static get hooks() {\n return ['buildStart', 'resolvePath', 'resolveName', 'buildEnd'] as const\n }\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","type 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> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(promises: TInput): 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'\n ? SeqOutput<TInput, TValue>\n : TStrategy extends 'parallel'\n ? HookParallelOutput<TInput, TValue>\n : never\n\n// tests\n\ntype test = ValueOfPromiseFuncArray<Array<PromiseFunc<number, null>>>\n// ^?\n","export 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 { Plugin, PluginContext, PluginFactoryOptions, UserPluginWithLifeCycle } from './types.ts'\n\ntype PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>\n\ntype OptionalPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options?: T['options']) => UserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): OptionalPluginFactory<T> {\n return (options = {}) => {\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: () => Array<Plugin>\n plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type PluginCore = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginCore = createPlugin<PluginCore>((options) => {\n const { fileManager, pluginManager, resolvePath, resolveName, logger } = options\n\n return {\n name: 'core',\n options,\n key: ['core'],\n context() {\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 context 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(options.config.root, options.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","import type { PossiblePromise } from '@kubb/types'\nimport type { Config, InputPath, UserConfig } from './types.ts'\n\ntype Args = {\n /**\n * Path to `kubb.config.js`\n */\n config?: string\n /**\n * Watch changes on input\n */\n watch?: boolean\n\n /**\n * Log level to report when using the CLI\n *\n * `silent` will hide all information that is not relevant\n *\n * `info` will show all information possible(not related to the PluginManager)\n *\n * `debug` will show all information possible(related to the PluginManager), handy for seeing logs\n * @default `silent`\n */\n logLevel?: string\n /**\n * Run Kubb with Bun\n */\n bun?: boolean\n}\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link Config} 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<UserConfig | Array<UserConfig>>\n | ((\n /** The options derived from the CLI flags */\n args: Args,\n ) => PossiblePromise<UserConfig | Array<UserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: Config | undefined): result is Config<InputPath> {\n return !!result && 'path' in (result as any)\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 BaseGenerator<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\nimport { read, readSync } from '@kubb/fs'\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 const module = await import(location)\n\n return module?.default ?? module\n } catch (e) {\n console.error(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 const json = await read(pkgPath)\n\n return JSON.parse(json) 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 const json = readSync(pkgPath)\n\n return JSON.parse(json) 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 {locatePath, locatePathSync} from 'locate-path';\nimport {toPath} from 'unicorn-magic';\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, toPath(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 = path.resolve(directory, toPath(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","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 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","/*\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 {fileURLToPath} from 'node:url';\n\nexport function toPath(urlOrPath) {\n\treturn urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;\n}\n\nexport * from './default.js';\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"]}
package/dist/index.d.cts CHANGED
@@ -63,7 +63,7 @@ declare function isInputPath(result: Config | undefined): result is Config<Input
63
63
  * Abstract class that contains the building blocks for plugins to create their own Generator
64
64
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
65
65
  */
66
- declare abstract class Generator<TOptions = unknown, TContext = unknown> {
66
+ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
67
67
  #private;
68
68
  constructor(options?: TOptions, context?: TContext);
69
69
  get options(): TOptions;
@@ -117,4 +117,4 @@ declare class PromiseManager<TState = any> {
117
117
  run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(strategy: TStrategy, promises: TInput): TOutput;
118
118
  }
119
119
 
120
- export { Config, FileManager, Generator, InputPath, PackageManager, PluginContext, PluginFactoryOptions, PluginManager, PromiseManager, UserConfig, UserPluginWithLifeCycle, build, createPlugin, build as default, defineConfig, isInputPath, safeBuild };
120
+ export { BaseGenerator, Config, FileManager, InputPath, PackageManager, PluginContext, PluginFactoryOptions, PluginManager, PromiseManager, UserConfig, UserPluginWithLifeCycle, build, createPlugin, build as default, defineConfig, isInputPath, safeBuild };
package/dist/index.d.ts CHANGED
@@ -63,7 +63,7 @@ declare function isInputPath(result: Config | undefined): result is Config<Input
63
63
  * Abstract class that contains the building blocks for plugins to create their own Generator
64
64
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
65
65
  */
66
- declare abstract class Generator<TOptions = unknown, TContext = unknown> {
66
+ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
67
67
  #private;
68
68
  constructor(options?: TOptions, context?: TContext);
69
69
  get options(): TOptions;
@@ -117,4 +117,4 @@ declare class PromiseManager<TState = any> {
117
117
  run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(strategy: TStrategy, promises: TInput): TOutput;
118
118
  }
119
119
 
120
- export { Config, FileManager, Generator, InputPath, PackageManager, PluginContext, PluginFactoryOptions, PluginManager, PromiseManager, UserConfig, UserPluginWithLifeCycle, build, createPlugin, build as default, defineConfig, isInputPath, safeBuild };
120
+ export { BaseGenerator, Config, FileManager, InputPath, PackageManager, PluginContext, PluginFactoryOptions, PluginManager, PromiseManager, UserConfig, UserPluginWithLifeCycle, build, createPlugin, build as default, defineConfig, isInputPath, safeBuild };
package/dist/index.js CHANGED
@@ -497,7 +497,7 @@ Falling back on the first item.
497
497
  if (executer) {
498
498
  this.events.emit("executed", executer);
499
499
  this.executed.push(executer);
500
- this.logger.emit("progress", { id: executer.hookName, data: `${executer.plugin.name} ${executer.parameters?.join(", ") || ""}` });
500
+ this.logger.emit("progress", { id: executer.hookName, data: `${executer.plugin.name}` });
501
501
  }
502
502
  }
503
503
  /**
@@ -730,8 +730,8 @@ async function safeBuild(options) {
730
730
  };
731
731
  }
732
732
 
733
- // src/Generator.ts
734
- var Generator = class {
733
+ // src/BaseGenerator.ts
734
+ var BaseGenerator = class {
735
735
  #options = {};
736
736
  #context = {};
737
737
  constructor(options, context) {
@@ -885,8 +885,8 @@ var PackageManager = class _PackageManager {
885
885
  }
886
886
  };
887
887
  export {
888
+ BaseGenerator,
888
889
  FileManager,
889
- Generator,
890
890
  PackageManager,
891
891
  PluginManager,
892
892
  PromiseManager,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/build.ts","../src/utils/executeStrategies.ts","../src/PromiseManager.ts","../src/errors.ts","../src/plugin.ts","../src/utils/cache.ts","../src/PluginManager.ts","../src/config.ts","../src/Generator.ts","../src/PackageManager.ts"],"sourcesContent":["import { clean, read } from '@kubb/fs'\nimport type * as KubbFile from '@kubb/fs/types'\nimport { FileManager, processFiles } from './FileManager.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isInputPath } from './config.ts'\nimport { createLogger } from './logger.ts'\nimport { URLPath } from './utils/URLPath.ts'\n\nimport { resolve } from 'node:path'\nimport { getRelativePath } from '@kubb/fs'\nimport type { Logger } from './logger.ts'\nimport type { PluginContext } from './types.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 setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger() } = 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(`Cannot read file/URL defined in \\`input.path\\` or set with \\`kubb generate PATH\\` in the CLI of your Kubb config ${config.input.path}`, {\n cause: e,\n })\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n return new PluginManager(config, { logger })\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const { files, pluginManager, error } = await safeBuild(options)\n\n if (error) throw error\n\n return {\n files,\n pluginManager,\n error,\n }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n let files = []\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n // create root barrel file\n const root = resolve(options.config.root)\n const rootPath = resolve(root, options.config.output.path, 'index.ts')\n const barrelFiles = pluginManager.fileManager.files.filter((file) => {\n return file.sources.some((source) => source.isIndexable)\n })\n\n const rootFile: KubbFile.File = {\n path: rootPath,\n baseName: 'index.ts',\n exports: barrelFiles\n .flatMap((file) => {\n return file.sources\n ?.map((source) => {\n if (!file.path || !source.isIndexable) {\n return undefined\n }\n\n // validate of the file is coming from plugin x, needs pluginKey on every file TODO update typing\n const plugin = pluginManager.plugins.find((item) => {\n const meta = file.meta as any\n return item.name === meta?.pluginKey?.[0]\n })\n\n if (plugin?.output?.exportType === false) {\n return undefined\n }\n\n if (FileManager.getMode(plugin?.output?.path) === 'single') {\n return undefined\n }\n return {\n name: options.config.output.exportType === 'barrel' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: source.isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n })\n .filter(Boolean),\n sources: [],\n meta: {},\n }\n\n if (options.config.output.exportType) {\n await pluginManager.fileManager.add(rootFile)\n }\n\n //TODO set extName here instead of the files, extName is private. All exports will have extName, it's up the the process to hide.override the name\n files = await processFiles({\n config: options.config,\n dryRun: !options.config.output.write,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n pluginManager.fileManager.clear()\n } catch (e) {\n return {\n files: [],\n pluginManager,\n error: e as Error,\n }\n }\n\n return {\n files,\n pluginManager,\n }\n}\n","type 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> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(promises: TInput): 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'\n ? SeqOutput<TInput, TValue>\n : TStrategy extends 'parallel'\n ? 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","export 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 { Plugin, PluginContext, PluginFactoryOptions, UserPluginWithLifeCycle } from './types.ts'\n\ntype PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>\n\ntype OptionalPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options?: T['options']) => UserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): OptionalPluginFactory<T> {\n return (options = {}) => {\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: () => Array<Plugin>\n plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type PluginCore = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginCore = createPlugin<PluginCore>((options) => {\n const { fileManager, pluginManager, resolvePath, resolveName, logger } = options\n\n return {\n name: 'core',\n options,\n key: ['core'],\n context() {\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 context 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(options.config.root, options.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","import { FileManager } from './FileManager.ts'\nimport { isPromise, isPromiseRejectedResult } from './PromiseManager.ts'\nimport { PromiseManager } from './PromiseManager.ts'\nimport { ValidationPluginError } from './errors.ts'\nimport { pluginCore } from './plugin.ts'\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Logger } from './logger.ts'\nimport type { PluginCore } from './plugin.ts'\nimport type {\n Config,\n GetPluginFactoryOptions,\n Plugin,\n PluginFactoryOptions,\n PluginLifecycle,\n PluginLifecycleHooks,\n PluginParameter,\n PluginWithLifeCycle,\n ResolveNameParams,\n ResolvePathParams,\n UserPlugin,\n UserPluginWithLifeCycle,\n} from './types.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: Plugin\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: Plugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n logger: Logger\n}\n\ntype Events = {\n execute: [executer: Executer]\n executed: [executer: Executer]\n error: [error: Error]\n}\n\ntype GetFileProps<TOptions = object> = {\n name: string\n mode?: KubbFile.Mode\n extName: KubbFile.Extname\n pluginKey: Plugin['key']\n options?: TOptions\n}\n\nexport class PluginManager {\n readonly plugins: PluginWithLifeCycle[]\n readonly fileManager: FileManager\n readonly events: EventEmitter<Events> = new EventEmitter()\n\n readonly config: Config\n\n readonly executed: Array<Executer> = []\n readonly logger: Logger\n readonly options: Options\n readonly #core: Plugin<PluginCore>\n\n readonly #usedPluginNames: Record<string, number> = {}\n readonly #promiseManager: PromiseManager\n\n constructor(config: Config, options: Options) {\n this.config = config\n this.options = options\n this.logger = options.logger\n this.fileManager = new FileManager()\n this.#promiseManager = new PromiseManager({\n nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result,\n })\n\n const plugins = config.plugins || []\n\n const core = pluginCore({\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.context.call with empty context so we can transform `context()` to `context: {}`\n this.#core = this.#parse(core as unknown as UserPlugin, this as any, core.context.call(null as any)) as Plugin<PluginCore>\n\n this.plugins = [this.#core, ...plugins].map((plugin) => {\n return this.#parse(plugin as UserPlugin, this, this.#core.context)\n })\n\n return this\n }\n\n getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {\n const baseName = `${name}${extName}` as const\n const path = this.resolvePath({ baseName, mode, pluginKey, options })\n\n if (!path) {\n throw new Error(`Filepath should be defined for resolvedName \"${name}\" and pluginKey [${JSON.stringify(pluginKey)}]`)\n }\n\n return {\n path,\n baseName,\n meta: {\n pluginKey,\n },\n sources: [],\n }\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.mode, params.options as object],\n })\n\n if (paths && paths?.length > 1) {\n this.logger.emit('debug', {\n logs: [\n `Cannot return a path where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nPaths: ${JSON.stringify(paths, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n ],\n })\n }\n\n return paths?.at(0)\n }\n return this.hookFirstSync({\n hookName: 'resolvePath',\n parameters: [params.baseName, params.mode, params.options as object],\n }).result\n }\n //TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path\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) {\n this.logger.emit('debug', {\n logs: [\n `Cannot return a name where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nNames: ${JSON.stringify(names, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\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 /**\n * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.\n */\n on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n this.events.on(eventName, handler as any)\n }\n\n /**\n * Run a specific hookName for plugin x.\n */\n async hookForPlugin<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Promise<Array<ReturnType<ParseResult<H>> | null>> {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\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 const items = await Promise.all(promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return items\n }\n /**\n * Run a specific hookName for plugin x.\n */\n\n hookForPluginSync<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Array<ReturnType<ParseResult<H>>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n const result = 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 return result\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n async hookFirst<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): Promise<SafeParseResult<H>> {\n const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.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 plugin,\n result: value,\n } as SafeParseResult<H>)\n }\n })\n\n const result = await this.#promiseManager.run('first', promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return result\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n hookFirstSync<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): SafeParseResult<H> {\n let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n\n for (const plugin of plugins) {\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\n return parseResult\n }\n\n /**\n * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).\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 plugins = this.#getSortedPlugins(hookName)\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookParallel',\n hookName,\n parameters,\n plugin,\n }) as Promise<TOuput>\n })\n\n const results = await this.#promiseManager.run('parallel', promises)\n\n results.forEach((result, index) => {\n if (isPromiseRejectedResult<Error>(result)) {\n const plugin = this.#getSortedPlugins(hookName)[index]\n\n this.#catcher<H>(result.reason, plugin, hookName)\n }\n })\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n }\n\n /**\n * Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.\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: Plugin) => PossiblePromise<Argument0<H> | null>\n }): Promise<Argument0<H>> {\n const [argument0, ...rest] = parameters\n const plugins = this.#getSortedPlugins(hookName)\n\n let promise: Promise<Argument0<H>> = Promise.resolve(argument0)\n for (const plugin of plugins) {\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.context, 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 plugins = this.#getSortedPlugins(hookName)\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookSeq',\n hookName,\n parameters,\n plugin,\n })\n })\n\n await this.#promiseManager.run('seq', promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n }\n\n #getSortedPlugins(hookName?: keyof PluginLifecycle): Plugin[] {\n const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n if (hookName) {\n const containsHookName = plugins.some((item) => item[hookName])\n if (!containsHookName) {\n this.logger.emit('debug', { logs: [`No hook ${hookName} found`] })\n }\n\n return plugins.filter((item) => item[hookName])\n }\n // TODO add test case for sorting with pre/post\n\n return plugins\n .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 })\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: Plugin['key']): Plugin[] {\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 (corePlugin) {\n this.logger.emit('debug', {\n logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`],\n })\n } else {\n this.logger.emit('debug', {\n logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`],\n })\n }\n return corePlugin ? [corePlugin] : []\n }\n\n return pluginByPluginName\n }\n\n #addExecutedToCallStack(executer: Executer | undefined) {\n if (executer) {\n this.events.emit('executed', executer)\n this.executed.push(executer)\n\n this.logger.emit('progress', { id: executer.hookName, data: `${executer.plugin.name} ${executer.parameters?.join(', ') || ''}` })\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: PluginWithLifeCycle\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.events.emit('execute', { strategy, hookName, parameters, plugin })\n const promise = new Promise((resolve) => {\n resolve(undefined)\n })\n\n const task = promise\n .then(() => {\n if (typeof hook === 'function') {\n const possiblePromiseResult = (hook as Function).apply({ ...this.#core.context, 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: PluginWithLifeCycle\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.events.emit('execute', { strategy, hookName, parameters, plugin })\n\n try {\n if (typeof hook === 'function') {\n const fn = (hook as Function).apply({ ...this.#core.context, 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>(cause: Error, plugin?: Plugin, hookName?: H) {\n const text = `${cause.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})`\n\n this.logger.emit('error', text, cause)\n this.events.emit('error', cause)\n }\n\n #parse<TPlugin extends UserPluginWithLifeCycle>(\n plugin: TPlugin,\n pluginManager: PluginManager,\n context: PluginCore['context'] | undefined,\n ): Plugin<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.context && typeof plugin.context === 'function') {\n return {\n ...plugin,\n key,\n context: (plugin.context as Function).call(context) as typeof plugin.context,\n } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n return {\n ...plugin,\n key,\n } as unknown as Plugin<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: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>],\n >(plugins: Array<Plugin>, 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 static get hooks() {\n return ['buildStart', 'resolvePath', 'resolveName', 'buildEnd'] as const\n }\n}\n","import type { PossiblePromise } from '@kubb/types'\nimport type { Config, InputPath, UserConfig } from './types.ts'\n\ntype Args = {\n /**\n * Path to `kubb.config.js`\n */\n config?: string\n /**\n * Watch changes on input\n */\n watch?: boolean\n\n /**\n * Log level to report when using the CLI\n *\n * `silent` will hide all information that is not relevant\n *\n * `info` will show all information possible(not related to the PluginManager)\n *\n * `debug` will show all information possible(related to the PluginManager), handy for seeing logs\n * @default `silent`\n */\n logLevel?: string\n /**\n * Run Kubb with Bun\n */\n bun?: boolean\n}\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link Config} 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<UserConfig | Array<UserConfig>>\n | ((\n /** The options derived from the CLI flags */\n args: Args,\n ) => PossiblePromise<UserConfig | Array<UserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: Config | undefined): result is Config<InputPath> {\n return !!result && 'path' in (result as any)\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\nimport { read, readSync } from '@kubb/fs'\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 const module = await import(location)\n\n return module?.default ?? module\n } catch (e) {\n console.error(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 const json = await read(pkgPath)\n\n return JSON.parse(json) 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 const json = readSync(pkgPath)\n\n return JSON.parse(json) 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"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,OAAO,YAAY;;;ACWrB,SAAS,QAAsG,UAA2B;AAC/I,SAAO,SAAS,OAAO,OAAO,EAAE;AAAA,IAC9B,CAAC,SAAS,SAAS;AACjB,UAAI,OAAO,SAAS,YAAY;AAC9B,cAAM,IAAI,MAAM,0EAA0E;AAAA,MAC5F;AAEA,aAAO,QAAQ,KAAK,CAAC,UAAU;AAC7B,cAAM,aAAa,KAAK,KAAe;AAEvC,YAAI,YAAY;AACd,iBAAO,WAAW,KAAK,MAAM,UAAU,OAAO,KAAK,KAAK,CAAC;AAAA,QAC3D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,QAAQ,QAAQ,CAAC,CAAY;AAAA,EAC/B;AACF;AAOO,SAAS,UACd,UACA,YAAY,CAAC,UAAe,UAAU,MAC7B;AACT,MAAI,UAA4B,QAAQ,QAAQ,IAAI;AAEpD,aAAW,QAAQ,SAAS,OAAO,OAAO,GAAG;AAC3C,cAAU,QAAQ,KAAK,CAAC,UAAU;AAChC,UAAI,UAAU,KAAK,GAAG;AACpB,eAAO;AAAA,MACT;AAEA,YAAM,aAAa,KAAK,KAAe;AAEvC,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAOO,SAAS,aACd,UACS;AACT,SAAO,QAAQ,WAAW,SAAS,OAAO,OAAO,EAAE,IAAI,CAAC,YAAY,QAAQ,CAAC,CAAC;AAChF;;;ACtDO,IAAM,iBAAN,MAAmC;AAAA,EACxC,WAA4B,CAAC;AAAA,EAE7B,YAAY,UAA2B,CAAC,GAAG;AACzC,SAAK,WAAW;AAEhB,WA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AEA,MAAM,WAAW,YAA6E;AAC5F,QAAI,OAAO,eAAe,YAAY,gBAAe,OAAO,UAAU,GAAG;AACvE,aAAO,gBAAe,OAAO,UAAU;AAAA,IACzC;AAEA,UAAM,cAAc,MAAM,KAAK,eAAe;AAE9C,QAAI,CAAC,aAAa;AAChB,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,OAAO,aAAa,UAAU;AAAA,EAC5C;AAAA,EAEA,eAAe,YAAoE;AACjF,QAAI,OAAO,eAAe,YAAY,gBAAe,OAAO,UAAU,GAAG;AACvE,aAAO,gBAAe,OAAO,UAAU;AAAA,IACzC;AAEA,UAAM,cAAc,KAAK,mBAAmB;AAE5C,QAAI,CAAC,aAAa;AAChB,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,OAAO,aAAa,UAAU;AAAA,EAC5C;AAAA,EAEA,MAAM,QAAQ,YAAqC,SAA8C;AAC/F,UAAM,iBAAiB,MAAM,KAAK,WAAW,UAAU;AAEvD,QAAI,CAAC,gBAAgB;AACnB,aAAO;AAAA,IACT;AAEA,QAAI,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;","names":["path","resolve","plugin","read","path","require"]}
1
+ {"version":3,"sources":["../src/build.ts","../src/utils/executeStrategies.ts","../src/PromiseManager.ts","../src/errors.ts","../src/plugin.ts","../src/utils/cache.ts","../src/PluginManager.ts","../src/config.ts","../src/BaseGenerator.ts","../src/PackageManager.ts"],"sourcesContent":["import { clean, read } from '@kubb/fs'\nimport type * as KubbFile from '@kubb/fs/types'\nimport { FileManager, processFiles } from './FileManager.ts'\nimport { PluginManager } from './PluginManager.ts'\nimport { isInputPath } from './config.ts'\nimport { createLogger } from './logger.ts'\nimport { URLPath } from './utils/URLPath.ts'\n\nimport { resolve } from 'node:path'\nimport { getRelativePath } from '@kubb/fs'\nimport type { Logger } from './logger.ts'\nimport type { PluginContext } from './types.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 setup(options: BuildOptions): Promise<PluginManager> {\n const { config, logger = createLogger() } = 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(`Cannot read file/URL defined in \\`input.path\\` or set with \\`kubb generate PATH\\` in the CLI of your Kubb config ${config.input.path}`, {\n cause: e,\n })\n }\n }\n\n if (config.output.clean) {\n await clean(config.output.path)\n }\n\n return new PluginManager(config, { logger })\n}\n\nexport async function build(options: BuildOptions): Promise<BuildOutput> {\n const { files, pluginManager, error } = await safeBuild(options)\n\n if (error) throw error\n\n return {\n files,\n pluginManager,\n error,\n }\n}\n\nexport async function safeBuild(options: BuildOptions): Promise<BuildOutput> {\n const pluginManager = await setup(options)\n let files = []\n\n try {\n await pluginManager.hookParallel({\n hookName: 'buildStart',\n parameters: [options.config],\n })\n\n // create root barrel file\n const root = resolve(options.config.root)\n const rootPath = resolve(root, options.config.output.path, 'index.ts')\n const barrelFiles = pluginManager.fileManager.files.filter((file) => {\n return file.sources.some((source) => source.isIndexable)\n })\n\n const rootFile: KubbFile.File = {\n path: rootPath,\n baseName: 'index.ts',\n exports: barrelFiles\n .flatMap((file) => {\n return file.sources\n ?.map((source) => {\n if (!file.path || !source.isIndexable) {\n return undefined\n }\n\n // validate of the file is coming from plugin x, needs pluginKey on every file TODO update typing\n const plugin = pluginManager.plugins.find((item) => {\n const meta = file.meta as any\n return item.name === meta?.pluginKey?.[0]\n })\n\n if (plugin?.output?.exportType === false) {\n return undefined\n }\n\n if (FileManager.getMode(plugin?.output?.path) === 'single') {\n return undefined\n }\n return {\n name: options.config.output.exportType === 'barrel' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: source.isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n })\n .filter(Boolean),\n sources: [],\n meta: {},\n }\n\n if (options.config.output.exportType) {\n await pluginManager.fileManager.add(rootFile)\n }\n\n //TODO set extName here instead of the files, extName is private. All exports will have extName, it's up the the process to hide.override the name\n files = await processFiles({\n config: options.config,\n dryRun: !options.config.output.write,\n files: pluginManager.fileManager.files,\n logger: pluginManager.logger,\n })\n\n await pluginManager.hookParallel({ hookName: 'buildEnd' })\n\n pluginManager.fileManager.clear()\n } catch (e) {\n return {\n files: [],\n pluginManager,\n error: e as Error,\n }\n }\n\n return {\n files,\n pluginManager,\n }\n}\n","type 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> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>\n\n/**\n * Chains promises\n */\nexport function hookSeq<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TOutput = SeqOutput<TInput, TValue>>(promises: TInput): 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'\n ? SeqOutput<TInput, TValue>\n : TStrategy extends 'parallel'\n ? 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","export 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 { Plugin, PluginContext, PluginFactoryOptions, UserPluginWithLifeCycle } from './types.ts'\n\ntype PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>\n\ntype OptionalPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options?: T['options']) => UserPluginWithLifeCycle<T>\n\nexport function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): OptionalPluginFactory<T> {\n return (options = {}) => {\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: () => Array<Plugin>\n plugin?: PluginContext['plugin']\n}\n\n// not publicly exported\nexport type PluginCore = PluginFactoryOptions<'core', Options, Options, PluginContext, never>\n\nexport const pluginCore = createPlugin<PluginCore>((options) => {\n const { fileManager, pluginManager, resolvePath, resolveName, logger } = options\n\n return {\n name: 'core',\n options,\n key: ['core'],\n context() {\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 context 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(options.config.root, options.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","import { FileManager } from './FileManager.ts'\nimport { isPromise, isPromiseRejectedResult } from './PromiseManager.ts'\nimport { PromiseManager } from './PromiseManager.ts'\nimport { ValidationPluginError } from './errors.ts'\nimport { pluginCore } from './plugin.ts'\nimport { transformReservedWord } from './transformers/transformReservedWord.ts'\nimport { EventEmitter } from './utils/EventEmitter.ts'\nimport { setUniqueName } from './utils/uniqueName.ts'\n\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { PossiblePromise } from '@kubb/types'\nimport type { Logger } from './logger.ts'\nimport type { PluginCore } from './plugin.ts'\nimport type {\n Config,\n GetPluginFactoryOptions,\n Plugin,\n PluginFactoryOptions,\n PluginLifecycle,\n PluginLifecycleHooks,\n PluginParameter,\n PluginWithLifeCycle,\n ResolveNameParams,\n ResolvePathParams,\n UserPlugin,\n UserPluginWithLifeCycle,\n} from './types.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: Plugin\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: Plugin\n}\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n logger: Logger\n}\n\ntype Events = {\n execute: [executer: Executer]\n executed: [executer: Executer]\n error: [error: Error]\n}\n\ntype GetFileProps<TOptions = object> = {\n name: string\n mode?: KubbFile.Mode\n extName: KubbFile.Extname\n pluginKey: Plugin['key']\n options?: TOptions\n}\n\nexport class PluginManager {\n readonly plugins: PluginWithLifeCycle[]\n readonly fileManager: FileManager\n readonly events: EventEmitter<Events> = new EventEmitter()\n\n readonly config: Config\n\n readonly executed: Array<Executer> = []\n readonly logger: Logger\n readonly options: Options\n readonly #core: Plugin<PluginCore>\n\n readonly #usedPluginNames: Record<string, number> = {}\n readonly #promiseManager: PromiseManager\n\n constructor(config: Config, options: Options) {\n this.config = config\n this.options = options\n this.logger = options.logger\n this.fileManager = new FileManager()\n this.#promiseManager = new PromiseManager({\n nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result,\n })\n\n const plugins = config.plugins || []\n\n const core = pluginCore({\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.context.call with empty context so we can transform `context()` to `context: {}`\n this.#core = this.#parse(core as unknown as UserPlugin, this as any, core.context.call(null as any)) as Plugin<PluginCore>\n\n this.plugins = [this.#core, ...plugins].map((plugin) => {\n return this.#parse(plugin as UserPlugin, this, this.#core.context)\n })\n\n return this\n }\n\n getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {\n const baseName = `${name}${extName}` as const\n const path = this.resolvePath({ baseName, mode, pluginKey, options })\n\n if (!path) {\n throw new Error(`Filepath should be defined for resolvedName \"${name}\" and pluginKey [${JSON.stringify(pluginKey)}]`)\n }\n\n return {\n path,\n baseName,\n meta: {\n pluginKey,\n },\n sources: [],\n }\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.mode, params.options as object],\n })\n\n if (paths && paths?.length > 1) {\n this.logger.emit('debug', {\n logs: [\n `Cannot return a path where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nPaths: ${JSON.stringify(paths, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\n ],\n })\n }\n\n return paths?.at(0)\n }\n return this.hookFirstSync({\n hookName: 'resolvePath',\n parameters: [params.baseName, params.mode, params.options as object],\n }).result\n }\n //TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path\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) {\n this.logger.emit('debug', {\n logs: [\n `Cannot return a name where the 'pluginKey' ${\n params.pluginKey ? JSON.stringify(params.pluginKey) : '\"'\n } is not unique enough\\n\\nNames: ${JSON.stringify(names, undefined, 2)}\\n\\nFalling back on the first item.\\n`,\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 /**\n * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.\n */\n on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void {\n this.events.on(eventName, handler as any)\n }\n\n /**\n * Run a specific hookName for plugin x.\n */\n async hookForPlugin<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Promise<Array<ReturnType<ParseResult<H>> | null>> {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\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 const items = await Promise.all(promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return items\n }\n /**\n * Run a specific hookName for plugin x.\n */\n\n hookForPluginSync<H extends PluginLifecycleHooks>({\n pluginKey,\n hookName,\n parameters,\n }: {\n pluginKey: Plugin['key']\n hookName: H\n parameters: PluginParameter<H>\n }): Array<ReturnType<ParseResult<H>>> | null {\n const plugins = this.getPluginsByKey(hookName, pluginKey)\n\n const result = 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 return result\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n async hookFirst<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): Promise<SafeParseResult<H>> {\n const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.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 plugin,\n result: value,\n } as SafeParseResult<H>)\n }\n })\n\n const result = await this.#promiseManager.run('first', promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return result\n }\n\n /**\n * First non-null result stops and will return it's value.\n */\n hookFirstSync<H extends PluginLifecycleHooks>({\n hookName,\n parameters,\n skipped,\n }: {\n hookName: H\n parameters: PluginParameter<H>\n skipped?: ReadonlySet<Plugin> | null\n }): SafeParseResult<H> {\n let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>\n const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {\n return skipped ? skipped.has(plugin) : true\n })\n\n for (const plugin of plugins) {\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\n return parseResult\n }\n\n /**\n * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).\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 plugins = this.#getSortedPlugins(hookName)\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookParallel',\n hookName,\n parameters,\n plugin,\n }) as Promise<TOuput>\n })\n\n const results = await this.#promiseManager.run('parallel', promises)\n\n results.forEach((result, index) => {\n if (isPromiseRejectedResult<Error>(result)) {\n const plugin = this.#getSortedPlugins(hookName)[index]\n\n this.#catcher<H>(result.reason, plugin, hookName)\n }\n })\n\n this.logger.emit('progress_stop', { id: hookName })\n\n return results.filter((result) => result.status === 'fulfilled').map((result) => (result as PromiseFulfilledResult<Awaited<TOuput>>).value)\n }\n\n /**\n * Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.\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: Plugin) => PossiblePromise<Argument0<H> | null>\n }): Promise<Argument0<H>> {\n const [argument0, ...rest] = parameters\n const plugins = this.#getSortedPlugins(hookName)\n\n let promise: Promise<Argument0<H>> = Promise.resolve(argument0)\n for (const plugin of plugins) {\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.context, 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 plugins = this.#getSortedPlugins(hookName)\n this.logger.emit('progress_start', { id: hookName, size: plugins.length })\n\n const promises = plugins.map((plugin) => {\n return () =>\n this.#execute({\n strategy: 'hookSeq',\n hookName,\n parameters,\n plugin,\n })\n })\n\n await this.#promiseManager.run('seq', promises)\n\n this.logger.emit('progress_stop', { id: hookName })\n }\n\n #getSortedPlugins(hookName?: keyof PluginLifecycle): Plugin[] {\n const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')\n\n if (hookName) {\n const containsHookName = plugins.some((item) => item[hookName])\n if (!containsHookName) {\n this.logger.emit('debug', { logs: [`No hook ${hookName} found`] })\n }\n\n return plugins.filter((item) => item[hookName])\n }\n // TODO add test case for sorting with pre/post\n\n return plugins\n .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 })\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: Plugin['key']): Plugin[] {\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 (corePlugin) {\n this.logger.emit('debug', {\n logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`],\n })\n } else {\n this.logger.emit('debug', {\n logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`],\n })\n }\n return corePlugin ? [corePlugin] : []\n }\n\n return pluginByPluginName\n }\n\n #addExecutedToCallStack(executer: Executer | undefined) {\n if (executer) {\n this.events.emit('executed', executer)\n this.executed.push(executer)\n\n this.logger.emit('progress', { id: executer.hookName, data: `${executer.plugin.name}` })\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: PluginWithLifeCycle\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.events.emit('execute', { strategy, hookName, parameters, plugin })\n const promise = new Promise((resolve) => {\n resolve(undefined)\n })\n\n const task = promise\n .then(() => {\n if (typeof hook === 'function') {\n const possiblePromiseResult = (hook as Function).apply({ ...this.#core.context, 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: PluginWithLifeCycle\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.events.emit('execute', { strategy, hookName, parameters, plugin })\n\n try {\n if (typeof hook === 'function') {\n const fn = (hook as Function).apply({ ...this.#core.context, 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>(cause: Error, plugin?: Plugin, hookName?: H) {\n const text = `${cause.message} (plugin: ${plugin?.name || 'unknown'}, hook: ${hookName || 'unknown'})`\n\n this.logger.emit('error', text, cause)\n this.events.emit('error', cause)\n }\n\n #parse<TPlugin extends UserPluginWithLifeCycle>(\n plugin: TPlugin,\n pluginManager: PluginManager,\n context: PluginCore['context'] | undefined,\n ): Plugin<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.context && typeof plugin.context === 'function') {\n return {\n ...plugin,\n key,\n context: (plugin.context as Function).call(context) as typeof plugin.context,\n } as unknown as Plugin<GetPluginFactoryOptions<TPlugin>>\n }\n\n return {\n ...plugin,\n key,\n } as unknown as Plugin<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: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>],\n >(plugins: Array<Plugin>, 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 static get hooks() {\n return ['buildStart', 'resolvePath', 'resolveName', 'buildEnd'] as const\n }\n}\n","import type { PossiblePromise } from '@kubb/types'\nimport type { Config, InputPath, UserConfig } from './types.ts'\n\ntype Args = {\n /**\n * Path to `kubb.config.js`\n */\n config?: string\n /**\n * Watch changes on input\n */\n watch?: boolean\n\n /**\n * Log level to report when using the CLI\n *\n * `silent` will hide all information that is not relevant\n *\n * `info` will show all information possible(not related to the PluginManager)\n *\n * `debug` will show all information possible(related to the PluginManager), handy for seeing logs\n * @default `silent`\n */\n logLevel?: string\n /**\n * Run Kubb with Bun\n */\n bun?: boolean\n}\n\n/**\n * Type helper to make it easier to use kubb.config.js\n * accepts a direct {@link Config} 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<UserConfig | Array<UserConfig>>\n | ((\n /** The options derived from the CLI flags */\n args: Args,\n ) => PossiblePromise<UserConfig | Array<UserConfig>>),\n): typeof options {\n return options\n}\n\nexport function isInputPath(result: Config | undefined): result is Config<InputPath> {\n return !!result && 'path' in (result as any)\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 BaseGenerator<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\nimport { read, readSync } from '@kubb/fs'\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 const module = await import(location)\n\n return module?.default ?? module\n } catch (e) {\n console.error(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 const json = await read(pkgPath)\n\n return JSON.parse(json) 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 const json = readSync(pkgPath)\n\n return JSON.parse(json) 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"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,OAA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,OAAO,eAAe,YAAY,gBAAe,OAAO,UAAU,GAAG;AACvE,aAAO,gBAAe,OAAO,UAAU;AAAA,IACzC;AAEA,UAAM,cAAc,KAAK,mBAAmB;AAE5C,QAAI,CAAC,aAAa;AAChB,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,OAAO,aAAa,UAAU;AAAA,EAC5C;AAAA,EAEA,MAAM,QAAQ,YAAqC,SAA8C;AAC/F,UAAM,iBAAiB,MAAM,KAAK,WAAW,UAAU;AAEvD,QAAI,CAAC,gBAAgB;AACnB,aAAO;AAAA,IACT;AAEA,QAAI,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;","names":["path","resolve","plugin","read","path","require"]}
package/dist/mocks.cjs CHANGED
@@ -54,6 +54,9 @@ var mockedPluginManager = {
54
54
  }
55
55
  };
56
56
  async function matchFiles(files) {
57
+ if (!files) {
58
+ return void 0;
59
+ }
57
60
  for (const file of files) {
58
61
  const source = await _chunk5IGANEGEcjs.getSource.call(void 0, file, { logger: mockedLogger });
59
62
  expect(source).toMatchSnapshot();
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/core/dist/mocks.cjs","../mocks/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA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EsB;AACD,EAAA;AACF,IAAA;AACA,IAAA;AACjB,EAAA;AACF;ADKsB;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/core/dist/mocks.cjs","sourcesContent":[null,"import { camelCase, pascalCase } from '../src/transformers/casing.ts'\n\nimport type { File, ResolvedFile } from '@kubb/fs/types'\nimport { getSource } from '../src/FileManager'\nimport type { PluginManager } from '../src/PluginManager.ts'\nimport type { Logger } from '../src/logger'\n\nexport const mockedLogger = {\n emit(type, message) {},\n on(type, message) {},\n consola: {},\n} as Logger\n\nexport const mockedPluginManager = {\n resolveName: ({ name, type }) => {\n if (type === 'type') {\n return pascalCase(name)\n }\n\n if (type === 'function') {\n return camelCase(name)\n }\n\n return camelCase(name)\n },\n config: {\n output: {\n path: './path',\n },\n },\n resolvePath: ({ baseName }) => baseName,\n logger: {\n emit(message) {\n console.log(message)\n },\n on(eventName, args) {},\n logLevel: 3,\n },\n getFile: ({ name, extName, pluginKey }) => {\n const baseName = `${name}${extName}`\n\n return {\n path: baseName,\n baseName,\n meta: {\n pluginKey,\n },\n }\n },\n} as PluginManager\n\nexport async function matchFiles(files: Array<ResolvedFile | File>) {\n for (const file of files) {\n const source = await getSource(file as ResolvedFile, { logger: mockedLogger })\n expect(source).toMatchSnapshot()\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/core/dist/mocks.cjs","../mocks/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACXA,8CAAA,CAAA;AAOO,IAAM,aAAA,EAAe;AAAA,EAC1B,IAAA,CAAK,IAAA,EAAM,OAAA,EAAS;AAAA,EAAC,CAAA;AAAA,EACrB,EAAA,CAAG,IAAA,EAAM,OAAA,EAAS;AAAA,EAAC,CAAA;AAAA,EACnB,OAAA,EAAS,CAAC;AACZ,CAAA;AAEO,IAAM,oBAAA,EAAsB;AAAA,EACjC,WAAA,EAAa,CAAC,EAAE,IAAA,EAAM,KAAK,CAAA,EAAA,GAAM;AAC/B,IAAA,GAAA,CAAI,KAAA,IAAS,MAAA,EAAQ;AACnB,MAAA,OAAO,0CAAA,IAAe,CAAA;AAAA,IACxB;AAEA,IAAA,GAAA,CAAI,KAAA,IAAS,UAAA,EAAY;AACvB,MAAA,OAAO,yCAAA,IAAc,CAAA;AAAA,IACvB;AAEA,IAAA,OAAO,yCAAA,IAAc,CAAA;AAAA,EACvB,CAAA;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM;AAAA,IACR;AAAA,EACF,CAAA;AAAA,EACA,WAAA,EAAa,CAAC,EAAE,SAAS,CAAA,EAAA,GAAM,QAAA;AAAA,EAC/B,MAAA,EAAQ;AAAA,IACN,IAAA,CAAK,OAAA,EAAS;AACZ,MAAA,OAAA,CAAQ,GAAA,CAAI,OAAO,CAAA;AAAA,IACrB,CAAA;AAAA,IACA,EAAA,CAAG,SAAA,EAAW,IAAA,EAAM;AAAA,IAAC,CAAA;AAAA,IACrB,QAAA,EAAU;AAAA,EACZ,CAAA;AAAA,EACA,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,OAAA,EAAS,UAAU,CAAA,EAAA,GAAM;AACzC,IAAA,MAAM,SAAA,EAAW,CAAA,EAAA;AAEV,IAAA;AACC,MAAA;AACN,MAAA;AACM,MAAA;AACJ,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AACF;AAEsB;AACR,EAAA;AACH,IAAA;AACT,EAAA;AAEmB,EAAA;AACF,IAAA;AACA,IAAA;AACjB,EAAA;AACF;ADIsB;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/core/dist/mocks.cjs","sourcesContent":[null,"import { camelCase, pascalCase } from '../src/transformers/casing.ts'\n\nimport type { File, ResolvedFile } from '@kubb/fs/types'\nimport { getSource } from '../src/FileManager'\nimport type { PluginManager } from '../src/PluginManager.ts'\nimport type { Logger } from '../src/logger'\n\nexport const mockedLogger = {\n emit(type, message) {},\n on(type, message) {},\n consola: {},\n} as Logger\n\nexport const mockedPluginManager = {\n resolveName: ({ name, type }) => {\n if (type === 'type') {\n return pascalCase(name)\n }\n\n if (type === 'function') {\n return camelCase(name)\n }\n\n return camelCase(name)\n },\n config: {\n output: {\n path: './path',\n },\n },\n resolvePath: ({ baseName }) => baseName,\n logger: {\n emit(message) {\n console.log(message)\n },\n on(eventName, args) {},\n logLevel: 3,\n },\n getFile: ({ name, extName, pluginKey }) => {\n const baseName = `${name}${extName}`\n\n return {\n path: baseName,\n baseName,\n meta: {\n pluginKey,\n },\n }\n },\n} as PluginManager\n\nexport async function matchFiles(files: Array<ResolvedFile | File> | undefined) {\n if (!files) {\n return undefined\n }\n\n for (const file of files) {\n const source = await getSource(file as ResolvedFile, { logger: mockedLogger })\n expect(source).toMatchSnapshot()\n }\n}\n"]}
package/dist/mocks.d.cts CHANGED
@@ -7,6 +7,6 @@ import 'consola';
7
7
 
8
8
  declare const mockedLogger: Logger;
9
9
  declare const mockedPluginManager: PluginManager;
10
- declare function matchFiles(files: Array<ResolvedFile | File>): Promise<void>;
10
+ declare function matchFiles(files: Array<ResolvedFile | File> | undefined): Promise<undefined>;
11
11
 
12
12
  export { matchFiles, mockedLogger, mockedPluginManager };
package/dist/mocks.d.ts CHANGED
@@ -7,6 +7,6 @@ import 'consola';
7
7
 
8
8
  declare const mockedLogger: Logger;
9
9
  declare const mockedPluginManager: PluginManager;
10
- declare function matchFiles(files: Array<ResolvedFile | File>): Promise<void>;
10
+ declare function matchFiles(files: Array<ResolvedFile | File> | undefined): Promise<undefined>;
11
11
 
12
12
  export { matchFiles, mockedLogger, mockedPluginManager };
package/dist/mocks.js CHANGED
@@ -50,6 +50,9 @@ var mockedPluginManager = {
50
50
  }
51
51
  };
52
52
  async function matchFiles(files) {
53
+ if (!files) {
54
+ return void 0;
55
+ }
53
56
  for (const file of files) {
54
57
  const source = await getSource(file, { logger: mockedLogger });
55
58
  expect(source).toMatchSnapshot();
package/dist/mocks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../mocks/index.ts"],"sourcesContent":["import { camelCase, pascalCase } from '../src/transformers/casing.ts'\n\nimport type { File, ResolvedFile } from '@kubb/fs/types'\nimport { getSource } from '../src/FileManager'\nimport type { PluginManager } from '../src/PluginManager.ts'\nimport type { Logger } from '../src/logger'\n\nexport const mockedLogger = {\n emit(type, message) {},\n on(type, message) {},\n consola: {},\n} as Logger\n\nexport const mockedPluginManager = {\n resolveName: ({ name, type }) => {\n if (type === 'type') {\n return pascalCase(name)\n }\n\n if (type === 'function') {\n return camelCase(name)\n }\n\n return camelCase(name)\n },\n config: {\n output: {\n path: './path',\n },\n },\n resolvePath: ({ baseName }) => baseName,\n logger: {\n emit(message) {\n console.log(message)\n },\n on(eventName, args) {},\n logLevel: 3,\n },\n getFile: ({ name, extName, pluginKey }) => {\n const baseName = `${name}${extName}`\n\n return {\n path: baseName,\n baseName,\n meta: {\n pluginKey,\n },\n }\n },\n} as PluginManager\n\nexport async function matchFiles(files: Array<ResolvedFile | File>) {\n for (const file of files) {\n const source = await getSource(file as ResolvedFile, { logger: mockedLogger })\n expect(source).toMatchSnapshot()\n }\n}\n"],"mappings":";;;;;;;;;AAOO,IAAM,eAAe;AAAA,EAC1B,KAAK,MAAM,SAAS;AAAA,EAAC;AAAA,EACrB,GAAG,MAAM,SAAS;AAAA,EAAC;AAAA,EACnB,SAAS,CAAC;AACZ;AAEO,IAAM,sBAAsB;AAAA,EACjC,aAAa,CAAC,EAAE,MAAM,KAAK,MAAM;AAC/B,QAAI,SAAS,QAAQ;AACnB,aAAO,WAAW,IAAI;AAAA,IACxB;AAEA,QAAI,SAAS,YAAY;AACvB,aAAO,UAAU,IAAI;AAAA,IACvB;AAEA,WAAO,UAAU,IAAI;AAAA,EACvB;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,aAAa,CAAC,EAAE,SAAS,MAAM;AAAA,EAC/B,QAAQ;AAAA,IACN,KAAK,SAAS;AACZ,cAAQ,IAAI,OAAO;AAAA,IACrB;AAAA,IACA,GAAG,WAAW,MAAM;AAAA,IAAC;AAAA,IACrB,UAAU;AAAA,EACZ;AAAA,EACA,SAAS,CAAC,EAAE,MAAM,SAAS,UAAU,MAAM;AACzC,UAAM,WAAW,GAAG,IAAI,GAAG,OAAO;AAElC,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,MAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,WAAW,OAAmC;AAClE,aAAW,QAAQ,OAAO;AACxB,UAAM,SAAS,MAAM,UAAU,MAAsB,EAAE,QAAQ,aAAa,CAAC;AAC7E,WAAO,MAAM,EAAE,gBAAgB;AAAA,EACjC;AACF;","names":[]}
1
+ {"version":3,"sources":["../mocks/index.ts"],"sourcesContent":["import { camelCase, pascalCase } from '../src/transformers/casing.ts'\n\nimport type { File, ResolvedFile } from '@kubb/fs/types'\nimport { getSource } from '../src/FileManager'\nimport type { PluginManager } from '../src/PluginManager.ts'\nimport type { Logger } from '../src/logger'\n\nexport const mockedLogger = {\n emit(type, message) {},\n on(type, message) {},\n consola: {},\n} as Logger\n\nexport const mockedPluginManager = {\n resolveName: ({ name, type }) => {\n if (type === 'type') {\n return pascalCase(name)\n }\n\n if (type === 'function') {\n return camelCase(name)\n }\n\n return camelCase(name)\n },\n config: {\n output: {\n path: './path',\n },\n },\n resolvePath: ({ baseName }) => baseName,\n logger: {\n emit(message) {\n console.log(message)\n },\n on(eventName, args) {},\n logLevel: 3,\n },\n getFile: ({ name, extName, pluginKey }) => {\n const baseName = `${name}${extName}`\n\n return {\n path: baseName,\n baseName,\n meta: {\n pluginKey,\n },\n }\n },\n} as PluginManager\n\nexport async function matchFiles(files: Array<ResolvedFile | File> | undefined) {\n if (!files) {\n return undefined\n }\n\n for (const file of files) {\n const source = await getSource(file as ResolvedFile, { logger: mockedLogger })\n expect(source).toMatchSnapshot()\n }\n}\n"],"mappings":";;;;;;;;;AAOO,IAAM,eAAe;AAAA,EAC1B,KAAK,MAAM,SAAS;AAAA,EAAC;AAAA,EACrB,GAAG,MAAM,SAAS;AAAA,EAAC;AAAA,EACnB,SAAS,CAAC;AACZ;AAEO,IAAM,sBAAsB;AAAA,EACjC,aAAa,CAAC,EAAE,MAAM,KAAK,MAAM;AAC/B,QAAI,SAAS,QAAQ;AACnB,aAAO,WAAW,IAAI;AAAA,IACxB;AAEA,QAAI,SAAS,YAAY;AACvB,aAAO,UAAU,IAAI;AAAA,IACvB;AAEA,WAAO,UAAU,IAAI;AAAA,EACvB;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,aAAa,CAAC,EAAE,SAAS,MAAM;AAAA,EAC/B,QAAQ;AAAA,IACN,KAAK,SAAS;AACZ,cAAQ,IAAI,OAAO;AAAA,IACrB;AAAA,IACA,GAAG,WAAW,MAAM;AAAA,IAAC;AAAA,IACrB,UAAU;AAAA,EACZ;AAAA,EACA,SAAS,CAAC,EAAE,MAAM,SAAS,UAAU,MAAM;AACzC,UAAM,WAAW,GAAG,IAAI,GAAG,OAAO;AAElC,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA,MAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,WAAW,OAA+C;AAC9E,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,aAAW,QAAQ,OAAO;AACxB,UAAM,SAAS,MAAM,UAAU,MAAsB,EAAE,QAAQ,aAAa,CAAC;AAC7E,WAAO,MAAM,EAAE,gBAAgB;AAAA,EACjC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/core",
3
- "version": "3.0.0-alpha.8",
3
+ "version": "3.0.0-alpha.9",
4
4
  "description": "Generator core",
5
5
  "keywords": [
6
6
  "typescript",
@@ -84,9 +84,9 @@
84
84
  "seedrandom": "^3.0.5",
85
85
  "semver": "^7.6.3",
86
86
  "unraw": "^3.0.0",
87
- "@kubb/fs": "3.0.0-alpha.8",
88
- "@kubb/parser-ts": "3.0.0-alpha.8",
89
- "@kubb/types": "3.0.0-alpha.8"
87
+ "@kubb/fs": "3.0.0-alpha.9",
88
+ "@kubb/parser-ts": "3.0.0-alpha.9",
89
+ "@kubb/types": "3.0.0-alpha.9"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/object-hash": "^3.0.6",
@@ -98,9 +98,9 @@
98
98
  "tinyrainbow": "^1.2.0",
99
99
  "tsup": "^8.2.4",
100
100
  "typescript": "^5.5.4",
101
- "@kubb/config-biome": "3.0.0-alpha.8",
102
- "@kubb/config-ts": "3.0.0-alpha.8",
103
- "@kubb/config-tsup": "3.0.0-alpha.8"
101
+ "@kubb/config-biome": "3.0.0-alpha.9",
102
+ "@kubb/config-ts": "3.0.0-alpha.9",
103
+ "@kubb/config-tsup": "3.0.0-alpha.9"
104
104
  },
105
105
  "engines": {
106
106
  "node": ">=20"
@@ -2,7 +2,7 @@
2
2
  * Abstract class that contains the building blocks for plugins to create their own Generator
3
3
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
4
4
  */
5
- export abstract class Generator<TOptions = unknown, TContext = unknown> {
5
+ export abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
6
6
  #options: TOptions = {} as TOptions
7
7
  #context: TContext = {} as TContext
8
8
 
@@ -509,7 +509,7 @@ export class PluginManager {
509
509
  this.events.emit('executed', executer)
510
510
  this.executed.push(executer)
511
511
 
512
- this.logger.emit('progress', { id: executer.hookName, data: `${executer.plugin.name} ${executer.parameters?.join(', ') || ''}` })
512
+ this.logger.emit('progress', { id: executer.hookName, data: `${executer.plugin.name}` })
513
513
  }
514
514
  }
515
515
 
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ export { build, build as default, safeBuild } from './build.ts'
2
2
  export { defineConfig, isInputPath } from './config.ts'
3
3
  export { FileManager } from './FileManager.ts'
4
4
  export type { FileMetaBase } from './FileManager.ts'
5
- export { Generator } from './Generator.ts'
5
+ export { BaseGenerator } from './BaseGenerator.ts'
6
6
  export { PackageManager } from './PackageManager.ts'
7
7
  export { createPlugin } from './plugin.ts'
8
8
  export { PluginManager } from './PluginManager.ts'