@kubb/core 3.0.0-alpha.2 → 3.0.0-alpha.20

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 (107) hide show
  1. package/README.md +13 -4
  2. package/dist/{FileManager-BW--rO8q.d.ts → FileManager-DQtWE_rp.d.ts} +112 -72
  3. package/dist/{FileManager-Bw-FNS3q.d.cts → FileManager-qZTz0oZl.d.cts} +112 -72
  4. package/dist/chunk-253UUWI5.cjs +101 -0
  5. package/dist/chunk-253UUWI5.cjs.map +1 -0
  6. package/dist/chunk-2EU7DMPM.js +96 -0
  7. package/dist/chunk-2EU7DMPM.js.map +1 -0
  8. package/dist/chunk-4X5FFJPJ.js +8 -13
  9. package/dist/chunk-4X5FFJPJ.js.map +1 -1
  10. package/dist/chunk-7O42P6ET.cjs +1088 -0
  11. package/dist/chunk-7O42P6ET.cjs.map +1 -0
  12. package/dist/chunk-CLTNHSMO.js +895 -0
  13. package/dist/chunk-CLTNHSMO.js.map +1 -0
  14. package/dist/{chunk-3OXCZ5DJ.js → chunk-E6CN2CZC.js} +63 -54
  15. package/dist/chunk-E6CN2CZC.js.map +1 -0
  16. package/dist/chunk-HBQM723K.js +1049 -0
  17. package/dist/chunk-HBQM723K.js.map +1 -0
  18. package/dist/{chunk-LM2YQC3T.cjs → chunk-HRJU3XOH.cjs} +81 -51
  19. package/dist/chunk-HRJU3XOH.cjs.map +1 -0
  20. package/dist/chunk-OAGN4FY6.cjs +42 -0
  21. package/dist/chunk-OAGN4FY6.cjs.map +1 -0
  22. package/dist/chunk-P37BU33L.cjs +1537 -0
  23. package/dist/chunk-P37BU33L.cjs.map +1 -0
  24. package/dist/{chunk-67C6RBGQ.cjs → chunk-U3S2ZR6C.cjs} +28 -29
  25. package/dist/chunk-U3S2ZR6C.cjs.map +1 -0
  26. package/dist/index.cjs +551 -599
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +6 -19
  29. package/dist/index.d.ts +6 -19
  30. package/dist/index.js +442 -512
  31. package/dist/index.js.map +1 -1
  32. package/dist/{logger-DChjnJMn.d.cts → logger-DvbHXjIO.d.cts} +29 -19
  33. package/dist/{logger-DChjnJMn.d.ts → logger-DvbHXjIO.d.ts} +29 -19
  34. package/dist/logger.cjs +25 -15
  35. package/dist/logger.cjs.map +1 -1
  36. package/dist/logger.d.cts +1 -2
  37. package/dist/logger.d.ts +1 -2
  38. package/dist/logger.js +3 -15
  39. package/dist/logger.js.map +1 -1
  40. package/dist/mocks.cjs +42 -31
  41. package/dist/mocks.cjs.map +1 -1
  42. package/dist/mocks.d.cts +7 -9
  43. package/dist/mocks.d.ts +7 -9
  44. package/dist/mocks.js +35 -33
  45. package/dist/mocks.js.map +1 -1
  46. package/dist/prompt-TK4KVZVL.cjs +760 -0
  47. package/dist/prompt-TK4KVZVL.cjs.map +1 -0
  48. package/dist/prompt-WQQUN22Z.js +749 -0
  49. package/dist/prompt-WQQUN22Z.js.map +1 -0
  50. package/dist/transformers.cjs +215 -49
  51. package/dist/transformers.cjs.map +1 -1
  52. package/dist/transformers.d.cts +1 -3
  53. package/dist/transformers.d.ts +1 -3
  54. package/dist/transformers.js +148 -35
  55. package/dist/transformers.js.map +1 -1
  56. package/dist/utils.cjs +65 -26
  57. package/dist/utils.cjs.map +1 -1
  58. package/dist/utils.d.cts +32 -3
  59. package/dist/utils.d.ts +32 -3
  60. package/dist/utils.js +3 -26
  61. package/dist/utils.js.map +1 -1
  62. package/package.json +10 -13
  63. package/src/BarrelManager.ts +95 -109
  64. package/src/{Generator.ts → BaseGenerator.ts} +1 -1
  65. package/src/FileManager.ts +190 -298
  66. package/src/PackageManager.ts +1 -1
  67. package/src/PluginManager.ts +149 -90
  68. package/src/PromiseManager.ts +1 -1
  69. package/src/__snapshots__/barrel.json +93 -0
  70. package/src/__snapshots__/grouped.json +120 -0
  71. package/src/__snapshots__/ordered.json +68 -0
  72. package/src/build.ts +87 -122
  73. package/src/config.ts +1 -1
  74. package/src/errors.ts +0 -11
  75. package/src/index.ts +2 -3
  76. package/src/logger.ts +76 -34
  77. package/src/plugin.ts +2 -5
  78. package/src/transformers/escape.ts +0 -10
  79. package/src/transformers/index.ts +2 -3
  80. package/src/transformers/trim.ts +0 -4
  81. package/src/types.ts +36 -5
  82. package/src/utils/TreeNode.ts +132 -50
  83. package/src/utils/executeStrategies.ts +3 -3
  84. package/src/utils/index.ts +2 -1
  85. package/src/utils/parser.ts +166 -0
  86. package/dist/chunk-3OXCZ5DJ.js.map +0 -1
  87. package/dist/chunk-5JZNFPUP.js +0 -309
  88. package/dist/chunk-5JZNFPUP.js.map +0 -1
  89. package/dist/chunk-67C6RBGQ.cjs.map +0 -1
  90. package/dist/chunk-ADC5UNZ5.cjs +0 -1227
  91. package/dist/chunk-ADC5UNZ5.cjs.map +0 -1
  92. package/dist/chunk-HMLY7DHA.js +0 -16
  93. package/dist/chunk-HMLY7DHA.js.map +0 -1
  94. package/dist/chunk-JKZG2IJR.js +0 -283
  95. package/dist/chunk-JKZG2IJR.js.map +0 -1
  96. package/dist/chunk-LM2YQC3T.cjs.map +0 -1
  97. package/dist/chunk-PZT4CTBV.cjs +0 -299
  98. package/dist/chunk-PZT4CTBV.cjs.map +0 -1
  99. package/dist/chunk-SA2GZKXS.js +0 -596
  100. package/dist/chunk-SA2GZKXS.js.map +0 -1
  101. package/dist/chunk-XCPFG6DO.cjs +0 -66
  102. package/dist/chunk-XCPFG6DO.cjs.map +0 -1
  103. package/dist/chunk-YTSNYMHW.cjs +0 -320
  104. package/dist/chunk-YTSNYMHW.cjs.map +0 -1
  105. package/schema.json +0 -86
  106. package/src/utils/cache.ts +0 -35
  107. package/src/utils/getParser.ts +0 -17
@@ -1,1227 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
2
-
3
-
4
-
5
- var _chunkPZT4CTBVcjs = require('./chunk-PZT4CTBV.cjs');
6
-
7
-
8
- var _chunkYTSNYMHWcjs = require('./chunk-YTSNYMHW.cjs');
9
-
10
-
11
- var _chunk67C6RBGQcjs = require('./chunk-67C6RBGQ.cjs');
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
- var _chunkXCPFG6DOcjs = require('./chunk-XCPFG6DO.cjs');
23
-
24
- // ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js
25
- var require_eventemitter3 = _chunkXCPFG6DOcjs.__commonJS.call(void 0, {
26
- "../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
27
- "use strict";
28
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
29
- var has = Object.prototype.hasOwnProperty;
30
- var prefix = "~";
31
- function Events() {
32
- }
33
- if (Object.create) {
34
- Events.prototype = /* @__PURE__ */ Object.create(null);
35
- if (!new Events().__proto__) prefix = false;
36
- }
37
- function EE(fn, context, once) {
38
- this.fn = fn;
39
- this.context = context;
40
- this.once = once || false;
41
- }
42
- function addListener(emitter, event, fn, context, once) {
43
- if (typeof fn !== "function") {
44
- throw new TypeError("The listener must be a function");
45
- }
46
- var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
47
- if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
48
- else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
49
- else emitter._events[evt] = [emitter._events[evt], listener];
50
- return emitter;
51
- }
52
- function clearEvent(emitter, evt) {
53
- if (--emitter._eventsCount === 0) emitter._events = new Events();
54
- else delete emitter._events[evt];
55
- }
56
- function EventEmitter2() {
57
- this._events = new Events();
58
- this._eventsCount = 0;
59
- }
60
- EventEmitter2.prototype.eventNames = function eventNames() {
61
- var names = [], events, name;
62
- if (this._eventsCount === 0) return names;
63
- for (name in events = this._events) {
64
- if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
65
- }
66
- if (Object.getOwnPropertySymbols) {
67
- return names.concat(Object.getOwnPropertySymbols(events));
68
- }
69
- return names;
70
- };
71
- EventEmitter2.prototype.listeners = function listeners(event) {
72
- var evt = prefix ? prefix + event : event, handlers = this._events[evt];
73
- if (!handlers) return [];
74
- if (handlers.fn) return [handlers.fn];
75
- for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
76
- ee[i] = handlers[i].fn;
77
- }
78
- return ee;
79
- };
80
- EventEmitter2.prototype.listenerCount = function listenerCount(event) {
81
- var evt = prefix ? prefix + event : event, listeners = this._events[evt];
82
- if (!listeners) return 0;
83
- if (listeners.fn) return 1;
84
- return listeners.length;
85
- };
86
- EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
87
- var evt = prefix ? prefix + event : event;
88
- if (!this._events[evt]) return false;
89
- var listeners = this._events[evt], len = arguments.length, args, i;
90
- if (listeners.fn) {
91
- if (listeners.once) this.removeListener(event, listeners.fn, void 0, true);
92
- switch (len) {
93
- case 1:
94
- return listeners.fn.call(listeners.context), true;
95
- case 2:
96
- return listeners.fn.call(listeners.context, a1), true;
97
- case 3:
98
- return listeners.fn.call(listeners.context, a1, a2), true;
99
- case 4:
100
- return listeners.fn.call(listeners.context, a1, a2, a3), true;
101
- case 5:
102
- return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
103
- case 6:
104
- return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
105
- }
106
- for (i = 1, args = new Array(len - 1); i < len; i++) {
107
- args[i - 1] = arguments[i];
108
- }
109
- listeners.fn.apply(listeners.context, args);
110
- } else {
111
- var length = listeners.length, j;
112
- for (i = 0; i < length; i++) {
113
- if (listeners[i].once) this.removeListener(event, listeners[i].fn, void 0, true);
114
- switch (len) {
115
- case 1:
116
- listeners[i].fn.call(listeners[i].context);
117
- break;
118
- case 2:
119
- listeners[i].fn.call(listeners[i].context, a1);
120
- break;
121
- case 3:
122
- listeners[i].fn.call(listeners[i].context, a1, a2);
123
- break;
124
- case 4:
125
- listeners[i].fn.call(listeners[i].context, a1, a2, a3);
126
- break;
127
- default:
128
- if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
129
- args[j - 1] = arguments[j];
130
- }
131
- listeners[i].fn.apply(listeners[i].context, args);
132
- }
133
- }
134
- }
135
- return true;
136
- };
137
- EventEmitter2.prototype.on = function on(event, fn, context) {
138
- return addListener(this, event, fn, context, false);
139
- };
140
- EventEmitter2.prototype.once = function once(event, fn, context) {
141
- return addListener(this, event, fn, context, true);
142
- };
143
- EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) {
144
- var evt = prefix ? prefix + event : event;
145
- if (!this._events[evt]) return this;
146
- if (!fn) {
147
- clearEvent(this, evt);
148
- return this;
149
- }
150
- var listeners = this._events[evt];
151
- if (listeners.fn) {
152
- if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
153
- clearEvent(this, evt);
154
- }
155
- } else {
156
- for (var i = 0, events = [], length = listeners.length; i < length; i++) {
157
- if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
158
- events.push(listeners[i]);
159
- }
160
- }
161
- if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
162
- else clearEvent(this, evt);
163
- }
164
- return this;
165
- };
166
- EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) {
167
- var evt;
168
- if (event) {
169
- evt = prefix ? prefix + event : event;
170
- if (this._events[evt]) clearEvent(this, evt);
171
- } else {
172
- this._events = new Events();
173
- this._eventsCount = 0;
174
- }
175
- return this;
176
- };
177
- EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
178
- EventEmitter2.prototype.addListener = EventEmitter2.prototype.on;
179
- EventEmitter2.prefixed = prefix;
180
- EventEmitter2.EventEmitter = EventEmitter2;
181
- if ("undefined" !== typeof module) {
182
- module.exports = EventEmitter2;
183
- }
184
- }
185
- });
186
-
187
- // src/FileManager.ts
188
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
189
- var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
190
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
191
-
192
- // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
193
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
194
-
195
- // ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
196
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
197
- var import_index = _chunkXCPFG6DOcjs.__toESM.call(void 0, require_eventemitter3(), 1);
198
-
199
- // ../../node_modules/.pnpm/p-timeout@6.1.2/node_modules/p-timeout/index.js
200
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
201
- var TimeoutError = class extends Error {
202
- constructor(message) {
203
- super(message);
204
- this.name = "TimeoutError";
205
- }
206
- };
207
- var AbortError = class extends Error {
208
- constructor(message) {
209
- super();
210
- this.name = "AbortError";
211
- this.message = message;
212
- }
213
- };
214
- var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new AbortError(errorMessage) : new DOMException(errorMessage);
215
- var getAbortedReason = (signal) => {
216
- const reason = signal.reason === void 0 ? getDOMException("This operation was aborted.") : signal.reason;
217
- return reason instanceof Error ? reason : getDOMException(reason);
218
- };
219
- function pTimeout(promise, options) {
220
- const {
221
- milliseconds,
222
- fallback,
223
- message,
224
- customTimers = { setTimeout, clearTimeout }
225
- } = options;
226
- let timer;
227
- const wrappedPromise = new Promise((resolve2, reject) => {
228
- if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
229
- throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
230
- }
231
- if (options.signal) {
232
- const { signal } = options;
233
- if (signal.aborted) {
234
- reject(getAbortedReason(signal));
235
- }
236
- signal.addEventListener("abort", () => {
237
- reject(getAbortedReason(signal));
238
- });
239
- }
240
- if (milliseconds === Number.POSITIVE_INFINITY) {
241
- promise.then(resolve2, reject);
242
- return;
243
- }
244
- const timeoutError = new TimeoutError();
245
- timer = customTimers.setTimeout.call(void 0, () => {
246
- if (fallback) {
247
- try {
248
- resolve2(fallback());
249
- } catch (error) {
250
- reject(error);
251
- }
252
- return;
253
- }
254
- if (typeof promise.cancel === "function") {
255
- promise.cancel();
256
- }
257
- if (message === false) {
258
- resolve2();
259
- } else if (message instanceof Error) {
260
- reject(message);
261
- } else {
262
- timeoutError.message = _nullishCoalesce(message, () => ( `Promise timed out after ${milliseconds} milliseconds`));
263
- reject(timeoutError);
264
- }
265
- }, milliseconds);
266
- (async () => {
267
- try {
268
- resolve2(await promise);
269
- } catch (error) {
270
- reject(error);
271
- }
272
- })();
273
- });
274
- const cancelablePromise = wrappedPromise.finally(() => {
275
- cancelablePromise.clear();
276
- });
277
- cancelablePromise.clear = () => {
278
- customTimers.clearTimeout.call(void 0, timer);
279
- timer = void 0;
280
- };
281
- return cancelablePromise;
282
- }
283
-
284
- // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/priority-queue.js
285
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
286
-
287
- // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/lower-bound.js
288
- _chunkXCPFG6DOcjs.init_cjs_shims.call(void 0, );
289
- function lowerBound(array, value, comparator) {
290
- let first = 0;
291
- let count = array.length;
292
- while (count > 0) {
293
- const step = Math.trunc(count / 2);
294
- let it = first + step;
295
- if (comparator(array[it], value) <= 0) {
296
- first = ++it;
297
- count -= step + 1;
298
- } else {
299
- count = step;
300
- }
301
- }
302
- return first;
303
- }
304
-
305
- // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/priority-queue.js
306
- var _queue;
307
- var PriorityQueue = class {
308
- constructor() {
309
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _queue, []);
310
- }
311
- enqueue(run, options) {
312
- options = {
313
- priority: 0,
314
- ...options
315
- };
316
- const element = {
317
- priority: options.priority,
318
- run
319
- };
320
- if (this.size && _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue)[this.size - 1].priority >= options.priority) {
321
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).push(element);
322
- return;
323
- }
324
- const index = lowerBound(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue), element, (a, b) => b.priority - a.priority);
325
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).splice(index, 0, element);
326
- }
327
- dequeue() {
328
- const item = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).shift();
329
- return _optionalChain([item, 'optionalAccess', _2 => _2.run]);
330
- }
331
- filter(options) {
332
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).filter((element) => element.priority === options.priority).map((element) => element.run);
333
- }
334
- get size() {
335
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue).length;
336
- }
337
- };
338
- _queue = new WeakMap();
339
-
340
- // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
341
- var _carryoverConcurrencyCount, _isIntervalIgnored, _intervalCount, _intervalCap, _interval, _intervalEnd, _intervalId, _timeoutId, _queue2, _queueClass, _pending, _concurrency, _isPaused, _throwOnTimeout, _PQueue_instances, doesIntervalAllowAnother_get, doesConcurrentAllowAnother_get, next_fn, onResumeInterval_fn, isIntervalPaused_get, tryToStartAnother_fn, initializeIntervalIfNeeded_fn, onInterval_fn, processQueue_fn, throwOnAbort_fn, onEvent_fn;
342
- var PQueue = class extends import_index.default {
343
- // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
344
- constructor(options) {
345
- super();
346
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _PQueue_instances);
347
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _carryoverConcurrencyCount);
348
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _isIntervalIgnored);
349
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _intervalCount, 0);
350
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _intervalCap);
351
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _interval);
352
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _intervalEnd, 0);
353
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _intervalId);
354
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _timeoutId);
355
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _queue2);
356
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _queueClass);
357
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _pending, 0);
358
- // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
359
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _concurrency);
360
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _isPaused);
361
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _throwOnTimeout);
362
- /**
363
- Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.
364
-
365
- Applies to each future operation.
366
- */
367
- _chunkXCPFG6DOcjs.__publicField.call(void 0, this, "timeout");
368
- options = {
369
- carryoverConcurrencyCount: false,
370
- intervalCap: Number.POSITIVE_INFINITY,
371
- interval: 0,
372
- concurrency: Number.POSITIVE_INFINITY,
373
- autoStart: true,
374
- queueClass: PriorityQueue,
375
- ...options
376
- };
377
- 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})`);
379
- }
380
- 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})`);
382
- }
383
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _carryoverConcurrencyCount, options.carryoverConcurrencyCount);
384
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0);
385
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _intervalCap, options.intervalCap);
386
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _interval, options.interval);
387
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _queue2, new options.queueClass());
388
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _queueClass, options.queueClass);
389
- this.concurrency = options.concurrency;
390
- this.timeout = options.timeout;
391
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _throwOnTimeout, options.throwOnTimeout === true);
392
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _isPaused, options.autoStart === false);
393
- }
394
- get concurrency() {
395
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _concurrency);
396
- }
397
- set concurrency(newConcurrency) {
398
- if (!(typeof newConcurrency === "number" && newConcurrency >= 1)) {
399
- throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${newConcurrency}\` (${typeof newConcurrency})`);
400
- }
401
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _concurrency, newConcurrency);
402
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, processQueue_fn).call(this);
403
- }
404
- async add(function_, options = {}) {
405
- options = {
406
- timeout: this.timeout,
407
- throwOnTimeout: _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _throwOnTimeout),
408
- ...options
409
- };
410
- return new Promise((resolve2, reject) => {
411
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).enqueue(async () => {
412
- _chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _pending)._++;
413
- _chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _intervalCount)._++;
414
- try {
415
- _optionalChain([options, 'access', _9 => _9.signal, 'optionalAccess', _10 => _10.throwIfAborted, 'call', _11 => _11()]);
416
- let operation = function_({ signal: options.signal });
417
- if (options.timeout) {
418
- operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
419
- }
420
- if (options.signal) {
421
- operation = Promise.race([operation, _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, throwOnAbort_fn).call(this, options.signal)]);
422
- }
423
- const result = await operation;
424
- resolve2(result);
425
- this.emit("completed", result);
426
- } catch (error) {
427
- if (error instanceof TimeoutError && !options.throwOnTimeout) {
428
- resolve2();
429
- return;
430
- }
431
- reject(error);
432
- this.emit("error", error);
433
- } finally {
434
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, next_fn).call(this);
435
- }
436
- }, options);
437
- this.emit("add");
438
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, tryToStartAnother_fn).call(this);
439
- });
440
- }
441
- async addAll(functions, options) {
442
- return Promise.all(functions.map(async (function_) => this.add(function_, options)));
443
- }
444
- /**
445
- Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
446
- */
447
- start() {
448
- if (!_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _isPaused)) {
449
- return this;
450
- }
451
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _isPaused, false);
452
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, processQueue_fn).call(this);
453
- return this;
454
- }
455
- /**
456
- Put queue execution on hold.
457
- */
458
- pause() {
459
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _isPaused, true);
460
- }
461
- /**
462
- Clear the queue.
463
- */
464
- clear() {
465
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _queue2, new (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queueClass))());
466
- }
467
- /**
468
- Can be called multiple times. Useful if you for example add additional items at a later time.
469
-
470
- @returns A promise that settles when the queue becomes empty.
471
- */
472
- async onEmpty() {
473
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
474
- return;
475
- }
476
- await _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, onEvent_fn).call(this, "empty");
477
- }
478
- /**
479
- @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
480
-
481
- If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
482
-
483
- Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.
484
- */
485
- async onSizeLessThan(limit) {
486
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).size < limit) {
487
- return;
488
- }
489
- await _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, onEvent_fn).call(this, "next", () => _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).size < limit);
490
- }
491
- /**
492
- The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
493
-
494
- @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
495
- */
496
- async onIdle() {
497
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _pending) === 0 && _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
498
- return;
499
- }
500
- await _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, onEvent_fn).call(this, "idle");
501
- }
502
- /**
503
- Size of the queue, the number of queued items waiting to run.
504
- */
505
- get size() {
506
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).size;
507
- }
508
- /**
509
- Size of the queue, filtered by the given options.
510
-
511
- For example, this can be used to find the number of items remaining in the queue with a specific priority level.
512
- */
513
- sizeBy(options) {
514
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).filter(options).length;
515
- }
516
- /**
517
- Number of running items (no longer in the queue).
518
- */
519
- get pending() {
520
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _pending);
521
- }
522
- /**
523
- Whether the queue is currently paused.
524
- */
525
- get isPaused() {
526
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _isPaused);
527
- }
528
- };
529
- _carryoverConcurrencyCount = new WeakMap();
530
- _isIntervalIgnored = new WeakMap();
531
- _intervalCount = new WeakMap();
532
- _intervalCap = new WeakMap();
533
- _interval = new WeakMap();
534
- _intervalEnd = new WeakMap();
535
- _intervalId = new WeakMap();
536
- _timeoutId = new WeakMap();
537
- _queue2 = new WeakMap();
538
- _queueClass = new WeakMap();
539
- _pending = new WeakMap();
540
- _concurrency = new WeakMap();
541
- _isPaused = new WeakMap();
542
- _throwOnTimeout = new WeakMap();
543
- _PQueue_instances = new WeakSet();
544
- doesIntervalAllowAnother_get = function() {
545
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _isIntervalIgnored) || _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalCount) < _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalCap);
546
- };
547
- doesConcurrentAllowAnother_get = function() {
548
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _pending) < _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _concurrency);
549
- };
550
- next_fn = function() {
551
- _chunkXCPFG6DOcjs.__privateWrapper.call(void 0, this, _pending)._--;
552
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, tryToStartAnother_fn).call(this);
553
- this.emit("next");
554
- };
555
- onResumeInterval_fn = function() {
556
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, onInterval_fn).call(this);
557
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, initializeIntervalIfNeeded_fn).call(this);
558
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _timeoutId, void 0);
559
- };
560
- isIntervalPaused_get = function() {
561
- const now = Date.now();
562
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalId) === void 0) {
563
- const delay = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalEnd) - now;
564
- if (delay < 0) {
565
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _intervalCount, _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _carryoverConcurrencyCount) ? _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _pending) : 0);
566
- } else {
567
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _timeoutId) === void 0) {
568
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _timeoutId, setTimeout(() => {
569
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, onResumeInterval_fn).call(this);
570
- }, delay));
571
- }
572
- return true;
573
- }
574
- }
575
- return false;
576
- };
577
- tryToStartAnother_fn = function() {
578
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
579
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalId)) {
580
- clearInterval(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalId));
581
- }
582
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _intervalId, void 0);
583
- this.emit("empty");
584
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _pending) === 0) {
585
- this.emit("idle");
586
- }
587
- return false;
588
- }
589
- if (!_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _isPaused)) {
590
- const canInitializeInterval = !_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _PQueue_instances, isIntervalPaused_get);
591
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _PQueue_instances, doesIntervalAllowAnother_get) && _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _PQueue_instances, doesConcurrentAllowAnother_get)) {
592
- const job = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _queue2).dequeue();
593
- if (!job) {
594
- return false;
595
- }
596
- this.emit("active");
597
- job();
598
- if (canInitializeInterval) {
599
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, initializeIntervalIfNeeded_fn).call(this);
600
- }
601
- return true;
602
- }
603
- }
604
- return false;
605
- };
606
- initializeIntervalIfNeeded_fn = function() {
607
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _isIntervalIgnored) || _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalId) !== void 0) {
608
- return;
609
- }
610
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _intervalId, setInterval(() => {
611
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, onInterval_fn).call(this);
612
- }, _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _interval)));
613
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _intervalEnd, Date.now() + _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _interval));
614
- };
615
- onInterval_fn = function() {
616
- if (_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalCount) === 0 && _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _pending) === 0 && _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalId)) {
617
- clearInterval(_chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _intervalId));
618
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _intervalId, void 0);
619
- }
620
- _chunkXCPFG6DOcjs.__privateSet.call(void 0, this, _intervalCount, _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _carryoverConcurrencyCount) ? _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _pending) : 0);
621
- _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, processQueue_fn).call(this);
622
- };
623
- /**
624
- Executes all queued functions until it reaches the limit.
625
- */
626
- processQueue_fn = function() {
627
- while (_chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _PQueue_instances, tryToStartAnother_fn).call(this)) {
628
- }
629
- };
630
- throwOnAbort_fn = async function(signal) {
631
- return new Promise((_resolve, reject) => {
632
- signal.addEventListener("abort", () => {
633
- reject(signal.reason);
634
- }, { once: true });
635
- });
636
- };
637
- onEvent_fn = async function(event, filter) {
638
- return new Promise((resolve2) => {
639
- const listener = () => {
640
- if (filter && !filter()) {
641
- return;
642
- }
643
- this.off(event, listener);
644
- resolve2();
645
- };
646
- this.on(event, listener);
647
- });
648
- };
649
-
650
- // 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;
862
- var _FileManager = class _FileManager {
863
- constructor({ task = async (file) => file, queue = new PQueue() } = {}) {
864
- _chunkXCPFG6DOcjs.__privateAdd.call(void 0, this, _FileManager_instances);
865
- _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
- return this;
871
- }
872
- get files() {
873
- const files = [];
874
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).forEach((item) => {
875
- files.push(...item.flat(1));
876
- });
877
- return files;
878
- }
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
- async add(...files) {
883
- const promises = combineFiles(files).map((file) => {
884
- if (file.override) {
885
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, file);
886
- }
887
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, addOrAppend_fn).call(this, file);
888
- });
889
- const resolvedFiles = await Promise.all(promises);
890
- if (files.length > 1) {
891
- return resolvedFiles;
892
- }
893
- return resolvedFiles[0];
894
- }
895
- async addIndexes({ root, output, meta, logger, options = {} }) {
896
- const { exportType = "barrel" } = output;
897
- if (exportType === false) {
898
- return void 0;
899
- }
900
- const pathToBuildFrom = _path.resolve.call(void 0, root, output.path);
901
- if (_chunkPZT4CTBVcjs.transformers_default.trimExtName(pathToBuildFrom).endsWith("index")) {
902
- logger.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
903
- return;
904
- }
905
- const exportPath = output.path.startsWith("./") ? _chunkPZT4CTBVcjs.trimExtName.call(void 0, output.path) : `./${_chunkPZT4CTBVcjs.trimExtName.call(void 0, output.path)}`;
906
- const mode = _FileManager.getMode(output.path);
907
- const barrelManager = new BarrelManager({
908
- extName: output.extName,
909
- ...options
910
- });
911
- let files = barrelManager.getIndexes(pathToBuildFrom);
912
- if (!files) {
913
- return void 0;
914
- }
915
- if (exportType === "barrelNamed") {
916
- files = files.map((file) => {
917
- if (file.exports) {
918
- return {
919
- ...file,
920
- exports: barrelManager.getNamedExports(pathToBuildFrom, file.exports)
921
- };
922
- }
923
- return file;
924
- });
925
- }
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
- const rootPath = mode === "split" ? `${exportPath}/index${output.extName || ""}` : `${exportPath}${output.extName || ""}`;
935
- const rootFile = {
936
- path: _path.resolve.call(void 0, root, "index.ts"),
937
- baseName: "index.ts",
938
- source: "",
939
- exports: [
940
- output.exportAs ? {
941
- name: output.exportAs,
942
- asAlias: true,
943
- path: rootPath,
944
- isTypeOnly: options.isTypeOnly
945
- } : {
946
- path: rootPath,
947
- isTypeOnly: options.isTypeOnly
948
- }
949
- ],
950
- exportable: true
951
- };
952
- if (exportType === "barrelNamed" && !output.exportAs && _optionalChain([rootFile, 'access', _32 => _32.exports, 'optionalAccess', _33 => _33[0]])) {
953
- rootFile.exports = barrelManager.getNamedExport(root, rootFile.exports[0]);
954
- }
955
- await _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, addOrAppend_fn).call(this, {
956
- ...rootFile,
957
- meta: meta ? meta : rootFile.meta
958
- });
959
- }
960
- getCacheByUUID(UUID) {
961
- let cache;
962
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).forEach((files) => {
963
- cache = files.find((item) => item.id === UUID);
964
- });
965
- return cache;
966
- }
967
- get(path2) {
968
- return _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).get(path2);
969
- }
970
- remove(path2) {
971
- const cacheItem = this.get(path2);
972
- if (!cacheItem) {
973
- return;
974
- }
975
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).delete(path2);
976
- }
977
- async write(...params) {
978
- return _fs.write.call(void 0, ...params);
979
- }
980
- async read(...params) {
981
- return _fs.read.call(void 0, ...params);
982
- }
983
- // statics
984
- static async getSource(file) {
985
- return getSource(file);
986
- }
987
- static combineFiles(files) {
988
- return combineFiles(files);
989
- }
990
- static getMode(path2) {
991
- if (!path2) {
992
- return "split";
993
- }
994
- return _path.extname.call(void 0, path2) ? "single" : "split";
995
- }
996
- static get extensions() {
997
- return [".js", ".ts", ".tsx"];
998
- }
999
- static isJavascript(baseName) {
1000
- return _FileManager.extensions.some((extension) => baseName.endsWith(extension));
1001
- }
1002
- };
1003
- _cache = new WeakMap();
1004
- _task = new WeakMap();
1005
- _queue3 = new WeakMap();
1006
- _FileManager_instances = new WeakSet();
1007
- add_fn = async function(file) {
1008
- const controller = new AbortController();
1009
- const resolvedFile = {
1010
- id: _crypto2.default.randomUUID(),
1011
- name: _chunkPZT4CTBVcjs.trimExtName.call(void 0, file.baseName),
1012
- ...file
1013
- };
1014
- if (_optionalChain([resolvedFile, 'access', _34 => _34.exports, 'optionalAccess', _35 => _35.length])) {
1015
- const folder = resolvedFile.path.replace(resolvedFile.baseName, "");
1016
- resolvedFile.exports = resolvedFile.exports.filter((exportItem) => {
1017
- const exportedFile = this.files.find((file2) => file2.path.includes(_path.resolve.call(void 0, folder, exportItem.path)));
1018
- if (exportedFile) {
1019
- return exportedFile.exportable;
1020
- }
1021
- return true;
1022
- });
1023
- }
1024
- _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
- );
1032
- };
1033
- addOrAppend_fn = async function(file) {
1034
- const previousCaches = _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).get(file.path);
1035
- const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
1036
- if (previousCache) {
1037
- _chunkXCPFG6DOcjs.__privateGet.call(void 0, this, _cache).delete(previousCache.path);
1038
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, {
1039
- ...file,
1040
- source: previousCache.source && file.source ? `${previousCache.source}
1041
- ${file.source}` : "",
1042
- imports: [...previousCache.imports || [], ...file.imports || []],
1043
- exports: [...previousCache.exports || [], ...file.exports || []],
1044
- env: { ...previousCache.env || {}, ...file.env || {} }
1045
- });
1046
- }
1047
- return _chunkXCPFG6DOcjs.__privateMethod.call(void 0, this, _FileManager_instances, add_fn).call(this, file);
1048
- };
1049
- var FileManager = _FileManager;
1050
- function combineFiles(files) {
1051
- return files.filter(Boolean).reduce(
1052
- (acc, file) => {
1053
- const prevIndex = acc.findIndex((item) => item.path === file.path);
1054
- if (prevIndex === -1) {
1055
- return [...acc, file];
1056
- }
1057
- const prev = acc[prevIndex];
1058
- if (prev && file.override) {
1059
- acc[prevIndex] = {
1060
- imports: [],
1061
- exports: [],
1062
- ...file
1063
- };
1064
- return acc;
1065
- }
1066
- if (prev) {
1067
- acc[prevIndex] = {
1068
- ...file,
1069
- source: prev.source && file.source ? `${prev.source}
1070
- ${file.source}` : "",
1071
- imports: [...prev.imports || [], ...file.imports || []],
1072
- exports: [...prev.exports || [], ...file.exports || []],
1073
- env: { ...prev.env || {}, ...file.env || {} }
1074
- };
1075
- }
1076
- return acc;
1077
- },
1078
- []
1079
- );
1080
- }
1081
- async function getSource(file) {
1082
- if (file.language ? !["typescript", "javascript"].includes(file.language) : !FileManager.isJavascript(file.baseName)) {
1083
- return file.source;
1084
- }
1085
- const parser = await _chunkYTSNYMHWcjs.getParser.call(void 0, file.language);
1086
- const exports = file.exports ? combineExports(file.exports) : [];
1087
- const imports = file.imports && file.source ? combineImports(file.imports, exports, file.source) : [];
1088
- const importNodes = imports.filter((item) => {
1089
- const path2 = item.root ? _fs.getRelativePath.call(void 0, item.root, item.path) : item.path;
1090
- return path2 !== _chunkPZT4CTBVcjs.trimExtName.call(void 0, file.path);
1091
- }).map((item) => {
1092
- const path2 = item.root ? _fs.getRelativePath.call(void 0, item.root, item.path) : item.path;
1093
- return parser.factory.createImportDeclaration({
1094
- name: item.name,
1095
- path: item.extName ? `${path2}${item.extName}` : path2,
1096
- isTypeOnly: item.isTypeOnly
1097
- });
1098
- });
1099
- const exportNodes = exports.map(
1100
- (item) => parser.factory.createExportDeclaration({
1101
- name: item.name,
1102
- path: item.extName ? `${item.path}${item.extName}` : item.path,
1103
- isTypeOnly: item.isTypeOnly,
1104
- asAlias: item.asAlias
1105
- })
1106
- );
1107
- const source = [parser.print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join("\n");
1108
- return parser.print([], { source, noEmitHelpers: false });
1109
- }
1110
- function combineExports(exports) {
1111
- const combinedExports = _chunk67C6RBGQcjs.orderBy.call(void 0, exports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
1112
- (prev, curr) => {
1113
- const name = curr.name;
1114
- const prevByPath = prev.findLast((imp) => imp.path === curr.path);
1115
- const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly);
1116
- if (prevByPathAndIsTypeOnly) {
1117
- return prev;
1118
- }
1119
- const uniquePrev = prev.findLast(
1120
- (imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
1121
- );
1122
- if (uniquePrev || Array.isArray(name) && !name.length || _optionalChain([prevByPath, 'optionalAccess', _36 => _36.asAlias]) && !curr.asAlias) {
1123
- return prev;
1124
- }
1125
- if (!prevByPath) {
1126
- return [
1127
- ...prev,
1128
- {
1129
- ...curr,
1130
- name: Array.isArray(name) ? [...new Set(name)] : name
1131
- }
1132
- ];
1133
- }
1134
- if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
1135
- prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...curr.name])];
1136
- return prev;
1137
- }
1138
- return [...prev, curr];
1139
- },
1140
- []
1141
- );
1142
- return _chunk67C6RBGQcjs.orderBy.call(void 0, combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ["desc", "desc"]);
1143
- }
1144
- function combineImports(imports, exports, source) {
1145
- const combinedImports = _chunk67C6RBGQcjs.orderBy.call(void 0, imports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
1146
- (prev, curr) => {
1147
- let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
1148
- const hasImportInSource = (importName) => {
1149
- if (!source) {
1150
- return true;
1151
- }
1152
- const checker = (name2) => name2 && !!source.includes(name2);
1153
- return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
1154
- };
1155
- if (curr.path === curr.root) {
1156
- return prev;
1157
- }
1158
- if (Array.isArray(name)) {
1159
- name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
1160
- }
1161
- const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
1162
- const uniquePrev = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
1163
- const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly);
1164
- if (prevByPathNameAndIsTypeOnly) {
1165
- return prev;
1166
- }
1167
- if (uniquePrev || Array.isArray(name) && !name.length) {
1168
- return prev;
1169
- }
1170
- if (!prevByPath) {
1171
- return [
1172
- ...prev,
1173
- {
1174
- ...curr,
1175
- name
1176
- }
1177
- ];
1178
- }
1179
- if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
1180
- prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...name])];
1181
- return prev;
1182
- }
1183
- if (!Array.isArray(name) && name && !hasImportInSource(name)) {
1184
- return prev;
1185
- }
1186
- return [...prev, curr];
1187
- },
1188
- []
1189
- );
1190
- return _chunk67C6RBGQcjs.orderBy.call(void 0, combinedImports, [(v) => !v.isTypeOnly], ["desc"]);
1191
- }
1192
- function getEnvSource(source, env) {
1193
- if (!env) {
1194
- return source;
1195
- }
1196
- const keys = Object.keys(env);
1197
- if (!keys.length) {
1198
- return source;
1199
- }
1200
- return keys.reduce((prev, key) => {
1201
- const environmentValue = env[key];
1202
- const replaceBy = environmentValue ? `'${_optionalChain([environmentValue, 'access', _37 => _37.replaceAll, 'call', _38 => _38('"', ""), 'optionalAccess', _39 => _39.replaceAll, 'call', _40 => _40("'", "")])}'` : "undefined";
1203
- if (key.toUpperCase() !== key) {
1204
- throw new TypeError(`Environment should be in upperCase for ${key}`);
1205
- }
1206
- if (typeof replaceBy === "string") {
1207
- prev = _chunkPZT4CTBVcjs.searchAndReplace.call(void 0, {
1208
- text: prev.replaceAll(`process.env.${key}`, replaceBy),
1209
- replaceBy,
1210
- prefix: "process.env",
1211
- key
1212
- });
1213
- prev = _chunkPZT4CTBVcjs.searchAndReplace.call(void 0, {
1214
- text: prev.replaceAll(/(declare const).*\n/gi, ""),
1215
- replaceBy,
1216
- key
1217
- });
1218
- }
1219
- return prev;
1220
- }, source);
1221
- }
1222
-
1223
-
1224
-
1225
-
1226
- exports.PQueue = PQueue; exports.FileManager = FileManager;
1227
- //# sourceMappingURL=chunk-ADC5UNZ5.cjs.map