@kubb/core 5.0.0-alpha.4 → 5.0.0-alpha.41

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.
Files changed (71) hide show
  1. package/dist/PluginDriver-BQwm8hDd.cjs +1729 -0
  2. package/dist/PluginDriver-BQwm8hDd.cjs.map +1 -0
  3. package/dist/PluginDriver-CgXFtmNP.js +1617 -0
  4. package/dist/PluginDriver-CgXFtmNP.js.map +1 -0
  5. package/dist/index.cjs +915 -1901
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +268 -264
  8. package/dist/index.js +894 -1863
  9. package/dist/index.js.map +1 -1
  10. package/dist/mocks.cjs +164 -0
  11. package/dist/mocks.cjs.map +1 -0
  12. package/dist/mocks.d.ts +74 -0
  13. package/dist/mocks.js +159 -0
  14. package/dist/mocks.js.map +1 -0
  15. package/dist/types-C6NCtNqM.d.ts +2151 -0
  16. package/package.json +11 -14
  17. package/src/FileManager.ts +131 -0
  18. package/src/FileProcessor.ts +84 -0
  19. package/src/Kubb.ts +174 -85
  20. package/src/PluginDriver.ts +941 -0
  21. package/src/constants.ts +33 -43
  22. package/src/createAdapter.ts +25 -0
  23. package/src/createKubb.ts +605 -0
  24. package/src/createPlugin.ts +31 -0
  25. package/src/createRenderer.ts +57 -0
  26. package/src/createStorage.ts +58 -0
  27. package/src/defineGenerator.ts +88 -100
  28. package/src/defineLogger.ts +13 -3
  29. package/src/defineParser.ts +45 -0
  30. package/src/definePlugin.ts +90 -7
  31. package/src/defineResolver.ts +453 -0
  32. package/src/devtools.ts +14 -14
  33. package/src/index.ts +12 -17
  34. package/src/mocks.ts +234 -0
  35. package/src/renderNode.ts +35 -0
  36. package/src/storages/fsStorage.ts +29 -9
  37. package/src/storages/memoryStorage.ts +2 -2
  38. package/src/types.ts +821 -152
  39. package/src/utils/TreeNode.ts +47 -9
  40. package/src/utils/diagnostics.ts +4 -1
  41. package/src/utils/executeStrategies.ts +16 -13
  42. package/src/utils/getBarrelFiles.ts +88 -15
  43. package/src/utils/isInputPath.ts +10 -0
  44. package/src/utils/packageJSON.ts +75 -0
  45. package/dist/chunk-ByKO4r7w.cjs +0 -38
  46. package/dist/hooks.cjs +0 -50
  47. package/dist/hooks.cjs.map +0 -1
  48. package/dist/hooks.d.ts +0 -49
  49. package/dist/hooks.js +0 -46
  50. package/dist/hooks.js.map +0 -1
  51. package/dist/types-Bbh1o0yW.d.ts +0 -1057
  52. package/src/BarrelManager.ts +0 -74
  53. package/src/PackageManager.ts +0 -180
  54. package/src/PluginManager.ts +0 -668
  55. package/src/PromiseManager.ts +0 -40
  56. package/src/build.ts +0 -420
  57. package/src/config.ts +0 -56
  58. package/src/defineAdapter.ts +0 -22
  59. package/src/defineStorage.ts +0 -56
  60. package/src/errors.ts +0 -1
  61. package/src/hooks/index.ts +0 -8
  62. package/src/hooks/useKubb.ts +0 -22
  63. package/src/hooks/useMode.ts +0 -11
  64. package/src/hooks/usePlugin.ts +0 -11
  65. package/src/hooks/usePluginManager.ts +0 -11
  66. package/src/utils/FunctionParams.ts +0 -155
  67. package/src/utils/formatters.ts +0 -56
  68. package/src/utils/getConfigs.ts +0 -30
  69. package/src/utils/getPlugins.ts +0 -23
  70. package/src/utils/linters.ts +0 -25
  71. package/src/utils/resolveOptions.ts +0 -93
@@ -0,0 +1,453 @@
1
+ import path from 'node:path'
2
+ import { camelCase, pascalCase } from '@internals/utils'
3
+ import type { FileNode, InputNode, Node, OperationNode, SchemaNode } from '@kubb/ast'
4
+ import { createFile, isOperationNode, isSchemaNode } from '@kubb/ast'
5
+ import { PluginDriver } from './PluginDriver.ts'
6
+ import type {
7
+ Config,
8
+ PluginFactoryOptions,
9
+ ResolveBannerContext,
10
+ ResolveNameParams,
11
+ ResolveOptionsContext,
12
+ Resolver,
13
+ ResolverContext,
14
+ ResolverFileParams,
15
+ ResolverPathParams,
16
+ } from './types.ts'
17
+
18
+ /**
19
+ * Builder type for the plugin-specific resolver fields.
20
+ *
21
+ * `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
22
+ * are optional — built-in fallbacks are injected when omitted.
23
+ */
24
+ type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<
25
+ T['resolver'],
26
+ 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter' | 'name' | 'pluginName'
27
+ > &
28
+ Partial<Pick<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>> & {
29
+ name: string
30
+ pluginName: T['name']
31
+ } & ThisType<T['resolver']>
32
+
33
+ /**
34
+ * Checks if an operation matches a pattern for a given filter type (`tag`, `operationId`, `path`, `method`).
35
+ */
36
+ function matchesOperationPattern(node: OperationNode, type: string, pattern: string | RegExp): boolean {
37
+ switch (type) {
38
+ case 'tag':
39
+ return node.tags.some((tag) => !!tag.match(pattern))
40
+ case 'operationId':
41
+ return !!node.operationId.match(pattern)
42
+ case 'path':
43
+ return !!node.path.match(pattern)
44
+ case 'method':
45
+ return !!(node.method.toLowerCase() as string).match(pattern)
46
+ case 'contentType':
47
+ return !!node.requestBody?.contentType?.match(pattern)
48
+ default:
49
+ return false
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Checks if a schema matches a pattern for a given filter type (`schemaName`).
55
+ *
56
+ * Returns `null` when the filter type doesn't apply to schemas.
57
+ */
58
+ function matchesSchemaPattern(node: SchemaNode, type: string, pattern: string | RegExp): boolean | null {
59
+ switch (type) {
60
+ case 'schemaName':
61
+ return node.name ? !!node.name.match(pattern) : false
62
+ default:
63
+ return null
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Default name resolver used by `defineResolver`.
69
+ *
70
+ * - `camelCase` for `function` and `file` types.
71
+ * - `PascalCase` for `type`.
72
+ * - `camelCase` for everything else.
73
+ */
74
+ function defaultResolver(name: ResolveNameParams['name'], type: ResolveNameParams['type']): string {
75
+ let resolvedName = camelCase(name)
76
+
77
+ if (type === 'file' || type === 'function') {
78
+ resolvedName = camelCase(name, {
79
+ isFile: type === 'file',
80
+ })
81
+ }
82
+
83
+ if (type === 'type') {
84
+ resolvedName = pascalCase(name)
85
+ }
86
+
87
+ return resolvedName
88
+ }
89
+
90
+ /**
91
+ * Default option resolver — applies include/exclude filters and merges matching override options.
92
+ *
93
+ * Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.
94
+ *
95
+ * @example Include/exclude filtering
96
+ * ```ts
97
+ * const options = defaultResolveOptions(operationNode, {
98
+ * options: { output: 'types' },
99
+ * exclude: [{ type: 'tag', pattern: 'internal' }],
100
+ * })
101
+ * // → null when node has tag 'internal'
102
+ * ```
103
+ *
104
+ * @example Override merging
105
+ * ```ts
106
+ * const options = defaultResolveOptions(operationNode, {
107
+ * options: { enumType: 'asConst' },
108
+ * override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],
109
+ * })
110
+ * // → { enumType: 'enum' } when operationId matches
111
+ * ```
112
+ */
113
+ export function defaultResolveOptions<TOptions>(
114
+ node: Node,
115
+ { options, exclude = [], include, override = [] }: ResolveOptionsContext<TOptions>,
116
+ ): TOptions | null {
117
+ if (isOperationNode(node)) {
118
+ const isExcluded = exclude.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))
119
+ if (isExcluded) {
120
+ return null
121
+ }
122
+
123
+ if (include && !include.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) {
124
+ return null
125
+ }
126
+
127
+ const overrideOptions = override.find(({ type, pattern }) => matchesOperationPattern(node, type, pattern))?.options
128
+
129
+ return { ...options, ...overrideOptions }
130
+ }
131
+
132
+ if (isSchemaNode(node)) {
133
+ if (exclude.some(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)) {
134
+ return null
135
+ }
136
+
137
+ if (include) {
138
+ const results = include.map(({ type, pattern }) => matchesSchemaPattern(node, type, pattern))
139
+ const applicable = results.filter((r) => r !== null)
140
+ if (applicable.length > 0 && !applicable.includes(true)) {
141
+ return null
142
+ }
143
+ }
144
+
145
+ const overrideOptions = override.find(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)?.options
146
+
147
+ return { ...options, ...overrideOptions }
148
+ }
149
+
150
+ return options
151
+ }
152
+
153
+ /**
154
+ * Default path resolver used by `defineResolver`.
155
+ *
156
+ * - Returns the output directory in `single` mode.
157
+ * - Resolves into a tag- or path-based subdirectory when `group` and a `tag`/`path` value are provided.
158
+ * - Falls back to a flat `output/baseName` path otherwise.
159
+ *
160
+ * A custom `group.name` function overrides the default subdirectory naming.
161
+ * For `tag` groups the default is `${camelCase(tag)}Controller`.
162
+ * For `path` groups the default is the first path segment after `/`.
163
+ *
164
+ * @example Flat output
165
+ * ```ts
166
+ * defaultResolvePath({ baseName: 'petTypes.ts' }, { root: '/src', output: { path: 'types' } })
167
+ * // → '/src/types/petTypes.ts'
168
+ * ```
169
+ *
170
+ * @example Tag-based grouping
171
+ * ```ts
172
+ * defaultResolvePath(
173
+ * { baseName: 'petTypes.ts', tag: 'pets' },
174
+ * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
175
+ * )
176
+ * // → '/src/types/petsController/petTypes.ts'
177
+ * ```
178
+ *
179
+ * @example Path-based grouping
180
+ * ```ts
181
+ * defaultResolvePath(
182
+ * { baseName: 'petTypes.ts', path: '/pets/list' },
183
+ * { root: '/src', output: { path: 'types' }, group: { type: 'path' } },
184
+ * )
185
+ * // → '/src/types/pets/petTypes.ts'
186
+ * ```
187
+ *
188
+ * @example Single-file mode
189
+ * ```ts
190
+ * defaultResolvePath(
191
+ * { baseName: 'petTypes.ts', pathMode: 'single' },
192
+ * { root: '/src', output: { path: 'types' } },
193
+ * )
194
+ * // → '/src/types'
195
+ * ```
196
+ */
197
+ export function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }: ResolverPathParams, { root, output, group }: ResolverContext): string {
198
+ const mode = pathMode ?? PluginDriver.getMode(path.resolve(root, output.path))
199
+
200
+ if (mode === 'single') {
201
+ return path.resolve(root, output.path)
202
+ }
203
+
204
+ if (group && (groupPath || tag)) {
205
+ return path.resolve(root, output.path, group.name({ group: group.type === 'path' ? groupPath! : tag! }), baseName)
206
+ }
207
+
208
+ return path.resolve(root, output.path, baseName)
209
+ }
210
+
211
+ /**
212
+ * Default file resolver used by `defineResolver`.
213
+ *
214
+ * Resolves a `FileNode` by combining name resolution (`resolver.default`) with
215
+ * path resolution (`resolver.resolvePath`). The resolved file always has empty
216
+ * `sources`, `imports`, and `exports` arrays — consumers populate those separately.
217
+ *
218
+ * In `single` mode the name is omitted and the file sits directly in the output directory.
219
+ *
220
+ * @example Resolve a schema file
221
+ * ```ts
222
+ * const file = defaultResolveFile.call(resolver,
223
+ * { name: 'pet', extname: '.ts' },
224
+ * { root: '/src', output: { path: 'types' } },
225
+ * )
226
+ * // → { baseName: 'pet.ts', path: '/src/types/pet.ts', sources: [], ... }
227
+ * ```
228
+ *
229
+ * @example Resolve an operation file with tag grouping
230
+ * ```ts
231
+ * const file = defaultResolveFile.call(resolver,
232
+ * { name: 'listPets', extname: '.ts', tag: 'pets' },
233
+ * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
234
+ * )
235
+ * // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }
236
+ * ```
237
+ */
238
+ export function defaultResolveFile(this: Resolver, { name, extname, tag, path: groupPath }: ResolverFileParams, context: ResolverContext): FileNode {
239
+ const pathMode = PluginDriver.getMode(path.resolve(context.root, context.output.path))
240
+ const resolvedName = pathMode === 'single' ? '' : this.default(name, 'file')
241
+ const baseName = `${resolvedName}${extname}` as FileNode['baseName']
242
+ const filePath = this.resolvePath({ baseName, pathMode, tag, path: groupPath }, context)
243
+
244
+ return createFile({
245
+ path: filePath,
246
+ baseName: path.basename(filePath) as `${string}.${string}`,
247
+ meta: {
248
+ pluginName: this.pluginName,
249
+ },
250
+ sources: [],
251
+ imports: [],
252
+ exports: [],
253
+ })
254
+ }
255
+
256
+ /**
257
+ * Generates the default "Generated by Kubb" banner from config and optional node metadata.
258
+ */
259
+ export function buildDefaultBanner({
260
+ title,
261
+ description,
262
+ version,
263
+ config,
264
+ }: {
265
+ title?: string
266
+ description?: string
267
+ version?: string
268
+ config: Config
269
+ }): string {
270
+ try {
271
+ let source = ''
272
+ if (Array.isArray(config.input)) {
273
+ const first = config.input[0]
274
+ if (first && 'path' in first) {
275
+ source = path.basename(first.path)
276
+ }
277
+ } else if ('path' in config.input) {
278
+ source = path.basename(config.input.path)
279
+ } else if ('data' in config.input) {
280
+ source = 'text content'
281
+ }
282
+
283
+ let banner = '/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n'
284
+
285
+ if (config.output.defaultBanner === 'simple') {
286
+ banner += '*/\n'
287
+ return banner
288
+ }
289
+
290
+ if (source) {
291
+ banner += `* Source: ${source}\n`
292
+ }
293
+
294
+ if (title) {
295
+ banner += `* Title: ${title}\n`
296
+ }
297
+
298
+ if (description) {
299
+ const formattedDescription = description.replace(/\n/gm, '\n* ')
300
+ banner += `* Description: ${formattedDescription}\n`
301
+ }
302
+
303
+ if (version) {
304
+ banner += `* OpenAPI spec version: ${version}\n`
305
+ }
306
+
307
+ banner += '*/\n'
308
+ return banner
309
+ } catch (_error) {
310
+ return '/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/'
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Default banner resolver — returns the banner string for a generated file.
316
+ *
317
+ * A user-supplied `output.banner` overrides the default Kubb "Generated by Kubb" notice.
318
+ * When no `output.banner` is set, the Kubb notice is used (including `title` and `version`
319
+ * from the OAS spec when a `node` is provided).
320
+ *
321
+ * - When `output.banner` is a function and `node` is provided, returns `output.banner(node)`.
322
+ * - When `output.banner` is a function and `node` is absent, falls back to the Kubb notice.
323
+ * - When `output.banner` is a string, returns it directly.
324
+ * - When `config.output.defaultBanner` is `false`, returns `undefined`.
325
+ * - Otherwise returns the Kubb "Generated by Kubb" notice.
326
+ *
327
+ * @example String banner overrides default
328
+ * ```ts
329
+ * defaultResolveBanner(undefined, { output: { banner: '// my banner' }, config })
330
+ * // → '// my banner'
331
+ * ```
332
+ *
333
+ * @example Function banner with node
334
+ * ```ts
335
+ * defaultResolveBanner(inputNode, { output: { banner: (node) => `// v${node.version}` }, config })
336
+ * // → '// v3.0.0'
337
+ * ```
338
+ *
339
+ * @example No user banner — Kubb notice with OAS metadata
340
+ * ```ts
341
+ * defaultResolveBanner(inputNode, { config })
342
+ * // → '/** Generated by Kubb ... Title: Pet Store ... *\/'
343
+ * ```
344
+ *
345
+ * @example Disabled default banner
346
+ * ```ts
347
+ * defaultResolveBanner(undefined, { config: { output: { defaultBanner: false }, ...config } })
348
+ * // → undefined
349
+ * ```
350
+ */
351
+ export function defaultResolveBanner(node: InputNode | undefined, { output, config }: ResolveBannerContext): string | undefined {
352
+ if (typeof output?.banner === 'function') {
353
+ return output.banner(node)
354
+ }
355
+
356
+ if (typeof output?.banner === 'string') {
357
+ return output.banner
358
+ }
359
+
360
+ if (config.output.defaultBanner === false) {
361
+ return undefined
362
+ }
363
+
364
+ return buildDefaultBanner({ title: node?.meta?.title, version: node?.meta?.version, config })
365
+ }
366
+
367
+ /**
368
+ * Default footer resolver — returns the footer string for a generated file.
369
+ *
370
+ * - When `output.footer` is a function and `node` is provided, calls it with the node.
371
+ * - When `output.footer` is a function and `node` is absent, returns `undefined`.
372
+ * - When `output.footer` is a string, returns it directly.
373
+ * - Otherwise returns `undefined`.
374
+ *
375
+ * @example String footer
376
+ * ```ts
377
+ * defaultResolveFooter(undefined, { output: { footer: '// end of file' }, config })
378
+ * // → '// end of file'
379
+ * ```
380
+ *
381
+ * @example Function footer with node
382
+ * ```ts
383
+ * defaultResolveFooter(inputNode, { output: { footer: (node) => `// ${node.title}` }, config })
384
+ * // → '// Pet Store'
385
+ * ```
386
+ */
387
+ export function defaultResolveFooter(node: InputNode | undefined, { output }: ResolveBannerContext): string | undefined {
388
+ if (typeof output?.footer === 'function') {
389
+ return node ? output.footer(node) : undefined
390
+ }
391
+ if (typeof output?.footer === 'string') {
392
+ return output.footer
393
+ }
394
+ return undefined
395
+ }
396
+
397
+ /**
398
+ * Defines a resolver for a plugin, injecting built-in defaults for name casing,
399
+ * include/exclude/override filtering, path resolution, and file construction.
400
+ *
401
+ * All four defaults can be overridden by providing them in the builder function:
402
+ * - `default` — name casing strategy (camelCase / PascalCase)
403
+ * - `resolveOptions` — include/exclude/override filtering
404
+ * - `resolvePath` — output path computation
405
+ * - `resolveFile` — full `FileNode` construction
406
+ *
407
+ * Methods in the builder have access to `this` (the full resolver object), so they
408
+ * can call other resolver methods without circular imports.
409
+ *
410
+ * @example Basic resolver with naming helpers
411
+ * ```ts
412
+ * export const resolver = defineResolver<PluginTs>(() => ({
413
+ * name: 'default',
414
+ * resolveName(node) {
415
+ * return this.default(node.name, 'function')
416
+ * },
417
+ * resolveTypedName(node) {
418
+ * return this.default(node.name, 'type')
419
+ * },
420
+ * }))
421
+ * ```
422
+ *
423
+ * @example Override resolvePath for a custom output structure
424
+ * ```ts
425
+ * export const resolver = defineResolver<PluginTs>(() => ({
426
+ * name: 'custom',
427
+ * resolvePath({ baseName }, { root, output }) {
428
+ * return path.resolve(root, output.path, 'generated', baseName)
429
+ * },
430
+ * }))
431
+ * ```
432
+ *
433
+ * @example Use this.default inside a helper
434
+ * ```ts
435
+ * export const resolver = defineResolver<PluginTs>(() => ({
436
+ * name: 'default',
437
+ * resolveParamName(node, param) {
438
+ * return this.default(`${node.operationId} ${param.in} ${param.name}`, 'type')
439
+ * },
440
+ * }))
441
+ * ```
442
+ */
443
+ export function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'] {
444
+ return {
445
+ default: defaultResolver,
446
+ resolveOptions: defaultResolveOptions,
447
+ resolvePath: defaultResolvePath,
448
+ resolveFile: defaultResolveFile,
449
+ resolveBanner: defaultResolveBanner,
450
+ resolveFooter: defaultResolveFooter,
451
+ ...build(),
452
+ } as T['resolver']
453
+ }
package/src/devtools.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { RootNode } from '@kubb/ast/types'
1
+ import type { InputNode } from '@kubb/ast'
2
2
  import { deflateSync, inflateSync } from 'fflate'
3
3
  import { x } from 'tinyexec'
4
4
  import type { DevtoolsOptions } from './types.ts'
5
5
 
6
6
  /**
7
- * Encodes a `RootNode` as a compressed, URL-safe string.
7
+ * Encodes an `InputNode` as a compressed, URL-safe string.
8
8
  *
9
9
  * The JSON representation is deflate-compressed with {@link deflateSync} before
10
10
  * base64url encoding, which typically reduces payload size by 70–80 % and
@@ -12,41 +12,41 @@ import type { DevtoolsOptions } from './types.ts'
12
12
  *
13
13
  * Use {@link decodeAst} to reverse.
14
14
  */
15
- export function encodeAst(root: RootNode): string {
16
- const compressed = deflateSync(new TextEncoder().encode(JSON.stringify(root)))
15
+ export function encodeAst(input: InputNode): string {
16
+ const compressed = deflateSync(new TextEncoder().encode(JSON.stringify(input)))
17
17
  return Buffer.from(compressed).toString('base64url')
18
18
  }
19
19
 
20
20
  /**
21
- * Decodes a `RootNode` from a string produced by {@link encodeAst}.
21
+ * Decodes an `InputNode` from a string produced by {@link encodeAst}.
22
22
  *
23
23
  * Works in both Node.js and the browser — no streaming APIs required.
24
24
  */
25
- export function decodeAst(encoded: string): RootNode {
25
+ export function decodeAst(encoded: string): InputNode {
26
26
  const bytes = Buffer.from(encoded, 'base64url')
27
- return JSON.parse(new TextDecoder().decode(inflateSync(bytes))) as RootNode
27
+ return JSON.parse(new TextDecoder().decode(inflateSync(bytes))) as InputNode
28
28
  }
29
29
 
30
30
  /**
31
- * Constructs the Kubb Studio URL for the given `RootNode`.
31
+ * Constructs the Kubb Studio URL for the given `InputNode`.
32
32
  * When `options.ast` is `true`, navigates to the AST inspector (`/ast`).
33
- * The `root` is encoded and attached as the `?root=` query parameter so Studio
33
+ * The `input` is encoded and attached as the `?root=` query parameter so Studio
34
34
  * can decode and render it without a round-trip to any server.
35
35
  */
36
- export function getStudioUrl(root: RootNode, studioUrl: string, options: DevtoolsOptions = {}): string {
36
+ export function getStudioUrl(input: InputNode, studioUrl: string, options: DevtoolsOptions = {}): string {
37
37
  const baseUrl = studioUrl.replace(/\/$/, '')
38
38
  const path = options.ast ? '/ast' : ''
39
39
 
40
- return `${baseUrl}${path}?root=${encodeAst(root)}`
40
+ return `${baseUrl}${path}?root=${encodeAst(input)}`
41
41
  }
42
42
 
43
43
  /**
44
- * Opens the Kubb Studio URL for the given `RootNode` in the default browser —
44
+ * Opens the Kubb Studio URL for the given `InputNode` in the default browser —
45
45
  *
46
46
  * Falls back to printing the URL if the browser cannot be launched.
47
47
  */
48
- export async function openInStudio(root: RootNode, studioUrl: string, options: DevtoolsOptions = {}): Promise<void> {
49
- const url = getStudioUrl(root, studioUrl, options)
48
+ export async function openInStudio(input: InputNode, studioUrl: string, options: DevtoolsOptions = {}): Promise<void> {
49
+ const url = getStudioUrl(input, studioUrl, options)
50
50
 
51
51
  const cmd = process.platform === 'win32' ? 'cmd' : process.platform === 'darwin' ? 'open' : 'xdg-open'
52
52
  const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url]
package/src/index.ts CHANGED
@@ -1,24 +1,19 @@
1
1
  export { AsyncEventEmitter, URLPath } from '@internals/utils'
2
- export { definePrinter } from '@kubb/ast'
3
- export { build, build as default, safeBuild, setup } from './build.ts'
4
- export { type CLIOptions, type ConfigInput, defineConfig, isInputPath } from './config.ts'
5
- export { formatters, linters, logLevel } from './constants.ts'
6
- export { defineAdapter } from './defineAdapter.ts'
2
+ export * as ast from '@kubb/ast'
3
+ export { logLevel } from './constants.ts'
4
+ export { createAdapter } from './createAdapter.ts'
5
+ export { createKubb } from './createKubb.ts'
6
+ export { createRenderer } from './createRenderer.ts'
7
+ export { createStorage } from './createStorage.ts'
7
8
  export { defineGenerator } from './defineGenerator.ts'
8
9
  export { defineLogger } from './defineLogger.ts'
10
+ export { defineParser } from './defineParser.ts'
9
11
  export { definePlugin } from './definePlugin.ts'
10
- export { defineStorage } from './defineStorage.ts'
11
- export { PackageManager } from './PackageManager.ts'
12
- export { getMode, PluginManager } from './PluginManager.ts'
13
- export { PromiseManager } from './PromiseManager.ts'
12
+ export { defineResolver } from './defineResolver.ts'
13
+ export { FileManager } from './FileManager.ts'
14
+ export { FileProcessor } from './FileProcessor.ts'
15
+ export { PluginDriver } from './PluginDriver.ts'
14
16
  export { fsStorage } from './storages/fsStorage.ts'
15
17
  export { memoryStorage } from './storages/memoryStorage.ts'
16
18
  export * from './types.ts'
17
- export type { FunctionParamsAST } from './utils/FunctionParams.ts'
18
- export { FunctionParams } from './utils/FunctionParams.ts'
19
- export { detectFormatter } from './utils/formatters.ts'
20
- export type { FileMetaBase } from './utils/getBarrelFiles.ts'
21
- export { getBarrelFiles } from './utils/getBarrelFiles.ts'
22
- export { getConfigs } from './utils/getConfigs.ts'
23
- export { detectLinter } from './utils/linters.ts'
24
- export { resolveOptions } from './utils/resolveOptions.ts'
19
+ export { isInputPath } from './utils/isInputPath.ts'