@kubb/core 2.18.4 → 2.18.5
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.
- package/dist/chunk-7TB4GNKF.cjs +1268 -0
- package/dist/chunk-7TB4GNKF.cjs.map +1 -0
- package/dist/{chunk-TIYJPVUG.js → chunk-7UMWFPXG.js} +1 -9
- package/dist/chunk-7UMWFPXG.js.map +1 -0
- package/dist/{chunk-GRBLCGB5.cjs → chunk-BE4KSMB4.cjs} +5 -5
- package/dist/chunk-EPAC7V2R.js +597 -0
- package/dist/chunk-EPAC7V2R.js.map +1 -0
- package/dist/{chunk-YTLMG2AN.cjs → chunk-FWUA552W.cjs} +29 -29
- package/dist/{chunk-NP7GXHZS.cjs → chunk-JI763CHT.cjs} +18 -18
- package/dist/{chunk-GG3XRJX3.cjs → chunk-M6VNU2SJ.cjs} +12 -20
- package/dist/chunk-M6VNU2SJ.cjs.map +1 -0
- package/dist/{chunk-XUCU53HT.cjs → chunk-TCFN5BZ6.cjs} +3 -11
- package/dist/chunk-TCFN5BZ6.cjs.map +1 -0
- package/dist/index.cjs +1297 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -148
- package/dist/index.d.ts +26 -148
- package/dist/index.js +991 -22
- package/dist/index.js.map +1 -1
- package/dist/logger.cjs +3 -4
- package/dist/logger.js +1 -2
- package/dist/mocks.cjs +15 -14
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +4 -2
- package/dist/mocks.d.ts +4 -2
- package/dist/mocks.js +7 -6
- package/dist/mocks.js.map +1 -1
- package/dist/transformers.cjs +4 -4
- package/dist/utils.cjs +4 -4
- package/package.json +8 -18
- package/src/BarrelManager.ts +1 -1
- package/src/FileManager.ts +36 -167
- package/src/PackageManager.ts +1 -1
- package/src/PluginManager.ts +5 -5
- package/src/build.ts +6 -8
- package/src/index.ts +2 -3
- package/src/logger.ts +0 -7
- package/src/types.ts +3 -2
- package/src/utils/TreeNode.ts +1 -1
- package/dist/chunk-2F7E62RD.js +0 -85
- package/dist/chunk-2F7E62RD.js.map +0 -1
- package/dist/chunk-6NMPKKGV.js +0 -1597
- package/dist/chunk-6NMPKKGV.js.map +0 -1
- package/dist/chunk-7PBKI3OR.cjs +0 -2584
- package/dist/chunk-7PBKI3OR.cjs.map +0 -1
- package/dist/chunk-AQJCCWPW.cjs +0 -75
- package/dist/chunk-AQJCCWPW.cjs.map +0 -1
- package/dist/chunk-GG3XRJX3.cjs.map +0 -1
- package/dist/chunk-MDO6MCFJ.js +0 -65
- package/dist/chunk-MDO6MCFJ.js.map +0 -1
- package/dist/chunk-TIYJPVUG.js.map +0 -1
- package/dist/chunk-X5IJHUXJ.cjs +0 -2332
- package/dist/chunk-X5IJHUXJ.cjs.map +0 -1
- package/dist/chunk-XUCU53HT.cjs.map +0 -1
- package/dist/fs.cjs +0 -23
- package/dist/fs.cjs.map +0 -1
- package/dist/fs.d.cts +0 -5
- package/dist/fs.d.ts +0 -5
- package/dist/fs.js +0 -18
- package/dist/fs.js.map +0 -1
- package/dist/write-CN8f7bYv.d.cts +0 -10
- package/dist/write-CN8f7bYv.d.ts +0 -10
- package/src/fs/clean.ts +0 -5
- package/src/fs/index.ts +0 -3
- package/src/fs/read.ts +0 -68
- package/src/fs/write.ts +0 -83
- /package/dist/{chunk-GRBLCGB5.cjs.map → chunk-BE4KSMB4.cjs.map} +0 -0
- /package/dist/{chunk-YTLMG2AN.cjs.map → chunk-FWUA552W.cjs.map} +0 -0
- /package/dist/{chunk-NP7GXHZS.cjs.map → chunk-JI763CHT.cjs.map} +0 -0
package/dist/chunk-7PBKI3OR.cjs
DELETED
|
@@ -1,2584 +0,0 @@
|
|
|
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 _chunkNP7GXHZScjs = require('./chunk-NP7GXHZS.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _chunkYTLMG2ANcjs = require('./chunk-YTLMG2AN.cjs');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _chunkGRBLCGB5cjs = require('./chunk-GRBLCGB5.cjs');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _chunkGG3XRJX3cjs = require('./chunk-GG3XRJX3.cjs');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var _chunkAQJCCWPWcjs = require('./chunk-AQJCCWPW.cjs');
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var _chunkX5IJHUXJcjs = require('./chunk-X5IJHUXJ.cjs');
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var _chunkXUCU53HTcjs = require('./chunk-XUCU53HT.cjs');
|
|
42
|
-
|
|
43
|
-
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js
|
|
44
|
-
var require_eventemitter3 = _chunkXUCU53HTcjs.__commonJS.call(void 0, {
|
|
45
|
-
"../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
|
|
46
|
-
"use strict";
|
|
47
|
-
_chunkXUCU53HTcjs.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
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
228
|
-
|
|
229
|
-
// src/build.ts
|
|
230
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
231
|
-
|
|
232
|
-
// src/FileManager.ts
|
|
233
|
-
_chunkXUCU53HTcjs.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
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
239
|
-
|
|
240
|
-
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
|
|
241
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
242
|
-
var import_index = _chunkXUCU53HTcjs.__toESM.call(void 0, require_eventemitter3(), 1);
|
|
243
|
-
|
|
244
|
-
// ../../node_modules/.pnpm/p-timeout@6.1.2/node_modules/p-timeout/index.js
|
|
245
|
-
_chunkXUCU53HTcjs.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
|
-
_chunkXUCU53HTcjs.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
|
-
_chunkXUCU53HTcjs.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
|
-
_chunkXUCU53HTcjs.__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 && _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue)[this.size - 1].priority >= options.priority) {
|
|
366
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue).push(element);
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
const index = lowerBound(_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue), element, (a, b) => b.priority - a.priority);
|
|
370
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue).splice(index, 0, element);
|
|
371
|
-
}
|
|
372
|
-
dequeue() {
|
|
373
|
-
const item = _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue).shift();
|
|
374
|
-
return _optionalChain([item, 'optionalAccess', _2 => _2.run]);
|
|
375
|
-
}
|
|
376
|
-
filter(options) {
|
|
377
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue).filter((element) => element.priority === options.priority).map((element) => element.run);
|
|
378
|
-
}
|
|
379
|
-
get size() {
|
|
380
|
-
return _chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _doesIntervalAllowAnother);
|
|
392
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _doesConcurrentAllowAnother);
|
|
393
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _next);
|
|
394
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _onResumeInterval);
|
|
395
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _isIntervalPaused);
|
|
396
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _tryToStartAnother);
|
|
397
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _initializeIntervalIfNeeded);
|
|
398
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _onInterval);
|
|
399
|
-
/**
|
|
400
|
-
Executes all queued functions until it reaches the limit.
|
|
401
|
-
*/
|
|
402
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _processQueue);
|
|
403
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _throwOnAbort);
|
|
404
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _onEvent);
|
|
405
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _carryoverConcurrencyCount, void 0);
|
|
406
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _isIntervalIgnored, void 0);
|
|
407
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _intervalCount, 0);
|
|
408
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _intervalCap, void 0);
|
|
409
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _interval, void 0);
|
|
410
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _intervalEnd, 0);
|
|
411
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _intervalId, void 0);
|
|
412
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _timeoutId, void 0);
|
|
413
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _queue2, void 0);
|
|
414
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _queueClass, void 0);
|
|
415
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _pending, 0);
|
|
416
|
-
// The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
|
|
417
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _concurrency, void 0);
|
|
418
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _isPaused, void 0);
|
|
419
|
-
_chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _carryoverConcurrencyCount, options.carryoverConcurrencyCount);
|
|
442
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _isIntervalIgnored, options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0);
|
|
443
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _intervalCap, options.intervalCap);
|
|
444
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _interval, options.interval);
|
|
445
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _queue2, new options.queueClass());
|
|
446
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _queueClass, options.queueClass);
|
|
447
|
-
this.concurrency = options.concurrency;
|
|
448
|
-
this.timeout = options.timeout;
|
|
449
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _throwOnTimeout, options.throwOnTimeout === true);
|
|
450
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _isPaused, options.autoStart === false);
|
|
451
|
-
}
|
|
452
|
-
get concurrency() {
|
|
453
|
-
return _chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _concurrency, newConcurrency);
|
|
460
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _processQueue, processQueue_fn).call(this);
|
|
461
|
-
}
|
|
462
|
-
async add(function_, options = {}) {
|
|
463
|
-
options = {
|
|
464
|
-
timeout: this.timeout,
|
|
465
|
-
throwOnTimeout: _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _throwOnTimeout),
|
|
466
|
-
...options
|
|
467
|
-
};
|
|
468
|
-
return new Promise((resolve2, reject) => {
|
|
469
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue2).enqueue(async () => {
|
|
470
|
-
_chunkXUCU53HTcjs.__privateWrapper.call(void 0, this, _pending)._++;
|
|
471
|
-
_chunkXUCU53HTcjs.__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, _chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _next, next_fn).call(this);
|
|
493
|
-
}
|
|
494
|
-
}, options);
|
|
495
|
-
this.emit("add");
|
|
496
|
-
_chunkXUCU53HTcjs.__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 (!_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _isPaused)) {
|
|
507
|
-
return this;
|
|
508
|
-
}
|
|
509
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _isPaused, false);
|
|
510
|
-
_chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _isPaused, true);
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
Clear the queue.
|
|
521
|
-
*/
|
|
522
|
-
clear() {
|
|
523
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _queue2, new (_chunkXUCU53HTcjs.__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 (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
await _chunkXUCU53HTcjs.__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 (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue2).size < limit) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
await _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _onEvent, onEvent_fn).call(this, "next", () => _chunkXUCU53HTcjs.__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 (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _pending) === 0 && _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
await _chunkXUCU53HTcjs.__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 _chunkXUCU53HTcjs.__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 _chunkXUCU53HTcjs.__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 _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _pending);
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
Whether the queue is currently paused.
|
|
582
|
-
*/
|
|
583
|
-
get isPaused() {
|
|
584
|
-
return _chunkXUCU53HTcjs.__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 _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _isIntervalIgnored) || _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalCount) < _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalCap);
|
|
604
|
-
};
|
|
605
|
-
_doesConcurrentAllowAnother = new WeakSet();
|
|
606
|
-
doesConcurrentAllowAnother_get = function() {
|
|
607
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _pending) < _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _concurrency);
|
|
608
|
-
};
|
|
609
|
-
_next = new WeakSet();
|
|
610
|
-
next_fn = function() {
|
|
611
|
-
_chunkXUCU53HTcjs.__privateWrapper.call(void 0, this, _pending)._--;
|
|
612
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _tryToStartAnother, tryToStartAnother_fn).call(this);
|
|
613
|
-
this.emit("next");
|
|
614
|
-
};
|
|
615
|
-
_onResumeInterval = new WeakSet();
|
|
616
|
-
onResumeInterval_fn = function() {
|
|
617
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _onInterval, onInterval_fn).call(this);
|
|
618
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _initializeIntervalIfNeeded, initializeIntervalIfNeeded_fn).call(this);
|
|
619
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _timeoutId, void 0);
|
|
620
|
-
};
|
|
621
|
-
_isIntervalPaused = new WeakSet();
|
|
622
|
-
isIntervalPaused_get = function() {
|
|
623
|
-
const now = Date.now();
|
|
624
|
-
if (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalId) === void 0) {
|
|
625
|
-
const delay = _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalEnd) - now;
|
|
626
|
-
if (delay < 0) {
|
|
627
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _intervalCount, _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _carryoverConcurrencyCount) ? _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _pending) : 0);
|
|
628
|
-
} else {
|
|
629
|
-
if (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _timeoutId) === void 0) {
|
|
630
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _timeoutId, setTimeout(() => {
|
|
631
|
-
_chunkXUCU53HTcjs.__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 (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue2).size === 0) {
|
|
642
|
-
if (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalId)) {
|
|
643
|
-
clearInterval(_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalId));
|
|
644
|
-
}
|
|
645
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _intervalId, void 0);
|
|
646
|
-
this.emit("empty");
|
|
647
|
-
if (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _pending) === 0) {
|
|
648
|
-
this.emit("idle");
|
|
649
|
-
}
|
|
650
|
-
return false;
|
|
651
|
-
}
|
|
652
|
-
if (!_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _isPaused)) {
|
|
653
|
-
const canInitializeInterval = !_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _isIntervalPaused, isIntervalPaused_get);
|
|
654
|
-
if (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _doesIntervalAllowAnother, doesIntervalAllowAnother_get) && _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _doesConcurrentAllowAnother, doesConcurrentAllowAnother_get)) {
|
|
655
|
-
const job = _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue2).dequeue();
|
|
656
|
-
if (!job) {
|
|
657
|
-
return false;
|
|
658
|
-
}
|
|
659
|
-
this.emit("active");
|
|
660
|
-
job();
|
|
661
|
-
if (canInitializeInterval) {
|
|
662
|
-
_chunkXUCU53HTcjs.__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 (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _isIntervalIgnored) || _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalId) !== void 0) {
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _intervalId, setInterval(() => {
|
|
675
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _onInterval, onInterval_fn).call(this);
|
|
676
|
-
}, _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _interval)));
|
|
677
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _intervalEnd, Date.now() + _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _interval));
|
|
678
|
-
};
|
|
679
|
-
_onInterval = new WeakSet();
|
|
680
|
-
onInterval_fn = function() {
|
|
681
|
-
if (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalCount) === 0 && _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _pending) === 0 && _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalId)) {
|
|
682
|
-
clearInterval(_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _intervalId));
|
|
683
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _intervalId, void 0);
|
|
684
|
-
}
|
|
685
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _intervalCount, _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _carryoverConcurrencyCount) ? _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _pending) : 0);
|
|
686
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _processQueue, processQueue_fn).call(this);
|
|
687
|
-
};
|
|
688
|
-
_processQueue = new WeakSet();
|
|
689
|
-
processQueue_fn = function() {
|
|
690
|
-
while (_chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
720
|
-
var _parserts = require('@kubb/parser-ts');
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
// src/utils/TreeNode.ts
|
|
724
|
-
_chunkXUCU53HTcjs.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
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _options, void 0);
|
|
828
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _options, options);
|
|
829
|
-
return this;
|
|
830
|
-
}
|
|
831
|
-
getNamedExport(root, item) {
|
|
832
|
-
const exportedNames = _parserts.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 } = _chunkXUCU53HTcjs.__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` : `./${_chunkNP7GXHZScjs.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` : `./${_chunkNP7GXHZScjs.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
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _add);
|
|
932
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _addOrAppend);
|
|
933
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _cache, /* @__PURE__ */ new Map());
|
|
934
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _task, void 0);
|
|
935
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _queue3, void 0);
|
|
936
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _task, task);
|
|
937
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _queue3, queue);
|
|
938
|
-
return this;
|
|
939
|
-
}
|
|
940
|
-
get files() {
|
|
941
|
-
const files = [];
|
|
942
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cache).forEach((item) => {
|
|
943
|
-
files.push(...item.flat(1));
|
|
944
|
-
});
|
|
945
|
-
return files;
|
|
946
|
-
}
|
|
947
|
-
get isExecuting() {
|
|
948
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue3).size !== 0 && _chunkXUCU53HTcjs.__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 _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _add, add_fn).call(this, file);
|
|
954
|
-
}
|
|
955
|
-
return _chunkXUCU53HTcjs.__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 (_chunkNP7GXHZScjs.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("./") ? _chunkNP7GXHZScjs.trimExtName.call(void 0, output.path) : `./${_chunkNP7GXHZScjs.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 _chunkXUCU53HTcjs.__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 _chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.__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 _chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cache).delete(path5);
|
|
1044
|
-
}
|
|
1045
|
-
async write(...params) {
|
|
1046
|
-
return _chunkX5IJHUXJcjs.write.call(void 0, ...params);
|
|
1047
|
-
}
|
|
1048
|
-
async read(...params) {
|
|
1049
|
-
return _chunkAQJCCWPWcjs.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: _chunkNP7GXHZScjs.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
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
|
|
1093
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _queue3).add(
|
|
1094
|
-
async () => {
|
|
1095
|
-
var _a;
|
|
1096
|
-
return (_a = _chunkXUCU53HTcjs.__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 = _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cache).get(file.path);
|
|
1104
|
-
const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
|
|
1105
|
-
if (previousCache) {
|
|
1106
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cache).delete(previousCache.path);
|
|
1107
|
-
return _chunkXUCU53HTcjs.__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 _chunkXUCU53HTcjs.__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 _chunkYTLMG2ANcjs.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 ? _chunkAQJCCWPWcjs.getRelativePath.call(void 0, item.root, item.path) : item.path;
|
|
1159
|
-
return path5 !== _chunkNP7GXHZScjs.trimExtName.call(void 0, file.path);
|
|
1160
|
-
}).map((item) => {
|
|
1161
|
-
return parser.factory.createImportDeclaration({
|
|
1162
|
-
name: item.name,
|
|
1163
|
-
path: item.root ? _chunkAQJCCWPWcjs.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 = _chunkGRBLCGB5cjs.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 _chunkGRBLCGB5cjs.orderBy.call(void 0, combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ["desc", "desc"]);
|
|
1211
|
-
}
|
|
1212
|
-
function combineImports(imports, exports, source) {
|
|
1213
|
-
const combinedImports = _chunkGRBLCGB5cjs.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 _chunkGRBLCGB5cjs.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 = _chunkNP7GXHZScjs.searchAndReplace.call(void 0, {
|
|
1276
|
-
text: prev.replaceAll(`process.env.${key}`, replaceBy),
|
|
1277
|
-
replaceBy,
|
|
1278
|
-
prefix: "process.env",
|
|
1279
|
-
key
|
|
1280
|
-
});
|
|
1281
|
-
prev = _chunkNP7GXHZScjs.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
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
1293
|
-
|
|
1294
|
-
// src/PromiseManager.ts
|
|
1295
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
1296
|
-
|
|
1297
|
-
// src/utils/executeStrategies.ts
|
|
1298
|
-
_chunkXUCU53HTcjs.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
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _options2, {});
|
|
1337
|
-
_chunkXUCU53HTcjs.__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, _chunkXUCU53HTcjs.__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
|
-
_chunkXUCU53HTcjs.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
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
// src/utils/cache.ts
|
|
1377
|
-
_chunkXUCU53HTcjs.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 pluginCore = createPlugin((options) => {
|
|
1412
|
-
const { fileManager, pluginManager, resolvePath, resolveName, logger } = options;
|
|
1413
|
-
return {
|
|
1414
|
-
name: "core",
|
|
1415
|
-
options,
|
|
1416
|
-
key: ["core"],
|
|
1417
|
-
api() {
|
|
1418
|
-
return {
|
|
1419
|
-
get config() {
|
|
1420
|
-
return options.config;
|
|
1421
|
-
},
|
|
1422
|
-
get plugins() {
|
|
1423
|
-
return options.getPlugins();
|
|
1424
|
-
},
|
|
1425
|
-
get plugin() {
|
|
1426
|
-
return options.plugin;
|
|
1427
|
-
},
|
|
1428
|
-
logger,
|
|
1429
|
-
fileManager,
|
|
1430
|
-
pluginManager,
|
|
1431
|
-
async addFile(...files) {
|
|
1432
|
-
const resolvedFiles = await fileManager.add(...files);
|
|
1433
|
-
if (!Array.isArray(resolvedFiles)) {
|
|
1434
|
-
return [resolvedFiles];
|
|
1435
|
-
}
|
|
1436
|
-
return resolvedFiles;
|
|
1437
|
-
},
|
|
1438
|
-
resolvePath,
|
|
1439
|
-
resolveName,
|
|
1440
|
-
cache: createPluginCache()
|
|
1441
|
-
};
|
|
1442
|
-
},
|
|
1443
|
-
resolvePath(baseName) {
|
|
1444
|
-
const root = _path2.default.resolve(this.config.root, this.config.output.path);
|
|
1445
|
-
return _path2.default.resolve(root, baseName);
|
|
1446
|
-
},
|
|
1447
|
-
resolveName(name) {
|
|
1448
|
-
return name;
|
|
1449
|
-
}
|
|
1450
|
-
};
|
|
1451
|
-
});
|
|
1452
|
-
|
|
1453
|
-
// src/PluginManager.ts
|
|
1454
|
-
var _core, _usedPluginNames, _promiseManager, _getSortedPlugins, getSortedPlugins_fn, _addExecutedToCallStack, addExecutedToCallStack_fn, _execute, execute_fn, _executeSync, executeSync_fn, _catcher, catcher_fn, _parse, parse_fn;
|
|
1455
|
-
var PluginManager = class {
|
|
1456
|
-
constructor(config, options) {
|
|
1457
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _getSortedPlugins);
|
|
1458
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _addExecutedToCallStack);
|
|
1459
|
-
/**
|
|
1460
|
-
* Run an async plugin hook and return the result.
|
|
1461
|
-
* @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
|
|
1462
|
-
* @param args Arguments passed to the plugin hook.
|
|
1463
|
-
* @param plugin The actual pluginObject to run.
|
|
1464
|
-
*/
|
|
1465
|
-
// Implementation signature
|
|
1466
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _execute);
|
|
1467
|
-
/**
|
|
1468
|
-
* Run a sync plugin hook and return the result.
|
|
1469
|
-
* @param hookName Name of the plugin hook. Must be in `PluginHooks`.
|
|
1470
|
-
* @param args Arguments passed to the plugin hook.
|
|
1471
|
-
* @param plugin The acutal plugin
|
|
1472
|
-
* @param replaceContext When passed, the plugin context can be overridden.
|
|
1473
|
-
*/
|
|
1474
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _executeSync);
|
|
1475
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _catcher);
|
|
1476
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _parse);
|
|
1477
|
-
this.events = new (0, _chunkGG3XRJX3cjs.EventEmitter)();
|
|
1478
|
-
this.executed = [];
|
|
1479
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _core, void 0);
|
|
1480
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _usedPluginNames, {});
|
|
1481
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _promiseManager, void 0);
|
|
1482
|
-
this.resolvePath = (params) => {
|
|
1483
|
-
if (params.pluginKey) {
|
|
1484
|
-
const paths = this.hookForPluginSync({
|
|
1485
|
-
pluginKey: params.pluginKey,
|
|
1486
|
-
hookName: "resolvePath",
|
|
1487
|
-
parameters: [params.baseName, params.mode, params.options]
|
|
1488
|
-
});
|
|
1489
|
-
if (paths && _optionalChain([paths, 'optionalAccess', _43 => _43.length]) > 1) {
|
|
1490
|
-
this.logger.emit("debug", [
|
|
1491
|
-
`Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
1492
|
-
|
|
1493
|
-
Paths: ${JSON.stringify(paths, void 0, 2)}
|
|
1494
|
-
|
|
1495
|
-
Falling back on the first item.
|
|
1496
|
-
`
|
|
1497
|
-
]);
|
|
1498
|
-
}
|
|
1499
|
-
return _optionalChain([paths, 'optionalAccess', _44 => _44.at, 'call', _45 => _45(0)]);
|
|
1500
|
-
}
|
|
1501
|
-
return this.hookFirstSync({
|
|
1502
|
-
hookName: "resolvePath",
|
|
1503
|
-
parameters: [params.baseName, params.mode, params.options]
|
|
1504
|
-
}).result;
|
|
1505
|
-
};
|
|
1506
|
-
this.resolveName = (params) => {
|
|
1507
|
-
if (params.pluginKey) {
|
|
1508
|
-
const names = this.hookForPluginSync({
|
|
1509
|
-
pluginKey: params.pluginKey,
|
|
1510
|
-
hookName: "resolveName",
|
|
1511
|
-
parameters: [params.name, params.type]
|
|
1512
|
-
});
|
|
1513
|
-
if (names && _optionalChain([names, 'optionalAccess', _46 => _46.length]) > 1) {
|
|
1514
|
-
this.logger.emit("debug", [
|
|
1515
|
-
`Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
|
|
1516
|
-
|
|
1517
|
-
Names: ${JSON.stringify(names, void 0, 2)}
|
|
1518
|
-
|
|
1519
|
-
Falling back on the first item.
|
|
1520
|
-
`
|
|
1521
|
-
]);
|
|
1522
|
-
}
|
|
1523
|
-
return _chunkNP7GXHZScjs.transformReservedWord.call(void 0, _optionalChain([names, 'optionalAccess', _47 => _47.at, 'call', _48 => _48(0)]) || params.name);
|
|
1524
|
-
}
|
|
1525
|
-
const name = this.hookFirstSync({
|
|
1526
|
-
hookName: "resolveName",
|
|
1527
|
-
parameters: [params.name, params.type]
|
|
1528
|
-
}).result;
|
|
1529
|
-
return _chunkNP7GXHZScjs.transformReservedWord.call(void 0, name);
|
|
1530
|
-
};
|
|
1531
|
-
this.config = config;
|
|
1532
|
-
this.logger = options.logger;
|
|
1533
|
-
this.queue = new PQueue({ concurrency: 1 });
|
|
1534
|
-
this.fileManager = new FileManager({
|
|
1535
|
-
task: options.task,
|
|
1536
|
-
queue: this.queue
|
|
1537
|
-
});
|
|
1538
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _promiseManager, new PromiseManager({
|
|
1539
|
-
nullCheck: (state) => !!_optionalChain([state, 'optionalAccess', _49 => _49.result])
|
|
1540
|
-
}));
|
|
1541
|
-
const plugins = config.plugins || [];
|
|
1542
|
-
const core = pluginCore({
|
|
1543
|
-
config,
|
|
1544
|
-
logger: this.logger,
|
|
1545
|
-
pluginManager: this,
|
|
1546
|
-
fileManager: this.fileManager,
|
|
1547
|
-
resolvePath: this.resolvePath.bind(this),
|
|
1548
|
-
resolveName: this.resolveName.bind(this),
|
|
1549
|
-
getPlugins: _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).bind(this)
|
|
1550
|
-
});
|
|
1551
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _core, _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _parse, parse_fn).call(this, core, this, core.api.call(null)));
|
|
1552
|
-
this.plugins = [_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _core), ...plugins].map((plugin) => {
|
|
1553
|
-
return _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _parse, parse_fn).call(this, plugin, this, _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _core).api);
|
|
1554
|
-
});
|
|
1555
|
-
return this;
|
|
1556
|
-
}
|
|
1557
|
-
getFile({ name, mode, extName, pluginKey, options }) {
|
|
1558
|
-
let source = "";
|
|
1559
|
-
const baseName = `${name}${extName}`;
|
|
1560
|
-
const path5 = this.resolvePath({ baseName, mode, pluginKey, options });
|
|
1561
|
-
if (!path5) {
|
|
1562
|
-
throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginKey [${JSON.stringify(pluginKey)}]`);
|
|
1563
|
-
}
|
|
1564
|
-
try {
|
|
1565
|
-
source = _chunkAQJCCWPWcjs.readSync.call(void 0, path5);
|
|
1566
|
-
} catch (_e) {
|
|
1567
|
-
}
|
|
1568
|
-
return {
|
|
1569
|
-
path: path5,
|
|
1570
|
-
baseName,
|
|
1571
|
-
meta: {
|
|
1572
|
-
pluginKey
|
|
1573
|
-
},
|
|
1574
|
-
source
|
|
1575
|
-
};
|
|
1576
|
-
}
|
|
1577
|
-
/**
|
|
1578
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
1579
|
-
*/
|
|
1580
|
-
on(eventName, handler) {
|
|
1581
|
-
this.events.on(eventName, handler);
|
|
1582
|
-
}
|
|
1583
|
-
/**
|
|
1584
|
-
* Run a specific hookName for plugin x.
|
|
1585
|
-
*/
|
|
1586
|
-
hookForPlugin({
|
|
1587
|
-
pluginKey,
|
|
1588
|
-
hookName,
|
|
1589
|
-
parameters
|
|
1590
|
-
}) {
|
|
1591
|
-
const plugins = this.getPluginsByKey(hookName, pluginKey);
|
|
1592
|
-
const promises = plugins.map((plugin) => {
|
|
1593
|
-
return _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
|
|
1594
|
-
strategy: "hookFirst",
|
|
1595
|
-
hookName,
|
|
1596
|
-
parameters,
|
|
1597
|
-
plugin
|
|
1598
|
-
});
|
|
1599
|
-
}).filter(Boolean);
|
|
1600
|
-
return Promise.all(promises);
|
|
1601
|
-
}
|
|
1602
|
-
/**
|
|
1603
|
-
* Run a specific hookName for plugin x.
|
|
1604
|
-
*/
|
|
1605
|
-
hookForPluginSync({
|
|
1606
|
-
pluginKey,
|
|
1607
|
-
hookName,
|
|
1608
|
-
parameters
|
|
1609
|
-
}) {
|
|
1610
|
-
const plugins = this.getPluginsByKey(hookName, pluginKey);
|
|
1611
|
-
return plugins.map((plugin) => {
|
|
1612
|
-
return _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _executeSync, executeSync_fn).call(this, {
|
|
1613
|
-
strategy: "hookFirst",
|
|
1614
|
-
hookName,
|
|
1615
|
-
parameters,
|
|
1616
|
-
plugin
|
|
1617
|
-
});
|
|
1618
|
-
}).filter(Boolean);
|
|
1619
|
-
}
|
|
1620
|
-
/**
|
|
1621
|
-
* First non-null result stops and will return it's value.
|
|
1622
|
-
*/
|
|
1623
|
-
async hookFirst({
|
|
1624
|
-
hookName,
|
|
1625
|
-
parameters,
|
|
1626
|
-
skipped
|
|
1627
|
-
}) {
|
|
1628
|
-
const promises = _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this).filter((plugin) => {
|
|
1629
|
-
return skipped ? skipped.has(plugin) : true;
|
|
1630
|
-
}).map((plugin) => {
|
|
1631
|
-
return async () => {
|
|
1632
|
-
const value = await _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
|
|
1633
|
-
strategy: "hookFirst",
|
|
1634
|
-
hookName,
|
|
1635
|
-
parameters,
|
|
1636
|
-
plugin
|
|
1637
|
-
});
|
|
1638
|
-
return Promise.resolve({
|
|
1639
|
-
plugin,
|
|
1640
|
-
result: value
|
|
1641
|
-
});
|
|
1642
|
-
};
|
|
1643
|
-
});
|
|
1644
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _promiseManager).run("first", promises);
|
|
1645
|
-
}
|
|
1646
|
-
/**
|
|
1647
|
-
* First non-null result stops and will return it's value.
|
|
1648
|
-
*/
|
|
1649
|
-
hookFirstSync({
|
|
1650
|
-
hookName,
|
|
1651
|
-
parameters,
|
|
1652
|
-
skipped
|
|
1653
|
-
}) {
|
|
1654
|
-
let parseResult = null;
|
|
1655
|
-
for (const plugin of _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
|
|
1656
|
-
if (_optionalChain([skipped, 'optionalAccess', _50 => _50.has, 'call', _51 => _51(plugin)])) {
|
|
1657
|
-
continue;
|
|
1658
|
-
}
|
|
1659
|
-
parseResult = {
|
|
1660
|
-
result: _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _executeSync, executeSync_fn).call(this, {
|
|
1661
|
-
strategy: "hookFirst",
|
|
1662
|
-
hookName,
|
|
1663
|
-
parameters,
|
|
1664
|
-
plugin
|
|
1665
|
-
}),
|
|
1666
|
-
plugin
|
|
1667
|
-
};
|
|
1668
|
-
if (_optionalChain([parseResult, 'optionalAccess', _52 => _52.result]) != null) {
|
|
1669
|
-
break;
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
return parseResult;
|
|
1673
|
-
}
|
|
1674
|
-
/**
|
|
1675
|
-
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
1676
|
-
*/
|
|
1677
|
-
async hookParallel({
|
|
1678
|
-
hookName,
|
|
1679
|
-
parameters
|
|
1680
|
-
}) {
|
|
1681
|
-
const promises = _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
|
|
1682
|
-
return () => _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
|
|
1683
|
-
strategy: "hookParallel",
|
|
1684
|
-
hookName,
|
|
1685
|
-
parameters,
|
|
1686
|
-
plugin
|
|
1687
|
-
});
|
|
1688
|
-
});
|
|
1689
|
-
const results = await _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _promiseManager).run("parallel", promises);
|
|
1690
|
-
results.forEach((result, index) => {
|
|
1691
|
-
if (isPromiseRejectedResult(result)) {
|
|
1692
|
-
const plugin = _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this)[index];
|
|
1693
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _catcher, catcher_fn).call(this, result.reason, plugin, hookName);
|
|
1694
|
-
}
|
|
1695
|
-
});
|
|
1696
|
-
return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
1697
|
-
}
|
|
1698
|
-
/**
|
|
1699
|
-
* 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.
|
|
1700
|
-
*/
|
|
1701
|
-
hookReduceArg0({
|
|
1702
|
-
hookName,
|
|
1703
|
-
parameters,
|
|
1704
|
-
reduce
|
|
1705
|
-
}) {
|
|
1706
|
-
const [argument0, ...rest] = parameters;
|
|
1707
|
-
let promise = Promise.resolve(argument0);
|
|
1708
|
-
for (const plugin of _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
|
|
1709
|
-
promise = promise.then((arg0) => {
|
|
1710
|
-
const value = _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
|
|
1711
|
-
strategy: "hookReduceArg0",
|
|
1712
|
-
hookName,
|
|
1713
|
-
parameters: [arg0, ...rest],
|
|
1714
|
-
plugin
|
|
1715
|
-
});
|
|
1716
|
-
return value;
|
|
1717
|
-
}).then((result) => reduce.call(_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _core).api, argument0, result, plugin));
|
|
1718
|
-
}
|
|
1719
|
-
return promise;
|
|
1720
|
-
}
|
|
1721
|
-
/**
|
|
1722
|
-
* Chains plugins
|
|
1723
|
-
*/
|
|
1724
|
-
async hookSeq({ hookName, parameters }) {
|
|
1725
|
-
const promises = _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
|
|
1726
|
-
return () => _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _execute, execute_fn).call(this, {
|
|
1727
|
-
strategy: "hookSeq",
|
|
1728
|
-
hookName,
|
|
1729
|
-
parameters,
|
|
1730
|
-
plugin
|
|
1731
|
-
});
|
|
1732
|
-
});
|
|
1733
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _promiseManager).run("seq", promises);
|
|
1734
|
-
}
|
|
1735
|
-
getPluginsByKey(hookName, pluginKey) {
|
|
1736
|
-
const plugins = [...this.plugins];
|
|
1737
|
-
const [searchPluginName, searchIdentifier] = pluginKey;
|
|
1738
|
-
const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
|
|
1739
|
-
const [name, identifier] = item.key;
|
|
1740
|
-
const identifierCheck = _optionalChain([identifier, 'optionalAccess', _53 => _53.toString, 'call', _54 => _54()]) === _optionalChain([searchIdentifier, 'optionalAccess', _55 => _55.toString, 'call', _56 => _56()]);
|
|
1741
|
-
const nameCheck = name === searchPluginName;
|
|
1742
|
-
if (searchIdentifier) {
|
|
1743
|
-
return identifierCheck && nameCheck;
|
|
1744
|
-
}
|
|
1745
|
-
return nameCheck;
|
|
1746
|
-
});
|
|
1747
|
-
if (!_optionalChain([pluginByPluginName, 'optionalAccess', _57 => _57.length])) {
|
|
1748
|
-
const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
|
|
1749
|
-
if (corePlugin) {
|
|
1750
|
-
this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`]);
|
|
1751
|
-
} else {
|
|
1752
|
-
this.logger.emit("debug", [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`]);
|
|
1753
|
-
}
|
|
1754
|
-
return corePlugin ? [corePlugin] : [];
|
|
1755
|
-
}
|
|
1756
|
-
return pluginByPluginName;
|
|
1757
|
-
}
|
|
1758
|
-
static getDependedPlugins(plugins, dependedPluginNames) {
|
|
1759
|
-
let pluginNames = [];
|
|
1760
|
-
if (typeof dependedPluginNames === "string") {
|
|
1761
|
-
pluginNames = [dependedPluginNames];
|
|
1762
|
-
} else {
|
|
1763
|
-
pluginNames = dependedPluginNames;
|
|
1764
|
-
}
|
|
1765
|
-
return pluginNames.map((pluginName) => {
|
|
1766
|
-
const plugin = plugins.find((plugin2) => plugin2.name === pluginName);
|
|
1767
|
-
if (!plugin) {
|
|
1768
|
-
throw new ValidationPluginError(`This plugin depends on the ${pluginName} plugin.`);
|
|
1769
|
-
}
|
|
1770
|
-
return plugin;
|
|
1771
|
-
});
|
|
1772
|
-
}
|
|
1773
|
-
static get hooks() {
|
|
1774
|
-
return ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
1775
|
-
}
|
|
1776
|
-
};
|
|
1777
|
-
_core = new WeakMap();
|
|
1778
|
-
_usedPluginNames = new WeakMap();
|
|
1779
|
-
_promiseManager = new WeakMap();
|
|
1780
|
-
_getSortedPlugins = new WeakSet();
|
|
1781
|
-
getSortedPlugins_fn = function(hookName) {
|
|
1782
|
-
const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
|
|
1783
|
-
if (hookName) {
|
|
1784
|
-
if (this.logger.logLevel === _chunkGG3XRJX3cjs.LogLevel.info) {
|
|
1785
|
-
const containsHookName = plugins.some((item) => item[hookName]);
|
|
1786
|
-
if (!containsHookName) {
|
|
1787
|
-
this.logger.emit("warning", `No hook ${hookName} found`);
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
return plugins.filter((item) => item[hookName]);
|
|
1791
|
-
}
|
|
1792
|
-
return plugins.map((plugin) => {
|
|
1793
|
-
if (plugin.pre) {
|
|
1794
|
-
const isValid = plugin.pre.every((pluginName) => plugins.find((pluginToFind) => pluginToFind.name === pluginName));
|
|
1795
|
-
if (!isValid) {
|
|
1796
|
-
throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
return plugin;
|
|
1800
|
-
}).sort((a, b) => {
|
|
1801
|
-
if (_optionalChain([b, 'access', _58 => _58.pre, 'optionalAccess', _59 => _59.includes, 'call', _60 => _60(a.name)])) {
|
|
1802
|
-
return 1;
|
|
1803
|
-
}
|
|
1804
|
-
if (_optionalChain([b, 'access', _61 => _61.post, 'optionalAccess', _62 => _62.includes, 'call', _63 => _63(a.name)])) {
|
|
1805
|
-
return -1;
|
|
1806
|
-
}
|
|
1807
|
-
return 0;
|
|
1808
|
-
});
|
|
1809
|
-
};
|
|
1810
|
-
_addExecutedToCallStack = new WeakSet();
|
|
1811
|
-
addExecutedToCallStack_fn = function(executer) {
|
|
1812
|
-
if (executer) {
|
|
1813
|
-
this.events.emit("executed", executer);
|
|
1814
|
-
this.executed.push(executer);
|
|
1815
|
-
}
|
|
1816
|
-
};
|
|
1817
|
-
_execute = new WeakSet();
|
|
1818
|
-
execute_fn = function({
|
|
1819
|
-
strategy,
|
|
1820
|
-
hookName,
|
|
1821
|
-
parameters,
|
|
1822
|
-
plugin
|
|
1823
|
-
}) {
|
|
1824
|
-
const hook = plugin[hookName];
|
|
1825
|
-
let output;
|
|
1826
|
-
if (!hook) {
|
|
1827
|
-
return null;
|
|
1828
|
-
}
|
|
1829
|
-
this.events.emit("execute", { strategy, hookName, parameters, plugin });
|
|
1830
|
-
const task = Promise.resolve().then(() => {
|
|
1831
|
-
if (typeof hook === "function") {
|
|
1832
|
-
const possiblePromiseResult = hook.apply({ ..._chunkXUCU53HTcjs.__privateGet.call(void 0, this, _core).api, plugin }, parameters);
|
|
1833
|
-
if (isPromise(possiblePromiseResult)) {
|
|
1834
|
-
return Promise.resolve(possiblePromiseResult);
|
|
1835
|
-
}
|
|
1836
|
-
return possiblePromiseResult;
|
|
1837
|
-
}
|
|
1838
|
-
return hook;
|
|
1839
|
-
}).then((result) => {
|
|
1840
|
-
output = result;
|
|
1841
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
|
|
1842
|
-
parameters,
|
|
1843
|
-
output,
|
|
1844
|
-
strategy,
|
|
1845
|
-
hookName,
|
|
1846
|
-
plugin
|
|
1847
|
-
});
|
|
1848
|
-
return result;
|
|
1849
|
-
}).catch((e) => {
|
|
1850
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _catcher, catcher_fn).call(this, e, plugin, hookName);
|
|
1851
|
-
return null;
|
|
1852
|
-
});
|
|
1853
|
-
return task;
|
|
1854
|
-
};
|
|
1855
|
-
_executeSync = new WeakSet();
|
|
1856
|
-
executeSync_fn = function({
|
|
1857
|
-
strategy,
|
|
1858
|
-
hookName,
|
|
1859
|
-
parameters,
|
|
1860
|
-
plugin
|
|
1861
|
-
}) {
|
|
1862
|
-
const hook = plugin[hookName];
|
|
1863
|
-
let output;
|
|
1864
|
-
if (!hook) {
|
|
1865
|
-
return null;
|
|
1866
|
-
}
|
|
1867
|
-
this.events.emit("execute", { strategy, hookName, parameters, plugin });
|
|
1868
|
-
try {
|
|
1869
|
-
if (typeof hook === "function") {
|
|
1870
|
-
const fn = hook.apply({ ..._chunkXUCU53HTcjs.__privateGet.call(void 0, this, _core).api, plugin }, parameters);
|
|
1871
|
-
output = fn;
|
|
1872
|
-
return fn;
|
|
1873
|
-
}
|
|
1874
|
-
output = hook;
|
|
1875
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
|
|
1876
|
-
parameters,
|
|
1877
|
-
output,
|
|
1878
|
-
strategy,
|
|
1879
|
-
hookName,
|
|
1880
|
-
plugin
|
|
1881
|
-
});
|
|
1882
|
-
return hook;
|
|
1883
|
-
} catch (e) {
|
|
1884
|
-
_chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _catcher, catcher_fn).call(this, e, plugin, hookName);
|
|
1885
|
-
return null;
|
|
1886
|
-
}
|
|
1887
|
-
};
|
|
1888
|
-
_catcher = new WeakSet();
|
|
1889
|
-
catcher_fn = function(cause, plugin, hookName) {
|
|
1890
|
-
const text = `${cause.message} (plugin: ${_optionalChain([plugin, 'optionalAccess', _64 => _64.name]) || "unknown"}, hook: ${hookName || "unknown"})`;
|
|
1891
|
-
this.logger.emit("error", text, cause);
|
|
1892
|
-
this.events.emit("error", cause);
|
|
1893
|
-
};
|
|
1894
|
-
_parse = new WeakSet();
|
|
1895
|
-
parse_fn = function(plugin, pluginManager, context) {
|
|
1896
|
-
const usedPluginNames = _chunkXUCU53HTcjs.__privateGet.call(void 0, pluginManager, _usedPluginNames);
|
|
1897
|
-
_chunkYTLMG2ANcjs.setUniqueName.call(void 0, plugin.name, usedPluginNames);
|
|
1898
|
-
const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
|
|
1899
|
-
if (!plugin.transform) {
|
|
1900
|
-
plugin.transform = function transform(code) {
|
|
1901
|
-
return code;
|
|
1902
|
-
};
|
|
1903
|
-
}
|
|
1904
|
-
if (plugin.api && typeof plugin.api === "function") {
|
|
1905
|
-
const api = plugin.api.call(context);
|
|
1906
|
-
return {
|
|
1907
|
-
...plugin,
|
|
1908
|
-
key,
|
|
1909
|
-
api
|
|
1910
|
-
};
|
|
1911
|
-
}
|
|
1912
|
-
return {
|
|
1913
|
-
...plugin,
|
|
1914
|
-
key
|
|
1915
|
-
};
|
|
1916
|
-
};
|
|
1917
|
-
|
|
1918
|
-
// src/config.ts
|
|
1919
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
1920
|
-
function defineConfig(options) {
|
|
1921
|
-
return options;
|
|
1922
|
-
}
|
|
1923
|
-
function isInputPath(result) {
|
|
1924
|
-
return !!result && "path" in result;
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
// src/build.ts
|
|
1928
|
-
async function transformReducer(_previousCode, result, _plugin) {
|
|
1929
|
-
return result;
|
|
1930
|
-
}
|
|
1931
|
-
async function setup(options) {
|
|
1932
|
-
const { config, logger = _chunkGG3XRJX3cjs.createLogger.call(void 0, { logLevel: _chunkGG3XRJX3cjs.LogLevel.silent }) } = options;
|
|
1933
|
-
let count = 0;
|
|
1934
|
-
try {
|
|
1935
|
-
if (isInputPath(config) && !new (0, _chunkYTLMG2ANcjs.URLPath)(config.input.path).isURL) {
|
|
1936
|
-
await _chunkAQJCCWPWcjs.read.call(void 0, config.input.path);
|
|
1937
|
-
}
|
|
1938
|
-
} catch (e) {
|
|
1939
|
-
if (isInputPath(config)) {
|
|
1940
|
-
throw new Error(
|
|
1941
|
-
`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${_chunkGG3XRJX3cjs.p.dim(config.input.path)}`,
|
|
1942
|
-
{
|
|
1943
|
-
cause: e
|
|
1944
|
-
}
|
|
1945
|
-
);
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
if (config.output.clean) {
|
|
1949
|
-
await _chunkAQJCCWPWcjs.clean.call(void 0, config.output.path);
|
|
1950
|
-
}
|
|
1951
|
-
const task = async (file) => {
|
|
1952
|
-
const { path: path5 } = file;
|
|
1953
|
-
let source = await FileManager.getSource(file);
|
|
1954
|
-
const { result: loadedResult } = await pluginManager.hookFirst({
|
|
1955
|
-
hookName: "load",
|
|
1956
|
-
parameters: [path5]
|
|
1957
|
-
});
|
|
1958
|
-
if (loadedResult && isPromise(loadedResult)) {
|
|
1959
|
-
source = await loadedResult;
|
|
1960
|
-
}
|
|
1961
|
-
if (loadedResult && !isPromise(loadedResult)) {
|
|
1962
|
-
source = loadedResult;
|
|
1963
|
-
}
|
|
1964
|
-
if (source) {
|
|
1965
|
-
source = await pluginManager.hookReduceArg0({
|
|
1966
|
-
hookName: "transform",
|
|
1967
|
-
parameters: [source, path5],
|
|
1968
|
-
reduce: transformReducer
|
|
1969
|
-
});
|
|
1970
|
-
if (config.output.write || config.output.write === void 0) {
|
|
1971
|
-
if (_optionalChain([file, 'access', _65 => _65.meta, 'optionalAccess', _66 => _66.pluginKey])) {
|
|
1972
|
-
await pluginManager.hookForPlugin({
|
|
1973
|
-
pluginKey: _optionalChain([file, 'access', _67 => _67.meta, 'optionalAccess', _68 => _68.pluginKey]),
|
|
1974
|
-
hookName: "writeFile",
|
|
1975
|
-
parameters: [source, path5]
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
await pluginManager.hookFirst({
|
|
1979
|
-
hookName: "writeFile",
|
|
1980
|
-
parameters: [source, path5]
|
|
1981
|
-
});
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
return {
|
|
1985
|
-
...file,
|
|
1986
|
-
source: source || ""
|
|
1987
|
-
};
|
|
1988
|
-
};
|
|
1989
|
-
const pluginManager = new PluginManager(config, { logger, task });
|
|
1990
|
-
pluginManager.on("execute", (executer) => {
|
|
1991
|
-
const { hookName, parameters, plugin } = executer;
|
|
1992
|
-
if (hookName === "writeFile") {
|
|
1993
|
-
const [code] = parameters;
|
|
1994
|
-
logger.emit("debug", [`PluginKey ${_chunkGG3XRJX3cjs.p.dim(JSON.stringify(plugin.key))}
|
|
1995
|
-
with source
|
|
1996
|
-
|
|
1997
|
-
${code}`]);
|
|
1998
|
-
}
|
|
1999
|
-
});
|
|
2000
|
-
pluginManager.queue.on("add", () => {
|
|
2001
|
-
if (logger.logLevel !== _chunkGG3XRJX3cjs.LogLevel.info) {
|
|
2002
|
-
return;
|
|
2003
|
-
}
|
|
2004
|
-
if (count === 0) {
|
|
2005
|
-
logger.emit("start", "\u{1F4BE} Writing");
|
|
2006
|
-
}
|
|
2007
|
-
});
|
|
2008
|
-
pluginManager.queue.on("active", () => {
|
|
2009
|
-
if (logger.logLevel !== _chunkGG3XRJX3cjs.LogLevel.info) {
|
|
2010
|
-
return;
|
|
2011
|
-
}
|
|
2012
|
-
if (logger.spinner && pluginManager.queue.size > 0) {
|
|
2013
|
-
const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
|
|
2014
|
-
logger.spinner.suffixText = _chunkGG3XRJX3cjs.p.dim(text);
|
|
2015
|
-
}
|
|
2016
|
-
++count;
|
|
2017
|
-
});
|
|
2018
|
-
pluginManager.queue.on("completed", () => {
|
|
2019
|
-
if (logger.logLevel !== _chunkGG3XRJX3cjs.LogLevel.info) {
|
|
2020
|
-
return;
|
|
2021
|
-
}
|
|
2022
|
-
if (logger.spinner) {
|
|
2023
|
-
const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`;
|
|
2024
|
-
logger.spinner.suffixText = _chunkGG3XRJX3cjs.p.dim(text);
|
|
2025
|
-
}
|
|
2026
|
-
});
|
|
2027
|
-
pluginManager.on("executed", (executer) => {
|
|
2028
|
-
const { hookName, plugin, output, parameters } = executer;
|
|
2029
|
-
const logs = [
|
|
2030
|
-
`${_chunkGG3XRJX3cjs.randomCliColour.call(void 0, plugin.name)} Executing ${hookName}`,
|
|
2031
|
-
parameters && `${_chunkGG3XRJX3cjs.p.bgWhite("Parameters")} ${_chunkGG3XRJX3cjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
|
|
2032
|
-
JSON.stringify(parameters, void 0, 2),
|
|
2033
|
-
output && `${_chunkGG3XRJX3cjs.p.bgWhite("Output")} ${_chunkGG3XRJX3cjs.randomCliColour.call(void 0, plugin.name)} ${hookName}`,
|
|
2034
|
-
output
|
|
2035
|
-
].filter(Boolean);
|
|
2036
|
-
logger.emit("debug", logs);
|
|
2037
|
-
});
|
|
2038
|
-
return pluginManager;
|
|
2039
|
-
}
|
|
2040
|
-
async function build(options) {
|
|
2041
|
-
const pluginManager = await setup(options);
|
|
2042
|
-
const { fileManager, logger } = pluginManager;
|
|
2043
|
-
await pluginManager.hookParallel({
|
|
2044
|
-
hookName: "buildStart",
|
|
2045
|
-
parameters: [options.config]
|
|
2046
|
-
});
|
|
2047
|
-
await pluginManager.hookParallel({ hookName: "buildEnd" });
|
|
2048
|
-
if (logger.logLevel === _chunkGG3XRJX3cjs.LogLevel.info) {
|
|
2049
|
-
logger.emit("end", "\u{1F4BE} Writing completed");
|
|
2050
|
-
}
|
|
2051
|
-
const files = await Promise.all(
|
|
2052
|
-
fileManager.files.map(async (file) => ({
|
|
2053
|
-
...file,
|
|
2054
|
-
source: await FileManager.getSource(file)
|
|
2055
|
-
}))
|
|
2056
|
-
);
|
|
2057
|
-
return {
|
|
2058
|
-
files,
|
|
2059
|
-
pluginManager
|
|
2060
|
-
};
|
|
2061
|
-
}
|
|
2062
|
-
async function safeBuild(options) {
|
|
2063
|
-
const pluginManager = await setup(options);
|
|
2064
|
-
const { fileManager, logger } = pluginManager;
|
|
2065
|
-
try {
|
|
2066
|
-
await pluginManager.hookParallel({
|
|
2067
|
-
hookName: "buildStart",
|
|
2068
|
-
parameters: [options.config]
|
|
2069
|
-
});
|
|
2070
|
-
await pluginManager.hookParallel({ hookName: "buildEnd" });
|
|
2071
|
-
if (logger.logLevel === _chunkGG3XRJX3cjs.LogLevel.info) {
|
|
2072
|
-
logger.emit("end", "\u{1F4BE} Writing completed");
|
|
2073
|
-
}
|
|
2074
|
-
} catch (e) {
|
|
2075
|
-
const files2 = await Promise.all(
|
|
2076
|
-
fileManager.files.map(async (file) => ({
|
|
2077
|
-
...file,
|
|
2078
|
-
source: await FileManager.getSource(file)
|
|
2079
|
-
}))
|
|
2080
|
-
);
|
|
2081
|
-
return {
|
|
2082
|
-
files: files2,
|
|
2083
|
-
pluginManager,
|
|
2084
|
-
error: e
|
|
2085
|
-
};
|
|
2086
|
-
}
|
|
2087
|
-
const files = await Promise.all(
|
|
2088
|
-
fileManager.files.map(async (file) => ({
|
|
2089
|
-
...file,
|
|
2090
|
-
source: await FileManager.getSource(file)
|
|
2091
|
-
}))
|
|
2092
|
-
);
|
|
2093
|
-
return {
|
|
2094
|
-
files,
|
|
2095
|
-
pluginManager
|
|
2096
|
-
};
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
|
-
// src/Generator.ts
|
|
2100
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2101
|
-
var _options3, _context;
|
|
2102
|
-
var Generator = class {
|
|
2103
|
-
constructor(options, context) {
|
|
2104
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _options3, {});
|
|
2105
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _context, {});
|
|
2106
|
-
if (context) {
|
|
2107
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _context, context);
|
|
2108
|
-
}
|
|
2109
|
-
if (options) {
|
|
2110
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _options3, options);
|
|
2111
|
-
}
|
|
2112
|
-
return this;
|
|
2113
|
-
}
|
|
2114
|
-
get options() {
|
|
2115
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _options3);
|
|
2116
|
-
}
|
|
2117
|
-
get context() {
|
|
2118
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _context);
|
|
2119
|
-
}
|
|
2120
|
-
set options(options) {
|
|
2121
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _options3, { ..._chunkXUCU53HTcjs.__privateGet.call(void 0, this, _options3), ...options });
|
|
2122
|
-
}
|
|
2123
|
-
};
|
|
2124
|
-
_options3 = new WeakMap();
|
|
2125
|
-
_context = new WeakMap();
|
|
2126
|
-
|
|
2127
|
-
// src/PackageManager.ts
|
|
2128
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2129
|
-
var _module = require('module'); var _module2 = _interopRequireDefault(_module);
|
|
2130
|
-
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
2131
|
-
var _url = require('url');
|
|
2132
|
-
|
|
2133
|
-
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
2134
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
// ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
|
|
2138
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2139
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
2140
|
-
|
|
2141
|
-
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
// ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
|
2145
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2146
|
-
|
|
2147
|
-
// ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
2148
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2149
|
-
|
|
2150
|
-
// ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
|
2151
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2152
|
-
var Node = class {
|
|
2153
|
-
constructor(value) {
|
|
2154
|
-
_chunkXUCU53HTcjs.__publicField.call(void 0, this, "value");
|
|
2155
|
-
_chunkXUCU53HTcjs.__publicField.call(void 0, this, "next");
|
|
2156
|
-
this.value = value;
|
|
2157
|
-
}
|
|
2158
|
-
};
|
|
2159
|
-
var _head, _tail, _size;
|
|
2160
|
-
var Queue = class {
|
|
2161
|
-
constructor() {
|
|
2162
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _head, void 0);
|
|
2163
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _tail, void 0);
|
|
2164
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _size, void 0);
|
|
2165
|
-
this.clear();
|
|
2166
|
-
}
|
|
2167
|
-
enqueue(value) {
|
|
2168
|
-
const node = new Node(value);
|
|
2169
|
-
if (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _head)) {
|
|
2170
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _tail).next = node;
|
|
2171
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _tail, node);
|
|
2172
|
-
} else {
|
|
2173
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _head, node);
|
|
2174
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _tail, node);
|
|
2175
|
-
}
|
|
2176
|
-
_chunkXUCU53HTcjs.__privateWrapper.call(void 0, this, _size)._++;
|
|
2177
|
-
}
|
|
2178
|
-
dequeue() {
|
|
2179
|
-
const current = _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _head);
|
|
2180
|
-
if (!current) {
|
|
2181
|
-
return;
|
|
2182
|
-
}
|
|
2183
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _head, _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _head).next);
|
|
2184
|
-
_chunkXUCU53HTcjs.__privateWrapper.call(void 0, this, _size)._--;
|
|
2185
|
-
return current.value;
|
|
2186
|
-
}
|
|
2187
|
-
clear() {
|
|
2188
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _head, void 0);
|
|
2189
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _tail, void 0);
|
|
2190
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _size, 0);
|
|
2191
|
-
}
|
|
2192
|
-
get size() {
|
|
2193
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _size);
|
|
2194
|
-
}
|
|
2195
|
-
*[Symbol.iterator]() {
|
|
2196
|
-
let current = _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _head);
|
|
2197
|
-
while (current) {
|
|
2198
|
-
yield current.value;
|
|
2199
|
-
current = current.next;
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
};
|
|
2203
|
-
_head = new WeakMap();
|
|
2204
|
-
_tail = new WeakMap();
|
|
2205
|
-
_size = new WeakMap();
|
|
2206
|
-
|
|
2207
|
-
// ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
|
|
2208
|
-
function pLimit(concurrency) {
|
|
2209
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
2210
|
-
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
2211
|
-
}
|
|
2212
|
-
const queue = new Queue();
|
|
2213
|
-
let activeCount = 0;
|
|
2214
|
-
const next = () => {
|
|
2215
|
-
activeCount--;
|
|
2216
|
-
if (queue.size > 0) {
|
|
2217
|
-
queue.dequeue()();
|
|
2218
|
-
}
|
|
2219
|
-
};
|
|
2220
|
-
const run = async (fn, resolve2, args) => {
|
|
2221
|
-
activeCount++;
|
|
2222
|
-
const result = (async () => fn(...args))();
|
|
2223
|
-
resolve2(result);
|
|
2224
|
-
try {
|
|
2225
|
-
await result;
|
|
2226
|
-
} catch (e2) {
|
|
2227
|
-
}
|
|
2228
|
-
next();
|
|
2229
|
-
};
|
|
2230
|
-
const enqueue = (fn, resolve2, args) => {
|
|
2231
|
-
queue.enqueue(run.bind(void 0, fn, resolve2, args));
|
|
2232
|
-
(async () => {
|
|
2233
|
-
await Promise.resolve();
|
|
2234
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
2235
|
-
queue.dequeue()();
|
|
2236
|
-
}
|
|
2237
|
-
})();
|
|
2238
|
-
};
|
|
2239
|
-
const generator = (fn, ...args) => new Promise((resolve2) => {
|
|
2240
|
-
enqueue(fn, resolve2, args);
|
|
2241
|
-
});
|
|
2242
|
-
Object.defineProperties(generator, {
|
|
2243
|
-
activeCount: {
|
|
2244
|
-
get: () => activeCount
|
|
2245
|
-
},
|
|
2246
|
-
pendingCount: {
|
|
2247
|
-
get: () => queue.size
|
|
2248
|
-
},
|
|
2249
|
-
clearQueue: {
|
|
2250
|
-
value: () => {
|
|
2251
|
-
queue.clear();
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
});
|
|
2255
|
-
return generator;
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
// ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
|
|
2259
|
-
var EndError = class extends Error {
|
|
2260
|
-
constructor(value) {
|
|
2261
|
-
super();
|
|
2262
|
-
this.value = value;
|
|
2263
|
-
}
|
|
2264
|
-
};
|
|
2265
|
-
var testElement = async (element, tester) => tester(await element);
|
|
2266
|
-
var finder = async (element) => {
|
|
2267
|
-
const values = await Promise.all(element);
|
|
2268
|
-
if (values[1] === true) {
|
|
2269
|
-
throw new EndError(values[0]);
|
|
2270
|
-
}
|
|
2271
|
-
return false;
|
|
2272
|
-
};
|
|
2273
|
-
async function pLocate(iterable, tester, {
|
|
2274
|
-
concurrency = Number.POSITIVE_INFINITY,
|
|
2275
|
-
preserveOrder = true
|
|
2276
|
-
} = {}) {
|
|
2277
|
-
const limit = pLimit(concurrency);
|
|
2278
|
-
const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
|
|
2279
|
-
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
|
2280
|
-
try {
|
|
2281
|
-
await Promise.all(items.map((element) => checkLimit(finder, element)));
|
|
2282
|
-
} catch (error) {
|
|
2283
|
-
if (error instanceof EndError) {
|
|
2284
|
-
return error.value;
|
|
2285
|
-
}
|
|
2286
|
-
throw error;
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
|
-
// ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
|
|
2291
|
-
var typeMappings = {
|
|
2292
|
-
directory: "isDirectory",
|
|
2293
|
-
file: "isFile"
|
|
2294
|
-
};
|
|
2295
|
-
function checkType(type) {
|
|
2296
|
-
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
|
2297
|
-
return;
|
|
2298
|
-
}
|
|
2299
|
-
throw new Error(`Invalid type specified: ${type}`);
|
|
2300
|
-
}
|
|
2301
|
-
var matchType = (type, stat) => stat[typeMappings[type]]();
|
|
2302
|
-
var toPath = (urlOrPath) => urlOrPath instanceof URL ? _url.fileURLToPath.call(void 0, urlOrPath) : urlOrPath;
|
|
2303
|
-
async function locatePath(paths, {
|
|
2304
|
-
cwd = _process2.default.cwd(),
|
|
2305
|
-
type = "file",
|
|
2306
|
-
allowSymlinks = true,
|
|
2307
|
-
concurrency,
|
|
2308
|
-
preserveOrder
|
|
2309
|
-
} = {}) {
|
|
2310
|
-
checkType(type);
|
|
2311
|
-
cwd = toPath(cwd);
|
|
2312
|
-
const statFunction = allowSymlinks ? _fs.promises.stat : _fs.promises.lstat;
|
|
2313
|
-
return pLocate(paths, async (path_) => {
|
|
2314
|
-
try {
|
|
2315
|
-
const stat = await statFunction(_path2.default.resolve(cwd, path_));
|
|
2316
|
-
return matchType(type, stat);
|
|
2317
|
-
} catch (e3) {
|
|
2318
|
-
return false;
|
|
2319
|
-
}
|
|
2320
|
-
}, { concurrency, preserveOrder });
|
|
2321
|
-
}
|
|
2322
|
-
function locatePathSync(paths, {
|
|
2323
|
-
cwd = _process2.default.cwd(),
|
|
2324
|
-
type = "file",
|
|
2325
|
-
allowSymlinks = true
|
|
2326
|
-
} = {}) {
|
|
2327
|
-
checkType(type);
|
|
2328
|
-
cwd = toPath(cwd);
|
|
2329
|
-
const statFunction = allowSymlinks ? _fs2.default.statSync : _fs2.default.lstatSync;
|
|
2330
|
-
for (const path_ of paths) {
|
|
2331
|
-
try {
|
|
2332
|
-
const stat = statFunction(_path2.default.resolve(cwd, path_), {
|
|
2333
|
-
throwIfNoEntry: false
|
|
2334
|
-
});
|
|
2335
|
-
if (!stat) {
|
|
2336
|
-
continue;
|
|
2337
|
-
}
|
|
2338
|
-
if (matchType(type, stat)) {
|
|
2339
|
-
return path_;
|
|
2340
|
-
}
|
|
2341
|
-
} catch (e4) {
|
|
2342
|
-
}
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2345
|
-
|
|
2346
|
-
// ../../node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
|
|
2347
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2348
|
-
|
|
2349
|
-
function toPath2(urlOrPath) {
|
|
2350
|
-
return urlOrPath instanceof URL ? _url.fileURLToPath.call(void 0, urlOrPath) : urlOrPath;
|
|
2351
|
-
}
|
|
2352
|
-
|
|
2353
|
-
// ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
|
|
2354
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
// ../../node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
2358
|
-
var findUpStop = Symbol("findUpStop");
|
|
2359
|
-
async function findUpMultiple(name, options = {}) {
|
|
2360
|
-
let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
|
|
2361
|
-
const { root } = _path2.default.parse(directory);
|
|
2362
|
-
const stopAt = _path2.default.resolve(directory, toPath2(_nullishCoalesce(options.stopAt, () => ( root))));
|
|
2363
|
-
const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
|
|
2364
|
-
const paths = [name].flat();
|
|
2365
|
-
const runMatcher = async (locateOptions) => {
|
|
2366
|
-
if (typeof name !== "function") {
|
|
2367
|
-
return locatePath(paths, locateOptions);
|
|
2368
|
-
}
|
|
2369
|
-
const foundPath = await name(locateOptions.cwd);
|
|
2370
|
-
if (typeof foundPath === "string") {
|
|
2371
|
-
return locatePath([foundPath], locateOptions);
|
|
2372
|
-
}
|
|
2373
|
-
return foundPath;
|
|
2374
|
-
};
|
|
2375
|
-
const matches = [];
|
|
2376
|
-
while (true) {
|
|
2377
|
-
const foundPath = await runMatcher({ ...options, cwd: directory });
|
|
2378
|
-
if (foundPath === findUpStop) {
|
|
2379
|
-
break;
|
|
2380
|
-
}
|
|
2381
|
-
if (foundPath) {
|
|
2382
|
-
matches.push(_path2.default.resolve(directory, foundPath));
|
|
2383
|
-
}
|
|
2384
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
2385
|
-
break;
|
|
2386
|
-
}
|
|
2387
|
-
directory = _path2.default.dirname(directory);
|
|
2388
|
-
}
|
|
2389
|
-
return matches;
|
|
2390
|
-
}
|
|
2391
|
-
function findUpMultipleSync(name, options = {}) {
|
|
2392
|
-
let directory = _path2.default.resolve(_nullishCoalesce(toPath2(options.cwd), () => ( "")));
|
|
2393
|
-
const { root } = _path2.default.parse(directory);
|
|
2394
|
-
const stopAt = _path2.default.resolve(directory, _nullishCoalesce(toPath2(options.stopAt), () => ( root)));
|
|
2395
|
-
const limit = _nullishCoalesce(options.limit, () => ( Number.POSITIVE_INFINITY));
|
|
2396
|
-
const paths = [name].flat();
|
|
2397
|
-
const runMatcher = (locateOptions) => {
|
|
2398
|
-
if (typeof name !== "function") {
|
|
2399
|
-
return locatePathSync(paths, locateOptions);
|
|
2400
|
-
}
|
|
2401
|
-
const foundPath = name(locateOptions.cwd);
|
|
2402
|
-
if (typeof foundPath === "string") {
|
|
2403
|
-
return locatePathSync([foundPath], locateOptions);
|
|
2404
|
-
}
|
|
2405
|
-
return foundPath;
|
|
2406
|
-
};
|
|
2407
|
-
const matches = [];
|
|
2408
|
-
while (true) {
|
|
2409
|
-
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
2410
|
-
if (foundPath === findUpStop) {
|
|
2411
|
-
break;
|
|
2412
|
-
}
|
|
2413
|
-
if (foundPath) {
|
|
2414
|
-
matches.push(_path2.default.resolve(directory, foundPath));
|
|
2415
|
-
}
|
|
2416
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
2417
|
-
break;
|
|
2418
|
-
}
|
|
2419
|
-
directory = _path2.default.dirname(directory);
|
|
2420
|
-
}
|
|
2421
|
-
return matches;
|
|
2422
|
-
}
|
|
2423
|
-
async function findUp(name, options = {}) {
|
|
2424
|
-
const matches = await findUpMultiple(name, { ...options, limit: 1 });
|
|
2425
|
-
return matches[0];
|
|
2426
|
-
}
|
|
2427
|
-
function findUpSync(name, options = {}) {
|
|
2428
|
-
const matches = findUpMultipleSync(name, { ...options, limit: 1 });
|
|
2429
|
-
return matches[0];
|
|
2430
|
-
}
|
|
2431
|
-
|
|
2432
|
-
// src/PackageManager.ts
|
|
2433
|
-
var _semver = require('semver');
|
|
2434
|
-
var _cache2, _cwd, _SLASHES, _match, match_fn;
|
|
2435
|
-
var _PackageManager = class _PackageManager {
|
|
2436
|
-
constructor(workspace) {
|
|
2437
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _match);
|
|
2438
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _cwd, void 0);
|
|
2439
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, this, _SLASHES, /* @__PURE__ */ new Set(["/", "\\"]));
|
|
2440
|
-
if (workspace) {
|
|
2441
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _cwd, workspace);
|
|
2442
|
-
}
|
|
2443
|
-
return this;
|
|
2444
|
-
}
|
|
2445
|
-
set workspace(workspace) {
|
|
2446
|
-
_chunkXUCU53HTcjs.__privateSet.call(void 0, this, _cwd, workspace);
|
|
2447
|
-
}
|
|
2448
|
-
get workspace() {
|
|
2449
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cwd);
|
|
2450
|
-
}
|
|
2451
|
-
normalizeDirectory(directory) {
|
|
2452
|
-
if (!_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _SLASHES).has(directory[directory.length - 1])) {
|
|
2453
|
-
return `${directory}/`;
|
|
2454
|
-
}
|
|
2455
|
-
return directory;
|
|
2456
|
-
}
|
|
2457
|
-
getLocation(path5) {
|
|
2458
|
-
let location = path5;
|
|
2459
|
-
if (_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cwd)) {
|
|
2460
|
-
const require2 = _module2.default.createRequire(this.normalizeDirectory(_chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cwd)));
|
|
2461
|
-
location = require2.resolve(path5);
|
|
2462
|
-
}
|
|
2463
|
-
return location;
|
|
2464
|
-
}
|
|
2465
|
-
async import(path5) {
|
|
2466
|
-
try {
|
|
2467
|
-
let location = this.getLocation(path5);
|
|
2468
|
-
if (_os2.default.platform() === "win32") {
|
|
2469
|
-
location = _url.pathToFileURL.call(void 0, location).href;
|
|
2470
|
-
}
|
|
2471
|
-
const module = await Promise.resolve().then(() => _interopRequireWildcard(require(location)));
|
|
2472
|
-
return _nullishCoalesce(_optionalChain([module, 'optionalAccess', _69 => _69.default]), () => ( module));
|
|
2473
|
-
} catch (e) {
|
|
2474
|
-
console.log(e);
|
|
2475
|
-
return void 0;
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
async getPackageJSON() {
|
|
2479
|
-
const pkgPath = await findUp(["package.json"], {
|
|
2480
|
-
cwd: _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cwd)
|
|
2481
|
-
});
|
|
2482
|
-
if (!pkgPath) {
|
|
2483
|
-
return void 0;
|
|
2484
|
-
}
|
|
2485
|
-
const json = await _chunkAQJCCWPWcjs.read.call(void 0, pkgPath);
|
|
2486
|
-
return JSON.parse(json);
|
|
2487
|
-
}
|
|
2488
|
-
getPackageJSONSync() {
|
|
2489
|
-
const pkgPath = findUpSync(["package.json"], {
|
|
2490
|
-
cwd: _chunkXUCU53HTcjs.__privateGet.call(void 0, this, _cwd)
|
|
2491
|
-
});
|
|
2492
|
-
if (!pkgPath) {
|
|
2493
|
-
return void 0;
|
|
2494
|
-
}
|
|
2495
|
-
const json = _chunkAQJCCWPWcjs.readSync.call(void 0, pkgPath);
|
|
2496
|
-
return JSON.parse(json);
|
|
2497
|
-
}
|
|
2498
|
-
static setVersion(dependency, version) {
|
|
2499
|
-
_chunkXUCU53HTcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency] = version;
|
|
2500
|
-
}
|
|
2501
|
-
async getVersion(dependency) {
|
|
2502
|
-
if (typeof dependency === "string" && _chunkXUCU53HTcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency]) {
|
|
2503
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency];
|
|
2504
|
-
}
|
|
2505
|
-
const packageJSON = await this.getPackageJSON();
|
|
2506
|
-
if (!packageJSON) {
|
|
2507
|
-
return void 0;
|
|
2508
|
-
}
|
|
2509
|
-
return _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _match, match_fn).call(this, packageJSON, dependency);
|
|
2510
|
-
}
|
|
2511
|
-
getVersionSync(dependency) {
|
|
2512
|
-
if (typeof dependency === "string" && _chunkXUCU53HTcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency]) {
|
|
2513
|
-
return _chunkXUCU53HTcjs.__privateGet.call(void 0, _PackageManager, _cache2)[dependency];
|
|
2514
|
-
}
|
|
2515
|
-
const packageJSON = this.getPackageJSONSync();
|
|
2516
|
-
if (!packageJSON) {
|
|
2517
|
-
return void 0;
|
|
2518
|
-
}
|
|
2519
|
-
return _chunkXUCU53HTcjs.__privateMethod.call(void 0, this, _match, match_fn).call(this, packageJSON, dependency);
|
|
2520
|
-
}
|
|
2521
|
-
async isValid(dependency, version) {
|
|
2522
|
-
const packageVersion = await this.getVersion(dependency);
|
|
2523
|
-
if (!packageVersion) {
|
|
2524
|
-
return false;
|
|
2525
|
-
}
|
|
2526
|
-
if (packageVersion === version) {
|
|
2527
|
-
return true;
|
|
2528
|
-
}
|
|
2529
|
-
const semVer = _semver.coerce.call(void 0, packageVersion);
|
|
2530
|
-
if (!semVer) {
|
|
2531
|
-
throw new Error(`${packageVersion} is not valid`);
|
|
2532
|
-
}
|
|
2533
|
-
return _semver.satisfies.call(void 0, semVer, version);
|
|
2534
|
-
}
|
|
2535
|
-
isValidSync(dependency, version) {
|
|
2536
|
-
const packageVersion = this.getVersionSync(dependency);
|
|
2537
|
-
if (!packageVersion) {
|
|
2538
|
-
return false;
|
|
2539
|
-
}
|
|
2540
|
-
const semVer = _semver.coerce.call(void 0, packageVersion);
|
|
2541
|
-
if (!semVer) {
|
|
2542
|
-
throw new Error(`${packageVersion} is not valid`);
|
|
2543
|
-
}
|
|
2544
|
-
return _semver.satisfies.call(void 0, semVer, version);
|
|
2545
|
-
}
|
|
2546
|
-
};
|
|
2547
|
-
_cache2 = new WeakMap();
|
|
2548
|
-
_cwd = new WeakMap();
|
|
2549
|
-
_SLASHES = new WeakMap();
|
|
2550
|
-
_match = new WeakSet();
|
|
2551
|
-
match_fn = function(packageJSON, dependency) {
|
|
2552
|
-
const dependencies = {
|
|
2553
|
-
...packageJSON["dependencies"] || {},
|
|
2554
|
-
...packageJSON["devDependencies"] || {}
|
|
2555
|
-
};
|
|
2556
|
-
if (typeof dependency === "string" && dependencies[dependency]) {
|
|
2557
|
-
return dependencies[dependency];
|
|
2558
|
-
}
|
|
2559
|
-
const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency));
|
|
2560
|
-
return matchedDependency ? dependencies[matchedDependency] : void 0;
|
|
2561
|
-
};
|
|
2562
|
-
_chunkXUCU53HTcjs.__privateAdd.call(void 0, _PackageManager, _cache2, {});
|
|
2563
|
-
var PackageManager = _PackageManager;
|
|
2564
|
-
|
|
2565
|
-
// src/kubb.ts
|
|
2566
|
-
var kubb_exports = {};
|
|
2567
|
-
_chunkXUCU53HTcjs.init_cjs_shims.call(void 0, );
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
exports.KubbFile = KubbFile; exports.FileManager = FileManager; exports.PromiseManager = PromiseManager; exports.Warning = Warning; exports.createPlugin = createPlugin; 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;
|
|
2584
|
-
//# sourceMappingURL=chunk-7PBKI3OR.cjs.map
|