@kubb/core 3.0.0-alpha.9 → 3.0.0-beta.2

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 (91) hide show
  1. package/README.md +14 -5
  2. package/dist/{FileManager-B0GJlthB.d.cts → FileManager-C9aZTwst.d.ts} +94 -77
  3. package/dist/{FileManager-BFycBDqG.d.ts → FileManager-ibNoWwHN.d.cts} +94 -77
  4. package/dist/chunk-2EU7DMPM.js +2 -3
  5. package/dist/chunk-2EU7DMPM.js.map +1 -1
  6. package/dist/{chunk-DID47EQD.cjs → chunk-2TOEDZ2U.cjs} +6 -7
  7. package/dist/chunk-2TOEDZ2U.cjs.map +1 -0
  8. package/dist/{chunk-A6PCLWEY.cjs → chunk-4GJEWGQN.cjs} +30 -31
  9. package/dist/chunk-4GJEWGQN.cjs.map +1 -0
  10. package/dist/{chunk-SEH6NUCX.cjs → chunk-72BWXKV4.cjs} +10 -10
  11. package/dist/chunk-72BWXKV4.cjs.map +1 -0
  12. package/dist/{chunk-4X5FFJPJ.js → chunk-BQXM32UO.js} +11 -16
  13. package/dist/chunk-BQXM32UO.js.map +1 -0
  14. package/dist/{chunk-27CPVXAT.js → chunk-DXGMSPTW.js} +174 -231
  15. package/dist/chunk-DXGMSPTW.js.map +1 -0
  16. package/dist/{chunk-SCR3LUXT.js → chunk-E6CN2CZC.js} +38 -27
  17. package/dist/chunk-E6CN2CZC.js.map +1 -0
  18. package/dist/chunk-HBQM723K.js +12 -26
  19. package/dist/chunk-HBQM723K.js.map +1 -1
  20. package/dist/{chunk-5E2I6KH4.cjs → chunk-KXT7F2WS.cjs} +54 -37
  21. package/dist/chunk-KXT7F2WS.cjs.map +1 -0
  22. package/dist/{chunk-IPZQXBA2.cjs → chunk-MVWRVN66.cjs} +57 -34
  23. package/dist/chunk-MVWRVN66.cjs.map +1 -0
  24. package/dist/{chunk-5IGANEGE.cjs → chunk-SQBOUPF4.cjs} +268 -301
  25. package/dist/chunk-SQBOUPF4.cjs.map +1 -0
  26. package/dist/index.cjs +223 -241
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +4 -6
  29. package/dist/index.d.ts +4 -6
  30. package/dist/index.js +106 -148
  31. package/dist/index.js.map +1 -1
  32. package/dist/{logger-BWFeedRk.d.cts → logger-DvbHXjIO.d.cts} +10 -8
  33. package/dist/{logger-BWFeedRk.d.ts → logger-DvbHXjIO.d.ts} +10 -8
  34. package/dist/logger.cjs +25 -14
  35. package/dist/logger.cjs.map +1 -1
  36. package/dist/logger.d.cts +1 -1
  37. package/dist/logger.d.ts +1 -1
  38. package/dist/logger.js +3 -13
  39. package/dist/logger.js.map +1 -1
  40. package/dist/mocks.cjs +29 -24
  41. package/dist/mocks.cjs.map +1 -1
  42. package/dist/mocks.d.cts +4 -3
  43. package/dist/mocks.d.ts +4 -3
  44. package/dist/mocks.js +22 -25
  45. package/dist/mocks.js.map +1 -1
  46. package/dist/{prompt-DVQN7JTN.cjs → prompt-FODZPXQF.cjs} +89 -89
  47. package/dist/prompt-FODZPXQF.cjs.map +1 -0
  48. package/dist/prompt-WQQUN22Z.js +8 -13
  49. package/dist/prompt-WQQUN22Z.js.map +1 -1
  50. package/dist/transformers.cjs +63 -52
  51. package/dist/transformers.cjs.map +1 -1
  52. package/dist/transformers.d.cts +1 -1
  53. package/dist/transformers.d.ts +1 -1
  54. package/dist/transformers.js +10 -37
  55. package/dist/transformers.js.map +1 -1
  56. package/dist/utils.cjs +65 -34
  57. package/dist/utils.cjs.map +1 -1
  58. package/dist/utils.d.cts +6 -8
  59. package/dist/utils.d.ts +6 -8
  60. package/dist/utils.js +3 -33
  61. package/dist/utils.js.map +1 -1
  62. package/package.json +10 -13
  63. package/src/BarrelManager.ts +76 -74
  64. package/src/FileManager.ts +55 -60
  65. package/src/PluginManager.ts +61 -61
  66. package/src/PromiseManager.ts +1 -1
  67. package/src/__snapshots__/barrel.json +11 -29
  68. package/src/__snapshots__/grouped.json +18 -12
  69. package/src/__snapshots__/ordered.json +18 -12
  70. package/src/build.ts +24 -11
  71. package/src/config.ts +2 -4
  72. package/src/index.ts +1 -1
  73. package/src/logger.ts +41 -7
  74. package/src/plugin.ts +0 -3
  75. package/src/transformers/escape.ts +0 -10
  76. package/src/transformers/stringify.ts +1 -1
  77. package/src/types.ts +70 -38
  78. package/src/utils/TreeNode.ts +31 -56
  79. package/src/utils/executeStrategies.ts +2 -2
  80. package/src/utils/parser.ts +38 -39
  81. package/dist/chunk-27CPVXAT.js.map +0 -1
  82. package/dist/chunk-4X5FFJPJ.js.map +0 -1
  83. package/dist/chunk-5E2I6KH4.cjs.map +0 -1
  84. package/dist/chunk-5IGANEGE.cjs.map +0 -1
  85. package/dist/chunk-A6PCLWEY.cjs.map +0 -1
  86. package/dist/chunk-DID47EQD.cjs.map +0 -1
  87. package/dist/chunk-IPZQXBA2.cjs.map +0 -1
  88. package/dist/chunk-SCR3LUXT.js.map +0 -1
  89. package/dist/chunk-SEH6NUCX.cjs.map +0 -1
  90. package/dist/prompt-DVQN7JTN.cjs.map +0 -1
  91. package/src/utils/cache.ts +0 -35
@@ -1,18 +1,21 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
1
+ 'use strict';
2
2
 
3
+ var chunk4GJEWGQN_cjs = require('./chunk-4GJEWGQN.cjs');
4
+ var chunk72BWXKV4_cjs = require('./chunk-72BWXKV4.cjs');
5
+ var path = require('path');
6
+ var fs = require('@kubb/fs');
7
+ var hash = require('object-hash');
8
+ var remeda = require('remeda');
3
9
 
4
- var _chunkA6PCLWEYcjs = require('./chunk-A6PCLWEY.cjs');
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
5
11
 
6
-
7
-
8
-
9
- var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
12
+ var path__default = /*#__PURE__*/_interopDefault(path);
13
+ var hash__default = /*#__PURE__*/_interopDefault(hash);
10
14
 
11
15
  // ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js
12
- var require_eventemitter3 = _chunkSEH6NUCXcjs.__commonJS.call(void 0, {
16
+ var require_eventemitter3 = chunk72BWXKV4_cjs.__commonJS({
13
17
  "../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
14
- "use strict";
15
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
18
+ chunk72BWXKV4_cjs.init_cjs_shims();
16
19
  var has = Object.prototype.hasOwnProperty;
17
20
  var prefix = "~";
18
21
  function Events() {
@@ -172,10 +175,10 @@ var require_eventemitter3 = _chunkSEH6NUCXcjs.__commonJS.call(void 0, {
172
175
  });
173
176
 
174
177
  // src/utils/index.ts
175
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
178
+ chunk72BWXKV4_cjs.init_cjs_shims();
176
179
 
177
180
  // src/utils/FunctionParams.ts
178
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
181
+ chunk72BWXKV4_cjs.init_cjs_shims();
179
182
  var FunctionParams = class _FunctionParams {
180
183
  #items = [];
181
184
  constructor() {
@@ -196,7 +199,7 @@ var FunctionParams = class _FunctionParams {
196
199
  return this;
197
200
  }
198
201
  static #orderItems(items) {
199
- return _chunkA6PCLWEYcjs.orderBy.call(void 0,
202
+ return chunk4GJEWGQN_cjs.orderBy(
200
203
  items.filter(Boolean),
201
204
  [
202
205
  (v) => {
@@ -209,7 +212,7 @@ var FunctionParams = class _FunctionParams {
209
212
  if (Array.isArray(v)) {
210
213
  return void 0;
211
214
  }
212
- return _nullishCoalesce(v.required, () => ( true));
215
+ return v.required ?? true;
213
216
  }
214
217
  ],
215
218
  ["desc", "desc"]
@@ -224,7 +227,7 @@ var FunctionParams = class _FunctionParams {
224
227
  acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
225
228
  return acc;
226
229
  }
227
- const parameterName = name.startsWith("{") ? name : _chunkA6PCLWEYcjs.camelCase.call(void 0, name);
230
+ const parameterName = name.startsWith("{") ? name : chunk4GJEWGQN_cjs.camelCase(name);
228
231
  if (type) {
229
232
  if (required) {
230
233
  acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
@@ -239,8 +242,8 @@ var FunctionParams = class _FunctionParams {
239
242
  static toObject(items) {
240
243
  let type = [];
241
244
  let name = [];
242
- const enabled = items.every((item) => item.enabled) ? _optionalChain([items, 'access', _ => _.at, 'call', _2 => _2(0), 'optionalAccess', _3 => _3.enabled]) : true;
243
- const required = _nullishCoalesce(items.every((item) => item.required), () => ( true));
245
+ const enabled = items.every((item) => item.enabled) ? items.at(0)?.enabled : true;
246
+ const required = items.every((item) => item.required) ?? true;
244
247
  items.forEach((item) => {
245
248
  name = _FunctionParams.#addParams(name, { ...item, type: void 0 });
246
249
  if (items.some((item2) => item2.type)) {
@@ -279,9 +282,9 @@ var FunctionParams = class _FunctionParams {
279
282
  };
280
283
 
281
284
  // src/utils/promise.ts
282
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
285
+ chunk72BWXKV4_cjs.init_cjs_shims();
283
286
  function isPromise(result) {
284
- return !!result && typeof _optionalChain([result, 'optionalAccess', _4 => _4.then]) === "function";
287
+ return !!result && typeof result?.then === "function";
285
288
  }
286
289
  function isPromiseFulfilledResult(result) {
287
290
  return result.status === "fulfilled";
@@ -291,14 +294,14 @@ function isPromiseRejectedResult(result) {
291
294
  }
292
295
 
293
296
  // src/utils/renderTemplate.ts
294
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
297
+ chunk72BWXKV4_cjs.init_cjs_shims();
295
298
  function renderTemplate(template, data = void 0) {
296
299
  if (!data || !Object.keys(data).length) {
297
300
  return template.replace(/{{(.*?)}}/g, "");
298
301
  }
299
302
  const matches = template.match(/{{(.*?)}}/g);
300
- return _optionalChain([matches, 'optionalAccess', _5 => _5.reduce, 'call', _6 => _6((prev, curr) => {
301
- const index = _optionalChain([curr, 'access', _7 => _7.split, 'call', _8 => _8(/{{|}}/), 'access', _9 => _9.filter, 'call', _10 => _10(Boolean), 'access', _11 => _11[0], 'optionalAccess', _12 => _12.trim, 'call', _13 => _13()]);
303
+ return matches?.reduce((prev, curr) => {
304
+ const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim();
302
305
  if (index === void 0) {
303
306
  return prev;
304
307
  }
@@ -312,11 +315,11 @@ function renderTemplate(template, data = void 0) {
312
315
  }
313
316
  return value || "";
314
317
  }).trim();
315
- }, template)]) || "";
318
+ }, template) || "";
316
319
  }
317
320
 
318
321
  // src/utils/timeout.ts
319
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
322
+ chunk72BWXKV4_cjs.init_cjs_shims();
320
323
  async function timeout(ms) {
321
324
  return new Promise((resolve) => {
322
325
  setTimeout(() => {
@@ -326,7 +329,7 @@ async function timeout(ms) {
326
329
  }
327
330
 
328
331
  // src/utils/uniqueName.ts
329
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
332
+ chunk72BWXKV4_cjs.init_cjs_shims();
330
333
  function getUniqueName(originalName, data) {
331
334
  let used = data[originalName] || 0;
332
335
  if (used) {
@@ -347,11 +350,11 @@ function setUniqueName(originalName, data) {
347
350
  }
348
351
 
349
352
  // src/utils/URLPath.ts
350
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
353
+ chunk72BWXKV4_cjs.init_cjs_shims();
351
354
  var URLPath = class {
352
-
353
- constructor(path) {
354
- this.path = path;
355
+ path;
356
+ constructor(path2) {
357
+ this.path = path2;
355
358
  return this;
356
359
  }
357
360
  /**
@@ -364,7 +367,7 @@ var URLPath = class {
364
367
  get isURL() {
365
368
  try {
366
369
  const url = new URL(this.path);
367
- if (_optionalChain([url, 'optionalAccess', _14 => _14.href])) {
370
+ if (url?.href) {
368
371
  return true;
369
372
  }
370
373
  } catch (error) {
@@ -415,7 +418,7 @@ var URLPath = class {
415
418
  let newPath = this.path.replaceAll("{", "${");
416
419
  if (found) {
417
420
  newPath = found.reduce((prev, curr) => {
418
- const pathParam = replacer ? replacer(_chunkA6PCLWEYcjs.camelCase.call(void 0, curr)) : _chunkA6PCLWEYcjs.camelCase.call(void 0, curr);
421
+ const pathParam = replacer ? replacer(chunk4GJEWGQN_cjs.camelCase(curr)) : chunk4GJEWGQN_cjs.camelCase(curr);
419
422
  const replacement = `\${${pathParam}}`;
420
423
  return prev.replace(curr, replacement);
421
424
  }, this.path);
@@ -431,7 +434,7 @@ var URLPath = class {
431
434
  const params = {};
432
435
  found.forEach((item) => {
433
436
  item = item.replaceAll("{", "").replaceAll("}", "");
434
- const pathParam = replacer ? replacer(_chunkA6PCLWEYcjs.camelCase.call(void 0, item)) : _chunkA6PCLWEYcjs.camelCase.call(void 0, item);
437
+ const pathParam = replacer ? replacer(chunk4GJEWGQN_cjs.camelCase(item)) : chunk4GJEWGQN_cjs.camelCase(item);
435
438
  params[pathParam] = pathParam;
436
439
  }, this.path);
437
440
  return params;
@@ -446,28 +449,22 @@ var URLPath = class {
446
449
  };
447
450
 
448
451
  // src/utils/parser.ts
449
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
450
- var _path = require('path');
451
- var _fs = require('@kubb/fs');
452
- var _objecthash = require('object-hash'); var _objecthash2 = _interopRequireDefault(_objecthash);
452
+ chunk72BWXKV4_cjs.init_cjs_shims();
453
453
 
454
454
  // src/FileManager.ts
455
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
456
-
457
- var _remeda = require('remeda');
458
-
455
+ chunk72BWXKV4_cjs.init_cjs_shims();
459
456
 
460
457
  // src/BarrelManager.ts
461
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
462
-
458
+ chunk72BWXKV4_cjs.init_cjs_shims();
463
459
 
464
460
  // src/utils/TreeNode.ts
465
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
466
- var TreeNode = (_class = class _TreeNode {
467
-
468
-
469
- __init() {this.children = []}
470
- constructor(data, parent) {;_class.prototype.__init.call(this);
461
+ chunk72BWXKV4_cjs.init_cjs_shims();
462
+ var TreeNode = class _TreeNode {
463
+ data;
464
+ parent;
465
+ children = [];
466
+ #cachedLeaves = void 0;
467
+ constructor(data, parent) {
471
468
  this.data = data;
472
469
  this.parent = parent;
473
470
  return this;
@@ -480,41 +477,28 @@ var TreeNode = (_class = class _TreeNode {
480
477
  this.children.push(child);
481
478
  return child;
482
479
  }
483
- find(data) {
484
- if (!data) {
485
- return null;
486
- }
487
- if (data === this.data) {
480
+ get root() {
481
+ if (!this.parent) {
488
482
  return this;
489
483
  }
490
- if (_optionalChain([this, 'access', _15 => _15.children, 'optionalAccess', _16 => _16.length])) {
491
- for (let i = 0, { length } = this.children, target = null; i < length; i++) {
492
- target = this.children[i].find(data);
493
- if (target) {
494
- return target;
495
- }
496
- }
497
- }
498
- return null;
484
+ return this.parent.root;
499
485
  }
500
486
  get leaves() {
501
487
  if (!this.children || this.children.length === 0) {
502
488
  return [this];
503
489
  }
490
+ if (this.#cachedLeaves) {
491
+ return this.#cachedLeaves;
492
+ }
504
493
  const leaves = [];
505
494
  if (this.children) {
506
495
  for (let i = 0, { length } = this.children; i < length; i++) {
507
496
  leaves.push.apply(leaves, this.children[i].leaves);
508
497
  }
509
498
  }
499
+ this.#cachedLeaves = leaves;
510
500
  return leaves;
511
501
  }
512
- get root() {
513
- if (!this.parent) {
514
- return this;
515
- }
516
- return this.parent.root;
517
- }
518
502
  forEach(callback) {
519
503
  if (typeof callback !== "function") {
520
504
  throw new TypeError("forEach() callback must be a function");
@@ -522,40 +506,34 @@ var TreeNode = (_class = class _TreeNode {
522
506
  callback(this);
523
507
  if (this.children) {
524
508
  for (let i = 0, { length } = this.children; i < length; i++) {
525
- _optionalChain([this, 'access', _17 => _17.children, 'access', _18 => _18[i], 'optionalAccess', _19 => _19.forEach, 'call', _20 => _20(callback)]);
509
+ this.children[i]?.forEach(callback);
526
510
  }
527
511
  }
528
512
  return this;
529
513
  }
530
- filter(callback) {
531
- let data = [];
514
+ findDeep(predicate) {
515
+ if (typeof predicate !== "function") {
516
+ throw new TypeError("find() predicate must be a function");
517
+ }
518
+ return this.leaves.find(predicate);
519
+ }
520
+ forEachDeep(callback) {
532
521
  if (typeof callback !== "function") {
533
522
  throw new TypeError("forEach() callback must be a function");
534
523
  }
535
- if (callback(this)) {
536
- data.push(this);
537
- }
538
- if (this.children) {
539
- for (let i = 0, { length } = this.children; i < length; i++) {
540
- const childData = _optionalChain([this, 'access', _21 => _21.children, 'access', _22 => _22[i], 'optionalAccess', _23 => _23.filter, 'call', _24 => _24(callback), 'access', _25 => _25.filter, 'call', _26 => _26(Boolean)]) || [];
541
- data = [.../* @__PURE__ */ new Set([...data, ...childData])];
542
- }
543
- }
544
- return data;
524
+ this.leaves.forEach(callback);
545
525
  }
546
- map(callback) {
547
- let data = [];
526
+ filterDeep(callback) {
548
527
  if (typeof callback !== "function") {
549
- throw new TypeError("forEach() callback must be a function");
528
+ throw new TypeError("filter() callback must be a function");
550
529
  }
551
- data.push(callback(this));
552
- if (this.children) {
553
- for (let i = 0, { length } = this.children; i < length; i++) {
554
- const childData = _optionalChain([this, 'access', _27 => _27.children, 'access', _28 => _28[i], 'optionalAccess', _29 => _29.map, 'call', _30 => _30(callback), 'access', _31 => _31.filter, 'call', _32 => _32(Boolean)]) || [];
555
- data = [.../* @__PURE__ */ new Set([...data, ...childData])];
556
- }
530
+ return this.leaves.filter(callback);
531
+ }
532
+ mapDeep(callback) {
533
+ if (typeof callback !== "function") {
534
+ throw new TypeError("map() callback must be a function");
557
535
  }
558
- return data;
536
+ return this.leaves.map(callback);
559
537
  }
560
538
  static build(files, root) {
561
539
  try {
@@ -576,19 +554,19 @@ var TreeNode = (_class = class _TreeNode {
576
554
  file: item.file,
577
555
  type: FileManager.getMode(item.path)
578
556
  });
579
- if (_optionalChain([item, 'access', _33 => _33.children, 'optionalAccess', _34 => _34.length])) {
580
- _optionalChain([item, 'access', _35 => _35.children, 'optionalAccess', _36 => _36.forEach, 'call', _37 => _37((child) => {
557
+ if (item.children?.length) {
558
+ item.children?.forEach((child) => {
581
559
  recurse(subNode, child);
582
- })]);
560
+ });
583
561
  }
584
562
  };
585
- _optionalChain([filteredTree, 'access', _38 => _38.children, 'optionalAccess', _39 => _39.forEach, 'call', _40 => _40((child) => recurse(treeNode, child))]);
563
+ filteredTree.children?.forEach((child) => recurse(treeNode, child));
586
564
  return treeNode;
587
565
  } catch (e) {
588
566
  throw new Error("Something went wrong with creating barrel files with the TreeNode class", { cause: e });
589
567
  }
590
568
  }
591
- }, _class);
569
+ };
592
570
  function buildDirectoryTree(files, rootFolder = "") {
593
571
  const rootPrefix = rootFolder.endsWith("/") ? rootFolder : `${rootFolder}/`;
594
572
  const filteredFiles = files.filter((file) => rootFolder ? file.path.startsWith(rootPrefix) && !file.path.endsWith(".json") : !file.path.endsWith(".json"));
@@ -601,8 +579,8 @@ function buildDirectoryTree(files, rootFolder = "") {
601
579
  children: []
602
580
  };
603
581
  filteredFiles.forEach((file) => {
604
- const path = file.path.slice(rootFolder.length);
605
- const parts = path.split("/");
582
+ const path2 = file.path.slice(rootFolder.length);
583
+ const parts = path2.split("/");
606
584
  let currentLevel = root.children;
607
585
  let currentPath = rootFolder;
608
586
  parts.forEach((part, index) => {
@@ -635,112 +613,107 @@ function buildDirectoryTree(files, rootFolder = "") {
635
613
  });
636
614
  return root;
637
615
  }
638
-
639
- // src/BarrelManager.ts
640
-
641
616
  var BarrelManager = class {
642
617
  #options;
643
618
  constructor(options = {}) {
644
619
  this.#options = options;
645
620
  return this;
646
621
  }
647
- getFiles(generatedFiles, root) {
622
+ getFiles({ files: generatedFiles, root, meta }) {
648
623
  const { logger } = this.#options;
649
- const files = /* @__PURE__ */ new Map();
650
- _optionalChain([TreeNode, 'access', _41 => _41.build, 'call', _42 => _42(generatedFiles, root), 'optionalAccess', _43 => _43.forEach, 'call', _44 => _44((treeNode) => {
651
- if (!treeNode || !treeNode.children || !_optionalChain([treeNode, 'access', _45 => _45.parent, 'optionalAccess', _46 => _46.data, 'access', _47 => _47.path])) {
624
+ const cachedFiles = /* @__PURE__ */ new Map();
625
+ logger?.emit("debug", { date: /* @__PURE__ */ new Date(), logs: [`Start barrel generation for pluginKey ${meta?.pluginKey?.join(".")} and root '${root}'`] });
626
+ TreeNode.build(generatedFiles, root)?.forEach((treeNode) => {
627
+ if (!treeNode || !treeNode.children || !treeNode.parent?.data.path) {
652
628
  return void 0;
653
629
  }
654
- const barrelPath = _path.join.call(void 0, _optionalChain([treeNode, 'access', _48 => _48.parent, 'optionalAccess', _49 => _49.data, 'access', _50 => _50.path]), "index.ts");
630
+ const barrelFile = {
631
+ path: path.join(treeNode.parent?.data.path, "index.ts"),
632
+ baseName: "index.ts",
633
+ exports: [],
634
+ sources: []
635
+ };
636
+ const previousBarrelFile = cachedFiles.get(barrelFile.path);
655
637
  const leaves = treeNode.leaves;
656
- const exports = leaves.map((item) => {
638
+ leaves.forEach((item) => {
657
639
  if (!item.data.name) {
658
640
  return void 0;
659
641
  }
660
- const sources = _optionalChain([item, 'access', _51 => _51.data, 'access', _52 => _52.file, 'optionalAccess', _53 => _53.sources]) || [];
642
+ const sources = item.data.file?.sources || [];
661
643
  if (!sources.some((source) => source.isIndexable)) {
662
- _optionalChain([logger, 'optionalAccess', _54 => _54.emit, 'call', _55 => _55(
644
+ logger?.emit(
663
645
  "warning",
664
646
  `No isIndexable source found(source should have a name and isIndexable):
665
647
  File: ${JSON.stringify(item.data.file, void 0, 2)}`
666
- )]);
648
+ );
667
649
  }
668
- return sources.map((source) => {
669
- if (!_optionalChain([item, 'access', _56 => _56.data, 'access', _57 => _57.file, 'optionalAccess', _58 => _58.path]) || !source.isIndexable) {
650
+ sources.forEach((source) => {
651
+ if (!item.data.file?.path || !source.isIndexable || !source.name) {
652
+ return void 0;
653
+ }
654
+ const alreadyContainInPreviousBarrelFile = previousBarrelFile?.sources.some((item2) => item2.name === source.name);
655
+ if (alreadyContainInPreviousBarrelFile) {
670
656
  return void 0;
671
657
  }
672
- const isSubExport = !!_optionalChain([treeNode, 'access', _59 => _59.parent, 'optionalAccess', _60 => _60.data, 'access', _61 => _61.path, 'optionalAccess', _62 => _62.split, 'optionalCall', _63 => _63("/"), 'optionalAccess', _64 => _64.length]);
658
+ if (!barrelFile.exports) {
659
+ barrelFile.exports = [];
660
+ }
661
+ const isSubExport = !!treeNode.parent?.data.path?.split?.("/")?.length;
673
662
  if (isSubExport) {
674
- return {
663
+ barrelFile.exports.push({
675
664
  name: [source.name],
676
- path: _fs.getRelativePath.call(void 0, _optionalChain([treeNode, 'access', _65 => _65.parent, 'optionalAccess', _66 => _66.data, 'access', _67 => _67.path]), item.data.path),
665
+ path: fs.getRelativePath(treeNode.parent?.data.path, item.data.path),
666
+ isTypeOnly: source.isTypeOnly
667
+ });
668
+ } else {
669
+ barrelFile.exports.push({
670
+ name: [source.name],
671
+ path: `./${item.data.file.baseName}`,
677
672
  isTypeOnly: source.isTypeOnly
678
- };
679
- }
680
- return {
681
- name: [source.name],
682
- path: `./${item.data.file.baseName}`,
683
- isTypeOnly: source.isTypeOnly
684
- };
685
- });
686
- }).flat().filter(Boolean);
687
- const barrelFile = {
688
- path: barrelPath,
689
- baseName: "index.ts",
690
- exports,
691
- sources: exports.flatMap((item) => {
692
- if (Array.isArray(item.name)) {
693
- return item.name.map((name) => {
694
- return {
695
- name,
696
- isTypeOnly: item.isTypeOnly,
697
- //TODO use parser to generate import
698
- value: "",
699
- isExportable: false,
700
- isIndexable: false
701
- };
702
673
  });
703
674
  }
704
- return [
705
- {
706
- name: item.name,
707
- isTypeOnly: item.isTypeOnly,
708
- //TODO use parser to generate import
709
- value: "",
710
- isExportable: false,
711
- isIndexable: false
712
- }
713
- ];
714
- })
715
- };
716
- const previousBarrelFile = files.get(barrelFile.path);
717
- if (previousBarrelFile) {
718
- files.set(barrelFile.path, {
719
- ...previousBarrelFile,
720
- ...barrelFile,
721
- exports: combineExports([...previousBarrelFile.exports || [], ...barrelFile.exports || []]),
722
- sources: combineSources([...previousBarrelFile.sources || [], ...barrelFile.sources || []])
675
+ barrelFile.sources.push({
676
+ name: source.name,
677
+ isTypeOnly: source.isTypeOnly,
678
+ //TODO use parser to generate import
679
+ value: "",
680
+ isExportable: false,
681
+ isIndexable: false
682
+ });
723
683
  });
684
+ });
685
+ logger?.emit("debug", {
686
+ date: /* @__PURE__ */ new Date(),
687
+ logs: [
688
+ `Generating barrelFile '${fs.getRelativePath(root, barrelFile.path)}' for '${fs.getRelativePath(root, treeNode.data?.path)}' with ${barrelFile.sources.length} indexable exports: '${barrelFile.sources?.map((source) => source.name).join(", ")}'`
689
+ ]
690
+ });
691
+ logger?.emit("debug", {
692
+ date: /* @__PURE__ */ new Date(),
693
+ logs: [
694
+ `Generated barrelFile '${fs.getRelativePath(root, barrelFile.path)}' for '${fs.getRelativePath(root, treeNode.data?.path)}' with exports: '${cachedFiles.get(barrelFile.path)?.sources?.map((source) => source.name).join(", ")}'`
695
+ ]
696
+ });
697
+ if (previousBarrelFile) {
698
+ previousBarrelFile.sources.push(...barrelFile.sources);
699
+ previousBarrelFile.exports?.push(...barrelFile.exports || []);
724
700
  } else {
725
- files.set(barrelFile.path, barrelFile);
701
+ cachedFiles.set(barrelFile.path, barrelFile);
726
702
  }
727
- })]);
728
- return [...files.values()];
703
+ });
704
+ return [...cachedFiles.values()];
729
705
  }
730
706
  };
731
707
 
732
- // src/FileManager.ts
733
-
734
-
735
708
  // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
736
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
709
+ chunk72BWXKV4_cjs.init_cjs_shims();
737
710
 
738
711
  // ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
739
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
740
- var import_index = _chunkSEH6NUCXcjs.__toESM.call(void 0, require_eventemitter3(), 1);
712
+ chunk72BWXKV4_cjs.init_cjs_shims();
713
+ var import_index = chunk72BWXKV4_cjs.__toESM(require_eventemitter3(), 1);
741
714
 
742
715
  // ../../node_modules/.pnpm/p-timeout@6.1.2/node_modules/p-timeout/index.js
743
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
716
+ chunk72BWXKV4_cjs.init_cjs_shims();
744
717
  var TimeoutError = class extends Error {
745
718
  constructor(message) {
746
719
  super(message);
@@ -802,7 +775,7 @@ function pTimeout(promise, options) {
802
775
  } else if (message instanceof Error) {
803
776
  reject(message);
804
777
  } else {
805
- timeoutError.message = _nullishCoalesce(message, () => ( `Promise timed out after ${milliseconds} milliseconds`));
778
+ timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
806
779
  reject(timeoutError);
807
780
  }
808
781
  }, milliseconds);
@@ -825,10 +798,10 @@ function pTimeout(promise, options) {
825
798
  }
826
799
 
827
800
  // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/priority-queue.js
828
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
801
+ chunk72BWXKV4_cjs.init_cjs_shims();
829
802
 
830
803
  // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/lower-bound.js
831
- _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
804
+ chunk72BWXKV4_cjs.init_cjs_shims();
832
805
  function lowerBound(array, value, comparator) {
833
806
  let first = 0;
834
807
  let count = array.length;
@@ -866,7 +839,7 @@ var PriorityQueue = class {
866
839
  }
867
840
  dequeue() {
868
841
  const item = this.#queue.shift();
869
- return _optionalChain([item, 'optionalAccess', _68 => _68.run]);
842
+ return item?.run;
870
843
  }
871
844
  filter(options) {
872
845
  return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);
@@ -898,7 +871,7 @@ var PQueue = class extends import_index.default {
898
871
 
899
872
  Applies to each future operation.
900
873
  */
901
-
874
+ timeout;
902
875
  // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
903
876
  constructor(options) {
904
877
  super();
@@ -912,10 +885,10 @@ var PQueue = class extends import_index.default {
912
885
  ...options
913
886
  };
914
887
  if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
915
- throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${_nullishCoalesce(_optionalChain([options, 'access', _69 => _69.intervalCap, 'optionalAccess', _70 => _70.toString, 'call', _71 => _71()]), () => ( ""))}\` (${typeof options.intervalCap})`);
888
+ throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${options.intervalCap?.toString() ?? ""}\` (${typeof options.intervalCap})`);
916
889
  }
917
890
  if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
918
- throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${_nullishCoalesce(_optionalChain([options, 'access', _72 => _72.interval, 'optionalAccess', _73 => _73.toString, 'call', _74 => _74()]), () => ( ""))}\` (${typeof options.interval})`);
891
+ throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${options.interval?.toString() ?? ""}\` (${typeof options.interval})`);
919
892
  }
920
893
  this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;
921
894
  this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
@@ -1042,7 +1015,7 @@ var PQueue = class extends import_index.default {
1042
1015
  this.#pending++;
1043
1016
  this.#intervalCount++;
1044
1017
  try {
1045
- _optionalChain([options, 'access', _75 => _75.signal, 'optionalAccess', _76 => _76.throwIfAborted, 'call', _77 => _77()]);
1018
+ options.signal?.throwIfAborted();
1046
1019
  let operation = function_({ signal: options.signal });
1047
1020
  if (options.timeout) {
1048
1021
  operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
@@ -1172,27 +1145,29 @@ var PQueue = class extends import_index.default {
1172
1145
  // src/FileManager.ts
1173
1146
  var FileManager = class {
1174
1147
  #filesByPath = /* @__PURE__ */ new Map();
1175
- #files = /* @__PURE__ */ new Set();
1176
1148
  constructor() {
1177
1149
  return this;
1178
1150
  }
1179
1151
  get files() {
1180
- return Array.from(this.#files);
1152
+ return [...this.#filesByPath.values()];
1181
1153
  }
1182
1154
  get orderedFiles() {
1183
- return _chunkA6PCLWEYcjs.orderBy.call(void 0, Array.from(this.#files), [
1184
- (v) => _optionalChain([v, 'optionalAccess', _78 => _78.meta]) && "pluginKey" in v.meta && !v.meta.pluginKey,
1185
- (v) => v.path.length,
1186
- (v) => _fs.trimExtName.call(void 0, v.path).endsWith("index"),
1187
- (v) => _fs.trimExtName.call(void 0, v.baseName),
1188
- (v) => v.path.split(".").pop()
1189
- ]);
1155
+ return chunk4GJEWGQN_cjs.orderBy(
1156
+ [...this.#filesByPath.values()],
1157
+ [
1158
+ (v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
1159
+ (v) => v.path.length,
1160
+ (v) => fs.trimExtName(v.path).endsWith("index"),
1161
+ (v) => fs.trimExtName(v.baseName),
1162
+ (v) => v.path.split(".").pop()
1163
+ ]
1164
+ );
1190
1165
  }
1191
1166
  get groupedFiles() {
1192
- return buildDirectoryTree(Array.from(this.#files));
1167
+ return buildDirectoryTree([...this.#filesByPath.values()]);
1193
1168
  }
1194
1169
  get treeNode() {
1195
- return TreeNode.build(Array.from(this.#files));
1170
+ return TreeNode.build([...this.#filesByPath.values()]);
1196
1171
  }
1197
1172
  async add(...files) {
1198
1173
  const promises = files.map((file) => {
@@ -1210,64 +1185,53 @@ var FileManager = class {
1210
1185
  async #add(file) {
1211
1186
  const resolvedFile = createFile(file);
1212
1187
  this.#filesByPath.set(resolvedFile.path, resolvedFile);
1213
- this.#files.add(resolvedFile);
1214
1188
  return resolvedFile;
1215
1189
  }
1216
1190
  clear() {
1217
1191
  this.#filesByPath.clear();
1218
- this.#files.clear();
1219
1192
  }
1220
1193
  async #addOrAppend(file) {
1221
1194
  const previousFile = this.#filesByPath.get(file.path);
1222
1195
  if (previousFile) {
1223
1196
  this.#filesByPath.delete(previousFile.path);
1224
- this.#files.delete(previousFile);
1225
1197
  return this.#add(mergeFile(previousFile, file));
1226
1198
  }
1227
1199
  return this.#add(file);
1228
1200
  }
1229
1201
  getCacheById(id) {
1230
- let cache;
1231
- this.#files.forEach((file) => {
1232
- if (file.id === id) {
1233
- cache = file;
1234
- }
1235
- });
1236
- return cache;
1202
+ return [...this.#filesByPath.values()].find((file) => file.id === id);
1237
1203
  }
1238
- getByPath(path) {
1239
- return this.#filesByPath.get(path);
1204
+ getByPath(path2) {
1205
+ return this.#filesByPath.get(path2);
1240
1206
  }
1241
- deleteByPath(path) {
1242
- const cacheItem = this.getByPath(path);
1207
+ deleteByPath(path2) {
1208
+ const cacheItem = this.getByPath(path2);
1243
1209
  if (!cacheItem) {
1244
1210
  return;
1245
1211
  }
1246
- this.#filesByPath.delete(path);
1247
- this.#files.delete(cacheItem);
1212
+ this.#filesByPath.delete(path2);
1248
1213
  }
1249
- async getBarrelFiles({ files, meta, root, output, logger }) {
1250
- const { exportType = "barrelNamed" } = output;
1251
- const barrelManager = new BarrelManager({ logger });
1252
- if (exportType === false) {
1214
+ async getBarrelFiles({ type, files, meta = {}, root, output, logger }) {
1215
+ if (!type) {
1253
1216
  return [];
1254
1217
  }
1255
- const pathToBuildFrom = _path.join.call(void 0, root, output.path);
1256
- if (_fs.trimExtName.call(void 0, pathToBuildFrom).endsWith("index")) {
1257
- _optionalChain([logger, 'optionalAccess', _79 => _79.emit, 'call', _80 => _80("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation")]);
1218
+ const barrelManager = new BarrelManager({ logger });
1219
+ const pathToBuildFrom = path.join(root, output.path);
1220
+ if (fs.trimExtName(pathToBuildFrom).endsWith("index")) {
1221
+ logger?.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
1258
1222
  return [];
1259
1223
  }
1260
- const barrelFiles = barrelManager.getFiles(files, pathToBuildFrom);
1261
- if (exportType === "barrel") {
1224
+ const barrelFiles = barrelManager.getFiles({ files, root: pathToBuildFrom, meta });
1225
+ if (type === "all") {
1262
1226
  return barrelFiles.map((file) => {
1263
1227
  return {
1264
1228
  ...file,
1265
- exports: _optionalChain([file, 'access', _81 => _81.exports, 'optionalAccess', _82 => _82.map, 'call', _83 => _83((exportItem) => {
1229
+ exports: file.exports?.map((exportItem) => {
1266
1230
  return {
1267
1231
  ...exportItem,
1268
1232
  name: void 0
1269
1233
  };
1270
- })])
1234
+ })
1271
1235
  };
1272
1236
  });
1273
1237
  }
@@ -1279,22 +1243,23 @@ var FileManager = class {
1279
1243
  });
1280
1244
  }
1281
1245
  async write(...params) {
1282
- return _fs.write.call(void 0, ...params);
1246
+ return fs.write(...params);
1283
1247
  }
1284
1248
  async read(...params) {
1285
- return _fs.read.call(void 0, ...params);
1249
+ return fs.read(...params);
1286
1250
  }
1287
1251
  // statics
1288
- static getMode(path) {
1289
- if (!path) {
1252
+ static getMode(path2) {
1253
+ if (!path2) {
1290
1254
  return "split";
1291
1255
  }
1292
- return _path.extname.call(void 0, path) ? "single" : "split";
1256
+ return path.extname(path2) ? "single" : "split";
1293
1257
  }
1294
1258
  };
1295
- async function getSource(file, { logger } = {}) {
1296
- const parser = await getFileParser(file.extName);
1297
- return parser.print(file, { logger });
1259
+ async function getSource(file, { logger, extname: extname2 } = {}) {
1260
+ const parser = await getFileParser(file.extname);
1261
+ const source = await parser.print(file, { logger, extname: extname2 });
1262
+ return parser.format(source);
1298
1263
  }
1299
1264
  function mergeFile(a, b) {
1300
1265
  return {
@@ -1307,7 +1272,7 @@ function mergeFile(a, b) {
1307
1272
  function combineSources(sources) {
1308
1273
  return sources.reduce(
1309
1274
  (prev, curr) => {
1310
- const prevByName = prev.findLast((imp) => imp.name === curr.name);
1275
+ const prevByName = prev.findLast((imp) => imp.name && imp.name === curr.name);
1311
1276
  const prevByPathAndIsExportable = prev.findLast((imp) => imp.name === curr.name && imp.isExportable);
1312
1277
  if (prevByPathAndIsExportable) {
1313
1278
  return [...prev, curr];
@@ -1325,18 +1290,24 @@ function combineSources(sources) {
1325
1290
  );
1326
1291
  }
1327
1292
  function combineExports(exports) {
1328
- const combinedExports = exports.reduce(
1293
+ return chunk4GJEWGQN_cjs.orderBy(exports, [
1294
+ (v) => !!Array.isArray(v.name),
1295
+ (v) => !v.isTypeOnly,
1296
+ (v) => v.path,
1297
+ (v) => !!v.name,
1298
+ (v) => Array.isArray(v.name) ? chunk4GJEWGQN_cjs.orderBy(v.name) : v.name
1299
+ ]).reduce(
1329
1300
  (prev, curr) => {
1330
1301
  const name = curr.name;
1331
1302
  const prevByPath = prev.findLast((imp) => imp.path === curr.path);
1332
- const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly);
1303
+ const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && remeda.isDeepEqual(imp.name, name) && imp.isTypeOnly);
1333
1304
  if (prevByPathAndIsTypeOnly) {
1334
1305
  return prev;
1335
1306
  }
1336
1307
  const uniquePrev = prev.findLast(
1337
- (imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
1308
+ (imp) => imp.path === curr.path && remeda.isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
1338
1309
  );
1339
- if (uniquePrev || Array.isArray(name) && !name.length || _optionalChain([prevByPath, 'optionalAccess', _84 => _84.asAlias]) && !curr.asAlias) {
1310
+ if (uniquePrev || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) {
1340
1311
  return prev;
1341
1312
  }
1342
1313
  if (!prevByPath) {
@@ -1356,23 +1327,24 @@ function combineExports(exports) {
1356
1327
  },
1357
1328
  []
1358
1329
  );
1359
- return _chunkA6PCLWEYcjs.orderBy.call(void 0, combinedExports, [
1330
+ }
1331
+ function combineImports(imports, exports, source) {
1332
+ return chunk4GJEWGQN_cjs.orderBy(imports, [
1360
1333
  (v) => !!Array.isArray(v.name),
1361
1334
  (v) => !v.isTypeOnly,
1362
1335
  (v) => v.path,
1363
1336
  (v) => !!v.name,
1364
- (v) => Array.isArray(v.name) ? _chunkA6PCLWEYcjs.orderBy.call(void 0, v.name) : v.name
1365
- ]);
1366
- }
1367
- function combineImports(imports, exports, source) {
1368
- const combinedImports = imports.reduce(
1337
+ (v) => Array.isArray(v.name) ? chunk4GJEWGQN_cjs.orderBy(v.name) : v.name
1338
+ ]).reduce(
1369
1339
  (prev, curr) => {
1370
1340
  let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
1371
1341
  const hasImportInSource = (importName) => {
1372
1342
  if (!source) {
1373
1343
  return true;
1374
1344
  }
1375
- const checker = (name2) => name2 && !!source.includes(name2);
1345
+ const checker = (name2) => {
1346
+ return name2 && !!source.includes(name2);
1347
+ };
1376
1348
  return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
1377
1349
  };
1378
1350
  if (curr.path === curr.root) {
@@ -1382,8 +1354,8 @@ function combineImports(imports, exports, source) {
1382
1354
  name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
1383
1355
  }
1384
1356
  const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
1385
- const uniquePrev = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
1386
- const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly);
1357
+ const uniquePrev = prev.findLast((imp) => imp.path === curr.path && remeda.isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
1358
+ const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && remeda.isDeepEqual(imp.name, name) && imp.isTypeOnly);
1387
1359
  if (prevByPathNameAndIsTypeOnly) {
1388
1360
  return prev;
1389
1361
  }
@@ -1410,34 +1382,29 @@ function combineImports(imports, exports, source) {
1410
1382
  },
1411
1383
  []
1412
1384
  );
1413
- return _chunkA6PCLWEYcjs.orderBy.call(void 0, combinedImports, [
1414
- (v) => !!Array.isArray(v.name),
1415
- (v) => !v.isTypeOnly,
1416
- (v) => v.path,
1417
- (v) => !!v.name,
1418
- (v) => Array.isArray(v.name) ? _chunkA6PCLWEYcjs.orderBy.call(void 0, v.name) : v.name
1419
- ]);
1420
1385
  }
1421
1386
  var queue = new PQueue({ concurrency: 100 });
1422
1387
  async function processFiles({ dryRun, config, logger, files }) {
1423
- const orderedFiles = _chunkA6PCLWEYcjs.orderBy.call(void 0, files, [
1424
- (v) => _optionalChain([v, 'optionalAccess', _85 => _85.meta]) && "pluginKey" in v.meta && !v.meta.pluginKey,
1388
+ const orderedFiles = chunk4GJEWGQN_cjs.orderBy(files, [
1389
+ (v) => v?.meta && "pluginKey" in v.meta && !v.meta.pluginKey,
1425
1390
  (v) => v.path.length,
1426
- (v) => _fs.trimExtName.call(void 0, v.path).endsWith("index")
1391
+ (v) => fs.trimExtName(v.path).endsWith("index")
1427
1392
  ]);
1428
1393
  logger.emit("debug", {
1394
+ date: /* @__PURE__ */ new Date(),
1429
1395
  logs: [JSON.stringify({ files: orderedFiles }, null, 2)],
1430
- fileName: "kubb-files.json",
1431
- override: true
1396
+ fileName: "kubb-files.log"
1432
1397
  });
1433
1398
  if (!dryRun) {
1434
1399
  const size = orderedFiles.length;
1435
- logger.emit("progress_start", { id: "files", size });
1400
+ logger.emit("progress_start", { id: "files", size, message: "Writing files ..." });
1436
1401
  const promises = orderedFiles.map(async (file) => {
1437
1402
  await queue.add(async () => {
1438
- const source = await getSource(file, { logger });
1439
- await _fs.write.call(void 0, file.path, source, { sanity: false });
1440
- logger.emit("progress", { id: "files", data: file ? _path.relative.call(void 0, config.root, file.path) : "" });
1403
+ const message = file ? `Writing ${path.relative(config.root, file.path)}` : "";
1404
+ const extname2 = config.output.extension?.[file.extname];
1405
+ const source = await getSource(file, { logger, extname: extname2 });
1406
+ await fs.write(file.path, source, { sanity: false });
1407
+ logger.emit("progressed", { id: "files", message });
1441
1408
  });
1442
1409
  });
1443
1410
  await Promise.all(promises);
@@ -1448,9 +1415,9 @@ async function processFiles({ dryRun, config, logger, files }) {
1448
1415
 
1449
1416
  // src/utils/parser.ts
1450
1417
  function createFile(file) {
1451
- const extName = _path.extname.call(void 0, file.baseName);
1452
- if (!extName) {
1453
- throw new Error(`No extName found for ${file.baseName}`);
1418
+ const extname2 = path__default.default.extname(file.baseName);
1419
+ if (!extname2) {
1420
+ throw new Error(`No extname found for ${file.baseName}`);
1454
1421
  }
1455
1422
  const source = file.sources.map((item) => item.value).join("\n\n");
1456
1423
  const exports = file.exports ? combineExports(file.exports) : [];
@@ -1458,65 +1425,66 @@ function createFile(file) {
1458
1425
  const sources = file.sources ? combineSources(file.sources) : [];
1459
1426
  return {
1460
1427
  ...file,
1461
- id: _objecthash2.default.call(void 0, { path: file.path }),
1428
+ id: hash__default.default({ path: file.path }),
1462
1429
  name: trimExtName2(file.baseName),
1463
- extName,
1430
+ extname: extname2,
1464
1431
  imports: imports.map((item) => createFileImport(item)),
1465
1432
  exports: exports.map((item) => createFileExport(item)),
1466
- sources: sources.map((item) => createFileSource(item))
1433
+ sources: sources.map((item) => createFileSource(item)),
1434
+ meta: file.meta || {}
1467
1435
  };
1468
1436
  }
1469
1437
  function createFileSource(source) {
1470
1438
  return source;
1471
1439
  }
1472
1440
  function createFileImport(imp) {
1473
- const extName = _path.extname.call(void 0, imp.path);
1474
1441
  return {
1475
- ...imp,
1476
- extName: imp.extName ? imp.extName : extName
1442
+ ...imp
1477
1443
  };
1478
1444
  }
1479
1445
  function createFileExport(exp) {
1480
- const extName = _path.extname.call(void 0, exp.path);
1481
1446
  return {
1482
- ...exp,
1483
- extName: exp.extName ? exp.extName : extName
1447
+ ...exp
1484
1448
  };
1485
1449
  }
1486
1450
  function createFileParser(parser) {
1487
1451
  return parser;
1488
1452
  }
1489
1453
  var typeScriptParser = createFileParser({
1490
- render() {
1491
- return void 0;
1454
+ async format(source) {
1455
+ const module = await import('@kubb/parser-ts');
1456
+ return module.format(source);
1492
1457
  },
1493
- async print(file) {
1494
- const module = await Promise.resolve().then(() => _interopRequireWildcard(require("@kubb/parser-ts")));
1458
+ async print(file, options = { extname: ".ts" }) {
1459
+ const module = await import('@kubb/parser-ts');
1460
+ const source = file.sources.map((item) => item.value).join("\n\n");
1495
1461
  const importNodes = file.imports.map((item) => {
1496
- const path = item.root ? _fs.getRelativePath.call(void 0, item.root, item.path) : item.path;
1462
+ const importPath = item.root ? fs.getRelativePath(item.root, item.path) : item.path;
1463
+ const hasExtname = !!path__default.default.extname(importPath);
1497
1464
  return module.factory.createImportDeclaration({
1498
1465
  name: item.name,
1499
- path,
1466
+ path: options.extname && hasExtname ? `${trimExtName2(importPath)}${options.extname}` : trimExtName2(importPath),
1500
1467
  isTypeOnly: item.isTypeOnly
1501
1468
  });
1502
1469
  }).filter(Boolean);
1503
1470
  const exportNodes = file.exports.map((item) => {
1471
+ const exportPath = item.path;
1472
+ const hasExtname = !!path__default.default.extname(exportPath);
1504
1473
  return module.factory.createExportDeclaration({
1505
1474
  name: item.name,
1506
- path: item.path,
1475
+ path: options.extname && hasExtname ? `${trimExtName2(item.path)}${options.extname}` : trimExtName2(item.path),
1507
1476
  isTypeOnly: item.isTypeOnly,
1508
1477
  asAlias: item.asAlias
1509
1478
  });
1510
1479
  }).filter(Boolean);
1511
- const source = [module.print([...importNodes, ...exportNodes]), file.sources.map((item) => item.value).join("\n\n")].join("\n");
1512
- return module.print([], { source, noEmitHelpers: false });
1480
+ return [file.banner, module.print([...importNodes, ...exportNodes]), source, file.footer].join("\n");
1513
1481
  }
1514
1482
  });
1515
1483
  var defaultParser = createFileParser({
1516
- render() {
1517
- return void 0;
1484
+ async format(source) {
1485
+ return source;
1518
1486
  },
1519
- async print(file, { logger }) {
1487
+ async print(file) {
1520
1488
  return file.sources.map((item) => item.value).join("\n\n");
1521
1489
  }
1522
1490
  });
@@ -1527,38 +1495,37 @@ var parsers = {
1527
1495
  ".tsx": typeScriptParser,
1528
1496
  ".json": defaultParser
1529
1497
  };
1530
- async function getFileParser(extName) {
1531
- if (!extName) {
1498
+ async function getFileParser(extname2) {
1499
+ if (!extname2) {
1532
1500
  return defaultParser;
1533
1501
  }
1534
- const parser = parsers[extName];
1502
+ const parser = parsers[extname2];
1535
1503
  if (!parser) {
1536
- console.warn(`[parser] No parser found for ${extName}, default parser will be used`);
1504
+ console.warn(`[parser] No parser found for ${extname2}, default parser will be used`);
1537
1505
  }
1538
1506
  return parser || defaultParser;
1539
1507
  }
1540
1508
  function trimExtName2(text) {
1541
- const extName = text.split(".").pop();
1542
- return text.replace(`.${extName}`, "");
1509
+ const extname2 = text.split(".").pop();
1510
+ return text.replace(`.${extname2}`, "");
1543
1511
  }
1544
1512
 
1545
-
1546
-
1547
-
1548
-
1549
-
1550
-
1551
-
1552
-
1553
-
1554
-
1555
-
1556
-
1557
-
1558
-
1559
-
1560
-
1561
-
1562
-
1563
- exports.FunctionParams = FunctionParams; exports.isPromise = isPromise; exports.isPromiseFulfilledResult = isPromiseFulfilledResult; exports.isPromiseRejectedResult = isPromiseRejectedResult; exports.renderTemplate = renderTemplate; exports.timeout = timeout; exports.getUniqueName = getUniqueName; exports.setUniqueName = setUniqueName; exports.URLPath = URLPath; exports.createFile = createFile; exports.createFileImport = createFileImport; exports.createFileExport = createFileExport; exports.createFileParser = createFileParser; exports.getFileParser = getFileParser; exports.FileManager = FileManager; exports.getSource = getSource; exports.processFiles = processFiles;
1564
- //# sourceMappingURL=chunk-5IGANEGE.cjs.map
1513
+ exports.FileManager = FileManager;
1514
+ exports.FunctionParams = FunctionParams;
1515
+ exports.URLPath = URLPath;
1516
+ exports.createFile = createFile;
1517
+ exports.createFileExport = createFileExport;
1518
+ exports.createFileImport = createFileImport;
1519
+ exports.createFileParser = createFileParser;
1520
+ exports.getFileParser = getFileParser;
1521
+ exports.getSource = getSource;
1522
+ exports.getUniqueName = getUniqueName;
1523
+ exports.isPromise = isPromise;
1524
+ exports.isPromiseFulfilledResult = isPromiseFulfilledResult;
1525
+ exports.isPromiseRejectedResult = isPromiseRejectedResult;
1526
+ exports.processFiles = processFiles;
1527
+ exports.renderTemplate = renderTemplate;
1528
+ exports.setUniqueName = setUniqueName;
1529
+ exports.timeout = timeout;
1530
+ //# sourceMappingURL=chunk-SQBOUPF4.cjs.map
1531
+ //# sourceMappingURL=chunk-SQBOUPF4.cjs.map