@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
package/src/constants.ts CHANGED
@@ -1,21 +1,45 @@
1
- import type { KubbFile } from '@kubb/fabric-core/types'
1
+ import type { FileNode } from '@kubb/ast'
2
2
 
3
+ /**
4
+ * Base URL for the Kubb Studio web app.
5
+ */
3
6
  export const DEFAULT_STUDIO_URL = 'https://studio.kubb.dev' as const
4
7
 
5
- export const CORE_PLUGIN_NAME = 'core' as const
6
-
7
- export const DEFAULT_MAX_LISTENERS = 100
8
-
8
+ /**
9
+ * Default number of plugins that may run concurrently during a build.
10
+ */
9
11
  export const DEFAULT_CONCURRENCY = 15
10
12
 
13
+ /**
14
+ * Maximum number of files processed in parallel by FileProcessor.
15
+ */
16
+ export const PARALLEL_CONCURRENCY_LIMIT = 100
17
+
18
+ /**
19
+ * File name used for generated barrel (index) files.
20
+ */
11
21
  export const BARREL_FILENAME = 'index.ts' as const
12
22
 
23
+ /**
24
+ * Default banner style written at the top of every generated file.
25
+ */
13
26
  export const DEFAULT_BANNER = 'simple' as const
14
27
 
15
- export const DEFAULT_EXTENSION: Record<KubbFile.Extname, KubbFile.Extname | ''> = { '.ts': '.ts' }
16
-
17
- export const PATH_SEPARATORS = ['/', '\\'] as const
18
-
28
+ /**
29
+ * Default file-extension mapping used when no explicit mapping is configured.
30
+ */
31
+ export const DEFAULT_EXTENSION: Record<FileNode['extname'], FileNode['extname'] | ''> = { '.ts': '.ts' }
32
+
33
+ /**
34
+ * Characters recognized as path separators on both POSIX and Windows.
35
+ */
36
+ export const PATH_SEPARATORS = new Set(['/', '\\'] as const)
37
+
38
+ /**
39
+ * Numeric log-level thresholds used internally to compare verbosity.
40
+ *
41
+ * Higher numbers are more verbose.
42
+ */
19
43
  export const logLevel = {
20
44
  silent: Number.NEGATIVE_INFINITY,
21
45
  error: 0,
@@ -25,38 +49,4 @@ export const logLevel = {
25
49
  debug: 5,
26
50
  } as const
27
51
 
28
- export const linters = {
29
- eslint: {
30
- command: 'eslint',
31
- args: (outputPath: string) => [outputPath, '--fix'],
32
- errorMessage: 'Eslint not found',
33
- },
34
- biome: {
35
- command: 'biome',
36
- args: (outputPath: string) => ['lint', '--fix', outputPath],
37
- errorMessage: 'Biome not found',
38
- },
39
- oxlint: {
40
- command: 'oxlint',
41
- args: (outputPath: string) => ['--fix', outputPath],
42
- errorMessage: 'Oxlint not found',
43
- },
44
- } as const
45
52
 
46
- export const formatters = {
47
- prettier: {
48
- command: 'prettier',
49
- args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],
50
- errorMessage: 'Prettier not found',
51
- },
52
- biome: {
53
- command: 'biome',
54
- args: (outputPath: string) => ['format', '--write', outputPath],
55
- errorMessage: 'Biome not found',
56
- },
57
- oxfmt: {
58
- command: 'oxfmt',
59
- args: (outputPath: string) => [outputPath],
60
- errorMessage: 'Oxfmt not found',
61
- },
62
- } as const
@@ -0,0 +1,25 @@
1
+ import type { Adapter, AdapterFactoryOptions } from './types.ts'
2
+
3
+ /**
4
+ * Builder type for an {@link Adapter} — takes options and returns the adapter instance.
5
+ */
6
+ type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>
7
+
8
+ /**
9
+ * Creates an adapter factory. Call the returned function with optional options to get the adapter instance.
10
+ *
11
+ * @example
12
+ * export const myAdapter = createAdapter<MyAdapter>((options) => {
13
+ * return {
14
+ * name: 'my-adapter',
15
+ * options,
16
+ * async parse(source) { ... },
17
+ * }
18
+ * })
19
+ *
20
+ * // instantiate
21
+ * const adapter = myAdapter({ validate: true })
22
+ */
23
+ export function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T> {
24
+ return (options) => build(options ?? ({} as T['options']))
25
+ }