@kubb/core 2.0.6 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/chunk-5P7ZNIXW.js +15 -0
  2. package/dist/chunk-5P7ZNIXW.js.map +1 -0
  3. package/dist/chunk-65JU7D5L.cjs +29 -0
  4. package/dist/chunk-65JU7D5L.cjs.map +1 -0
  5. package/dist/chunk-6CLGRKHL.js +1859 -0
  6. package/dist/chunk-6CLGRKHL.js.map +1 -0
  7. package/dist/chunk-6TTDLGHW.cjs +2548 -0
  8. package/dist/chunk-6TTDLGHW.cjs.map +1 -0
  9. package/dist/{chunk-XDHI63G7.cjs → chunk-BOAROBF4.cjs} +4 -4
  10. package/dist/chunk-BYGMREPJ.cjs +15 -0
  11. package/dist/chunk-BYGMREPJ.cjs.map +1 -0
  12. package/dist/{chunk-WZQO3EPM.cjs → chunk-CDC7AOGD.cjs} +3 -3
  13. package/dist/{chunk-WZQO3EPM.cjs.map → chunk-CDC7AOGD.cjs.map} +1 -1
  14. package/dist/{chunk-PLVKILIY.cjs → chunk-DQ3TMDDK.cjs} +7 -7
  15. package/dist/{chunk-5TK7TMV6.cjs → chunk-DU6UHGVD.cjs} +5 -5
  16. package/dist/{chunk-K2H7BYQB.js → chunk-EOUT5FJT.js} +3 -3
  17. package/dist/chunk-GPCFICX2.js +29 -0
  18. package/dist/chunk-GPCFICX2.js.map +1 -0
  19. package/dist/{chunk-4A7WG6IA.js → chunk-GQGYHVNX.js} +4 -25
  20. package/dist/chunk-GQGYHVNX.js.map +1 -0
  21. package/dist/{chunk-54P4AWHI.js → chunk-GUCIIN3Z.js} +3 -3
  22. package/dist/{chunk-54P4AWHI.js.map → chunk-GUCIIN3Z.js.map} +1 -1
  23. package/dist/{chunk-H47IKRXJ.cjs → chunk-IZOYUU2C.cjs} +6 -29
  24. package/dist/chunk-IZOYUU2C.cjs.map +1 -0
  25. package/dist/{chunk-NAWI7UXW.js → chunk-JSVMBHJE.js} +6 -12
  26. package/dist/chunk-JSVMBHJE.js.map +1 -0
  27. package/dist/{chunk-HIE46T3F.js → chunk-LIEJUR4C.js} +2 -2
  28. package/dist/{chunk-W2FP7ZWW.cjs → chunk-PTGWQCIU.cjs} +7 -15
  29. package/dist/chunk-PTGWQCIU.cjs.map +1 -0
  30. package/dist/{chunk-7S67BJXQ.js → chunk-QJQ3GMYY.js} +2 -2
  31. package/dist/{chunk-E3ANGQ5N.cjs → chunk-WHFBT7CJ.cjs} +90 -90
  32. package/dist/{chunk-XPOF4D5N.js → chunk-ZXH2OPE4.js} +2 -2
  33. package/dist/fs.cjs +10 -9
  34. package/dist/fs.cjs.map +1 -1
  35. package/dist/fs.js +4 -3
  36. package/dist/fs.js.map +1 -1
  37. package/dist/index.cjs +171 -2637
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +2 -2
  40. package/dist/index.d.ts +2 -2
  41. package/dist/index.js +36 -1847
  42. package/dist/index.js.map +1 -1
  43. package/dist/logger.cjs +7 -7
  44. package/dist/logger.js +3 -3
  45. package/dist/mocks.cjs +40 -0
  46. package/dist/mocks.cjs.map +1 -0
  47. package/dist/mocks.d.cts +11 -0
  48. package/dist/mocks.d.ts +11 -0
  49. package/dist/mocks.js +41 -0
  50. package/dist/mocks.js.map +1 -0
  51. package/dist/transformers.cjs +21 -21
  52. package/dist/transformers.js +5 -5
  53. package/dist/utils.cjs +13 -12
  54. package/dist/utils.cjs.map +1 -1
  55. package/dist/utils.js +4 -3
  56. package/dist/utils.js.map +1 -1
  57. package/package.json +10 -5
  58. package/src/BarrelManager.ts +43 -17
  59. package/src/FileManager.ts +33 -26
  60. package/dist/chunk-4A7WG6IA.js.map +0 -1
  61. package/dist/chunk-H47IKRXJ.cjs.map +0 -1
  62. package/dist/chunk-NAWI7UXW.js.map +0 -1
  63. package/dist/chunk-W2FP7ZWW.cjs.map +0 -1
  64. /package/dist/{chunk-XDHI63G7.cjs.map → chunk-BOAROBF4.cjs.map} +0 -0
  65. /package/dist/{chunk-PLVKILIY.cjs.map → chunk-DQ3TMDDK.cjs.map} +0 -0
  66. /package/dist/{chunk-5TK7TMV6.cjs.map → chunk-DU6UHGVD.cjs.map} +0 -0
  67. /package/dist/{chunk-K2H7BYQB.js.map → chunk-EOUT5FJT.js.map} +0 -0
  68. /package/dist/{chunk-HIE46T3F.js.map → chunk-LIEJUR4C.js.map} +0 -0
  69. /package/dist/{chunk-7S67BJXQ.js.map → chunk-QJQ3GMYY.js.map} +0 -0
  70. /package/dist/{chunk-E3ANGQ5N.cjs.map → chunk-WHFBT7CJ.cjs.map} +0 -0
  71. /package/dist/{chunk-XPOF4D5N.js.map → chunk-ZXH2OPE4.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,19 +1,15 @@
1
1
  import mod, { createRequire } from 'module';
2
- import { transformReservedWord, trimExtName, searchAndReplace } from './chunk-HIE46T3F.js';
3
- import { setUniqueName, URLPath } from './chunk-4A7WG6IA.js';
4
- import './chunk-XPOF4D5N.js';
5
- import { LogLevel, createLogger, p, randomCliColour } from './chunk-K2H7BYQB.js';
6
- import { read, getRelativePath, clean } from './chunk-NAWI7UXW.js';
7
- import { write } from './chunk-7S67BJXQ.js';
8
- import { __commonJS, init_esm_shims, __toESM, __privateAdd, __privateSet, __privateGet, __privateMethod, __require } from './chunk-54P4AWHI.js';
9
- import crypto from 'crypto';
10
- import path, { resolve, extname } from 'path';
11
- import { print } from '@kubb/parser';
12
- import * as factory from '@kubb/parser/factory';
13
- import { orderBy } from 'natural-orderby';
14
- import PQueue from 'p-queue';
15
- import dirTree from 'directory-tree';
16
- import { EventEmitter as EventEmitter$1 } from 'events';
2
+ import { URLPath } from './chunk-GQGYHVNX.js';
3
+ import { clean } from './chunk-5P7ZNIXW.js';
4
+ import { FileManager, PluginManager, isPromise } from './chunk-6CLGRKHL.js';
5
+ export { FileManager, KubbFile, PluginManager, PromiseManager, Warning, createPlugin, pluginName as name, pluginName } from './chunk-6CLGRKHL.js';
6
+ import './chunk-LIEJUR4C.js';
7
+ import './chunk-GPCFICX2.js';
8
+ import './chunk-ZXH2OPE4.js';
9
+ import { LogLevel, createLogger, p, randomCliColour } from './chunk-EOUT5FJT.js';
10
+ import { read } from './chunk-JSVMBHJE.js';
11
+ import './chunk-QJQ3GMYY.js';
12
+ import { init_esm_shims, __privateAdd, __privateSet, __privateGet, __require, __privateMethod } from './chunk-GUCIIN3Z.js';
17
13
  import os from 'os';
18
14
  import { pathToFileURL } from 'url';
19
15
  import { findUp, findUpSync } from 'find-up';
@@ -21,708 +17,6 @@ import { coerce, satisfies } from 'semver';
21
17
 
22
18
  createRequire(import.meta.url);
23
19
 
24
- // ../../node_modules/.pnpm/lodash.isequal@4.5.0/node_modules/lodash.isequal/index.js
25
- var require_lodash = __commonJS({
26
- "../../node_modules/.pnpm/lodash.isequal@4.5.0/node_modules/lodash.isequal/index.js"(exports, module) {
27
- init_esm_shims();
28
- var LARGE_ARRAY_SIZE = 200;
29
- var HASH_UNDEFINED = "__lodash_hash_undefined__";
30
- var COMPARE_PARTIAL_FLAG = 1;
31
- var COMPARE_UNORDERED_FLAG = 2;
32
- var MAX_SAFE_INTEGER = 9007199254740991;
33
- var argsTag = "[object Arguments]";
34
- var arrayTag = "[object Array]";
35
- var asyncTag = "[object AsyncFunction]";
36
- var boolTag = "[object Boolean]";
37
- var dateTag = "[object Date]";
38
- var errorTag = "[object Error]";
39
- var funcTag = "[object Function]";
40
- var genTag = "[object GeneratorFunction]";
41
- var mapTag = "[object Map]";
42
- var numberTag = "[object Number]";
43
- var nullTag = "[object Null]";
44
- var objectTag = "[object Object]";
45
- var promiseTag = "[object Promise]";
46
- var proxyTag = "[object Proxy]";
47
- var regexpTag = "[object RegExp]";
48
- var setTag = "[object Set]";
49
- var stringTag = "[object String]";
50
- var symbolTag = "[object Symbol]";
51
- var undefinedTag = "[object Undefined]";
52
- var weakMapTag = "[object WeakMap]";
53
- var arrayBufferTag = "[object ArrayBuffer]";
54
- var dataViewTag = "[object DataView]";
55
- var float32Tag = "[object Float32Array]";
56
- var float64Tag = "[object Float64Array]";
57
- var int8Tag = "[object Int8Array]";
58
- var int16Tag = "[object Int16Array]";
59
- var int32Tag = "[object Int32Array]";
60
- var uint8Tag = "[object Uint8Array]";
61
- var uint8ClampedTag = "[object Uint8ClampedArray]";
62
- var uint16Tag = "[object Uint16Array]";
63
- var uint32Tag = "[object Uint32Array]";
64
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
65
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
66
- var reIsUint = /^(?:0|[1-9]\d*)$/;
67
- var typedArrayTags = {};
68
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
69
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
70
- var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
71
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
72
- var root = freeGlobal || freeSelf || Function("return this")();
73
- var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
74
- var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
75
- var moduleExports = freeModule && freeModule.exports === freeExports;
76
- var freeProcess = moduleExports && freeGlobal.process;
77
- var nodeUtil = function() {
78
- try {
79
- return freeProcess && freeProcess.binding && freeProcess.binding("util");
80
- } catch (e) {
81
- }
82
- }();
83
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
84
- function arrayFilter(array, predicate) {
85
- var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
86
- while (++index < length) {
87
- var value = array[index];
88
- if (predicate(value, index, array)) {
89
- result[resIndex++] = value;
90
- }
91
- }
92
- return result;
93
- }
94
- function arrayPush(array, values) {
95
- var index = -1, length = values.length, offset = array.length;
96
- while (++index < length) {
97
- array[offset + index] = values[index];
98
- }
99
- return array;
100
- }
101
- function arraySome(array, predicate) {
102
- var index = -1, length = array == null ? 0 : array.length;
103
- while (++index < length) {
104
- if (predicate(array[index], index, array)) {
105
- return true;
106
- }
107
- }
108
- return false;
109
- }
110
- function baseTimes(n, iteratee) {
111
- var index = -1, result = Array(n);
112
- while (++index < n) {
113
- result[index] = iteratee(index);
114
- }
115
- return result;
116
- }
117
- function baseUnary(func) {
118
- return function(value) {
119
- return func(value);
120
- };
121
- }
122
- function cacheHas(cache, key) {
123
- return cache.has(key);
124
- }
125
- function getValue(object, key) {
126
- return object == null ? void 0 : object[key];
127
- }
128
- function mapToArray(map) {
129
- var index = -1, result = Array(map.size);
130
- map.forEach(function(value, key) {
131
- result[++index] = [key, value];
132
- });
133
- return result;
134
- }
135
- function overArg(func, transform) {
136
- return function(arg) {
137
- return func(transform(arg));
138
- };
139
- }
140
- function setToArray(set) {
141
- var index = -1, result = Array(set.size);
142
- set.forEach(function(value) {
143
- result[++index] = value;
144
- });
145
- return result;
146
- }
147
- var arrayProto = Array.prototype;
148
- var funcProto = Function.prototype;
149
- var objectProto = Object.prototype;
150
- var coreJsData = root["__core-js_shared__"];
151
- var funcToString = funcProto.toString;
152
- var hasOwnProperty = objectProto.hasOwnProperty;
153
- var maskSrcKey = function() {
154
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
155
- return uid ? "Symbol(src)_1." + uid : "";
156
- }();
157
- var nativeObjectToString = objectProto.toString;
158
- var reIsNative = RegExp(
159
- "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
160
- );
161
- var Buffer = moduleExports ? root.Buffer : void 0;
162
- var Symbol = root.Symbol;
163
- var Uint8Array = root.Uint8Array;
164
- var propertyIsEnumerable = objectProto.propertyIsEnumerable;
165
- var splice = arrayProto.splice;
166
- var symToStringTag = Symbol ? Symbol.toStringTag : void 0;
167
- var nativeGetSymbols = Object.getOwnPropertySymbols;
168
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
169
- var nativeKeys = overArg(Object.keys, Object);
170
- var DataView = getNative(root, "DataView");
171
- var Map2 = getNative(root, "Map");
172
- var Promise2 = getNative(root, "Promise");
173
- var Set2 = getNative(root, "Set");
174
- var WeakMap2 = getNative(root, "WeakMap");
175
- var nativeCreate = getNative(Object, "create");
176
- var dataViewCtorString = toSource(DataView);
177
- var mapCtorString = toSource(Map2);
178
- var promiseCtorString = toSource(Promise2);
179
- var setCtorString = toSource(Set2);
180
- var weakMapCtorString = toSource(WeakMap2);
181
- var symbolProto = Symbol ? Symbol.prototype : void 0;
182
- var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
183
- function Hash(entries) {
184
- var index = -1, length = entries == null ? 0 : entries.length;
185
- this.clear();
186
- while (++index < length) {
187
- var entry = entries[index];
188
- this.set(entry[0], entry[1]);
189
- }
190
- }
191
- function hashClear() {
192
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
193
- this.size = 0;
194
- }
195
- function hashDelete(key) {
196
- var result = this.has(key) && delete this.__data__[key];
197
- this.size -= result ? 1 : 0;
198
- return result;
199
- }
200
- function hashGet(key) {
201
- var data = this.__data__;
202
- if (nativeCreate) {
203
- var result = data[key];
204
- return result === HASH_UNDEFINED ? void 0 : result;
205
- }
206
- return hasOwnProperty.call(data, key) ? data[key] : void 0;
207
- }
208
- function hashHas(key) {
209
- var data = this.__data__;
210
- return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key);
211
- }
212
- function hashSet(key, value) {
213
- var data = this.__data__;
214
- this.size += this.has(key) ? 0 : 1;
215
- data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
216
- return this;
217
- }
218
- Hash.prototype.clear = hashClear;
219
- Hash.prototype["delete"] = hashDelete;
220
- Hash.prototype.get = hashGet;
221
- Hash.prototype.has = hashHas;
222
- Hash.prototype.set = hashSet;
223
- function ListCache(entries) {
224
- var index = -1, length = entries == null ? 0 : entries.length;
225
- this.clear();
226
- while (++index < length) {
227
- var entry = entries[index];
228
- this.set(entry[0], entry[1]);
229
- }
230
- }
231
- function listCacheClear() {
232
- this.__data__ = [];
233
- this.size = 0;
234
- }
235
- function listCacheDelete(key) {
236
- var data = this.__data__, index = assocIndexOf(data, key);
237
- if (index < 0) {
238
- return false;
239
- }
240
- var lastIndex = data.length - 1;
241
- if (index == lastIndex) {
242
- data.pop();
243
- } else {
244
- splice.call(data, index, 1);
245
- }
246
- --this.size;
247
- return true;
248
- }
249
- function listCacheGet(key) {
250
- var data = this.__data__, index = assocIndexOf(data, key);
251
- return index < 0 ? void 0 : data[index][1];
252
- }
253
- function listCacheHas(key) {
254
- return assocIndexOf(this.__data__, key) > -1;
255
- }
256
- function listCacheSet(key, value) {
257
- var data = this.__data__, index = assocIndexOf(data, key);
258
- if (index < 0) {
259
- ++this.size;
260
- data.push([key, value]);
261
- } else {
262
- data[index][1] = value;
263
- }
264
- return this;
265
- }
266
- ListCache.prototype.clear = listCacheClear;
267
- ListCache.prototype["delete"] = listCacheDelete;
268
- ListCache.prototype.get = listCacheGet;
269
- ListCache.prototype.has = listCacheHas;
270
- ListCache.prototype.set = listCacheSet;
271
- function MapCache(entries) {
272
- var index = -1, length = entries == null ? 0 : entries.length;
273
- this.clear();
274
- while (++index < length) {
275
- var entry = entries[index];
276
- this.set(entry[0], entry[1]);
277
- }
278
- }
279
- function mapCacheClear() {
280
- this.size = 0;
281
- this.__data__ = {
282
- "hash": new Hash(),
283
- "map": new (Map2 || ListCache)(),
284
- "string": new Hash()
285
- };
286
- }
287
- function mapCacheDelete(key) {
288
- var result = getMapData(this, key)["delete"](key);
289
- this.size -= result ? 1 : 0;
290
- return result;
291
- }
292
- function mapCacheGet(key) {
293
- return getMapData(this, key).get(key);
294
- }
295
- function mapCacheHas(key) {
296
- return getMapData(this, key).has(key);
297
- }
298
- function mapCacheSet(key, value) {
299
- var data = getMapData(this, key), size = data.size;
300
- data.set(key, value);
301
- this.size += data.size == size ? 0 : 1;
302
- return this;
303
- }
304
- MapCache.prototype.clear = mapCacheClear;
305
- MapCache.prototype["delete"] = mapCacheDelete;
306
- MapCache.prototype.get = mapCacheGet;
307
- MapCache.prototype.has = mapCacheHas;
308
- MapCache.prototype.set = mapCacheSet;
309
- function SetCache(values) {
310
- var index = -1, length = values == null ? 0 : values.length;
311
- this.__data__ = new MapCache();
312
- while (++index < length) {
313
- this.add(values[index]);
314
- }
315
- }
316
- function setCacheAdd(value) {
317
- this.__data__.set(value, HASH_UNDEFINED);
318
- return this;
319
- }
320
- function setCacheHas(value) {
321
- return this.__data__.has(value);
322
- }
323
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
324
- SetCache.prototype.has = setCacheHas;
325
- function Stack(entries) {
326
- var data = this.__data__ = new ListCache(entries);
327
- this.size = data.size;
328
- }
329
- function stackClear() {
330
- this.__data__ = new ListCache();
331
- this.size = 0;
332
- }
333
- function stackDelete(key) {
334
- var data = this.__data__, result = data["delete"](key);
335
- this.size = data.size;
336
- return result;
337
- }
338
- function stackGet(key) {
339
- return this.__data__.get(key);
340
- }
341
- function stackHas(key) {
342
- return this.__data__.has(key);
343
- }
344
- function stackSet(key, value) {
345
- var data = this.__data__;
346
- if (data instanceof ListCache) {
347
- var pairs = data.__data__;
348
- if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
349
- pairs.push([key, value]);
350
- this.size = ++data.size;
351
- return this;
352
- }
353
- data = this.__data__ = new MapCache(pairs);
354
- }
355
- data.set(key, value);
356
- this.size = data.size;
357
- return this;
358
- }
359
- Stack.prototype.clear = stackClear;
360
- Stack.prototype["delete"] = stackDelete;
361
- Stack.prototype.get = stackGet;
362
- Stack.prototype.has = stackHas;
363
- Stack.prototype.set = stackSet;
364
- function arrayLikeKeys(value, inherited) {
365
- var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
366
- for (var key in value) {
367
- if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
368
- (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
369
- isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
370
- isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
371
- isIndex(key, length)))) {
372
- result.push(key);
373
- }
374
- }
375
- return result;
376
- }
377
- function assocIndexOf(array, key) {
378
- var length = array.length;
379
- while (length--) {
380
- if (eq(array[length][0], key)) {
381
- return length;
382
- }
383
- }
384
- return -1;
385
- }
386
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
387
- var result = keysFunc(object);
388
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
389
- }
390
- function baseGetTag(value) {
391
- if (value == null) {
392
- return value === void 0 ? undefinedTag : nullTag;
393
- }
394
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
395
- }
396
- function baseIsArguments(value) {
397
- return isObjectLike(value) && baseGetTag(value) == argsTag;
398
- }
399
- function baseIsEqual(value, other, bitmask, customizer, stack) {
400
- if (value === other) {
401
- return true;
402
- }
403
- if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
404
- return value !== value && other !== other;
405
- }
406
- return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
407
- }
408
- function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
409
- var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
410
- objTag = objTag == argsTag ? objectTag : objTag;
411
- othTag = othTag == argsTag ? objectTag : othTag;
412
- var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
413
- if (isSameTag && isBuffer(object)) {
414
- if (!isBuffer(other)) {
415
- return false;
416
- }
417
- objIsArr = true;
418
- objIsObj = false;
419
- }
420
- if (isSameTag && !objIsObj) {
421
- stack || (stack = new Stack());
422
- return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
423
- }
424
- if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
425
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
426
- if (objIsWrapped || othIsWrapped) {
427
- var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
428
- stack || (stack = new Stack());
429
- return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
430
- }
431
- }
432
- if (!isSameTag) {
433
- return false;
434
- }
435
- stack || (stack = new Stack());
436
- return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
437
- }
438
- function baseIsNative(value) {
439
- if (!isObject(value) || isMasked(value)) {
440
- return false;
441
- }
442
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
443
- return pattern.test(toSource(value));
444
- }
445
- function baseIsTypedArray(value) {
446
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
447
- }
448
- function baseKeys(object) {
449
- if (!isPrototype(object)) {
450
- return nativeKeys(object);
451
- }
452
- var result = [];
453
- for (var key in Object(object)) {
454
- if (hasOwnProperty.call(object, key) && key != "constructor") {
455
- result.push(key);
456
- }
457
- }
458
- return result;
459
- }
460
- function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
461
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
462
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
463
- return false;
464
- }
465
- var stacked = stack.get(array);
466
- if (stacked && stack.get(other)) {
467
- return stacked == other;
468
- }
469
- var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : void 0;
470
- stack.set(array, other);
471
- stack.set(other, array);
472
- while (++index < arrLength) {
473
- var arrValue = array[index], othValue = other[index];
474
- if (customizer) {
475
- var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
476
- }
477
- if (compared !== void 0) {
478
- if (compared) {
479
- continue;
480
- }
481
- result = false;
482
- break;
483
- }
484
- if (seen) {
485
- if (!arraySome(other, function(othValue2, othIndex) {
486
- if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
487
- return seen.push(othIndex);
488
- }
489
- })) {
490
- result = false;
491
- break;
492
- }
493
- } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
494
- result = false;
495
- break;
496
- }
497
- }
498
- stack["delete"](array);
499
- stack["delete"](other);
500
- return result;
501
- }
502
- function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
503
- switch (tag) {
504
- case dataViewTag:
505
- if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
506
- return false;
507
- }
508
- object = object.buffer;
509
- other = other.buffer;
510
- case arrayBufferTag:
511
- if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
512
- return false;
513
- }
514
- return true;
515
- case boolTag:
516
- case dateTag:
517
- case numberTag:
518
- return eq(+object, +other);
519
- case errorTag:
520
- return object.name == other.name && object.message == other.message;
521
- case regexpTag:
522
- case stringTag:
523
- return object == other + "";
524
- case mapTag:
525
- var convert = mapToArray;
526
- case setTag:
527
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
528
- convert || (convert = setToArray);
529
- if (object.size != other.size && !isPartial) {
530
- return false;
531
- }
532
- var stacked = stack.get(object);
533
- if (stacked) {
534
- return stacked == other;
535
- }
536
- bitmask |= COMPARE_UNORDERED_FLAG;
537
- stack.set(object, other);
538
- var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
539
- stack["delete"](object);
540
- return result;
541
- case symbolTag:
542
- if (symbolValueOf) {
543
- return symbolValueOf.call(object) == symbolValueOf.call(other);
544
- }
545
- }
546
- return false;
547
- }
548
- function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
549
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
550
- if (objLength != othLength && !isPartial) {
551
- return false;
552
- }
553
- var index = objLength;
554
- while (index--) {
555
- var key = objProps[index];
556
- if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
557
- return false;
558
- }
559
- }
560
- var stacked = stack.get(object);
561
- if (stacked && stack.get(other)) {
562
- return stacked == other;
563
- }
564
- var result = true;
565
- stack.set(object, other);
566
- stack.set(other, object);
567
- var skipCtor = isPartial;
568
- while (++index < objLength) {
569
- key = objProps[index];
570
- var objValue = object[key], othValue = other[key];
571
- if (customizer) {
572
- var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
573
- }
574
- if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
575
- result = false;
576
- break;
577
- }
578
- skipCtor || (skipCtor = key == "constructor");
579
- }
580
- if (result && !skipCtor) {
581
- var objCtor = object.constructor, othCtor = other.constructor;
582
- if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
583
- result = false;
584
- }
585
- }
586
- stack["delete"](object);
587
- stack["delete"](other);
588
- return result;
589
- }
590
- function getAllKeys(object) {
591
- return baseGetAllKeys(object, keys, getSymbols);
592
- }
593
- function getMapData(map, key) {
594
- var data = map.__data__;
595
- return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
596
- }
597
- function getNative(object, key) {
598
- var value = getValue(object, key);
599
- return baseIsNative(value) ? value : void 0;
600
- }
601
- function getRawTag(value) {
602
- var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
603
- try {
604
- value[symToStringTag] = void 0;
605
- var unmasked = true;
606
- } catch (e) {
607
- }
608
- var result = nativeObjectToString.call(value);
609
- if (unmasked) {
610
- if (isOwn) {
611
- value[symToStringTag] = tag;
612
- } else {
613
- delete value[symToStringTag];
614
- }
615
- }
616
- return result;
617
- }
618
- var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
619
- if (object == null) {
620
- return [];
621
- }
622
- object = Object(object);
623
- return arrayFilter(nativeGetSymbols(object), function(symbol) {
624
- return propertyIsEnumerable.call(object, symbol);
625
- });
626
- };
627
- var getTag = baseGetTag;
628
- if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) {
629
- getTag = function(value) {
630
- var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
631
- if (ctorString) {
632
- switch (ctorString) {
633
- case dataViewCtorString:
634
- return dataViewTag;
635
- case mapCtorString:
636
- return mapTag;
637
- case promiseCtorString:
638
- return promiseTag;
639
- case setCtorString:
640
- return setTag;
641
- case weakMapCtorString:
642
- return weakMapTag;
643
- }
644
- }
645
- return result;
646
- };
647
- }
648
- function isIndex(value, length) {
649
- length = length == null ? MAX_SAFE_INTEGER : length;
650
- return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
651
- }
652
- function isKeyable(value) {
653
- var type = typeof value;
654
- return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
655
- }
656
- function isMasked(func) {
657
- return !!maskSrcKey && maskSrcKey in func;
658
- }
659
- function isPrototype(value) {
660
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto;
661
- return value === proto;
662
- }
663
- function objectToString(value) {
664
- return nativeObjectToString.call(value);
665
- }
666
- function toSource(func) {
667
- if (func != null) {
668
- try {
669
- return funcToString.call(func);
670
- } catch (e) {
671
- }
672
- try {
673
- return func + "";
674
- } catch (e) {
675
- }
676
- }
677
- return "";
678
- }
679
- function eq(value, other) {
680
- return value === other || value !== value && other !== other;
681
- }
682
- var isArguments = baseIsArguments(/* @__PURE__ */ function() {
683
- return arguments;
684
- }()) ? baseIsArguments : function(value) {
685
- return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
686
- };
687
- var isArray = Array.isArray;
688
- function isArrayLike(value) {
689
- return value != null && isLength(value.length) && !isFunction(value);
690
- }
691
- var isBuffer = nativeIsBuffer || stubFalse;
692
- function isEqual2(value, other) {
693
- return baseIsEqual(value, other);
694
- }
695
- function isFunction(value) {
696
- if (!isObject(value)) {
697
- return false;
698
- }
699
- var tag = baseGetTag(value);
700
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
701
- }
702
- function isLength(value) {
703
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
704
- }
705
- function isObject(value) {
706
- var type = typeof value;
707
- return value != null && (type == "object" || type == "function");
708
- }
709
- function isObjectLike(value) {
710
- return value != null && typeof value == "object";
711
- }
712
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
713
- function keys(object) {
714
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
715
- }
716
- function stubArray() {
717
- return [];
718
- }
719
- function stubFalse() {
720
- return false;
721
- }
722
- module.exports = isEqual2;
723
- }
724
- });
725
-
726
20
  // src/index.ts
727
21
  init_esm_shims();
728
22
 
@@ -738,1111 +32,6 @@ function isInputPath(result) {
738
32
  return !!result && "path" in result;
739
33
  }
740
34
 
741
- // src/FileManager.ts
742
- init_esm_shims();
743
- var import_lodash = __toESM(require_lodash(), 1);
744
-
745
- // src/BarrelManager.ts
746
- init_esm_shims();
747
-
748
- // src/utils/TreeNode.ts
749
- init_esm_shims();
750
- var TreeNode = class _TreeNode {
751
- constructor(data, parent) {
752
- this.children = [];
753
- this.data = data;
754
- this.parent = parent;
755
- return this;
756
- }
757
- addChild(data) {
758
- const child = new _TreeNode(data, this);
759
- if (!this.children) {
760
- this.children = [];
761
- }
762
- this.children.push(child);
763
- return child;
764
- }
765
- find(data) {
766
- if (!data) {
767
- return null;
768
- }
769
- if (data === this.data) {
770
- return this;
771
- }
772
- if (this.children?.length) {
773
- for (let i = 0, { length } = this.children, target = null; i < length; i++) {
774
- target = this.children[i].find(data);
775
- if (target) {
776
- return target;
777
- }
778
- }
779
- }
780
- return null;
781
- }
782
- get leaves() {
783
- if (!this.children || this.children.length === 0) {
784
- return [this];
785
- }
786
- const leaves = [];
787
- if (this.children) {
788
- for (let i = 0, { length } = this.children; i < length; i++) {
789
- leaves.push.apply(leaves, this.children[i].leaves);
790
- }
791
- }
792
- return leaves;
793
- }
794
- get root() {
795
- if (!this.parent) {
796
- return this;
797
- }
798
- return this.parent.root;
799
- }
800
- forEach(callback) {
801
- if (typeof callback !== "function") {
802
- throw new TypeError("forEach() callback must be a function");
803
- }
804
- callback(this);
805
- if (this.children) {
806
- for (let i = 0, { length } = this.children; i < length; i++) {
807
- this.children[i].forEach(callback);
808
- }
809
- }
810
- return this;
811
- }
812
- static build(path3, options = {}) {
813
- try {
814
- const exclude = Array.isArray(options.exclude) ? options.exclude : [options.exclude].filter(Boolean);
815
- const filteredTree = dirTree(path3, { extensions: options.extensions, exclude: [/node_modules/, ...exclude] });
816
- if (!filteredTree) {
817
- return null;
818
- }
819
- const treeNode = new _TreeNode({ name: filteredTree.name, path: filteredTree.path, type: filteredTree.type || FileManager.getMode(filteredTree.path) });
820
- const recurse = (node, item) => {
821
- const subNode = node.addChild({ name: item.name, path: item.path, type: item.type || FileManager.getMode(item.path) });
822
- if (item.children?.length) {
823
- item.children?.forEach((child) => {
824
- recurse(subNode, child);
825
- });
826
- }
827
- };
828
- filteredTree.children?.forEach((child) => recurse(treeNode, child));
829
- return treeNode;
830
- } catch (e) {
831
- throw new Error("Something went wrong with creating index files with the TreehNode class", { cause: e });
832
- }
833
- }
834
- };
835
-
836
- // src/BarrelManager.ts
837
- var _options;
838
- var BarrelManager = class {
839
- constructor(options = {}) {
840
- __privateAdd(this, _options, void 0);
841
- __privateSet(this, _options, options);
842
- return this;
843
- }
844
- getIndexes(pathToBuild) {
845
- const { treeNode = {}, isTypeOnly, extName } = __privateGet(this, _options);
846
- const tree = TreeNode.build(pathToBuild, treeNode);
847
- if (!tree) {
848
- return null;
849
- }
850
- const fileReducer = (files, treeNode2) => {
851
- if (!treeNode2.children) {
852
- return [];
853
- }
854
- if (treeNode2.children.length > 1) {
855
- const indexPath = path.resolve(treeNode2.data.path, "index.ts");
856
- const exports = treeNode2.children.filter(Boolean).map((file) => {
857
- const importPath = file.data.type === "directory" ? `./${file.data.name}/index` : `./${trimExtName(file.data.name)}`;
858
- if (importPath.endsWith("index") && file.data.type === "file") {
859
- return void 0;
860
- }
861
- return {
862
- path: extName ? `${importPath}${extName}` : importPath,
863
- isTypeOnly
864
- };
865
- }).filter(Boolean);
866
- files.push({
867
- path: indexPath,
868
- baseName: "index.ts",
869
- source: "",
870
- exports,
871
- meta: {
872
- treeNode: treeNode2
873
- }
874
- });
875
- } else if (treeNode2.children.length === 1) {
876
- const [treeNodeChild] = treeNode2.children;
877
- const indexPath = path.resolve(treeNode2.data.path, "index.ts");
878
- const importPath = treeNodeChild.data.type === "directory" ? `./${treeNodeChild.data.name}/index` : `./${trimExtName(treeNodeChild.data.name)}`;
879
- const exports = [
880
- {
881
- path: extName ? `${importPath}${extName}` : importPath,
882
- isTypeOnly
883
- }
884
- ];
885
- files.push({
886
- path: indexPath,
887
- baseName: "index.ts",
888
- source: "",
889
- exports,
890
- meta: {
891
- treeNode: treeNode2
892
- }
893
- });
894
- }
895
- treeNode2.children.forEach((childItem) => {
896
- fileReducer(files, childItem);
897
- });
898
- return files;
899
- };
900
- return fileReducer([], tree).reverse();
901
- }
902
- };
903
- _options = new WeakMap();
904
-
905
- // src/FileManager.ts
906
- var KubbFile;
907
- ((KubbFile2) => {
908
- })(KubbFile || (KubbFile = {}));
909
- var _cache, _task, _queue, _add, add_fn, _addOrAppend, addOrAppend_fn;
910
- var _FileManager = class _FileManager {
911
- constructor({ task = async (file) => file, queue = new PQueue() } = {}) {
912
- __privateAdd(this, _add);
913
- __privateAdd(this, _addOrAppend);
914
- __privateAdd(this, _cache, /* @__PURE__ */ new Map());
915
- __privateAdd(this, _task, void 0);
916
- __privateAdd(this, _queue, void 0);
917
- __privateSet(this, _task, task);
918
- __privateSet(this, _queue, queue);
919
- return this;
920
- }
921
- get files() {
922
- const files = [];
923
- __privateGet(this, _cache).forEach((item) => {
924
- files.push(...item.flat(1));
925
- });
926
- return files;
927
- }
928
- get isExecuting() {
929
- return __privateGet(this, _queue).size !== 0 && __privateGet(this, _queue).pending !== 0;
930
- }
931
- async add(...files) {
932
- const promises = combineFiles(files).map((file) => {
933
- if (file.override) {
934
- return __privateMethod(this, _add, add_fn).call(this, file);
935
- }
936
- return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, file);
937
- });
938
- const resolvedFiles = await Promise.all(promises);
939
- if (files.length > 1) {
940
- return resolvedFiles;
941
- }
942
- return resolvedFiles[0];
943
- }
944
- async addIndexes({ root, output, meta, options = {} }) {
945
- const { exportType = "barrel" } = output;
946
- if (!exportType) {
947
- return void 0;
948
- }
949
- const exportPath = output.path.startsWith("./") ? trimExtName(output.path) : `./${trimExtName(output.path)}`;
950
- const mode = _FileManager.getMode(output.path);
951
- const barrelManager = new BarrelManager({ extName: output.extName, ...options });
952
- const files = barrelManager.getIndexes(resolve(root, output.path));
953
- function getPath() {
954
- if (output.extName) {
955
- if (mode === "directory") {
956
- return `${exportPath}/index${output.extName}`;
957
- }
958
- return `${exportPath}${output.extName}`;
959
- }
960
- return exportPath;
961
- }
962
- if (!files) {
963
- return void 0;
964
- }
965
- const rootFile = {
966
- path: resolve(root, "index.ts"),
967
- baseName: "index.ts",
968
- source: "",
969
- exports: [
970
- output.exportAs ? {
971
- name: output.exportAs,
972
- asAlias: true,
973
- path: getPath(),
974
- isTypeOnly: options.isTypeOnly
975
- } : {
976
- path: getPath(),
977
- isTypeOnly: options.isTypeOnly
978
- }
979
- ]
980
- };
981
- await __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
982
- ...rootFile,
983
- meta: meta ? meta : rootFile.meta
984
- });
985
- return await Promise.all(
986
- files.map((file) => {
987
- return __privateMethod(this, _addOrAppend, addOrAppend_fn).call(this, {
988
- ...file,
989
- meta: meta ? meta : file.meta
990
- });
991
- })
992
- );
993
- }
994
- getCacheByUUID(UUID) {
995
- let cache;
996
- __privateGet(this, _cache).forEach((files) => {
997
- cache = files.find((item) => item.id === UUID);
998
- });
999
- return cache;
1000
- }
1001
- get(path3) {
1002
- return __privateGet(this, _cache).get(path3);
1003
- }
1004
- remove(path3) {
1005
- const cacheItem = this.get(path3);
1006
- if (!cacheItem) {
1007
- return;
1008
- }
1009
- __privateGet(this, _cache).delete(path3);
1010
- }
1011
- async write(...params) {
1012
- return write(...params);
1013
- }
1014
- async read(...params) {
1015
- return read(...params);
1016
- }
1017
- // statics
1018
- static getSource(file) {
1019
- return getSource(file);
1020
- }
1021
- static combineFiles(files) {
1022
- return combineFiles(files);
1023
- }
1024
- static getMode(path3) {
1025
- if (!path3) {
1026
- return "directory";
1027
- }
1028
- return extname(path3) ? "file" : "directory";
1029
- }
1030
- static get extensions() {
1031
- return [".js", ".ts", ".tsx"];
1032
- }
1033
- static isExtensionAllowed(baseName) {
1034
- return _FileManager.extensions.some((extension) => baseName.endsWith(extension));
1035
- }
1036
- };
1037
- _cache = new WeakMap();
1038
- _task = new WeakMap();
1039
- _queue = new WeakMap();
1040
- _add = new WeakSet();
1041
- add_fn = async function(file) {
1042
- const controller = new AbortController();
1043
- const resolvedFile = { id: crypto.randomUUID(), name: trimExtName(file.baseName), ...file };
1044
- __privateGet(this, _cache).set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
1045
- return __privateGet(this, _queue).add(
1046
- async () => {
1047
- var _a;
1048
- return (_a = __privateGet(this, _task)) == null ? void 0 : _a.call(this, resolvedFile);
1049
- },
1050
- { signal: controller.signal }
1051
- );
1052
- };
1053
- _addOrAppend = new WeakSet();
1054
- addOrAppend_fn = async function(file) {
1055
- const previousCaches = __privateGet(this, _cache).get(file.path);
1056
- const previousCache = previousCaches ? previousCaches.at(previousCaches.length - 1) : void 0;
1057
- if (previousCache) {
1058
- __privateGet(this, _cache).delete(previousCache.path);
1059
- return __privateMethod(this, _add, add_fn).call(this, {
1060
- ...file,
1061
- source: previousCache.source && file.source ? `${previousCache.source}
1062
- ${file.source}` : "",
1063
- imports: [...previousCache.imports || [], ...file.imports || []],
1064
- exports: [...previousCache.exports || [], ...file.exports || []],
1065
- env: { ...previousCache.env || {}, ...file.env || {} }
1066
- });
1067
- }
1068
- return __privateMethod(this, _add, add_fn).call(this, file);
1069
- };
1070
- var FileManager = _FileManager;
1071
- function combineFiles(files) {
1072
- return files.filter(Boolean).reduce((acc, file) => {
1073
- const prevIndex = acc.findIndex((item) => item.path === file.path);
1074
- if (prevIndex === -1) {
1075
- return [...acc, file];
1076
- }
1077
- const prev = acc[prevIndex];
1078
- if (prev && file.override) {
1079
- acc[prevIndex] = {
1080
- imports: [],
1081
- exports: [],
1082
- ...file
1083
- };
1084
- return acc;
1085
- }
1086
- if (prev) {
1087
- acc[prevIndex] = {
1088
- ...file,
1089
- source: prev.source && file.source ? `${prev.source}
1090
- ${file.source}` : "",
1091
- imports: [...prev.imports || [], ...file.imports || []],
1092
- exports: [...prev.exports || [], ...file.exports || []],
1093
- env: { ...prev.env || {}, ...file.env || {} }
1094
- };
1095
- }
1096
- return acc;
1097
- }, []);
1098
- }
1099
- function getSource(file) {
1100
- if (!FileManager.isExtensionAllowed(file.baseName)) {
1101
- return file.source;
1102
- }
1103
- const exports = file.exports ? combineExports(file.exports) : [];
1104
- const imports = file.imports ? combineImports(file.imports, exports, file.source) : [];
1105
- const importNodes = imports.filter((item) => {
1106
- return item.path !== trimExtName(file.path);
1107
- }).map((item) => {
1108
- return factory.createImportDeclaration({
1109
- name: item.name,
1110
- path: item.root ? getRelativePath(item.root, item.path) : item.path,
1111
- isTypeOnly: item.isTypeOnly
1112
- });
1113
- });
1114
- const exportNodes = exports.map(
1115
- (item) => factory.createExportDeclaration({
1116
- name: item.name,
1117
- path: item.path,
1118
- isTypeOnly: item.isTypeOnly,
1119
- asAlias: item.asAlias
1120
- })
1121
- );
1122
- return [print([...importNodes, ...exportNodes]), getEnvSource(file.source, file.env)].join("\n");
1123
- }
1124
- function combineExports(exports) {
1125
- const combinedExports = orderBy(exports, [(v) => !v.isTypeOnly], ["asc"]).reduce((prev, curr) => {
1126
- const name = curr.name;
1127
- const prevByPath = prev.findLast((imp) => imp.path === curr.path);
1128
- const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && (0, import_lodash.default)(imp.name, name) && imp.isTypeOnly);
1129
- if (prevByPathAndIsTypeOnly) {
1130
- return prev;
1131
- }
1132
- const uniquePrev = prev.findLast(
1133
- (imp) => imp.path === curr.path && (0, import_lodash.default)(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias
1134
- );
1135
- if (uniquePrev || Array.isArray(name) && !name.length || prevByPath?.asAlias && !curr.asAlias) {
1136
- return prev;
1137
- }
1138
- if (!prevByPath) {
1139
- return [
1140
- ...prev,
1141
- {
1142
- ...curr,
1143
- name: Array.isArray(name) ? [...new Set(name)] : name
1144
- }
1145
- ];
1146
- }
1147
- if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
1148
- prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...curr.name])];
1149
- return prev;
1150
- }
1151
- return [...prev, curr];
1152
- }, []);
1153
- return orderBy(combinedExports, [(v) => !v.isTypeOnly, (v) => v.asAlias], ["desc", "desc"]);
1154
- }
1155
- function combineImports(imports, exports, source) {
1156
- const combinedImports = orderBy(imports, [(v) => !v.isTypeOnly], ["asc"]).reduce((prev, curr) => {
1157
- let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name;
1158
- const hasImportInSource = (importName) => {
1159
- if (!source) {
1160
- return true;
1161
- }
1162
- const checker = (name2) => name2 && !!source.includes(name2);
1163
- return checker(importName) || exports.some(({ name: name2 }) => Array.isArray(name2) ? name2.some(checker) : checker(name2));
1164
- };
1165
- if (Array.isArray(name)) {
1166
- name = name.filter((item) => typeof item === "string" ? hasImportInSource(item) : hasImportInSource(item.propertyName));
1167
- }
1168
- const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly);
1169
- const uniquePrev = prev.findLast((imp) => imp.path === curr.path && (0, import_lodash.default)(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly);
1170
- const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && (0, import_lodash.default)(imp.name, name) && imp.isTypeOnly);
1171
- if (prevByPathNameAndIsTypeOnly) {
1172
- return prev;
1173
- }
1174
- if (uniquePrev || Array.isArray(name) && !name.length) {
1175
- return prev;
1176
- }
1177
- if (!prevByPath) {
1178
- return [
1179
- ...prev,
1180
- {
1181
- ...curr,
1182
- name
1183
- }
1184
- ];
1185
- }
1186
- if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {
1187
- prevByPath.name = [.../* @__PURE__ */ new Set([...prevByPath.name, ...name])];
1188
- return prev;
1189
- }
1190
- if (!Array.isArray(name) && name && !hasImportInSource(name)) {
1191
- return prev;
1192
- }
1193
- return [...prev, curr];
1194
- }, []);
1195
- return orderBy(combinedImports, [(v) => !v.isTypeOnly], ["desc"]);
1196
- }
1197
- function getEnvSource(source, env) {
1198
- if (!env) {
1199
- return source;
1200
- }
1201
- const keys = Object.keys(env);
1202
- if (!keys.length) {
1203
- return source;
1204
- }
1205
- return keys.reduce((prev, key) => {
1206
- const environmentValue = env[key];
1207
- const replaceBy = environmentValue ? `'${environmentValue.replaceAll('"', "")?.replaceAll("'", "")}'` : "undefined";
1208
- if (key.toUpperCase() !== key) {
1209
- throw new TypeError(`Environment should be in upperCase for ${key}`);
1210
- }
1211
- if (typeof replaceBy === "string") {
1212
- prev = searchAndReplace({ text: prev.replaceAll(`process.env.${key}`, replaceBy), replaceBy, prefix: "process.env", key });
1213
- prev = searchAndReplace({ text: prev.replaceAll(new RegExp(`(declare const).*
1214
- `, "ig"), ""), replaceBy, key });
1215
- }
1216
- return prev;
1217
- }, source);
1218
- }
1219
-
1220
- // src/PluginManager.ts
1221
- init_esm_shims();
1222
-
1223
- // src/utils/EventEmitter.ts
1224
- init_esm_shims();
1225
- var _emitter;
1226
- var EventEmitter = class {
1227
- constructor() {
1228
- __privateAdd(this, _emitter, new EventEmitter$1());
1229
- __privateGet(this, _emitter).setMaxListeners(100);
1230
- }
1231
- emit(eventName, ...eventArg) {
1232
- __privateGet(this, _emitter).emit(eventName, ...eventArg);
1233
- }
1234
- on(eventName, handler) {
1235
- __privateGet(this, _emitter).on(eventName, handler);
1236
- }
1237
- off(eventName, handler) {
1238
- __privateGet(this, _emitter).off(eventName, handler);
1239
- }
1240
- removeAll() {
1241
- __privateGet(this, _emitter).removeAllListeners();
1242
- }
1243
- };
1244
- _emitter = new WeakMap();
1245
-
1246
- // src/errors.ts
1247
- init_esm_shims();
1248
- var Warning = class extends Error {
1249
- constructor(message, options) {
1250
- super(message, { cause: options?.cause });
1251
- this.name = "Warning";
1252
- }
1253
- };
1254
- var ValidationPluginError = class extends Error {
1255
- };
1256
-
1257
- // src/plugin.ts
1258
- init_esm_shims();
1259
-
1260
- // src/utils/cache.ts
1261
- init_esm_shims();
1262
- function createPluginCache(Store = /* @__PURE__ */ Object.create(null)) {
1263
- return {
1264
- set(id, value) {
1265
- Store[id] = [0, value];
1266
- },
1267
- get(id) {
1268
- const item = Store[id];
1269
- if (!item) {
1270
- return null;
1271
- }
1272
- item[0] = 0;
1273
- return item[1];
1274
- },
1275
- has(id) {
1276
- const item = Store[id];
1277
- if (!item) {
1278
- return false;
1279
- }
1280
- item[0] = 0;
1281
- return true;
1282
- },
1283
- delete(id) {
1284
- return delete Store[id];
1285
- }
1286
- };
1287
- }
1288
-
1289
- // src/plugin.ts
1290
- function createPlugin(factory2) {
1291
- return (options) => {
1292
- return factory2(options);
1293
- };
1294
- }
1295
- var pluginName = "core";
1296
- var definePlugin = createPlugin((options) => {
1297
- const { fileManager, pluginManager, resolvePath, resolveName, logger } = options;
1298
- return {
1299
- name: pluginName,
1300
- options,
1301
- key: ["core"],
1302
- api() {
1303
- return {
1304
- get config() {
1305
- return options.config;
1306
- },
1307
- get plugins() {
1308
- return options.getPlugins();
1309
- },
1310
- get plugin() {
1311
- return options.plugin;
1312
- },
1313
- logger,
1314
- fileManager,
1315
- pluginManager,
1316
- async addFile(...files) {
1317
- const resolvedFiles = await fileManager.add(...files);
1318
- if (!Array.isArray(resolvedFiles)) {
1319
- return [resolvedFiles];
1320
- }
1321
- return resolvedFiles;
1322
- },
1323
- resolvePath,
1324
- resolveName,
1325
- cache: createPluginCache()
1326
- };
1327
- },
1328
- resolvePath(baseName) {
1329
- const root = path.resolve(this.config.root, this.config.output.path);
1330
- return path.resolve(root, baseName);
1331
- },
1332
- resolveName(name) {
1333
- return name;
1334
- }
1335
- };
1336
- });
1337
-
1338
- // src/PromiseManager.ts
1339
- init_esm_shims();
1340
-
1341
- // src/utils/executeStrategies.ts
1342
- init_esm_shims();
1343
- function hookSeq(promises) {
1344
- return promises.filter(Boolean).reduce(
1345
- (promise, func) => {
1346
- if (typeof func !== "function") {
1347
- throw new Error("HookSeq needs a function that returns a promise `() => Promise<unknown>`");
1348
- }
1349
- return promise.then((state) => {
1350
- const calledFunc = func(state);
1351
- if (calledFunc) {
1352
- return calledFunc.then(Array.prototype.concat.bind(state));
1353
- }
1354
- });
1355
- },
1356
- Promise.resolve([])
1357
- );
1358
- }
1359
- function hookFirst(promises, nullCheck = (state) => state !== null) {
1360
- let promise = Promise.resolve(null);
1361
- for (const func of promises.filter(Boolean)) {
1362
- promise = promise.then((state) => {
1363
- if (nullCheck(state)) {
1364
- return state;
1365
- }
1366
- const calledFunc = func(state);
1367
- return calledFunc;
1368
- });
1369
- }
1370
- return promise;
1371
- }
1372
- function hookParallel(promises) {
1373
- return Promise.allSettled(promises.filter(Boolean).map((promise) => promise()));
1374
- }
1375
-
1376
- // src/PromiseManager.ts
1377
- var _options2;
1378
- var PromiseManager = class {
1379
- constructor(options = {}) {
1380
- __privateAdd(this, _options2, {});
1381
- __privateSet(this, _options2, options);
1382
- return this;
1383
- }
1384
- run(strategy, promises) {
1385
- if (strategy === "seq") {
1386
- return hookSeq(promises);
1387
- }
1388
- if (strategy === "first") {
1389
- return hookFirst(promises, __privateGet(this, _options2).nullCheck);
1390
- }
1391
- if (strategy === "parallel") {
1392
- return hookParallel(promises);
1393
- }
1394
- throw new Error(`${strategy} not implemented`);
1395
- }
1396
- };
1397
- _options2 = new WeakMap();
1398
- function isPromise(result) {
1399
- return !!result && typeof result?.then === "function";
1400
- }
1401
- function isPromiseRejectedResult(result) {
1402
- return result.status === "rejected";
1403
- }
1404
-
1405
- // src/PluginManager.ts
1406
- var _core, _usedPluginNames, _promiseManager, _getSortedPlugins, getSortedPlugins_fn, _addExecutedToCallStack, addExecutedToCallStack_fn, _execute, execute_fn, _executeSync, executeSync_fn, _catcher, catcher_fn, _parse, parse_fn;
1407
- var PluginManager = class {
1408
- constructor(config, options) {
1409
- __privateAdd(this, _getSortedPlugins);
1410
- __privateAdd(this, _addExecutedToCallStack);
1411
- /**
1412
- * Run an async plugin hook and return the result.
1413
- * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
1414
- * @param args Arguments passed to the plugin hook.
1415
- * @param plugin The actual pluginObject to run.
1416
- */
1417
- // Implementation signature
1418
- __privateAdd(this, _execute);
1419
- /**
1420
- * Run a sync plugin hook and return the result.
1421
- * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
1422
- * @param args Arguments passed to the plugin hook.
1423
- * @param plugin The acutal plugin
1424
- * @param replaceContext When passed, the plugin context can be overridden.
1425
- */
1426
- __privateAdd(this, _executeSync);
1427
- __privateAdd(this, _catcher);
1428
- __privateAdd(this, _parse);
1429
- this.events = new EventEmitter();
1430
- this.executed = [];
1431
- __privateAdd(this, _core, void 0);
1432
- __privateAdd(this, _usedPluginNames, {});
1433
- __privateAdd(this, _promiseManager, void 0);
1434
- this.resolvePath = (params) => {
1435
- if (params.pluginKey) {
1436
- const paths = this.hookForPluginSync({
1437
- pluginKey: params.pluginKey,
1438
- hookName: "resolvePath",
1439
- parameters: [params.baseName, params.directory, params.options]
1440
- });
1441
- if (paths && paths?.length > 1 && this.logger.logLevel === LogLevel.debug) {
1442
- this.logger.debug(
1443
- `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1444
-
1445
- Paths: ${JSON.stringify(paths, void 0, 2)}
1446
-
1447
- Falling back on the first item.
1448
- `
1449
- );
1450
- }
1451
- return paths?.at(0);
1452
- }
1453
- return this.hookFirstSync({
1454
- hookName: "resolvePath",
1455
- parameters: [params.baseName, params.directory, params.options]
1456
- }).result;
1457
- };
1458
- this.resolveName = (params) => {
1459
- if (params.pluginKey) {
1460
- const names = this.hookForPluginSync({
1461
- pluginKey: params.pluginKey,
1462
- hookName: "resolveName",
1463
- parameters: [params.name, params.type]
1464
- });
1465
- if (names && names?.length > 1 && this.logger.logLevel === LogLevel.debug) {
1466
- this.logger.debug(
1467
- `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough
1468
-
1469
- Names: ${JSON.stringify(names, void 0, 2)}
1470
-
1471
- Falling back on the first item.
1472
- `
1473
- );
1474
- }
1475
- return transformReservedWord(names?.at(0) || params.name);
1476
- }
1477
- const name = this.hookFirstSync({
1478
- hookName: "resolveName",
1479
- parameters: [params.name, params.type]
1480
- }).result;
1481
- return transformReservedWord(name);
1482
- };
1483
- this.config = config;
1484
- this.logger = options.logger;
1485
- this.queue = new PQueue({ concurrency: 1 });
1486
- this.fileManager = new FileManager({ task: options.task, queue: this.queue });
1487
- __privateSet(this, _promiseManager, new PromiseManager({ nullCheck: (state) => !!state?.result }));
1488
- const plugins = config.plugins || [];
1489
- const core = definePlugin({
1490
- config,
1491
- logger: this.logger,
1492
- pluginManager: this,
1493
- fileManager: this.fileManager,
1494
- resolvePath: this.resolvePath.bind(this),
1495
- resolveName: this.resolveName.bind(this),
1496
- getPlugins: __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).bind(this)
1497
- });
1498
- __privateSet(this, _core, __privateMethod(this, _parse, parse_fn).call(this, core, this, core.api.call(null)));
1499
- this.plugins = [__privateGet(this, _core), ...plugins].map((plugin) => {
1500
- return __privateMethod(this, _parse, parse_fn).call(this, plugin, this, __privateGet(this, _core).api);
1501
- });
1502
- return this;
1503
- }
1504
- /**
1505
- * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
1506
- */
1507
- on(eventName, handler) {
1508
- this.events.on(eventName, handler);
1509
- }
1510
- /**
1511
- * Run a specific hookName for plugin x.
1512
- */
1513
- hookForPlugin({
1514
- pluginKey,
1515
- hookName,
1516
- parameters
1517
- }) {
1518
- const plugins = this.getPluginsByKey(hookName, pluginKey);
1519
- const promises = plugins.map((plugin) => {
1520
- return __privateMethod(this, _execute, execute_fn).call(this, {
1521
- strategy: "hookFirst",
1522
- hookName,
1523
- parameters,
1524
- plugin
1525
- });
1526
- }).filter(Boolean);
1527
- return Promise.all(promises);
1528
- }
1529
- /**
1530
- * Run a specific hookName for plugin x.
1531
- */
1532
- hookForPluginSync({
1533
- pluginKey,
1534
- hookName,
1535
- parameters
1536
- }) {
1537
- const plugins = this.getPluginsByKey(hookName, pluginKey);
1538
- return plugins.map((plugin) => {
1539
- return __privateMethod(this, _executeSync, executeSync_fn).call(this, {
1540
- strategy: "hookFirst",
1541
- hookName,
1542
- parameters,
1543
- plugin
1544
- });
1545
- }).filter(Boolean);
1546
- }
1547
- /**
1548
- * First non-null result stops and will return it's value.
1549
- */
1550
- async hookFirst({
1551
- hookName,
1552
- parameters,
1553
- skipped
1554
- }) {
1555
- const promises = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this).filter((plugin) => {
1556
- return skipped ? skipped.has(plugin) : true;
1557
- }).map((plugin) => {
1558
- return async () => {
1559
- const value = await __privateMethod(this, _execute, execute_fn).call(this, {
1560
- strategy: "hookFirst",
1561
- hookName,
1562
- parameters,
1563
- plugin
1564
- });
1565
- return Promise.resolve(
1566
- {
1567
- plugin,
1568
- result: value
1569
- }
1570
- );
1571
- };
1572
- });
1573
- return __privateGet(this, _promiseManager).run("first", promises);
1574
- }
1575
- /**
1576
- * First non-null result stops and will return it's value.
1577
- */
1578
- hookFirstSync({
1579
- hookName,
1580
- parameters,
1581
- skipped
1582
- }) {
1583
- let parseResult = null;
1584
- for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1585
- if (skipped && skipped.has(plugin)) {
1586
- continue;
1587
- }
1588
- parseResult = {
1589
- result: __privateMethod(this, _executeSync, executeSync_fn).call(this, {
1590
- strategy: "hookFirst",
1591
- hookName,
1592
- parameters,
1593
- plugin
1594
- }),
1595
- plugin
1596
- };
1597
- if (parseResult?.result != null) {
1598
- break;
1599
- }
1600
- }
1601
- return parseResult;
1602
- }
1603
- /**
1604
- * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
1605
- */
1606
- async hookParallel({
1607
- hookName,
1608
- parameters
1609
- }) {
1610
- const promises = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
1611
- return () => __privateMethod(this, _execute, execute_fn).call(this, { strategy: "hookParallel", hookName, parameters, plugin });
1612
- });
1613
- const results = await __privateGet(this, _promiseManager).run("parallel", promises);
1614
- results.forEach((result, index) => {
1615
- if (isPromiseRejectedResult(result)) {
1616
- const plugin = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)[index];
1617
- __privateMethod(this, _catcher, catcher_fn).call(this, result.reason, plugin, hookName);
1618
- }
1619
- });
1620
- return results.filter((result) => result.status === "fulfilled").map((result) => result.value);
1621
- }
1622
- /**
1623
- * 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.
1624
- */
1625
- hookReduceArg0({
1626
- hookName,
1627
- parameters,
1628
- reduce
1629
- }) {
1630
- const [argument0, ...rest] = parameters;
1631
- let promise = Promise.resolve(argument0);
1632
- for (const plugin of __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this)) {
1633
- promise = promise.then((arg0) => {
1634
- const value = __privateMethod(this, _execute, execute_fn).call(this, {
1635
- strategy: "hookReduceArg0",
1636
- hookName,
1637
- parameters: [arg0, ...rest],
1638
- plugin
1639
- });
1640
- return value;
1641
- }).then((result) => reduce.call(__privateGet(this, _core).api, argument0, result, plugin));
1642
- }
1643
- return promise;
1644
- }
1645
- /**
1646
- * Chains plugins
1647
- */
1648
- async hookSeq({ hookName, parameters }) {
1649
- const promises = __privateMethod(this, _getSortedPlugins, getSortedPlugins_fn).call(this).map((plugin) => {
1650
- return () => __privateMethod(this, _execute, execute_fn).call(this, {
1651
- strategy: "hookSeq",
1652
- hookName,
1653
- parameters,
1654
- plugin
1655
- });
1656
- });
1657
- return __privateGet(this, _promiseManager).run("seq", promises);
1658
- }
1659
- getPluginsByKey(hookName, pluginKey) {
1660
- const plugins = [...this.plugins];
1661
- const [searchPluginName, searchIdentifier] = pluginKey;
1662
- const pluginByPluginName = plugins.filter((plugin) => plugin[hookName]).filter((item) => {
1663
- const [name, identifier] = item.key;
1664
- const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
1665
- const nameCheck = name === searchPluginName;
1666
- if (searchIdentifier) {
1667
- return identifierCheck && nameCheck;
1668
- }
1669
- return nameCheck;
1670
- });
1671
- if (!pluginByPluginName?.length) {
1672
- const corePlugin = plugins.find((plugin) => plugin.name === "core" && plugin[hookName]);
1673
- if (this.logger.logLevel === LogLevel.debug) {
1674
- if (corePlugin) {
1675
- this.logger.debug(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`);
1676
- } else {
1677
- this.logger.debug(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`);
1678
- }
1679
- }
1680
- return corePlugin ? [corePlugin] : [];
1681
- }
1682
- return pluginByPluginName;
1683
- }
1684
- static getDependedPlugins(plugins, dependedPluginNames) {
1685
- let pluginNames = [];
1686
- if (typeof dependedPluginNames === "string") {
1687
- pluginNames = [dependedPluginNames];
1688
- } else {
1689
- pluginNames = dependedPluginNames;
1690
- }
1691
- return pluginNames.map((pluginName2) => {
1692
- const plugin = plugins.find((plugin2) => plugin2.name === pluginName2);
1693
- if (!plugin) {
1694
- throw new ValidationPluginError(`This plugin depends on the ${pluginName2} plugin.`);
1695
- }
1696
- return plugin;
1697
- });
1698
- }
1699
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
1700
- static get hooks() {
1701
- return ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
1702
- }
1703
- };
1704
- _core = new WeakMap();
1705
- _usedPluginNames = new WeakMap();
1706
- _promiseManager = new WeakMap();
1707
- _getSortedPlugins = new WeakSet();
1708
- getSortedPlugins_fn = function(hookName) {
1709
- const plugins = [...this.plugins].filter((plugin) => plugin.name !== "core");
1710
- if (hookName) {
1711
- if (this.logger.logLevel === LogLevel.info) {
1712
- const containsHookName = plugins.some((item) => item[hookName]);
1713
- if (!containsHookName) {
1714
- this.logger.warn(`No hook ${hookName} found`);
1715
- }
1716
- }
1717
- return plugins.filter((item) => item[hookName]);
1718
- }
1719
- return plugins.map((plugin) => {
1720
- if (plugin.pre) {
1721
- const isValid = plugin.pre.every((pluginName2) => plugins.find((pluginToFind) => pluginToFind.name === pluginName2));
1722
- if (!isValid) {
1723
- throw new ValidationPluginError(`This plugin has a pre set that is not valid(${JSON.stringify(plugin.pre, void 0, 2)})`);
1724
- }
1725
- }
1726
- return plugin;
1727
- }).sort((a, b) => {
1728
- if (b.pre?.includes(a.name)) {
1729
- return 1;
1730
- }
1731
- if (b.post?.includes(a.name)) {
1732
- return -1;
1733
- }
1734
- return 0;
1735
- });
1736
- };
1737
- _addExecutedToCallStack = new WeakSet();
1738
- addExecutedToCallStack_fn = function(executer) {
1739
- if (executer) {
1740
- this.events.emit("executed", executer);
1741
- this.executed.push(executer);
1742
- }
1743
- };
1744
- _execute = new WeakSet();
1745
- execute_fn = function({
1746
- strategy,
1747
- hookName,
1748
- parameters,
1749
- plugin
1750
- }) {
1751
- const hook = plugin[hookName];
1752
- let output;
1753
- if (!hook) {
1754
- return null;
1755
- }
1756
- this.events.emit("execute", { strategy, hookName, parameters, plugin });
1757
- const task = Promise.resolve().then(() => {
1758
- if (typeof hook === "function") {
1759
- const possiblePromiseResult = hook.apply({ ...__privateGet(this, _core).api, plugin }, parameters);
1760
- if (isPromise(possiblePromiseResult)) {
1761
- return Promise.resolve(possiblePromiseResult);
1762
- }
1763
- return possiblePromiseResult;
1764
- }
1765
- return hook;
1766
- }).then((result) => {
1767
- output = result;
1768
- __privateMethod(this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
1769
- parameters,
1770
- output,
1771
- strategy,
1772
- hookName,
1773
- plugin
1774
- });
1775
- return result;
1776
- }).catch((e) => {
1777
- __privateMethod(this, _catcher, catcher_fn).call(this, e, plugin, hookName);
1778
- return null;
1779
- });
1780
- return task;
1781
- };
1782
- _executeSync = new WeakSet();
1783
- executeSync_fn = function({
1784
- strategy,
1785
- hookName,
1786
- parameters,
1787
- plugin
1788
- }) {
1789
- const hook = plugin[hookName];
1790
- let output;
1791
- if (!hook) {
1792
- return null;
1793
- }
1794
- this.events.emit("execute", { strategy, hookName, parameters, plugin });
1795
- try {
1796
- if (typeof hook === "function") {
1797
- const fn = hook.apply({ ...__privateGet(this, _core).api, plugin }, parameters);
1798
- output = fn;
1799
- return fn;
1800
- }
1801
- output = hook;
1802
- __privateMethod(this, _addExecutedToCallStack, addExecutedToCallStack_fn).call(this, {
1803
- parameters,
1804
- output,
1805
- strategy,
1806
- hookName,
1807
- plugin
1808
- });
1809
- return hook;
1810
- } catch (e) {
1811
- __privateMethod(this, _catcher, catcher_fn).call(this, e, plugin, hookName);
1812
- return null;
1813
- }
1814
- };
1815
- _catcher = new WeakSet();
1816
- catcher_fn = function(e, plugin, hookName) {
1817
- const text = `${e.message} (plugin: ${plugin?.name || "unknown"}, hook: ${hookName || "unknown"})
1818
- `;
1819
- this.logger.error(text);
1820
- this.events.emit("error", e);
1821
- };
1822
- _parse = new WeakSet();
1823
- parse_fn = function(plugin, pluginManager, context) {
1824
- const usedPluginNames = __privateGet(pluginManager, _usedPluginNames);
1825
- setUniqueName(plugin.name, usedPluginNames);
1826
- const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean);
1827
- if (!plugin.transform) {
1828
- plugin.transform = function transform(code) {
1829
- return code;
1830
- };
1831
- }
1832
- if (plugin.api && typeof plugin.api === "function") {
1833
- const api = plugin.api.call(context);
1834
- return {
1835
- ...plugin,
1836
- key,
1837
- api
1838
- };
1839
- }
1840
- return {
1841
- ...plugin,
1842
- key
1843
- };
1844
- };
1845
-
1846
35
  // src/build.ts
1847
36
  async function transformReducer(_previousCode, result, _plugin) {
1848
37
  return result;
@@ -1868,11 +57,11 @@ async function setup(options) {
1868
57
  await clean(config.output.path);
1869
58
  }
1870
59
  const task = async (file) => {
1871
- const { path: path3 } = file;
60
+ const { path } = file;
1872
61
  let source = FileManager.getSource(file);
1873
62
  const { result: loadedResult } = await pluginManager.hookFirst({
1874
63
  hookName: "load",
1875
- parameters: [path3]
64
+ parameters: [path]
1876
65
  });
1877
66
  if (loadedResult && isPromise(loadedResult)) {
1878
67
  source = await loadedResult;
@@ -1883,7 +72,7 @@ async function setup(options) {
1883
72
  if (source) {
1884
73
  source = await pluginManager.hookReduceArg0({
1885
74
  hookName: "transform",
1886
- parameters: [source, path3],
75
+ parameters: [source, path],
1887
76
  reduce: transformReducer
1888
77
  });
1889
78
  if (config.output.write || config.output.write === void 0) {
@@ -1891,12 +80,12 @@ async function setup(options) {
1891
80
  await pluginManager.hookForPlugin({
1892
81
  pluginKey: file.meta?.pluginKey,
1893
82
  hookName: "writeFile",
1894
- parameters: [source, path3]
83
+ parameters: [source, path]
1895
84
  });
1896
85
  }
1897
86
  await pluginManager.hookFirst({
1898
87
  hookName: "writeFile",
1899
- parameters: [source, path3]
88
+ parameters: [source, path]
1900
89
  });
1901
90
  }
1902
91
  }
@@ -1995,35 +184,35 @@ async function safeBuild(options) {
1995
184
 
1996
185
  // src/Generator.ts
1997
186
  init_esm_shims();
1998
- var _options3, _context;
187
+ var _options, _context;
1999
188
  var Generator = class {
2000
189
  constructor(options, context) {
2001
- __privateAdd(this, _options3, {});
190
+ __privateAdd(this, _options, {});
2002
191
  __privateAdd(this, _context, {});
2003
192
  if (context) {
2004
193
  __privateSet(this, _context, context);
2005
194
  }
2006
195
  if (options) {
2007
- __privateSet(this, _options3, options);
196
+ __privateSet(this, _options, options);
2008
197
  }
2009
198
  return this;
2010
199
  }
2011
200
  get options() {
2012
- return __privateGet(this, _options3);
201
+ return __privateGet(this, _options);
2013
202
  }
2014
203
  get context() {
2015
204
  return __privateGet(this, _context);
2016
205
  }
2017
206
  set options(options) {
2018
- __privateSet(this, _options3, { ...__privateGet(this, _options3), ...options });
207
+ __privateSet(this, _options, { ...__privateGet(this, _options), ...options });
2019
208
  }
2020
209
  };
2021
- _options3 = new WeakMap();
210
+ _options = new WeakMap();
2022
211
  _context = new WeakMap();
2023
212
 
2024
213
  // src/PackageManager.ts
2025
214
  init_esm_shims();
2026
- var _cache2, _cwd, _SLASHES, _match, match_fn;
215
+ var _cache, _cwd, _SLASHES, _match, match_fn;
2027
216
  var _PackageManager = class _PackageManager {
2028
217
  constructor(workspace) {
2029
218
  __privateAdd(this, _match);
@@ -2046,17 +235,17 @@ var _PackageManager = class _PackageManager {
2046
235
  }
2047
236
  return directory;
2048
237
  }
2049
- getLocation(path3) {
2050
- let location = path3;
238
+ getLocation(path) {
239
+ let location = path;
2051
240
  if (__privateGet(this, _cwd)) {
2052
241
  const require2 = mod.createRequire(this.normalizeDirectory(__privateGet(this, _cwd)));
2053
- location = require2.resolve(path3);
242
+ location = require2.resolve(path);
2054
243
  }
2055
244
  return location;
2056
245
  }
2057
- async import(path3) {
246
+ async import(path) {
2058
247
  try {
2059
- let location = this.getLocation(path3);
248
+ let location = this.getLocation(path);
2060
249
  if (os.platform() == "win32") {
2061
250
  location = pathToFileURL(location).href;
2062
251
  }
@@ -2086,11 +275,11 @@ var _PackageManager = class _PackageManager {
2086
275
  return __require(pkgPath);
2087
276
  }
2088
277
  static setVersion(dependency, version) {
2089
- __privateGet(_PackageManager, _cache2)[dependency] = version;
278
+ __privateGet(_PackageManager, _cache)[dependency] = version;
2090
279
  }
2091
280
  async getVersion(dependency) {
2092
- if (typeof dependency === "string" && __privateGet(_PackageManager, _cache2)[dependency]) {
2093
- return __privateGet(_PackageManager, _cache2)[dependency];
281
+ if (typeof dependency === "string" && __privateGet(_PackageManager, _cache)[dependency]) {
282
+ return __privateGet(_PackageManager, _cache)[dependency];
2094
283
  }
2095
284
  const packageJSON = await this.getPackageJSON();
2096
285
  if (!packageJSON) {
@@ -2099,8 +288,8 @@ var _PackageManager = class _PackageManager {
2099
288
  return __privateMethod(this, _match, match_fn).call(this, packageJSON, dependency);
2100
289
  }
2101
290
  getVersionSync(dependency) {
2102
- if (typeof dependency === "string" && __privateGet(_PackageManager, _cache2)[dependency]) {
2103
- return __privateGet(_PackageManager, _cache2)[dependency];
291
+ if (typeof dependency === "string" && __privateGet(_PackageManager, _cache)[dependency]) {
292
+ return __privateGet(_PackageManager, _cache)[dependency];
2104
293
  }
2105
294
  const packageJSON = this.getPackageJSONSync();
2106
295
  if (!packageJSON) {
@@ -2134,7 +323,7 @@ var _PackageManager = class _PackageManager {
2134
323
  return satisfies(semVer, version);
2135
324
  }
2136
325
  };
2137
- _cache2 = new WeakMap();
326
+ _cache = new WeakMap();
2138
327
  _cwd = new WeakMap();
2139
328
  _SLASHES = new WeakMap();
2140
329
  _match = new WeakSet();
@@ -2149,12 +338,12 @@ match_fn = function(packageJSON, dependency) {
2149
338
  const matchedDependency = Object.keys(dependencies).find((dep) => dep.match(dependency));
2150
339
  return matchedDependency ? dependencies[matchedDependency] : void 0;
2151
340
  };
2152
- __privateAdd(_PackageManager, _cache2, {});
341
+ __privateAdd(_PackageManager, _cache, {});
2153
342
  var PackageManager = _PackageManager;
2154
343
 
2155
344
  // src/index.ts
2156
345
  var src_default = build;
2157
346
 
2158
- export { FileManager, Generator, KubbFile, PackageManager, PluginManager, PromiseManager, Warning, build, createPlugin, src_default as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
347
+ export { Generator, PackageManager, build, src_default as default, defineConfig, isInputPath, safeBuild };
2159
348
  //# sourceMappingURL=out.js.map
2160
349
  //# sourceMappingURL=index.js.map