@midscene/cli 1.8.10-beta-20260604215059.0 → 1.9.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/es/framework/index.mjs +21 -2
- package/dist/es/framework/index.mjs.map +1 -1
- package/dist/es/index.mjs +783 -1115
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +21 -2
- package/dist/lib/framework/index.js.map +1 -1
- package/dist/lib/index.js +783 -1115
- package/dist/lib/index.js.map +1 -1
- package/package.json +8 -7
package/dist/es/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { createReportCliCommands } from "@midscene/core";
|
|
|
4
4
|
import { runToolsCLI } from "@midscene/shared/cli";
|
|
5
5
|
import { getDebug } from "@midscene/shared/logger";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
-
import { channel, tracingChannel } from "node:diagnostics_channel";
|
|
8
7
|
import { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
9
8
|
import { EventEmitter } from "node:events";
|
|
10
9
|
import node_stream from "node:stream";
|
|
@@ -3027,7 +3026,9 @@ var __webpack_modules__ = {
|
|
|
3027
3026
|
"./src/index.ts" (__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
3028
3027
|
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
3029
3028
|
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
3030
|
-
var package_namespaceObject =
|
|
3029
|
+
var package_namespaceObject = {
|
|
3030
|
+
rE: "1.9.0"
|
|
3031
|
+
};
|
|
3031
3032
|
var brace_expansion = __webpack_require__("../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js");
|
|
3032
3033
|
const MAX_PATTERN_LENGTH = 65536;
|
|
3033
3034
|
const assertValidPattern = (pattern)=>{
|
|
@@ -4162,46 +4163,85 @@ var __webpack_modules__ = {
|
|
|
4162
4163
|
minimatch.Minimatch = esm_Minimatch;
|
|
4163
4164
|
minimatch.escape = escape_escape;
|
|
4164
4165
|
minimatch.unescape = unescape_unescape;
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4166
|
+
const perf = 'object' == typeof performance && performance && 'function' == typeof performance.now ? performance : Date;
|
|
4167
|
+
const warned = new Set();
|
|
4168
|
+
const PROCESS = 'object' == typeof process && process ? process : {};
|
|
4169
|
+
const emitWarning = (msg, type, code, fn)=>{
|
|
4170
|
+
'function' == typeof PROCESS.emitWarning ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
4171
|
+
};
|
|
4172
|
+
let AC = globalThis.AbortController;
|
|
4173
|
+
let AS = globalThis.AbortSignal;
|
|
4174
|
+
if (void 0 === AC) {
|
|
4175
|
+
AS = class {
|
|
4176
|
+
onabort;
|
|
4177
|
+
_onabort = [];
|
|
4178
|
+
reason;
|
|
4179
|
+
aborted = false;
|
|
4180
|
+
addEventListener(_, fn) {
|
|
4181
|
+
this._onabort.push(fn);
|
|
4182
|
+
}
|
|
4183
|
+
};
|
|
4184
|
+
AC = class {
|
|
4185
|
+
constructor(){
|
|
4186
|
+
warnACPolyfill();
|
|
4187
|
+
}
|
|
4188
|
+
signal = new AS();
|
|
4189
|
+
abort(reason) {
|
|
4190
|
+
if (this.signal.aborted) return;
|
|
4191
|
+
this.signal.reason = reason;
|
|
4192
|
+
this.signal.aborted = true;
|
|
4193
|
+
for (const fn of this.signal._onabort)fn(reason);
|
|
4194
|
+
this.signal.onabort?.(reason);
|
|
4195
|
+
}
|
|
4196
|
+
};
|
|
4197
|
+
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
4198
|
+
const warnACPolyfill = ()=>{
|
|
4199
|
+
if (!printACPolyfillWarning) return;
|
|
4200
|
+
printACPolyfillWarning = false;
|
|
4201
|
+
emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
|
|
4202
|
+
};
|
|
4203
|
+
}
|
|
4204
|
+
const shouldWarn = (code)=>!warned.has(code);
|
|
4205
|
+
Symbol('type');
|
|
4206
|
+
const isPosInt = (n)=>n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
4207
|
+
const getUintArray = (max)=>isPosInt(max) ? max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null : null;
|
|
4208
|
+
class ZeroArray extends Array {
|
|
4209
|
+
constructor(size){
|
|
4210
|
+
super(size);
|
|
4211
|
+
this.fill(0);
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
class Stack {
|
|
4173
4215
|
heap;
|
|
4174
4216
|
length;
|
|
4175
|
-
static #
|
|
4176
|
-
static create(
|
|
4177
|
-
|
|
4178
|
-
if (!
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4217
|
+
static #constructing = false;
|
|
4218
|
+
static create(max) {
|
|
4219
|
+
const HeapCls = getUintArray(max);
|
|
4220
|
+
if (!HeapCls) return [];
|
|
4221
|
+
Stack.#constructing = true;
|
|
4222
|
+
const s = new Stack(max, HeapCls);
|
|
4223
|
+
Stack.#constructing = false;
|
|
4224
|
+
return s;
|
|
4225
|
+
}
|
|
4226
|
+
constructor(max, HeapCls){
|
|
4227
|
+
if (!Stack.#constructing) throw new TypeError('instantiate Stack using Stack.create(n)');
|
|
4228
|
+
this.heap = new HeapCls(max);
|
|
4229
|
+
this.length = 0;
|
|
4230
|
+
}
|
|
4231
|
+
push(n) {
|
|
4232
|
+
this.heap[this.length++] = n;
|
|
4189
4233
|
}
|
|
4190
4234
|
pop() {
|
|
4191
4235
|
return this.heap[--this.length];
|
|
4192
4236
|
}
|
|
4193
|
-
}
|
|
4194
|
-
|
|
4195
|
-
#
|
|
4196
|
-
#
|
|
4197
|
-
#
|
|
4198
|
-
#
|
|
4199
|
-
#
|
|
4200
|
-
#
|
|
4201
|
-
#m;
|
|
4202
|
-
get perf() {
|
|
4203
|
-
return this.#m;
|
|
4204
|
-
}
|
|
4237
|
+
}
|
|
4238
|
+
class LRUCache {
|
|
4239
|
+
#max;
|
|
4240
|
+
#maxSize;
|
|
4241
|
+
#dispose;
|
|
4242
|
+
#disposeAfter;
|
|
4243
|
+
#fetchMethod;
|
|
4244
|
+
#memoMethod;
|
|
4205
4245
|
ttl;
|
|
4206
4246
|
ttlResolution;
|
|
4207
4247
|
ttlAutopurge;
|
|
@@ -4217,613 +4257,823 @@ var __webpack_modules__ = {
|
|
|
4217
4257
|
allowStaleOnFetchAbort;
|
|
4218
4258
|
allowStaleOnFetchRejection;
|
|
4219
4259
|
ignoreFetchAbort;
|
|
4220
|
-
#
|
|
4221
|
-
#
|
|
4222
|
-
#
|
|
4223
|
-
#
|
|
4224
|
-
#
|
|
4225
|
-
#
|
|
4226
|
-
#
|
|
4227
|
-
#
|
|
4228
|
-
#
|
|
4229
|
-
#
|
|
4230
|
-
#
|
|
4231
|
-
#
|
|
4232
|
-
#
|
|
4233
|
-
#
|
|
4234
|
-
#
|
|
4235
|
-
#
|
|
4236
|
-
#
|
|
4237
|
-
|
|
4238
|
-
#j;
|
|
4239
|
-
static unsafeExposeInternals(e1) {
|
|
4260
|
+
#size;
|
|
4261
|
+
#calculatedSize;
|
|
4262
|
+
#keyMap;
|
|
4263
|
+
#keyList;
|
|
4264
|
+
#valList;
|
|
4265
|
+
#next;
|
|
4266
|
+
#prev;
|
|
4267
|
+
#head;
|
|
4268
|
+
#tail;
|
|
4269
|
+
#free;
|
|
4270
|
+
#disposed;
|
|
4271
|
+
#sizes;
|
|
4272
|
+
#starts;
|
|
4273
|
+
#ttls;
|
|
4274
|
+
#hasDispose;
|
|
4275
|
+
#hasFetchMethod;
|
|
4276
|
+
#hasDisposeAfter;
|
|
4277
|
+
static unsafeExposeInternals(c) {
|
|
4240
4278
|
return {
|
|
4241
|
-
starts:
|
|
4242
|
-
ttls:
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
prev: e1.#c,
|
|
4279
|
+
starts: c.#starts,
|
|
4280
|
+
ttls: c.#ttls,
|
|
4281
|
+
sizes: c.#sizes,
|
|
4282
|
+
keyMap: c.#keyMap,
|
|
4283
|
+
keyList: c.#keyList,
|
|
4284
|
+
valList: c.#valList,
|
|
4285
|
+
next: c.#next,
|
|
4286
|
+
prev: c.#prev,
|
|
4250
4287
|
get head () {
|
|
4251
|
-
return
|
|
4288
|
+
return c.#head;
|
|
4252
4289
|
},
|
|
4253
4290
|
get tail () {
|
|
4254
|
-
return
|
|
4291
|
+
return c.#tail;
|
|
4255
4292
|
},
|
|
4256
|
-
free:
|
|
4257
|
-
isBackgroundFetch: (
|
|
4258
|
-
backgroundFetch: (
|
|
4259
|
-
moveToTail: (
|
|
4260
|
-
indexes: (
|
|
4261
|
-
rindexes: (
|
|
4262
|
-
isStale: (
|
|
4293
|
+
free: c.#free,
|
|
4294
|
+
isBackgroundFetch: (p)=>c.#isBackgroundFetch(p),
|
|
4295
|
+
backgroundFetch: (k, index, options, context)=>c.#backgroundFetch(k, index, options, context),
|
|
4296
|
+
moveToTail: (index)=>c.#moveToTail(index),
|
|
4297
|
+
indexes: (options)=>c.#indexes(options),
|
|
4298
|
+
rindexes: (options)=>c.#rindexes(options),
|
|
4299
|
+
isStale: (index)=>c.#isStale(index)
|
|
4263
4300
|
};
|
|
4264
4301
|
}
|
|
4265
4302
|
get max() {
|
|
4266
|
-
return this.#
|
|
4303
|
+
return this.#max;
|
|
4267
4304
|
}
|
|
4268
4305
|
get maxSize() {
|
|
4269
|
-
return this.#
|
|
4306
|
+
return this.#maxSize;
|
|
4270
4307
|
}
|
|
4271
4308
|
get calculatedSize() {
|
|
4272
|
-
return this.#
|
|
4309
|
+
return this.#calculatedSize;
|
|
4273
4310
|
}
|
|
4274
4311
|
get size() {
|
|
4275
|
-
return this.#
|
|
4312
|
+
return this.#size;
|
|
4276
4313
|
}
|
|
4277
4314
|
get fetchMethod() {
|
|
4278
|
-
return this.#
|
|
4315
|
+
return this.#fetchMethod;
|
|
4279
4316
|
}
|
|
4280
4317
|
get memoMethod() {
|
|
4281
|
-
return this.#
|
|
4318
|
+
return this.#memoMethod;
|
|
4282
4319
|
}
|
|
4283
4320
|
get dispose() {
|
|
4284
|
-
return this.#
|
|
4285
|
-
}
|
|
4286
|
-
get onInsert() {
|
|
4287
|
-
return this.#D;
|
|
4321
|
+
return this.#dispose;
|
|
4288
4322
|
}
|
|
4289
4323
|
get disposeAfter() {
|
|
4290
|
-
return this.#
|
|
4291
|
-
}
|
|
4292
|
-
constructor(
|
|
4293
|
-
|
|
4294
|
-
if (
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
this.#
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
this
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4324
|
+
return this.#disposeAfter;
|
|
4325
|
+
}
|
|
4326
|
+
constructor(options){
|
|
4327
|
+
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
|
|
4328
|
+
if (0 !== max && !isPosInt(max)) throw new TypeError('max option must be a nonnegative integer');
|
|
4329
|
+
const UintArray = max ? getUintArray(max) : Array;
|
|
4330
|
+
if (!UintArray) throw new Error('invalid max value: ' + max);
|
|
4331
|
+
this.#max = max;
|
|
4332
|
+
this.#maxSize = maxSize;
|
|
4333
|
+
this.maxEntrySize = maxEntrySize || this.#maxSize;
|
|
4334
|
+
this.sizeCalculation = sizeCalculation;
|
|
4335
|
+
if (this.sizeCalculation) {
|
|
4336
|
+
if (!this.#maxSize && !this.maxEntrySize) throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
|
|
4337
|
+
if ('function' != typeof this.sizeCalculation) throw new TypeError('sizeCalculation set to non-function');
|
|
4338
|
+
}
|
|
4339
|
+
if (void 0 !== memoMethod && 'function' != typeof memoMethod) throw new TypeError('memoMethod must be a function if defined');
|
|
4340
|
+
this.#memoMethod = memoMethod;
|
|
4341
|
+
if (void 0 !== fetchMethod && 'function' != typeof fetchMethod) throw new TypeError('fetchMethod must be a function if specified');
|
|
4342
|
+
this.#fetchMethod = fetchMethod;
|
|
4343
|
+
this.#hasFetchMethod = !!fetchMethod;
|
|
4344
|
+
this.#keyMap = new Map();
|
|
4345
|
+
this.#keyList = new Array(max).fill(void 0);
|
|
4346
|
+
this.#valList = new Array(max).fill(void 0);
|
|
4347
|
+
this.#next = new UintArray(max);
|
|
4348
|
+
this.#prev = new UintArray(max);
|
|
4349
|
+
this.#head = 0;
|
|
4350
|
+
this.#tail = 0;
|
|
4351
|
+
this.#free = Stack.create(max);
|
|
4352
|
+
this.#size = 0;
|
|
4353
|
+
this.#calculatedSize = 0;
|
|
4354
|
+
if ('function' == typeof dispose) this.#dispose = dispose;
|
|
4355
|
+
if ('function' == typeof disposeAfter) {
|
|
4356
|
+
this.#disposeAfter = disposeAfter;
|
|
4357
|
+
this.#disposed = [];
|
|
4358
|
+
} else {
|
|
4359
|
+
this.#disposeAfter = void 0;
|
|
4360
|
+
this.#disposed = void 0;
|
|
4361
|
+
}
|
|
4362
|
+
this.#hasDispose = !!this.#dispose;
|
|
4363
|
+
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
4364
|
+
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
4365
|
+
this.noUpdateTTL = !!noUpdateTTL;
|
|
4366
|
+
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
|
|
4367
|
+
this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
|
|
4368
|
+
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
|
|
4369
|
+
this.ignoreFetchAbort = !!ignoreFetchAbort;
|
|
4370
|
+
if (0 !== this.maxEntrySize) {
|
|
4371
|
+
if (0 !== this.#maxSize) {
|
|
4372
|
+
if (!isPosInt(this.#maxSize)) throw new TypeError('maxSize must be a positive integer if specified');
|
|
4373
|
+
}
|
|
4374
|
+
if (!isPosInt(this.maxEntrySize)) throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
4375
|
+
this.#initializeSizeTracking();
|
|
4376
|
+
}
|
|
4377
|
+
this.allowStale = !!allowStale;
|
|
4378
|
+
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
4379
|
+
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
4380
|
+
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
4381
|
+
this.ttlResolution = isPosInt(ttlResolution) || 0 === ttlResolution ? ttlResolution : 1;
|
|
4382
|
+
this.ttlAutopurge = !!ttlAutopurge;
|
|
4383
|
+
this.ttl = ttl || 0;
|
|
4384
|
+
if (this.ttl) {
|
|
4385
|
+
if (!isPosInt(this.ttl)) throw new TypeError('ttl must be a positive integer if specified');
|
|
4386
|
+
this.#initializeTTLTracking();
|
|
4387
|
+
}
|
|
4388
|
+
if (0 === this.#max && 0 === this.ttl && 0 === this.#maxSize) throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
4389
|
+
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
4390
|
+
const code = 'LRU_CACHE_UNBOUNDED';
|
|
4391
|
+
if (shouldWarn(code)) {
|
|
4392
|
+
warned.add(code);
|
|
4393
|
+
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
4394
|
+
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
|
|
4395
|
+
}
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4398
|
+
getRemainingTTL(key) {
|
|
4399
|
+
return this.#keyMap.has(key) ? 1 / 0 : 0;
|
|
4400
|
+
}
|
|
4401
|
+
#initializeTTLTracking() {
|
|
4402
|
+
const ttls = new ZeroArray(this.#max);
|
|
4403
|
+
const starts = new ZeroArray(this.#max);
|
|
4404
|
+
this.#ttls = ttls;
|
|
4405
|
+
this.#starts = starts;
|
|
4406
|
+
this.#setItemTTL = (index, ttl, start = perf.now())=>{
|
|
4407
|
+
starts[index] = 0 !== ttl ? start : 0;
|
|
4408
|
+
ttls[index] = ttl;
|
|
4409
|
+
if (0 !== ttl && this.ttlAutopurge) {
|
|
4410
|
+
const t1 = setTimeout(()=>{
|
|
4411
|
+
if (this.#isStale(index)) this.#delete(this.#keyList[index], 'expire');
|
|
4412
|
+
}, ttl + 1);
|
|
4413
|
+
if (t1.unref) t1.unref();
|
|
4414
|
+
}
|
|
4336
4415
|
};
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
let f = r.now - c;
|
|
4351
|
-
r.remainingTTL = l - f;
|
|
4416
|
+
this.#updateItemAge = (index)=>{
|
|
4417
|
+
starts[index] = 0 !== ttls[index] ? perf.now() : 0;
|
|
4418
|
+
};
|
|
4419
|
+
this.#statusTTL = (status, index)=>{
|
|
4420
|
+
if (ttls[index]) {
|
|
4421
|
+
const ttl = ttls[index];
|
|
4422
|
+
const start = starts[index];
|
|
4423
|
+
if (!ttl || !start) return;
|
|
4424
|
+
status.ttl = ttl;
|
|
4425
|
+
status.start = start;
|
|
4426
|
+
status.now = cachedNow || getNow();
|
|
4427
|
+
const age = status.now - start;
|
|
4428
|
+
status.remainingTTL = ttl - age;
|
|
4352
4429
|
}
|
|
4353
4430
|
};
|
|
4354
|
-
let
|
|
4355
|
-
|
|
4431
|
+
let cachedNow = 0;
|
|
4432
|
+
const getNow = ()=>{
|
|
4433
|
+
const n = perf.now();
|
|
4356
4434
|
if (this.ttlResolution > 0) {
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4435
|
+
cachedNow = n;
|
|
4436
|
+
const t1 = setTimeout(()=>cachedNow = 0, this.ttlResolution);
|
|
4437
|
+
if (t1.unref) t1.unref();
|
|
4360
4438
|
}
|
|
4361
|
-
return
|
|
4439
|
+
return n;
|
|
4440
|
+
};
|
|
4441
|
+
this.getRemainingTTL = (key)=>{
|
|
4442
|
+
const index = this.#keyMap.get(key);
|
|
4443
|
+
if (void 0 === index) return 0;
|
|
4444
|
+
const ttl = ttls[index];
|
|
4445
|
+
const start = starts[index];
|
|
4446
|
+
if (!ttl || !start) return 1 / 0;
|
|
4447
|
+
const age = (cachedNow || getNow()) - start;
|
|
4448
|
+
return ttl - age;
|
|
4362
4449
|
};
|
|
4363
|
-
this
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
if (!l || !c) return 1 / 0;
|
|
4368
|
-
let f = (n || o()) - c;
|
|
4369
|
-
return l - f;
|
|
4370
|
-
}, this.#p = (r)=>{
|
|
4371
|
-
let h = t1[r], l = e1[r];
|
|
4372
|
-
return !!l && !!h && (n || o()) - h > l;
|
|
4450
|
+
this.#isStale = (index)=>{
|
|
4451
|
+
const s = starts[index];
|
|
4452
|
+
const t1 = ttls[index];
|
|
4453
|
+
return !!t1 && !!s && (cachedNow || getNow()) - s > t1;
|
|
4373
4454
|
};
|
|
4374
4455
|
}
|
|
4375
|
-
#
|
|
4376
|
-
#
|
|
4377
|
-
#
|
|
4378
|
-
#
|
|
4379
|
-
#
|
|
4380
|
-
|
|
4381
|
-
this.#
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4456
|
+
#updateItemAge = ()=>{};
|
|
4457
|
+
#statusTTL = ()=>{};
|
|
4458
|
+
#setItemTTL = ()=>{};
|
|
4459
|
+
#isStale = ()=>false;
|
|
4460
|
+
#initializeSizeTracking() {
|
|
4461
|
+
const sizes = new ZeroArray(this.#max);
|
|
4462
|
+
this.#calculatedSize = 0;
|
|
4463
|
+
this.#sizes = sizes;
|
|
4464
|
+
this.#removeItemSize = (index)=>{
|
|
4465
|
+
this.#calculatedSize -= sizes[index];
|
|
4466
|
+
sizes[index] = 0;
|
|
4467
|
+
};
|
|
4468
|
+
this.#requireSize = (k, v, size, sizeCalculation)=>{
|
|
4469
|
+
if (this.#isBackgroundFetch(v)) return 0;
|
|
4470
|
+
if (!isPosInt(size)) if (sizeCalculation) {
|
|
4471
|
+
if ('function' != typeof sizeCalculation) throw new TypeError('sizeCalculation must be a function');
|
|
4472
|
+
size = sizeCalculation(v, k);
|
|
4473
|
+
if (!isPosInt(size)) throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
4388
4474
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
4389
|
-
return
|
|
4390
|
-
}
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4475
|
+
return size;
|
|
4476
|
+
};
|
|
4477
|
+
this.#addItemSize = (index, size, status)=>{
|
|
4478
|
+
sizes[index] = size;
|
|
4479
|
+
if (this.#maxSize) {
|
|
4480
|
+
const maxSize = this.#maxSize - sizes[index];
|
|
4481
|
+
while(this.#calculatedSize > maxSize)this.#evict(true);
|
|
4482
|
+
}
|
|
4483
|
+
this.#calculatedSize += sizes[index];
|
|
4484
|
+
if (status) {
|
|
4485
|
+
status.entrySize = size;
|
|
4486
|
+
status.totalCalculatedSize = this.#calculatedSize;
|
|
4394
4487
|
}
|
|
4395
|
-
this.#b += e1[t1], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
4396
4488
|
};
|
|
4397
4489
|
}
|
|
4398
|
-
#
|
|
4399
|
-
#
|
|
4400
|
-
#
|
|
4401
|
-
if (
|
|
4490
|
+
#removeItemSize = (_i)=>{};
|
|
4491
|
+
#addItemSize = (_i, _s, _st)=>{};
|
|
4492
|
+
#requireSize = (_k, _v, size, sizeCalculation)=>{
|
|
4493
|
+
if (size || sizeCalculation) throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
|
|
4402
4494
|
return 0;
|
|
4403
4495
|
};
|
|
4404
|
-
*#
|
|
4405
|
-
if (this.#
|
|
4496
|
+
*#indexes({ allowStale = this.allowStale } = {}) {
|
|
4497
|
+
if (this.#size) for(let i = this.#tail; true;){
|
|
4498
|
+
if (!this.#isValidIndex(i)) break;
|
|
4499
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
4500
|
+
if (i === this.#head) break;
|
|
4501
|
+
i = this.#prev[i];
|
|
4502
|
+
}
|
|
4406
4503
|
}
|
|
4407
|
-
*#
|
|
4408
|
-
if (this.#
|
|
4504
|
+
*#rindexes({ allowStale = this.allowStale } = {}) {
|
|
4505
|
+
if (this.#size) for(let i = this.#head; true;){
|
|
4506
|
+
if (!this.#isValidIndex(i)) break;
|
|
4507
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
4508
|
+
if (i === this.#tail) break;
|
|
4509
|
+
i = this.#next[i];
|
|
4510
|
+
}
|
|
4409
4511
|
}
|
|
4410
|
-
#
|
|
4411
|
-
return void 0 !==
|
|
4512
|
+
#isValidIndex(index) {
|
|
4513
|
+
return void 0 !== index && this.#keyMap.get(this.#keyList[index]) === index;
|
|
4412
4514
|
}
|
|
4413
4515
|
*entries() {
|
|
4414
|
-
for (
|
|
4415
|
-
this.#i
|
|
4416
|
-
this.#
|
|
4417
|
-
]
|
|
4516
|
+
for (const i of this.#indexes())if (void 0 !== this.#valList[i] && void 0 !== this.#keyList[i] && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
4517
|
+
this.#keyList[i],
|
|
4518
|
+
this.#valList[i]
|
|
4519
|
+
];
|
|
4418
4520
|
}
|
|
4419
4521
|
*rentries() {
|
|
4420
|
-
for (
|
|
4421
|
-
this.#i
|
|
4422
|
-
this.#
|
|
4423
|
-
]
|
|
4522
|
+
for (const i of this.#rindexes())if (void 0 !== this.#valList[i] && void 0 !== this.#keyList[i] && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
4523
|
+
this.#keyList[i],
|
|
4524
|
+
this.#valList[i]
|
|
4525
|
+
];
|
|
4424
4526
|
}
|
|
4425
4527
|
*keys() {
|
|
4426
|
-
for (
|
|
4427
|
-
|
|
4428
|
-
void 0
|
|
4528
|
+
for (const i of this.#indexes()){
|
|
4529
|
+
const k = this.#keyList[i];
|
|
4530
|
+
if (void 0 !== k && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
4429
4531
|
}
|
|
4430
4532
|
}
|
|
4431
4533
|
*rkeys() {
|
|
4432
|
-
for (
|
|
4433
|
-
|
|
4434
|
-
void 0
|
|
4534
|
+
for (const i of this.#rindexes()){
|
|
4535
|
+
const k = this.#keyList[i];
|
|
4536
|
+
if (void 0 !== k && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
4435
4537
|
}
|
|
4436
4538
|
}
|
|
4437
4539
|
*values() {
|
|
4438
|
-
for (
|
|
4540
|
+
for (const i of this.#indexes()){
|
|
4541
|
+
const v = this.#valList[i];
|
|
4542
|
+
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
4543
|
+
}
|
|
4439
4544
|
}
|
|
4440
4545
|
*rvalues() {
|
|
4441
|
-
for (
|
|
4546
|
+
for (const i of this.#rindexes()){
|
|
4547
|
+
const v = this.#valList[i];
|
|
4548
|
+
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
4549
|
+
}
|
|
4442
4550
|
}
|
|
4443
4551
|
[Symbol.iterator]() {
|
|
4444
4552
|
return this.entries();
|
|
4445
4553
|
}
|
|
4446
|
-
[Symbol.toStringTag] =
|
|
4447
|
-
find(
|
|
4448
|
-
for (
|
|
4449
|
-
|
|
4450
|
-
|
|
4554
|
+
[Symbol.toStringTag] = 'LRUCache';
|
|
4555
|
+
find(fn, getOptions = {}) {
|
|
4556
|
+
for (const i of this.#indexes()){
|
|
4557
|
+
const v = this.#valList[i];
|
|
4558
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4559
|
+
if (void 0 !== value) {
|
|
4560
|
+
if (fn(value, this.#keyList[i], this)) return this.get(this.#keyList[i], getOptions);
|
|
4561
|
+
}
|
|
4451
4562
|
}
|
|
4452
4563
|
}
|
|
4453
|
-
forEach(
|
|
4454
|
-
for (
|
|
4455
|
-
|
|
4456
|
-
|
|
4564
|
+
forEach(fn, thisp = this) {
|
|
4565
|
+
for (const i of this.#indexes()){
|
|
4566
|
+
const v = this.#valList[i];
|
|
4567
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4568
|
+
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
4457
4569
|
}
|
|
4458
4570
|
}
|
|
4459
|
-
rforEach(
|
|
4460
|
-
for (
|
|
4461
|
-
|
|
4462
|
-
|
|
4571
|
+
rforEach(fn, thisp = this) {
|
|
4572
|
+
for (const i of this.#rindexes()){
|
|
4573
|
+
const v = this.#valList[i];
|
|
4574
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4575
|
+
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
4463
4576
|
}
|
|
4464
4577
|
}
|
|
4465
4578
|
purgeStale() {
|
|
4466
|
-
let
|
|
4467
|
-
for (
|
|
4468
|
-
allowStale:
|
|
4469
|
-
}))
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4579
|
+
let deleted = false;
|
|
4580
|
+
for (const i of this.#rindexes({
|
|
4581
|
+
allowStale: true
|
|
4582
|
+
}))if (this.#isStale(i)) {
|
|
4583
|
+
this.#delete(this.#keyList[i], 'expire');
|
|
4584
|
+
deleted = true;
|
|
4585
|
+
}
|
|
4586
|
+
return deleted;
|
|
4587
|
+
}
|
|
4588
|
+
info(key) {
|
|
4589
|
+
const i = this.#keyMap.get(key);
|
|
4590
|
+
if (void 0 === i) return;
|
|
4591
|
+
const v = this.#valList[i];
|
|
4592
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4593
|
+
if (void 0 === value) return;
|
|
4594
|
+
const entry = {
|
|
4595
|
+
value
|
|
4479
4596
|
};
|
|
4480
|
-
if (this.#
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4597
|
+
if (this.#ttls && this.#starts) {
|
|
4598
|
+
const ttl = this.#ttls[i];
|
|
4599
|
+
const start = this.#starts[i];
|
|
4600
|
+
if (ttl && start) {
|
|
4601
|
+
const remain = ttl - (perf.now() - start);
|
|
4602
|
+
entry.ttl = remain;
|
|
4603
|
+
entry.start = Date.now();
|
|
4485
4604
|
}
|
|
4486
4605
|
}
|
|
4487
|
-
|
|
4606
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4607
|
+
return entry;
|
|
4488
4608
|
}
|
|
4489
4609
|
dump() {
|
|
4490
|
-
|
|
4491
|
-
for (
|
|
4492
|
-
allowStale:
|
|
4610
|
+
const arr = [];
|
|
4611
|
+
for (const i of this.#indexes({
|
|
4612
|
+
allowStale: true
|
|
4493
4613
|
})){
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4614
|
+
const key = this.#keyList[i];
|
|
4615
|
+
const v = this.#valList[i];
|
|
4616
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4617
|
+
if (void 0 === value || void 0 === key) continue;
|
|
4618
|
+
const entry = {
|
|
4619
|
+
value
|
|
4498
4620
|
};
|
|
4499
|
-
if (this.#
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
}
|
|
4504
|
-
this.#
|
|
4505
|
-
|
|
4506
|
-
|
|
4621
|
+
if (this.#ttls && this.#starts) {
|
|
4622
|
+
entry.ttl = this.#ttls[i];
|
|
4623
|
+
const age = perf.now() - this.#starts[i];
|
|
4624
|
+
entry.start = Math.floor(Date.now() - age);
|
|
4625
|
+
}
|
|
4626
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4627
|
+
arr.unshift([
|
|
4628
|
+
key,
|
|
4629
|
+
entry
|
|
4507
4630
|
]);
|
|
4508
4631
|
}
|
|
4509
|
-
return
|
|
4632
|
+
return arr;
|
|
4510
4633
|
}
|
|
4511
|
-
load(
|
|
4634
|
+
load(arr) {
|
|
4512
4635
|
this.clear();
|
|
4513
|
-
for (
|
|
4514
|
-
if (
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
}
|
|
4518
|
-
this
|
|
4519
|
-
}
|
|
4520
|
-
}
|
|
4521
|
-
set(
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
if (
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4636
|
+
for (const [key, entry] of arr){
|
|
4637
|
+
if (entry.start) {
|
|
4638
|
+
const age = Date.now() - entry.start;
|
|
4639
|
+
entry.start = perf.now() - age;
|
|
4640
|
+
}
|
|
4641
|
+
this.set(key, entry.value, entry);
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4644
|
+
set(k, v, setOptions = {}) {
|
|
4645
|
+
if (void 0 === v) {
|
|
4646
|
+
this.delete(k);
|
|
4647
|
+
return this;
|
|
4648
|
+
}
|
|
4649
|
+
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
|
|
4650
|
+
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
4651
|
+
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
4652
|
+
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
4653
|
+
if (status) {
|
|
4654
|
+
status.set = 'miss';
|
|
4655
|
+
status.maxEntrySizeExceeded = true;
|
|
4656
|
+
}
|
|
4657
|
+
this.#delete(k, 'set');
|
|
4658
|
+
return this;
|
|
4659
|
+
}
|
|
4660
|
+
let index = 0 === this.#size ? void 0 : this.#keyMap.get(k);
|
|
4661
|
+
if (void 0 === index) {
|
|
4662
|
+
index = 0 === this.#size ? this.#tail : 0 !== this.#free.length ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
|
|
4663
|
+
this.#keyList[index] = k;
|
|
4664
|
+
this.#valList[index] = v;
|
|
4665
|
+
this.#keyMap.set(k, index);
|
|
4666
|
+
this.#next[this.#tail] = index;
|
|
4667
|
+
this.#prev[index] = this.#tail;
|
|
4668
|
+
this.#tail = index;
|
|
4669
|
+
this.#size++;
|
|
4670
|
+
this.#addItemSize(index, size, status);
|
|
4671
|
+
if (status) status.set = 'add';
|
|
4672
|
+
noUpdateTTL = false;
|
|
4673
|
+
} else {
|
|
4674
|
+
this.#moveToTail(index);
|
|
4675
|
+
const oldVal = this.#valList[index];
|
|
4676
|
+
if (v !== oldVal) {
|
|
4677
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
|
4678
|
+
oldVal.__abortController.abort(new Error('replaced'));
|
|
4679
|
+
const { __staleWhileFetching: s } = oldVal;
|
|
4680
|
+
if (void 0 !== s && !noDisposeOnSet) {
|
|
4681
|
+
if (this.#hasDispose) this.#dispose?.(s, k, 'set');
|
|
4682
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
4683
|
+
s,
|
|
4684
|
+
k,
|
|
4685
|
+
'set'
|
|
4686
|
+
]);
|
|
4687
|
+
}
|
|
4688
|
+
} else if (!noDisposeOnSet) {
|
|
4689
|
+
if (this.#hasDispose) this.#dispose?.(oldVal, k, 'set');
|
|
4690
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
4691
|
+
oldVal,
|
|
4692
|
+
k,
|
|
4693
|
+
'set'
|
|
4694
|
+
]);
|
|
4695
|
+
}
|
|
4696
|
+
this.#removeItemSize(index);
|
|
4697
|
+
this.#addItemSize(index, size, status);
|
|
4698
|
+
this.#valList[index] = v;
|
|
4699
|
+
if (status) {
|
|
4700
|
+
status.set = 'replace';
|
|
4701
|
+
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
|
|
4702
|
+
if (void 0 !== oldValue) status.oldValue = oldValue;
|
|
4557
4703
|
}
|
|
4558
|
-
} else
|
|
4559
|
-
this.#j && this.onInsert?.(t1, e1, t1 === g ? "update" : "replace");
|
|
4704
|
+
} else if (status) status.set = 'update';
|
|
4560
4705
|
}
|
|
4561
|
-
if (0
|
|
4562
|
-
|
|
4563
|
-
|
|
4706
|
+
if (0 !== ttl && !this.#ttls) this.#initializeTTLTracking();
|
|
4707
|
+
if (this.#ttls) {
|
|
4708
|
+
if (!noUpdateTTL) this.#setItemTTL(index, ttl, start);
|
|
4709
|
+
if (status) this.#statusTTL(status, index);
|
|
4710
|
+
}
|
|
4711
|
+
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
4712
|
+
const dt = this.#disposed;
|
|
4713
|
+
let task;
|
|
4714
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4564
4715
|
}
|
|
4565
4716
|
return this;
|
|
4566
4717
|
}
|
|
4567
4718
|
pop() {
|
|
4568
4719
|
try {
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4720
|
+
while(this.#size){
|
|
4721
|
+
const val = this.#valList[this.#head];
|
|
4722
|
+
this.#evict(true);
|
|
4723
|
+
if (this.#isBackgroundFetch(val)) {
|
|
4724
|
+
if (val.__staleWhileFetching) return val.__staleWhileFetching;
|
|
4725
|
+
} else if (void 0 !== val) return val;
|
|
4574
4726
|
}
|
|
4575
4727
|
} finally{
|
|
4576
|
-
if (this.#
|
|
4577
|
-
|
|
4578
|
-
|
|
4728
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
4729
|
+
const dt = this.#disposed;
|
|
4730
|
+
let task;
|
|
4731
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4579
4732
|
}
|
|
4580
4733
|
}
|
|
4581
4734
|
}
|
|
4582
|
-
#
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
4595
|
-
}
|
|
4596
|
-
#Y(e1, t1 = {}) {
|
|
4597
|
-
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t1, n = this.#s.get(e1);
|
|
4598
|
-
if (void 0 !== n) {
|
|
4599
|
-
let o = this.#t[n];
|
|
4600
|
-
if (this.#e(o) && void 0 === o.__staleWhileFetching) return !1;
|
|
4601
|
-
if (!this.#p(n)) return i && this.#x(n), s && (s.has = "hit", this.#E(s, n)), !0;
|
|
4602
|
-
s && (s.has = "stale", this.#E(s, n));
|
|
4603
|
-
} else s && (s.has = "miss");
|
|
4604
|
-
return !1;
|
|
4605
|
-
}
|
|
4606
|
-
peek(e1, t1 = {}) {
|
|
4607
|
-
let { status: i = D() ? {} : void 0 } = t1;
|
|
4608
|
-
i && (i.op = "peek", i.key = e1), t1.status = i;
|
|
4609
|
-
let s = this.#J(e1, t1);
|
|
4610
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
4611
|
-
}
|
|
4612
|
-
#J(e1, t1) {
|
|
4613
|
-
let { status: i, allowStale: s = this.allowStale } = t1, n = this.#s.get(e1);
|
|
4614
|
-
if (void 0 === n || !s && this.#p(n)) {
|
|
4615
|
-
i && (i.peek = void 0 === n ? "miss" : "stale");
|
|
4616
|
-
return;
|
|
4735
|
+
#evict(free) {
|
|
4736
|
+
const head = this.#head;
|
|
4737
|
+
const k = this.#keyList[head];
|
|
4738
|
+
const v = this.#valList[head];
|
|
4739
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('evicted'));
|
|
4740
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
4741
|
+
if (this.#hasDispose) this.#dispose?.(v, k, 'evict');
|
|
4742
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
4743
|
+
v,
|
|
4744
|
+
k,
|
|
4745
|
+
'evict'
|
|
4746
|
+
]);
|
|
4617
4747
|
}
|
|
4618
|
-
|
|
4619
|
-
|
|
4748
|
+
this.#removeItemSize(head);
|
|
4749
|
+
if (free) {
|
|
4750
|
+
this.#keyList[head] = void 0;
|
|
4751
|
+
this.#valList[head] = void 0;
|
|
4752
|
+
this.#free.push(head);
|
|
4753
|
+
}
|
|
4754
|
+
if (1 === this.#size) {
|
|
4755
|
+
this.#head = this.#tail = 0;
|
|
4756
|
+
this.#free.length = 0;
|
|
4757
|
+
} else this.#head = this.#next[head];
|
|
4758
|
+
this.#keyMap.delete(k);
|
|
4759
|
+
this.#size--;
|
|
4760
|
+
return head;
|
|
4761
|
+
}
|
|
4762
|
+
has(k, hasOptions = {}) {
|
|
4763
|
+
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
4764
|
+
const index = this.#keyMap.get(k);
|
|
4765
|
+
if (void 0 !== index) {
|
|
4766
|
+
const v = this.#valList[index];
|
|
4767
|
+
if (this.#isBackgroundFetch(v) && void 0 === v.__staleWhileFetching) return false;
|
|
4768
|
+
if (this.#isStale(index)) {
|
|
4769
|
+
if (status) {
|
|
4770
|
+
status.has = 'stale';
|
|
4771
|
+
this.#statusTTL(status, index);
|
|
4772
|
+
}
|
|
4773
|
+
} else {
|
|
4774
|
+
if (updateAgeOnHas) this.#updateItemAge(index);
|
|
4775
|
+
if (status) {
|
|
4776
|
+
status.has = 'hit';
|
|
4777
|
+
this.#statusTTL(status, index);
|
|
4778
|
+
}
|
|
4779
|
+
return true;
|
|
4780
|
+
}
|
|
4781
|
+
} else if (status) status.has = 'miss';
|
|
4782
|
+
return false;
|
|
4620
4783
|
}
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4784
|
+
peek(k, peekOptions = {}) {
|
|
4785
|
+
const { allowStale = this.allowStale } = peekOptions;
|
|
4786
|
+
const index = this.#keyMap.get(k);
|
|
4787
|
+
if (void 0 === index || !allowStale && this.#isStale(index)) return;
|
|
4788
|
+
const v = this.#valList[index];
|
|
4789
|
+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4790
|
+
}
|
|
4791
|
+
#backgroundFetch(k, index, options, context) {
|
|
4792
|
+
const v = void 0 === index ? void 0 : this.#valList[index];
|
|
4793
|
+
if (this.#isBackgroundFetch(v)) return v;
|
|
4794
|
+
const ac = new AC();
|
|
4795
|
+
const { signal } = options;
|
|
4796
|
+
signal?.addEventListener('abort', ()=>ac.abort(signal.reason), {
|
|
4797
|
+
signal: ac.signal
|
|
4627
4798
|
});
|
|
4628
|
-
|
|
4629
|
-
signal:
|
|
4630
|
-
options
|
|
4631
|
-
context
|
|
4632
|
-
}
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4799
|
+
const fetchOpts = {
|
|
4800
|
+
signal: ac.signal,
|
|
4801
|
+
options,
|
|
4802
|
+
context
|
|
4803
|
+
};
|
|
4804
|
+
const cb = (v, updateCache = false)=>{
|
|
4805
|
+
const { aborted } = ac.signal;
|
|
4806
|
+
const ignoreAbort = options.ignoreFetchAbort && void 0 !== v;
|
|
4807
|
+
if (options.status) if (aborted && !updateCache) {
|
|
4808
|
+
options.status.fetchAborted = true;
|
|
4809
|
+
options.status.fetchError = ac.signal.reason;
|
|
4810
|
+
if (ignoreAbort) options.status.fetchAbortIgnored = true;
|
|
4811
|
+
} else options.status.fetchResolved = true;
|
|
4812
|
+
if (aborted && !ignoreAbort && !updateCache) return fetchFail(ac.signal.reason);
|
|
4813
|
+
const bf = p;
|
|
4814
|
+
if (this.#valList[index] === p) if (void 0 === v) if (bf.__staleWhileFetching) this.#valList[index] = bf.__staleWhileFetching;
|
|
4815
|
+
else this.#delete(k, 'fetch');
|
|
4816
|
+
else {
|
|
4817
|
+
if (options.status) options.status.fetchUpdated = true;
|
|
4818
|
+
this.set(k, v, fetchOpts.options);
|
|
4819
|
+
}
|
|
4820
|
+
return v;
|
|
4821
|
+
};
|
|
4822
|
+
const eb = (er)=>{
|
|
4823
|
+
if (options.status) {
|
|
4824
|
+
options.status.fetchRejected = true;
|
|
4825
|
+
options.status.fetchError = er;
|
|
4826
|
+
}
|
|
4827
|
+
return fetchFail(er);
|
|
4828
|
+
};
|
|
4829
|
+
const fetchFail = (er)=>{
|
|
4830
|
+
const { aborted } = ac.signal;
|
|
4831
|
+
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
4832
|
+
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
4833
|
+
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
4834
|
+
const bf = p;
|
|
4835
|
+
if (this.#valList[index] === p) {
|
|
4836
|
+
const del = !noDelete || void 0 === bf.__staleWhileFetching;
|
|
4837
|
+
if (del) this.#delete(k, 'fetch');
|
|
4838
|
+
else if (!allowStaleAborted) this.#valList[index] = bf.__staleWhileFetching;
|
|
4839
|
+
}
|
|
4840
|
+
if (allowStale) {
|
|
4841
|
+
if (options.status && void 0 !== bf.__staleWhileFetching) options.status.returnedStale = true;
|
|
4842
|
+
return bf.__staleWhileFetching;
|
|
4843
|
+
}
|
|
4844
|
+
if (bf.__returned === bf) throw er;
|
|
4845
|
+
};
|
|
4846
|
+
const pcall = (res, rej)=>{
|
|
4847
|
+
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
4848
|
+
if (fmp && fmp instanceof Promise) fmp.then((v)=>res(void 0 === v ? void 0 : v), rej);
|
|
4849
|
+
ac.signal.addEventListener('abort', ()=>{
|
|
4850
|
+
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
|
4851
|
+
res(void 0);
|
|
4852
|
+
if (options.allowStaleOnFetchAbort) res = (v)=>cb(v, true);
|
|
4853
|
+
}
|
|
4645
4854
|
});
|
|
4646
4855
|
};
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4856
|
+
if (options.status) options.status.fetchDispatched = true;
|
|
4857
|
+
const p = new Promise(pcall).then(cb, eb);
|
|
4858
|
+
const bf = Object.assign(p, {
|
|
4859
|
+
__abortController: ac,
|
|
4860
|
+
__staleWhileFetching: v,
|
|
4651
4861
|
__returned: void 0
|
|
4652
4862
|
});
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4863
|
+
if (void 0 === index) {
|
|
4864
|
+
this.set(k, bf, {
|
|
4865
|
+
...fetchOpts.options,
|
|
4866
|
+
status: void 0
|
|
4867
|
+
});
|
|
4868
|
+
index = this.#keyMap.get(k);
|
|
4869
|
+
} else this.#valList[index] = bf;
|
|
4870
|
+
return bf;
|
|
4871
|
+
}
|
|
4872
|
+
#isBackgroundFetch(p) {
|
|
4873
|
+
if (!this.#hasFetchMethod) return false;
|
|
4874
|
+
const b = p;
|
|
4875
|
+
return !!b && b instanceof Promise && b.hasOwnProperty('__staleWhileFetching') && b.__abortController instanceof AC;
|
|
4876
|
+
}
|
|
4877
|
+
async fetch(k, fetchOptions = {}) {
|
|
4878
|
+
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL, noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal } = fetchOptions;
|
|
4879
|
+
if (!this.#hasFetchMethod) {
|
|
4880
|
+
if (status) status.fetch = 'get';
|
|
4881
|
+
return this.get(k, {
|
|
4882
|
+
allowStale,
|
|
4883
|
+
updateAgeOnGet,
|
|
4884
|
+
noDeleteOnStaleGet,
|
|
4885
|
+
status
|
|
4886
|
+
});
|
|
4887
|
+
}
|
|
4888
|
+
const options = {
|
|
4889
|
+
allowStale,
|
|
4890
|
+
updateAgeOnGet,
|
|
4891
|
+
noDeleteOnStaleGet,
|
|
4892
|
+
ttl,
|
|
4893
|
+
noDisposeOnSet,
|
|
4894
|
+
size,
|
|
4895
|
+
sizeCalculation,
|
|
4896
|
+
noUpdateTTL,
|
|
4897
|
+
noDeleteOnFetchRejection,
|
|
4898
|
+
allowStaleOnFetchRejection,
|
|
4899
|
+
allowStaleOnFetchAbort,
|
|
4900
|
+
ignoreFetchAbort,
|
|
4901
|
+
status,
|
|
4902
|
+
signal
|
|
4903
|
+
};
|
|
4904
|
+
let index = this.#keyMap.get(k);
|
|
4905
|
+
if (void 0 === index) {
|
|
4906
|
+
if (status) status.fetch = 'miss';
|
|
4907
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
4908
|
+
return p.__returned = p;
|
|
4697
4909
|
}
|
|
4698
4910
|
{
|
|
4699
|
-
|
|
4700
|
-
if (this.#
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
}
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
if (
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4911
|
+
const v = this.#valList[index];
|
|
4912
|
+
if (this.#isBackgroundFetch(v)) {
|
|
4913
|
+
const stale = allowStale && void 0 !== v.__staleWhileFetching;
|
|
4914
|
+
if (status) {
|
|
4915
|
+
status.fetch = 'inflight';
|
|
4916
|
+
if (stale) status.returnedStale = true;
|
|
4917
|
+
}
|
|
4918
|
+
return stale ? v.__staleWhileFetching : v.__returned = v;
|
|
4919
|
+
}
|
|
4920
|
+
const isStale = this.#isStale(index);
|
|
4921
|
+
if (!forceRefresh && !isStale) {
|
|
4922
|
+
if (status) status.fetch = 'hit';
|
|
4923
|
+
this.#moveToTail(index);
|
|
4924
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
4925
|
+
if (status) this.#statusTTL(status, index);
|
|
4926
|
+
return v;
|
|
4927
|
+
}
|
|
4928
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
4929
|
+
const hasStale = void 0 !== p.__staleWhileFetching;
|
|
4930
|
+
const staleVal = hasStale && allowStale;
|
|
4931
|
+
if (status) {
|
|
4932
|
+
status.fetch = isStale ? 'stale' : 'refresh';
|
|
4933
|
+
if (staleVal && isStale) status.returnedStale = true;
|
|
4934
|
+
}
|
|
4935
|
+
return staleVal ? p.__staleWhileFetching : p.__returned = p;
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
async forceFetch(k, fetchOptions = {}) {
|
|
4939
|
+
const v = await this.fetch(k, fetchOptions);
|
|
4940
|
+
if (void 0 === v) throw new Error('fetch() returned undefined');
|
|
4941
|
+
return v;
|
|
4942
|
+
}
|
|
4943
|
+
memo(k, memoOptions = {}) {
|
|
4944
|
+
const memoMethod = this.#memoMethod;
|
|
4945
|
+
if (!memoMethod) throw new Error('no memoMethod provided to constructor');
|
|
4946
|
+
const { context, forceRefresh, ...options } = memoOptions;
|
|
4947
|
+
const v = this.get(k, options);
|
|
4948
|
+
if (!forceRefresh && void 0 !== v) return v;
|
|
4949
|
+
const vv = memoMethod(k, v, {
|
|
4950
|
+
options,
|
|
4951
|
+
context
|
|
4737
4952
|
});
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4953
|
+
this.set(k, vv, options);
|
|
4954
|
+
return vv;
|
|
4955
|
+
}
|
|
4956
|
+
get(k, getOptions = {}) {
|
|
4957
|
+
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
|
|
4958
|
+
const index = this.#keyMap.get(k);
|
|
4959
|
+
if (void 0 !== index) {
|
|
4960
|
+
const value = this.#valList[index];
|
|
4961
|
+
const fetching = this.#isBackgroundFetch(value);
|
|
4962
|
+
if (status) this.#statusTTL(status, index);
|
|
4963
|
+
if (this.#isStale(index)) {
|
|
4964
|
+
if (status) status.get = 'stale';
|
|
4965
|
+
if (fetching) {
|
|
4966
|
+
if (status && allowStale && void 0 !== value.__staleWhileFetching) status.returnedStale = true;
|
|
4967
|
+
return allowStale ? value.__staleWhileFetching : void 0;
|
|
4968
|
+
}
|
|
4969
|
+
if (!noDeleteOnStaleGet) this.#delete(k, 'expire');
|
|
4970
|
+
if (status && allowStale) status.returnedStale = true;
|
|
4971
|
+
return allowStale ? value : void 0;
|
|
4972
|
+
}
|
|
4973
|
+
if (status) status.get = 'hit';
|
|
4974
|
+
if (fetching) return value.__staleWhileFetching;
|
|
4975
|
+
this.#moveToTail(index);
|
|
4976
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
4977
|
+
return value;
|
|
4751
4978
|
}
|
|
4752
|
-
|
|
4753
|
-
return o && this.#E(o, r), this.#p(r) ? l ? (o && (o.get = "stale-fetching"), i && void 0 !== h.__staleWhileFetching ? (o && (o.returnedStale = !0), h.__staleWhileFetching) : void 0) : (n || this.#v(e1, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = !0), h) : void 0) : (o && (o.get = l ? "fetching" : "hit"), this.#L(r), s && this.#x(r), l ? h.__staleWhileFetching : h);
|
|
4979
|
+
if (status) status.get = 'miss';
|
|
4754
4980
|
}
|
|
4755
|
-
|
|
4756
|
-
this.#
|
|
4981
|
+
#connect(p, n) {
|
|
4982
|
+
this.#prev[n] = p;
|
|
4983
|
+
this.#next[p] = n;
|
|
4757
4984
|
}
|
|
4758
|
-
#
|
|
4759
|
-
|
|
4985
|
+
#moveToTail(index) {
|
|
4986
|
+
if (index !== this.#tail) {
|
|
4987
|
+
if (index === this.#head) this.#head = this.#next[index];
|
|
4988
|
+
else this.#connect(this.#prev[index], this.#next[index]);
|
|
4989
|
+
this.#connect(this.#tail, index);
|
|
4990
|
+
this.#tail = index;
|
|
4991
|
+
}
|
|
4760
4992
|
}
|
|
4761
|
-
delete(
|
|
4762
|
-
return this.#
|
|
4993
|
+
delete(k) {
|
|
4994
|
+
return this.#delete(k, 'delete');
|
|
4763
4995
|
}
|
|
4764
|
-
#
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
if (0 !== this.#n) {
|
|
4772
|
-
let s = this.#s.get(e1);
|
|
4773
|
-
if (void 0 !== s) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = !0, 1 === this.#n) this.#q(t1);
|
|
4774
|
-
else {
|
|
4775
|
-
this.#R(s);
|
|
4776
|
-
let n = this.#t[s];
|
|
4777
|
-
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, e1, t1), this.#f && this.#r?.push([
|
|
4778
|
-
n,
|
|
4779
|
-
e1,
|
|
4780
|
-
t1
|
|
4781
|
-
])), this.#s.delete(e1), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
|
|
4782
|
-
else if (s === this.#l) this.#l = this.#a[s];
|
|
4996
|
+
#delete(k, reason) {
|
|
4997
|
+
let deleted = false;
|
|
4998
|
+
if (0 !== this.#size) {
|
|
4999
|
+
const index = this.#keyMap.get(k);
|
|
5000
|
+
if (void 0 !== index) {
|
|
5001
|
+
deleted = true;
|
|
5002
|
+
if (1 === this.#size) this.#clear(reason);
|
|
4783
5003
|
else {
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
this.#
|
|
5004
|
+
this.#removeItemSize(index);
|
|
5005
|
+
const v = this.#valList[index];
|
|
5006
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5007
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
5008
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
5009
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5010
|
+
v,
|
|
5011
|
+
k,
|
|
5012
|
+
reason
|
|
5013
|
+
]);
|
|
5014
|
+
}
|
|
5015
|
+
this.#keyMap.delete(k);
|
|
5016
|
+
this.#keyList[index] = void 0;
|
|
5017
|
+
this.#valList[index] = void 0;
|
|
5018
|
+
if (index === this.#tail) this.#tail = this.#prev[index];
|
|
5019
|
+
else if (index === this.#head) this.#head = this.#next[index];
|
|
5020
|
+
else {
|
|
5021
|
+
const pi = this.#prev[index];
|
|
5022
|
+
this.#next[pi] = this.#next[index];
|
|
5023
|
+
const ni = this.#next[index];
|
|
5024
|
+
this.#prev[ni] = this.#prev[index];
|
|
5025
|
+
}
|
|
5026
|
+
this.#size--;
|
|
5027
|
+
this.#free.push(index);
|
|
4788
5028
|
}
|
|
4789
|
-
this.#n--, this.#y.push(s);
|
|
4790
5029
|
}
|
|
4791
5030
|
}
|
|
4792
|
-
if (this.#
|
|
4793
|
-
|
|
4794
|
-
|
|
5031
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
5032
|
+
const dt = this.#disposed;
|
|
5033
|
+
let task;
|
|
5034
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4795
5035
|
}
|
|
4796
|
-
return
|
|
5036
|
+
return deleted;
|
|
4797
5037
|
}
|
|
4798
5038
|
clear() {
|
|
4799
|
-
return this.#
|
|
5039
|
+
return this.#clear('delete');
|
|
4800
5040
|
}
|
|
4801
|
-
#
|
|
4802
|
-
for (
|
|
4803
|
-
allowStale:
|
|
5041
|
+
#clear(reason) {
|
|
5042
|
+
for (const index of this.#rindexes({
|
|
5043
|
+
allowStale: true
|
|
4804
5044
|
})){
|
|
4805
|
-
|
|
4806
|
-
if (this.#
|
|
5045
|
+
const v = this.#valList[index];
|
|
5046
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
4807
5047
|
else {
|
|
4808
|
-
|
|
4809
|
-
this.#
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
5048
|
+
const k = this.#keyList[index];
|
|
5049
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
5050
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5051
|
+
v,
|
|
5052
|
+
k,
|
|
5053
|
+
reason
|
|
4813
5054
|
]);
|
|
4814
5055
|
}
|
|
4815
5056
|
}
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
5057
|
+
this.#keyMap.clear();
|
|
5058
|
+
this.#valList.fill(void 0);
|
|
5059
|
+
this.#keyList.fill(void 0);
|
|
5060
|
+
if (this.#ttls && this.#starts) {
|
|
5061
|
+
this.#ttls.fill(0);
|
|
5062
|
+
this.#starts.fill(0);
|
|
4820
5063
|
}
|
|
4821
|
-
if (this.#
|
|
4822
|
-
|
|
4823
|
-
|
|
5064
|
+
if (this.#sizes) this.#sizes.fill(0);
|
|
5065
|
+
this.#head = 0;
|
|
5066
|
+
this.#tail = 0;
|
|
5067
|
+
this.#free.length = 0;
|
|
5068
|
+
this.#calculatedSize = 0;
|
|
5069
|
+
this.#size = 0;
|
|
5070
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
5071
|
+
const dt = this.#disposed;
|
|
5072
|
+
let task;
|
|
5073
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4824
5074
|
}
|
|
4825
5075
|
}
|
|
4826
|
-
}
|
|
5076
|
+
}
|
|
4827
5077
|
var external_fs_ = __webpack_require__("fs");
|
|
4828
5078
|
const proc = 'object' == typeof process && process ? process : {
|
|
4829
5079
|
stdout: null,
|
|
@@ -4896,7 +5146,7 @@ var __webpack_modules__ = {
|
|
|
4896
5146
|
}
|
|
4897
5147
|
constructor(src, dest, opts){
|
|
4898
5148
|
super(src, dest, opts);
|
|
4899
|
-
this.proxyErrors = (er)=>
|
|
5149
|
+
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
4900
5150
|
src.on('error', this.proxyErrors);
|
|
4901
5151
|
}
|
|
4902
5152
|
}
|
|
@@ -5348,8 +5598,7 @@ var __webpack_modules__ = {
|
|
|
5348
5598
|
return: stop,
|
|
5349
5599
|
[Symbol.asyncIterator] () {
|
|
5350
5600
|
return this;
|
|
5351
|
-
}
|
|
5352
|
-
[Symbol.asyncDispose]: async ()=>{}
|
|
5601
|
+
}
|
|
5353
5602
|
};
|
|
5354
5603
|
}
|
|
5355
5604
|
[Symbol.iterator]() {
|
|
@@ -5383,8 +5632,7 @@ var __webpack_modules__ = {
|
|
|
5383
5632
|
return: stop,
|
|
5384
5633
|
[Symbol.iterator] () {
|
|
5385
5634
|
return this;
|
|
5386
|
-
}
|
|
5387
|
-
[Symbol.dispose]: ()=>{}
|
|
5635
|
+
}
|
|
5388
5636
|
};
|
|
5389
5637
|
}
|
|
5390
5638
|
destroy(er) {
|
|
@@ -5467,14 +5715,14 @@ var __webpack_modules__ = {
|
|
|
5467
5715
|
normalizeNocaseCache.set(s, n);
|
|
5468
5716
|
return n;
|
|
5469
5717
|
};
|
|
5470
|
-
class ResolveCache extends
|
|
5718
|
+
class ResolveCache extends LRUCache {
|
|
5471
5719
|
constructor(){
|
|
5472
5720
|
super({
|
|
5473
5721
|
max: 256
|
|
5474
5722
|
});
|
|
5475
5723
|
}
|
|
5476
5724
|
}
|
|
5477
|
-
class ChildrenCache extends
|
|
5725
|
+
class ChildrenCache extends LRUCache {
|
|
5478
5726
|
constructor(maxSize = 16384){
|
|
5479
5727
|
super({
|
|
5480
5728
|
maxSize,
|
|
@@ -6617,586 +6865,6 @@ var __webpack_modules__ = {
|
|
|
6617
6865
|
return true;
|
|
6618
6866
|
}
|
|
6619
6867
|
}
|
|
6620
|
-
const esm_proc = 'object' == typeof process && process ? process : {
|
|
6621
|
-
stdout: null,
|
|
6622
|
-
stderr: null
|
|
6623
|
-
};
|
|
6624
|
-
const esm_isStream = (s)=>!!s && 'object' == typeof s && (s instanceof esm_Minipass || s instanceof node_stream || esm_isReadable(s) || esm_isWritable(s));
|
|
6625
|
-
const esm_isReadable = (s)=>!!s && 'object' == typeof s && s instanceof EventEmitter && 'function' == typeof s.pipe && s.pipe !== node_stream.Writable.prototype.pipe;
|
|
6626
|
-
const esm_isWritable = (s)=>!!s && 'object' == typeof s && s instanceof EventEmitter && 'function' == typeof s.write && 'function' == typeof s.end;
|
|
6627
|
-
const esm_EOF = Symbol('EOF');
|
|
6628
|
-
const esm_MAYBE_EMIT_END = Symbol('maybeEmitEnd');
|
|
6629
|
-
const esm_EMITTED_END = Symbol('emittedEnd');
|
|
6630
|
-
const esm_EMITTING_END = Symbol('emittingEnd');
|
|
6631
|
-
const esm_EMITTED_ERROR = Symbol('emittedError');
|
|
6632
|
-
const esm_CLOSED = Symbol('closed');
|
|
6633
|
-
const esm_READ = Symbol('read');
|
|
6634
|
-
const esm_FLUSH = Symbol('flush');
|
|
6635
|
-
const esm_FLUSHCHUNK = Symbol('flushChunk');
|
|
6636
|
-
const esm_ENCODING = Symbol('encoding');
|
|
6637
|
-
const esm_DECODER = Symbol('decoder');
|
|
6638
|
-
const esm_FLOWING = Symbol('flowing');
|
|
6639
|
-
const esm_PAUSED = Symbol('paused');
|
|
6640
|
-
const esm_RESUME = Symbol('resume');
|
|
6641
|
-
const esm_BUFFER = Symbol('buffer');
|
|
6642
|
-
const esm_PIPES = Symbol('pipes');
|
|
6643
|
-
const esm_BUFFERLENGTH = Symbol('bufferLength');
|
|
6644
|
-
const esm_BUFFERPUSH = Symbol('bufferPush');
|
|
6645
|
-
const esm_BUFFERSHIFT = Symbol('bufferShift');
|
|
6646
|
-
const esm_OBJECTMODE = Symbol('objectMode');
|
|
6647
|
-
const esm_DESTROYED = Symbol('destroyed');
|
|
6648
|
-
const esm_ERROR = Symbol('error');
|
|
6649
|
-
const esm_EMITDATA = Symbol('emitData');
|
|
6650
|
-
const esm_EMITEND = Symbol('emitEnd');
|
|
6651
|
-
const esm_EMITEND2 = Symbol('emitEnd2');
|
|
6652
|
-
const esm_ASYNC = Symbol('async');
|
|
6653
|
-
const esm_ABORT = Symbol('abort');
|
|
6654
|
-
const esm_ABORTED = Symbol('aborted');
|
|
6655
|
-
const esm_SIGNAL = Symbol('signal');
|
|
6656
|
-
const esm_DATALISTENERS = Symbol('dataListeners');
|
|
6657
|
-
const esm_DISCARDED = Symbol('discarded');
|
|
6658
|
-
const esm_defer = (fn)=>Promise.resolve().then(fn);
|
|
6659
|
-
const esm_nodefer = (fn)=>fn();
|
|
6660
|
-
const esm_isEndish = (ev)=>'end' === ev || 'finish' === ev || 'prefinish' === ev;
|
|
6661
|
-
const esm_isArrayBufferLike = (b)=>b instanceof ArrayBuffer || !!b && 'object' == typeof b && b.constructor && 'ArrayBuffer' === b.constructor.name && b.byteLength >= 0;
|
|
6662
|
-
const esm_isArrayBufferView = (b)=>!Buffer.isBuffer(b) && ArrayBuffer.isView(b);
|
|
6663
|
-
class esm_Pipe {
|
|
6664
|
-
src;
|
|
6665
|
-
dest;
|
|
6666
|
-
opts;
|
|
6667
|
-
ondrain;
|
|
6668
|
-
constructor(src, dest, opts){
|
|
6669
|
-
this.src = src;
|
|
6670
|
-
this.dest = dest;
|
|
6671
|
-
this.opts = opts;
|
|
6672
|
-
this.ondrain = ()=>src[esm_RESUME]();
|
|
6673
|
-
this.dest.on('drain', this.ondrain);
|
|
6674
|
-
}
|
|
6675
|
-
unpipe() {
|
|
6676
|
-
this.dest.removeListener('drain', this.ondrain);
|
|
6677
|
-
}
|
|
6678
|
-
proxyErrors(_er) {}
|
|
6679
|
-
end() {
|
|
6680
|
-
this.unpipe();
|
|
6681
|
-
if (this.opts.end) this.dest.end();
|
|
6682
|
-
}
|
|
6683
|
-
}
|
|
6684
|
-
class esm_PipeProxyErrors extends esm_Pipe {
|
|
6685
|
-
unpipe() {
|
|
6686
|
-
this.src.removeListener('error', this.proxyErrors);
|
|
6687
|
-
super.unpipe();
|
|
6688
|
-
}
|
|
6689
|
-
constructor(src, dest, opts){
|
|
6690
|
-
super(src, dest, opts);
|
|
6691
|
-
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
6692
|
-
src.on('error', this.proxyErrors);
|
|
6693
|
-
}
|
|
6694
|
-
}
|
|
6695
|
-
const esm_isObjectModeOptions = (o)=>!!o.objectMode;
|
|
6696
|
-
const esm_isEncodingOptions = (o)=>!o.objectMode && !!o.encoding && 'buffer' !== o.encoding;
|
|
6697
|
-
class esm_Minipass extends EventEmitter {
|
|
6698
|
-
[esm_FLOWING] = false;
|
|
6699
|
-
[esm_PAUSED] = false;
|
|
6700
|
-
[esm_PIPES] = [];
|
|
6701
|
-
[esm_BUFFER] = [];
|
|
6702
|
-
[esm_OBJECTMODE];
|
|
6703
|
-
[esm_ENCODING];
|
|
6704
|
-
[esm_ASYNC];
|
|
6705
|
-
[esm_DECODER];
|
|
6706
|
-
[esm_EOF] = false;
|
|
6707
|
-
[esm_EMITTED_END] = false;
|
|
6708
|
-
[esm_EMITTING_END] = false;
|
|
6709
|
-
[esm_CLOSED] = false;
|
|
6710
|
-
[esm_EMITTED_ERROR] = null;
|
|
6711
|
-
[esm_BUFFERLENGTH] = 0;
|
|
6712
|
-
[esm_DESTROYED] = false;
|
|
6713
|
-
[esm_SIGNAL];
|
|
6714
|
-
[esm_ABORTED] = false;
|
|
6715
|
-
[esm_DATALISTENERS] = 0;
|
|
6716
|
-
[esm_DISCARDED] = false;
|
|
6717
|
-
writable = true;
|
|
6718
|
-
readable = true;
|
|
6719
|
-
constructor(...args){
|
|
6720
|
-
const options = args[0] || {};
|
|
6721
|
-
super();
|
|
6722
|
-
if (options.objectMode && 'string' == typeof options.encoding) throw new TypeError('Encoding and objectMode may not be used together');
|
|
6723
|
-
if (esm_isObjectModeOptions(options)) {
|
|
6724
|
-
this[esm_OBJECTMODE] = true;
|
|
6725
|
-
this[esm_ENCODING] = null;
|
|
6726
|
-
} else if (esm_isEncodingOptions(options)) {
|
|
6727
|
-
this[esm_ENCODING] = options.encoding;
|
|
6728
|
-
this[esm_OBJECTMODE] = false;
|
|
6729
|
-
} else {
|
|
6730
|
-
this[esm_OBJECTMODE] = false;
|
|
6731
|
-
this[esm_ENCODING] = null;
|
|
6732
|
-
}
|
|
6733
|
-
this[esm_ASYNC] = !!options.async;
|
|
6734
|
-
this[esm_DECODER] = this[esm_ENCODING] ? new StringDecoder(this[esm_ENCODING]) : null;
|
|
6735
|
-
if (options && true === options.debugExposeBuffer) Object.defineProperty(this, 'buffer', {
|
|
6736
|
-
get: ()=>this[esm_BUFFER]
|
|
6737
|
-
});
|
|
6738
|
-
if (options && true === options.debugExposePipes) Object.defineProperty(this, 'pipes', {
|
|
6739
|
-
get: ()=>this[esm_PIPES]
|
|
6740
|
-
});
|
|
6741
|
-
const { signal } = options;
|
|
6742
|
-
if (signal) {
|
|
6743
|
-
this[esm_SIGNAL] = signal;
|
|
6744
|
-
if (signal.aborted) this[esm_ABORT]();
|
|
6745
|
-
else signal.addEventListener('abort', ()=>this[esm_ABORT]());
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
get bufferLength() {
|
|
6749
|
-
return this[esm_BUFFERLENGTH];
|
|
6750
|
-
}
|
|
6751
|
-
get encoding() {
|
|
6752
|
-
return this[esm_ENCODING];
|
|
6753
|
-
}
|
|
6754
|
-
set encoding(_enc) {
|
|
6755
|
-
throw new Error('Encoding must be set at instantiation time');
|
|
6756
|
-
}
|
|
6757
|
-
setEncoding(_enc) {
|
|
6758
|
-
throw new Error('Encoding must be set at instantiation time');
|
|
6759
|
-
}
|
|
6760
|
-
get objectMode() {
|
|
6761
|
-
return this[esm_OBJECTMODE];
|
|
6762
|
-
}
|
|
6763
|
-
set objectMode(_om) {
|
|
6764
|
-
throw new Error('objectMode must be set at instantiation time');
|
|
6765
|
-
}
|
|
6766
|
-
get ['async']() {
|
|
6767
|
-
return this[esm_ASYNC];
|
|
6768
|
-
}
|
|
6769
|
-
set ['async'](a) {
|
|
6770
|
-
this[esm_ASYNC] = this[esm_ASYNC] || !!a;
|
|
6771
|
-
}
|
|
6772
|
-
[esm_ABORT]() {
|
|
6773
|
-
this[esm_ABORTED] = true;
|
|
6774
|
-
this.emit('abort', this[esm_SIGNAL]?.reason);
|
|
6775
|
-
this.destroy(this[esm_SIGNAL]?.reason);
|
|
6776
|
-
}
|
|
6777
|
-
get aborted() {
|
|
6778
|
-
return this[esm_ABORTED];
|
|
6779
|
-
}
|
|
6780
|
-
set aborted(_) {}
|
|
6781
|
-
write(chunk, encoding, cb) {
|
|
6782
|
-
if (this[esm_ABORTED]) return false;
|
|
6783
|
-
if (this[esm_EOF]) throw new Error('write after end');
|
|
6784
|
-
if (this[esm_DESTROYED]) {
|
|
6785
|
-
this.emit('error', Object.assign(new Error('Cannot call write after a stream was destroyed'), {
|
|
6786
|
-
code: 'ERR_STREAM_DESTROYED'
|
|
6787
|
-
}));
|
|
6788
|
-
return true;
|
|
6789
|
-
}
|
|
6790
|
-
if ('function' == typeof encoding) {
|
|
6791
|
-
cb = encoding;
|
|
6792
|
-
encoding = 'utf8';
|
|
6793
|
-
}
|
|
6794
|
-
if (!encoding) encoding = 'utf8';
|
|
6795
|
-
const fn = this[esm_ASYNC] ? esm_defer : esm_nodefer;
|
|
6796
|
-
if (!this[esm_OBJECTMODE] && !Buffer.isBuffer(chunk)) {
|
|
6797
|
-
if (esm_isArrayBufferView(chunk)) chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
6798
|
-
else if (esm_isArrayBufferLike(chunk)) chunk = Buffer.from(chunk);
|
|
6799
|
-
else if ('string' != typeof chunk) throw new Error('Non-contiguous data written to non-objectMode stream');
|
|
6800
|
-
}
|
|
6801
|
-
if (this[esm_OBJECTMODE]) {
|
|
6802
|
-
if (this[esm_FLOWING] && 0 !== this[esm_BUFFERLENGTH]) this[esm_FLUSH](true);
|
|
6803
|
-
if (this[esm_FLOWING]) this.emit('data', chunk);
|
|
6804
|
-
else this[esm_BUFFERPUSH](chunk);
|
|
6805
|
-
if (0 !== this[esm_BUFFERLENGTH]) this.emit('readable');
|
|
6806
|
-
if (cb) fn(cb);
|
|
6807
|
-
return this[esm_FLOWING];
|
|
6808
|
-
}
|
|
6809
|
-
if (!chunk.length) {
|
|
6810
|
-
if (0 !== this[esm_BUFFERLENGTH]) this.emit('readable');
|
|
6811
|
-
if (cb) fn(cb);
|
|
6812
|
-
return this[esm_FLOWING];
|
|
6813
|
-
}
|
|
6814
|
-
if ('string' == typeof chunk && !(encoding === this[esm_ENCODING] && !this[esm_DECODER]?.lastNeed)) chunk = Buffer.from(chunk, encoding);
|
|
6815
|
-
if (Buffer.isBuffer(chunk) && this[esm_ENCODING]) chunk = this[esm_DECODER].write(chunk);
|
|
6816
|
-
if (this[esm_FLOWING] && 0 !== this[esm_BUFFERLENGTH]) this[esm_FLUSH](true);
|
|
6817
|
-
if (this[esm_FLOWING]) this.emit('data', chunk);
|
|
6818
|
-
else this[esm_BUFFERPUSH](chunk);
|
|
6819
|
-
if (0 !== this[esm_BUFFERLENGTH]) this.emit('readable');
|
|
6820
|
-
if (cb) fn(cb);
|
|
6821
|
-
return this[esm_FLOWING];
|
|
6822
|
-
}
|
|
6823
|
-
read(n) {
|
|
6824
|
-
if (this[esm_DESTROYED]) return null;
|
|
6825
|
-
this[esm_DISCARDED] = false;
|
|
6826
|
-
if (0 === this[esm_BUFFERLENGTH] || 0 === n || n && n > this[esm_BUFFERLENGTH]) {
|
|
6827
|
-
this[esm_MAYBE_EMIT_END]();
|
|
6828
|
-
return null;
|
|
6829
|
-
}
|
|
6830
|
-
if (this[esm_OBJECTMODE]) n = null;
|
|
6831
|
-
if (this[esm_BUFFER].length > 1 && !this[esm_OBJECTMODE]) this[esm_BUFFER] = [
|
|
6832
|
-
this[esm_ENCODING] ? this[esm_BUFFER].join('') : Buffer.concat(this[esm_BUFFER], this[esm_BUFFERLENGTH])
|
|
6833
|
-
];
|
|
6834
|
-
const ret = this[esm_READ](n || null, this[esm_BUFFER][0]);
|
|
6835
|
-
this[esm_MAYBE_EMIT_END]();
|
|
6836
|
-
return ret;
|
|
6837
|
-
}
|
|
6838
|
-
[esm_READ](n, chunk) {
|
|
6839
|
-
if (this[esm_OBJECTMODE]) this[esm_BUFFERSHIFT]();
|
|
6840
|
-
else {
|
|
6841
|
-
const c = chunk;
|
|
6842
|
-
if (n === c.length || null === n) this[esm_BUFFERSHIFT]();
|
|
6843
|
-
else if ('string' == typeof c) {
|
|
6844
|
-
this[esm_BUFFER][0] = c.slice(n);
|
|
6845
|
-
chunk = c.slice(0, n);
|
|
6846
|
-
this[esm_BUFFERLENGTH] -= n;
|
|
6847
|
-
} else {
|
|
6848
|
-
this[esm_BUFFER][0] = c.subarray(n);
|
|
6849
|
-
chunk = c.subarray(0, n);
|
|
6850
|
-
this[esm_BUFFERLENGTH] -= n;
|
|
6851
|
-
}
|
|
6852
|
-
}
|
|
6853
|
-
this.emit('data', chunk);
|
|
6854
|
-
if (!this[esm_BUFFER].length && !this[esm_EOF]) this.emit('drain');
|
|
6855
|
-
return chunk;
|
|
6856
|
-
}
|
|
6857
|
-
end(chunk, encoding, cb) {
|
|
6858
|
-
if ('function' == typeof chunk) {
|
|
6859
|
-
cb = chunk;
|
|
6860
|
-
chunk = void 0;
|
|
6861
|
-
}
|
|
6862
|
-
if ('function' == typeof encoding) {
|
|
6863
|
-
cb = encoding;
|
|
6864
|
-
encoding = 'utf8';
|
|
6865
|
-
}
|
|
6866
|
-
if (void 0 !== chunk) this.write(chunk, encoding);
|
|
6867
|
-
if (cb) this.once('end', cb);
|
|
6868
|
-
this[esm_EOF] = true;
|
|
6869
|
-
this.writable = false;
|
|
6870
|
-
if (this[esm_FLOWING] || !this[esm_PAUSED]) this[esm_MAYBE_EMIT_END]();
|
|
6871
|
-
return this;
|
|
6872
|
-
}
|
|
6873
|
-
[esm_RESUME]() {
|
|
6874
|
-
if (this[esm_DESTROYED]) return;
|
|
6875
|
-
if (!this[esm_DATALISTENERS] && !this[esm_PIPES].length) this[esm_DISCARDED] = true;
|
|
6876
|
-
this[esm_PAUSED] = false;
|
|
6877
|
-
this[esm_FLOWING] = true;
|
|
6878
|
-
this.emit('resume');
|
|
6879
|
-
if (this[esm_BUFFER].length) this[esm_FLUSH]();
|
|
6880
|
-
else if (this[esm_EOF]) this[esm_MAYBE_EMIT_END]();
|
|
6881
|
-
else this.emit('drain');
|
|
6882
|
-
}
|
|
6883
|
-
resume() {
|
|
6884
|
-
return this[esm_RESUME]();
|
|
6885
|
-
}
|
|
6886
|
-
pause() {
|
|
6887
|
-
this[esm_FLOWING] = false;
|
|
6888
|
-
this[esm_PAUSED] = true;
|
|
6889
|
-
this[esm_DISCARDED] = false;
|
|
6890
|
-
}
|
|
6891
|
-
get destroyed() {
|
|
6892
|
-
return this[esm_DESTROYED];
|
|
6893
|
-
}
|
|
6894
|
-
get flowing() {
|
|
6895
|
-
return this[esm_FLOWING];
|
|
6896
|
-
}
|
|
6897
|
-
get paused() {
|
|
6898
|
-
return this[esm_PAUSED];
|
|
6899
|
-
}
|
|
6900
|
-
[esm_BUFFERPUSH](chunk) {
|
|
6901
|
-
if (this[esm_OBJECTMODE]) this[esm_BUFFERLENGTH] += 1;
|
|
6902
|
-
else this[esm_BUFFERLENGTH] += chunk.length;
|
|
6903
|
-
this[esm_BUFFER].push(chunk);
|
|
6904
|
-
}
|
|
6905
|
-
[esm_BUFFERSHIFT]() {
|
|
6906
|
-
if (this[esm_OBJECTMODE]) this[esm_BUFFERLENGTH] -= 1;
|
|
6907
|
-
else this[esm_BUFFERLENGTH] -= this[esm_BUFFER][0].length;
|
|
6908
|
-
return this[esm_BUFFER].shift();
|
|
6909
|
-
}
|
|
6910
|
-
[esm_FLUSH](noDrain = false) {
|
|
6911
|
-
do ;
|
|
6912
|
-
while (this[esm_FLUSHCHUNK](this[esm_BUFFERSHIFT]()) && this[esm_BUFFER].length);
|
|
6913
|
-
if (!noDrain && !this[esm_BUFFER].length && !this[esm_EOF]) this.emit('drain');
|
|
6914
|
-
}
|
|
6915
|
-
[esm_FLUSHCHUNK](chunk) {
|
|
6916
|
-
this.emit('data', chunk);
|
|
6917
|
-
return this[esm_FLOWING];
|
|
6918
|
-
}
|
|
6919
|
-
pipe(dest, opts) {
|
|
6920
|
-
if (this[esm_DESTROYED]) return dest;
|
|
6921
|
-
this[esm_DISCARDED] = false;
|
|
6922
|
-
const ended = this[esm_EMITTED_END];
|
|
6923
|
-
opts = opts || {};
|
|
6924
|
-
if (dest === esm_proc.stdout || dest === esm_proc.stderr) opts.end = false;
|
|
6925
|
-
else opts.end = false !== opts.end;
|
|
6926
|
-
opts.proxyErrors = !!opts.proxyErrors;
|
|
6927
|
-
if (ended) {
|
|
6928
|
-
if (opts.end) dest.end();
|
|
6929
|
-
} else {
|
|
6930
|
-
this[esm_PIPES].push(opts.proxyErrors ? new esm_PipeProxyErrors(this, dest, opts) : new esm_Pipe(this, dest, opts));
|
|
6931
|
-
if (this[esm_ASYNC]) esm_defer(()=>this[esm_RESUME]());
|
|
6932
|
-
else this[esm_RESUME]();
|
|
6933
|
-
}
|
|
6934
|
-
return dest;
|
|
6935
|
-
}
|
|
6936
|
-
unpipe(dest) {
|
|
6937
|
-
const p = this[esm_PIPES].find((p)=>p.dest === dest);
|
|
6938
|
-
if (p) {
|
|
6939
|
-
if (1 === this[esm_PIPES].length) {
|
|
6940
|
-
if (this[esm_FLOWING] && 0 === this[esm_DATALISTENERS]) this[esm_FLOWING] = false;
|
|
6941
|
-
this[esm_PIPES] = [];
|
|
6942
|
-
} else this[esm_PIPES].splice(this[esm_PIPES].indexOf(p), 1);
|
|
6943
|
-
p.unpipe();
|
|
6944
|
-
}
|
|
6945
|
-
}
|
|
6946
|
-
addListener(ev, handler) {
|
|
6947
|
-
return this.on(ev, handler);
|
|
6948
|
-
}
|
|
6949
|
-
on(ev, handler) {
|
|
6950
|
-
const ret = super.on(ev, handler);
|
|
6951
|
-
if ('data' === ev) {
|
|
6952
|
-
this[esm_DISCARDED] = false;
|
|
6953
|
-
this[esm_DATALISTENERS]++;
|
|
6954
|
-
if (!this[esm_PIPES].length && !this[esm_FLOWING]) this[esm_RESUME]();
|
|
6955
|
-
} else if ('readable' === ev && 0 !== this[esm_BUFFERLENGTH]) super.emit('readable');
|
|
6956
|
-
else if (esm_isEndish(ev) && this[esm_EMITTED_END]) {
|
|
6957
|
-
super.emit(ev);
|
|
6958
|
-
this.removeAllListeners(ev);
|
|
6959
|
-
} else if ('error' === ev && this[esm_EMITTED_ERROR]) {
|
|
6960
|
-
const h = handler;
|
|
6961
|
-
if (this[esm_ASYNC]) esm_defer(()=>h.call(this, this[esm_EMITTED_ERROR]));
|
|
6962
|
-
else h.call(this, this[esm_EMITTED_ERROR]);
|
|
6963
|
-
}
|
|
6964
|
-
return ret;
|
|
6965
|
-
}
|
|
6966
|
-
removeListener(ev, handler) {
|
|
6967
|
-
return this.off(ev, handler);
|
|
6968
|
-
}
|
|
6969
|
-
off(ev, handler) {
|
|
6970
|
-
const ret = super.off(ev, handler);
|
|
6971
|
-
if ('data' === ev) {
|
|
6972
|
-
this[esm_DATALISTENERS] = this.listeners('data').length;
|
|
6973
|
-
if (0 === this[esm_DATALISTENERS] && !this[esm_DISCARDED] && !this[esm_PIPES].length) this[esm_FLOWING] = false;
|
|
6974
|
-
}
|
|
6975
|
-
return ret;
|
|
6976
|
-
}
|
|
6977
|
-
removeAllListeners(ev) {
|
|
6978
|
-
const ret = super.removeAllListeners(ev);
|
|
6979
|
-
if ('data' === ev || void 0 === ev) {
|
|
6980
|
-
this[esm_DATALISTENERS] = 0;
|
|
6981
|
-
if (!this[esm_DISCARDED] && !this[esm_PIPES].length) this[esm_FLOWING] = false;
|
|
6982
|
-
}
|
|
6983
|
-
return ret;
|
|
6984
|
-
}
|
|
6985
|
-
get emittedEnd() {
|
|
6986
|
-
return this[esm_EMITTED_END];
|
|
6987
|
-
}
|
|
6988
|
-
[esm_MAYBE_EMIT_END]() {
|
|
6989
|
-
if (!this[esm_EMITTING_END] && !this[esm_EMITTED_END] && !this[esm_DESTROYED] && 0 === this[esm_BUFFER].length && this[esm_EOF]) {
|
|
6990
|
-
this[esm_EMITTING_END] = true;
|
|
6991
|
-
this.emit('end');
|
|
6992
|
-
this.emit('prefinish');
|
|
6993
|
-
this.emit('finish');
|
|
6994
|
-
if (this[esm_CLOSED]) this.emit('close');
|
|
6995
|
-
this[esm_EMITTING_END] = false;
|
|
6996
|
-
}
|
|
6997
|
-
}
|
|
6998
|
-
emit(ev, ...args) {
|
|
6999
|
-
const data = args[0];
|
|
7000
|
-
if ('error' !== ev && 'close' !== ev && ev !== esm_DESTROYED && this[esm_DESTROYED]) return false;
|
|
7001
|
-
if ('data' === ev) return this[esm_OBJECTMODE] || data ? this[esm_ASYNC] ? (esm_defer(()=>this[esm_EMITDATA](data)), true) : this[esm_EMITDATA](data) : false;
|
|
7002
|
-
if ('end' === ev) return this[esm_EMITEND]();
|
|
7003
|
-
if ('close' === ev) {
|
|
7004
|
-
this[esm_CLOSED] = true;
|
|
7005
|
-
if (!this[esm_EMITTED_END] && !this[esm_DESTROYED]) return false;
|
|
7006
|
-
const ret = super.emit('close');
|
|
7007
|
-
this.removeAllListeners('close');
|
|
7008
|
-
return ret;
|
|
7009
|
-
}
|
|
7010
|
-
if ('error' === ev) {
|
|
7011
|
-
this[esm_EMITTED_ERROR] = data;
|
|
7012
|
-
super.emit(esm_ERROR, data);
|
|
7013
|
-
const ret = !this[esm_SIGNAL] || this.listeners('error').length ? super.emit('error', data) : false;
|
|
7014
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7015
|
-
return ret;
|
|
7016
|
-
} else if ('resume' === ev) {
|
|
7017
|
-
const ret = super.emit('resume');
|
|
7018
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7019
|
-
return ret;
|
|
7020
|
-
} else if ('finish' === ev || 'prefinish' === ev) {
|
|
7021
|
-
const ret = super.emit(ev);
|
|
7022
|
-
this.removeAllListeners(ev);
|
|
7023
|
-
return ret;
|
|
7024
|
-
}
|
|
7025
|
-
const ret = super.emit(ev, ...args);
|
|
7026
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7027
|
-
return ret;
|
|
7028
|
-
}
|
|
7029
|
-
[esm_EMITDATA](data) {
|
|
7030
|
-
for (const p of this[esm_PIPES])if (false === p.dest.write(data)) this.pause();
|
|
7031
|
-
const ret = this[esm_DISCARDED] ? false : super.emit('data', data);
|
|
7032
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7033
|
-
return ret;
|
|
7034
|
-
}
|
|
7035
|
-
[esm_EMITEND]() {
|
|
7036
|
-
if (this[esm_EMITTED_END]) return false;
|
|
7037
|
-
this[esm_EMITTED_END] = true;
|
|
7038
|
-
this.readable = false;
|
|
7039
|
-
return this[esm_ASYNC] ? (esm_defer(()=>this[esm_EMITEND2]()), true) : this[esm_EMITEND2]();
|
|
7040
|
-
}
|
|
7041
|
-
[esm_EMITEND2]() {
|
|
7042
|
-
if (this[esm_DECODER]) {
|
|
7043
|
-
const data = this[esm_DECODER].end();
|
|
7044
|
-
if (data) {
|
|
7045
|
-
for (const p of this[esm_PIPES])p.dest.write(data);
|
|
7046
|
-
if (!this[esm_DISCARDED]) super.emit('data', data);
|
|
7047
|
-
}
|
|
7048
|
-
}
|
|
7049
|
-
for (const p of this[esm_PIPES])p.end();
|
|
7050
|
-
const ret = super.emit('end');
|
|
7051
|
-
this.removeAllListeners('end');
|
|
7052
|
-
return ret;
|
|
7053
|
-
}
|
|
7054
|
-
async collect() {
|
|
7055
|
-
const buf = Object.assign([], {
|
|
7056
|
-
dataLength: 0
|
|
7057
|
-
});
|
|
7058
|
-
if (!this[esm_OBJECTMODE]) buf.dataLength = 0;
|
|
7059
|
-
const p = this.promise();
|
|
7060
|
-
this.on('data', (c)=>{
|
|
7061
|
-
buf.push(c);
|
|
7062
|
-
if (!this[esm_OBJECTMODE]) buf.dataLength += c.length;
|
|
7063
|
-
});
|
|
7064
|
-
await p;
|
|
7065
|
-
return buf;
|
|
7066
|
-
}
|
|
7067
|
-
async concat() {
|
|
7068
|
-
if (this[esm_OBJECTMODE]) throw new Error('cannot concat in objectMode');
|
|
7069
|
-
const buf = await this.collect();
|
|
7070
|
-
return this[esm_ENCODING] ? buf.join('') : Buffer.concat(buf, buf.dataLength);
|
|
7071
|
-
}
|
|
7072
|
-
async promise() {
|
|
7073
|
-
return new Promise((resolve, reject)=>{
|
|
7074
|
-
this.on(esm_DESTROYED, ()=>reject(new Error('stream destroyed')));
|
|
7075
|
-
this.on('error', (er)=>reject(er));
|
|
7076
|
-
this.on('end', ()=>resolve());
|
|
7077
|
-
});
|
|
7078
|
-
}
|
|
7079
|
-
[Symbol.asyncIterator]() {
|
|
7080
|
-
this[esm_DISCARDED] = false;
|
|
7081
|
-
let stopped = false;
|
|
7082
|
-
const stop = async ()=>{
|
|
7083
|
-
this.pause();
|
|
7084
|
-
stopped = true;
|
|
7085
|
-
return {
|
|
7086
|
-
value: void 0,
|
|
7087
|
-
done: true
|
|
7088
|
-
};
|
|
7089
|
-
};
|
|
7090
|
-
const next = ()=>{
|
|
7091
|
-
if (stopped) return stop();
|
|
7092
|
-
const res = this.read();
|
|
7093
|
-
if (null !== res) return Promise.resolve({
|
|
7094
|
-
done: false,
|
|
7095
|
-
value: res
|
|
7096
|
-
});
|
|
7097
|
-
if (this[esm_EOF]) return stop();
|
|
7098
|
-
let resolve;
|
|
7099
|
-
let reject;
|
|
7100
|
-
const onerr = (er)=>{
|
|
7101
|
-
this.off('data', ondata);
|
|
7102
|
-
this.off('end', onend);
|
|
7103
|
-
this.off(esm_DESTROYED, ondestroy);
|
|
7104
|
-
stop();
|
|
7105
|
-
reject(er);
|
|
7106
|
-
};
|
|
7107
|
-
const ondata = (value)=>{
|
|
7108
|
-
this.off('error', onerr);
|
|
7109
|
-
this.off('end', onend);
|
|
7110
|
-
this.off(esm_DESTROYED, ondestroy);
|
|
7111
|
-
this.pause();
|
|
7112
|
-
resolve({
|
|
7113
|
-
value,
|
|
7114
|
-
done: !!this[esm_EOF]
|
|
7115
|
-
});
|
|
7116
|
-
};
|
|
7117
|
-
const onend = ()=>{
|
|
7118
|
-
this.off('error', onerr);
|
|
7119
|
-
this.off('data', ondata);
|
|
7120
|
-
this.off(esm_DESTROYED, ondestroy);
|
|
7121
|
-
stop();
|
|
7122
|
-
resolve({
|
|
7123
|
-
done: true,
|
|
7124
|
-
value: void 0
|
|
7125
|
-
});
|
|
7126
|
-
};
|
|
7127
|
-
const ondestroy = ()=>onerr(new Error('stream destroyed'));
|
|
7128
|
-
return new Promise((res, rej)=>{
|
|
7129
|
-
reject = rej;
|
|
7130
|
-
resolve = res;
|
|
7131
|
-
this.once(esm_DESTROYED, ondestroy);
|
|
7132
|
-
this.once('error', onerr);
|
|
7133
|
-
this.once('end', onend);
|
|
7134
|
-
this.once('data', ondata);
|
|
7135
|
-
});
|
|
7136
|
-
};
|
|
7137
|
-
return {
|
|
7138
|
-
next,
|
|
7139
|
-
throw: stop,
|
|
7140
|
-
return: stop,
|
|
7141
|
-
[Symbol.asyncIterator] () {
|
|
7142
|
-
return this;
|
|
7143
|
-
}
|
|
7144
|
-
};
|
|
7145
|
-
}
|
|
7146
|
-
[Symbol.iterator]() {
|
|
7147
|
-
this[esm_DISCARDED] = false;
|
|
7148
|
-
let stopped = false;
|
|
7149
|
-
const stop = ()=>{
|
|
7150
|
-
this.pause();
|
|
7151
|
-
this.off(esm_ERROR, stop);
|
|
7152
|
-
this.off(esm_DESTROYED, stop);
|
|
7153
|
-
this.off('end', stop);
|
|
7154
|
-
stopped = true;
|
|
7155
|
-
return {
|
|
7156
|
-
done: true,
|
|
7157
|
-
value: void 0
|
|
7158
|
-
};
|
|
7159
|
-
};
|
|
7160
|
-
const next = ()=>{
|
|
7161
|
-
if (stopped) return stop();
|
|
7162
|
-
const value = this.read();
|
|
7163
|
-
return null === value ? stop() : {
|
|
7164
|
-
done: false,
|
|
7165
|
-
value
|
|
7166
|
-
};
|
|
7167
|
-
};
|
|
7168
|
-
this.once('end', stop);
|
|
7169
|
-
this.once(esm_ERROR, stop);
|
|
7170
|
-
this.once(esm_DESTROYED, stop);
|
|
7171
|
-
return {
|
|
7172
|
-
next,
|
|
7173
|
-
throw: stop,
|
|
7174
|
-
return: stop,
|
|
7175
|
-
[Symbol.iterator] () {
|
|
7176
|
-
return this;
|
|
7177
|
-
}
|
|
7178
|
-
};
|
|
7179
|
-
}
|
|
7180
|
-
destroy(er) {
|
|
7181
|
-
if (this[esm_DESTROYED]) {
|
|
7182
|
-
if (er) this.emit('error', er);
|
|
7183
|
-
else this.emit(esm_DESTROYED);
|
|
7184
|
-
return this;
|
|
7185
|
-
}
|
|
7186
|
-
this[esm_DESTROYED] = true;
|
|
7187
|
-
this[esm_DISCARDED] = true;
|
|
7188
|
-
this[esm_BUFFER].length = 0;
|
|
7189
|
-
this[esm_BUFFERLENGTH] = 0;
|
|
7190
|
-
const wc = this;
|
|
7191
|
-
if ('function' == typeof wc.close && !this[esm_CLOSED]) wc.close();
|
|
7192
|
-
if (er) this.emit('error', er);
|
|
7193
|
-
else this.emit(esm_DESTROYED);
|
|
7194
|
-
return this;
|
|
7195
|
-
}
|
|
7196
|
-
static get isStream() {
|
|
7197
|
-
return esm_isStream;
|
|
7198
|
-
}
|
|
7199
|
-
}
|
|
7200
6868
|
const ignore_defaultPlatform = 'object' == typeof process && process && 'string' == typeof process.platform ? process.platform : 'linux';
|
|
7201
6869
|
class Ignore {
|
|
7202
6870
|
relative;
|
|
@@ -7675,7 +7343,7 @@ var __webpack_modules__ = {
|
|
|
7675
7343
|
results;
|
|
7676
7344
|
constructor(patterns, path, opts){
|
|
7677
7345
|
super(patterns, path, opts);
|
|
7678
|
-
this.results = new
|
|
7346
|
+
this.results = new Minipass({
|
|
7679
7347
|
signal: this.signal,
|
|
7680
7348
|
objectMode: true
|
|
7681
7349
|
});
|
|
@@ -11183,7 +10851,7 @@ Usage:
|
|
|
11183
10851
|
type: 'boolean',
|
|
11184
10852
|
description: `Turn on logging to help debug why certain keys or values are not being set as you expect, default is ${config_factory_defaultConfig.dotenvDebug}`
|
|
11185
10853
|
}
|
|
11186
|
-
}).version('version', 'Show version number', "1.
|
|
10854
|
+
}).version('version', 'Show version number', "1.9.0").help().epilogue(`For complete list of configuration options, please visit:
|
|
11187
10855
|
• Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
|
|
11188
10856
|
• Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
|
|
11189
10857
|
• iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
|