@kubb/core 5.0.0-beta.18 → 5.0.0-beta.19

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.
@@ -27,9 +27,8 @@ export type Renderer<TElement = unknown> = {
27
27
  /**
28
28
  * When present, core calls this instead of {@link render} and {@link files},
29
29
  * forwarding each file to `FileManager` as soon as it is ready.
30
- * Implementing this method enables per-file streaming without buffering the full result set.
31
30
  */
32
- stream?(element: TElement): AsyncIterable<FileNode>
31
+ stream?(element: TElement): Iterable<FileNode>
33
32
  }
34
33
 
35
34
  /**
@@ -17,7 +17,7 @@ export type Parser<TMeta extends object = any> = {
17
17
  /**
18
18
  * Convert a resolved file to a string.
19
19
  */
20
- parse(file: FileNode<TMeta>, options?: PrintOptions): Promise<string> | string
20
+ parse(file: FileNode<TMeta>, options?: PrintOptions): string
21
21
  }
22
22
 
23
23
  /**
@@ -231,19 +231,9 @@ function matchesSchemaPattern(node: SchemaNode, type: string, pattern: string |
231
231
  * - `camelCase` for everything else.
232
232
  */
233
233
  function defaultResolver(name: string, type?: 'file' | 'function' | 'type' | 'const'): string {
234
- let resolvedName = camelCase(name)
235
-
236
- if (type === 'file' || type === 'function') {
237
- resolvedName = camelCase(name, {
238
- isFile: type === 'file',
239
- })
240
- }
241
-
242
- if (type === 'type') {
243
- resolvedName = pascalCase(name)
244
- }
245
-
246
- return resolvedName
234
+ if (type === 'file' || type === 'function') return camelCase(name, { isFile: type === 'file' })
235
+ if (type === 'type') return pascalCase(name)
236
+ return camelCase(name)
247
237
  }
248
238
 
249
239
  /**
@@ -269,19 +259,18 @@ function defaultResolver(name: string, type?: 'file' | 'function' | 'type' | 'co
269
259
  * // → { enumType: 'enum' } when operationId matches
270
260
  * ```
271
261
  */
272
- export function defaultResolveOptions<TOptions>(
262
+ const resolveOptionsCache = new WeakMap<object, WeakMap<Node, { value: unknown }>>()
263
+
264
+ function computeOptions<TOptions>(
273
265
  node: Node,
274
- { options, exclude = [], include, override = [] }: ResolveOptionsContext<TOptions>,
266
+ options: TOptions,
267
+ exclude: Array<PatternFilter>,
268
+ include: Array<PatternFilter> | undefined,
269
+ override: Array<PatternOverride<TOptions>>,
275
270
  ): TOptions | null {
276
271
  if (isOperationNode(node)) {
277
- const isExcluded = exclude.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))
278
- if (isExcluded) {
279
- return null
280
- }
281
-
282
- if (include && !include.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) {
283
- return null
284
- }
272
+ if (exclude.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) return null
273
+ if (include && !include.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) return null
285
274
 
286
275
  const overrideOptions = override.find(({ type, pattern }) => matchesOperationPattern(node, type, pattern))?.options
287
276
 
@@ -289,18 +278,13 @@ export function defaultResolveOptions<TOptions>(
289
278
  }
290
279
 
291
280
  if (isSchemaNode(node)) {
292
- if (exclude.some(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)) {
293
- return null
294
- }
295
-
281
+ if (exclude.some(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)) return null
296
282
  if (include) {
297
283
  const results = include.map(({ type, pattern }) => matchesSchemaPattern(node, type, pattern))
298
284
  const applicable = results.filter((r) => r !== null)
299
- if (applicable.length > 0 && !applicable.includes(true)) {
300
- return null
301
- }
302
- }
303
285
 
286
+ if (applicable.length > 0 && !applicable.includes(true)) return null
287
+ }
304
288
  const overrideOptions = override.find(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)?.options
305
289
 
306
290
  return { ...options, ...overrideOptions }
@@ -309,6 +293,26 @@ export function defaultResolveOptions<TOptions>(
309
293
  return options
310
294
  }
311
295
 
296
+ export function defaultResolveOptions<TOptions>(
297
+ node: Node,
298
+ { options, exclude = [], include, override = [] }: ResolveOptionsContext<TOptions>,
299
+ ): TOptions | null {
300
+ const optionsKey = options as object
301
+ let byOptions = resolveOptionsCache.get(optionsKey)
302
+ if (!byOptions) {
303
+ byOptions = new WeakMap()
304
+ resolveOptionsCache.set(optionsKey, byOptions)
305
+ }
306
+ const cached = byOptions.get(node)
307
+ if (cached !== undefined) return cached.value as TOptions | null
308
+
309
+ const result = computeOptions(node, options, exclude, include, override)
310
+
311
+ byOptions.set(node, { value: result })
312
+
313
+ return result
314
+ }
315
+
312
316
  /**
313
317
  * Default path resolver used by `defineResolver`.
314
318
  *
@@ -360,25 +364,24 @@ export function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }:
360
364
  return path.resolve(root, output.path)
361
365
  }
362
366
 
363
- let result: string
364
-
365
- if (group && (groupPath || tag)) {
366
- const groupValue = group.type === 'path' ? groupPath! : tag!
367
- const defaultName =
368
- group.type === 'tag'
369
- ? ({ group: g }: { group: string }) => `${camelCase(g)}Controller`
370
- : ({ group: g }: { group: string }) => {
371
- // Strip traversal components (empty, '.', '..') before taking the first meaningful segment.
372
- // When every segment is a traversal component (e.g. '../../') we fall back to '' so the
373
- // file is placed directly in the output root the boundary check below ensures safety.
374
- const segment = g.split('/').filter((s) => s !== '' && s !== '.' && s !== '..')[0]
375
- return segment ? camelCase(segment) : ''
376
- }
377
- const resolveName = group.name ?? defaultName
378
- result = path.resolve(root, output.path, resolveName({ group: groupValue }), baseName)
379
- } else {
380
- result = path.resolve(root, output.path, baseName)
381
- }
367
+ const result: string = (() => {
368
+ if (group && (groupPath || tag)) {
369
+ const groupValue = group.type === 'path' ? groupPath! : tag!
370
+ const defaultName =
371
+ group.type === 'tag'
372
+ ? ({ group: g }: { group: string }) => `${camelCase(g)}Controller`
373
+ : ({ group: g }: { group: string }) => {
374
+ // Strip traversal components (empty, '.', '..') before taking the first meaningful segment.
375
+ // When every segment is a traversal component (e.g. '../../') we fall back to '' so the
376
+ // file is placed directly in the output root the boundary check below ensures safety.
377
+ const segment = g.split('/').filter((s) => s !== '' && s !== '.' && s !== '..')[0]
378
+ return segment ? camelCase(segment) : ''
379
+ }
380
+ const resolveName = group.name ?? defaultName
381
+ return path.resolve(root, output.path, resolveName({ group: groupValue }), baseName)
382
+ }
383
+ return path.resolve(root, output.path, baseName)
384
+ })()
382
385
 
383
386
  // Ensure the resolved path stays within the configured output directory.
384
387
  // This prevents path traversal from malicious OpenAPI specs or custom group.name functions.
@@ -458,17 +461,16 @@ export function buildDefaultBanner({
458
461
  config: Config
459
462
  }): string {
460
463
  try {
461
- let source = ''
462
- if (Array.isArray(config.input)) {
463
- const first = config.input[0]
464
- if (first && 'path' in first) {
465
- source = path.basename(first.path)
464
+ const source = (() => {
465
+ if (Array.isArray(config.input)) {
466
+ const first = config.input[0]
467
+ if (first && 'path' in first) return path.basename(first.path)
468
+ return ''
466
469
  }
467
- } else if (config.input && 'path' in config.input) {
468
- source = path.basename(config.input.path)
469
- } else if (config.input && 'data' in config.input) {
470
- source = 'text content'
471
- }
470
+ if (config.input && 'path' in config.input) return path.basename(config.input.path)
471
+ if (config.input && 'data' in config.input) return 'text content'
472
+ return ''
473
+ })()
472
474
 
473
475
  let banner = '/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n'
474
476
 
package/src/mocks.ts CHANGED
@@ -123,7 +123,7 @@ export async function renderGeneratorSchema<TOptions extends PluginFactoryOption
123
123
  ...context,
124
124
  options: opts.options,
125
125
  })
126
- await applyHookResult(result, opts.driver, generator.renderer ?? undefined)
126
+ await applyHookResult({ result, driver: opts.driver, rendererFactory: generator.renderer ?? undefined })
127
127
  }
128
128
 
129
129
  /**
@@ -147,7 +147,7 @@ export async function renderGeneratorOperation<TOptions extends PluginFactoryOpt
147
147
  ...context,
148
148
  options: opts.options,
149
149
  })
150
- await applyHookResult(result, opts.driver, generator.renderer ?? undefined)
150
+ await applyHookResult({ result, driver: opts.driver, rendererFactory: generator.renderer ?? undefined })
151
151
  }
152
152
 
153
153
  /**
@@ -171,5 +171,5 @@ export async function renderGeneratorOperations<TOptions extends PluginFactoryOp
171
171
  ...context,
172
172
  options: opts.options,
173
173
  })
174
- await applyHookResult(result, opts.driver, generator.renderer ?? undefined)
174
+ await applyHookResult({ result, driver: opts.driver, rendererFactory: generator.renderer ?? undefined })
175
175
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"PluginDriver-Bc-k8EUQ.cjs","names":["path","#cache","#store","#filesCache","#pluginsWithEventGenerators","#resolvers","#defaultResolvers","#hookListeners","#normalizePlugin","#trackHookListener","#createDefaultResolver","#studioIsOpen","openInStudioFn"],"sources":["../../../internals/utils/src/casing.ts","../src/constants.ts","../src/definePlugin.ts","../src/defineResolver.ts","../src/devtools.ts","../src/FileManager.ts","../src/PluginDriver.ts"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n *\n * Empty segments are filtered before joining. They arise when the text starts with\n * a dot followed immediately by a letter (e.g. `..Schema` splits into `['..', 'Schema']`\n * and `'..'` transforms to an empty string). Without this filter the join would produce\n * a leading `/`, which `path.resolve` would interpret as an absolute path, allowing\n * generated files to escape the configured output directory.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => transformPart(part, i === parts.length - 1))\n .filter(Boolean)\n .join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","import type { FileNode } from '@kubb/ast'\n\n/**\n * Base URL for the Kubb Studio web app.\n */\nexport const DEFAULT_STUDIO_URL = 'https://kubb.studio' as const\n\n/**\n * Default banner style written at the top of every generated file.\n */\nexport const DEFAULT_BANNER = 'simple' as const\n\n/**\n * Default file-extension mapping used when no explicit mapping is configured.\n */\nexport const DEFAULT_EXTENSION: Record<FileNode['extname'], FileNode['extname'] | ''> = { '.ts': '.ts' }\n\n/**\n * Schema count above which the adapter's `stream()` path is used instead of `parse()`.\n */\nexport const STREAM_SCHEMA_THRESHOLD = 100\n\n/**\n * In streaming mode, flush generated files to disk every N schemas to bound in-memory file buffers.\n */\nexport const STREAM_FLUSH_EVERY = 50\n\n/**\n * Numeric log-level thresholds used internally to compare verbosity.\n *\n * Higher numbers are more verbose.\n */\nexport const logLevel = {\n silent: Number.NEGATIVE_INFINITY,\n error: 0,\n warn: 1,\n info: 3,\n verbose: 4,\n debug: 5,\n} as const\n","import { extname } from 'node:path'\nimport type { FileNode, HttpMethod, InputNode, UserFileNode, Visitor } from '@kubb/ast'\nimport type { RendererFactory } from './createRenderer.ts'\nimport type { Generator } from './defineGenerator.ts'\nimport type { Resolver } from './defineResolver.ts'\nimport type { Config, KubbHooks } from './types.ts'\n\n/**\n * Safely extracts a type from a registry, returning `{}` if the key doesn't exist.\n * Enables optional interface augmentation for `Kubb.ConfigOptionsRegistry` and `Kubb.PluginOptionsRegistry`\n * without requiring changes to core.\n *\n * @internal\n */\ntype ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {}\n\n/**\n * Output configuration for generated files.\n */\nexport type Output<_TOptions = unknown> = {\n /**\n * Output folder or file path for generated code.\n */\n path: string\n /**\n * Text or function prepended to every generated file.\n * When a function, receives the current `InputNode` and returns a string.\n */\n banner?: string | ((node?: InputNode) => string)\n /**\n * Text or function appended to every generated file.\n * When a function, receives the current `InputNode` and returns a string.\n */\n footer?: string | ((node?: InputNode) => string)\n /**\n * Whether to override existing external files if they already exist.\n * @default false\n */\n override?: boolean\n} & ExtractRegistryKey<Kubb.PluginOptionsRegistry, 'output'>\n\nexport type Group = {\n /**\n * How to group files into subdirectories.\n * - `'tag'` — group by OpenAPI tags\n * - `'path'` — group by OpenAPI paths\n */\n type: 'tag' | 'path'\n /**\n * Function that returns the subdirectory name for a group value.\n * Defaults to `${camelCase(group)}Controller` for tags, first path segment for paths.\n */\n name?: (context: { group: string }) => string\n}\n\ntype ByTag = {\n /**\n * Filter by OpenAPI `tags` field. Matches one or more tags assigned to operations.\n */\n type: 'tag'\n /**\n * Tag name to match (case-sensitive). Can be a literal string or regex pattern.\n */\n pattern: string | RegExp\n}\n\ntype ByOperationId = {\n /**\n * Filter by OpenAPI `operationId` field. Each operation (GET, POST, etc.) has a unique identifier.\n */\n type: 'operationId'\n /**\n * Operation ID to match (case-sensitive). Can be a literal string or regex pattern.\n */\n pattern: string | RegExp\n}\n\ntype ByPath = {\n /**\n * Filter by OpenAPI `path` (URL endpoint). Useful to group or filter by service segments like `/pets`, `/users`, etc.\n */\n type: 'path'\n /**\n * URL path to match (case-sensitive). Can be a literal string or regex pattern. Matches against the full path.\n */\n pattern: string | RegExp\n}\n\ntype ByMethod = {\n /**\n * Filter by HTTP method: `'get'`, `'post'`, `'put'`, `'delete'`, `'patch'`, `'head'`, `'options'`.\n */\n type: 'method'\n /**\n * HTTP method to match (case-insensitive when using string, or regex for dynamic matching).\n */\n pattern: HttpMethod | RegExp\n}\n// TODO implement as alternative for ByMethod\n// type ByMethods = {\n// type: 'methods'\n// pattern: Array<HttpMethod>\n// }\n\ntype BySchemaName = {\n /**\n * Filter by schema component name (TypeScript or JSON schema). Matches schemas in `#/components/schemas`.\n */\n type: 'schemaName'\n /**\n * Schema name to match (case-sensitive). Can be a literal string or regex pattern.\n */\n pattern: string | RegExp\n}\n\ntype ByContentType = {\n /**\n * Filter by response or request content type: `'application/json'`, `'application/xml'`, etc.\n */\n type: 'contentType'\n /**\n * Content type to match (case-sensitive). Can be a literal string or regex pattern.\n */\n pattern: string | RegExp\n}\n\n/**\n * A pattern filter that prevents matching nodes from being generated.\n *\n * Use to skip code generation for specific operations or schemas. For example, exclude deprecated endpoints\n * or internal-only schemas. Can filter by tag, operationId, path, HTTP method, content type, or schema name.\n *\n * @example\n * ```ts\n * exclude: [\n * { type: 'tag', pattern: 'internal' }, // skip \"internal\" tag\n * { type: 'path', pattern: /^\\/admin/ }, // skip all /admin endpoints\n * { type: 'operationId', pattern: 'deprecated_*' } // skip operationIds matching pattern\n * ]\n * ```\n */\nexport type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName\n\n/**\n * A pattern filter that restricts generation to only matching nodes.\n *\n * Use to generate code for a subset of operations or schemas. For example, only generate for a specific service\n * tag or only for \"production\" endpoints. Can filter by tag, operationId, path, HTTP method, content type, or schema name.\n *\n * @example\n * ```ts\n * include: [\n * { type: 'tag', pattern: 'public' }, // generate only \"public\" tag\n * { type: 'path', pattern: /^\\/api\\/v1/ }, // generate only v1 endpoints\n * ]\n * ```\n */\nexport type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName\n\n/**\n * A pattern filter paired with partial option overrides applied when the pattern matches.\n *\n * Use to customize generation for specific operations or schemas. For example, apply different output paths\n * for different tags, or use custom resolver functions per operation. Can filter by tag, operationId, path,\n * HTTP method, schema name, or content type.\n *\n * @example\n * ```ts\n * override: [\n * {\n * type: 'tag',\n * pattern: 'admin',\n * options: { output: { path: './src/gen/admin' } } // admin APIs go to separate folder\n * },\n * {\n * type: 'operationId',\n * pattern: 'listPets',\n * options: { exclude: true } // skip this specific operation\n * }\n * ]\n * ```\n */\nexport type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {\n //TODO should be options: Omit<Partial<TOptions>, 'override'>\n options: Partial<TOptions>\n}\n\nexport type PluginFactoryOptions<\n /**\n * Unique plugin name.\n */\n TName extends string = string,\n /**\n * User-facing plugin options.\n */\n TOptions extends object = object,\n /**\n * Plugin options after defaults are applied.\n */\n TResolvedOptions extends object = TOptions,\n /**\n * Resolver that encapsulates naming and path-resolution helpers.\n * Define with `defineResolver` and export alongside the plugin.\n */\n TResolver extends Resolver = Resolver,\n> = {\n name: TName\n options: TOptions\n resolvedOptions: TResolvedOptions\n resolver: TResolver\n}\n\n/**\n * Context for hook-style plugin `kubb:plugin:setup` handler.\n * Provides methods to register generators, configure resolvers, transformers, and renderers.\n */\nexport type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {\n /**\n * Register a generator dynamically. Generators fire during the AST walk (schema/operation/operations)\n * just like generators declared statically on `createPlugin`.\n */\n addGenerator<TElement = unknown>(generator: Generator<TFactory, TElement>): void\n /**\n * Set or override the resolver for this plugin.\n * The resolver controls file naming and path resolution.\n */\n setResolver(resolver: Partial<TFactory['resolver']>): void\n /**\n * Set the AST transformer to pre-process nodes before they reach generators.\n */\n setTransformer(visitor: Visitor): void\n /**\n * Set the renderer factory to process JSX elements from generators.\n */\n setRenderer(renderer: RendererFactory): void\n /**\n * Set resolved options merged into the normalized plugin's `options`.\n * Call this in `kubb:plugin:setup` to provide options generators need.\n */\n setOptions(options: TFactory['resolvedOptions']): void\n /**\n * Inject a raw file into the build output, bypassing the generation pipeline.\n */\n injectFile(userFileNode: UserFileNode): void\n /**\n * Merge a partial config update into the current build configuration.\n */\n updateConfig(config: Partial<Config>): void\n /**\n * The resolved build configuration at setup time.\n */\n config: Config\n /**\n * The plugin's user-provided options.\n */\n options: TFactory['options']\n}\n\n/**\n * A plugin object produced by `definePlugin`.\n * Instead of flat lifecycle methods, it groups all handlers under a `hooks:` property\n * (matching Astro's integration naming convention).\n *\n * @template TFactory - The plugin's `PluginFactoryOptions` type.\n */\nexport type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {\n /**\n * Unique name for the plugin, following the same naming convention as `createPlugin`.\n */\n name: string\n /**\n * Plugins that must be registered before this plugin executes.\n * An error is thrown at startup when any listed dependency is missing.\n */\n dependencies?: Array<string>\n /**\n * Controls the execution order of this plugin relative to others.\n *\n * - `'pre'` — runs before all normal plugins.\n * - `'post'` — runs after all normal plugins.\n * - `undefined` (default) — runs in declaration order among normal plugins.\n *\n * Dependency constraints always take precedence over `enforce`.\n */\n enforce?: 'pre' | 'post'\n /**\n * The options passed by the user when calling the plugin factory.\n */\n options?: TFactory['options']\n /**\n * Lifecycle event handlers for this plugin.\n * Any event from the global `KubbHooks` map can be subscribed to here.\n */\n hooks: {\n [K in keyof KubbHooks as K extends 'kubb:plugin:setup' ? never : K]?: (...args: KubbHooks[K]) => void | Promise<void>\n } & {\n 'kubb:plugin:setup'?(ctx: KubbPluginSetupContext<TFactory>): void | Promise<void>\n }\n}\n\n/**\n * Normalized plugin after setup, with runtime fields populated.\n * For internal use only — plugins use the public `Plugin` type externally.\n *\n * @internal\n */\nexport type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & {\n options: TOptions['resolvedOptions'] & {\n output: Output\n include?: Array<Include>\n exclude: Array<Exclude>\n override: Array<Override<TOptions['resolvedOptions']>>\n }\n resolver: TOptions['resolver']\n transformer?: Visitor\n renderer?: RendererFactory\n generators?: Array<Generator>\n apply?: (config: Config) => boolean\n version?: string\n}\n\nexport type KubbPluginStartContext = {\n plugin: NormalizedPlugin\n}\n\nexport type KubbPluginEndContext = {\n plugin: NormalizedPlugin\n duration: number\n success: boolean\n error?: Error\n config: Config\n /**\n * Returns all files currently in the file manager (lazy snapshot).\n * Includes files added by plugins that have already run.\n */\n readonly files: ReadonlyArray<FileNode>\n /**\n * Upsert one or more files into the file manager.\n */\n upsertFile: (...files: Array<FileNode>) => void\n}\n\n/**\n * Wraps a factory function and returns a typed `Plugin` with lifecycle handlers grouped under `hooks`.\n *\n * Handlers live in a single `hooks` object (inspired by Astro integrations).\n * All lifecycle events from `KubbHooks` are available for subscription.\n *\n * @note For real plugins, use a `PluginFactoryOptions` type parameter to get type-safe context in `kubb:plugin:setup`.\n * Plugin names should follow the convention `plugin-<feature>` (e.g., `plugin-react-query`, `plugin-zod`).\n *\n * @example\n * ```ts\n * import { definePlugin } from '@kubb/core'\n *\n * export const pluginTs = definePlugin((options: { prefix?: string } = {}) => ({\n * name: 'plugin-ts',\n * hooks: {\n * 'kubb:plugin:setup'(ctx) {\n * ctx.setResolver(resolverTs)\n * },\n * },\n * }))\n * ```\n */\nexport function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(\n factory: (options: TFactory['options']) => Plugin<TFactory>,\n): (options?: TFactory['options']) => Plugin<TFactory> {\n return (options) => factory(options ?? ({} as TFactory['options']))\n}\n\n/**\n * Returns `'single'` when `fileOrFolder` has a file extension, `'split'` otherwise.\n * Used to determine whether an output path targets a single file or a directory.\n */\nexport function getMode(fileOrFolder: string | undefined | null): 'single' | 'split' {\n if (!fileOrFolder) return 'split'\n return extname(fileOrFolder) ? 'single' : 'split'\n}\n","import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport type { FileNode, InputNode, Node, OperationNode, SchemaNode } from '@kubb/ast'\nimport { createFile, isOperationNode, isSchemaNode } from '@kubb/ast'\nimport type { PluginFactoryOptions } from './definePlugin.ts'\nimport { getMode } from './definePlugin.ts'\nimport type { Config, Group, Output } from './types.ts'\n\n/**\n * Type/string pattern filter for include/exclude/override matching.\n */\ntype PatternFilter = {\n type: string\n pattern: string | RegExp\n}\n\n/**\n * Pattern filter with partial option overrides applied when the pattern matches.\n */\ntype PatternOverride<TOptions> = PatternFilter & {\n options: Omit<Partial<TOptions>, 'override'>\n}\n\n/**\n * Context for resolving filtered options for a given operation or schema node.\n *\n * @internal\n */\nexport type ResolveOptionsContext<TOptions> = {\n options: TOptions\n exclude?: Array<PatternFilter>\n include?: Array<PatternFilter>\n override?: Array<PatternOverride<TOptions>>\n}\n\n/**\n * Base constraint for all plugin resolver objects.\n *\n * `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`\n * are injected automatically by `defineResolver` — extend this type to add custom resolution methods.\n *\n * @example\n * ```ts\n * type MyResolver = Resolver & {\n * resolveName(node: SchemaNode): string\n * resolveTypedName(node: SchemaNode): string\n * }\n * ```\n */\nexport type Resolver = {\n name: string\n pluginName: string\n default(name: string, type?: 'file' | 'function' | 'type' | 'const'): string\n resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null\n resolvePath(params: ResolverPathParams, context: ResolverContext): string\n resolveFile(params: ResolverFileParams, context: ResolverContext): FileNode\n resolveBanner(node: InputNode | null, context: ResolveBannerContext): string | undefined\n resolveFooter(node: InputNode | null, context: ResolveBannerContext): string | undefined\n}\n\n/**\n * File-specific parameters for `Resolver.resolvePath`.\n *\n * Pass alongside a `ResolverContext` to identify which file to resolve.\n * Provide `tag` for tag-based grouping or `path` for path-based grouping.\n *\n * @example\n * ```ts\n * resolver.resolvePath(\n * { baseName: 'petTypes.ts', tag: 'pets' },\n * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },\n * )\n * // → '/src/types/petsController/petTypes.ts'\n * ```\n */\nexport type ResolverPathParams = {\n baseName: FileNode['baseName']\n pathMode?: 'single' | 'split'\n /**\n * Tag value used when `group.type === 'tag'`.\n */\n tag?: string\n /**\n * Path value used when `group.type === 'path'`.\n */\n path?: string\n}\n\n/**\n * Shared context passed as the second argument to `Resolver.resolvePath` and `Resolver.resolveFile`.\n *\n * Describes where on disk output is rooted, which output config is active, and the optional\n * grouping strategy that controls subdirectory layout.\n *\n * @example\n * ```ts\n * const context: ResolverContext = {\n * root: config.root,\n * output,\n * group,\n * }\n * ```\n */\nexport type ResolverContext = {\n root: string\n output: Output\n group?: Group\n /**\n * Plugin name used to populate `meta.pluginName` on the resolved file.\n */\n pluginName?: string\n}\n\n/**\n * File-specific parameters for `Resolver.resolveFile`.\n *\n * Pass alongside a `ResolverContext` to fully describe the file to resolve.\n * `tag` and `path` are used only when a matching `group` is present in the context.\n *\n * @example\n * ```ts\n * resolver.resolveFile(\n * { name: 'listPets', extname: '.ts', tag: 'pets' },\n * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },\n * )\n * // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }\n * ```\n */\nexport type ResolverFileParams = {\n name: string\n extname: FileNode['extname']\n /**\n * Tag value used when `group.type === 'tag'`.\n */\n tag?: string\n /**\n * Path value used when `group.type === 'path'`.\n */\n path?: string\n}\n\n/**\n * Context passed to `Resolver.resolveBanner` and `Resolver.resolveFooter`.\n *\n * `output` is optional — not every plugin configures a banner/footer.\n * `config` carries the global Kubb config, used to derive the default Kubb banner.\n *\n * @example\n * ```ts\n * resolver.resolveBanner(inputNode, { output: { banner: '// generated' }, config })\n * // → '// generated'\n * ```\n */\nexport type ResolveBannerContext = {\n output?: Pick<Output, 'banner' | 'footer'>\n config: Config\n}\n\n/**\n * Builder type for the plugin-specific resolver fields.\n *\n * `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`\n * are optional — built-in fallbacks are injected when omitted.\n *\n * Methods in the returned object can call sibling resolver methods via `this`.\n */\ntype ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<\n T['resolver'],\n 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter' | 'name' | 'pluginName'\n> &\n Partial<Pick<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>> & {\n name: string\n pluginName: T['name']\n } & ThisType<T['resolver']>\n\n// String patterns are compiled lazily and cached — the same filter is reused for every node.\nconst stringPatternCache = new Map<string, RegExp>()\n\nfunction testPattern(value: string, pattern: string | RegExp): boolean {\n if (typeof pattern === 'string') {\n let regex = stringPatternCache.get(pattern)\n if (!regex) {\n regex = new RegExp(pattern)\n stringPatternCache.set(pattern, regex)\n }\n return regex.test(value)\n }\n // Use .match() for user-supplied RegExp to preserve semantics regardless of `g`/`y` flags.\n return value.match(pattern) !== null\n}\n\n/**\n * Checks if an operation matches a pattern for a given filter type (`tag`, `operationId`, `path`, `method`).\n */\nfunction matchesOperationPattern(node: OperationNode, type: string, pattern: string | RegExp): boolean {\n switch (type) {\n case 'tag':\n return node.tags.some((tag) => testPattern(tag, pattern))\n case 'operationId':\n return testPattern(node.operationId, pattern)\n case 'path':\n return testPattern(node.path, pattern)\n case 'method':\n return testPattern(node.method.toLowerCase(), pattern)\n case 'contentType':\n return node.requestBody?.content?.some((c) => testPattern(c.contentType, pattern)) ?? false\n default:\n return false\n }\n}\n\n/**\n * Checks if a schema matches a pattern for a given filter type (`schemaName`).\n *\n * Returns `null` when the filter type doesn't apply to schemas.\n */\nfunction matchesSchemaPattern(node: SchemaNode, type: string, pattern: string | RegExp): boolean | null {\n switch (type) {\n case 'schemaName':\n return node.name ? testPattern(node.name, pattern) : false\n default:\n return null\n }\n}\n\n/**\n * Default name resolver used by `defineResolver`.\n *\n * - `camelCase` for `function` and `file` types.\n * - `PascalCase` for `type`.\n * - `camelCase` for everything else.\n */\nfunction defaultResolver(name: string, type?: 'file' | 'function' | 'type' | 'const'): string {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n return resolvedName\n}\n\n/**\n * Default option resolver — applies include/exclude filters and merges matching override options.\n *\n * Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.\n *\n * @example Include/exclude filtering\n * ```ts\n * const options = defaultResolveOptions(operationNode, {\n * options: { output: 'types' },\n * exclude: [{ type: 'tag', pattern: 'internal' }],\n * })\n * // → null when node has tag 'internal'\n * ```\n *\n * @example Override merging\n * ```ts\n * const options = defaultResolveOptions(operationNode, {\n * options: { enumType: 'asConst' },\n * override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],\n * })\n * // → { enumType: 'enum' } when operationId matches\n * ```\n */\nexport function defaultResolveOptions<TOptions>(\n node: Node,\n { options, exclude = [], include, override = [] }: ResolveOptionsContext<TOptions>,\n): TOptions | null {\n if (isOperationNode(node)) {\n const isExcluded = exclude.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))\n if (isExcluded) {\n return null\n }\n\n if (include && !include.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) {\n return null\n }\n\n const overrideOptions = override.find(({ type, pattern }) => matchesOperationPattern(node, type, pattern))?.options\n\n return { ...options, ...overrideOptions }\n }\n\n if (isSchemaNode(node)) {\n if (exclude.some(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)) {\n return null\n }\n\n if (include) {\n const results = include.map(({ type, pattern }) => matchesSchemaPattern(node, type, pattern))\n const applicable = results.filter((r) => r !== null)\n if (applicable.length > 0 && !applicable.includes(true)) {\n return null\n }\n }\n\n const overrideOptions = override.find(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)?.options\n\n return { ...options, ...overrideOptions }\n }\n\n return options\n}\n\n/**\n * Default path resolver used by `defineResolver`.\n *\n * - Returns the output directory in `single` mode.\n * - Resolves into a tag- or path-based subdirectory when `group` and a `tag`/`path` value are provided.\n * - Falls back to a flat `output/baseName` path otherwise.\n *\n * A custom `group.name` function overrides the default subdirectory naming.\n * For `tag` groups the default is `${camelCase(tag)}Controller`.\n * For `path` groups the default is the first path segment after `/`.\n *\n * @example Flat output\n * ```ts\n * defaultResolvePath({ baseName: 'petTypes.ts' }, { root: '/src', output: { path: 'types' } })\n * // → '/src/types/petTypes.ts'\n * ```\n *\n * @example Tag-based grouping\n * ```ts\n * defaultResolvePath(\n * { baseName: 'petTypes.ts', tag: 'pets' },\n * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },\n * )\n * // → '/src/types/petsController/petTypes.ts'\n * ```\n *\n * @example Path-based grouping\n * ```ts\n * defaultResolvePath(\n * { baseName: 'petTypes.ts', path: '/pets/list' },\n * { root: '/src', output: { path: 'types' }, group: { type: 'path' } },\n * )\n * // → '/src/types/pets/petTypes.ts'\n * ```\n *\n * @example Single-file mode\n * ```ts\n * defaultResolvePath(\n * { baseName: 'petTypes.ts', pathMode: 'single' },\n * { root: '/src', output: { path: 'types' } },\n * )\n * // → '/src/types'\n * ```\n */\nexport function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }: ResolverPathParams, { root, output, group }: ResolverContext): string {\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n return path.resolve(root, output.path)\n }\n\n let result: string\n\n if (group && (groupPath || tag)) {\n const groupValue = group.type === 'path' ? groupPath! : tag!\n const defaultName =\n group.type === 'tag'\n ? ({ group: g }: { group: string }) => `${camelCase(g)}Controller`\n : ({ group: g }: { group: string }) => {\n // Strip traversal components (empty, '.', '..') before taking the first meaningful segment.\n // When every segment is a traversal component (e.g. '../../') we fall back to '' so the\n // file is placed directly in the output root — the boundary check below ensures safety.\n const segment = g.split('/').filter((s) => s !== '' && s !== '.' && s !== '..')[0]\n return segment ? camelCase(segment) : ''\n }\n const resolveName = group.name ?? defaultName\n result = path.resolve(root, output.path, resolveName({ group: groupValue }), baseName)\n } else {\n result = path.resolve(root, output.path, baseName)\n }\n\n // Ensure the resolved path stays within the configured output directory.\n // This prevents path traversal from malicious OpenAPI specs or custom group.name functions.\n // `result === outputDir` is intentionally permitted: it matches single-file mode paths and\n // edge cases where baseName resolves to the output directory itself.\n const outputDir = path.resolve(root, output.path)\n const outputDirWithSep = outputDir.endsWith(path.sep) ? outputDir : `${outputDir}${path.sep}`\n if (result !== outputDir && !result.startsWith(outputDirWithSep)) {\n throw new Error(\n `[Kubb] Resolved path \"${result}\" is outside the output directory \"${outputDir}\". ` +\n 'This may indicate a path traversal attempt in the OpenAPI specification or a misconfigured group.name function.',\n )\n }\n\n return result\n}\n\n/**\n * Default file resolver used by `defineResolver`.\n *\n * Resolves a `FileNode` by combining name resolution (`resolver.default`) with\n * path resolution (`resolver.resolvePath`). The resolved file always has empty\n * `sources`, `imports`, and `exports` arrays — consumers populate those separately.\n *\n * In `single` mode the name is omitted and the file sits directly in the output directory.\n *\n * @example Resolve a schema file\n * ```ts\n * const file = defaultResolveFile.call(\n * resolver,\n * { name: 'pet', extname: '.ts' },\n * { root: '/src', output: { path: 'types' } },\n * )\n * // → { baseName: 'pet.ts', path: '/src/types/pet.ts', sources: [], ... }\n * ```\n *\n * @example Resolve an operation file with tag grouping\n * ```ts\n * const file = defaultResolveFile.call(\n * resolver,\n * { name: 'listPets', extname: '.ts', tag: 'pets' },\n * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },\n * )\n * // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }\n * ```\n */\nexport function defaultResolveFile(this: Resolver, { name, extname, tag, path: groupPath }: ResolverFileParams, context: ResolverContext): FileNode {\n const pathMode = getMode(path.resolve(context.root, context.output.path))\n const resolvedName = pathMode === 'single' ? '' : this.default(name, 'file')\n const baseName = `${resolvedName}${extname}` as FileNode['baseName']\n const filePath = this.resolvePath({ baseName, pathMode, tag, path: groupPath }, context)\n\n return createFile({\n path: filePath,\n baseName: path.basename(filePath) as `${string}.${string}`,\n meta: {\n pluginName: this.pluginName,\n },\n sources: [],\n imports: [],\n exports: [],\n })\n}\n\n/**\n * Generates the default \"Generated by Kubb\" banner from config and optional node metadata.\n */\nexport function buildDefaultBanner({\n title,\n description,\n version,\n config,\n}: {\n title?: string\n description?: string\n version?: string\n config: Config\n}): string {\n try {\n let source = ''\n if (Array.isArray(config.input)) {\n const first = config.input[0]\n if (first && 'path' in first) {\n source = path.basename(first.path)\n }\n } else if (config.input && 'path' in config.input) {\n source = path.basename(config.input.path)\n } else if (config.input && 'data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n return '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n*/'\n }\n}\n\n/**\n * Default banner resolver — returns the banner string for a generated file.\n *\n * A user-supplied `output.banner` overrides the default Kubb \"Generated by Kubb\" notice.\n * When no `output.banner` is set, the Kubb notice is used (including `title` and `version`\n * from the OAS spec when a `node` is provided).\n *\n * - When `output.banner` is a function and `node` is provided, returns `output.banner(node)`.\n * - When `output.banner` is a function and `node` is absent, falls back to the Kubb notice.\n * - When `output.banner` is a string, returns it directly.\n * - When `config.output.defaultBanner` is `false`, returns `undefined`.\n * - Otherwise returns the Kubb \"Generated by Kubb\" notice.\n *\n * @example String banner overrides default\n * ```ts\n * defaultResolveBanner(undefined, { output: { banner: '// my banner' }, config })\n * // → '// my banner'\n * ```\n *\n * @example Function banner with node\n * ```ts\n * defaultResolveBanner(inputNode, { output: { banner: (node) => `// v${node.version}` }, config })\n * // → '// v3.0.0'\n * ```\n *\n * @example No user banner — Kubb notice with OAS metadata\n * ```ts\n * defaultResolveBanner(inputNode, { config })\n * // → '/** Generated by Kubb ... Title: Pet Store ... *\\/'\n * ```\n *\n * @example Disabled default banner\n * ```ts\n * defaultResolveBanner(undefined, { config: { output: { defaultBanner: false }, ...config } })\n * // → undefined\n * ```\n */\nexport function defaultResolveBanner(node: InputNode | undefined, { output, config }: ResolveBannerContext): string | undefined {\n if (typeof output?.banner === 'function') {\n return output.banner(node)\n }\n\n if (typeof output?.banner === 'string') {\n return output.banner\n }\n\n if (config.output.defaultBanner === false) {\n return undefined\n }\n\n return buildDefaultBanner({\n title: node?.meta?.title,\n version: node?.meta?.version,\n config,\n })\n}\n\n/**\n * Default footer resolver — returns the footer string for a generated file.\n *\n * - When `output.footer` is a function and `node` is provided, calls it with the node.\n * - When `output.footer` is a function and `node` is absent, returns `undefined`.\n * - When `output.footer` is a string, returns it directly.\n * - Otherwise returns `undefined`.\n *\n * @example String footer\n * ```ts\n * defaultResolveFooter(undefined, { output: { footer: '// end of file' }, config })\n * // → '// end of file'\n * ```\n *\n * @example Function footer with node\n * ```ts\n * defaultResolveFooter(inputNode, { output: { footer: (node) => `// ${node.title}` }, config })\n * // → '// Pet Store'\n * ```\n */\nexport function defaultResolveFooter(node: InputNode | undefined, { output }: ResolveBannerContext): string | undefined {\n if (typeof output?.footer === 'function') {\n return node ? output.footer(node) : undefined\n }\n if (typeof output?.footer === 'string') {\n return output.footer\n }\n return undefined\n}\n\n/**\n * Defines a resolver for a plugin, injecting built-in defaults for name casing,\n * include/exclude/override filtering, path resolution, and file construction.\n *\n * All four defaults can be overridden by providing them in the builder function:\n * - `default` — name casing strategy (camelCase / PascalCase)\n * - `resolveOptions` — include/exclude/override filtering\n * - `resolvePath` — output path computation\n * - `resolveFile` — full `FileNode` construction\n *\n * Methods in the returned object can call sibling resolver methods via `this`.\n *\n * @example Basic resolver with naming helpers\n * ```ts\n * export const resolver = defineResolver<PluginTs>(() => ({\n * name: 'default',\n * resolveName(node) {\n * return this.default(node.name, 'function')\n * },\n * resolveTypedName(node) {\n * return this.default(node.name, 'type')\n * },\n * }))\n * ```\n *\n * @example Override resolvePath for a custom output structure\n * ```ts\n * export const resolver = defineResolver<PluginTs>(() => ({\n * name: 'custom',\n * resolvePath({ baseName }, { root, output }) {\n * return path.resolve(root, output.path, 'generated', baseName)\n * },\n * }))\n * ```\n *\n * @example Use this.default inside a helper\n * ```ts\n * export const resolver = defineResolver<PluginTs>(() => ({\n * name: 'default',\n * resolveParamName(node, param) {\n * return this.default(`${node.operationId} ${param.in} ${param.name}`, 'type')\n * },\n * }))\n * ```\n */\nexport function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'] {\n // `resolver` is kept so the default `resolveFile` wrapper can reference the fully assembled\n // object via `.call(resolver, ...)` at call-time, after the result is assigned below.\n let resolver: T['resolver']\n\n const result = {\n default: defaultResolver,\n resolveOptions: defaultResolveOptions,\n resolvePath: defaultResolvePath,\n resolveFile: (params: ResolverFileParams, context: ResolverContext) => defaultResolveFile.call(resolver as Resolver, params, context),\n resolveBanner: defaultResolveBanner,\n resolveFooter: defaultResolveFooter,\n ...build(),\n } as T['resolver']\n\n resolver = result\n\n return resolver\n}\n","import type { InputNode } from '@kubb/ast'\nimport { deflateSync, inflateSync } from 'fflate'\nimport { x } from 'tinyexec'\n\nexport type DevtoolsOptions = {\n /**\n * Open the AST inspector in Kubb Studio (`/ast`). Defaults to the main Studio page.\n * @default false\n */\n ast?: boolean\n}\n\n/**\n * Encodes an `InputNode` as a compressed, URL-safe string.\n *\n * The JSON representation is deflate-compressed with {@link deflateSync} before\n * base64url encoding, which typically reduces payload size by 70–80 % and\n * keeps URLs well within browser and server path-length limits.\n *\n * Use {@link decodeAst} to reverse.\n */\nexport function encodeAst(input: InputNode): string {\n const compressed = deflateSync(new TextEncoder().encode(JSON.stringify(input)))\n return Buffer.from(compressed).toString('base64url')\n}\n\n/**\n * Decodes an `InputNode` from a string produced by {@link encodeAst}.\n *\n * Works in both Node.js and the browser — no streaming APIs required.\n */\nexport function decodeAst(encoded: string): InputNode {\n const bytes = Buffer.from(encoded, 'base64url')\n return JSON.parse(new TextDecoder().decode(inflateSync(bytes))) as InputNode\n}\n\n/**\n * Constructs the Kubb Studio URL for the given `InputNode`.\n * When `options.ast` is `true`, navigates to the AST inspector (`/ast`).\n * The `input` is encoded and attached as the `?root=` query parameter so Studio\n * can decode and render it without a round-trip to any server.\n */\nexport function getStudioUrl(input: InputNode, studioUrl: string, options: DevtoolsOptions = {}): string {\n const baseUrl = studioUrl.replace(/\\/$/, '')\n const path = options.ast ? '/ast' : ''\n\n return `${baseUrl}${path}?root=${encodeAst(input)}`\n}\n\n/**\n * Opens the Kubb Studio URL for the given `InputNode` in the default browser —\n *\n * Falls back to printing the URL if the browser cannot be launched.\n */\nexport async function openInStudio(input: InputNode, studioUrl: string, options: DevtoolsOptions = {}): Promise<void> {\n const url = getStudioUrl(input, studioUrl, options)\n\n const cmd = process.platform === 'win32' ? 'cmd' : process.platform === 'darwin' ? 'open' : 'xdg-open'\n const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url]\n\n try {\n await x(cmd, args)\n } catch {\n console.log(`\\n ${url}\\n`)\n }\n}\n","import type { FileNode } from '@kubb/ast'\nimport { createFile } from '@kubb/ast'\n\nfunction mergeFile<TMeta extends object = object>(a: FileNode<TMeta>, b: FileNode<TMeta>): FileNode<TMeta> {\n return {\n ...a,\n // Incoming file (b) takes precedence for banner/footer so that barrel files,\n // which never carry a banner, can clear banners set by plugin-generated files\n // at the same path.\n banner: b.banner,\n footer: b.footer,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\n/**\n * Collapses a list of files so that duplicates sharing the same `path` are merged\n * in arrival order. Keeps the original order of first occurrence.\n */\nfunction mergeFilesByPath(files: ReadonlyArray<FileNode>): Map<string, FileNode> {\n const merged = new Map<string, FileNode>()\n for (const file of files) {\n const existing = merged.get(file.path)\n merged.set(file.path, existing ? mergeFile(existing, file) : file)\n }\n return merged\n}\n\n/**\n * In-memory file store for generated files.\n *\n * Files with the same `path` are merged — sources, imports, and exports are concatenated.\n * The `files` getter returns all stored files sorted by path length (shortest first).\n *\n * @example\n * ```ts\n * import { FileManager } from '@kubb/core'\n *\n * const manager = new FileManager()\n * manager.upsert(myFile)\n * console.log(manager.files) // all stored files\n * ```\n */\nexport class FileManager {\n readonly #cache = new Map<string, FileNode>()\n #filesCache: Array<FileNode> | null = null\n\n /**\n * Adds one or more files. Incoming files with the same path are merged\n * (sources/imports/exports concatenated), but existing cache entries are\n * replaced — use {@link upsert} when you want to merge into the cache too.\n */\n add(...files: Array<FileNode>): Array<FileNode> {\n return this.#store(files, false)\n }\n\n /**\n * Adds or merges one or more files.\n * If a file with the same path already exists in the cache, its\n * sources/imports/exports are merged into the incoming file.\n */\n upsert(...files: Array<FileNode>): Array<FileNode> {\n return this.#store(files, true)\n }\n\n #store(files: ReadonlyArray<FileNode>, mergeExisting: boolean): Array<FileNode> {\n const resolvedFiles: Array<FileNode> = []\n for (const file of mergeFilesByPath(files).values()) {\n const existing = mergeExisting ? this.#cache.get(file.path) : undefined\n const resolvedFile = createFile(existing ? mergeFile(existing, file) : file)\n this.#cache.set(resolvedFile.path, resolvedFile)\n resolvedFiles.push(resolvedFile)\n }\n this.#filesCache = null\n return resolvedFiles\n }\n\n getByPath(path: string): FileNode | null {\n return this.#cache.get(path) ?? null\n }\n\n deleteByPath(path: string): void {\n this.#cache.delete(path)\n this.#filesCache = null\n }\n\n clear(): void {\n this.#cache.clear()\n this.#filesCache = null\n }\n\n /**\n * Releases all stored files. Called by the core after `kubb:build:end` to\n * free the per-plugin FileNode caches for the rest of the process lifetime.\n */\n dispose(): void {\n this.clear()\n }\n\n [Symbol.dispose](): void {\n this.dispose()\n }\n\n /**\n * All stored files, sorted by path length (shorter paths first).\n */\n get files(): Array<FileNode> {\n if (this.#filesCache) {\n return this.#filesCache\n }\n\n this.#filesCache = [...this.#cache.values()].sort((a, b) => {\n const lenDiff = a.path.length - b.path.length\n if (lenDiff !== 0) return lenDiff\n // Within the same length bucket, index.ts barrel files go last so other\n // files are always processed before their barrel file.\n const aIsIndex = a.path.endsWith('/index.ts') || a.path === 'index.ts'\n const bIsIndex = b.path.endsWith('/index.ts') || b.path === 'index.ts'\n if (aIsIndex && !bIsIndex) return 1\n if (!aIsIndex && bIsIndex) return -1\n return 0\n })\n return this.#filesCache\n }\n}\n","import { resolve } from 'node:path'\nimport type { AsyncEventEmitter } from '@internals/utils'\nimport type { FileNode, InputNode, InputStreamNode, OperationNode, SchemaNode } from '@kubb/ast'\nimport { createFile } from '@kubb/ast'\nimport { DEFAULT_STUDIO_URL } from './constants.ts'\nimport type { Generator } from './defineGenerator.ts'\nimport type { Plugin } from './definePlugin.ts'\nimport { getMode } from './definePlugin.ts'\nimport { defineResolver } from './defineResolver.ts'\nimport { openInStudio as openInStudioFn } from './devtools.ts'\nimport { FileManager } from './FileManager.ts'\nimport type { RendererFactory } from './createRenderer.ts'\n\nimport type {\n Adapter,\n Config,\n DevtoolsOptions,\n GeneratorContext,\n KubbHooks,\n KubbPluginSetupContext,\n NormalizedPlugin,\n PluginFactoryOptions,\n Resolver,\n} from './types.ts'\n\n// inspired by: https://github.com/rollup/rollup/blob/master/src/utils/PluginDriver.ts#\n\ntype Options = {\n hooks: AsyncEventEmitter<KubbHooks>\n}\n\nfunction enforceOrder(enforce: 'pre' | 'post' | undefined): number {\n return enforce === 'pre' ? -1 : enforce === 'post' ? 1 : 0\n}\n\nexport class PluginDriver {\n readonly config: Config\n readonly options: Options\n\n /**\n * Returns `'single'` when `fileOrFolder` has a file extension, `'split'` otherwise.\n *\n * @example\n * ```ts\n * PluginDriver.getMode('src/gen/types.ts') // 'single'\n * PluginDriver.getMode('src/gen/types') // 'split'\n * ```\n */\n static getMode(fileOrFolder: string | undefined | null): 'single' | 'split' {\n return getMode(fileOrFolder)\n }\n\n /**\n * The universal `@kubb/ast` `InputNode` produced by the adapter, set by\n * the build pipeline after the adapter's `parse()` resolves.\n */\n inputNode: InputNode | undefined = undefined\n /**\n * Set when the adapter returns a streaming `InputStreamNode` (large specs).\n * Mutually exclusive with `inputNode` — exactly one is set after adapter setup.\n */\n inputStreamNode: InputStreamNode | undefined = undefined\n\n adapter: Adapter | undefined = undefined\n #studioIsOpen = false\n\n /**\n * Central file store for all generated files.\n * Plugins should use `this.addFile()` / `this.upsertFile()` (via their context) to\n * add files; this property gives direct read/write access when needed.\n */\n readonly fileManager = new FileManager()\n\n readonly plugins = new Map<string, NormalizedPlugin>()\n\n /**\n * Tracks which plugins have generators registered via `addGenerator()` (event-based path).\n * Used by the build loop to decide whether to emit generator events for a given plugin.\n */\n readonly #pluginsWithEventGenerators = new Set<string>()\n readonly #resolvers = new Map<string, Resolver>()\n readonly #defaultResolvers = new Map<string, Resolver>()\n readonly #hookListeners = new Map<keyof KubbHooks, Set<(...args: never[]) => void | Promise<void>>>()\n\n constructor(config: Config, options: Options) {\n this.config = config\n this.options = options\n config.plugins\n .map((rawPlugin) => this.#normalizePlugin(rawPlugin as Plugin))\n .filter((plugin) => {\n if (typeof plugin.apply === 'function') {\n return plugin.apply(config)\n }\n return true\n })\n .sort((a, b) => {\n if (b.dependencies?.includes(a.name)) return -1\n if (a.dependencies?.includes(b.name)) return 1\n // enforce: 'pre' plugins run first, 'post' plugins run last\n return enforceOrder(a.enforce) - enforceOrder(b.enforce)\n })\n .forEach((plugin) => {\n this.plugins.set(plugin.name, plugin)\n })\n }\n\n get hooks() {\n return this.options.hooks\n }\n\n /**\n * Creates an `NormalizedPlugin` from a hook-style plugin and registers\n * its lifecycle handlers on the `AsyncEventEmitter`.\n */\n #normalizePlugin(hookPlugin: Plugin): NormalizedPlugin {\n const normalizedPlugin = {\n name: hookPlugin.name,\n dependencies: hookPlugin.dependencies,\n enforce: hookPlugin.enforce,\n options: { output: { path: '.' }, exclude: [], override: [] },\n } as unknown as NormalizedPlugin\n\n this.registerPluginHooks(hookPlugin, normalizedPlugin)\n return normalizedPlugin\n }\n\n /**\n * Registers a hook-style plugin's lifecycle handlers on the shared `AsyncEventEmitter`.\n *\n * For `kubb:plugin:setup`, the registered listener wraps the globally emitted context with a\n * plugin-specific one so that `addGenerator`, `setResolver`, `setTransformer`, and\n * `setRenderer` all target the correct `normalizedPlugin` entry in the plugins map.\n *\n * All other hooks are iterated and registered directly as pass-through listeners.\n * Any event key present in the global `KubbHooks` interface can be subscribed to.\n *\n * External tooling can subscribe to any of these events via `hooks.on(...)` to observe\n * the plugin lifecycle without modifying plugin behavior.\n *\n * @internal\n */\n registerPluginHooks(hookPlugin: Plugin, normalizedPlugin: NormalizedPlugin): void {\n const { hooks } = hookPlugin\n\n if (!hooks) return\n\n // kubb:plugin:setup gets special treatment: the globally emitted context is wrapped with\n // plugin-specific implementations so that addGenerator / setResolver / etc. target\n // this plugin's normalizedPlugin entry rather than being no-ops.\n if (hooks['kubb:plugin:setup']) {\n const setupHandler = (globalCtx: KubbPluginSetupContext) => {\n const pluginCtx: KubbPluginSetupContext = {\n ...globalCtx,\n options: hookPlugin.options ?? {},\n addGenerator: (gen) => {\n this.registerGenerator(normalizedPlugin.name, gen)\n },\n setResolver: (resolver) => {\n this.setPluginResolver(normalizedPlugin.name, resolver)\n },\n setTransformer: (visitor) => {\n normalizedPlugin.transformer = visitor\n },\n setRenderer: (renderer) => {\n normalizedPlugin.renderer = renderer\n },\n setOptions: (opts) => {\n normalizedPlugin.options = { ...normalizedPlugin.options, ...opts }\n },\n injectFile: (userFileNode) => {\n this.fileManager.add(createFile(userFileNode))\n },\n }\n return hooks['kubb:plugin:setup']!(pluginCtx)\n }\n\n this.hooks.on('kubb:plugin:setup', setupHandler)\n this.#trackHookListener('kubb:plugin:setup', setupHandler as (...args: never[]) => void | Promise<void>)\n }\n\n // All other hooks are registered as direct pass-through listeners on the shared emitter.\n for (const [event, handler] of Object.entries(hooks) as Array<[keyof KubbHooks, ((...args: never[]) => void | Promise<void>) | undefined]>) {\n if (event === 'kubb:plugin:setup' || !handler) continue\n\n this.hooks.on(event, handler as never)\n this.#trackHookListener(event, handler as (...args: never[]) => void | Promise<void>)\n }\n }\n\n /**\n * Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners\n * can configure generators, resolvers, transformers and renderers before `buildStart` runs.\n *\n * Call this once from `safeBuild` before the plugin execution loop begins.\n */\n async emitSetupHooks(): Promise<void> {\n const noop = () => {}\n\n await this.hooks.emit('kubb:plugin:setup', {\n config: this.config,\n options: {},\n addGenerator: noop,\n setResolver: noop,\n setTransformer: noop,\n setRenderer: noop,\n setOptions: noop,\n injectFile: noop,\n updateConfig: noop,\n })\n }\n\n /**\n * Registers a generator for the given plugin on the shared event emitter.\n *\n * The generator's `schema`, `operation`, and `operations` methods are registered as\n * listeners on `kubb:generate:schema`, `kubb:generate:operation`, and `kubb:generate:operations`\n * respectively. Each listener is scoped to the owning plugin via a `ctx.plugin.name` check\n * so that generators from different plugins do not cross-fire.\n *\n * The renderer resolution chain is: `generator.renderer → plugin.renderer → config.renderer`.\n * Set `generator.renderer = null` to explicitly opt out of rendering even when the plugin\n * declares a renderer.\n *\n * Call this method inside `addGenerator()` (in `kubb:plugin:setup`) to wire up a generator.\n */\n registerGenerator(pluginName: string, gen: Generator): void {\n const resolveRenderer = () => {\n const plugin = this.plugins.get(pluginName)\n return gen.renderer === null ? undefined : (gen.renderer ?? plugin?.renderer ?? this.config.renderer)\n }\n\n if (gen.schema) {\n const schemaHandler = async (node: SchemaNode, ctx: GeneratorContext) => {\n if (ctx.plugin.name !== pluginName) return\n const result = await gen.schema!(node, ctx)\n await applyHookResult(result, this, resolveRenderer())\n }\n\n this.hooks.on('kubb:generate:schema', schemaHandler)\n this.#trackHookListener('kubb:generate:schema', schemaHandler as (...args: never[]) => void | Promise<void>)\n }\n\n if (gen.operation) {\n const operationHandler = async (node: OperationNode, ctx: GeneratorContext) => {\n if (ctx.plugin.name !== pluginName) return\n const result = await gen.operation!(node, ctx)\n await applyHookResult(result, this, resolveRenderer())\n }\n\n this.hooks.on('kubb:generate:operation', operationHandler)\n this.#trackHookListener('kubb:generate:operation', operationHandler as (...args: never[]) => void | Promise<void>)\n }\n\n if (gen.operations) {\n const operationsHandler = async (nodes: Array<OperationNode>, ctx: GeneratorContext) => {\n if (ctx.plugin.name !== pluginName) return\n const result = await gen.operations!(nodes, ctx)\n await applyHookResult(result, this, resolveRenderer())\n }\n\n this.hooks.on('kubb:generate:operations', operationsHandler)\n this.#trackHookListener('kubb:generate:operations', operationsHandler as (...args: never[]) => void | Promise<void>)\n }\n\n this.#pluginsWithEventGenerators.add(pluginName)\n }\n\n /**\n * Returns `true` when at least one generator was registered for the given plugin\n * via `addGenerator()` in `kubb:plugin:setup` (event-based path).\n *\n * Used by the build loop to decide whether to walk the AST and emit generator events\n * for a plugin that has no static `plugin.generators`.\n */\n hasRegisteredGenerators(pluginName: string): boolean {\n return this.#pluginsWithEventGenerators.has(pluginName)\n }\n\n /**\n * Unregisters all plugin lifecycle listeners from the shared event emitter.\n * Called at the end of a build to prevent listener leaks across repeated builds.\n *\n * @internal\n */\n dispose(): void {\n for (const [event, handlers] of this.#hookListeners) {\n for (const handler of handlers) {\n this.hooks.off(event, handler as never)\n }\n }\n this.#hookListeners.clear()\n this.#pluginsWithEventGenerators.clear()\n // Release resolver closures — the driver is rebuilt for each build() call\n // so there is no value in retaining these maps after disposal.\n this.#resolvers.clear()\n this.#defaultResolvers.clear()\n // Release the parsed adapter graph and the FileNode cache once the build\n // has finished; the returned `BuildOutput.files` array still references\n // any FileNodes the caller needs to inspect.\n this.fileManager.dispose()\n this.inputNode = undefined\n this.inputStreamNode = undefined\n }\n\n [Symbol.dispose](): void {\n this.dispose()\n }\n\n #trackHookListener(event: keyof KubbHooks, handler: (...args: never[]) => void | Promise<void>): void {\n let handlers = this.#hookListeners.get(event)\n if (!handlers) {\n handlers = new Set()\n this.#hookListeners.set(event, handlers)\n }\n handlers.add(handler)\n }\n\n #createDefaultResolver(pluginName: string): Resolver {\n const existingResolver = this.#defaultResolvers.get(pluginName)\n if (existingResolver) {\n return existingResolver\n }\n\n const resolver = defineResolver<PluginFactoryOptions>(() => ({\n name: 'default',\n pluginName,\n }))\n this.#defaultResolvers.set(pluginName, resolver)\n return resolver\n }\n\n /**\n * Merges `partial` with the plugin's default resolver and stores the result.\n * Also mirrors it onto `plugin.resolver` so callers using `getPlugin(name).resolver`\n * get the up-to-date resolver without going through `getResolver()`.\n */\n setPluginResolver(pluginName: string, partial: Partial<Resolver>): void {\n const defaultResolver = this.#createDefaultResolver(pluginName)\n const merged = { ...defaultResolver, ...partial }\n this.#resolvers.set(pluginName, merged)\n const plugin = this.plugins.get(pluginName)\n if (plugin) {\n plugin.resolver = merged\n }\n }\n\n /**\n * Returns the resolver for the given plugin.\n *\n * Resolution order: dynamic resolver set via `setPluginResolver` → static resolver on the\n * plugin → lazily created default resolver (identity name, no path transforms).\n */\n getResolver<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Kubb.PluginRegistry[TName]['resolver']\n getResolver<TResolver extends Resolver = Resolver>(pluginName: string): TResolver\n getResolver(pluginName: string): Resolver {\n return this.#resolvers.get(pluginName) ?? this.plugins.get(pluginName)?.resolver ?? this.#createDefaultResolver(pluginName)\n }\n\n getContext<TOptions extends PluginFactoryOptions>(plugin: NormalizedPlugin<TOptions>): GeneratorContext<TOptions> & Record<string, unknown> {\n const driver = this\n\n const baseContext = {\n config: driver.config,\n get root(): string {\n return resolve(driver.config.root, driver.config.output.path)\n },\n getMode(output: { path: string }): 'single' | 'split' {\n return PluginDriver.getMode(resolve(driver.config.root, driver.config.output.path, output.path))\n },\n hooks: driver.hooks,\n plugin,\n getPlugin: driver.getPlugin.bind(driver),\n requirePlugin: driver.requirePlugin.bind(driver),\n getResolver: driver.getResolver.bind(driver),\n driver,\n addFile: async (...files: Array<FileNode>) => {\n driver.fileManager.add(...files)\n },\n upsertFile: async (...files: Array<FileNode>) => {\n driver.fileManager.upsert(...files)\n },\n get inputNode(): InputNode {\n return driver.inputNode ?? { kind: 'Input' as const, schemas: [], operations: [], meta: driver.inputStreamNode?.meta }\n },\n get adapter(): Adapter | undefined {\n return driver.adapter\n },\n get resolver() {\n return driver.getResolver(plugin.name)\n },\n get transformer() {\n return plugin.transformer\n },\n warn(message: string) {\n driver.hooks.emit('kubb:warn', { message })\n },\n error(error: string | Error) {\n driver.hooks.emit('kubb:error', { error: typeof error === 'string' ? new Error(error) : error })\n },\n info(message: string) {\n driver.hooks.emit('kubb:info', { message })\n },\n openInStudio(options?: DevtoolsOptions) {\n if (!driver.config.devtools || driver.#studioIsOpen) {\n return\n }\n\n if (typeof driver.config.devtools !== 'object') {\n throw new Error('Devtools must be an object')\n }\n\n if (!driver.inputNode || !driver.adapter) {\n throw new Error('adapter is not defined, make sure you have set the parser in kubb.config.ts')\n }\n\n driver.#studioIsOpen = true\n\n const studioUrl = driver.config.devtools?.studioUrl ?? DEFAULT_STUDIO_URL\n\n return openInStudioFn(driver.inputNode, studioUrl, options)\n },\n } as unknown as GeneratorContext<TOptions>\n\n return baseContext\n }\n\n getPlugin<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined\n getPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions> | undefined\n getPlugin(pluginName: string): Plugin | undefined {\n return this.plugins.get(pluginName)\n }\n\n /**\n * Like `getPlugin` but throws a descriptive error when the plugin is not found.\n */\n requirePlugin<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Plugin<Kubb.PluginRegistry[TName]>\n requirePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions>\n requirePlugin(pluginName: string): Plugin {\n const plugin = this.plugins.get(pluginName)\n if (!plugin) {\n throw new Error(`[kubb] Plugin \"${pluginName}\" is required but not found. Make sure it is included in your Kubb config.`)\n }\n return plugin\n }\n}\n\n/**\n * Handles the return value of a plugin AST hook or generator method.\n *\n * - Renderer output → rendered via the provided `rendererFactory` (e.g. JSX), files stored in `driver.fileManager`\n * - `Array<FileNode>` → added directly into `driver.fileManager`\n * - `void` / `null` / `undefined` → no-op (plugin handled it via `this.upsertFile`)\n *\n * Pass a `rendererFactory` (e.g. `jsxRenderer` from `@kubb/renderer-jsx`) when the result\n * may be a renderer element. Generators that only return `Array<FileNode>` do not need one.\n */\nexport async function applyHookResult<TElement = unknown>(\n result: TElement | Array<FileNode> | void,\n driver: PluginDriver,\n rendererFactory?: RendererFactory<TElement>,\n): Promise<void> {\n if (!result) return\n\n if (Array.isArray(result)) {\n driver.fileManager.upsert(...(result as Array<FileNode>))\n return\n }\n\n if (!rendererFactory) {\n return\n }\n\n const renderer = rendererFactory()\n if (renderer.stream) {\n for await (const file of renderer.stream(result)) {\n driver.fileManager.upsert(file)\n }\n } else {\n await renderer.render(result)\n driver.fileManager.upsert(...renderer.files)\n }\n renderer.unmount()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;CAS9D,OARmB,KAChB,MAAM,CACN,QAAQ,qB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