@kubb/core 3.0.0-alpha.3 → 3.0.0-alpha.4

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 (40) hide show
  1. package/dist/{FileManager-Bw-FNS3q.d.cts → FileManager--scIq4y4.d.cts} +26 -18
  2. package/dist/{FileManager-BW--rO8q.d.ts → FileManager-CaejIVBd.d.ts} +26 -18
  3. package/dist/{chunk-3OXCZ5DJ.js → chunk-EFQPHF4E.js} +29 -21
  4. package/dist/chunk-EFQPHF4E.js.map +1 -0
  5. package/dist/{chunk-LM2YQC3T.cjs → chunk-QRIDQ4RG.cjs} +38 -23
  6. package/dist/chunk-QRIDQ4RG.cjs.map +1 -0
  7. package/dist/{chunk-SA2GZKXS.js → chunk-UUBPTMRW.js} +49 -37
  8. package/dist/chunk-UUBPTMRW.js.map +1 -0
  9. package/dist/{chunk-ADC5UNZ5.cjs → chunk-V5THHXXQ.cjs} +259 -250
  10. package/dist/chunk-V5THHXXQ.cjs.map +1 -0
  11. package/dist/index.cjs +45 -127
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +4 -15
  14. package/dist/index.d.ts +4 -15
  15. package/dist/index.js +27 -102
  16. package/dist/index.js.map +1 -1
  17. package/dist/{logger-DChjnJMn.d.cts → logger-dzAcLeAA.d.cts} +12 -19
  18. package/dist/{logger-DChjnJMn.d.ts → logger-dzAcLeAA.d.ts} +12 -19
  19. package/dist/logger.cjs +3 -4
  20. package/dist/logger.cjs.map +1 -1
  21. package/dist/logger.d.cts +1 -2
  22. package/dist/logger.d.ts +1 -2
  23. package/dist/logger.js +2 -3
  24. package/dist/mocks.cjs +3 -3
  25. package/dist/mocks.cjs.map +1 -1
  26. package/dist/mocks.d.cts +2 -4
  27. package/dist/mocks.d.ts +2 -4
  28. package/dist/mocks.js +2 -2
  29. package/dist/mocks.js.map +1 -1
  30. package/package.json +7 -8
  31. package/src/FileManager.ts +62 -42
  32. package/src/PluginManager.ts +4 -20
  33. package/src/build.ts +23 -99
  34. package/src/errors.ts +0 -11
  35. package/src/index.ts +0 -1
  36. package/src/logger.ts +42 -33
  37. package/dist/chunk-3OXCZ5DJ.js.map +0 -1
  38. package/dist/chunk-ADC5UNZ5.cjs.map +0 -1
  39. package/dist/chunk-LM2YQC3T.cjs.map +0 -1
  40. package/dist/chunk-SA2GZKXS.js.map +0 -1
@@ -188,6 +188,214 @@ var require_eventemitter3 = _chunkXCPFG6DOcjs.__commonJS.call(void 0, {
188
188
  _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
189
189
  var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
190
190
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
191
+ var _remeda = require('remeda');
192
+ var _fs = require('@kubb/fs');
193
+
194
+ // src/BarrelManager.ts
195
+ _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
196
+ var _parserts = require('@kubb/parser-ts');
197
+
198
+
199
+ // src/utils/TreeNode.ts
200
+ _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
201
+ var _directorytree = require('directory-tree'); var _directorytree2 = _interopRequireDefault(_directorytree);
202
+ var TreeNode = class _TreeNode {
203
+ constructor(data, parent) {
204
+ this.children = [];
205
+ this.data = data;
206
+ this.parent = parent;
207
+ return this;
208
+ }
209
+ addChild(data) {
210
+ const child = new _TreeNode(data, this);
211
+ if (!this.children) {
212
+ this.children = [];
213
+ }
214
+ this.children.push(child);
215
+ return child;
216
+ }
217
+ find(data) {
218
+ if (!data) {
219
+ return null;
220
+ }
221
+ if (data === this.data) {
222
+ return this;
223
+ }
224
+ if (_optionalChain([this, 'access', _2 => _2.children, 'optionalAccess', _3 => _3.length])) {
225
+ for (let i = 0, { length } = this.children, target = null; i < length; i++) {
226
+ target = this.children[i].find(data);
227
+ if (target) {
228
+ return target;
229
+ }
230
+ }
231
+ }
232
+ return null;
233
+ }
234
+ get leaves() {
235
+ if (!this.children || this.children.length === 0) {
236
+ return [this];
237
+ }
238
+ const leaves = [];
239
+ if (this.children) {
240
+ for (let i = 0, { length } = this.children; i < length; i++) {
241
+ leaves.push.apply(leaves, this.children[i].leaves);
242
+ }
243
+ }
244
+ return leaves;
245
+ }
246
+ get root() {
247
+ if (!this.parent) {
248
+ return this;
249
+ }
250
+ return this.parent.root;
251
+ }
252
+ forEach(callback) {
253
+ if (typeof callback !== "function") {
254
+ throw new TypeError("forEach() callback must be a function");
255
+ }
256
+ callback(this);
257
+ if (this.children) {
258
+ for (let i = 0, { length } = this.children; i < length; i++) {
259
+ _optionalChain([this, 'access', _4 => _4.children, 'access', _5 => _5[i], 'optionalAccess', _6 => _6.forEach, 'call', _7 => _7(callback)]);
260
+ }
261
+ }
262
+ return this;
263
+ }
264
+ static build(path2, options = {}) {
265
+ try {
266
+ const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
267
+ const filteredTree = _directorytree2.default.call(void 0, path2, {
268
+ extensions: options.extensions,
269
+ exclude: [/node_modules/, ...exclude]
270
+ });
271
+ if (!filteredTree) {
272
+ return null;
273
+ }
274
+ const treeNode = new _TreeNode({
275
+ name: filteredTree.name,
276
+ path: filteredTree.path,
277
+ type: FileManager.getMode(filteredTree.path)
278
+ });
279
+ const recurse = (node, item) => {
280
+ const subNode = node.addChild({
281
+ name: item.name,
282
+ path: item.path,
283
+ type: FileManager.getMode(item.path)
284
+ });
285
+ if (_optionalChain([item, 'access', _8 => _8.children, 'optionalAccess', _9 => _9.length])) {
286
+ _optionalChain([item, 'access', _10 => _10.children, 'optionalAccess', _11 => _11.forEach, 'call', _12 => _12((child) => {
287
+ recurse(subNode, child);
288
+ })]);
289
+ }
290
+ };
291
+ _optionalChain([filteredTree, 'access', _13 => _13.children, 'optionalAccess', _14 => _14.forEach, 'call', _15 => _15((child) => recurse(treeNode, child))]);
292
+ return treeNode;
293
+ } catch (e) {
294
+ throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
295
+ }
296
+ }
297
+ };
298
+
299
+ // src/BarrelManager.ts
300
+ var _options;
301
+ var BarrelManager = class {
302
+ constructor(options = {}) {
303
+ _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _options);
304
+ _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _options, options);
305
+ return this;
306
+ }
307
+ getNamedExport(root, item) {
308
+ const exportedNames = _parserts.getExports.call(void 0, _path2.default.resolve(root, item.path));
309
+ if (!exportedNames) {
310
+ return [item];
311
+ }
312
+ return exportedNames.reduce(
313
+ (prev, curr) => {
314
+ if (!_optionalChain([prev, 'access', _16 => _16[0], 'optionalAccess', _17 => _17.name]) || !_optionalChain([prev, 'access', _18 => _18[1], 'optionalAccess', _19 => _19.name])) {
315
+ return prev;
316
+ }
317
+ if (curr.isTypeOnly) {
318
+ prev[1] = { ...prev[1], name: [...prev[1].name, curr.name] };
319
+ } else {
320
+ prev[0] = { ...prev[0], name: [...prev[0].name, curr.name] };
321
+ }
322
+ return prev;
323
+ },
324
+ [
325
+ {
326
+ ...item,
327
+ name: [],
328
+ isTypeOnly: false
329
+ },
330
+ {
331
+ ...item,
332
+ name: [],
333
+ isTypeOnly: true
334
+ }
335
+ ]
336
+ );
337
+ }
338
+ getNamedExports(root, exports) {
339
+ return _optionalChain([exports, 'optionalAccess', _20 => _20.flatMap, 'call', _21 => _21((item) => {
340
+ return this.getNamedExport(root, item);
341
+ })]);
342
+ }
343
+ getIndexes(root) {
344
+ const { treeNode = {}, isTypeOnly, extName } = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _options);
345
+ const tree = TreeNode.build(root, treeNode);
346
+ if (!tree) {
347
+ return null;
348
+ }
349
+ const fileReducer = (files, treeNode2) => {
350
+ if (!treeNode2.children) {
351
+ return [];
352
+ }
353
+ if (treeNode2.children.length > 1) {
354
+ const indexPath = _path2.default.resolve(treeNode2.data.path, "index.ts");
355
+ const exports = treeNode2.children.filter(Boolean).map((file) => {
356
+ const importPath = file.data.type === "split" ? `./${file.data.name}/index` : `./${_chunkPZT4CTBVcjs.trimExtName.call(void 0, file.data.name)}`;
357
+ if (importPath.endsWith("index") && file.data.type === "single") {
358
+ return void 0;
359
+ }
360
+ return {
361
+ path: extName ? `${importPath}${extName}` : importPath,
362
+ isTypeOnly
363
+ };
364
+ }).filter(Boolean);
365
+ files.push({
366
+ path: indexPath,
367
+ baseName: "index.ts",
368
+ source: "",
369
+ exports,
370
+ exportable: true
371
+ });
372
+ } else if (treeNode2.children.length === 1) {
373
+ const [treeNodeChild] = treeNode2.children;
374
+ const indexPath = _path2.default.resolve(treeNode2.data.path, "index.ts");
375
+ const importPath = treeNodeChild.data.type === "split" ? `./${treeNodeChild.data.name}/index` : `./${_chunkPZT4CTBVcjs.trimExtName.call(void 0, treeNodeChild.data.name)}`;
376
+ const exports = [
377
+ {
378
+ path: extName ? `${importPath}${extName}` : importPath,
379
+ isTypeOnly
380
+ }
381
+ ];
382
+ files.push({
383
+ path: indexPath,
384
+ baseName: "index.ts",
385
+ source: "",
386
+ exports,
387
+ exportable: true
388
+ });
389
+ }
390
+ treeNode2.children.forEach((childItem) => {
391
+ fileReducer(files, childItem);
392
+ });
393
+ return files;
394
+ };
395
+ return fileReducer([], tree).reverse();
396
+ }
397
+ };
398
+ _options = new WeakMap();
191
399
 
192
400
  // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
193
401
  _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
@@ -326,7 +534,7 @@ var PriorityQueue = class {
326
534
  }
327
535
  dequeue() {
328
536
  const item = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).shift();
329
- return _optionalChain([item, 'optionalAccess', _2 => _2.run]);
537
+ return _optionalChain([item, 'optionalAccess', _22 => _22.run]);
330
538
  }
331
539
  filter(options) {
332
540
  return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).filter((element) => element.priority === options.priority).map((element) => element.run);
@@ -375,10 +583,10 @@ var PQueue = class extends import_index.default {
375
583
  ...options
376
584
  };
377
585
  if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
378
- throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${_nullishCoalesce(_optionalChain([options, 'access', _3 => _3.intervalCap, 'optionalAccess', _4 => _4.toString, 'call', _5 => _5()]), () => ( ""))}\` (${typeof options.intervalCap})`);
586
+ throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${_nullishCoalesce(_optionalChain([options, 'access', _23 => _23.intervalCap, 'optionalAccess', _24 => _24.toString, 'call', _25 => _25()]), () => ( ""))}\` (${typeof options.intervalCap})`);
379
587
  }
380
588
  if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
381
- throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${_nullishCoalesce(_optionalChain([options, 'access', _6 => _6.interval, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]), () => ( ""))}\` (${typeof options.interval})`);
589
+ throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${_nullishCoalesce(_optionalChain([options, 'access', _26 => _26.interval, 'optionalAccess', _27 => _27.toString, 'call', _28 => _28()]), () => ( ""))}\` (${typeof options.interval})`);
382
590
  }
383
591
  _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _carryoverConcurrencyCount, options.carryoverConcurrencyCount);
384
592
  _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0);
@@ -412,7 +620,7 @@ var PQueue = class extends import_index.default {
412
620
  _chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _pending)._++;
413
621
  _chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _intervalCount)._++;
414
622
  try {
415
- _optionalChain([options, 'access', _9 => _9.signal, 'optionalAccess', _10 => _10.throwIfAborted, 'call', _11 => _11()]);
623
+ _optionalChain([options, 'access', _29 => _29.signal, 'optionalAccess', _30 => _30.throwIfAborted, 'call', _31 => _31()]);
416
624
  let operation = function_({ signal: options.signal });
417
625
  if (options.timeout) {
418
626
  operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
@@ -648,225 +856,11 @@ onEvent_fn = async function(event, filter) {
648
856
  };
649
857
 
650
858
  // src/FileManager.ts
651
- var _remeda = require('remeda');
652
- var _fs = require('@kubb/fs');
653
-
654
- // src/BarrelManager.ts
655
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
656
- var _parserts = require('@kubb/parser-ts');
657
-
658
-
659
- // src/utils/TreeNode.ts
660
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
661
- var _directorytree = require('directory-tree'); var _directorytree2 = _interopRequireDefault(_directorytree);
662
- var TreeNode = class _TreeNode {
663
- constructor(data, parent) {
664
- this.children = [];
665
- this.data = data;
666
- this.parent = parent;
667
- return this;
668
- }
669
- addChild(data) {
670
- const child = new _TreeNode(data, this);
671
- if (!this.children) {
672
- this.children = [];
673
- }
674
- this.children.push(child);
675
- return child;
676
- }
677
- find(data) {
678
- if (!data) {
679
- return null;
680
- }
681
- if (data === this.data) {
682
- return this;
683
- }
684
- if (_optionalChain([this, 'access', _12 => _12.children, 'optionalAccess', _13 => _13.length])) {
685
- for (let i = 0, { length } = this.children, target = null; i < length; i++) {
686
- target = this.children[i].find(data);
687
- if (target) {
688
- return target;
689
- }
690
- }
691
- }
692
- return null;
693
- }
694
- get leaves() {
695
- if (!this.children || this.children.length === 0) {
696
- return [this];
697
- }
698
- const leaves = [];
699
- if (this.children) {
700
- for (let i = 0, { length } = this.children; i < length; i++) {
701
- leaves.push.apply(leaves, this.children[i].leaves);
702
- }
703
- }
704
- return leaves;
705
- }
706
- get root() {
707
- if (!this.parent) {
708
- return this;
709
- }
710
- return this.parent.root;
711
- }
712
- forEach(callback) {
713
- if (typeof callback !== "function") {
714
- throw new TypeError("forEach() callback must be a function");
715
- }
716
- callback(this);
717
- if (this.children) {
718
- for (let i = 0, { length } = this.children; i < length; i++) {
719
- _optionalChain([this, 'access', _14 => _14.children, 'access', _15 => _15[i], 'optionalAccess', _16 => _16.forEach, 'call', _17 => _17(callback)]);
720
- }
721
- }
722
- return this;
723
- }
724
- static build(path2, options = {}) {
725
- try {
726
- const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
727
- const filteredTree = _directorytree2.default.call(void 0, path2, {
728
- extensions: options.extensions,
729
- exclude: [/node_modules/, ...exclude]
730
- });
731
- if (!filteredTree) {
732
- return null;
733
- }
734
- const treeNode = new _TreeNode({
735
- name: filteredTree.name,
736
- path: filteredTree.path,
737
- type: FileManager.getMode(filteredTree.path)
738
- });
739
- const recurse = (node, item) => {
740
- const subNode = node.addChild({
741
- name: item.name,
742
- path: item.path,
743
- type: FileManager.getMode(item.path)
744
- });
745
- if (_optionalChain([item, 'access', _18 => _18.children, 'optionalAccess', _19 => _19.length])) {
746
- _optionalChain([item, 'access', _20 => _20.children, 'optionalAccess', _21 => _21.forEach, 'call', _22 => _22((child) => {
747
- recurse(subNode, child);
748
- })]);
749
- }
750
- };
751
- _optionalChain([filteredTree, 'access', _23 => _23.children, 'optionalAccess', _24 => _24.forEach, 'call', _25 => _25((child) => recurse(treeNode, child))]);
752
- return treeNode;
753
- } catch (e) {
754
- throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
755
- }
756
- }
757
- };
758
-
759
- // src/BarrelManager.ts
760
- var _options;
761
- var BarrelManager = class {
762
- constructor(options = {}) {
763
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _options);
764
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _options, options);
765
- return this;
766
- }
767
- getNamedExport(root, item) {
768
- const exportedNames = _parserts.getExports.call(void 0, _path2.default.resolve(root, item.path));
769
- if (!exportedNames) {
770
- return [item];
771
- }
772
- return exportedNames.reduce(
773
- (prev, curr) => {
774
- if (!_optionalChain([prev, 'access', _26 => _26[0], 'optionalAccess', _27 => _27.name]) || !_optionalChain([prev, 'access', _28 => _28[1], 'optionalAccess', _29 => _29.name])) {
775
- return prev;
776
- }
777
- if (curr.isTypeOnly) {
778
- prev[1] = { ...prev[1], name: [...prev[1].name, curr.name] };
779
- } else {
780
- prev[0] = { ...prev[0], name: [...prev[0].name, curr.name] };
781
- }
782
- return prev;
783
- },
784
- [
785
- {
786
- ...item,
787
- name: [],
788
- isTypeOnly: false
789
- },
790
- {
791
- ...item,
792
- name: [],
793
- isTypeOnly: true
794
- }
795
- ]
796
- );
797
- }
798
- getNamedExports(root, exports) {
799
- return _optionalChain([exports, 'optionalAccess', _30 => _30.flatMap, 'call', _31 => _31((item) => {
800
- return this.getNamedExport(root, item);
801
- })]);
802
- }
803
- getIndexes(root) {
804
- const { treeNode = {}, isTypeOnly, extName } = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _options);
805
- const tree = TreeNode.build(root, treeNode);
806
- if (!tree) {
807
- return null;
808
- }
809
- const fileReducer = (files, treeNode2) => {
810
- if (!treeNode2.children) {
811
- return [];
812
- }
813
- if (treeNode2.children.length > 1) {
814
- const indexPath = _path2.default.resolve(treeNode2.data.path, "index.ts");
815
- const exports = treeNode2.children.filter(Boolean).map((file) => {
816
- const importPath = file.data.type === "split" ? `./${file.data.name}/index` : `./${_chunkPZT4CTBVcjs.trimExtName.call(void 0, file.data.name)}`;
817
- if (importPath.endsWith("index") && file.data.type === "single") {
818
- return void 0;
819
- }
820
- return {
821
- path: extName ? `${importPath}${extName}` : importPath,
822
- isTypeOnly
823
- };
824
- }).filter(Boolean);
825
- files.push({
826
- path: indexPath,
827
- baseName: "index.ts",
828
- source: "",
829
- exports,
830
- exportable: true
831
- });
832
- } else if (treeNode2.children.length === 1) {
833
- const [treeNodeChild] = treeNode2.children;
834
- const indexPath = _path2.default.resolve(treeNode2.data.path, "index.ts");
835
- const importPath = treeNodeChild.data.type === "split" ? `./${treeNodeChild.data.name}/index` : `./${_chunkPZT4CTBVcjs.trimExtName.call(void 0, treeNodeChild.data.name)}`;
836
- const exports = [
837
- {
838
- path: extName ? `${importPath}${extName}` : importPath,
839
- isTypeOnly
840
- }
841
- ];
842
- files.push({
843
- path: indexPath,
844
- baseName: "index.ts",
845
- source: "",
846
- exports,
847
- exportable: true
848
- });
849
- }
850
- treeNode2.children.forEach((childItem) => {
851
- fileReducer(files, childItem);
852
- });
853
- return files;
854
- };
855
- return fileReducer([], tree).reverse();
856
- }
857
- };
858
- _options = new WeakMap();
859
-
860
- // src/FileManager.ts
861
- var _cache, _task, _queue3, _FileManager_instances, add_fn, addOrAppend_fn;
859
+ var _cache, _FileManager_instances, add_fn, addOrAppend_fn;
862
860
  var _FileManager = class _FileManager {
863
- constructor({ task = async (file) => file, queue = new PQueue() } = {}) {
861
+ constructor() {
864
862
  _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _FileManager_instances);
865
863
  _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _cache, /* @__PURE__ */ new Map());
866
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _task);
867
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _queue3);
868
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _task, task);
869
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _queue3, queue);
870
864
  return this;
871
865
  }
872
866
  get files() {
@@ -876,9 +870,6 @@ var _FileManager = class _FileManager {
876
870
  });
877
871
  return files;
878
872
  }
879
- get isExecuting() {
880
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue3).size !== 0 && _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue3).pending !== 0;
881
- }
882
873
  async add(...files) {
883
874
  const promises = combineFiles(files).map((file) => {
884
875
  if (file.override) {
@@ -892,15 +883,15 @@ var _FileManager = class _FileManager {
892
883
  }
893
884
  return resolvedFiles[0];
894
885
  }
895
- async addIndexes({ root, output, meta, logger, options = {} }) {
886
+ async getIndexFiles({ root, output, meta, logger, options = {} }) {
896
887
  const { exportType = "barrel" } = output;
897
888
  if (exportType === false) {
898
- return void 0;
889
+ return [];
899
890
  }
900
891
  const pathToBuildFrom = _path.resolve.call(void 0, root, output.path);
901
892
  if (_chunkPZT4CTBVcjs.transformers_default.trimExtName(pathToBuildFrom).endsWith("index")) {
902
893
  logger.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
903
- return;
894
+ return [];
904
895
  }
905
896
  const exportPath = output.path.startsWith("./") ? _chunkPZT4CTBVcjs.trimExtName.call(void 0, output.path) : `./${_chunkPZT4CTBVcjs.trimExtName.call(void 0, output.path)}`;
906
897
  const mode = _FileManager.getMode(output.path);
@@ -910,7 +901,7 @@ var _FileManager = class _FileManager {
910
901
  });
911
902
  let files = barrelManager.getIndexes(pathToBuildFrom);
912
903
  if (!files) {
913
- return void 0;
904
+ return [];
914
905
  }
915
906
  if (exportType === "barrelNamed") {
916
907
  files = files.map((file) => {
@@ -923,14 +914,6 @@ var _FileManager = class _FileManager {
923
914
  return file;
924
915
  });
925
916
  }
926
- await Promise.all(
927
- files.map((file) => {
928
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, addOrAppend_fn).call(this, {
929
- ...file,
930
- meta: meta ? meta : file.meta
931
- });
932
- })
933
- );
934
917
  const rootPath = mode === "split" ? `${exportPath}/index${output.extName || ""}` : `${exportPath}${output.extName || ""}`;
935
918
  const rootFile = {
936
919
  path: _path.resolve.call(void 0, root, "index.ts"),
@@ -952,10 +935,20 @@ var _FileManager = class _FileManager {
952
935
  if (exportType === "barrelNamed" && !output.exportAs && _optionalChain([rootFile, 'access', _32 => _32.exports, 'optionalAccess', _33 => _33[0]])) {
953
936
  rootFile.exports = barrelManager.getNamedExport(root, rootFile.exports[0]);
954
937
  }
955
- await _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, addOrAppend_fn).call(this, {
956
- ...rootFile,
957
- meta: meta ? meta : rootFile.meta
958
- });
938
+ return [
939
+ ...await Promise.all(
940
+ files.map((file) => {
941
+ return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, addOrAppend_fn).call(this, {
942
+ ...file,
943
+ meta: meta ? meta : file.meta
944
+ });
945
+ })
946
+ ),
947
+ await _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, addOrAppend_fn).call(this, {
948
+ ...rootFile,
949
+ meta: meta ? meta : rootFile.meta
950
+ })
951
+ ];
959
952
  }
960
953
  getCacheByUUID(UUID) {
961
954
  let cache;
@@ -980,6 +973,9 @@ var _FileManager = class _FileManager {
980
973
  async read(...params) {
981
974
  return _fs.read.call(void 0, ...params);
982
975
  }
976
+ async processFiles(...params) {
977
+ return processFiles(...params);
978
+ }
983
979
  // statics
984
980
  static async getSource(file) {
985
981
  return getSource(file);
@@ -1001,8 +997,6 @@ var _FileManager = class _FileManager {
1001
997
  }
1002
998
  };
1003
999
  _cache = new WeakMap();
1004
- _task = new WeakMap();
1005
- _queue3 = new WeakMap();
1006
1000
  _FileManager_instances = new WeakSet();
1007
1001
  add_fn = async function(file) {
1008
1002
  const controller = new AbortController();
@@ -1022,13 +1016,7 @@ add_fn = async function(file) {
1022
1016
  });
1023
1017
  }
1024
1018
  _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
1025
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue3).add(
1026
- async () => {
1027
- var _a;
1028
- return (_a = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _task)) == null ? void 0 : _a.call(this, resolvedFile);
1029
- },
1030
- { signal: controller.signal }
1031
- );
1019
+ return resolvedFile;
1032
1020
  };
1033
1021
  addOrAppend_fn = async function(file) {
1034
1022
  const previousCaches = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).get(file.path);
@@ -1219,9 +1207,30 @@ function getEnvSource(source, env) {
1219
1207
  return prev;
1220
1208
  }, source);
1221
1209
  }
1210
+ var queue = new PQueue({ concurrency: 1 });
1211
+ async function processFiles({ dryRun, logger, files }) {
1212
+ const mergedFiles = await Promise.all(
1213
+ files.map(async (file) => ({
1214
+ ...file,
1215
+ source: await FileManager.getSource(file)
1216
+ }))
1217
+ );
1218
+ if (!dryRun) {
1219
+ _optionalChain([logger, 'access', _41 => _41.consola, 'optionalAccess', _42 => _42.pauseLogs, 'call', _43 => _43()]);
1220
+ const filePromises = mergedFiles.map(async (file, index) => {
1221
+ await queue.add(() => {
1222
+ logger.emit("progress", index, mergedFiles.length);
1223
+ return _fs.write.call(void 0, file.path, file.source, { sanity: false });
1224
+ });
1225
+ });
1226
+ await Promise.all(filePromises);
1227
+ _optionalChain([logger, 'access', _44 => _44.consola, 'optionalAccess', _45 => _45.resumeLogs, 'call', _46 => _46()]);
1228
+ }
1229
+ return mergedFiles;
1230
+ }
1222
1231
 
1223
1232
 
1224
1233
 
1225
1234
 
1226
- exports.PQueue = PQueue; exports.FileManager = FileManager;
1227
- //# sourceMappingURL=chunk-ADC5UNZ5.cjs.map
1235
+ exports.FileManager = FileManager; exports.processFiles = processFiles;
1236
+ //# sourceMappingURL=chunk-V5THHXXQ.cjs.map