@kubb/core 4.1.4 → 4.2.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 (149) hide show
  1. package/dist/URLPath-8WVzHBnA.cjs +134 -0
  2. package/dist/URLPath-8WVzHBnA.cjs.map +1 -0
  3. package/dist/URLPath-BYceu_vY.js +117 -0
  4. package/dist/URLPath-BYceu_vY.js.map +1 -0
  5. package/dist/{acorn-Cg_eXN51.cjs → acorn-BAVXZMtK.cjs} +17 -21
  6. package/dist/{acorn-Cg_eXN51.cjs.map → acorn-BAVXZMtK.cjs.map} +1 -1
  7. package/dist/{acorn-Z0oy0vSt.js → acorn-D-VhIOLw.js} +17 -21
  8. package/dist/{acorn-Z0oy0vSt.js.map → acorn-D-VhIOLw.js.map} +1 -1
  9. package/dist/{angular-nBly58h0.cjs → angular-Bp0XO9db.cjs} +24 -29
  10. package/dist/{angular-nBly58h0.cjs.map → angular-Bp0XO9db.cjs.map} +1 -1
  11. package/dist/{angular-BUlb_iaU.js → angular-Czhp4eq5.js} +24 -29
  12. package/dist/{angular-BUlb_iaU.js.map → angular-Czhp4eq5.js.map} +1 -1
  13. package/dist/{babel-DfXTN9QX.js → babel-DCR_B4Qn.js} +27 -37
  14. package/dist/{babel-DfXTN9QX.js.map → babel-DCR_B4Qn.js.map} +1 -1
  15. package/dist/{babel-5qXjvTGO.cjs → babel-NI0v59ga.cjs} +27 -37
  16. package/dist/{babel-5qXjvTGO.cjs.map → babel-NI0v59ga.cjs.map} +1 -1
  17. package/dist/casing-BSeq_teY.js +100 -0
  18. package/dist/casing-BSeq_teY.js.map +1 -0
  19. package/dist/casing-CP-9GGdK.cjs +112 -0
  20. package/dist/casing-CP-9GGdK.cjs.map +1 -0
  21. package/dist/{chunk-kPDogv7o.js → chunk-1SJ2vVWa.js} +1 -1
  22. package/dist/{estree-DyiFjXDy.cjs → estree-C3BZPlpU.cjs} +49 -64
  23. package/dist/{estree-DyiFjXDy.cjs.map → estree-C3BZPlpU.cjs.map} +1 -1
  24. package/dist/{estree-Bt3vRtV3.js → estree-DU2NummP.js} +49 -64
  25. package/dist/{estree-Bt3vRtV3.js.map → estree-DU2NummP.js.map} +1 -1
  26. package/dist/{flow-DdtBrX0O.cjs → flow-CWUBUkoi.cjs} +978 -1038
  27. package/dist/{flow-DdtBrX0O.cjs.map → flow-CWUBUkoi.cjs.map} +1 -1
  28. package/dist/{flow-Bb8_yYns.js → flow-JiEbweKj.js} +978 -1038
  29. package/dist/{flow-Bb8_yYns.js.map → flow-JiEbweKj.js.map} +1 -1
  30. package/dist/{fs-BNC5Fj6t.js → fs-BIPMUfpW.js} +3 -4
  31. package/dist/{fs-BNC5Fj6t.js.map → fs-BIPMUfpW.js.map} +1 -1
  32. package/dist/{fs-Bi2kuxAm.cjs → fs-RSVoUw3S.cjs} +2 -3
  33. package/dist/{fs-Bi2kuxAm.cjs.map → fs-RSVoUw3S.cjs.map} +1 -1
  34. package/dist/fs.cjs +1 -1
  35. package/dist/fs.d.cts +1 -1
  36. package/dist/fs.d.ts +1 -1
  37. package/dist/fs.js +2 -2
  38. package/dist/{glimmer-BuCRLjbI.cjs → glimmer-CX9OqG1j.cjs} +27 -41
  39. package/dist/{glimmer-BuCRLjbI.cjs.map → glimmer-CX9OqG1j.cjs.map} +1 -1
  40. package/dist/{glimmer-By8WZPkK.js → glimmer-t9nWn9aE.js} +27 -41
  41. package/dist/{glimmer-By8WZPkK.js.map → glimmer-t9nWn9aE.js.map} +1 -1
  42. package/dist/{graphql-DsrNefXx.js → graphql-DjErlIi5.js} +16 -20
  43. package/dist/{graphql-DsrNefXx.js.map → graphql-DjErlIi5.js.map} +1 -1
  44. package/dist/{graphql-TN0hv-fx.cjs → graphql-GOxQAKxM.cjs} +16 -20
  45. package/dist/{graphql-TN0hv-fx.cjs.map → graphql-GOxQAKxM.cjs.map} +1 -1
  46. package/dist/hooks.cjs +29 -0
  47. package/dist/hooks.cjs.map +1 -0
  48. package/dist/hooks.d.cts +16 -0
  49. package/dist/hooks.d.ts +16 -0
  50. package/dist/hooks.js +25 -0
  51. package/dist/hooks.js.map +1 -0
  52. package/dist/{html-1W4-2_9J.cjs → html-CWrdYAhQ.cjs} +26 -27
  53. package/dist/{html-1W4-2_9J.cjs.map → html-CWrdYAhQ.cjs.map} +1 -1
  54. package/dist/{html-Y5KDc150.js → html-_apcbx34.js} +26 -27
  55. package/dist/{html-Y5KDc150.js.map → html-_apcbx34.js.map} +1 -1
  56. package/dist/{index-CGJ3tdk-.d.ts → index-BTe91LHd.d.ts} +7 -2
  57. package/dist/{index-CWX6_-da.d.cts → index-BmQIxvw0.d.cts} +5 -2
  58. package/dist/index.cjs +383 -30
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +43 -10
  61. package/dist/index.d.ts +43 -10
  62. package/dist/index.js +376 -23
  63. package/dist/index.js.map +1 -1
  64. package/dist/{logger-OWS6fqk0.d.cts → logger-BA-za85-.d.ts} +2 -2
  65. package/dist/{logger-DBJsdlpZ.cjs → logger-BXL0YCrv.cjs} +8 -12
  66. package/dist/{logger-DBJsdlpZ.cjs.map → logger-BXL0YCrv.cjs.map} +1 -1
  67. package/dist/{logger-BKPT4rkB.js → logger-CDxSrFkR.js} +10 -14
  68. package/dist/{logger-BKPT4rkB.js.map → logger-CDxSrFkR.js.map} +1 -1
  69. package/dist/{logger-B-4AXUmB.d.ts → logger-DpoDtxfo.d.cts} +2 -2
  70. package/dist/logger.cjs +1 -1
  71. package/dist/logger.d.cts +1 -1
  72. package/dist/logger.d.ts +1 -1
  73. package/dist/logger.js +2 -2
  74. package/dist/{markdown-Drl4Cbq5.js → markdown-ckUc3Q6q.js} +25 -29
  75. package/dist/{markdown-Drl4Cbq5.js.map → markdown-ckUc3Q6q.js.map} +1 -1
  76. package/dist/{markdown-Bltb-uzO.cjs → markdown-pzqiRmft.cjs} +25 -29
  77. package/dist/{markdown-Bltb-uzO.cjs.map → markdown-pzqiRmft.cjs.map} +1 -1
  78. package/dist/{meriyah-Cz9whwp-.js → meriyah-BjnGqpUs.js} +21 -29
  79. package/dist/{meriyah-Cz9whwp-.js.map → meriyah-BjnGqpUs.js.map} +1 -1
  80. package/dist/{meriyah-CdG8HPS2.cjs → meriyah-D_x7itbT.cjs} +21 -29
  81. package/dist/{meriyah-CdG8HPS2.cjs.map → meriyah-D_x7itbT.cjs.map} +1 -1
  82. package/dist/mocks.cjs +87 -144
  83. package/dist/mocks.cjs.map +1 -1
  84. package/dist/mocks.d.cts +4 -3
  85. package/dist/mocks.d.ts +4 -3
  86. package/dist/mocks.js +83 -141
  87. package/dist/mocks.js.map +1 -1
  88. package/dist/{postcss-B7n9zUIy.cjs → postcss-B_c2wbFu.cjs} +41 -54
  89. package/dist/{postcss-B7n9zUIy.cjs.map → postcss-B_c2wbFu.cjs.map} +1 -1
  90. package/dist/{postcss-Dfx_9buT.js → postcss-v7BP6SZ-.js} +41 -54
  91. package/dist/{postcss-Dfx_9buT.js.map → postcss-v7BP6SZ-.js.map} +1 -1
  92. package/dist/{prompt-BMs_Y-vT.js → prompt-DBVnG4Me.js} +30 -32
  93. package/dist/{prompt-BMs_Y-vT.js.map → prompt-DBVnG4Me.js.map} +1 -1
  94. package/dist/{prompt-BXlYKArM.cjs → prompt-DgONOpPH.cjs} +29 -31
  95. package/dist/{prompt-BXlYKArM.cjs.map → prompt-DgONOpPH.cjs.map} +1 -1
  96. package/dist/{transformers-DZ22lE-S.cjs → transformers-BH0KLJJP.cjs} +130 -248
  97. package/dist/transformers-BH0KLJJP.cjs.map +1 -0
  98. package/dist/{transformers-BllSzdDt.js → transformers-DzHGqYO2.js} +130 -236
  99. package/dist/transformers-DzHGqYO2.js.map +1 -0
  100. package/dist/transformers.cjs +4 -3
  101. package/dist/transformers.js +2 -1
  102. package/dist/types-BzI9JlV8.d.ts +5 -0
  103. package/dist/types-C3ea5qNG.d.cts +5 -0
  104. package/dist/{PluginManager-BSUDeUfP.d.ts → types-DNxlynJr.d.cts} +187 -246
  105. package/dist/{PluginManager-a3RiDAFC.d.cts → types-DPeNK0FO.d.ts} +187 -246
  106. package/dist/{typescript-Evf8GXVW.cjs → typescript-6kMN6Wqz.cjs} +100 -152
  107. package/dist/{typescript-Evf8GXVW.cjs.map → typescript-6kMN6Wqz.cjs.map} +1 -1
  108. package/dist/{typescript-C8iCxnaF.js → typescript-B_IBfKSe.js} +101 -153
  109. package/dist/{typescript-C8iCxnaF.js.map → typescript-B_IBfKSe.js.map} +1 -1
  110. package/dist/typescript-C5hce4HG.cjs +4 -0
  111. package/dist/typescript-Cas1XcNz.js +3 -0
  112. package/dist/utils.cjs +165 -20
  113. package/dist/utils.cjs.map +1 -0
  114. package/dist/utils.d.cts +136 -5
  115. package/dist/utils.d.ts +136 -5
  116. package/dist/utils.js +156 -5
  117. package/dist/utils.js.map +1 -0
  118. package/dist/{write-O9QWtBJ_.js → write-CxO1CDML.js} +2 -2
  119. package/dist/{write-O9QWtBJ_.js.map → write-CxO1CDML.js.map} +1 -1
  120. package/dist/{yaml-Bi_nSoU_.js → yaml-BfWM_B73.js} +141 -157
  121. package/dist/{yaml-Bi_nSoU_.js.map → yaml-BfWM_B73.js.map} +1 -1
  122. package/dist/{yaml-B2qeXFgu.cjs → yaml-DZs6MhV1.cjs} +141 -157
  123. package/dist/{yaml-B2qeXFgu.cjs.map → yaml-DZs6MhV1.cjs.map} +1 -1
  124. package/package.json +15 -3
  125. package/src/FileManager.ts +34 -302
  126. package/src/PluginManager.ts +9 -8
  127. package/src/__snapshots__/barrel.json +5 -5
  128. package/src/build.ts +19 -5
  129. package/src/hooks/index.ts +3 -0
  130. package/src/hooks/useMode.ts +8 -0
  131. package/src/hooks/usePlugin.ts +8 -0
  132. package/src/hooks/usePluginManager.ts +8 -0
  133. package/src/index.ts +1 -2
  134. package/src/mocks/index.ts +4 -3
  135. package/src/plugin.ts +1 -1
  136. package/src/types.ts +4 -1
  137. package/src/utils/TreeNode.ts +3 -3
  138. package/src/utils/index.ts +2 -4
  139. package/dist/FileManager-B0V0rX5Z.js +0 -881
  140. package/dist/FileManager-B0V0rX5Z.js.map +0 -1
  141. package/dist/FileManager-COJW0Zp4.cjs +0 -1003
  142. package/dist/FileManager-COJW0Zp4.cjs.map +0 -1
  143. package/dist/index-B7KKQHG8.d.cts +0 -179
  144. package/dist/index-BhFFCWR1.d.ts +0 -179
  145. package/dist/transformers-BllSzdDt.js.map +0 -1
  146. package/dist/transformers-DZ22lE-S.cjs.map +0 -1
  147. package/dist/typescript-BY9-7pw9.js +0 -3
  148. package/dist/typescript-PxlX-TH7.cjs +0 -4
  149. package/src/utils/parser.ts +0 -199
@@ -1,3 +1,5 @@
1
+ import { n as __export } from "./chunk-1SJ2vVWa.js";
2
+
1
3
  //#region src/fs/clean.d.ts
2
4
  declare function clean(path: string): Promise<void>;
3
5
  //#endregion
@@ -19,6 +21,9 @@ type Options = {
19
21
  sanity?: boolean;
20
22
  };
21
23
  declare function write(path: string, data: string, options?: Options): Promise<string | undefined>;
24
+ declare namespace types_d_exports {
25
+ export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
26
+ }
22
27
  type BasePath<T extends string = string> = `${T}/`;
23
28
  type Import = {
24
29
  /**
@@ -136,5 +141,5 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
136
141
  //#region src/fs/index.d.ts
137
142
  declare function trimExtName(text: string): string;
138
143
  //#endregion
139
- export { BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, clean, exists, getRelativePath, read, readSync, trimExtName, types_d_exports, unlink, write };
140
- //# sourceMappingURL=index-CGJ3tdk-.d.ts.map
144
+ export { Mode as a, types_d_exports as c, unlink as d, read as f, clean as h, File as i, write as l, exists as m, BaseName as n, OptionalPath as o, readSync as p, Extname as r, ResolvedFile as s, trimExtName as t, getRelativePath as u };
145
+ //# sourceMappingURL=index-BTe91LHd.d.ts.map
@@ -20,6 +20,9 @@ type Options = {
20
20
  sanity?: boolean;
21
21
  };
22
22
  declare function write(path: string, data: string, options?: Options): Promise<string | undefined>;
23
+ declare namespace types_d_exports {
24
+ export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
25
+ }
23
26
  type BasePath<T extends string = string> = `${T}/`;
24
27
  type Import = {
25
28
  /**
@@ -137,5 +140,5 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
137
140
  //#region src/fs/index.d.ts
138
141
  declare function trimExtName(text: string): string;
139
142
  //#endregion
140
- export { BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, clean, exists, getRelativePath, read, readSync, trimExtName, types_d_exports, unlink, write };
141
- //# sourceMappingURL=index-CWX6_-da.d.cts.map
143
+ export { Mode as a, types_d_exports as c, unlink as d, read as f, clean as h, File as i, write as l, exists as m, BaseName as n, OptionalPath as o, readSync as p, Extname as r, ResolvedFile as s, trimExtName as t, getRelativePath as u };
144
+ //# sourceMappingURL=index-BmQIxvw0.d.cts.map
package/dist/index.cjs CHANGED
@@ -1,10 +1,11 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_chunk = require('./chunk-CZg_9w7l.cjs');
3
- const require_fs = require('./fs-Bi2kuxAm.cjs');
3
+ const require_fs = require('./fs-RSVoUw3S.cjs');
4
4
  require('./write-BJfM7G1_.cjs');
5
- const require_logger = require('./logger-DBJsdlpZ.cjs');
6
- const require_transformers = require('./transformers-DZ22lE-S.cjs');
7
- const require_FileManager = require('./FileManager-COJW0Zp4.cjs');
5
+ const require_logger = require('./logger-BXL0YCrv.cjs');
6
+ const require_transformers = require('./transformers-BH0KLJJP.cjs');
7
+ const require_URLPath = require('./URLPath-8WVzHBnA.cjs');
8
+ require('./casing-CP-9GGdK.cjs');
8
9
  let node_path = require("node:path");
9
10
  node_path = require_chunk.__toESM(node_path);
10
11
  let picocolors = require("picocolors");
@@ -13,6 +14,8 @@ let remeda = require("remeda");
13
14
  remeda = require_chunk.__toESM(remeda);
14
15
  let node_process = require("node:process");
15
16
  node_process = require_chunk.__toESM(node_process);
17
+ let __kubb_fabric_core = require("@kubb/fabric-core");
18
+ __kubb_fabric_core = require_chunk.__toESM(__kubb_fabric_core);
16
19
  let node_module = require("node:module");
17
20
  node_module = require_chunk.__toESM(node_module);
18
21
  let node_os = require("node:os");
@@ -63,6 +66,128 @@ function isInputPath(result) {
63
66
  return !!result && "path" in result?.input;
64
67
  }
65
68
 
69
+ //#endregion
70
+ //#region src/errors.ts
71
+ var ValidationPluginError = class extends Error {};
72
+
73
+ //#endregion
74
+ //#region ../../node_modules/.pnpm/yocto-queue@1.2.1/node_modules/yocto-queue/index.js
75
+ var Node = class {
76
+ value;
77
+ next;
78
+ constructor(value) {
79
+ this.value = value;
80
+ }
81
+ };
82
+ var Queue = class {
83
+ #head;
84
+ #tail;
85
+ #size;
86
+ constructor() {
87
+ this.clear();
88
+ }
89
+ enqueue(value) {
90
+ const node = new Node(value);
91
+ if (this.#head) {
92
+ this.#tail.next = node;
93
+ this.#tail = node;
94
+ } else {
95
+ this.#head = node;
96
+ this.#tail = node;
97
+ }
98
+ this.#size++;
99
+ }
100
+ dequeue() {
101
+ const current = this.#head;
102
+ if (!current) return;
103
+ this.#head = this.#head.next;
104
+ this.#size--;
105
+ return current.value;
106
+ }
107
+ peek() {
108
+ if (!this.#head) return;
109
+ return this.#head.value;
110
+ }
111
+ clear() {
112
+ this.#head = void 0;
113
+ this.#tail = void 0;
114
+ this.#size = 0;
115
+ }
116
+ get size() {
117
+ return this.#size;
118
+ }
119
+ *[Symbol.iterator]() {
120
+ let current = this.#head;
121
+ while (current) {
122
+ yield current.value;
123
+ current = current.next;
124
+ }
125
+ }
126
+ *drain() {
127
+ while (this.#head) yield this.dequeue();
128
+ }
129
+ };
130
+
131
+ //#endregion
132
+ //#region ../../node_modules/.pnpm/p-limit@7.2.0/node_modules/p-limit/index.js
133
+ function pLimit$1(concurrency) {
134
+ validateConcurrency(concurrency);
135
+ const queue = new Queue();
136
+ let activeCount = 0;
137
+ const resumeNext = () => {
138
+ if (activeCount < concurrency && queue.size > 0) {
139
+ activeCount++;
140
+ queue.dequeue()();
141
+ }
142
+ };
143
+ const next = () => {
144
+ activeCount--;
145
+ resumeNext();
146
+ };
147
+ const run = async (function_, resolve$1, arguments_) => {
148
+ const result = (async () => function_(...arguments_))();
149
+ resolve$1(result);
150
+ try {
151
+ await result;
152
+ } catch {}
153
+ next();
154
+ };
155
+ const enqueue = (function_, resolve$1, arguments_) => {
156
+ new Promise((internalResolve) => {
157
+ queue.enqueue(internalResolve);
158
+ }).then(run.bind(void 0, function_, resolve$1, arguments_));
159
+ if (activeCount < concurrency) resumeNext();
160
+ };
161
+ const generator = (function_, ...arguments_) => new Promise((resolve$1) => {
162
+ enqueue(function_, resolve$1, arguments_);
163
+ });
164
+ Object.defineProperties(generator, {
165
+ activeCount: { get: () => activeCount },
166
+ pendingCount: { get: () => queue.size },
167
+ clearQueue: { value() {
168
+ queue.clear();
169
+ } },
170
+ concurrency: {
171
+ get: () => concurrency,
172
+ set(newConcurrency) {
173
+ validateConcurrency(newConcurrency);
174
+ concurrency = newConcurrency;
175
+ queueMicrotask(() => {
176
+ while (activeCount < concurrency && queue.size > 0) resumeNext();
177
+ });
178
+ }
179
+ },
180
+ map: { async value(iterable, function_) {
181
+ const promises = Array.from(iterable, (value, index) => this(function_, value, index));
182
+ return Promise.all(promises);
183
+ } }
184
+ });
185
+ return generator;
186
+ }
187
+ function validateConcurrency(concurrency) {
188
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) throw new TypeError("Expected `concurrency` to be a number from 1 and up");
189
+ }
190
+
66
191
  //#endregion
67
192
  //#region src/utils/executeStrategies.ts
68
193
  /**
@@ -92,7 +217,7 @@ function hookFirst(promises, nullCheck = (state) => state !== null) {
92
217
  * Runs an array of promise functions with optional concurrency limit.
93
218
  */
94
219
  function hookParallel(promises, concurrency = Number.POSITIVE_INFINITY) {
95
- const limit = require_FileManager.pLimit(concurrency);
220
+ const limit = pLimit$1(concurrency);
96
221
  const tasks = promises.filter(Boolean).map((promise) => limit(() => promise()));
97
222
  return Promise.allSettled(tasks);
98
223
  }
@@ -116,10 +241,6 @@ function isPromiseRejectedResult(result) {
116
241
  return result.status === "rejected";
117
242
  }
118
243
 
119
- //#endregion
120
- //#region src/errors.ts
121
- var ValidationPluginError = class extends Error {};
122
-
123
244
  //#endregion
124
245
  //#region src/plugin.ts
125
246
  function createPlugin(factory) {
@@ -170,6 +291,9 @@ const pluginCore = createPlugin((options) => {
170
291
  //#region src/PluginManager.ts
171
292
  var PluginManager = class {
172
293
  plugins = /* @__PURE__ */ new Set();
294
+ /**
295
+ * @deprecated do not use from pluginManager
296
+ */
173
297
  fileManager;
174
298
  events = new require_logger.EventEmitter();
175
299
  config;
@@ -183,7 +307,7 @@ var PluginManager = class {
183
307
  this.config = config;
184
308
  this.options = options;
185
309
  this.logger = options.logger;
186
- this.fileManager = new require_FileManager.FileManager();
310
+ this.fileManager = new __kubb_fabric_core.FileManager();
187
311
  this.#promiseManager = new PromiseManager({ nullCheck: (state) => !!state?.result });
188
312
  const core = pluginCore({
189
313
  config,
@@ -201,8 +325,8 @@ var PluginManager = class {
201
325
  });
202
326
  return this;
203
327
  }
204
- getFile({ name, mode, extname, pluginKey, options }) {
205
- const baseName = `${name}${extname}`;
328
+ getFile({ name, mode, extname: extname$1, pluginKey, options }) {
329
+ const baseName = `${name}${extname$1}`;
206
330
  const path$3 = this.resolvePath({
207
331
  baseName,
208
332
  mode,
@@ -576,7 +700,7 @@ var PluginManager = class {
576
700
  }
577
701
  #parse(plugin, pluginManager, context) {
578
702
  const usedPluginNames = pluginManager.#usedPluginNames;
579
- require_FileManager.setUniqueName(plugin.name, usedPluginNames);
703
+ require_URLPath.setUniqueName(plugin.name, usedPluginNames);
580
704
  const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
581
705
  if (plugin.context && typeof plugin.context === "function") return {
582
706
  ...plugin,
@@ -615,7 +739,7 @@ async function setup(options) {
615
739
  const { config: userConfig, logger = require_logger.createLogger() } = options;
616
740
  if (Array.isArray(userConfig.input)) console.warn(picocolors.default.yellow("This feature is still under development — use with caution"));
617
741
  try {
618
- if (isInputPath(userConfig) && !new require_FileManager.URLPath(userConfig.input.path).isURL) await require_fs.exists(userConfig.input.path);
742
+ if (isInputPath(userConfig) && !new require_URLPath.URLPath(userConfig.input.path).isURL) await require_fs.exists(userConfig.input.path);
619
743
  } catch (e) {
620
744
  if (isInputPath(userConfig)) throw new Error(`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${userConfig.input.path}`, { cause: e });
621
745
  }
@@ -671,15 +795,13 @@ async function safeBuild(options) {
671
795
  message: "buildStart"
672
796
  });
673
797
  if (config.output.barrelType) {
674
- const root = (0, node_path.resolve)(config.root);
675
- const rootPath = (0, node_path.resolve)(root, config.output.path, "index.ts");
676
- const barrelFiles = (await pluginManager.fileManager.getFiles()).filter((file) => {
677
- return file.sources.some((source) => source.isIndexable);
678
- });
798
+ const rootPath = (0, node_path.resolve)((0, node_path.resolve)(config.root), config.output.path, "index.ts");
679
799
  const rootFile = {
680
800
  path: rootPath,
681
801
  baseName: "index.ts",
682
- exports: barrelFiles.flatMap((file) => {
802
+ exports: (await pluginManager.fileManager.files).filter((file) => {
803
+ return file.sources.some((source) => source.isIndexable);
804
+ }).flatMap((file) => {
683
805
  const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
684
806
  return file.sources?.map((source) => {
685
807
  if (!file.path || !source.isIndexable) return;
@@ -700,11 +822,27 @@ async function safeBuild(options) {
700
822
  };
701
823
  await pluginManager.fileManager.add(rootFile);
702
824
  }
703
- const files = await pluginManager.fileManager.processFiles({
704
- root: config.root,
825
+ pluginManager.fileManager.processor.on("start", ({ files: files$1 }) => {
826
+ pluginManager.logger.emit("progress_start", {
827
+ id: "files",
828
+ size: files$1.length,
829
+ message: "Writing files ..."
830
+ });
831
+ });
832
+ pluginManager.fileManager.processor.on("file:start", ({ file }) => {
833
+ const message = file ? `Writing ${(0, node_path.relative)(config.root, file.path)}` : "";
834
+ pluginManager.logger.emit("progressed", {
835
+ id: "files",
836
+ message
837
+ });
838
+ });
839
+ pluginManager.fileManager.processor.on("file:finish", () => {});
840
+ pluginManager.fileManager.processor.on("finish", () => {
841
+ pluginManager.logger.emit("progress_stop", { id: "files" });
842
+ });
843
+ const files = await pluginManager.fileManager.write({
705
844
  extension: config.output.extension,
706
- dryRun: !config.output.write,
707
- logger: pluginManager.logger
845
+ dryRun: !config.output.write
708
846
  });
709
847
  await pluginManager.hookParallel({
710
848
  hookName: "buildEnd",
@@ -724,11 +862,228 @@ async function safeBuild(options) {
724
862
  }
725
863
  }
726
864
 
865
+ //#endregion
866
+ //#region src/utils/TreeNode.ts
867
+ var TreeNode = class TreeNode {
868
+ data;
869
+ parent;
870
+ children = [];
871
+ #cachedLeaves = void 0;
872
+ constructor(data, parent) {
873
+ this.data = data;
874
+ this.parent = parent;
875
+ return this;
876
+ }
877
+ addChild(data) {
878
+ const child = new TreeNode(data, this);
879
+ if (!this.children) this.children = [];
880
+ this.children.push(child);
881
+ return child;
882
+ }
883
+ get root() {
884
+ if (!this.parent) return this;
885
+ return this.parent.root;
886
+ }
887
+ get leaves() {
888
+ if (!this.children || this.children.length === 0) return [this];
889
+ if (this.#cachedLeaves) return this.#cachedLeaves;
890
+ const leaves = [];
891
+ if (this.children) for (let i = 0, { length } = this.children; i < length; i++) leaves.push.apply(leaves, this.children[i].leaves);
892
+ this.#cachedLeaves = leaves;
893
+ return leaves;
894
+ }
895
+ forEach(callback) {
896
+ if (typeof callback !== "function") throw new TypeError("forEach() callback must be a function");
897
+ callback(this);
898
+ if (this.children) for (let i = 0, { length } = this.children; i < length; i++) this.children[i]?.forEach(callback);
899
+ return this;
900
+ }
901
+ findDeep(predicate) {
902
+ if (typeof predicate !== "function") throw new TypeError("find() predicate must be a function");
903
+ return this.leaves.find(predicate);
904
+ }
905
+ forEachDeep(callback) {
906
+ if (typeof callback !== "function") throw new TypeError("forEach() callback must be a function");
907
+ this.leaves.forEach(callback);
908
+ }
909
+ filterDeep(callback) {
910
+ if (typeof callback !== "function") throw new TypeError("filter() callback must be a function");
911
+ return this.leaves.filter(callback);
912
+ }
913
+ mapDeep(callback) {
914
+ if (typeof callback !== "function") throw new TypeError("map() callback must be a function");
915
+ return this.leaves.map(callback);
916
+ }
917
+ static build(files, root) {
918
+ try {
919
+ const filteredTree = buildDirectoryTree(files, root);
920
+ if (!filteredTree) return null;
921
+ const treeNode = new TreeNode({
922
+ name: filteredTree.name,
923
+ path: filteredTree.path,
924
+ file: filteredTree.file,
925
+ type: getMode(filteredTree.path)
926
+ });
927
+ const recurse = (node, item) => {
928
+ const subNode = node.addChild({
929
+ name: item.name,
930
+ path: item.path,
931
+ file: item.file,
932
+ type: getMode(item.path)
933
+ });
934
+ if (item.children?.length) item.children?.forEach((child) => {
935
+ recurse(subNode, child);
936
+ });
937
+ };
938
+ filteredTree.children?.forEach((child) => {
939
+ recurse(treeNode, child);
940
+ });
941
+ return treeNode;
942
+ } catch (e) {
943
+ throw new Error("Something went wrong with creating barrel files with the TreeNode class", { cause: e });
944
+ }
945
+ }
946
+ };
947
+ const normalizePath = (p) => p.replace(/\\/g, "/");
948
+ function buildDirectoryTree(files, rootFolder = "") {
949
+ const normalizedRootFolder = normalizePath(rootFolder);
950
+ const rootPrefix = normalizedRootFolder.endsWith("/") ? normalizedRootFolder : `${normalizedRootFolder}/`;
951
+ const filteredFiles = files.filter((file) => {
952
+ const normalizedFilePath = normalizePath(file.path);
953
+ return rootFolder ? normalizedFilePath.startsWith(rootPrefix) && !normalizedFilePath.endsWith(".json") : !normalizedFilePath.endsWith(".json");
954
+ });
955
+ if (filteredFiles.length === 0) return null;
956
+ const root = {
957
+ name: rootFolder || "",
958
+ path: rootFolder || "",
959
+ children: []
960
+ };
961
+ filteredFiles.forEach((file) => {
962
+ const parts = file.path.slice(rootFolder.length).split("/");
963
+ let currentLevel = root.children;
964
+ let currentPath = rootFolder;
965
+ parts.forEach((part, index) => {
966
+ if (index !== 0) currentPath += `/${part}`;
967
+ else currentPath += `${part}`;
968
+ let existingNode = currentLevel.find((node) => node.name === part);
969
+ if (!existingNode) {
970
+ if (index === parts.length - 1) existingNode = {
971
+ name: part,
972
+ file,
973
+ path: currentPath
974
+ };
975
+ else existingNode = {
976
+ name: part,
977
+ path: currentPath,
978
+ children: []
979
+ };
980
+ currentLevel.push(existingNode);
981
+ }
982
+ if (!existingNode.file) currentLevel = existingNode.children;
983
+ });
984
+ });
985
+ return root;
986
+ }
987
+
988
+ //#endregion
989
+ //#region src/BarrelManager.ts
990
+ var BarrelManager = class {
991
+ #options;
992
+ constructor(options = {}) {
993
+ this.#options = options;
994
+ return this;
995
+ }
996
+ getFiles({ files: generatedFiles, root }) {
997
+ const { logger } = this.#options;
998
+ const cachedFiles = /* @__PURE__ */ new Map();
999
+ TreeNode.build(generatedFiles, root)?.forEach((treeNode) => {
1000
+ if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) return;
1001
+ const barrelFile = {
1002
+ path: (0, node_path.join)(treeNode.parent?.data.path, "index.ts"),
1003
+ baseName: "index.ts",
1004
+ exports: [],
1005
+ sources: []
1006
+ };
1007
+ const previousBarrelFile = cachedFiles.get(barrelFile.path);
1008
+ treeNode.leaves.forEach((item) => {
1009
+ if (!item.data.name) return;
1010
+ const sources = item.data.file?.sources || [];
1011
+ if (!sources.some((source) => source.isIndexable)) logger?.emit("warning", `No isIndexable source found(source should have a name and isIndexable):\nFile: ${JSON.stringify(item.data.file, void 0, 2)}`);
1012
+ sources.forEach((source) => {
1013
+ if (!item.data.file?.path || !source.isIndexable || !source.name) return;
1014
+ if (previousBarrelFile?.sources.some((item$1) => item$1.name === source.name && item$1.isTypeOnly === source.isTypeOnly)) return;
1015
+ if (!barrelFile.exports) barrelFile.exports = [];
1016
+ if (!!treeNode.parent?.data.path?.split?.("/")?.length) barrelFile.exports.push({
1017
+ name: [source.name],
1018
+ path: require_fs.getRelativePath(treeNode.parent?.data.path, item.data.path),
1019
+ isTypeOnly: source.isTypeOnly
1020
+ });
1021
+ else barrelFile.exports.push({
1022
+ name: [source.name],
1023
+ path: `./${item.data.file.baseName}`,
1024
+ isTypeOnly: source.isTypeOnly
1025
+ });
1026
+ barrelFile.sources.push({
1027
+ name: source.name,
1028
+ isTypeOnly: source.isTypeOnly,
1029
+ value: "",
1030
+ isExportable: false,
1031
+ isIndexable: false
1032
+ });
1033
+ });
1034
+ });
1035
+ if (previousBarrelFile) {
1036
+ previousBarrelFile.sources.push(...barrelFile.sources);
1037
+ previousBarrelFile.exports?.push(...barrelFile.exports || []);
1038
+ } else cachedFiles.set(barrelFile.path, barrelFile);
1039
+ });
1040
+ return [...cachedFiles.values()];
1041
+ }
1042
+ };
1043
+
1044
+ //#endregion
1045
+ //#region src/FileManager.ts
1046
+ function getMode(path$3) {
1047
+ if (!path$3) return "split";
1048
+ return (0, node_path.extname)(path$3) ? "single" : "split";
1049
+ }
1050
+ async function getBarrelFiles(files, { type, meta = {}, root, output, logger }) {
1051
+ if (!type || type === "propagate") return [];
1052
+ const barrelManager = new BarrelManager({ logger });
1053
+ const pathToBuildFrom = (0, node_path.join)(root, output.path);
1054
+ if (require_fs.trimExtName(pathToBuildFrom).endsWith("index")) {
1055
+ logger?.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
1056
+ return [];
1057
+ }
1058
+ const barrelFiles = barrelManager.getFiles({
1059
+ files,
1060
+ root: pathToBuildFrom,
1061
+ meta
1062
+ });
1063
+ if (type === "all") return barrelFiles.map((file) => {
1064
+ return {
1065
+ ...file,
1066
+ exports: file.exports?.map((exportItem) => {
1067
+ return {
1068
+ ...exportItem,
1069
+ name: void 0
1070
+ };
1071
+ })
1072
+ };
1073
+ });
1074
+ return barrelFiles.map((indexFile) => {
1075
+ return {
1076
+ ...indexFile,
1077
+ meta
1078
+ };
1079
+ });
1080
+ }
1081
+
727
1082
  //#endregion
728
1083
  //#region ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
729
1084
  function pLimit(concurrency) {
730
1085
  if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) throw new TypeError("Expected `concurrency` to be a number from 1 and up");
731
- const queue = new require_FileManager.Queue();
1086
+ const queue = new Queue();
732
1087
  let activeCount = 0;
733
1088
  const next = () => {
734
1089
  activeCount--;
@@ -807,8 +1162,7 @@ async function locatePath(paths, { cwd = node_process.default.cwd(), type = "fil
807
1162
  const statFunction = allowSymlinks ? node_fs.promises.stat : node_fs.promises.lstat;
808
1163
  return pLocate(paths, async (path_) => {
809
1164
  try {
810
- const stat = await statFunction(node_path.default.resolve(cwd, path_));
811
- return matchType(type, stat);
1165
+ return matchType(type, await statFunction(node_path.default.resolve(cwd, path_)));
812
1166
  } catch {
813
1167
  return false;
814
1168
  }
@@ -992,7 +1346,6 @@ var PackageManager = class PackageManager {
992
1346
 
993
1347
  //#endregion
994
1348
  exports.BaseGenerator = BaseGenerator;
995
- exports.FileManager = require_FileManager.FileManager;
996
1349
  exports.PackageManager = PackageManager;
997
1350
  exports.PluginManager = PluginManager;
998
1351
  exports.PromiseManager = PromiseManager;
@@ -1000,8 +1353,8 @@ exports.build = build;
1000
1353
  exports.createPlugin = createPlugin;
1001
1354
  exports.default = build;
1002
1355
  exports.defineConfig = defineConfig;
1003
- exports.getDefaultBanner = require_FileManager.getDefaultBanner;
1004
- exports.getSource = require_FileManager.getSource;
1356
+ exports.getBarrelFiles = getBarrelFiles;
1357
+ exports.getMode = getMode;
1005
1358
  exports.isInputPath = isInputPath;
1006
1359
  exports.safeBuild = safeBuild;
1007
1360
  exports.setup = setup;