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