@kubb/core 4.3.1 → 4.4.1

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 (147) hide show
  1. package/dist/{URLPath-BYceu_vY.js → URLPath-DbWtfVa1.js} +2 -3
  2. package/dist/{URLPath-BYceu_vY.js.map → URLPath-DbWtfVa1.js.map} +1 -1
  3. package/dist/{URLPath-8WVzHBnA.cjs → URLPath-Dir2mxRT.cjs} +6 -7
  4. package/dist/{URLPath-8WVzHBnA.cjs.map → URLPath-Dir2mxRT.cjs.map} +1 -1
  5. package/dist/{chunk-CZg_9w7l.cjs → chunk-CUT6urMc.cjs} +0 -23
  6. package/dist/hooks.cjs +6 -6
  7. package/dist/hooks.cjs.map +1 -1
  8. package/dist/hooks.d.cts +5 -5
  9. package/dist/hooks.d.ts +5 -5
  10. package/dist/hooks.js +1 -1
  11. package/dist/hooks.js.map +1 -1
  12. package/dist/index.cjs +128 -62
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +22 -18
  15. package/dist/index.d.ts +22 -18
  16. package/dist/index.js +116 -53
  17. package/dist/index.js.map +1 -1
  18. package/dist/{logger-BXL0YCrv.cjs → logger-BIzTtBYJ.cjs} +48 -5
  19. package/dist/logger-BIzTtBYJ.cjs.map +1 -0
  20. package/dist/{logger-DpoDtxfo.d.cts → logger-BjfDkvkn.d.cts} +1 -1
  21. package/dist/{logger-BA-za85-.d.ts → logger-BwhJWK-H.d.ts} +1 -1
  22. package/dist/{logger-CDxSrFkR.js → logger-Bxe022ug.js} +39 -4
  23. package/dist/logger-Bxe022ug.js.map +1 -0
  24. package/dist/logger.cjs +1 -2
  25. package/dist/logger.d.cts +1 -1
  26. package/dist/logger.d.ts +1 -1
  27. package/dist/logger.js +1 -2
  28. package/dist/{prompt-DgONOpPH.cjs → prompt-D5DZPtWc.cjs} +2 -2
  29. package/dist/{prompt-DgONOpPH.cjs.map → prompt-D5DZPtWc.cjs.map} +1 -1
  30. package/dist/{prompt-DBVnG4Me.js → prompt-xM0onfy8.js} +1 -1
  31. package/dist/{prompt-DBVnG4Me.js.map → prompt-xM0onfy8.js.map} +1 -1
  32. package/dist/transformers-CeNW0G32.js +339 -0
  33. package/dist/transformers-CeNW0G32.js.map +1 -0
  34. package/dist/transformers-DWLXDYKb.cjs +443 -0
  35. package/dist/transformers-DWLXDYKb.cjs.map +1 -0
  36. package/dist/transformers.cjs +7 -6
  37. package/dist/transformers.js +1 -3
  38. package/dist/{types-DPeNK0FO.d.ts → types-CVONMhN_.d.cts} +51 -53
  39. package/dist/{types-DNxlynJr.d.cts → types-CyDeSlGF.d.ts} +51 -53
  40. package/dist/{types-BzI9JlV8.d.ts → types-DCR_QgGt.d.ts} +1 -1
  41. package/dist/{types-C3ea5qNG.d.cts → types-DueAg3XP.d.cts} +1 -1
  42. package/dist/utils.cjs +7 -7
  43. package/dist/utils.cjs.map +1 -1
  44. package/dist/utils.d.cts +1 -1
  45. package/dist/utils.d.ts +1 -1
  46. package/dist/utils.js +4 -6
  47. package/dist/utils.js.map +1 -1
  48. package/package.json +15 -20
  49. package/src/BarrelManager.ts +1 -1
  50. package/src/FileManager.ts +5 -2
  51. package/src/PluginManager.ts +4 -8
  52. package/src/build.ts +39 -42
  53. package/src/fs/index.ts +0 -7
  54. package/src/hooks/useMode.ts +2 -2
  55. package/src/hooks/usePlugin.ts +1 -1
  56. package/src/hooks/usePluginManager.ts +1 -1
  57. package/src/plugin.ts +10 -5
  58. package/src/types.ts +3 -2
  59. package/src/utils/TreeNode.ts +1 -1
  60. package/dist/acorn-BAVXZMtK.cjs +0 -5082
  61. package/dist/acorn-BAVXZMtK.cjs.map +0 -1
  62. package/dist/acorn-D-VhIOLw.js +0 -5080
  63. package/dist/acorn-D-VhIOLw.js.map +0 -1
  64. package/dist/angular-Bp0XO9db.cjs +0 -3631
  65. package/dist/angular-Bp0XO9db.cjs.map +0 -1
  66. package/dist/angular-Czhp4eq5.js +0 -3629
  67. package/dist/angular-Czhp4eq5.js.map +0 -1
  68. package/dist/babel-DCR_B4Qn.js +0 -10033
  69. package/dist/babel-DCR_B4Qn.js.map +0 -1
  70. package/dist/babel-NI0v59ga.cjs +0 -10035
  71. package/dist/babel-NI0v59ga.cjs.map +0 -1
  72. package/dist/casing-BSeq_teY.js +0 -100
  73. package/dist/casing-BSeq_teY.js.map +0 -1
  74. package/dist/casing-CP-9GGdK.cjs +0 -112
  75. package/dist/casing-CP-9GGdK.cjs.map +0 -1
  76. package/dist/chunk-1SJ2vVWa.js +0 -35
  77. package/dist/estree-C3BZPlpU.cjs +0 -6930
  78. package/dist/estree-C3BZPlpU.cjs.map +0 -1
  79. package/dist/estree-DU2NummP.js +0 -6926
  80. package/dist/estree-DU2NummP.js.map +0 -1
  81. package/dist/flow-CWUBUkoi.cjs +0 -52252
  82. package/dist/flow-CWUBUkoi.cjs.map +0 -1
  83. package/dist/flow-JiEbweKj.js +0 -52250
  84. package/dist/flow-JiEbweKj.js.map +0 -1
  85. package/dist/fs-BIPMUfpW.js +0 -90
  86. package/dist/fs-BIPMUfpW.js.map +0 -1
  87. package/dist/fs-RSVoUw3S.cjs +0 -141
  88. package/dist/fs-RSVoUw3S.cjs.map +0 -1
  89. package/dist/fs.cjs +0 -17
  90. package/dist/fs.d.cts +0 -2
  91. package/dist/fs.d.ts +0 -2
  92. package/dist/fs.js +0 -4
  93. package/dist/glimmer-CX9OqG1j.cjs +0 -7275
  94. package/dist/glimmer-CX9OqG1j.cjs.map +0 -1
  95. package/dist/glimmer-t9nWn9aE.js +0 -7271
  96. package/dist/glimmer-t9nWn9aE.js.map +0 -1
  97. package/dist/graphql-DjErlIi5.js +0 -1897
  98. package/dist/graphql-DjErlIi5.js.map +0 -1
  99. package/dist/graphql-GOxQAKxM.cjs +0 -1902
  100. package/dist/graphql-GOxQAKxM.cjs.map +0 -1
  101. package/dist/html-CWrdYAhQ.cjs +0 -6560
  102. package/dist/html-CWrdYAhQ.cjs.map +0 -1
  103. package/dist/html-_apcbx34.js +0 -6555
  104. package/dist/html-_apcbx34.js.map +0 -1
  105. package/dist/index-BTe91LHd.d.ts +0 -145
  106. package/dist/index-BmQIxvw0.d.cts +0 -144
  107. package/dist/logger-BXL0YCrv.cjs.map +0 -1
  108. package/dist/logger-CDxSrFkR.js.map +0 -1
  109. package/dist/markdown-ckUc3Q6q.js +0 -6750
  110. package/dist/markdown-ckUc3Q6q.js.map +0 -1
  111. package/dist/markdown-pzqiRmft.cjs +0 -6755
  112. package/dist/markdown-pzqiRmft.cjs.map +0 -1
  113. package/dist/meriyah-BjnGqpUs.js +0 -8928
  114. package/dist/meriyah-BjnGqpUs.js.map +0 -1
  115. package/dist/meriyah-D_x7itbT.cjs +0 -8930
  116. package/dist/meriyah-D_x7itbT.cjs.map +0 -1
  117. package/dist/mocks.cjs +0 -16830
  118. package/dist/mocks.cjs.map +0 -1
  119. package/dist/mocks.d.cts +0 -13
  120. package/dist/mocks.d.ts +0 -13
  121. package/dist/mocks.js +0 -16818
  122. package/dist/mocks.js.map +0 -1
  123. package/dist/postcss-B_c2wbFu.cjs +0 -6689
  124. package/dist/postcss-B_c2wbFu.cjs.map +0 -1
  125. package/dist/postcss-v7BP6SZ-.js +0 -6684
  126. package/dist/postcss-v7BP6SZ-.js.map +0 -1
  127. package/dist/transformers-BH0KLJJP.cjs +0 -804
  128. package/dist/transformers-BH0KLJJP.cjs.map +0 -1
  129. package/dist/transformers-DzHGqYO2.js +0 -702
  130. package/dist/transformers-DzHGqYO2.js.map +0 -1
  131. package/dist/typescript-6kMN6Wqz.cjs +0 -23014
  132. package/dist/typescript-6kMN6Wqz.cjs.map +0 -1
  133. package/dist/typescript-B_IBfKSe.js +0 -23002
  134. package/dist/typescript-B_IBfKSe.js.map +0 -1
  135. package/dist/typescript-C5hce4HG.cjs +0 -4
  136. package/dist/typescript-Cas1XcNz.js +0 -3
  137. package/dist/write-BJfM7G1_.cjs +0 -49
  138. package/dist/write-BJfM7G1_.cjs.map +0 -1
  139. package/dist/write-CxO1CDML.js +0 -40
  140. package/dist/write-CxO1CDML.js.map +0 -1
  141. package/dist/yaml-BfWM_B73.js +0 -5209
  142. package/dist/yaml-BfWM_B73.js.map +0 -1
  143. package/dist/yaml-DZs6MhV1.cjs +0 -5215
  144. package/dist/yaml-DZs6MhV1.cjs.map +0 -1
  145. package/src/fs/types.ts +0 -132
  146. package/src/fs/unlink.ts +0 -5
  147. package/src/mocks/index.ts +0 -82
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { a as Mode, i as File, s as ResolvedFile } from "./index-BTe91LHd.js";
2
- import { n as Logger } from "./logger-BA-za85-.js";
3
- import { _ as ResolvePathParams, a as InputData, b as UserPluginWithLifeCycle, c as Plugin, d as PluginKey, f as PluginLifecycle, g as ResolveNameParams, h as PluginWithLifeCycle, i as Group, l as PluginContext, m as PluginParameter, n as Config, o as InputPath, p as PluginLifecycleHooks, r as GetPluginFactoryOptions, s as Output, t as BarrelType, u as PluginFactoryOptions, v as UserConfig, x as PluginManager, y as UserPlugin } from "./types-DPeNK0FO.js";
4
- import { t as PossiblePromise } from "./types-BzI9JlV8.js";
5
- import { FileManager } from "@kubb/fabric-core";
1
+ import { n as Logger } from "./logger-BwhJWK-H.js";
2
+ import { _ as ResolvePathParams, a as InputData, b as UserPluginWithLifeCycle, c as Plugin, d as PluginKey, f as PluginLifecycle, g as ResolveNameParams, h as PluginWithLifeCycle, i as Group, l as PluginContext, m as PluginParameter, n as Config, o as InputPath, p as PluginLifecycleHooks, r as GetPluginFactoryOptions, s as Output, t as BarrelType, u as PluginFactoryOptions, v as UserConfig, x as PluginManager, y as UserPlugin } from "./types-CyDeSlGF.js";
3
+ import { t as PossiblePromise } from "./types-DCR_QgGt.js";
4
+ import { Fabric } from "@kubb/react-fabric";
5
+ import { KubbFile } from "@kubb/fabric-core/types";
6
6
 
7
7
  //#region src/BaseGenerator.d.ts
8
8
  /**
@@ -25,19 +25,23 @@ type BuildOptions = {
25
25
  * @default Logger without the spinner
26
26
  */
27
27
  logger?: Logger;
28
- pluginManager?: PluginManager;
29
28
  };
30
29
  type BuildOutput = {
31
- files: Array<ResolvedFile>;
30
+ fabric: Fabric;
31
+ files: Array<KubbFile.ResolvedFile>;
32
32
  pluginManager: PluginManager;
33
33
  /**
34
34
  * Only for safeBuild
35
35
  */
36
36
  error?: Error;
37
37
  };
38
- declare function setup(options: BuildOptions): Promise<PluginManager>;
39
- declare function build(options: BuildOptions): Promise<BuildOutput>;
40
- declare function safeBuild(options: BuildOptions): Promise<BuildOutput>;
38
+ type SetupResult = {
39
+ fabric: Fabric;
40
+ pluginManager: PluginManager;
41
+ };
42
+ declare function setup(options: BuildOptions): Promise<SetupResult>;
43
+ declare function build(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
44
+ declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
41
45
  //#endregion
42
46
  //#region src/config.d.ts
43
47
  type Args = {
@@ -95,14 +99,14 @@ type AddIndexesProps = {
95
99
  logger?: Logger;
96
100
  meta?: FileMetaBase;
97
101
  };
98
- declare function getMode(path: string | undefined | null): Mode;
99
- declare function getBarrelFiles(files: Array<ResolvedFile>, {
102
+ declare function getMode(path: string | undefined | null): KubbFile.Mode;
103
+ declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
100
104
  type,
101
105
  meta,
102
106
  root,
103
107
  output,
104
108
  logger
105
- }: AddIndexesProps): Promise<File[]>;
109
+ }: AddIndexesProps): Promise<KubbFile.File[]>;
106
110
  //#endregion
107
111
  //#region src/PackageManager.d.ts
108
112
  type PackageJSON = {
@@ -130,24 +134,24 @@ declare class PackageManager {
130
134
  //#endregion
131
135
  //#region src/utils/executeStrategies.d.ts
132
136
  type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
133
- type ValueOfPromiseFuncArray<TInput$1 extends Array<unknown>> = TInput$1 extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
134
- type SeqOutput<TInput$1 extends Array<PromiseFunc$1<TValue$1, null>>, TValue$1> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput$1>>>>;
137
+ type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
138
+ type SeqOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>;
135
139
  /**
136
140
  * Chains promises
137
141
  */
138
142
 
139
- type HookFirstOutput<TInput$1 extends Array<PromiseFunc$1<TValue$1, null>>, TValue$1 = unknown> = ValueOfPromiseFuncArray<TInput$1>;
143
+ type HookFirstOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>;
140
144
  /**
141
145
  * Chains promises, first non-null result stops and returns
142
146
  */
143
147
 
144
- type HookParallelOutput<TInput$1 extends Array<PromiseFunc$1<TValue$1, null>>, TValue$1> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput$1>>>[]>;
148
+ type HookParallelOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>;
145
149
  /**
146
150
  * Runs an array of promise functions with optional concurrency limit.
147
151
  */
148
152
 
149
153
  type Strategy = 'seq' | 'first' | 'parallel';
150
- type StrategySwitch<TStrategy$1 extends Strategy, TInput$1 extends Array<PromiseFunc$1<TValue$1, null>>, TValue$1> = TStrategy$1 extends 'first' ? HookFirstOutput<TInput$1, TValue$1> : TStrategy$1 extends 'seq' ? SeqOutput<TInput$1, TValue$1> : TStrategy$1 extends 'parallel' ? HookParallelOutput<TInput$1, TValue$1> : never;
154
+ type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = TStrategy extends 'first' ? HookFirstOutput<TInput, TValue> : TStrategy extends 'seq' ? SeqOutput<TInput, TValue> : TStrategy extends 'parallel' ? HookParallelOutput<TInput, TValue> : never;
151
155
  //#endregion
152
156
  //#region src/PromiseManager.d.ts
153
157
  type PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import { a as read, c as clean, o as readSync, r as getRelativePath, s as exists, t as trimExtName } from "./fs-BIPMUfpW.js";
2
- import { t as write } from "./write-CxO1CDML.js";
3
- import { a as EventEmitter, n as createLogger } from "./logger-CDxSrFkR.js";
4
- import { h as trim, v as transformReservedWord } from "./transformers-DzHGqYO2.js";
5
- import { r as setUniqueName, t as URLPath } from "./URLPath-BYceu_vY.js";
6
- import "./casing-BSeq_teY.js";
1
+ import { a as EventEmitter, n as createLogger, o as write } from "./logger-Bxe022ug.js";
2
+ import { g as trim, y as transformReservedWord } from "./transformers-CeNW0G32.js";
3
+ import { r as setUniqueName, t as URLPath } from "./URLPath-DbWtfVa1.js";
7
4
  import mod from "node:module";
8
- import path, { extname, join, relative, resolve } from "node:path";
9
- import { typescriptParser } from "@kubb/react";
5
+ import path, { extname, join, normalize, relative, resolve } from "node:path";
6
+ import { createFabric } from "@kubb/react-fabric";
7
+ import { typescriptParser } from "@kubb/react-fabric/parsers";
8
+ import { fsPlugin } from "@kubb/react-fabric/plugins";
10
9
  import pc from "picocolors";
11
10
  import { isDeepEqual } from "remeda";
11
+ import fs from "fs-extra";
12
+ import { switcher } from "js-runtime";
12
13
  import g$1 from "node:process";
13
- import { FileManager } from "@kubb/fabric-core";
14
14
  import os from "node:os";
15
15
  import { fileURLToPath, pathToFileURL } from "node:url";
16
- import fs, { promises } from "node:fs";
16
+ import fs$1, { promises } from "node:fs";
17
17
  import { coerce, satisfies } from "semver";
18
18
 
19
19
  //#region src/BaseGenerator.ts
@@ -55,6 +55,74 @@ function isInputPath(result) {
55
55
  return !!result && "path" in result?.input;
56
56
  }
57
57
 
58
+ //#endregion
59
+ //#region src/fs/clean.ts
60
+ async function clean(path$1) {
61
+ return fs.remove(path$1);
62
+ }
63
+
64
+ //#endregion
65
+ //#region src/fs/exists.ts
66
+ const reader$1 = switcher({
67
+ node: async (path$1) => {
68
+ return fs.pathExists(path$1);
69
+ },
70
+ bun: async (path$1) => {
71
+ return Bun.file(path$1).exists();
72
+ }
73
+ }, "node");
74
+ const syncReader$1 = switcher({
75
+ node: (path$1) => {
76
+ return fs.pathExistsSync(path$1);
77
+ },
78
+ bun: () => {
79
+ throw new Error("Bun cannot read sync");
80
+ }
81
+ }, "node");
82
+ async function exists(path$1) {
83
+ return reader$1(path$1);
84
+ }
85
+
86
+ //#endregion
87
+ //#region src/fs/read.ts
88
+ const reader = switcher({
89
+ node: async (path$1) => {
90
+ return fs.readFile(path$1, { encoding: "utf8" });
91
+ },
92
+ bun: async (path$1) => {
93
+ return Bun.file(path$1).text();
94
+ }
95
+ }, "node");
96
+ const syncReader = switcher({
97
+ node: (path$1) => {
98
+ return fs.readFileSync(path$1, { encoding: "utf8" });
99
+ },
100
+ bun: () => {
101
+ throw new Error("Bun cannot read sync");
102
+ }
103
+ }, "node");
104
+ async function read(path$1) {
105
+ return reader(path$1);
106
+ }
107
+ function readSync(path$1) {
108
+ return syncReader(path$1);
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/fs/utils.ts
113
+ function slash(path$1, platform = "linux") {
114
+ const isWindowsPath = /^\\\\\?\\/.test(path$1);
115
+ const normalizedPath = normalize(path$1);
116
+ if (["linux", "mac"].includes(platform) && !isWindowsPath) return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
117
+ return normalizedPath.replaceAll(/\\/g, "/").replace("../", "");
118
+ }
119
+ function getRelativePath(rootDir, filePath, platform = "linux") {
120
+ if (!rootDir || !filePath) throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ""} ${filePath || ""}`);
121
+ const slashedPath = slash(relative(rootDir, filePath), platform);
122
+ if (slashedPath.startsWith("../")) return slashedPath;
123
+ return `./${slashedPath}`;
124
+ }
125
+
58
126
  //#endregion
59
127
  //#region src/errors.ts
60
128
  var ValidationPluginError = class extends Error {};
@@ -238,13 +306,16 @@ function createPlugin(factory) {
238
306
  };
239
307
  }
240
308
  const pluginCore = createPlugin((options) => {
241
- const { fileManager, pluginManager, resolvePath, resolveName, logger } = options;
309
+ const { fabric, pluginManager, resolvePath, resolveName, logger } = options;
242
310
  return {
243
311
  name: "core",
244
312
  options,
245
313
  key: ["core"],
246
314
  context() {
247
315
  return {
316
+ get fabric() {
317
+ return fabric;
318
+ },
248
319
  get config() {
249
320
  return options.config;
250
321
  },
@@ -255,10 +326,12 @@ const pluginCore = createPlugin((options) => {
255
326
  return options.plugin;
256
327
  },
257
328
  logger,
258
- fileManager,
329
+ get fileManager() {
330
+ return fabric.context.fileManager;
331
+ },
259
332
  pluginManager,
260
333
  async addFile(...files) {
261
- const resolvedFiles = await fileManager.add(...files);
334
+ const resolvedFiles = await fabric.context.fileManager.add(...files);
262
335
  if (!Array.isArray(resolvedFiles)) return [resolvedFiles];
263
336
  return resolvedFiles;
264
337
  },
@@ -280,10 +353,6 @@ const pluginCore = createPlugin((options) => {
280
353
  //#region src/PluginManager.ts
281
354
  var PluginManager = class {
282
355
  plugins = /* @__PURE__ */ new Set();
283
- /**
284
- * @deprecated do not use from pluginManager
285
- */
286
- fileManager;
287
356
  events = new EventEmitter();
288
357
  config;
289
358
  executed = [];
@@ -296,13 +365,12 @@ var PluginManager = class {
296
365
  this.config = config;
297
366
  this.options = options;
298
367
  this.logger = options.logger;
299
- this.fileManager = new FileManager();
300
368
  this.#promiseManager = new PromiseManager({ nullCheck: (state) => !!state?.result });
301
369
  const core = pluginCore({
370
+ fabric: options.fabric,
302
371
  config,
303
372
  logger: this.logger,
304
373
  pluginManager: this,
305
- fileManager: this.fileManager,
306
374
  resolvePath: this.resolvePath.bind(this),
307
375
  resolveName: this.resolveName.bind(this),
308
376
  getPlugins: this.#getSortedPlugins.bind(this)
@@ -724,7 +792,6 @@ var PluginManager = class {
724
792
  //#endregion
725
793
  //#region src/build.ts
726
794
  async function setup(options) {
727
- if (options.pluginManager) return options.pluginManager;
728
795
  const { config: userConfig, logger = createLogger() } = options;
729
796
  if (Array.isArray(userConfig.input)) console.warn(pc.yellow("This feature is still under development — use with caution"));
730
797
  try {
@@ -748,36 +815,32 @@ async function setup(options) {
748
815
  await clean(definedConfig.output.path);
749
816
  await clean(join(definedConfig.root, ".kubb"));
750
817
  }
751
- return new PluginManager(definedConfig, {
752
- logger,
753
- concurrency: 5
754
- });
818
+ const fabric = createFabric();
819
+ fabric.use(fsPlugin, { dryRun: !definedConfig.output.write });
820
+ fabric.use(typescriptParser);
821
+ return {
822
+ fabric,
823
+ pluginManager: new PluginManager(definedConfig, {
824
+ fabric,
825
+ logger,
826
+ concurrency: 5
827
+ })
828
+ };
755
829
  }
756
- async function build(options) {
757
- const { files, pluginManager, error } = await safeBuild(options);
830
+ async function build(options, overrides) {
831
+ const { fabric, files, pluginManager, error } = await safeBuild(options, overrides);
758
832
  if (error) throw error;
759
833
  return {
834
+ fabric,
760
835
  files,
761
836
  pluginManager,
762
837
  error
763
838
  };
764
839
  }
765
- async function safeBuild(options) {
766
- const pluginManager = await setup(options);
840
+ async function safeBuild(options, overrides) {
841
+ const { fabric, pluginManager } = overrides ? overrides : await setup(options);
767
842
  const config = pluginManager.config;
768
843
  try {
769
- pluginManager.events.on("executing", ({ plugin, message }) => {
770
- pluginManager.logger.emit("debug", {
771
- date: /* @__PURE__ */ new Date(),
772
- logs: [`Executing pluginKey ${plugin.key?.join(".")} | ${message}`]
773
- });
774
- });
775
- pluginManager.events.on("executed", ({ plugin, message, output }) => {
776
- pluginManager.logger.emit("debug", {
777
- date: /* @__PURE__ */ new Date(),
778
- logs: [`Executed pluginKey ${plugin.key?.join(".")} | ${message} | ${JSON.stringify(output, void 0, 2)}`]
779
- });
780
- });
781
844
  await pluginManager.hookParallel({
782
845
  hookName: "buildStart",
783
846
  parameters: [config],
@@ -788,7 +851,7 @@ async function safeBuild(options) {
788
851
  const rootFile = {
789
852
  path: rootPath,
790
853
  baseName: "index.ts",
791
- exports: (await pluginManager.fileManager.files).filter((file) => {
854
+ exports: fabric.files.filter((file) => {
792
855
  return file.sources.some((source) => source.isIndexable);
793
856
  }).flatMap((file) => {
794
857
  const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
@@ -809,16 +872,16 @@ async function safeBuild(options) {
809
872
  sources: [],
810
873
  meta: {}
811
874
  };
812
- await pluginManager.fileManager.add(rootFile);
875
+ await fabric.addFile(rootFile);
813
876
  }
814
- pluginManager.fileManager.processor.events.on("process:start", ({ files: files$1 }) => {
877
+ fabric.context.events.on("process:start", ({ files: files$1 }) => {
815
878
  pluginManager.logger.emit("progress_start", {
816
879
  id: "files",
817
880
  size: files$1.length,
818
881
  message: "Writing files ..."
819
882
  });
820
883
  });
821
- pluginManager.fileManager.processor.events.on("process:progress", async ({ file, source }) => {
884
+ fabric.context.events.on("process:progress", async ({ file, source }) => {
822
885
  const message = file ? `Writing ${relative(config.root, file.path)}` : "";
823
886
  pluginManager.logger.emit("progressed", {
824
887
  id: "files",
@@ -826,26 +889,23 @@ async function safeBuild(options) {
826
889
  });
827
890
  if (source) await write(file.path, source, { sanity: false });
828
891
  });
829
- pluginManager.fileManager.processor.events.on("process:end", () => {
892
+ fabric.context.events.on("process:end", () => {
830
893
  pluginManager.logger.emit("progress_stop", { id: "files" });
831
894
  });
832
- const parsers = new Set([typescriptParser]);
833
- const files = await pluginManager.fileManager.write({
834
- extension: config.output.extension,
835
- dryRun: !config.output.write,
836
- parsers
837
- });
895
+ const files = [...fabric.files];
896
+ await fabric.write({ extension: config.output.extension });
838
897
  await pluginManager.hookParallel({
839
898
  hookName: "buildEnd",
840
899
  message: `Build stopped for ${config.name}`
841
900
  });
842
- await pluginManager.fileManager.clear();
843
901
  return {
902
+ fabric,
844
903
  files,
845
904
  pluginManager
846
905
  };
847
906
  } catch (e) {
848
907
  return {
908
+ fabric,
849
909
  files: [],
850
910
  pluginManager,
851
911
  error: e
@@ -1038,6 +1098,9 @@ function getMode(path$1) {
1038
1098
  if (!path$1) return "split";
1039
1099
  return extname(path$1) ? "single" : "split";
1040
1100
  }
1101
+ function trimExtName(text) {
1102
+ return text.replace(/\.[^/.]+$/, "");
1103
+ }
1041
1104
  async function getBarrelFiles(files, { type, meta = {}, root, output, logger }) {
1042
1105
  if (!type || type === "propagate") return [];
1043
1106
  const barrelManager = new BarrelManager({ logger });
@@ -1165,7 +1228,7 @@ async function locatePath(paths, { cwd = g$1.cwd(), type = "file", allowSymlinks
1165
1228
  function locatePathSync(paths, { cwd = g$1.cwd(), type = "file", allowSymlinks = true } = {}) {
1166
1229
  checkType(type);
1167
1230
  cwd = toPath$1(cwd);
1168
- const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
1231
+ const statFunction = allowSymlinks ? fs$1.statSync : fs$1.lstatSync;
1169
1232
  for (const path_ of paths) try {
1170
1233
  const stat = statFunction(path.resolve(cwd, path_), { throwIfNoEntry: false });
1171
1234
  if (!stat) continue;