@kubb/core 5.0.0-alpha.54 → 5.0.0-alpha.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PluginDriver-BGZHmzqu.cjs → PluginDriver-6bHJKAZ6.cjs} +14 -61
- package/dist/PluginDriver-6bHJKAZ6.cjs.map +1 -0
- package/dist/{PluginDriver-BU7faPiI.js → PluginDriver-Cn9cRX4m.js} +15 -50
- package/dist/PluginDriver-Cn9cRX4m.js.map +1 -0
- package/dist/index.cjs +38 -331
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +40 -333
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{types-CeLqzzAf.d.ts → types-BjL3cJ-T.d.ts} +227 -87
- package/package.json +4 -4
- package/src/FileManager.ts +10 -28
- package/src/Kubb.ts +50 -0
- package/src/PluginDriver.ts +7 -1
- package/src/constants.ts +0 -13
- package/src/createKubb.ts +23 -112
- package/src/defineMiddleware.ts +59 -0
- package/src/definePlugin.ts +10 -0
- package/src/index.ts +1 -0
- package/src/types.ts +62 -21
- package/dist/PluginDriver-BGZHmzqu.cjs.map +0 -1
- package/dist/PluginDriver-BU7faPiI.js.map +0 -1
- package/src/utils/TreeNode.ts +0 -253
- package/src/utils/getBarrelFiles.ts +0 -157
package/src/createKubb.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AsyncEventEmitter, BuildError, exists, formatMs, getElapsedMs,
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import { AsyncEventEmitter, BuildError, exists, formatMs, getElapsedMs, URLPath } from '@internals/utils'
|
|
3
|
+
import type { FileNode, OperationNode } from '@kubb/ast'
|
|
4
|
+
import { transform, walk } from '@kubb/ast'
|
|
5
|
+
import { DEFAULT_BANNER, DEFAULT_EXTENSION, DEFAULT_STUDIO_URL } from './constants.ts'
|
|
6
6
|
import type { RendererFactory } from './createRenderer.ts'
|
|
7
7
|
import type { Generator } from './defineGenerator.ts'
|
|
8
8
|
import type { Parser } from './defineParser.ts'
|
|
@@ -14,8 +14,6 @@ import { applyHookResult } from './renderNode.ts'
|
|
|
14
14
|
import { fsStorage } from './storages/fsStorage.ts'
|
|
15
15
|
import type { AdapterSource, Config, GeneratorContext, KubbHooks, NormalizedPlugin, Storage, UserConfig } from './types.ts'
|
|
16
16
|
import { getDiagnosticInfo } from './utils/diagnostics.ts'
|
|
17
|
-
import type { FileMetaBase } from './utils/getBarrelFiles.ts'
|
|
18
|
-
import { getBarrelFiles } from './utils/getBarrelFiles.ts'
|
|
19
17
|
import { isInputPath } from './utils/isInputPath.ts'
|
|
20
18
|
|
|
21
19
|
type SetupOptions = {
|
|
@@ -113,7 +111,6 @@ async function setup(userConfig: UserConfig, options: SetupOptions = {}): Promis
|
|
|
113
111
|
adapter: userConfig.adapter,
|
|
114
112
|
output: {
|
|
115
113
|
write: true,
|
|
116
|
-
barrelType: 'named',
|
|
117
114
|
extension: DEFAULT_EXTENSION,
|
|
118
115
|
defaultBanner: DEFAULT_BANNER,
|
|
119
116
|
...userConfig.output,
|
|
@@ -141,6 +138,13 @@ async function setup(userConfig: UserConfig, options: SetupOptions = {}): Promis
|
|
|
141
138
|
hooks,
|
|
142
139
|
})
|
|
143
140
|
|
|
141
|
+
// Install middleware listeners after all plugin hooks are registered.
|
|
142
|
+
// Because AsyncEventEmitter calls listeners in registration order,
|
|
143
|
+
// middleware hooks for any event fire after all plugin hooks for that event.
|
|
144
|
+
for (const middleware of config.middleware ?? []) {
|
|
145
|
+
middleware.install(hooks)
|
|
146
|
+
}
|
|
147
|
+
|
|
144
148
|
const adapter = config.adapter
|
|
145
149
|
if (!adapter) {
|
|
146
150
|
throw new Error('No adapter configured. Please provide an adapter in your kubb.config.ts.')
|
|
@@ -272,14 +276,16 @@ async function safeBuild(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
272
276
|
adapter: driver.adapter,
|
|
273
277
|
inputNode: driver.inputNode,
|
|
274
278
|
getPlugin: driver.getPlugin.bind(driver),
|
|
279
|
+
get files() {
|
|
280
|
+
return driver.fileManager.files
|
|
281
|
+
},
|
|
282
|
+
upsertFile: (...files) => driver.fileManager.upsert(...files),
|
|
275
283
|
})
|
|
276
284
|
}
|
|
277
285
|
|
|
278
286
|
for (const plugin of driver.plugins.values()) {
|
|
279
287
|
const context = driver.getContext(plugin)
|
|
280
288
|
const hrStart = process.hrtime()
|
|
281
|
-
const { output } = plugin.options ?? {}
|
|
282
|
-
const root = resolve(config.root, config.output.path)
|
|
283
289
|
|
|
284
290
|
try {
|
|
285
291
|
const timestamp = new Date()
|
|
@@ -295,16 +301,6 @@ async function safeBuild(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
295
301
|
await runPluginAstHooks(plugin, context)
|
|
296
302
|
}
|
|
297
303
|
|
|
298
|
-
if (output) {
|
|
299
|
-
const barrelFiles = await getBarrelFiles(driver.fileManager.files, {
|
|
300
|
-
type: output.barrelType ?? 'named',
|
|
301
|
-
root,
|
|
302
|
-
output,
|
|
303
|
-
meta: { pluginName: plugin.name },
|
|
304
|
-
})
|
|
305
|
-
await context.upsertFile(...barrelFiles)
|
|
306
|
-
}
|
|
307
|
-
|
|
308
304
|
const duration = getElapsedMs(hrStart)
|
|
309
305
|
pluginTimings.set(plugin.name, duration)
|
|
310
306
|
|
|
@@ -345,52 +341,13 @@ async function safeBuild(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
345
341
|
}
|
|
346
342
|
}
|
|
347
343
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
logs: ['Generating barrel file', ` • Type: ${config.output.barrelType}`, ` • Path: ${rootPath}`],
|
|
356
|
-
})
|
|
357
|
-
|
|
358
|
-
const barrelFiles = driver.fileManager.files.filter((file) => {
|
|
359
|
-
return file.sources.some((source) => source.isIndexable)
|
|
360
|
-
})
|
|
361
|
-
|
|
362
|
-
await hooks.emit('kubb:debug', {
|
|
363
|
-
date: new Date(),
|
|
364
|
-
logs: [`Found ${barrelFiles.length} indexable files for barrel export`],
|
|
365
|
-
})
|
|
366
|
-
|
|
367
|
-
const existingBarrel = driver.fileManager.files.find((f) => f.path === rootPath)
|
|
368
|
-
const existingExports = new Set(
|
|
369
|
-
existingBarrel?.exports?.flatMap((e) => (Array.isArray(e.name) ? e.name : [e.name])).filter((n): n is string => Boolean(n)) ?? [],
|
|
370
|
-
)
|
|
371
|
-
|
|
372
|
-
const rootFile = createFile<object>({
|
|
373
|
-
path: rootPath,
|
|
374
|
-
baseName: BARREL_FILENAME,
|
|
375
|
-
exports: buildBarrelExports({
|
|
376
|
-
barrelFiles,
|
|
377
|
-
rootDir,
|
|
378
|
-
existingExports,
|
|
379
|
-
config,
|
|
380
|
-
driver,
|
|
381
|
-
}).map((e) => createExport(e)),
|
|
382
|
-
sources: [],
|
|
383
|
-
imports: [],
|
|
384
|
-
meta: {},
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
driver.fileManager.upsert(rootFile)
|
|
388
|
-
|
|
389
|
-
await hooks.emit('kubb:debug', {
|
|
390
|
-
date: new Date(),
|
|
391
|
-
logs: [`✓ Generated barrel file (${rootFile.exports?.length || 0} exports)`],
|
|
392
|
-
})
|
|
393
|
-
}
|
|
344
|
+
await hooks.emit('kubb:plugins:end', {
|
|
345
|
+
config,
|
|
346
|
+
get files() {
|
|
347
|
+
return driver.fileManager.files
|
|
348
|
+
},
|
|
349
|
+
upsertFile: (...files) => driver.fileManager.upsert(...files),
|
|
350
|
+
})
|
|
394
351
|
|
|
395
352
|
const files = driver.fileManager.files
|
|
396
353
|
|
|
@@ -489,52 +446,6 @@ async function build(setupResult: SetupResult): Promise<BuildOutput> {
|
|
|
489
446
|
}
|
|
490
447
|
}
|
|
491
448
|
|
|
492
|
-
type BuildBarrelExportsParams = {
|
|
493
|
-
barrelFiles: FileNode[]
|
|
494
|
-
rootDir: string
|
|
495
|
-
existingExports: Set<string>
|
|
496
|
-
config: Config
|
|
497
|
-
driver: PluginDriver
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, driver }: BuildBarrelExportsParams): ExportNode[] {
|
|
501
|
-
const pluginNameMap = new Map<string, NormalizedPlugin>()
|
|
502
|
-
for (const plugin of driver.plugins.values()) {
|
|
503
|
-
pluginNameMap.set(plugin.name, plugin)
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
return barrelFiles.flatMap((file) => {
|
|
507
|
-
const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly)
|
|
508
|
-
|
|
509
|
-
return (file.sources ?? []).flatMap((source) => {
|
|
510
|
-
if (!file.path || !source.isIndexable) {
|
|
511
|
-
return []
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
const meta = file.meta as FileMetaBase | undefined
|
|
515
|
-
const plugin = meta?.pluginName ? pluginNameMap.get(meta.pluginName) : undefined
|
|
516
|
-
const pluginOptions = plugin?.options
|
|
517
|
-
|
|
518
|
-
if (!pluginOptions || pluginOptions.output?.barrelType === false) {
|
|
519
|
-
return []
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
const exportName = config.output.barrelType === 'all' ? undefined : source.name ? [source.name] : undefined
|
|
523
|
-
if (exportName?.some((n) => existingExports.has(n))) {
|
|
524
|
-
return []
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
return [
|
|
528
|
-
createExport({
|
|
529
|
-
name: exportName,
|
|
530
|
-
path: getRelativePath(rootDir, file.path),
|
|
531
|
-
isTypeOnly: config.output.barrelType === 'all' ? containsOnlyTypes : source.isTypeOnly,
|
|
532
|
-
}),
|
|
533
|
-
]
|
|
534
|
-
})
|
|
535
|
-
})
|
|
536
|
-
}
|
|
537
|
-
|
|
538
449
|
function inputToAdapterSource(config: Config): AdapterSource {
|
|
539
450
|
if (Array.isArray(config.input)) {
|
|
540
451
|
return {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AsyncEventEmitter } from '@internals/utils'
|
|
2
|
+
import type { KubbHooks } from './Kubb.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A middleware observes and post-processes the build output produced by plugins.
|
|
6
|
+
* It attaches listeners to the shared `hooks` emitter before the plugin execution loop
|
|
7
|
+
* begins and reacts to lifecycle events (e.g. `kubb:plugin:end`, `kubb:build:end`) to
|
|
8
|
+
* inject barrel files or perform other cross-cutting concerns.
|
|
9
|
+
*
|
|
10
|
+
* Middleware listeners are always registered **after** all plugin listeners, because
|
|
11
|
+
* `createKubb` installs middleware only after the `PluginDriver` has registered every
|
|
12
|
+
* plugin's hooks. This means middleware hooks for any event always fire last.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { defineMiddleware } from '@kubb/core'
|
|
17
|
+
*
|
|
18
|
+
* export const myMiddleware = defineMiddleware({
|
|
19
|
+
* name: 'my-middleware',
|
|
20
|
+
* install(hooks) {
|
|
21
|
+
* hooks.on('kubb:build:end', ({ files }) => {
|
|
22
|
+
* console.log(`Build complete with ${files.length} files`)
|
|
23
|
+
* })
|
|
24
|
+
* },
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export type Middleware = {
|
|
29
|
+
/**
|
|
30
|
+
* Unique identifier for this middleware.
|
|
31
|
+
*/
|
|
32
|
+
name: string
|
|
33
|
+
/**
|
|
34
|
+
* Called during `createKubb` after `setup()` but before the plugin
|
|
35
|
+
* execution loop starts. Attach listeners to `hooks` here.
|
|
36
|
+
*/
|
|
37
|
+
install(hooks: AsyncEventEmitter<KubbHooks>): void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Identity factory for middleware.
|
|
42
|
+
* Returns the middleware object unchanged but provides a typed entry-point
|
|
43
|
+
* to define middleware with proper inference.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* export const myMiddleware = defineMiddleware({
|
|
48
|
+
* name: 'my-middleware',
|
|
49
|
+
* install(hooks) {
|
|
50
|
+
* hooks.on('kubb:build:end', ({ files }) => {
|
|
51
|
+
* console.log(`Build complete with ${files.length} files`)
|
|
52
|
+
* })
|
|
53
|
+
* },
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function defineMiddleware(middleware: Middleware): Middleware {
|
|
58
|
+
return middleware
|
|
59
|
+
}
|
package/src/definePlugin.ts
CHANGED
|
@@ -18,6 +18,16 @@ export type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
18
18
|
* An error is thrown at startup when any listed dependency is missing.
|
|
19
19
|
*/
|
|
20
20
|
dependencies?: Array<string>
|
|
21
|
+
/**
|
|
22
|
+
* Controls the execution order of this plugin relative to others.
|
|
23
|
+
*
|
|
24
|
+
* - `'pre'` — runs before all normal plugins.
|
|
25
|
+
* - `'post'` — runs after all normal plugins.
|
|
26
|
+
* - `undefined` (default) — runs in declaration order among normal plugins.
|
|
27
|
+
*
|
|
28
|
+
* Dependency constraints always take precedence over `enforce`.
|
|
29
|
+
*/
|
|
30
|
+
enforce?: 'pre' | 'post'
|
|
21
31
|
/**
|
|
22
32
|
* The options passed by the user when calling the plugin factory.
|
|
23
33
|
*/
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { createRenderer } from './createRenderer.ts'
|
|
|
7
7
|
export { createStorage } from './createStorage.ts'
|
|
8
8
|
export { defineGenerator } from './defineGenerator.ts'
|
|
9
9
|
export { defineLogger } from './defineLogger.ts'
|
|
10
|
+
export { defineMiddleware } from './defineMiddleware.ts'
|
|
10
11
|
export { defineParser } from './defineParser.ts'
|
|
11
12
|
export { definePlugin } from './definePlugin.ts'
|
|
12
13
|
export { defineResolver } from './defineResolver.ts'
|
package/src/types.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { DEFAULT_STUDIO_URL, logLevel } from './constants.ts'
|
|
|
4
4
|
import type { RendererFactory } from './createRenderer.ts'
|
|
5
5
|
import type { Storage } from './createStorage.ts'
|
|
6
6
|
import type { Generator } from './defineGenerator.ts'
|
|
7
|
+
import type { Middleware } from './defineMiddleware.ts'
|
|
7
8
|
import type { Parser } from './defineParser.ts'
|
|
8
9
|
import type { Plugin } from './definePlugin.ts'
|
|
9
10
|
import type { KubbHooks } from './Kubb.ts'
|
|
@@ -11,6 +12,16 @@ import type { PluginDriver } from './PluginDriver.ts'
|
|
|
11
12
|
|
|
12
13
|
export type { Renderer, RendererFactory } from './createRenderer.ts'
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Safely extracts the type of key `K` from `T`, returning `{}` when `K` is not a key of `T`.
|
|
17
|
+
* Used to implement optional interface augmentation for `Kubb.ConfigOptionsRegistry` and
|
|
18
|
+
* `Kubb.PluginOptionsRegistry` so that middleware and plugin packages can extend core types
|
|
19
|
+
* without requiring modifications to core.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
type ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {}
|
|
24
|
+
|
|
14
25
|
export type InputPath = {
|
|
15
26
|
/**
|
|
16
27
|
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
@@ -101,14 +112,6 @@ export type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptio
|
|
|
101
112
|
getImports: (node: SchemaNode, resolve: (schemaName: string) => { name: string; path: string }) => Array<ImportNode>
|
|
102
113
|
}
|
|
103
114
|
|
|
104
|
-
/**
|
|
105
|
-
* Controls how `index.ts` barrel files are generated.
|
|
106
|
-
* - `'all'` — exports every generated symbol from every file.
|
|
107
|
-
* - `'named'` — exports only explicitly named exports.
|
|
108
|
-
* - `'propagate'` — propagates re-exports from nested barrel files upward.
|
|
109
|
-
*/
|
|
110
|
-
export type BarrelType = 'all' | 'named' | 'propagate'
|
|
111
|
-
|
|
112
115
|
export type DevtoolsOptions = {
|
|
113
116
|
/**
|
|
114
117
|
* Open the AST inspector view (`/ast`) in Kubb Studio.
|
|
@@ -225,11 +228,6 @@ export type Config<TInput = Input> = {
|
|
|
225
228
|
* @default { '.ts': '.ts'}
|
|
226
229
|
*/
|
|
227
230
|
extension?: Record<FileNode['extname'], FileNode['extname'] | ''>
|
|
228
|
-
/**
|
|
229
|
-
* Configures how `index.ts` files are created, including disabling barrel file generation. Each plugin has its own `barrelType` option; this setting controls the root barrel file (e.g., `src/gen/index.ts`).
|
|
230
|
-
* @default 'named'
|
|
231
|
-
*/
|
|
232
|
-
barrelType?: 'all' | 'named' | false
|
|
233
231
|
/**
|
|
234
232
|
* Adds a default banner to the start of every generated file indicating it was generated by Kubb.
|
|
235
233
|
* - 'simple' adds banner with link to Kubb.
|
|
@@ -245,7 +243,7 @@ export type Config<TInput = Input> = {
|
|
|
245
243
|
* @default false
|
|
246
244
|
*/
|
|
247
245
|
override?: boolean
|
|
248
|
-
}
|
|
246
|
+
} & ExtractRegistryKey<Kubb.ConfigOptionsRegistry, 'output'>
|
|
249
247
|
/**
|
|
250
248
|
* An array of Kubb plugins used for code generation.
|
|
251
249
|
* Each plugin may declare additional configurable options.
|
|
@@ -253,6 +251,22 @@ export type Config<TInput = Input> = {
|
|
|
253
251
|
* Use `dependencies` on the plugin to declare execution order.
|
|
254
252
|
*/
|
|
255
253
|
plugins: Array<Plugin>
|
|
254
|
+
/**
|
|
255
|
+
* Middleware instances that observe and post-process the build output.
|
|
256
|
+
* Each middleware receives the `hooks` emitter and attaches its own listeners.
|
|
257
|
+
* Middleware listeners are always registered after all plugin listeners,
|
|
258
|
+
* so middleware hooks fire last for any given event.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* import { middlewareBarrel } from '@kubb/middleware-barrel'
|
|
263
|
+
* export default defineConfig({
|
|
264
|
+
* middleware: [middlewareBarrel],
|
|
265
|
+
* plugins: [pluginTs(), pluginZod()],
|
|
266
|
+
* })
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
middleware?: Array<Middleware>
|
|
256
270
|
/**
|
|
257
271
|
* Project-wide renderer factory. All plugins and generators that do not declare their own
|
|
258
272
|
* `renderer` ultimately fall back to this value.
|
|
@@ -538,11 +552,6 @@ export type Output<_TOptions = unknown> = {
|
|
|
538
552
|
* Path to the output folder or file that will contain generated code.
|
|
539
553
|
*/
|
|
540
554
|
path: string
|
|
541
|
-
/**
|
|
542
|
-
* Define what needs to be exported, here you can also disable the export of barrel files
|
|
543
|
-
* @default 'named'
|
|
544
|
-
*/
|
|
545
|
-
barrelType?: BarrelType | false
|
|
546
555
|
/**
|
|
547
556
|
* Text or function appended at the start of every generated file.
|
|
548
557
|
* When a function, receives the current `InputNode` and must return a string.
|
|
@@ -558,7 +567,7 @@ export type Output<_TOptions = unknown> = {
|
|
|
558
567
|
* @default false
|
|
559
568
|
*/
|
|
560
569
|
override?: boolean
|
|
561
|
-
}
|
|
570
|
+
} & ExtractRegistryKey<Kubb.PluginOptionsRegistry, 'output'>
|
|
562
571
|
|
|
563
572
|
export type Group = {
|
|
564
573
|
/**
|
|
@@ -595,6 +604,7 @@ export type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Logger<
|
|
|
595
604
|
|
|
596
605
|
export type { Storage } from './createStorage.ts'
|
|
597
606
|
export type { Generator } from './defineGenerator.ts'
|
|
607
|
+
export type { Middleware } from './defineMiddleware.ts'
|
|
598
608
|
export type { Plugin } from './definePlugin.ts'
|
|
599
609
|
export type { Kubb, KubbHooks } from './Kubb.ts'
|
|
600
610
|
|
|
@@ -671,6 +681,38 @@ export type KubbBuildStartContext = {
|
|
|
671
681
|
*/
|
|
672
682
|
getPlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined
|
|
673
683
|
getPlugin(name: string): Plugin | undefined
|
|
684
|
+
/**
|
|
685
|
+
* Returns all files currently in the file manager.
|
|
686
|
+
* Call this lazily (e.g. inside a `kubb:plugin:end` listener) to see files added by plugins
|
|
687
|
+
* that have already run.
|
|
688
|
+
*/
|
|
689
|
+
readonly files: ReadonlyArray<FileNode>
|
|
690
|
+
/**
|
|
691
|
+
* Upsert one or more files into the file manager.
|
|
692
|
+
* Files with the same path are merged; new files are appended.
|
|
693
|
+
* Safe to call at any point during the plugin lifecycle, including inside `kubb:plugin:end`.
|
|
694
|
+
*/
|
|
695
|
+
upsertFile: (...files: Array<FileNode>) => void
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Context passed to `kubb:plugins:end` handlers.
|
|
700
|
+
* Fires after all plugins have run and per-plugin barrels have been written,
|
|
701
|
+
* but BEFORE files are written to disk.
|
|
702
|
+
* Middleware that needs to inject final files (e.g. a root barrel) should use this event.
|
|
703
|
+
*/
|
|
704
|
+
export type KubbPluginsEndContext = {
|
|
705
|
+
config: Config
|
|
706
|
+
/**
|
|
707
|
+
* Returns all files currently in the file manager (lazy snapshot).
|
|
708
|
+
* Includes files added by plugins and per-plugin barrel middleware.
|
|
709
|
+
*/
|
|
710
|
+
readonly files: ReadonlyArray<FileNode>
|
|
711
|
+
/**
|
|
712
|
+
* Upsert one or more files into the file manager.
|
|
713
|
+
* Files added here will be included in the write pass that follows.
|
|
714
|
+
*/
|
|
715
|
+
upsertFile: (...files: Array<FileNode>) => void
|
|
674
716
|
}
|
|
675
717
|
|
|
676
718
|
/**
|
|
@@ -988,4 +1030,3 @@ export type PossibleConfig<TCliOptions = undefined> =
|
|
|
988
1030
|
|
|
989
1031
|
export type { BuildOutput } from './createKubb.ts'
|
|
990
1032
|
export type { Parser } from './defineParser.ts'
|
|
991
|
-
export type { FileMetaBase } from './utils/getBarrelFiles.ts'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginDriver-BGZHmzqu.cjs","names":["path","#cache","#filesCache","#pluginsWithEventGenerators","#resolvers","#defaultResolvers","#hookListeners","#normalizePlugin","#trackHookListener","#createDefaultResolver","#studioIsOpen","openInStudioFn"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/string.ts","../src/constants.ts","../src/defineResolver.ts","../src/devtools.ts","../src/FileManager.ts","../src/renderNode.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","/**\n * Returns a masked version of a string, showing only the first and last few characters.\n * Useful for logging sensitive values (tokens, keys) without exposing the full value.\n *\n * @example\n * maskString('KUBB_STUDIO-abc123-xyz789') // 'KUBB_STUDIO-…789'\n */\nexport function maskString(value: string, start = 8, end = 4): string {\n if (value.length <= start + end) return value\n return `${value.slice(0, start)}…${value.slice(-end)}`\n}\n\n/**\n * Strips the file extension from a path or file name.\n * Only removes the last `.ext` segment when the dot is not part of a directory name.\n *\n * @example\n * trimExtName('petStore.ts') // 'petStore'\n * trimExtName('/src/models/pet.ts') // '/src/models/pet'\n * trimExtName('/project.v2/gen/pet.ts') // '/project.v2/gen/pet'\n * trimExtName('noExtension') // 'noExtension'\n */\nexport function trimExtName(text: string): string {\n const dotIndex = text.lastIndexOf('.')\n if (dotIndex > 0 && !text.includes('/', dotIndex)) {\n return text.slice(0, dotIndex)\n }\n return text\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://studio.kubb.dev' as const\n\n/**\n * Default number of plugins that may run concurrently during a build.\n */\nexport const DEFAULT_CONCURRENCY = 15\n\n/**\n * Maximum number of files processed in parallel by FileProcessor.\n */\nexport const PARALLEL_CONCURRENCY_LIMIT = 100\n\n/**\n * Basename (without extension) of generated barrel files.\n *\n * Used to detect whether a path already points at a barrel so the generator\n * avoids re-creating one on top of it.\n */\nexport const BARREL_BASENAME = 'index' as const\n\n/**\n * File name used for generated barrel (index) files.\n */\nexport const BARREL_FILENAME = `${BARREL_BASENAME}.ts` 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 * Characters recognized as path separators on both POSIX and Windows.\n */\nexport const PATH_SEPARATORS = new Set(['/', '\\\\'] as const)\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 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 { PluginDriver } from './PluginDriver.ts'\nimport type {\n Config,\n PluginFactoryOptions,\n ResolveBannerContext,\n ResolveOptionsContext,\n Resolver,\n ResolverContext,\n ResolverFileParams,\n ResolverPathParams,\n} from './types.ts'\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 * The builder receives `ctx` — a reference to the fully assembled resolver — so methods can\n * call sibling resolver methods without using `this`. Because `ctx` is captured by the closure\n * and the resolver is populated after the builder runs, `ctx` correctly reflects any overrides\n * that were applied by the builder itself.\n */\ntype ResolverBuilder<T extends PluginFactoryOptions> = (ctx: T['resolver']) => 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 }\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 ?? PluginDriver.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(\n * { name: 'pet', extname: '.ts' },\n * { root: '/src', output: { path: 'types' } },\n * resolver,\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(\n * { name: 'listPets', extname: '.ts', tag: 'pets' },\n * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },\n * resolver,\n * )\n * // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }\n * ```\n */\nexport function defaultResolveFile({ name, extname, tag, path: groupPath }: ResolverFileParams, context: ResolverContext, ctx: Resolver): FileNode {\n const pathMode = PluginDriver.getMode(path.resolve(context.root, context.output.path))\n const resolvedName = pathMode === 'single' ? '' : ctx.default(name, 'file')\n const baseName = `${resolvedName}${extname}` as FileNode['baseName']\n const filePath = ctx.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: ctx.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 ('path' in config.input) {\n source = path.basename(config.input.path)\n } else if ('data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n 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 * The builder receives `ctx` — a reference to the assembled resolver — so methods can\n * call sibling resolver methods using `ctx` instead of `this`.\n *\n * @example Basic resolver with naming helpers\n * ```ts\n * export const resolver = defineResolver<PluginTs>((ctx) => ({\n * name: 'default',\n * resolveName(node) {\n * return ctx.default(node.name, 'function')\n * },\n * resolveTypedName(node) {\n * return ctx.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>((_ctx) => ({\n * name: 'custom',\n * resolvePath({ baseName }, { root, output }) {\n * return path.resolve(root, output.path, 'generated', baseName)\n * },\n * }))\n * ```\n *\n * @example Use ctx.default inside a helper\n * ```ts\n * export const resolver = defineResolver<PluginTs>((ctx) => ({\n * name: 'default',\n * resolveParamName(node, param) {\n * return ctx.default(`${node.operationId} ${param.in} ${param.name}`, 'type')\n * },\n * }))\n * ```\n */\nexport function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'] {\n // Create the resolver shell first. When `build(resolver)` executes below, `resolver` is\n // still empty, but methods returned by the builder capture it by reference. By the time\n // those methods are actually called, `Object.assign` will have already populated all\n // properties (including any overrides from the builder itself).\n const resolver = {} as T['resolver']\n\n Object.assign(resolver, {\n default: defaultResolver,\n resolveOptions: defaultResolveOptions,\n resolvePath: defaultResolvePath,\n // Wire the default resolveFile implementation with a wrapper that passes resolver as ctx.\n // Unlike other defaults which can be assigned directly, defaultResolveFile requires the\n // resolver as its third parameter.\n resolveFile: (params: ResolverFileParams, context: ResolverContext) => defaultResolveFile(params, context, resolver as Resolver),\n resolveBanner: defaultResolveBanner,\n resolveFooter: defaultResolveFooter,\n // Builder overrides are applied last. Any method in the builder can call\n // ctx.xxx() and will see the fully merged resolver (including its own overrides).\n ...build(resolver),\n })\n\n return resolver\n}\n","import type { InputNode } from '@kubb/ast'\nimport { deflateSync, inflateSync } from 'fflate'\nimport { x } from 'tinyexec'\nimport type { DevtoolsOptions } from './types.ts'\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 { trimExtName } from '@internals/utils'\nimport type { FileNode } from '@kubb/ast'\nimport { createFile } from '@kubb/ast'\nimport { BARREL_BASENAME } from './constants.ts'\n\nfunction mergeFile<TMeta extends object = object>(a: FileNode<TMeta>, b: FileNode<TMeta>): FileNode<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\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. Files with the same path are merged — sources, imports,\n * and exports from all calls with the same path are concatenated together.\n */\n add(...files: Array<FileNode>): Array<FileNode> {\n const resolvedFiles: Array<FileNode> = []\n const mergedFiles = new Map<string, FileNode>()\n\n for (const file of files) {\n const existing = mergedFiles.get(file.path)\n mergedFiles.set(file.path, existing ? mergeFile(existing, file) : file)\n }\n\n for (const file of mergedFiles.values()) {\n const resolvedFile = createFile(file)\n this.#cache.set(resolvedFile.path, resolvedFile)\n resolvedFiles.push(resolvedFile)\n }\n this.#filesCache = null\n\n return resolvedFiles\n }\n\n /**\n * Adds or merges one or more files.\n * If a file with the same path already exists, its sources/imports/exports are merged together.\n */\n upsert(...files: Array<FileNode>): Array<FileNode> {\n const resolvedFiles: Array<FileNode> = []\n const mergedFiles = new Map<string, FileNode>()\n\n for (const file of files) {\n const existing = mergedFiles.get(file.path)\n mergedFiles.set(file.path, existing ? mergeFile(existing, file) : file)\n }\n\n for (const file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n this.#cache.set(resolvedFile.path, resolvedFile)\n resolvedFiles.push(resolvedFile)\n }\n this.#filesCache = null\n\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 * All stored files, sorted by path length (shorter paths first).\n * Barrel/index files (e.g. index.ts) are sorted last within each length bucket.\n */\n get files(): Array<FileNode> {\n if (this.#filesCache) {\n return this.#filesCache\n }\n\n // Precompute the barrel-file flag per key so the comparator avoids repeated string work.\n const keys = [...this.#cache.keys()]\n const meta = new Map<string, { length: number; isIndex: boolean }>()\n for (const key of keys) {\n meta.set(key, {\n length: key.length,\n isIndex: trimExtName(key).endsWith(BARREL_BASENAME),\n })\n }\n keys.sort((a, b) => {\n const ma = meta.get(a)!\n const mb = meta.get(b)!\n if (ma.length !== mb.length) return ma.length - mb.length\n if (ma.isIndex !== mb.isIndex) return ma.isIndex ? 1 : -1\n return 0\n })\n\n const files: Array<FileNode> = []\n for (const key of keys) {\n const file = this.#cache.get(key)\n if (file) {\n files.push(file)\n }\n }\n\n this.#filesCache = files\n return files\n }\n}\n","import type { FileNode } from '@kubb/ast'\nimport type { RendererFactory } from './createRenderer.ts'\nimport type { PluginDriver } from './PluginDriver.ts'\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 await renderer.render(result)\n driver.fileManager.upsert(...renderer.files)\n renderer.unmount()\n}\n","import { extname, resolve } from 'node:path'\nimport type { AsyncEventEmitter } from '@internals/utils'\nimport type { FileNode, InputNode, 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 { defineResolver } from './defineResolver.ts'\nimport { openInStudio as openInStudioFn } from './devtools.ts'\nimport { FileManager } from './FileManager.ts'\nimport { applyHookResult } from './renderNode.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\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 if (!fileOrFolder) {\n return 'split'\n }\n return extname(fileOrFolder) ? 'single' : 'split'\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 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 return 0\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 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 // 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: ({ sources = [], ...rest }) => {\n this.fileManager.add(createFile({ imports: [], exports: [], sources, ...rest }))\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 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 }\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>((_ctx) => ({\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 | undefined {\n return driver.inputNode\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAAQ,CAEV,MAAM,gBAAgB,CAAC,OAAO,QAAQ,CAG5D,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;;;;;;;;;;AAiBjC,SAAS,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