@kubb/core 2.17.0 → 2.18.0

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 (74) hide show
  1. package/dist/{chunk-C6JPLJPT.cjs → chunk-2H4XNW5D.cjs} +351 -267
  2. package/dist/chunk-2H4XNW5D.cjs.map +1 -0
  3. package/dist/{chunk-PVJACA4A.js → chunk-4X5FFJPJ.js} +35 -2
  4. package/dist/chunk-4X5FFJPJ.js.map +1 -0
  5. package/dist/{chunk-6V72PGTE.cjs → chunk-5T2QA53B.cjs} +139 -3
  6. package/dist/chunk-5T2QA53B.cjs.map +1 -0
  7. package/dist/{chunk-CWXJJLZF.cjs → chunk-7HFYOZ7F.cjs} +12 -4
  8. package/dist/chunk-7HFYOZ7F.cjs.map +1 -0
  9. package/dist/chunk-ECWTIHD5.js +311 -0
  10. package/dist/chunk-ECWTIHD5.js.map +1 -0
  11. package/dist/{chunk-NLZ2T737.js → chunk-MDO6MCFJ.js} +9 -2
  12. package/dist/chunk-MDO6MCFJ.js.map +1 -0
  13. package/dist/{chunk-JFESCSNU.cjs → chunk-OCUNVJPQ.cjs} +6 -8
  14. package/dist/chunk-OCUNVJPQ.cjs.map +1 -0
  15. package/dist/chunk-PXP5K73S.js +1599 -0
  16. package/dist/chunk-PXP5K73S.js.map +1 -0
  17. package/dist/{chunk-PQ7P6QX5.cjs → chunk-SU2W2A6V.cjs} +3 -3
  18. package/dist/chunk-T6TAUAYN.cjs +2586 -0
  19. package/dist/chunk-T6TAUAYN.cjs.map +1 -0
  20. package/dist/{chunk-YQ5ZU5PV.js → chunk-UCKFXEKM.js} +3 -5
  21. package/dist/{chunk-YQ5ZU5PV.js.map → chunk-UCKFXEKM.js.map} +1 -1
  22. package/dist/chunk-XF35HUZ2.cjs +322 -0
  23. package/dist/chunk-XF35HUZ2.cjs.map +1 -0
  24. package/dist/fs.cjs +3 -6
  25. package/dist/fs.cjs.map +1 -1
  26. package/dist/fs.js +5 -7
  27. package/dist/index.cjs +10 -2550
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.js +22 -1574
  32. package/dist/index.js.map +1 -1
  33. package/dist/logger.cjs +3 -4
  34. package/dist/mocks.cjs +19 -6
  35. package/dist/mocks.cjs.map +1 -1
  36. package/dist/mocks.d.cts +3 -2
  37. package/dist/mocks.d.ts +3 -2
  38. package/dist/mocks.js +16 -2
  39. package/dist/mocks.js.map +1 -1
  40. package/dist/transformers.cjs +3 -5
  41. package/dist/transformers.js +3 -5
  42. package/dist/utils.cjs +26 -194
  43. package/dist/utils.cjs.map +1 -1
  44. package/dist/utils.d.cts +4 -1
  45. package/dist/utils.d.ts +4 -1
  46. package/dist/utils.js +12 -172
  47. package/dist/utils.js.map +1 -1
  48. package/package.json +3 -3
  49. package/src/BarrelManager.ts +1 -1
  50. package/src/FileManager.ts +9 -9
  51. package/src/build.ts +22 -10
  52. package/src/utils/getParser.ts +17 -0
  53. package/src/utils/index.ts +1 -0
  54. package/dist/chunk-4ARKZPSY.js +0 -36
  55. package/dist/chunk-4ARKZPSY.js.map +0 -1
  56. package/dist/chunk-5PLDNXZK.js +0 -10
  57. package/dist/chunk-5PLDNXZK.js.map +0 -1
  58. package/dist/chunk-6V72PGTE.cjs.map +0 -1
  59. package/dist/chunk-C6JPLJPT.cjs.map +0 -1
  60. package/dist/chunk-CFHVVM3A.cjs +0 -132
  61. package/dist/chunk-CFHVVM3A.cjs.map +0 -1
  62. package/dist/chunk-CWXJJLZF.cjs.map +0 -1
  63. package/dist/chunk-FU3AZXHF.cjs +0 -19
  64. package/dist/chunk-FU3AZXHF.cjs.map +0 -1
  65. package/dist/chunk-GBVPADCA.js +0 -127
  66. package/dist/chunk-GBVPADCA.js.map +0 -1
  67. package/dist/chunk-JFESCSNU.cjs.map +0 -1
  68. package/dist/chunk-LEPKPXA4.cjs +0 -143
  69. package/dist/chunk-LEPKPXA4.cjs.map +0 -1
  70. package/dist/chunk-NLZ2T737.js.map +0 -1
  71. package/dist/chunk-PVJACA4A.js.map +0 -1
  72. package/dist/chunk-T7WVNL7N.cjs +0 -94
  73. package/dist/chunk-T7WVNL7N.cjs.map +0 -1
  74. /package/dist/{chunk-PQ7P6QX5.cjs.map → chunk-SU2W2A6V.cjs.map} +0 -0
@@ -0,0 +1,2586 @@
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; }
2
+
3
+
4
+
5
+
6
+ var _chunkOCUNVJPQcjs = require('./chunk-OCUNVJPQ.cjs');
7
+
8
+
9
+
10
+
11
+ var _chunkXF35HUZ2cjs = require('./chunk-XF35HUZ2.cjs');
12
+
13
+
14
+ var _chunk5T2QA53Bcjs = require('./chunk-5T2QA53B.cjs');
15
+
16
+
17
+
18
+
19
+
20
+
21
+ var _chunkSU2W2A6Vcjs = require('./chunk-SU2W2A6V.cjs');
22
+
23
+
24
+
25
+
26
+
27
+ var _chunk7HFYOZ7Fcjs = require('./chunk-7HFYOZ7F.cjs');
28
+
29
+
30
+ var _chunk2H4XNW5Dcjs = require('./chunk-2H4XNW5D.cjs');
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+ var _chunkOOZTXU7Fcjs = require('./chunk-OOZTXU7F.cjs');
42
+
43
+ // ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js
44
+ var require_eventemitter3 = _chunkOOZTXU7Fcjs.__commonJS.call(void 0, {
45
+ "../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
46
+ "use strict";
47
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
48
+ var has = Object.prototype.hasOwnProperty;
49
+ var prefix = "~";
50
+ function Events() {
51
+ }
52
+ if (Object.create) {
53
+ Events.prototype = /* @__PURE__ */ Object.create(null);
54
+ if (!new Events().__proto__)
55
+ prefix = false;
56
+ }
57
+ function EE(fn, context, once) {
58
+ this.fn = fn;
59
+ this.context = context;
60
+ this.once = once || false;
61
+ }
62
+ function addListener(emitter, event, fn, context, once) {
63
+ if (typeof fn !== "function") {
64
+ throw new TypeError("The listener must be a function");
65
+ }
66
+ var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
67
+ if (!emitter._events[evt])
68
+ emitter._events[evt] = listener, emitter._eventsCount++;
69
+ else if (!emitter._events[evt].fn)
70
+ emitter._events[evt].push(listener);
71
+ else
72
+ emitter._events[evt] = [emitter._events[evt], listener];
73
+ return emitter;
74
+ }
75
+ function clearEvent(emitter, evt) {
76
+ if (--emitter._eventsCount === 0)
77
+ emitter._events = new Events();
78
+ else
79
+ delete emitter._events[evt];
80
+ }
81
+ function EventEmitter3() {
82
+ this._events = new Events();
83
+ this._eventsCount = 0;
84
+ }
85
+ EventEmitter3.prototype.eventNames = function eventNames() {
86
+ var names = [], events, name;
87
+ if (this._eventsCount === 0)
88
+ return names;
89
+ for (name in events = this._events) {
90
+ if (has.call(events, name))
91
+ names.push(prefix ? name.slice(1) : name);
92
+ }
93
+ if (Object.getOwnPropertySymbols) {
94
+ return names.concat(Object.getOwnPropertySymbols(events));
95
+ }
96
+ return names;
97
+ };
98
+ EventEmitter3.prototype.listeners = function listeners(event) {
99
+ var evt = prefix ? prefix + event : event, handlers = this._events[evt];
100
+ if (!handlers)
101
+ return [];
102
+ if (handlers.fn)
103
+ return [handlers.fn];
104
+ for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
105
+ ee[i] = handlers[i].fn;
106
+ }
107
+ return ee;
108
+ };
109
+ EventEmitter3.prototype.listenerCount = function listenerCount(event) {
110
+ var evt = prefix ? prefix + event : event, listeners = this._events[evt];
111
+ if (!listeners)
112
+ return 0;
113
+ if (listeners.fn)
114
+ return 1;
115
+ return listeners.length;
116
+ };
117
+ EventEmitter3.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
118
+ var evt = prefix ? prefix + event : event;
119
+ if (!this._events[evt])
120
+ return false;
121
+ var listeners = this._events[evt], len = arguments.length, args, i;
122
+ if (listeners.fn) {
123
+ if (listeners.once)
124
+ this.removeListener(event, listeners.fn, void 0, true);
125
+ switch (len) {
126
+ case 1:
127
+ return listeners.fn.call(listeners.context), true;
128
+ case 2:
129
+ return listeners.fn.call(listeners.context, a1), true;
130
+ case 3:
131
+ return listeners.fn.call(listeners.context, a1, a2), true;
132
+ case 4:
133
+ return listeners.fn.call(listeners.context, a1, a2, a3), true;
134
+ case 5:
135
+ return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
136
+ case 6:
137
+ return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
138
+ }
139
+ for (i = 1, args = new Array(len - 1); i < len; i++) {
140
+ args[i - 1] = arguments[i];
141
+ }
142
+ listeners.fn.apply(listeners.context, args);
143
+ } else {
144
+ var length = listeners.length, j;
145
+ for (i = 0; i < length; i++) {
146
+ if (listeners[i].once)
147
+ this.removeListener(event, listeners[i].fn, void 0, true);
148
+ switch (len) {
149
+ case 1:
150
+ listeners[i].fn.call(listeners[i].context);
151
+ break;
152
+ case 2:
153
+ listeners[i].fn.call(listeners[i].context, a1);
154
+ break;
155
+ case 3:
156
+ listeners[i].fn.call(listeners[i].context, a1, a2);
157
+ break;
158
+ case 4:
159
+ listeners[i].fn.call(listeners[i].context, a1, a2, a3);
160
+ break;
161
+ default:
162
+ if (!args)
163
+ for (j = 1, args = new Array(len - 1); j < len; j++) {
164
+ args[j - 1] = arguments[j];
165
+ }
166
+ listeners[i].fn.apply(listeners[i].context, args);
167
+ }
168
+ }
169
+ }
170
+ return true;
171
+ };
172
+ EventEmitter3.prototype.on = function on(event, fn, context) {
173
+ return addListener(this, event, fn, context, false);
174
+ };
175
+ EventEmitter3.prototype.once = function once(event, fn, context) {
176
+ return addListener(this, event, fn, context, true);
177
+ };
178
+ EventEmitter3.prototype.removeListener = function removeListener(event, fn, context, once) {
179
+ var evt = prefix ? prefix + event : event;
180
+ if (!this._events[evt])
181
+ return this;
182
+ if (!fn) {
183
+ clearEvent(this, evt);
184
+ return this;
185
+ }
186
+ var listeners = this._events[evt];
187
+ if (listeners.fn) {
188
+ if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
189
+ clearEvent(this, evt);
190
+ }
191
+ } else {
192
+ for (var i = 0, events = [], length = listeners.length; i < length; i++) {
193
+ if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
194
+ events.push(listeners[i]);
195
+ }
196
+ }
197
+ if (events.length)
198
+ this._events[evt] = events.length === 1 ? events[0] : events;
199
+ else
200
+ clearEvent(this, evt);
201
+ }
202
+ return this;
203
+ };
204
+ EventEmitter3.prototype.removeAllListeners = function removeAllListeners(event) {
205
+ var evt;
206
+ if (event) {
207
+ evt = prefix ? prefix + event : event;
208
+ if (this._events[evt])
209
+ clearEvent(this, evt);
210
+ } else {
211
+ this._events = new Events();
212
+ this._eventsCount = 0;
213
+ }
214
+ return this;
215
+ };
216
+ EventEmitter3.prototype.off = EventEmitter3.prototype.removeListener;
217
+ EventEmitter3.prototype.addListener = EventEmitter3.prototype.on;
218
+ EventEmitter3.prefixed = prefix;
219
+ EventEmitter3.EventEmitter = EventEmitter3;
220
+ if ("undefined" !== typeof module) {
221
+ module.exports = EventEmitter3;
222
+ }
223
+ }
224
+ });
225
+
226
+ // src/index.ts
227
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
228
+
229
+ // src/build.ts
230
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
231
+
232
+ // src/FileManager.ts
233
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
234
+ var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
235
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
236
+
237
+ // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
238
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
239
+
240
+ // ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
241
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
242
+ var import_index = _chunkOOZTXU7Fcjs.__toESM.call(void 0, require_eventemitter3(), 1);
243
+
244
+ // ../../node_modules/.pnpm/p-timeout@6.1.2/node_modules/p-timeout/index.js
245
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
246
+ var TimeoutError = class extends Error {
247
+ constructor(message) {
248
+ super(message);
249
+ this.name = "TimeoutError";
250
+ }
251
+ };
252
+ var AbortError = class extends Error {
253
+ constructor(message) {
254
+ super();
255
+ this.name = "AbortError";
256
+ this.message = message;
257
+ }
258
+ };
259
+ var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new AbortError(errorMessage) : new DOMException(errorMessage);
260
+ var getAbortedReason = (signal) => {
261
+ const reason = signal.reason === void 0 ? getDOMException("This operation was aborted.") : signal.reason;
262
+ return reason instanceof Error ? reason : getDOMException(reason);
263
+ };
264
+ function pTimeout(promise, options) {
265
+ const {
266
+ milliseconds,
267
+ fallback,
268
+ message,
269
+ customTimers = { setTimeout, clearTimeout }
270
+ } = options;
271
+ let timer;
272
+ const wrappedPromise = new Promise((resolve2, reject) => {
273
+ if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
274
+ throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
275
+ }
276
+ if (options.signal) {
277
+ const { signal } = options;
278
+ if (signal.aborted) {
279
+ reject(getAbortedReason(signal));
280
+ }
281
+ signal.addEventListener("abort", () => {
282
+ reject(getAbortedReason(signal));
283
+ });
284
+ }
285
+ if (milliseconds === Number.POSITIVE_INFINITY) {
286
+ promise.then(resolve2, reject);
287
+ return;
288
+ }
289
+ const timeoutError = new TimeoutError();
290
+ timer = customTimers.setTimeout.call(void 0, () => {
291
+ if (fallback) {
292
+ try {
293
+ resolve2(fallback());
294
+ } catch (error) {
295
+ reject(error);
296
+ }
297
+ return;
298
+ }
299
+ if (typeof promise.cancel === "function") {
300
+ promise.cancel();
301
+ }
302
+ if (message === false) {
303
+ resolve2();
304
+ } else if (message instanceof Error) {
305
+ reject(message);
306
+ } else {
307
+ timeoutError.message = _nullishCoalesce(message, () => ( `Promise timed out after ${milliseconds} milliseconds`));
308
+ reject(timeoutError);
309
+ }
310
+ }, milliseconds);
311
+ (async () => {
312
+ try {
313
+ resolve2(await promise);
314
+ } catch (error) {
315
+ reject(error);
316
+ }
317
+ })();
318
+ });
319
+ const cancelablePromise = wrappedPromise.finally(() => {
320
+ cancelablePromise.clear();
321
+ });
322
+ cancelablePromise.clear = () => {
323
+ customTimers.clearTimeout.call(void 0, timer);
324
+ timer = void 0;
325
+ };
326
+ return cancelablePromise;
327
+ }
328
+
329
+ // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/priority-queue.js
330
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
331
+
332
+ // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/lower-bound.js
333
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
334
+ function lowerBound(array, value, comparator) {
335
+ let first = 0;
336
+ let count = array.length;
337
+ while (count > 0) {
338
+ const step = Math.trunc(count / 2);
339
+ let it = first + step;
340
+ if (comparator(array[it], value) <= 0) {
341
+ first = ++it;
342
+ count -= step + 1;
343
+ } else {
344
+ count = step;
345
+ }
346
+ }
347
+ return first;
348
+ }
349
+
350
+ // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/priority-queue.js
351
+ var _queue;
352
+ var PriorityQueue = class {
353
+ constructor() {
354
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _queue, []);
355
+ }
356
+ enqueue(run, options) {
357
+ options = {
358
+ priority: 0,
359
+ ...options
360
+ };
361
+ const element = {
362
+ priority: options.priority,
363
+ run
364
+ };
365
+ if (this.size && _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue)[this.size - 1].priority >= options.priority) {
366
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue).push(element);
367
+ return;
368
+ }
369
+ const index = lowerBound(_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue), element, (a, b) => b.priority - a.priority);
370
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue).splice(index, 0, element);
371
+ }
372
+ dequeue() {
373
+ const item = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue).shift();
374
+ return _optionalChain([item, 'optionalAccess', _2 => _2.run]);
375
+ }
376
+ filter(options) {
377
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue).filter((element) => element.priority === options.priority).map((element) => element.run);
378
+ }
379
+ get size() {
380
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue).length;
381
+ }
382
+ };
383
+ _queue = new WeakMap();
384
+
385
+ // ../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js
386
+ var _carryoverConcurrencyCount, _isIntervalIgnored, _intervalCount, _intervalCap, _interval, _intervalEnd, _intervalId, _timeoutId, _queue2, _queueClass, _pending, _concurrency, _isPaused, _throwOnTimeout, _doesIntervalAllowAnother, doesIntervalAllowAnother_get, _doesConcurrentAllowAnother, doesConcurrentAllowAnother_get, _next, next_fn, _onResumeInterval, onResumeInterval_fn, _isIntervalPaused, isIntervalPaused_get, _tryToStartAnother, tryToStartAnother_fn, _initializeIntervalIfNeeded, initializeIntervalIfNeeded_fn, _onInterval, onInterval_fn, _processQueue, processQueue_fn, _throwOnAbort, throwOnAbort_fn, _onEvent, onEvent_fn;
387
+ var PQueue = class extends import_index.default {
388
+ // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
389
+ constructor(options) {
390
+ super();
391
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _doesIntervalAllowAnother);
392
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _doesConcurrentAllowAnother);
393
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _next);
394
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _onResumeInterval);
395
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _isIntervalPaused);
396
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _tryToStartAnother);
397
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _initializeIntervalIfNeeded);
398
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _onInterval);
399
+ /**
400
+ Executes all queued functions until it reaches the limit.
401
+ */
402
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _processQueue);
403
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _throwOnAbort);
404
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _onEvent);
405
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _carryoverConcurrencyCount, void 0);
406
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _isIntervalIgnored, void 0);
407
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _intervalCount, 0);
408
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _intervalCap, void 0);
409
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _interval, void 0);
410
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _intervalEnd, 0);
411
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _intervalId, void 0);
412
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _timeoutId, void 0);
413
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _queue2, void 0);
414
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _queueClass, void 0);
415
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _pending, 0);
416
+ // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
417
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _concurrency, void 0);
418
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _isPaused, void 0);
419
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _throwOnTimeout, void 0);
420
+ /**
421
+ Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.
422
+
423
+ Applies to each future operation.
424
+ */
425
+ _chunkOOZTXU7Fcjs.__publicField.call(void 0, this, "timeout");
426
+ options = {
427
+ carryoverConcurrencyCount: false,
428
+ intervalCap: Number.POSITIVE_INFINITY,
429
+ interval: 0,
430
+ concurrency: Number.POSITIVE_INFINITY,
431
+ autoStart: true,
432
+ queueClass: PriorityQueue,
433
+ ...options
434
+ };
435
+ if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
436
+ 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})`);
437
+ }
438
+ if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
439
+ 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})`);
440
+ }
441
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _carryoverConcurrencyCount, options.carryoverConcurrencyCount);
442
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0);
443
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _intervalCap, options.intervalCap);
444
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _interval, options.interval);
445
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _queue2, new options.queueClass());
446
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _queueClass, options.queueClass);
447
+ this.concurrency = options.concurrency;
448
+ this.timeout = options.timeout;
449
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _throwOnTimeout, options.throwOnTimeout === true);
450
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _isPaused, options.autoStart === false);
451
+ }
452
+ get concurrency() {
453
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _concurrency);
454
+ }
455
+ set concurrency(newConcurrency) {
456
+ if (!(typeof newConcurrency === "number" && newConcurrency >= 1)) {
457
+ throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${newConcurrency}\` (${typeof newConcurrency})`);
458
+ }
459
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _concurrency, newConcurrency);
460
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _processQueue, processQueue_fn).call(this);
461
+ }
462
+ async add(function_, options = {}) {
463
+ options = {
464
+ timeout: this.timeout,
465
+ throwOnTimeout: _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _throwOnTimeout),
466
+ ...options
467
+ };
468
+ return new Promise((resolve2, reject) => {
469
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).enqueue(async () => {
470
+ _chunkOOZTXU7Fcjs.__privateWrapper.call(void 0, this, _pending)._++;
471
+ _chunkOOZTXU7Fcjs.__privateWrapper.call(void 0, this, _intervalCount)._++;
472
+ try {
473
+ _optionalChain([options, 'access', _9 => _9.signal, 'optionalAccess', _10 => _10.throwIfAborted, 'call', _11 => _11()]);
474
+ let operation = function_({ signal: options.signal });
475
+ if (options.timeout) {
476
+ operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });
477
+ }
478
+ if (options.signal) {
479
+ operation = Promise.race([operation, _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _throwOnAbort, throwOnAbort_fn).call(this, options.signal)]);
480
+ }
481
+ const result = await operation;
482
+ resolve2(result);
483
+ this.emit("completed", result);
484
+ } catch (error) {
485
+ if (error instanceof TimeoutError && !options.throwOnTimeout) {
486
+ resolve2();
487
+ return;
488
+ }
489
+ reject(error);
490
+ this.emit("error", error);
491
+ } finally {
492
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _next, next_fn).call(this);
493
+ }
494
+ }, options);
495
+ this.emit("add");
496
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _tryToStartAnother, tryToStartAnother_fn).call(this);
497
+ });
498
+ }
499
+ async addAll(functions, options) {
500
+ return Promise.all(functions.map(async (function_) => this.add(function_, options)));
501
+ }
502
+ /**
503
+ 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.)
504
+ */
505
+ start() {
506
+ if (!_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _isPaused)) {
507
+ return this;
508
+ }
509
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _isPaused, false);
510
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _processQueue, processQueue_fn).call(this);
511
+ return this;
512
+ }
513
+ /**
514
+ Put queue execution on hold.
515
+ */
516
+ pause() {
517
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _isPaused, true);
518
+ }
519
+ /**
520
+ Clear the queue.
521
+ */
522
+ clear() {
523
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _queue2, new (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queueClass))());
524
+ }
525
+ /**
526
+ Can be called multiple times. Useful if you for example add additional items at a later time.
527
+
528
+ @returns A promise that settles when the queue becomes empty.
529
+ */
530
+ async onEmpty() {
531
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
532
+ return;
533
+ }
534
+ await _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _onEvent, onEvent_fn).call(this, "empty");
535
+ }
536
+ /**
537
+ @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
538
+
539
+ If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
540
+
541
+ 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.
542
+ */
543
+ async onSizeLessThan(limit) {
544
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).size < limit) {
545
+ return;
546
+ }
547
+ await _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _onEvent, onEvent_fn).call(this, "next", () => _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).size < limit);
548
+ }
549
+ /**
550
+ 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.
551
+
552
+ @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
553
+ */
554
+ async onIdle() {
555
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _pending) === 0 && _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
556
+ return;
557
+ }
558
+ await _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _onEvent, onEvent_fn).call(this, "idle");
559
+ }
560
+ /**
561
+ Size of the queue, the number of queued items waiting to run.
562
+ */
563
+ get size() {
564
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).size;
565
+ }
566
+ /**
567
+ Size of the queue, filtered by the given options.
568
+
569
+ For example, this can be used to find the number of items remaining in the queue with a specific priority level.
570
+ */
571
+ sizeBy(options) {
572
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).filter(options).length;
573
+ }
574
+ /**
575
+ Number of running items (no longer in the queue).
576
+ */
577
+ get pending() {
578
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _pending);
579
+ }
580
+ /**
581
+ Whether the queue is currently paused.
582
+ */
583
+ get isPaused() {
584
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _isPaused);
585
+ }
586
+ };
587
+ _carryoverConcurrencyCount = new WeakMap();
588
+ _isIntervalIgnored = new WeakMap();
589
+ _intervalCount = new WeakMap();
590
+ _intervalCap = new WeakMap();
591
+ _interval = new WeakMap();
592
+ _intervalEnd = new WeakMap();
593
+ _intervalId = new WeakMap();
594
+ _timeoutId = new WeakMap();
595
+ _queue2 = new WeakMap();
596
+ _queueClass = new WeakMap();
597
+ _pending = new WeakMap();
598
+ _concurrency = new WeakMap();
599
+ _isPaused = new WeakMap();
600
+ _throwOnTimeout = new WeakMap();
601
+ _doesIntervalAllowAnother = new WeakSet();
602
+ doesIntervalAllowAnother_get = function() {
603
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _isIntervalIgnored) || _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalCount) < _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalCap);
604
+ };
605
+ _doesConcurrentAllowAnother = new WeakSet();
606
+ doesConcurrentAllowAnother_get = function() {
607
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _pending) < _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _concurrency);
608
+ };
609
+ _next = new WeakSet();
610
+ next_fn = function() {
611
+ _chunkOOZTXU7Fcjs.__privateWrapper.call(void 0, this, _pending)._--;
612
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _tryToStartAnother, tryToStartAnother_fn).call(this);
613
+ this.emit("next");
614
+ };
615
+ _onResumeInterval = new WeakSet();
616
+ onResumeInterval_fn = function() {
617
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _onInterval, onInterval_fn).call(this);
618
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _initializeIntervalIfNeeded, initializeIntervalIfNeeded_fn).call(this);
619
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _timeoutId, void 0);
620
+ };
621
+ _isIntervalPaused = new WeakSet();
622
+ isIntervalPaused_get = function() {
623
+ const now = Date.now();
624
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalId) === void 0) {
625
+ const delay = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalEnd) - now;
626
+ if (delay < 0) {
627
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _intervalCount, _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _carryoverConcurrencyCount) ? _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _pending) : 0);
628
+ } else {
629
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _timeoutId) === void 0) {
630
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _timeoutId, setTimeout(() => {
631
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _onResumeInterval, onResumeInterval_fn).call(this);
632
+ }, delay));
633
+ }
634
+ return true;
635
+ }
636
+ }
637
+ return false;
638
+ };
639
+ _tryToStartAnother = new WeakSet();
640
+ tryToStartAnother_fn = function() {
641
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
642
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalId)) {
643
+ clearInterval(_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalId));
644
+ }
645
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _intervalId, void 0);
646
+ this.emit("empty");
647
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _pending) === 0) {
648
+ this.emit("idle");
649
+ }
650
+ return false;
651
+ }
652
+ if (!_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _isPaused)) {
653
+ const canInitializeInterval = !_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _isIntervalPaused, isIntervalPaused_get);
654
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _doesIntervalAllowAnother, doesIntervalAllowAnother_get) && _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _doesConcurrentAllowAnother, doesConcurrentAllowAnother_get)) {
655
+ const job = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue2).dequeue();
656
+ if (!job) {
657
+ return false;
658
+ }
659
+ this.emit("active");
660
+ job();
661
+ if (canInitializeInterval) {
662
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _initializeIntervalIfNeeded, initializeIntervalIfNeeded_fn).call(this);
663
+ }
664
+ return true;
665
+ }
666
+ }
667
+ return false;
668
+ };
669
+ _initializeIntervalIfNeeded = new WeakSet();
670
+ initializeIntervalIfNeeded_fn = function() {
671
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _isIntervalIgnored) || _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalId) !== void 0) {
672
+ return;
673
+ }
674
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _intervalId, setInterval(() => {
675
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _onInterval, onInterval_fn).call(this);
676
+ }, _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _interval)));
677
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _intervalEnd, Date.now() + _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _interval));
678
+ };
679
+ _onInterval = new WeakSet();
680
+ onInterval_fn = function() {
681
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalCount) === 0 && _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _pending) === 0 && _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalId)) {
682
+ clearInterval(_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _intervalId));
683
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _intervalId, void 0);
684
+ }
685
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _intervalCount, _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _carryoverConcurrencyCount) ? _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _pending) : 0);
686
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _processQueue, processQueue_fn).call(this);
687
+ };
688
+ _processQueue = new WeakSet();
689
+ processQueue_fn = function() {
690
+ while (_chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _tryToStartAnother, tryToStartAnother_fn).call(this)) {
691
+ }
692
+ };
693
+ _throwOnAbort = new WeakSet();
694
+ throwOnAbort_fn = async function(signal) {
695
+ return new Promise((_resolve, reject) => {
696
+ signal.addEventListener("abort", () => {
697
+ reject(signal.reason);
698
+ }, { once: true });
699
+ });
700
+ };
701
+ _onEvent = new WeakSet();
702
+ onEvent_fn = async function(event, filter) {
703
+ return new Promise((resolve2) => {
704
+ const listener = () => {
705
+ if (filter && !filter()) {
706
+ return;
707
+ }
708
+ this.off(event, listener);
709
+ resolve2();
710
+ };
711
+ this.on(event, listener);
712
+ });
713
+ };
714
+
715
+ // src/FileManager.ts
716
+ var _remeda = require('remeda');
717
+
718
+ // src/BarrelManager.ts
719
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
720
+ var _tsparser = require('@kubb/ts-parser');
721
+
722
+
723
+ // src/utils/TreeNode.ts
724
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
725
+ var _directorytree = require('directory-tree'); var _directorytree2 = _interopRequireDefault(_directorytree);
726
+ var TreeNode = class _TreeNode {
727
+ constructor(data, parent) {
728
+ this.children = [];
729
+ this.data = data;
730
+ this.parent = parent;
731
+ return this;
732
+ }
733
+ addChild(data) {
734
+ const child = new _TreeNode(data, this);
735
+ if (!this.children) {
736
+ this.children = [];
737
+ }
738
+ this.children.push(child);
739
+ return child;
740
+ }
741
+ find(data) {
742
+ if (!data) {
743
+ return null;
744
+ }
745
+ if (data === this.data) {
746
+ return this;
747
+ }
748
+ if (_optionalChain([this, 'access', _12 => _12.children, 'optionalAccess', _13 => _13.length])) {
749
+ for (let i = 0, { length } = this.children, target = null; i < length; i++) {
750
+ target = this.children[i].find(data);
751
+ if (target) {
752
+ return target;
753
+ }
754
+ }
755
+ }
756
+ return null;
757
+ }
758
+ get leaves() {
759
+ if (!this.children || this.children.length === 0) {
760
+ return [this];
761
+ }
762
+ const leaves = [];
763
+ if (this.children) {
764
+ for (let i = 0, { length } = this.children; i < length; i++) {
765
+ leaves.push.apply(leaves, this.children[i].leaves);
766
+ }
767
+ }
768
+ return leaves;
769
+ }
770
+ get root() {
771
+ if (!this.parent) {
772
+ return this;
773
+ }
774
+ return this.parent.root;
775
+ }
776
+ forEach(callback) {
777
+ if (typeof callback !== "function") {
778
+ throw new TypeError("forEach() callback must be a function");
779
+ }
780
+ callback(this);
781
+ if (this.children) {
782
+ for (let i = 0, { length } = this.children; i < length; i++) {
783
+ _optionalChain([this, 'access', _14 => _14.children, 'access', _15 => _15[i], 'optionalAccess', _16 => _16.forEach, 'call', _17 => _17(callback)]);
784
+ }
785
+ }
786
+ return this;
787
+ }
788
+ static build(path5, options = {}) {
789
+ try {
790
+ const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
791
+ const filteredTree = _directorytree2.default.call(void 0, path5, {
792
+ extensions: options.extensions,
793
+ exclude: [/node_modules/, ...exclude]
794
+ });
795
+ if (!filteredTree) {
796
+ return null;
797
+ }
798
+ const treeNode = new _TreeNode({
799
+ name: filteredTree.name,
800
+ path: filteredTree.path,
801
+ type: FileManager.getMode(filteredTree.path)
802
+ });
803
+ const recurse = (node, item) => {
804
+ const subNode = node.addChild({
805
+ name: item.name,
806
+ path: item.path,
807
+ type: FileManager.getMode(item.path)
808
+ });
809
+ if (_optionalChain([item, 'access', _18 => _18.children, 'optionalAccess', _19 => _19.length])) {
810
+ _optionalChain([item, 'access', _20 => _20.children, 'optionalAccess', _21 => _21.forEach, 'call', _22 => _22((child) => {
811
+ recurse(subNode, child);
812
+ })]);
813
+ }
814
+ };
815
+ _optionalChain([filteredTree, 'access', _23 => _23.children, 'optionalAccess', _24 => _24.forEach, 'call', _25 => _25((child) => recurse(treeNode, child))]);
816
+ return treeNode;
817
+ } catch (e) {
818
+ throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
819
+ }
820
+ }
821
+ };
822
+
823
+ // src/BarrelManager.ts
824
+ var _options;
825
+ var BarrelManager = class {
826
+ constructor(options = {}) {
827
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _options, void 0);
828
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _options, options);
829
+ return this;
830
+ }
831
+ getNamedExport(root, item) {
832
+ const exportedNames = _tsparser.getExports.call(void 0, _path2.default.resolve(root, item.path));
833
+ if (!exportedNames) {
834
+ return [item];
835
+ }
836
+ return exportedNames.reduce(
837
+ (prev, curr) => {
838
+ if (!_optionalChain([prev, 'access', _26 => _26[0], 'optionalAccess', _27 => _27.name]) || !_optionalChain([prev, 'access', _28 => _28[1], 'optionalAccess', _29 => _29.name])) {
839
+ return prev;
840
+ }
841
+ if (curr.isTypeOnly) {
842
+ prev[1] = { ...prev[1], name: [...prev[1].name, curr.name] };
843
+ } else {
844
+ prev[0] = { ...prev[0], name: [...prev[0].name, curr.name] };
845
+ }
846
+ return prev;
847
+ },
848
+ [
849
+ {
850
+ ...item,
851
+ name: [],
852
+ isTypeOnly: false
853
+ },
854
+ {
855
+ ...item,
856
+ name: [],
857
+ isTypeOnly: true
858
+ }
859
+ ]
860
+ );
861
+ }
862
+ getNamedExports(root, exports) {
863
+ return _optionalChain([exports, 'optionalAccess', _30 => _30.flatMap, 'call', _31 => _31((item) => {
864
+ return this.getNamedExport(root, item);
865
+ })]);
866
+ }
867
+ getIndexes(root) {
868
+ const { treeNode = {}, isTypeOnly, extName } = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _options);
869
+ const tree = TreeNode.build(root, treeNode);
870
+ if (!tree) {
871
+ return null;
872
+ }
873
+ const fileReducer = (files, treeNode2) => {
874
+ if (!treeNode2.children) {
875
+ return [];
876
+ }
877
+ if (treeNode2.children.length > 1) {
878
+ const indexPath = _path2.default.resolve(treeNode2.data.path, "index.ts");
879
+ const exports = treeNode2.children.filter(Boolean).map((file) => {
880
+ const importPath = file.data.type === "split" ? `./${file.data.name}/index` : `./${_chunkOCUNVJPQcjs.trimExtName.call(void 0, file.data.name)}`;
881
+ if (importPath.endsWith("index") && file.data.type === "single") {
882
+ return void 0;
883
+ }
884
+ return {
885
+ path: extName ? `${importPath}${extName}` : importPath,
886
+ isTypeOnly
887
+ };
888
+ }).filter(Boolean);
889
+ files.push({
890
+ path: indexPath,
891
+ baseName: "index.ts",
892
+ source: "",
893
+ exports,
894
+ exportable: true
895
+ });
896
+ } else if (treeNode2.children.length === 1) {
897
+ const [treeNodeChild] = treeNode2.children;
898
+ const indexPath = _path2.default.resolve(treeNode2.data.path, "index.ts");
899
+ const importPath = treeNodeChild.data.type === "split" ? `./${treeNodeChild.data.name}/index` : `./${_chunkOCUNVJPQcjs.trimExtName.call(void 0, treeNodeChild.data.name)}`;
900
+ const exports = [
901
+ {
902
+ path: extName ? `${importPath}${extName}` : importPath,
903
+ isTypeOnly
904
+ }
905
+ ];
906
+ files.push({
907
+ path: indexPath,
908
+ baseName: "index.ts",
909
+ source: "",
910
+ exports,
911
+ exportable: true
912
+ });
913
+ }
914
+ treeNode2.children.forEach((childItem) => {
915
+ fileReducer(files, childItem);
916
+ });
917
+ return files;
918
+ };
919
+ return fileReducer([], tree).reverse();
920
+ }
921
+ };
922
+ _options = new WeakMap();
923
+
924
+ // src/FileManager.ts
925
+ var KubbFile;
926
+ ((KubbFile2) => {
927
+ })(KubbFile || (KubbFile = exports.KubbFile = {}));
928
+ var _cache, _task, _queue3, _add, add_fn, _addOrAppend, addOrAppend_fn;
929
+ var _FileManager = class _FileManager {
930
+ constructor({ task = async (file) => file, queue = new PQueue() } = {}) {
931
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _add);
932
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _addOrAppend);
933
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _cache, /* @__PURE__ */ new Map());
934
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _task, void 0);
935
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _queue3, void 0);
936
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _task, task);
937
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _queue3, queue);
938
+ return this;
939
+ }
940
+ get files() {
941
+ const files = [];
942
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cache).forEach((item) => {
943
+ files.push(...item.flat(1));
944
+ });
945
+ return files;
946
+ }
947
+ get isExecuting() {
948
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue3).size !== 0 && _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue3).pending !== 0;
949
+ }
950
+ async add(...files) {
951
+ const promises = combineFiles(files).map((file) => {
952
+ if (file.override) {
953
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _add, add_fn).call(this, file);
954
+ }
955
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _addOrAppend, addOrAppend_fn).call(this, file);
956
+ });
957
+ const resolvedFiles = await Promise.all(promises);
958
+ if (files.length > 1) {
959
+ return resolvedFiles;
960
+ }
961
+ return resolvedFiles[0];
962
+ }
963
+ async addIndexes({ root, output, meta, logger, options = {} }) {
964
+ const { exportType = "barrel" } = output;
965
+ if (exportType === false) {
966
+ return void 0;
967
+ }
968
+ const pathToBuildFrom = _path.resolve.call(void 0, root, output.path);
969
+ if (_chunkOCUNVJPQcjs.transformers_default.trimExtName(pathToBuildFrom).endsWith("index")) {
970
+ logger.emit("warning", "Output has the same fileName as the barrelFiles, please disable barrel generation");
971
+ return;
972
+ }
973
+ const exportPath = output.path.startsWith("./") ? _chunkOCUNVJPQcjs.trimExtName.call(void 0, output.path) : `./${_chunkOCUNVJPQcjs.trimExtName.call(void 0, output.path)}`;
974
+ const mode = _FileManager.getMode(output.path);
975
+ const barrelManager = new BarrelManager({
976
+ extName: output.extName,
977
+ ...options
978
+ });
979
+ let files = barrelManager.getIndexes(pathToBuildFrom);
980
+ if (!files) {
981
+ return void 0;
982
+ }
983
+ if (exportType === "barrelNamed") {
984
+ files = files.map((file) => {
985
+ if (file.exports) {
986
+ return {
987
+ ...file,
988
+ exports: barrelManager.getNamedExports(pathToBuildFrom, file.exports)
989
+ };
990
+ }
991
+ return file;
992
+ });
993
+ }
994
+ await Promise.all(
995
+ files.map((file) => {
996
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _addOrAppend, addOrAppend_fn).call(this, {
997
+ ...file,
998
+ meta: meta ? meta : file.meta
999
+ });
1000
+ })
1001
+ );
1002
+ const rootPath = mode === "split" ? `${exportPath}/index${output.extName || ""}` : `${exportPath}${output.extName || ""}`;
1003
+ const rootFile = {
1004
+ path: _path.resolve.call(void 0, root, "index.ts"),
1005
+ baseName: "index.ts",
1006
+ source: "",
1007
+ exports: [
1008
+ output.exportAs ? {
1009
+ name: output.exportAs,
1010
+ asAlias: true,
1011
+ path: rootPath,
1012
+ isTypeOnly: options.isTypeOnly
1013
+ } : {
1014
+ path: rootPath,
1015
+ isTypeOnly: options.isTypeOnly
1016
+ }
1017
+ ],
1018
+ exportable: true
1019
+ };
1020
+ if (exportType === "barrelNamed" && !output.exportAs && _optionalChain([rootFile, 'access', _32 => _32.exports, 'optionalAccess', _33 => _33[0]])) {
1021
+ rootFile.exports = barrelManager.getNamedExport(root, rootFile.exports[0]);
1022
+ }
1023
+ await _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _addOrAppend, addOrAppend_fn).call(this, {
1024
+ ...rootFile,
1025
+ meta: meta ? meta : rootFile.meta
1026
+ });
1027
+ }
1028
+ getCacheByUUID(UUID) {
1029
+ let cache;
1030
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cache).forEach((files) => {
1031
+ cache = files.find((item) => item.id === UUID);
1032
+ });
1033
+ return cache;
1034
+ }
1035
+ get(path5) {
1036
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cache).get(path5);
1037
+ }
1038
+ remove(path5) {
1039
+ const cacheItem = this.get(path5);
1040
+ if (!cacheItem) {
1041
+ return;
1042
+ }
1043
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cache).delete(path5);
1044
+ }
1045
+ async write(...params) {
1046
+ return _chunk2H4XNW5Dcjs.write.call(void 0, ...params);
1047
+ }
1048
+ async read(...params) {
1049
+ return _chunk7HFYOZ7Fcjs.read.call(void 0, ...params);
1050
+ }
1051
+ // statics
1052
+ static async getSource(file) {
1053
+ return getSource(file);
1054
+ }
1055
+ static combineFiles(files) {
1056
+ return combineFiles(files);
1057
+ }
1058
+ static getMode(path5) {
1059
+ if (!path5) {
1060
+ return "split";
1061
+ }
1062
+ return _path.extname.call(void 0, path5) ? "single" : "split";
1063
+ }
1064
+ static get extensions() {
1065
+ return [".js", ".ts", ".tsx"];
1066
+ }
1067
+ static isJavascript(baseName) {
1068
+ return _FileManager.extensions.some((extension) => baseName.endsWith(extension));
1069
+ }
1070
+ };
1071
+ _cache = new WeakMap();
1072
+ _task = new WeakMap();
1073
+ _queue3 = new WeakMap();
1074
+ _add = new WeakSet();
1075
+ add_fn = async function(file) {
1076
+ const controller = new AbortController();
1077
+ const resolvedFile = {
1078
+ id: _crypto2.default.randomUUID(),
1079
+ name: _chunkOCUNVJPQcjs.trimExtName.call(void 0, file.baseName),
1080
+ ...file
1081
+ };
1082
+ if (_optionalChain([resolvedFile, 'access', _34 => _34.exports, 'optionalAccess', _35 => _35.length])) {
1083
+ const folder = resolvedFile.path.replace(resolvedFile.baseName, "");
1084
+ resolvedFile.exports = resolvedFile.exports.filter((exportItem) => {
1085
+ const exportedFile = this.files.find((file2) => file2.path.includes(_path.resolve.call(void 0, folder, exportItem.path)));
1086
+ if (exportedFile) {
1087
+ return exportedFile.exportable;
1088
+ }
1089
+ return true;
1090
+ });
1091
+ }
1092
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
1093
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _queue3).add(
1094
+ async () => {
1095
+ var _a;
1096
+ return (_a = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _task)) == null ? void 0 : _a.call(this, resolvedFile);
1097
+ },
1098
+ { signal: controller.signal }
1099
+ );
1100
+ };
1101
+ _addOrAppend = new WeakSet();
1102
+ addOrAppend_fn = async function(file) {
1103
+ const previousCaches = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cache).get(file.path);
1104
+ const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
1105
+ if (previousCache) {
1106
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cache).delete(previousCache.path);
1107
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _add, add_fn).call(this, {
1108
+ ...file,
1109
+ source: previousCache.source && file.source ? `${previousCache.source}
1110
+ ${file.source}` : "",
1111
+ imports: [...previousCache.imports || [], ...file.imports || []],
1112
+ exports: [...previousCache.exports || [], ...file.exports || []],
1113
+ env: { ...previousCache.env || {}, ...file.env || {} }
1114
+ });
1115
+ }
1116
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _add, add_fn).call(this, file);
1117
+ };
1118
+ var FileManager = _FileManager;
1119
+ function combineFiles(files) {
1120
+ return files.filter(Boolean).reduce(
1121
+ (acc, file) => {
1122
+ const prevIndex = acc.findIndex((item) => item.path === file.path);
1123
+ if (prevIndex === -1) {
1124
+ return [...acc, file];
1125
+ }
1126
+ const prev = acc[prevIndex];
1127
+ if (prev && file.override) {
1128
+ acc[prevIndex] = {
1129
+ imports: [],
1130
+ exports: [],
1131
+ ...file
1132
+ };
1133
+ return acc;
1134
+ }
1135
+ if (prev) {
1136
+ acc[prevIndex] = {
1137
+ ...file,
1138
+ source: prev.source && file.source ? `${prev.source}
1139
+ ${file.source}` : "",
1140
+ imports: [...prev.imports || [], ...file.imports || []],
1141
+ exports: [...prev.exports || [], ...file.exports || []],
1142
+ env: { ...prev.env || {}, ...file.env || {} }
1143
+ };
1144
+ }
1145
+ return acc;
1146
+ },
1147
+ []
1148
+ );
1149
+ }
1150
+ async function getSource(file) {
1151
+ if (file.language ? !["typescript", "javascript"].includes(file.language) : !FileManager.isJavascript(file.baseName)) {
1152
+ return file.source;
1153
+ }
1154
+ const parser = await _chunkXF35HUZ2cjs.getParser.call(void 0, file.language);
1155
+ const exports = file.exports ? combineExports(file.exports) : [];
1156
+ const imports = file.imports && file.source ? combineImports(file.imports, exports, file.source) : [];
1157
+ const importNodes = imports.filter((item) => {
1158
+ const path5 = item.root ? _chunk7HFYOZ7Fcjs.getRelativePath.call(void 0, item.root, item.path) : item.path;
1159
+ return path5 !== _chunkOCUNVJPQcjs.trimExtName.call(void 0, file.path);
1160
+ }).map((item) => {
1161
+ return parser.factory.createImportDeclaration({
1162
+ name: item.name,
1163
+ path: item.root ? _chunk7HFYOZ7Fcjs.getRelativePath.call(void 0, item.root, item.path) : item.path,
1164
+ isTypeOnly: item.isTypeOnly
1165
+ });
1166
+ });
1167
+ const exportNodes = exports.map(
1168
+ (item) => parser.factory.createExportDeclaration({
1169
+ name: item.name,
1170
+ path: item.path,
1171
+ isTypeOnly: item.isTypeOnly,
1172
+ asAlias: item.asAlias
1173
+ })
1174
+ );
1175
+ const source = [parser.print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join("\n");
1176
+ return parser.print([], { source, noEmitHelpers: false });
1177
+ }
1178
+ function combineExports(exports) {
1179
+ const combinedExports = _chunk5T2QA53Bcjs.orderBy.call(void 0, exports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
1180
+ (prev, curr) => {
1181
+ const name = curr.name;
1182
+ const prevByPath = prev.findLast((imp) => imp.path === curr.path);
1183
+ const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly);
1184
+ if (prevByPathAndIsTypeOnly) {
1185
+ return prev;
1186
+ }
1187
+ const uniquePrev = prev.findLast(
1188
+ (imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
1189
+ );
1190
+ if (uniquePrev || Array.isArray(name) && !name.length || _optionalChain([prevByPath, 'optionalAccess', _36 => _36.asAlias]) && !curr.asAlias) {
1191
+ return prev;
1192
+ }
1193
+ if (!prevByPath) {
1194
+ return [
1195
+ ...prev,
1196
+ {
1197
+ ...curr,
1198
+ name: Array.isArray(name) ? [...new Set(name)] : name
1199
+ }
1200
+ ];
1201
+ }
1202
+ if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
1203
+ prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...curr.name])];
1204
+ return prev;
1205
+ }
1206
+ return [...prev, curr];
1207
+ },
1208
+ []
1209
+ );
1210
+ return _chunk5T2QA53Bcjs.orderBy.call(void 0, combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ["desc", "desc"]);
1211
+ }
1212
+ function combineImports(imports, exports, source) {
1213
+ const combinedImports = _chunk5T2QA53Bcjs.orderBy.call(void 0, imports, [(v) => !v.isTypeOnly], ["asc"]).reduce(
1214
+ (prev, curr) => {
1215
+ let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
1216
+ const hasImportInSource = (importName) => {
1217
+ if (!source) {
1218
+ return true;
1219
+ }
1220
+ const checker = (name2) => name2 && !!source.includes(name2);
1221
+ return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
1222
+ };
1223
+ if (curr.path === curr.root) {
1224
+ return prev;
1225
+ }
1226
+ if (Array.isArray(name)) {
1227
+ name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
1228
+ }
1229
+ const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
1230
+ const uniquePrev = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
1231
+ const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && _remeda.isDeepEqual.call(void 0, imp.name, name) && imp.isTypeOnly);
1232
+ if (prevByPathNameAndIsTypeOnly) {
1233
+ return prev;
1234
+ }
1235
+ if (uniquePrev || Array.isArray(name) && !name.length) {
1236
+ return prev;
1237
+ }
1238
+ if (!prevByPath) {
1239
+ return [
1240
+ ...prev,
1241
+ {
1242
+ ...curr,
1243
+ name
1244
+ }
1245
+ ];
1246
+ }
1247
+ if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
1248
+ prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...name])];
1249
+ return prev;
1250
+ }
1251
+ if (!Array.isArray(name) && name && !hasImportInSource(name)) {
1252
+ return prev;
1253
+ }
1254
+ return [...prev, curr];
1255
+ },
1256
+ []
1257
+ );
1258
+ return _chunk5T2QA53Bcjs.orderBy.call(void 0, combinedImports, [(v) => !v.isTypeOnly], ["desc"]);
1259
+ }
1260
+ function getEnvSource(source, env) {
1261
+ if (!env) {
1262
+ return source;
1263
+ }
1264
+ const keys = Object.keys(env);
1265
+ if (!keys.length) {
1266
+ return source;
1267
+ }
1268
+ return keys.reduce((prev, key) => {
1269
+ const environmentValue = env[key];
1270
+ const replaceBy = environmentValue ? `'${_optionalChain([environmentValue, 'access', _37 => _37.replaceAll, 'call', _38 => _38('"', ""), 'optionalAccess', _39 => _39.replaceAll, 'call', _40 => _40("'", "")])}'` : "undefined";
1271
+ if (key.toUpperCase() !== key) {
1272
+ throw new TypeError(`Environment should be in upperCase for ${key}`);
1273
+ }
1274
+ if (typeof replaceBy === "string") {
1275
+ prev = _chunkOCUNVJPQcjs.searchAndReplace.call(void 0, {
1276
+ text: prev.replaceAll(`process.env.${key}`, replaceBy),
1277
+ replaceBy,
1278
+ prefix: "process.env",
1279
+ key
1280
+ });
1281
+ prev = _chunkOCUNVJPQcjs.searchAndReplace.call(void 0, {
1282
+ text: prev.replaceAll(/(declare const).*\n/gi, ""),
1283
+ replaceBy,
1284
+ key
1285
+ });
1286
+ }
1287
+ return prev;
1288
+ }, source);
1289
+ }
1290
+
1291
+ // src/PluginManager.ts
1292
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
1293
+
1294
+ // src/PromiseManager.ts
1295
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
1296
+
1297
+ // src/utils/executeStrategies.ts
1298
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
1299
+ function hookSeq(promises) {
1300
+ return promises.filter(Boolean).reduce(
1301
+ (promise, func) => {
1302
+ if (typeof func !== "function") {
1303
+ throw new Error("HookSeq needs a function that returns a promise `() => Promise<unknown>`");
1304
+ }
1305
+ return promise.then((state) => {
1306
+ const calledFunc = func(state);
1307
+ if (calledFunc) {
1308
+ return calledFunc.then(Array.prototype.concat.bind(state));
1309
+ }
1310
+ });
1311
+ },
1312
+ Promise.resolve([])
1313
+ );
1314
+ }
1315
+ function hookFirst(promises, nullCheck = (state) => state !== null) {
1316
+ let promise = Promise.resolve(null);
1317
+ for (const func of promises.filter(Boolean)) {
1318
+ promise = promise.then((state) => {
1319
+ if (nullCheck(state)) {
1320
+ return state;
1321
+ }
1322
+ const calledFunc = func(state);
1323
+ return calledFunc;
1324
+ });
1325
+ }
1326
+ return promise;
1327
+ }
1328
+ function hookParallel(promises) {
1329
+ return Promise.allSettled(promises.filter(Boolean).map((promise) => promise()));
1330
+ }
1331
+
1332
+ // src/PromiseManager.ts
1333
+ var _options2;
1334
+ var PromiseManager = class {
1335
+ constructor(options = {}) {
1336
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _options2, {});
1337
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _options2, options);
1338
+ return this;
1339
+ }
1340
+ run(strategy, promises) {
1341
+ if (strategy === "seq") {
1342
+ return hookSeq(promises);
1343
+ }
1344
+ if (strategy === "first") {
1345
+ return hookFirst(promises, _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _options2).nullCheck);
1346
+ }
1347
+ if (strategy === "parallel") {
1348
+ return hookParallel(promises);
1349
+ }
1350
+ throw new Error(`${strategy} not implemented`);
1351
+ }
1352
+ };
1353
+ _options2 = new WeakMap();
1354
+ function isPromise(result) {
1355
+ return !!result && typeof _optionalChain([result, 'optionalAccess', _41 => _41.then]) === "function";
1356
+ }
1357
+ function isPromiseRejectedResult(result) {
1358
+ return result.status === "rejected";
1359
+ }
1360
+
1361
+ // src/errors.ts
1362
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
1363
+ var Warning = class extends Error {
1364
+ constructor(message, options) {
1365
+ super(message, { cause: _optionalChain([options, 'optionalAccess', _42 => _42.cause]) });
1366
+ this.name = "Warning";
1367
+ }
1368
+ };
1369
+ var ValidationPluginError = class extends Error {
1370
+ };
1371
+
1372
+ // src/plugin.ts
1373
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
1374
+
1375
+
1376
+ // src/utils/cache.ts
1377
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
1378
+ function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
1379
+ return {
1380
+ set(id, value) {
1381
+ Store[id] = [0, value];
1382
+ },
1383
+ get(id) {
1384
+ const item = Store[id];
1385
+ if (!item) {
1386
+ return null;
1387
+ }
1388
+ item[0] = 0;
1389
+ return item[1];
1390
+ },
1391
+ has(id) {
1392
+ const item = Store[id];
1393
+ if (!item) {
1394
+ return false;
1395
+ }
1396
+ item[0] = 0;
1397
+ return true;
1398
+ },
1399
+ delete(id) {
1400
+ return delete Store[id];
1401
+ }
1402
+ };
1403
+ }
1404
+
1405
+ // src/plugin.ts
1406
+ function createPlugin(factory) {
1407
+ return (options) => {
1408
+ return factory(options);
1409
+ };
1410
+ }
1411
+ var pluginName = "core";
1412
+ var definePlugin = createPlugin((options) => {
1413
+ const { fileManager, pluginManager, resolvePath, resolveName, logger } = options;
1414
+ return {
1415
+ name: pluginName,
1416
+ options,
1417
+ key: ["core"],
1418
+ api() {
1419
+ return {
1420
+ get config() {
1421
+ return options.config;
1422
+ },
1423
+ get plugins() {
1424
+ return options.getPlugins();
1425
+ },
1426
+ get plugin() {
1427
+ return options.plugin;
1428
+ },
1429
+ logger,
1430
+ fileManager,
1431
+ pluginManager,
1432
+ async addFile(...files) {
1433
+ const resolvedFiles = await fileManager.add(...files);
1434
+ if (!Array.isArray(resolvedFiles)) {
1435
+ return [resolvedFiles];
1436
+ }
1437
+ return resolvedFiles;
1438
+ },
1439
+ resolvePath,
1440
+ resolveName,
1441
+ cache: createPluginCache()
1442
+ };
1443
+ },
1444
+ resolvePath(baseName) {
1445
+ const root = _path2.default.resolve(this.config.root, this.config.output.path);
1446
+ return _path2.default.resolve(root, baseName);
1447
+ },
1448
+ resolveName(name) {
1449
+ return name;
1450
+ }
1451
+ };
1452
+ });
1453
+
1454
+ // src/PluginManager.ts
1455
+ var _core, _usedPluginNames, _promiseManager, _getSortedPlugins, getSortedPlugins_fn, _addExecutedToCallStack, addExecutedToCallStack_fn, _execute, execute_fn, _executeSync, executeSync_fn, _catcher, catcher_fn, _parse, parse_fn;
1456
+ var PluginManager = class {
1457
+ constructor(config, options) {
1458
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _getSortedPlugins);
1459
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _addExecutedToCallStack);
1460
+ /**
1461
+ * Run an async plugin hook and return the result.
1462
+ * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
1463
+ * @param args Arguments passed to the plugin hook.
1464
+ * @param plugin The actual pluginObject to run.
1465
+ */
1466
+ // Implementation signature
1467
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _execute);
1468
+ /**
1469
+ * Run a sync plugin hook and return the result.
1470
+ * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
1471
+ * @param args Arguments passed to the plugin hook.
1472
+ * @param plugin The acutal plugin
1473
+ * @param replaceContext When passed, the plugin context can be overridden.
1474
+ */
1475
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _executeSync);
1476
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _catcher);
1477
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _parse);
1478
+ this.events = new (0, _chunkSU2W2A6Vcjs.EventEmitter)();
1479
+ this.executed = [];
1480
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _core, void 0);
1481
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _usedPluginNames, {});
1482
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _promiseManager, void 0);
1483
+ this.resolvePath = (params) => {
1484
+ if (params.pluginKey) {
1485
+ const paths = this.hookForPluginSync({
1486
+ pluginKey: params.pluginKey,
1487
+ hookName: "resolvePath",
1488
+ parameters: [params.baseName, params.mode, params.options]
1489
+ });
1490
+ if (paths && _optionalChain([paths, 'optionalAccess', _43 => _43.length]) > 1) {
1491
+ this.logger.emit("debug", [
1492
+ `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1493
+
1494
+ Paths: ${JSON.stringify(paths, void 0, 2)}
1495
+
1496
+ Falling back on the first item.
1497
+ `
1498
+ ]);
1499
+ }
1500
+ return _optionalChain([paths, 'optionalAccess', _44 => _44.at, 'call', _45 => _45(0)]);
1501
+ }
1502
+ return this.hookFirstSync({
1503
+ hookName: "resolvePath",
1504
+ parameters: [params.baseName, params.mode, params.options]
1505
+ }).result;
1506
+ };
1507
+ this.resolveName = (params) => {
1508
+ if (params.pluginKey) {
1509
+ const names = this.hookForPluginSync({
1510
+ pluginKey: params.pluginKey,
1511
+ hookName: "resolveName",
1512
+ parameters: [params.name, params.type]
1513
+ });
1514
+ if (names && _optionalChain([names, 'optionalAccess', _46 => _46.length]) > 1) {
1515
+ this.logger.emit("debug", [
1516
+ `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1517
+
1518
+ Names: ${JSON.stringify(names, void 0, 2)}
1519
+
1520
+ Falling back on the first item.
1521
+ `
1522
+ ]);
1523
+ }
1524
+ return _chunkOCUNVJPQcjs.transformReservedWord.call(void 0, _optionalChain([names, 'optionalAccess', _47 => _47.at, 'call', _48 => _48(0)]) || params.name);
1525
+ }
1526
+ const name = this.hookFirstSync({
1527
+ hookName: "resolveName",
1528
+ parameters: [params.name, params.type]
1529
+ }).result;
1530
+ return _chunkOCUNVJPQcjs.transformReservedWord.call(void 0, name);
1531
+ };
1532
+ this.config = config;
1533
+ this.logger = options.logger;
1534
+ this.queue = new PQueue({ concurrency: 1 });
1535
+ this.fileManager = new FileManager({
1536
+ task: options.task,
1537
+ queue: this.queue
1538
+ });
1539
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _promiseManager, new PromiseManager({
1540
+ nullCheck: (state) => !!_optionalChain([state, 'optionalAccess', _49 => _49.result])
1541
+ }));
1542
+ const plugins = config.plugins || [];
1543
+ const core = definePlugin({
1544
+ config,
1545
+ logger: this.logger,
1546
+ pluginManager: this,
1547
+ fileManager: this.fileManager,
1548
+ resolvePath: this.resolvePath.bind(this),
1549
+ resolveName: this.resolveName.bind(this),
1550
+ getPlugins: _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).bind(this)
1551
+ });
1552
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _core, _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _parse, parse_fn).call(this, core, this, core.api.call(null)));
1553
+ this.plugins = [_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _core), ...plugins].map((plugin) => {
1554
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _parse, parse_fn).call(this, plugin, this, _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _core).api);
1555
+ });
1556
+ return this;
1557
+ }
1558
+ getFile({ name, mode, extName, pluginKey, options }) {
1559
+ let source = "";
1560
+ const baseName = `${name}${extName}`;
1561
+ const path5 = this.resolvePath({ baseName, mode, pluginKey, options });
1562
+ if (!path5) {
1563
+ throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
1564
+ }
1565
+ try {
1566
+ source = _chunk7HFYOZ7Fcjs.readSync.call(void 0, path5);
1567
+ } catch (_e) {
1568
+ }
1569
+ return {
1570
+ path: path5,
1571
+ baseName,
1572
+ meta: {
1573
+ pluginKey
1574
+ },
1575
+ source
1576
+ };
1577
+ }
1578
+ /**
1579
+ * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
1580
+ */
1581
+ on(eventName, handler) {
1582
+ this.events.on(eventName, handler);
1583
+ }
1584
+ /**
1585
+ * Run a specific hookName for plugin x.
1586
+ */
1587
+ hookForPlugin({
1588
+ pluginKey,
1589
+ hookName,
1590
+ parameters
1591
+ }) {
1592
+ const plugins = this.getPluginsByKey(hookName, pluginKey);
1593
+ const promises = plugins.map((plugin) => {
1594
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
1595
+ strategy: "hookFirst",
1596
+ hookName,
1597
+ parameters,
1598
+ plugin
1599
+ });
1600
+ }).filter(Boolean);
1601
+ return Promise.all(promises);
1602
+ }
1603
+ /**
1604
+ * Run a specific hookName for plugin x.
1605
+ */
1606
+ hookForPluginSync({
1607
+ pluginKey,
1608
+ hookName,
1609
+ parameters
1610
+ }) {
1611
+ const plugins = this.getPluginsByKey(hookName, pluginKey);
1612
+ return plugins.map((plugin) => {
1613
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _executeSync, executeSync_fn).call(this, {
1614
+ strategy: "hookFirst",
1615
+ hookName,
1616
+ parameters,
1617
+ plugin
1618
+ });
1619
+ }).filter(Boolean);
1620
+ }
1621
+ /**
1622
+ * First non-null result stops and will return it's value.
1623
+ */
1624
+ async hookFirst({
1625
+ hookName,
1626
+ parameters,
1627
+ skipped
1628
+ }) {
1629
+ const promises = _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this).filter((plugin) => {
1630
+ return skipped ? skipped.has(plugin) : true;
1631
+ }).map((plugin) => {
1632
+ return async () => {
1633
+ const value = await _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
1634
+ strategy: "hookFirst",
1635
+ hookName,
1636
+ parameters,
1637
+ plugin
1638
+ });
1639
+ return Promise.resolve({
1640
+ plugin,
1641
+ result: value
1642
+ });
1643
+ };
1644
+ });
1645
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _promiseManager).run("first", promises);
1646
+ }
1647
+ /**
1648
+ * First non-null result stops and will return it's value.
1649
+ */
1650
+ hookFirstSync({
1651
+ hookName,
1652
+ parameters,
1653
+ skipped
1654
+ }) {
1655
+ let parseResult = null;
1656
+ for (const plugin of _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1657
+ if (_optionalChain([skipped, 'optionalAccess', _50 => _50.has, 'call', _51 => _51(plugin)])) {
1658
+ continue;
1659
+ }
1660
+ parseResult = {
1661
+ result: _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _executeSync, executeSync_fn).call(this, {
1662
+ strategy: "hookFirst",
1663
+ hookName,
1664
+ parameters,
1665
+ plugin
1666
+ }),
1667
+ plugin
1668
+ };
1669
+ if (_optionalChain([parseResult, 'optionalAccess', _52 => _52.result]) != null) {
1670
+ break;
1671
+ }
1672
+ }
1673
+ return parseResult;
1674
+ }
1675
+ /**
1676
+ * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
1677
+ */
1678
+ async hookParallel({
1679
+ hookName,
1680
+ parameters
1681
+ }) {
1682
+ const promises = _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
1683
+ return () => _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
1684
+ strategy: "hookParallel",
1685
+ hookName,
1686
+ parameters,
1687
+ plugin
1688
+ });
1689
+ });
1690
+ const results = await _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _promiseManager).run("parallel", promises);
1691
+ results.forEach((result, index) => {
1692
+ if (isPromiseRejectedResult(result)) {
1693
+ const plugin = _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this)[index];
1694
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _catcher, catcher_fn).call(this, result.reason, plugin, hookName);
1695
+ }
1696
+ });
1697
+ return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
1698
+ }
1699
+ /**
1700
+ * Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.
1701
+ */
1702
+ hookReduceArg0({
1703
+ hookName,
1704
+ parameters,
1705
+ reduce
1706
+ }) {
1707
+ const [argument0, ...rest] = parameters;
1708
+ let promise = Promise.resolve(argument0);
1709
+ for (const plugin of _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1710
+ promise = promise.then((arg0) => {
1711
+ const value = _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
1712
+ strategy: "hookReduceArg0",
1713
+ hookName,
1714
+ parameters: [arg0, ...rest],
1715
+ plugin
1716
+ });
1717
+ return value;
1718
+ }).then((result) => reduce.call(_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _core).api, argument0, result, plugin));
1719
+ }
1720
+ return promise;
1721
+ }
1722
+ /**
1723
+ * Chains plugins
1724
+ */
1725
+ async hookSeq({ hookName, parameters }) {
1726
+ const promises = _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
1727
+ return () => _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
1728
+ strategy: "hookSeq",
1729
+ hookName,
1730
+ parameters,
1731
+ plugin
1732
+ });
1733
+ });
1734
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _promiseManager).run("seq", promises);
1735
+ }
1736
+ getPluginsByKey(hookName, pluginKey) {
1737
+ const plugins = [...this.plugins];
1738
+ const [searchPluginName, searchIdentifier] = pluginKey;
1739
+ const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
1740
+ const [name, identifier] = item.key;
1741
+ const identifierCheck = _optionalChain([identifier, 'optionalAccess', _53 => _53.toString, 'call', _54 => _54()]) === _optionalChain([searchIdentifier, 'optionalAccess', _55 => _55.toString, 'call', _56 => _56()]);
1742
+ const nameCheck = name === searchPluginName;
1743
+ if (searchIdentifier) {
1744
+ return identifierCheck && nameCheck;
1745
+ }
1746
+ return nameCheck;
1747
+ });
1748
+ if (!_optionalChain([pluginByPluginName, 'optionalAccess', _57 => _57.length])) {
1749
+ const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
1750
+ if (corePlugin) {
1751
+ this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`]);
1752
+ } else {
1753
+ this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`]);
1754
+ }
1755
+ return corePlugin ? [corePlugin] : [];
1756
+ }
1757
+ return pluginByPluginName;
1758
+ }
1759
+ static getDependedPlugins(plugins, dependedPluginNames) {
1760
+ let pluginNames = [];
1761
+ if (typeof dependedPluginNames === "string") {
1762
+ pluginNames = [dependedPluginNames];
1763
+ } else {
1764
+ pluginNames = dependedPluginNames;
1765
+ }
1766
+ return pluginNames.map((pluginName2) => {
1767
+ const plugin = plugins.find((plugin2) => plugin2.name === pluginName2);
1768
+ if (!plugin) {
1769
+ throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
1770
+ }
1771
+ return plugin;
1772
+ });
1773
+ }
1774
+ static get hooks() {
1775
+ return ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
1776
+ }
1777
+ };
1778
+ _core = new WeakMap();
1779
+ _usedPluginNames = new WeakMap();
1780
+ _promiseManager = new WeakMap();
1781
+ _getSortedPlugins = new WeakSet();
1782
+ getSortedPlugins_fn = function(hookName) {
1783
+ const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
1784
+ if (hookName) {
1785
+ if (this.logger.logLevel === _chunkSU2W2A6Vcjs.LogLevel.info) {
1786
+ const containsHookName = plugins.some((item) => item[hookName]);
1787
+ if (!containsHookName) {
1788
+ this.logger.emit("warning", `No hook ${hookName} found`);
1789
+ }
1790
+ }
1791
+ return plugins.filter((item) => item[hookName]);
1792
+ }
1793
+ return plugins.map((plugin) => {
1794
+ if (plugin.pre) {
1795
+ const isValid = plugin.pre.every((pluginName2) => plugins.find((pluginToFind) => pluginToFind.name === pluginName2));
1796
+ if (!isValid) {
1797
+ throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
1798
+ }
1799
+ }
1800
+ return plugin;
1801
+ }).sort((a, b) => {
1802
+ if (_optionalChain([b, 'access', _58 => _58.pre, 'optionalAccess', _59 => _59.includes, 'call', _60 => _60(a.name)])) {
1803
+ return 1;
1804
+ }
1805
+ if (_optionalChain([b, 'access', _61 => _61.post, 'optionalAccess', _62 => _62.includes, 'call', _63 => _63(a.name)])) {
1806
+ return -1;
1807
+ }
1808
+ return 0;
1809
+ });
1810
+ };
1811
+ _addExecutedToCallStack = new WeakSet();
1812
+ addExecutedToCallStack_fn = function(executer) {
1813
+ if (executer) {
1814
+ this.events.emit("executed", executer);
1815
+ this.executed.push(executer);
1816
+ }
1817
+ };
1818
+ _execute = new WeakSet();
1819
+ execute_fn = function({
1820
+ strategy,
1821
+ hookName,
1822
+ parameters,
1823
+ plugin
1824
+ }) {
1825
+ const hook = plugin[hookName];
1826
+ let output;
1827
+ if (!hook) {
1828
+ return null;
1829
+ }
1830
+ this.events.emit("execute", { strategy, hookName, parameters, plugin });
1831
+ const task = Promise.resolve().then(() => {
1832
+ if (typeof hook === "function") {
1833
+ const possiblePromiseResult = hook.apply({ ..._chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _core).api, plugin }, parameters);
1834
+ if (isPromise(possiblePromiseResult)) {
1835
+ return Promise.resolve(possiblePromiseResult);
1836
+ }
1837
+ return possiblePromiseResult;
1838
+ }
1839
+ return hook;
1840
+ }).then((result) => {
1841
+ output = result;
1842
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
1843
+ parameters,
1844
+ output,
1845
+ strategy,
1846
+ hookName,
1847
+ plugin
1848
+ });
1849
+ return result;
1850
+ }).catch((e) => {
1851
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _catcher, catcher_fn).call(this, e, plugin, hookName);
1852
+ return null;
1853
+ });
1854
+ return task;
1855
+ };
1856
+ _executeSync = new WeakSet();
1857
+ executeSync_fn = function({
1858
+ strategy,
1859
+ hookName,
1860
+ parameters,
1861
+ plugin
1862
+ }) {
1863
+ const hook = plugin[hookName];
1864
+ let output;
1865
+ if (!hook) {
1866
+ return null;
1867
+ }
1868
+ this.events.emit("execute", { strategy, hookName, parameters, plugin });
1869
+ try {
1870
+ if (typeof hook === "function") {
1871
+ const fn = hook.apply({ ..._chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _core).api, plugin }, parameters);
1872
+ output = fn;
1873
+ return fn;
1874
+ }
1875
+ output = hook;
1876
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
1877
+ parameters,
1878
+ output,
1879
+ strategy,
1880
+ hookName,
1881
+ plugin
1882
+ });
1883
+ return hook;
1884
+ } catch (e) {
1885
+ _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _catcher, catcher_fn).call(this, e, plugin, hookName);
1886
+ return null;
1887
+ }
1888
+ };
1889
+ _catcher = new WeakSet();
1890
+ catcher_fn = function(cause, plugin, hookName) {
1891
+ const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _64 => _64.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
1892
+ this.logger.emit("error", text, cause);
1893
+ this.events.emit("error", cause);
1894
+ };
1895
+ _parse = new WeakSet();
1896
+ parse_fn = function(plugin, pluginManager, context) {
1897
+ const usedPluginNames = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, pluginManager, _usedPluginNames);
1898
+ _chunkXF35HUZ2cjs.setUniqueName.call(void 0, plugin.name, usedPluginNames);
1899
+ const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
1900
+ if (!plugin.transform) {
1901
+ plugin.transform = function transform(code) {
1902
+ return code;
1903
+ };
1904
+ }
1905
+ if (plugin.api && typeof plugin.api === "function") {
1906
+ const api = plugin.api.call(context);
1907
+ return {
1908
+ ...plugin,
1909
+ key,
1910
+ api
1911
+ };
1912
+ }
1913
+ return {
1914
+ ...plugin,
1915
+ key
1916
+ };
1917
+ };
1918
+
1919
+ // src/config.ts
1920
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
1921
+ function defineConfig(options) {
1922
+ return options;
1923
+ }
1924
+ function isInputPath(result) {
1925
+ return !!result && "path" in result;
1926
+ }
1927
+
1928
+ // src/build.ts
1929
+ async function transformReducer(_previousCode, result, _plugin) {
1930
+ return result;
1931
+ }
1932
+ async function setup(options) {
1933
+ const { config, logger = _chunkSU2W2A6Vcjs.createLogger.call(void 0, { logLevel: _chunkSU2W2A6Vcjs.LogLevel.silent }) } = options;
1934
+ let count = 0;
1935
+ try {
1936
+ if (isInputPath(config) && !new (0, _chunkXF35HUZ2cjs.URLPath)(config.input.path).isURL) {
1937
+ await _chunk7HFYOZ7Fcjs.read.call(void 0, config.input.path);
1938
+ }
1939
+ } catch (e) {
1940
+ if (isInputPath(config)) {
1941
+ throw new Error(
1942
+ `Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${_chunkSU2W2A6Vcjs.p.dim(config.input.path)}`,
1943
+ {
1944
+ cause: e
1945
+ }
1946
+ );
1947
+ }
1948
+ }
1949
+ if (config.output.clean) {
1950
+ await _chunk7HFYOZ7Fcjs.clean.call(void 0, config.output.path);
1951
+ }
1952
+ const task = async (file) => {
1953
+ const { path: path5 } = file;
1954
+ let source = await FileManager.getSource(file);
1955
+ const { result: loadedResult } = await pluginManager.hookFirst({
1956
+ hookName: "load",
1957
+ parameters: [path5]
1958
+ });
1959
+ if (loadedResult && isPromise(loadedResult)) {
1960
+ source = await loadedResult;
1961
+ }
1962
+ if (loadedResult && !isPromise(loadedResult)) {
1963
+ source = loadedResult;
1964
+ }
1965
+ if (source) {
1966
+ source = await pluginManager.hookReduceArg0({
1967
+ hookName: "transform",
1968
+ parameters: [source, path5],
1969
+ reduce: transformReducer
1970
+ });
1971
+ if (config.output.write || config.output.write === void 0) {
1972
+ if (_optionalChain([file, 'access', _65 => _65.meta, 'optionalAccess', _66 => _66.pluginKey])) {
1973
+ await pluginManager.hookForPlugin({
1974
+ pluginKey: _optionalChain([file, 'access', _67 => _67.meta, 'optionalAccess', _68 => _68.pluginKey]),
1975
+ hookName: "writeFile",
1976
+ parameters: [source, path5]
1977
+ });
1978
+ }
1979
+ await pluginManager.hookFirst({
1980
+ hookName: "writeFile",
1981
+ parameters: [source, path5]
1982
+ });
1983
+ }
1984
+ }
1985
+ return {
1986
+ ...file,
1987
+ source: source || ""
1988
+ };
1989
+ };
1990
+ const pluginManager = new PluginManager(config, { logger, task });
1991
+ pluginManager.on("execute", (executer) => {
1992
+ const { hookName, parameters, plugin } = executer;
1993
+ if (hookName === "writeFile") {
1994
+ const [code] = parameters;
1995
+ logger.emit("debug", [`PluginKey ${_chunkSU2W2A6Vcjs.p.dim(JSON.stringify(plugin.key))}
1996
+ with source
1997
+
1998
+ ${code}`]);
1999
+ }
2000
+ });
2001
+ pluginManager.queue.on("add", () => {
2002
+ if (logger.logLevel !== _chunkSU2W2A6Vcjs.LogLevel.info) {
2003
+ return;
2004
+ }
2005
+ if (count === 0) {
2006
+ logger.emit("start", "\u{1F4BE} Writing");
2007
+ }
2008
+ });
2009
+ pluginManager.queue.on("active", () => {
2010
+ if (logger.logLevel !== _chunkSU2W2A6Vcjs.LogLevel.info) {
2011
+ return;
2012
+ }
2013
+ if (logger.spinner && pluginManager.queue.size > 0) {
2014
+ const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
2015
+ logger.spinner.suffixText = _chunkSU2W2A6Vcjs.p.dim(text);
2016
+ }
2017
+ ++count;
2018
+ });
2019
+ pluginManager.queue.on("completed", () => {
2020
+ if (logger.logLevel !== _chunkSU2W2A6Vcjs.LogLevel.info) {
2021
+ return;
2022
+ }
2023
+ if (logger.spinner) {
2024
+ const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
2025
+ logger.spinner.suffixText = _chunkSU2W2A6Vcjs.p.dim(text);
2026
+ }
2027
+ });
2028
+ pluginManager.on("executed", (executer) => {
2029
+ const { hookName, plugin, output, parameters } = executer;
2030
+ const logs = [
2031
+ `${_chunkSU2W2A6Vcjs.randomCliColour.call(void 0, plugin.name)} Executing ${hookName}`,
2032
+ parameters && `${_chunkSU2W2A6Vcjs.p.bgWhite("Parameters")} ${_chunkSU2W2A6Vcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
2033
+ JSON.stringify(parameters, void 0, 2),
2034
+ output && `${_chunkSU2W2A6Vcjs.p.bgWhite("Output")} ${_chunkSU2W2A6Vcjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
2035
+ output
2036
+ ].filter(Boolean);
2037
+ logger.emit("debug", logs);
2038
+ });
2039
+ return pluginManager;
2040
+ }
2041
+ async function build(options) {
2042
+ const pluginManager = await setup(options);
2043
+ const { fileManager, logger } = pluginManager;
2044
+ await pluginManager.hookParallel({
2045
+ hookName: "buildStart",
2046
+ parameters: [options.config]
2047
+ });
2048
+ await pluginManager.hookParallel({ hookName: "buildEnd" });
2049
+ if (logger.logLevel === _chunkSU2W2A6Vcjs.LogLevel.info) {
2050
+ logger.emit("end", "\u{1F4BE} Writing completed");
2051
+ }
2052
+ const files = await Promise.all(
2053
+ fileManager.files.map(async (file) => ({
2054
+ ...file,
2055
+ source: await FileManager.getSource(file)
2056
+ }))
2057
+ );
2058
+ return {
2059
+ files,
2060
+ pluginManager
2061
+ };
2062
+ }
2063
+ async function safeBuild(options) {
2064
+ const pluginManager = await setup(options);
2065
+ const { fileManager, logger } = pluginManager;
2066
+ try {
2067
+ await pluginManager.hookParallel({
2068
+ hookName: "buildStart",
2069
+ parameters: [options.config]
2070
+ });
2071
+ await pluginManager.hookParallel({ hookName: "buildEnd" });
2072
+ if (logger.logLevel === _chunkSU2W2A6Vcjs.LogLevel.info) {
2073
+ logger.emit("end", "\u{1F4BE} Writing completed");
2074
+ }
2075
+ } catch (e) {
2076
+ const files2 = await Promise.all(
2077
+ fileManager.files.map(async (file) => ({
2078
+ ...file,
2079
+ source: await FileManager.getSource(file)
2080
+ }))
2081
+ );
2082
+ return {
2083
+ files: files2,
2084
+ pluginManager,
2085
+ error: e
2086
+ };
2087
+ }
2088
+ const files = await Promise.all(
2089
+ fileManager.files.map(async (file) => ({
2090
+ ...file,
2091
+ source: await FileManager.getSource(file)
2092
+ }))
2093
+ );
2094
+ return {
2095
+ files,
2096
+ pluginManager
2097
+ };
2098
+ }
2099
+
2100
+ // src/Generator.ts
2101
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2102
+ var _options3, _context;
2103
+ var Generator = class {
2104
+ constructor(options, context) {
2105
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _options3, {});
2106
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _context, {});
2107
+ if (context) {
2108
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _context, context);
2109
+ }
2110
+ if (options) {
2111
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _options3, options);
2112
+ }
2113
+ return this;
2114
+ }
2115
+ get options() {
2116
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _options3);
2117
+ }
2118
+ get context() {
2119
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _context);
2120
+ }
2121
+ set options(options) {
2122
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _options3, { ..._chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _options3), ...options });
2123
+ }
2124
+ };
2125
+ _options3 = new WeakMap();
2126
+ _context = new WeakMap();
2127
+
2128
+ // src/PackageManager.ts
2129
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2130
+ var _module = require('module'); var _module2 = _interopRequireDefault(_module);
2131
+ var _os = require('os'); var _os2 = _interopRequireDefault(_os);
2132
+ var _url = require('url');
2133
+
2134
+ // ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
2135
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2136
+
2137
+
2138
+ // ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
2139
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2140
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
2141
+
2142
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
2143
+
2144
+
2145
+ // ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
2146
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2147
+
2148
+ // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
2149
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2150
+
2151
+ // ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
2152
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2153
+ var Node = class {
2154
+ constructor(value) {
2155
+ _chunkOOZTXU7Fcjs.__publicField.call(void 0, this, "value");
2156
+ _chunkOOZTXU7Fcjs.__publicField.call(void 0, this, "next");
2157
+ this.value = value;
2158
+ }
2159
+ };
2160
+ var _head, _tail, _size;
2161
+ var Queue = class {
2162
+ constructor() {
2163
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _head, void 0);
2164
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _tail, void 0);
2165
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _size, void 0);
2166
+ this.clear();
2167
+ }
2168
+ enqueue(value) {
2169
+ const node = new Node(value);
2170
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _head)) {
2171
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _tail).next = node;
2172
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _tail, node);
2173
+ } else {
2174
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _head, node);
2175
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _tail, node);
2176
+ }
2177
+ _chunkOOZTXU7Fcjs.__privateWrapper.call(void 0, this, _size)._++;
2178
+ }
2179
+ dequeue() {
2180
+ const current = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _head);
2181
+ if (!current) {
2182
+ return;
2183
+ }
2184
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _head, _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _head).next);
2185
+ _chunkOOZTXU7Fcjs.__privateWrapper.call(void 0, this, _size)._--;
2186
+ return current.value;
2187
+ }
2188
+ clear() {
2189
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _head, void 0);
2190
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _tail, void 0);
2191
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _size, 0);
2192
+ }
2193
+ get size() {
2194
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _size);
2195
+ }
2196
+ *[Symbol.iterator]() {
2197
+ let current = _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _head);
2198
+ while (current) {
2199
+ yield current.value;
2200
+ current = current.next;
2201
+ }
2202
+ }
2203
+ };
2204
+ _head = new WeakMap();
2205
+ _tail = new WeakMap();
2206
+ _size = new WeakMap();
2207
+
2208
+ // ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
2209
+ function pLimit(concurrency) {
2210
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
2211
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
2212
+ }
2213
+ const queue = new Queue();
2214
+ let activeCount = 0;
2215
+ const next = () => {
2216
+ activeCount--;
2217
+ if (queue.size > 0) {
2218
+ queue.dequeue()();
2219
+ }
2220
+ };
2221
+ const run = async (fn, resolve2, args) => {
2222
+ activeCount++;
2223
+ const result = (async () => fn(...args))();
2224
+ resolve2(result);
2225
+ try {
2226
+ await result;
2227
+ } catch (e2) {
2228
+ }
2229
+ next();
2230
+ };
2231
+ const enqueue = (fn, resolve2, args) => {
2232
+ queue.enqueue(run.bind(void 0, fn, resolve2, args));
2233
+ (async () => {
2234
+ await Promise.resolve();
2235
+ if (activeCount < concurrency && queue.size > 0) {
2236
+ queue.dequeue()();
2237
+ }
2238
+ })();
2239
+ };
2240
+ const generator = (fn, ...args) => new Promise((resolve2) => {
2241
+ enqueue(fn, resolve2, args);
2242
+ });
2243
+ Object.defineProperties(generator, {
2244
+ activeCount: {
2245
+ get: () => activeCount
2246
+ },
2247
+ pendingCount: {
2248
+ get: () => queue.size
2249
+ },
2250
+ clearQueue: {
2251
+ value: () => {
2252
+ queue.clear();
2253
+ }
2254
+ }
2255
+ });
2256
+ return generator;
2257
+ }
2258
+
2259
+ // ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
2260
+ var EndError = class extends Error {
2261
+ constructor(value) {
2262
+ super();
2263
+ this.value = value;
2264
+ }
2265
+ };
2266
+ var testElement = async (element, tester) => tester(await element);
2267
+ var finder = async (element) => {
2268
+ const values = await Promise.all(element);
2269
+ if (values[1] === true) {
2270
+ throw new EndError(values[0]);
2271
+ }
2272
+ return false;
2273
+ };
2274
+ async function pLocate(iterable, tester, {
2275
+ concurrency = Number.POSITIVE_INFINITY,
2276
+ preserveOrder = true
2277
+ } = {}) {
2278
+ const limit = pLimit(concurrency);
2279
+ const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
2280
+ const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
2281
+ try {
2282
+ await Promise.all(items.map((element) => checkLimit(finder, element)));
2283
+ } catch (error) {
2284
+ if (error instanceof EndError) {
2285
+ return error.value;
2286
+ }
2287
+ throw error;
2288
+ }
2289
+ }
2290
+
2291
+ // ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
2292
+ var typeMappings = {
2293
+ directory: "isDirectory",
2294
+ file: "isFile"
2295
+ };
2296
+ function checkType(type) {
2297
+ if (Object.hasOwnProperty.call(typeMappings, type)) {
2298
+ return;
2299
+ }
2300
+ throw new Error(`Invalid type specified: ${type}`);
2301
+ }
2302
+ var matchType = (type, stat) => stat[typeMappings[type]]();
2303
+ var toPath = (urlOrPath) => urlOrPath instanceof URL ? _url.fileURLToPath.call(void 0, urlOrPath) : urlOrPath;
2304
+ async function locatePath(paths, {
2305
+ cwd = _process2.default.cwd(),
2306
+ type = "file",
2307
+ allowSymlinks = true,
2308
+ concurrency,
2309
+ preserveOrder
2310
+ } = {}) {
2311
+ checkType(type);
2312
+ cwd = toPath(cwd);
2313
+ const statFunction = allowSymlinks ? _fs.promises.stat : _fs.promises.lstat;
2314
+ return pLocate(paths, async (path_) => {
2315
+ try {
2316
+ const stat = await statFunction(_path2.default.resolve(cwd, path_));
2317
+ return matchType(type, stat);
2318
+ } catch (e3) {
2319
+ return false;
2320
+ }
2321
+ }, { concurrency, preserveOrder });
2322
+ }
2323
+ function locatePathSync(paths, {
2324
+ cwd = _process2.default.cwd(),
2325
+ type = "file",
2326
+ allowSymlinks = true
2327
+ } = {}) {
2328
+ checkType(type);
2329
+ cwd = toPath(cwd);
2330
+ const statFunction = allowSymlinks ? _fs2.default.statSync : _fs2.default.lstatSync;
2331
+ for (const path_ of paths) {
2332
+ try {
2333
+ const stat = statFunction(_path2.default.resolve(cwd, path_), {
2334
+ throwIfNoEntry: false
2335
+ });
2336
+ if (!stat) {
2337
+ continue;
2338
+ }
2339
+ if (matchType(type, stat)) {
2340
+ return path_;
2341
+ }
2342
+ } catch (e4) {
2343
+ }
2344
+ }
2345
+ }
2346
+
2347
+ // ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
2348
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2349
+
2350
+ function toPath2(urlOrPath) {
2351
+ return urlOrPath instanceof URL ? _url.fileURLToPath.call(void 0, urlOrPath) : urlOrPath;
2352
+ }
2353
+
2354
+ // ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
2355
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2356
+
2357
+
2358
+ // ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
2359
+ var findUpStop = Symbol("findUpStop");
2360
+ async function findUpMultiple(name, options = {}) {
2361
+ let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
2362
+ const { root } = _path2.default.parse(directory);
2363
+ const stopAt = _path2.default.resolve(directory, toPath2(_nullishCoalesce(options.stopAt, () => ( root))));
2364
+ const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
2365
+ const paths = [name].flat();
2366
+ const runMatcher = async (locateOptions) => {
2367
+ if (typeof name !== "function") {
2368
+ return locatePath(paths, locateOptions);
2369
+ }
2370
+ const foundPath = await name(locateOptions.cwd);
2371
+ if (typeof foundPath === "string") {
2372
+ return locatePath([foundPath], locateOptions);
2373
+ }
2374
+ return foundPath;
2375
+ };
2376
+ const matches = [];
2377
+ while (true) {
2378
+ const foundPath = await runMatcher({ ...options, cwd: directory });
2379
+ if (foundPath === findUpStop) {
2380
+ break;
2381
+ }
2382
+ if (foundPath) {
2383
+ matches.push(_path2.default.resolve(directory, foundPath));
2384
+ }
2385
+ if (directory === stopAt || matches.length >= limit) {
2386
+ break;
2387
+ }
2388
+ directory = _path2.default.dirname(directory);
2389
+ }
2390
+ return matches;
2391
+ }
2392
+ function findUpMultipleSync(name, options = {}) {
2393
+ let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
2394
+ const { root } = _path2.default.parse(directory);
2395
+ const stopAt = _path2.default.resolve(directory, _nullishCoalesce(toPath2(options.stopAt), () => ( root)));
2396
+ const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
2397
+ const paths = [name].flat();
2398
+ const runMatcher = (locateOptions) => {
2399
+ if (typeof name !== "function") {
2400
+ return locatePathSync(paths, locateOptions);
2401
+ }
2402
+ const foundPath = name(locateOptions.cwd);
2403
+ if (typeof foundPath === "string") {
2404
+ return locatePathSync([foundPath], locateOptions);
2405
+ }
2406
+ return foundPath;
2407
+ };
2408
+ const matches = [];
2409
+ while (true) {
2410
+ const foundPath = runMatcher({ ...options, cwd: directory });
2411
+ if (foundPath === findUpStop) {
2412
+ break;
2413
+ }
2414
+ if (foundPath) {
2415
+ matches.push(_path2.default.resolve(directory, foundPath));
2416
+ }
2417
+ if (directory === stopAt || matches.length >= limit) {
2418
+ break;
2419
+ }
2420
+ directory = _path2.default.dirname(directory);
2421
+ }
2422
+ return matches;
2423
+ }
2424
+ async function findUp(name, options = {}) {
2425
+ const matches = await findUpMultiple(name, { ...options, limit: 1 });
2426
+ return matches[0];
2427
+ }
2428
+ function findUpSync(name, options = {}) {
2429
+ const matches = findUpMultipleSync(name, { ...options, limit: 1 });
2430
+ return matches[0];
2431
+ }
2432
+
2433
+ // src/PackageManager.ts
2434
+ var _semver = require('semver');
2435
+ var _cache2, _cwd, _SLASHES, _match, match_fn;
2436
+ var _PackageManager = class _PackageManager {
2437
+ constructor(workspace) {
2438
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _match);
2439
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _cwd, void 0);
2440
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, this, _SLASHES, /* @__PURE__ */ new Set(["/", "\\"]));
2441
+ if (workspace) {
2442
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _cwd, workspace);
2443
+ }
2444
+ return this;
2445
+ }
2446
+ set workspace(workspace) {
2447
+ _chunkOOZTXU7Fcjs.__privateSet.call(void 0, this, _cwd, workspace);
2448
+ }
2449
+ get workspace() {
2450
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cwd);
2451
+ }
2452
+ normalizeDirectory(directory) {
2453
+ if (!_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _SLASHES).has(directory[directory.length - 1])) {
2454
+ return `${directory}/`;
2455
+ }
2456
+ return directory;
2457
+ }
2458
+ getLocation(path5) {
2459
+ let location = path5;
2460
+ if (_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cwd)) {
2461
+ const require2 = _module2.default.createRequire(this.normalizeDirectory(_chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cwd)));
2462
+ location = require2.resolve(path5);
2463
+ }
2464
+ return location;
2465
+ }
2466
+ async import(path5) {
2467
+ try {
2468
+ let location = this.getLocation(path5);
2469
+ if (_os2.default.platform() === "win32") {
2470
+ location = _url.pathToFileURL.call(void 0, location).href;
2471
+ }
2472
+ const module = await Promise.resolve().then(() => _interopRequireWildcard(require(location)));
2473
+ return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _69 => _69.default]), () => ( module));
2474
+ } catch (e) {
2475
+ console.log(e);
2476
+ return void 0;
2477
+ }
2478
+ }
2479
+ async getPackageJSON() {
2480
+ const pkgPath = await findUp(["package.json"], {
2481
+ cwd: _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cwd)
2482
+ });
2483
+ if (!pkgPath) {
2484
+ return void 0;
2485
+ }
2486
+ const json = await _chunk7HFYOZ7Fcjs.read.call(void 0, pkgPath);
2487
+ return JSON.parse(json);
2488
+ }
2489
+ getPackageJSONSync() {
2490
+ const pkgPath = findUpSync(["package.json"], {
2491
+ cwd: _chunkOOZTXU7Fcjs.__privateGet.call(void 0, this, _cwd)
2492
+ });
2493
+ if (!pkgPath) {
2494
+ return void 0;
2495
+ }
2496
+ const json = _chunk7HFYOZ7Fcjs.readSync.call(void 0, pkgPath);
2497
+ return JSON.parse(json);
2498
+ }
2499
+ static setVersion(dependency, version) {
2500
+ _chunkOOZTXU7Fcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency] = version;
2501
+ }
2502
+ async getVersion(dependency) {
2503
+ if (typeof dependency === "string" && _chunkOOZTXU7Fcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency]) {
2504
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency];
2505
+ }
2506
+ const packageJSON = await this.getPackageJSON();
2507
+ if (!packageJSON) {
2508
+ return void 0;
2509
+ }
2510
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _match, match_fn).call(this, packageJSON, dependency);
2511
+ }
2512
+ getVersionSync(dependency) {
2513
+ if (typeof dependency === "string" && _chunkOOZTXU7Fcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency]) {
2514
+ return _chunkOOZTXU7Fcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency];
2515
+ }
2516
+ const packageJSON = this.getPackageJSONSync();
2517
+ if (!packageJSON) {
2518
+ return void 0;
2519
+ }
2520
+ return _chunkOOZTXU7Fcjs.__privateMethod.call(void 0, this, _match, match_fn).call(this, packageJSON, dependency);
2521
+ }
2522
+ async isValid(dependency, version) {
2523
+ const packageVersion = await this.getVersion(dependency);
2524
+ if (!packageVersion) {
2525
+ return false;
2526
+ }
2527
+ if (packageVersion === version) {
2528
+ return true;
2529
+ }
2530
+ const semVer = _semver.coerce.call(void 0, packageVersion);
2531
+ if (!semVer) {
2532
+ throw new Error(`${packageVersion} is not valid`);
2533
+ }
2534
+ return _semver.satisfies.call(void 0, semVer, version);
2535
+ }
2536
+ isValidSync(dependency, version) {
2537
+ const packageVersion = this.getVersionSync(dependency);
2538
+ if (!packageVersion) {
2539
+ return false;
2540
+ }
2541
+ const semVer = _semver.coerce.call(void 0, packageVersion);
2542
+ if (!semVer) {
2543
+ throw new Error(`${packageVersion} is not valid`);
2544
+ }
2545
+ return _semver.satisfies.call(void 0, semVer, version);
2546
+ }
2547
+ };
2548
+ _cache2 = new WeakMap();
2549
+ _cwd = new WeakMap();
2550
+ _SLASHES = new WeakMap();
2551
+ _match = new WeakSet();
2552
+ match_fn = function(packageJSON, dependency) {
2553
+ const dependencies = {
2554
+ ...packageJSON["dependencies"] || {},
2555
+ ...packageJSON["devDependencies"] || {}
2556
+ };
2557
+ if (typeof dependency === "string" && dependencies[dependency]) {
2558
+ return dependencies[dependency];
2559
+ }
2560
+ const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency));
2561
+ return matchedDependency ? dependencies[matchedDependency] : void 0;
2562
+ };
2563
+ _chunkOOZTXU7Fcjs.__privateAdd.call(void 0, _PackageManager, _cache2, {});
2564
+ var PackageManager = _PackageManager;
2565
+
2566
+ // src/kubb.ts
2567
+ var kubb_exports = {};
2568
+ _chunkOOZTXU7Fcjs.init_cjs_shims.call(void 0, );
2569
+
2570
+
2571
+
2572
+
2573
+
2574
+
2575
+
2576
+
2577
+
2578
+
2579
+
2580
+
2581
+
2582
+
2583
+
2584
+
2585
+ exports.KubbFile = KubbFile; exports.FileManager = FileManager; exports.PromiseManager = PromiseManager; exports.Warning = Warning; exports.createPlugin = createPlugin; exports.pluginName = pluginName; exports.PluginManager = PluginManager; exports.defineConfig = defineConfig; exports.isInputPath = isInputPath; exports.build = build; exports.safeBuild = safeBuild; exports.Generator = Generator; exports.PackageManager = PackageManager; exports.kubb_exports = kubb_exports;
2586
+ //# sourceMappingURL=chunk-T6TAUAYN.cjs.map