@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/lib/index.js
CHANGED
|
@@ -3374,7 +3374,9 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
3374
3374
|
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
3375
3375
|
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
3376
3376
|
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
3377
|
-
var package_namespaceObject =
|
|
3377
|
+
var package_namespaceObject = {
|
|
3378
|
+
rE: "1.9.0"
|
|
3379
|
+
};
|
|
3378
3380
|
var logger_ = __webpack_require__("@midscene/shared/logger");
|
|
3379
3381
|
var brace_expansion = __webpack_require__("../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js");
|
|
3380
3382
|
const MAX_PATTERN_LENGTH = 65536;
|
|
@@ -4511,47 +4513,85 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4511
4513
|
minimatch.escape = escape_escape;
|
|
4512
4514
|
minimatch.unescape = unescape_unescape;
|
|
4513
4515
|
var external_node_url_ = __webpack_require__("node:url");
|
|
4514
|
-
const
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4516
|
+
const perf = 'object' == typeof performance && performance && 'function' == typeof performance.now ? performance : Date;
|
|
4517
|
+
const warned = new Set();
|
|
4518
|
+
const PROCESS = 'object' == typeof process && process ? process : {};
|
|
4519
|
+
const emitWarning = (msg, type, code, fn)=>{
|
|
4520
|
+
'function' == typeof PROCESS.emitWarning ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
4521
|
+
};
|
|
4522
|
+
let AC = globalThis.AbortController;
|
|
4523
|
+
let AS = globalThis.AbortSignal;
|
|
4524
|
+
if (void 0 === AC) {
|
|
4525
|
+
AS = class {
|
|
4526
|
+
onabort;
|
|
4527
|
+
_onabort = [];
|
|
4528
|
+
reason;
|
|
4529
|
+
aborted = false;
|
|
4530
|
+
addEventListener(_, fn) {
|
|
4531
|
+
this._onabort.push(fn);
|
|
4532
|
+
}
|
|
4533
|
+
};
|
|
4534
|
+
AC = class {
|
|
4535
|
+
constructor(){
|
|
4536
|
+
warnACPolyfill();
|
|
4537
|
+
}
|
|
4538
|
+
signal = new AS();
|
|
4539
|
+
abort(reason) {
|
|
4540
|
+
if (this.signal.aborted) return;
|
|
4541
|
+
this.signal.reason = reason;
|
|
4542
|
+
this.signal.aborted = true;
|
|
4543
|
+
for (const fn of this.signal._onabort)fn(reason);
|
|
4544
|
+
this.signal.onabort?.(reason);
|
|
4545
|
+
}
|
|
4546
|
+
};
|
|
4547
|
+
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
4548
|
+
const warnACPolyfill = ()=>{
|
|
4549
|
+
if (!printACPolyfillWarning) return;
|
|
4550
|
+
printACPolyfillWarning = false;
|
|
4551
|
+
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);
|
|
4552
|
+
};
|
|
4553
|
+
}
|
|
4554
|
+
const shouldWarn = (code)=>!warned.has(code);
|
|
4555
|
+
Symbol('type');
|
|
4556
|
+
const isPosInt = (n)=>n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
4557
|
+
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;
|
|
4558
|
+
class ZeroArray extends Array {
|
|
4559
|
+
constructor(size){
|
|
4560
|
+
super(size);
|
|
4561
|
+
this.fill(0);
|
|
4562
|
+
}
|
|
4563
|
+
}
|
|
4564
|
+
class Stack {
|
|
4523
4565
|
heap;
|
|
4524
4566
|
length;
|
|
4525
|
-
static #
|
|
4526
|
-
static create(
|
|
4527
|
-
|
|
4528
|
-
if (!
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4567
|
+
static #constructing = false;
|
|
4568
|
+
static create(max) {
|
|
4569
|
+
const HeapCls = getUintArray(max);
|
|
4570
|
+
if (!HeapCls) return [];
|
|
4571
|
+
Stack.#constructing = true;
|
|
4572
|
+
const s = new Stack(max, HeapCls);
|
|
4573
|
+
Stack.#constructing = false;
|
|
4574
|
+
return s;
|
|
4575
|
+
}
|
|
4576
|
+
constructor(max, HeapCls){
|
|
4577
|
+
if (!Stack.#constructing) throw new TypeError('instantiate Stack using Stack.create(n)');
|
|
4578
|
+
this.heap = new HeapCls(max);
|
|
4579
|
+
this.length = 0;
|
|
4580
|
+
}
|
|
4581
|
+
push(n) {
|
|
4582
|
+
this.heap[this.length++] = n;
|
|
4539
4583
|
}
|
|
4540
4584
|
pop() {
|
|
4541
4585
|
return this.heap[--this.length];
|
|
4542
4586
|
}
|
|
4543
|
-
}
|
|
4544
|
-
|
|
4545
|
-
#
|
|
4546
|
-
#
|
|
4547
|
-
#
|
|
4548
|
-
#
|
|
4549
|
-
#
|
|
4550
|
-
#
|
|
4551
|
-
#m;
|
|
4552
|
-
get perf() {
|
|
4553
|
-
return this.#m;
|
|
4554
|
-
}
|
|
4587
|
+
}
|
|
4588
|
+
class LRUCache {
|
|
4589
|
+
#max;
|
|
4590
|
+
#maxSize;
|
|
4591
|
+
#dispose;
|
|
4592
|
+
#disposeAfter;
|
|
4593
|
+
#fetchMethod;
|
|
4594
|
+
#memoMethod;
|
|
4555
4595
|
ttl;
|
|
4556
4596
|
ttlResolution;
|
|
4557
4597
|
ttlAutopurge;
|
|
@@ -4567,613 +4607,823 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
4567
4607
|
allowStaleOnFetchAbort;
|
|
4568
4608
|
allowStaleOnFetchRejection;
|
|
4569
4609
|
ignoreFetchAbort;
|
|
4570
|
-
#
|
|
4571
|
-
#
|
|
4572
|
-
#
|
|
4573
|
-
#
|
|
4574
|
-
#
|
|
4575
|
-
#
|
|
4576
|
-
#
|
|
4577
|
-
#
|
|
4578
|
-
#
|
|
4579
|
-
#
|
|
4580
|
-
#
|
|
4581
|
-
#
|
|
4582
|
-
#
|
|
4583
|
-
#
|
|
4584
|
-
#
|
|
4585
|
-
#
|
|
4586
|
-
#
|
|
4587
|
-
|
|
4588
|
-
#j;
|
|
4589
|
-
static unsafeExposeInternals(e1) {
|
|
4610
|
+
#size;
|
|
4611
|
+
#calculatedSize;
|
|
4612
|
+
#keyMap;
|
|
4613
|
+
#keyList;
|
|
4614
|
+
#valList;
|
|
4615
|
+
#next;
|
|
4616
|
+
#prev;
|
|
4617
|
+
#head;
|
|
4618
|
+
#tail;
|
|
4619
|
+
#free;
|
|
4620
|
+
#disposed;
|
|
4621
|
+
#sizes;
|
|
4622
|
+
#starts;
|
|
4623
|
+
#ttls;
|
|
4624
|
+
#hasDispose;
|
|
4625
|
+
#hasFetchMethod;
|
|
4626
|
+
#hasDisposeAfter;
|
|
4627
|
+
static unsafeExposeInternals(c) {
|
|
4590
4628
|
return {
|
|
4591
|
-
starts:
|
|
4592
|
-
ttls:
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
prev: e1.#c,
|
|
4629
|
+
starts: c.#starts,
|
|
4630
|
+
ttls: c.#ttls,
|
|
4631
|
+
sizes: c.#sizes,
|
|
4632
|
+
keyMap: c.#keyMap,
|
|
4633
|
+
keyList: c.#keyList,
|
|
4634
|
+
valList: c.#valList,
|
|
4635
|
+
next: c.#next,
|
|
4636
|
+
prev: c.#prev,
|
|
4600
4637
|
get head () {
|
|
4601
|
-
return
|
|
4638
|
+
return c.#head;
|
|
4602
4639
|
},
|
|
4603
4640
|
get tail () {
|
|
4604
|
-
return
|
|
4641
|
+
return c.#tail;
|
|
4605
4642
|
},
|
|
4606
|
-
free:
|
|
4607
|
-
isBackgroundFetch: (
|
|
4608
|
-
backgroundFetch: (
|
|
4609
|
-
moveToTail: (
|
|
4610
|
-
indexes: (
|
|
4611
|
-
rindexes: (
|
|
4612
|
-
isStale: (
|
|
4643
|
+
free: c.#free,
|
|
4644
|
+
isBackgroundFetch: (p)=>c.#isBackgroundFetch(p),
|
|
4645
|
+
backgroundFetch: (k, index, options, context)=>c.#backgroundFetch(k, index, options, context),
|
|
4646
|
+
moveToTail: (index)=>c.#moveToTail(index),
|
|
4647
|
+
indexes: (options)=>c.#indexes(options),
|
|
4648
|
+
rindexes: (options)=>c.#rindexes(options),
|
|
4649
|
+
isStale: (index)=>c.#isStale(index)
|
|
4613
4650
|
};
|
|
4614
4651
|
}
|
|
4615
4652
|
get max() {
|
|
4616
|
-
return this.#
|
|
4653
|
+
return this.#max;
|
|
4617
4654
|
}
|
|
4618
4655
|
get maxSize() {
|
|
4619
|
-
return this.#
|
|
4656
|
+
return this.#maxSize;
|
|
4620
4657
|
}
|
|
4621
4658
|
get calculatedSize() {
|
|
4622
|
-
return this.#
|
|
4659
|
+
return this.#calculatedSize;
|
|
4623
4660
|
}
|
|
4624
4661
|
get size() {
|
|
4625
|
-
return this.#
|
|
4662
|
+
return this.#size;
|
|
4626
4663
|
}
|
|
4627
4664
|
get fetchMethod() {
|
|
4628
|
-
return this.#
|
|
4665
|
+
return this.#fetchMethod;
|
|
4629
4666
|
}
|
|
4630
4667
|
get memoMethod() {
|
|
4631
|
-
return this.#
|
|
4668
|
+
return this.#memoMethod;
|
|
4632
4669
|
}
|
|
4633
4670
|
get dispose() {
|
|
4634
|
-
return this.#
|
|
4635
|
-
}
|
|
4636
|
-
get onInsert() {
|
|
4637
|
-
return this.#D;
|
|
4671
|
+
return this.#dispose;
|
|
4638
4672
|
}
|
|
4639
4673
|
get disposeAfter() {
|
|
4640
|
-
return this.#
|
|
4641
|
-
}
|
|
4642
|
-
constructor(
|
|
4643
|
-
|
|
4644
|
-
if (
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
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
|
-
this.#
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
this
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4674
|
+
return this.#disposeAfter;
|
|
4675
|
+
}
|
|
4676
|
+
constructor(options){
|
|
4677
|
+
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;
|
|
4678
|
+
if (0 !== max && !isPosInt(max)) throw new TypeError('max option must be a nonnegative integer');
|
|
4679
|
+
const UintArray = max ? getUintArray(max) : Array;
|
|
4680
|
+
if (!UintArray) throw new Error('invalid max value: ' + max);
|
|
4681
|
+
this.#max = max;
|
|
4682
|
+
this.#maxSize = maxSize;
|
|
4683
|
+
this.maxEntrySize = maxEntrySize || this.#maxSize;
|
|
4684
|
+
this.sizeCalculation = sizeCalculation;
|
|
4685
|
+
if (this.sizeCalculation) {
|
|
4686
|
+
if (!this.#maxSize && !this.maxEntrySize) throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
|
|
4687
|
+
if ('function' != typeof this.sizeCalculation) throw new TypeError('sizeCalculation set to non-function');
|
|
4688
|
+
}
|
|
4689
|
+
if (void 0 !== memoMethod && 'function' != typeof memoMethod) throw new TypeError('memoMethod must be a function if defined');
|
|
4690
|
+
this.#memoMethod = memoMethod;
|
|
4691
|
+
if (void 0 !== fetchMethod && 'function' != typeof fetchMethod) throw new TypeError('fetchMethod must be a function if specified');
|
|
4692
|
+
this.#fetchMethod = fetchMethod;
|
|
4693
|
+
this.#hasFetchMethod = !!fetchMethod;
|
|
4694
|
+
this.#keyMap = new Map();
|
|
4695
|
+
this.#keyList = new Array(max).fill(void 0);
|
|
4696
|
+
this.#valList = new Array(max).fill(void 0);
|
|
4697
|
+
this.#next = new UintArray(max);
|
|
4698
|
+
this.#prev = new UintArray(max);
|
|
4699
|
+
this.#head = 0;
|
|
4700
|
+
this.#tail = 0;
|
|
4701
|
+
this.#free = Stack.create(max);
|
|
4702
|
+
this.#size = 0;
|
|
4703
|
+
this.#calculatedSize = 0;
|
|
4704
|
+
if ('function' == typeof dispose) this.#dispose = dispose;
|
|
4705
|
+
if ('function' == typeof disposeAfter) {
|
|
4706
|
+
this.#disposeAfter = disposeAfter;
|
|
4707
|
+
this.#disposed = [];
|
|
4708
|
+
} else {
|
|
4709
|
+
this.#disposeAfter = void 0;
|
|
4710
|
+
this.#disposed = void 0;
|
|
4711
|
+
}
|
|
4712
|
+
this.#hasDispose = !!this.#dispose;
|
|
4713
|
+
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
4714
|
+
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
4715
|
+
this.noUpdateTTL = !!noUpdateTTL;
|
|
4716
|
+
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
|
|
4717
|
+
this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
|
|
4718
|
+
this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
|
|
4719
|
+
this.ignoreFetchAbort = !!ignoreFetchAbort;
|
|
4720
|
+
if (0 !== this.maxEntrySize) {
|
|
4721
|
+
if (0 !== this.#maxSize) {
|
|
4722
|
+
if (!isPosInt(this.#maxSize)) throw new TypeError('maxSize must be a positive integer if specified');
|
|
4723
|
+
}
|
|
4724
|
+
if (!isPosInt(this.maxEntrySize)) throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
4725
|
+
this.#initializeSizeTracking();
|
|
4726
|
+
}
|
|
4727
|
+
this.allowStale = !!allowStale;
|
|
4728
|
+
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
4729
|
+
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
4730
|
+
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
4731
|
+
this.ttlResolution = isPosInt(ttlResolution) || 0 === ttlResolution ? ttlResolution : 1;
|
|
4732
|
+
this.ttlAutopurge = !!ttlAutopurge;
|
|
4733
|
+
this.ttl = ttl || 0;
|
|
4734
|
+
if (this.ttl) {
|
|
4735
|
+
if (!isPosInt(this.ttl)) throw new TypeError('ttl must be a positive integer if specified');
|
|
4736
|
+
this.#initializeTTLTracking();
|
|
4737
|
+
}
|
|
4738
|
+
if (0 === this.#max && 0 === this.ttl && 0 === this.#maxSize) throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
4739
|
+
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
4740
|
+
const code = 'LRU_CACHE_UNBOUNDED';
|
|
4741
|
+
if (shouldWarn(code)) {
|
|
4742
|
+
warned.add(code);
|
|
4743
|
+
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
4744
|
+
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4748
|
+
getRemainingTTL(key) {
|
|
4749
|
+
return this.#keyMap.has(key) ? 1 / 0 : 0;
|
|
4750
|
+
}
|
|
4751
|
+
#initializeTTLTracking() {
|
|
4752
|
+
const ttls = new ZeroArray(this.#max);
|
|
4753
|
+
const starts = new ZeroArray(this.#max);
|
|
4754
|
+
this.#ttls = ttls;
|
|
4755
|
+
this.#starts = starts;
|
|
4756
|
+
this.#setItemTTL = (index, ttl, start = perf.now())=>{
|
|
4757
|
+
starts[index] = 0 !== ttl ? start : 0;
|
|
4758
|
+
ttls[index] = ttl;
|
|
4759
|
+
if (0 !== ttl && this.ttlAutopurge) {
|
|
4760
|
+
const t1 = setTimeout(()=>{
|
|
4761
|
+
if (this.#isStale(index)) this.#delete(this.#keyList[index], 'expire');
|
|
4762
|
+
}, ttl + 1);
|
|
4763
|
+
if (t1.unref) t1.unref();
|
|
4764
|
+
}
|
|
4686
4765
|
};
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
let f = r.now - c;
|
|
4701
|
-
r.remainingTTL = l - f;
|
|
4766
|
+
this.#updateItemAge = (index)=>{
|
|
4767
|
+
starts[index] = 0 !== ttls[index] ? perf.now() : 0;
|
|
4768
|
+
};
|
|
4769
|
+
this.#statusTTL = (status, index)=>{
|
|
4770
|
+
if (ttls[index]) {
|
|
4771
|
+
const ttl = ttls[index];
|
|
4772
|
+
const start = starts[index];
|
|
4773
|
+
if (!ttl || !start) return;
|
|
4774
|
+
status.ttl = ttl;
|
|
4775
|
+
status.start = start;
|
|
4776
|
+
status.now = cachedNow || getNow();
|
|
4777
|
+
const age = status.now - start;
|
|
4778
|
+
status.remainingTTL = ttl - age;
|
|
4702
4779
|
}
|
|
4703
4780
|
};
|
|
4704
|
-
let
|
|
4705
|
-
|
|
4781
|
+
let cachedNow = 0;
|
|
4782
|
+
const getNow = ()=>{
|
|
4783
|
+
const n = perf.now();
|
|
4706
4784
|
if (this.ttlResolution > 0) {
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4785
|
+
cachedNow = n;
|
|
4786
|
+
const t1 = setTimeout(()=>cachedNow = 0, this.ttlResolution);
|
|
4787
|
+
if (t1.unref) t1.unref();
|
|
4710
4788
|
}
|
|
4711
|
-
return
|
|
4789
|
+
return n;
|
|
4790
|
+
};
|
|
4791
|
+
this.getRemainingTTL = (key)=>{
|
|
4792
|
+
const index = this.#keyMap.get(key);
|
|
4793
|
+
if (void 0 === index) return 0;
|
|
4794
|
+
const ttl = ttls[index];
|
|
4795
|
+
const start = starts[index];
|
|
4796
|
+
if (!ttl || !start) return 1 / 0;
|
|
4797
|
+
const age = (cachedNow || getNow()) - start;
|
|
4798
|
+
return ttl - age;
|
|
4712
4799
|
};
|
|
4713
|
-
this
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
if (!l || !c) return 1 / 0;
|
|
4718
|
-
let f = (n || o()) - c;
|
|
4719
|
-
return l - f;
|
|
4720
|
-
}, this.#p = (r)=>{
|
|
4721
|
-
let h = t1[r], l = e1[r];
|
|
4722
|
-
return !!l && !!h && (n || o()) - h > l;
|
|
4800
|
+
this.#isStale = (index)=>{
|
|
4801
|
+
const s = starts[index];
|
|
4802
|
+
const t1 = ttls[index];
|
|
4803
|
+
return !!t1 && !!s && (cachedNow || getNow()) - s > t1;
|
|
4723
4804
|
};
|
|
4724
4805
|
}
|
|
4725
|
-
#
|
|
4726
|
-
#
|
|
4727
|
-
#
|
|
4728
|
-
#
|
|
4729
|
-
#
|
|
4730
|
-
|
|
4731
|
-
this.#
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4806
|
+
#updateItemAge = ()=>{};
|
|
4807
|
+
#statusTTL = ()=>{};
|
|
4808
|
+
#setItemTTL = ()=>{};
|
|
4809
|
+
#isStale = ()=>false;
|
|
4810
|
+
#initializeSizeTracking() {
|
|
4811
|
+
const sizes = new ZeroArray(this.#max);
|
|
4812
|
+
this.#calculatedSize = 0;
|
|
4813
|
+
this.#sizes = sizes;
|
|
4814
|
+
this.#removeItemSize = (index)=>{
|
|
4815
|
+
this.#calculatedSize -= sizes[index];
|
|
4816
|
+
sizes[index] = 0;
|
|
4817
|
+
};
|
|
4818
|
+
this.#requireSize = (k, v, size, sizeCalculation)=>{
|
|
4819
|
+
if (this.#isBackgroundFetch(v)) return 0;
|
|
4820
|
+
if (!isPosInt(size)) if (sizeCalculation) {
|
|
4821
|
+
if ('function' != typeof sizeCalculation) throw new TypeError('sizeCalculation must be a function');
|
|
4822
|
+
size = sizeCalculation(v, k);
|
|
4823
|
+
if (!isPosInt(size)) throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
4738
4824
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
4739
|
-
return
|
|
4740
|
-
}
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4825
|
+
return size;
|
|
4826
|
+
};
|
|
4827
|
+
this.#addItemSize = (index, size, status)=>{
|
|
4828
|
+
sizes[index] = size;
|
|
4829
|
+
if (this.#maxSize) {
|
|
4830
|
+
const maxSize = this.#maxSize - sizes[index];
|
|
4831
|
+
while(this.#calculatedSize > maxSize)this.#evict(true);
|
|
4832
|
+
}
|
|
4833
|
+
this.#calculatedSize += sizes[index];
|
|
4834
|
+
if (status) {
|
|
4835
|
+
status.entrySize = size;
|
|
4836
|
+
status.totalCalculatedSize = this.#calculatedSize;
|
|
4744
4837
|
}
|
|
4745
|
-
this.#b += e1[t1], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
4746
4838
|
};
|
|
4747
4839
|
}
|
|
4748
|
-
#
|
|
4749
|
-
#
|
|
4750
|
-
#
|
|
4751
|
-
if (
|
|
4840
|
+
#removeItemSize = (_i)=>{};
|
|
4841
|
+
#addItemSize = (_i, _s, _st)=>{};
|
|
4842
|
+
#requireSize = (_k, _v, size, sizeCalculation)=>{
|
|
4843
|
+
if (size || sizeCalculation) throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
|
|
4752
4844
|
return 0;
|
|
4753
4845
|
};
|
|
4754
|
-
*#
|
|
4755
|
-
if (this.#
|
|
4846
|
+
*#indexes({ allowStale = this.allowStale } = {}) {
|
|
4847
|
+
if (this.#size) for(let i = this.#tail; true;){
|
|
4848
|
+
if (!this.#isValidIndex(i)) break;
|
|
4849
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
4850
|
+
if (i === this.#head) break;
|
|
4851
|
+
i = this.#prev[i];
|
|
4852
|
+
}
|
|
4756
4853
|
}
|
|
4757
|
-
*#
|
|
4758
|
-
if (this.#
|
|
4854
|
+
*#rindexes({ allowStale = this.allowStale } = {}) {
|
|
4855
|
+
if (this.#size) for(let i = this.#head; true;){
|
|
4856
|
+
if (!this.#isValidIndex(i)) break;
|
|
4857
|
+
if (allowStale || !this.#isStale(i)) yield i;
|
|
4858
|
+
if (i === this.#tail) break;
|
|
4859
|
+
i = this.#next[i];
|
|
4860
|
+
}
|
|
4759
4861
|
}
|
|
4760
|
-
#
|
|
4761
|
-
return void 0 !==
|
|
4862
|
+
#isValidIndex(index) {
|
|
4863
|
+
return void 0 !== index && this.#keyMap.get(this.#keyList[index]) === index;
|
|
4762
4864
|
}
|
|
4763
4865
|
*entries() {
|
|
4764
|
-
for (
|
|
4765
|
-
this.#i
|
|
4766
|
-
this.#
|
|
4767
|
-
]
|
|
4866
|
+
for (const i of this.#indexes())if (void 0 !== this.#valList[i] && void 0 !== this.#keyList[i] && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
4867
|
+
this.#keyList[i],
|
|
4868
|
+
this.#valList[i]
|
|
4869
|
+
];
|
|
4768
4870
|
}
|
|
4769
4871
|
*rentries() {
|
|
4770
|
-
for (
|
|
4771
|
-
this.#i
|
|
4772
|
-
this.#
|
|
4773
|
-
]
|
|
4872
|
+
for (const i of this.#rindexes())if (void 0 !== this.#valList[i] && void 0 !== this.#keyList[i] && !this.#isBackgroundFetch(this.#valList[i])) yield [
|
|
4873
|
+
this.#keyList[i],
|
|
4874
|
+
this.#valList[i]
|
|
4875
|
+
];
|
|
4774
4876
|
}
|
|
4775
4877
|
*keys() {
|
|
4776
|
-
for (
|
|
4777
|
-
|
|
4778
|
-
void 0
|
|
4878
|
+
for (const i of this.#indexes()){
|
|
4879
|
+
const k = this.#keyList[i];
|
|
4880
|
+
if (void 0 !== k && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
4779
4881
|
}
|
|
4780
4882
|
}
|
|
4781
4883
|
*rkeys() {
|
|
4782
|
-
for (
|
|
4783
|
-
|
|
4784
|
-
void 0
|
|
4884
|
+
for (const i of this.#rindexes()){
|
|
4885
|
+
const k = this.#keyList[i];
|
|
4886
|
+
if (void 0 !== k && !this.#isBackgroundFetch(this.#valList[i])) yield k;
|
|
4785
4887
|
}
|
|
4786
4888
|
}
|
|
4787
4889
|
*values() {
|
|
4788
|
-
for (
|
|
4890
|
+
for (const i of this.#indexes()){
|
|
4891
|
+
const v = this.#valList[i];
|
|
4892
|
+
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
4893
|
+
}
|
|
4789
4894
|
}
|
|
4790
4895
|
*rvalues() {
|
|
4791
|
-
for (
|
|
4896
|
+
for (const i of this.#rindexes()){
|
|
4897
|
+
const v = this.#valList[i];
|
|
4898
|
+
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
4899
|
+
}
|
|
4792
4900
|
}
|
|
4793
4901
|
[Symbol.iterator]() {
|
|
4794
4902
|
return this.entries();
|
|
4795
4903
|
}
|
|
4796
|
-
[Symbol.toStringTag] =
|
|
4797
|
-
find(
|
|
4798
|
-
for (
|
|
4799
|
-
|
|
4800
|
-
|
|
4904
|
+
[Symbol.toStringTag] = 'LRUCache';
|
|
4905
|
+
find(fn, getOptions = {}) {
|
|
4906
|
+
for (const i of this.#indexes()){
|
|
4907
|
+
const v = this.#valList[i];
|
|
4908
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4909
|
+
if (void 0 !== value) {
|
|
4910
|
+
if (fn(value, this.#keyList[i], this)) return this.get(this.#keyList[i], getOptions);
|
|
4911
|
+
}
|
|
4801
4912
|
}
|
|
4802
4913
|
}
|
|
4803
|
-
forEach(
|
|
4804
|
-
for (
|
|
4805
|
-
|
|
4806
|
-
|
|
4914
|
+
forEach(fn, thisp = this) {
|
|
4915
|
+
for (const i of this.#indexes()){
|
|
4916
|
+
const v = this.#valList[i];
|
|
4917
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4918
|
+
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
4807
4919
|
}
|
|
4808
4920
|
}
|
|
4809
|
-
rforEach(
|
|
4810
|
-
for (
|
|
4811
|
-
|
|
4812
|
-
|
|
4921
|
+
rforEach(fn, thisp = this) {
|
|
4922
|
+
for (const i of this.#rindexes()){
|
|
4923
|
+
const v = this.#valList[i];
|
|
4924
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4925
|
+
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
4813
4926
|
}
|
|
4814
4927
|
}
|
|
4815
4928
|
purgeStale() {
|
|
4816
|
-
let
|
|
4817
|
-
for (
|
|
4818
|
-
allowStale:
|
|
4819
|
-
}))
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4929
|
+
let deleted = false;
|
|
4930
|
+
for (const i of this.#rindexes({
|
|
4931
|
+
allowStale: true
|
|
4932
|
+
}))if (this.#isStale(i)) {
|
|
4933
|
+
this.#delete(this.#keyList[i], 'expire');
|
|
4934
|
+
deleted = true;
|
|
4935
|
+
}
|
|
4936
|
+
return deleted;
|
|
4937
|
+
}
|
|
4938
|
+
info(key) {
|
|
4939
|
+
const i = this.#keyMap.get(key);
|
|
4940
|
+
if (void 0 === i) return;
|
|
4941
|
+
const v = this.#valList[i];
|
|
4942
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4943
|
+
if (void 0 === value) return;
|
|
4944
|
+
const entry = {
|
|
4945
|
+
value
|
|
4829
4946
|
};
|
|
4830
|
-
if (this.#
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4947
|
+
if (this.#ttls && this.#starts) {
|
|
4948
|
+
const ttl = this.#ttls[i];
|
|
4949
|
+
const start = this.#starts[i];
|
|
4950
|
+
if (ttl && start) {
|
|
4951
|
+
const remain = ttl - (perf.now() - start);
|
|
4952
|
+
entry.ttl = remain;
|
|
4953
|
+
entry.start = Date.now();
|
|
4835
4954
|
}
|
|
4836
4955
|
}
|
|
4837
|
-
|
|
4956
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4957
|
+
return entry;
|
|
4838
4958
|
}
|
|
4839
4959
|
dump() {
|
|
4840
|
-
|
|
4841
|
-
for (
|
|
4842
|
-
allowStale:
|
|
4960
|
+
const arr = [];
|
|
4961
|
+
for (const i of this.#indexes({
|
|
4962
|
+
allowStale: true
|
|
4843
4963
|
})){
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4964
|
+
const key = this.#keyList[i];
|
|
4965
|
+
const v = this.#valList[i];
|
|
4966
|
+
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
4967
|
+
if (void 0 === value || void 0 === key) continue;
|
|
4968
|
+
const entry = {
|
|
4969
|
+
value
|
|
4848
4970
|
};
|
|
4849
|
-
if (this.#
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
}
|
|
4854
|
-
this.#
|
|
4855
|
-
|
|
4856
|
-
|
|
4971
|
+
if (this.#ttls && this.#starts) {
|
|
4972
|
+
entry.ttl = this.#ttls[i];
|
|
4973
|
+
const age = perf.now() - this.#starts[i];
|
|
4974
|
+
entry.start = Math.floor(Date.now() - age);
|
|
4975
|
+
}
|
|
4976
|
+
if (this.#sizes) entry.size = this.#sizes[i];
|
|
4977
|
+
arr.unshift([
|
|
4978
|
+
key,
|
|
4979
|
+
entry
|
|
4857
4980
|
]);
|
|
4858
4981
|
}
|
|
4859
|
-
return
|
|
4982
|
+
return arr;
|
|
4860
4983
|
}
|
|
4861
|
-
load(
|
|
4984
|
+
load(arr) {
|
|
4862
4985
|
this.clear();
|
|
4863
|
-
for (
|
|
4864
|
-
if (
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
}
|
|
4868
|
-
this
|
|
4869
|
-
}
|
|
4870
|
-
}
|
|
4871
|
-
set(
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
if (
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4986
|
+
for (const [key, entry] of arr){
|
|
4987
|
+
if (entry.start) {
|
|
4988
|
+
const age = Date.now() - entry.start;
|
|
4989
|
+
entry.start = perf.now() - age;
|
|
4990
|
+
}
|
|
4991
|
+
this.set(key, entry.value, entry);
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
set(k, v, setOptions = {}) {
|
|
4995
|
+
if (void 0 === v) {
|
|
4996
|
+
this.delete(k);
|
|
4997
|
+
return this;
|
|
4998
|
+
}
|
|
4999
|
+
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
|
|
5000
|
+
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
5001
|
+
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
|
|
5002
|
+
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
5003
|
+
if (status) {
|
|
5004
|
+
status.set = 'miss';
|
|
5005
|
+
status.maxEntrySizeExceeded = true;
|
|
5006
|
+
}
|
|
5007
|
+
this.#delete(k, 'set');
|
|
5008
|
+
return this;
|
|
5009
|
+
}
|
|
5010
|
+
let index = 0 === this.#size ? void 0 : this.#keyMap.get(k);
|
|
5011
|
+
if (void 0 === index) {
|
|
5012
|
+
index = 0 === this.#size ? this.#tail : 0 !== this.#free.length ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
|
|
5013
|
+
this.#keyList[index] = k;
|
|
5014
|
+
this.#valList[index] = v;
|
|
5015
|
+
this.#keyMap.set(k, index);
|
|
5016
|
+
this.#next[this.#tail] = index;
|
|
5017
|
+
this.#prev[index] = this.#tail;
|
|
5018
|
+
this.#tail = index;
|
|
5019
|
+
this.#size++;
|
|
5020
|
+
this.#addItemSize(index, size, status);
|
|
5021
|
+
if (status) status.set = 'add';
|
|
5022
|
+
noUpdateTTL = false;
|
|
5023
|
+
} else {
|
|
5024
|
+
this.#moveToTail(index);
|
|
5025
|
+
const oldVal = this.#valList[index];
|
|
5026
|
+
if (v !== oldVal) {
|
|
5027
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
|
|
5028
|
+
oldVal.__abortController.abort(new Error('replaced'));
|
|
5029
|
+
const { __staleWhileFetching: s } = oldVal;
|
|
5030
|
+
if (void 0 !== s && !noDisposeOnSet) {
|
|
5031
|
+
if (this.#hasDispose) this.#dispose?.(s, k, 'set');
|
|
5032
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5033
|
+
s,
|
|
5034
|
+
k,
|
|
5035
|
+
'set'
|
|
5036
|
+
]);
|
|
5037
|
+
}
|
|
5038
|
+
} else if (!noDisposeOnSet) {
|
|
5039
|
+
if (this.#hasDispose) this.#dispose?.(oldVal, k, 'set');
|
|
5040
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5041
|
+
oldVal,
|
|
5042
|
+
k,
|
|
5043
|
+
'set'
|
|
5044
|
+
]);
|
|
5045
|
+
}
|
|
5046
|
+
this.#removeItemSize(index);
|
|
5047
|
+
this.#addItemSize(index, size, status);
|
|
5048
|
+
this.#valList[index] = v;
|
|
5049
|
+
if (status) {
|
|
5050
|
+
status.set = 'replace';
|
|
5051
|
+
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
|
|
5052
|
+
if (void 0 !== oldValue) status.oldValue = oldValue;
|
|
4907
5053
|
}
|
|
4908
|
-
} else
|
|
4909
|
-
this.#j && this.onInsert?.(t1, e1, t1 === g ? "update" : "replace");
|
|
5054
|
+
} else if (status) status.set = 'update';
|
|
4910
5055
|
}
|
|
4911
|
-
if (0
|
|
4912
|
-
|
|
4913
|
-
|
|
5056
|
+
if (0 !== ttl && !this.#ttls) this.#initializeTTLTracking();
|
|
5057
|
+
if (this.#ttls) {
|
|
5058
|
+
if (!noUpdateTTL) this.#setItemTTL(index, ttl, start);
|
|
5059
|
+
if (status) this.#statusTTL(status, index);
|
|
5060
|
+
}
|
|
5061
|
+
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
5062
|
+
const dt = this.#disposed;
|
|
5063
|
+
let task;
|
|
5064
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4914
5065
|
}
|
|
4915
5066
|
return this;
|
|
4916
5067
|
}
|
|
4917
5068
|
pop() {
|
|
4918
5069
|
try {
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
5070
|
+
while(this.#size){
|
|
5071
|
+
const val = this.#valList[this.#head];
|
|
5072
|
+
this.#evict(true);
|
|
5073
|
+
if (this.#isBackgroundFetch(val)) {
|
|
5074
|
+
if (val.__staleWhileFetching) return val.__staleWhileFetching;
|
|
5075
|
+
} else if (void 0 !== val) return val;
|
|
4924
5076
|
}
|
|
4925
5077
|
} finally{
|
|
4926
|
-
if (this.#
|
|
4927
|
-
|
|
4928
|
-
|
|
5078
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
5079
|
+
const dt = this.#disposed;
|
|
5080
|
+
let task;
|
|
5081
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
4929
5082
|
}
|
|
4930
5083
|
}
|
|
4931
5084
|
}
|
|
4932
|
-
#
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
4945
|
-
}
|
|
4946
|
-
#Y(e1, t1 = {}) {
|
|
4947
|
-
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t1, n = this.#s.get(e1);
|
|
4948
|
-
if (void 0 !== n) {
|
|
4949
|
-
let o = this.#t[n];
|
|
4950
|
-
if (this.#e(o) && void 0 === o.__staleWhileFetching) return !1;
|
|
4951
|
-
if (!this.#p(n)) return i && this.#x(n), s && (s.has = "hit", this.#E(s, n)), !0;
|
|
4952
|
-
s && (s.has = "stale", this.#E(s, n));
|
|
4953
|
-
} else s && (s.has = "miss");
|
|
4954
|
-
return !1;
|
|
4955
|
-
}
|
|
4956
|
-
peek(e1, t1 = {}) {
|
|
4957
|
-
let { status: i = D() ? {} : void 0 } = t1;
|
|
4958
|
-
i && (i.op = "peek", i.key = e1), t1.status = i;
|
|
4959
|
-
let s = this.#J(e1, t1);
|
|
4960
|
-
return S.hasSubscribers && S.publish(i), s;
|
|
4961
|
-
}
|
|
4962
|
-
#J(e1, t1) {
|
|
4963
|
-
let { status: i, allowStale: s = this.allowStale } = t1, n = this.#s.get(e1);
|
|
4964
|
-
if (void 0 === n || !s && this.#p(n)) {
|
|
4965
|
-
i && (i.peek = void 0 === n ? "miss" : "stale");
|
|
4966
|
-
return;
|
|
5085
|
+
#evict(free) {
|
|
5086
|
+
const head = this.#head;
|
|
5087
|
+
const k = this.#keyList[head];
|
|
5088
|
+
const v = this.#valList[head];
|
|
5089
|
+
if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('evicted'));
|
|
5090
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
5091
|
+
if (this.#hasDispose) this.#dispose?.(v, k, 'evict');
|
|
5092
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5093
|
+
v,
|
|
5094
|
+
k,
|
|
5095
|
+
'evict'
|
|
5096
|
+
]);
|
|
4967
5097
|
}
|
|
4968
|
-
|
|
4969
|
-
|
|
5098
|
+
this.#removeItemSize(head);
|
|
5099
|
+
if (free) {
|
|
5100
|
+
this.#keyList[head] = void 0;
|
|
5101
|
+
this.#valList[head] = void 0;
|
|
5102
|
+
this.#free.push(head);
|
|
5103
|
+
}
|
|
5104
|
+
if (1 === this.#size) {
|
|
5105
|
+
this.#head = this.#tail = 0;
|
|
5106
|
+
this.#free.length = 0;
|
|
5107
|
+
} else this.#head = this.#next[head];
|
|
5108
|
+
this.#keyMap.delete(k);
|
|
5109
|
+
this.#size--;
|
|
5110
|
+
return head;
|
|
5111
|
+
}
|
|
5112
|
+
has(k, hasOptions = {}) {
|
|
5113
|
+
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
5114
|
+
const index = this.#keyMap.get(k);
|
|
5115
|
+
if (void 0 !== index) {
|
|
5116
|
+
const v = this.#valList[index];
|
|
5117
|
+
if (this.#isBackgroundFetch(v) && void 0 === v.__staleWhileFetching) return false;
|
|
5118
|
+
if (this.#isStale(index)) {
|
|
5119
|
+
if (status) {
|
|
5120
|
+
status.has = 'stale';
|
|
5121
|
+
this.#statusTTL(status, index);
|
|
5122
|
+
}
|
|
5123
|
+
} else {
|
|
5124
|
+
if (updateAgeOnHas) this.#updateItemAge(index);
|
|
5125
|
+
if (status) {
|
|
5126
|
+
status.has = 'hit';
|
|
5127
|
+
this.#statusTTL(status, index);
|
|
5128
|
+
}
|
|
5129
|
+
return true;
|
|
5130
|
+
}
|
|
5131
|
+
} else if (status) status.has = 'miss';
|
|
5132
|
+
return false;
|
|
4970
5133
|
}
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
5134
|
+
peek(k, peekOptions = {}) {
|
|
5135
|
+
const { allowStale = this.allowStale } = peekOptions;
|
|
5136
|
+
const index = this.#keyMap.get(k);
|
|
5137
|
+
if (void 0 === index || !allowStale && this.#isStale(index)) return;
|
|
5138
|
+
const v = this.#valList[index];
|
|
5139
|
+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
5140
|
+
}
|
|
5141
|
+
#backgroundFetch(k, index, options, context) {
|
|
5142
|
+
const v = void 0 === index ? void 0 : this.#valList[index];
|
|
5143
|
+
if (this.#isBackgroundFetch(v)) return v;
|
|
5144
|
+
const ac = new AC();
|
|
5145
|
+
const { signal } = options;
|
|
5146
|
+
signal?.addEventListener('abort', ()=>ac.abort(signal.reason), {
|
|
5147
|
+
signal: ac.signal
|
|
4977
5148
|
});
|
|
4978
|
-
|
|
4979
|
-
signal:
|
|
4980
|
-
options
|
|
4981
|
-
context
|
|
4982
|
-
}
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
5149
|
+
const fetchOpts = {
|
|
5150
|
+
signal: ac.signal,
|
|
5151
|
+
options,
|
|
5152
|
+
context
|
|
5153
|
+
};
|
|
5154
|
+
const cb = (v, updateCache = false)=>{
|
|
5155
|
+
const { aborted } = ac.signal;
|
|
5156
|
+
const ignoreAbort = options.ignoreFetchAbort && void 0 !== v;
|
|
5157
|
+
if (options.status) if (aborted && !updateCache) {
|
|
5158
|
+
options.status.fetchAborted = true;
|
|
5159
|
+
options.status.fetchError = ac.signal.reason;
|
|
5160
|
+
if (ignoreAbort) options.status.fetchAbortIgnored = true;
|
|
5161
|
+
} else options.status.fetchResolved = true;
|
|
5162
|
+
if (aborted && !ignoreAbort && !updateCache) return fetchFail(ac.signal.reason);
|
|
5163
|
+
const bf = p;
|
|
5164
|
+
if (this.#valList[index] === p) if (void 0 === v) if (bf.__staleWhileFetching) this.#valList[index] = bf.__staleWhileFetching;
|
|
5165
|
+
else this.#delete(k, 'fetch');
|
|
5166
|
+
else {
|
|
5167
|
+
if (options.status) options.status.fetchUpdated = true;
|
|
5168
|
+
this.set(k, v, fetchOpts.options);
|
|
5169
|
+
}
|
|
5170
|
+
return v;
|
|
5171
|
+
};
|
|
5172
|
+
const eb = (er)=>{
|
|
5173
|
+
if (options.status) {
|
|
5174
|
+
options.status.fetchRejected = true;
|
|
5175
|
+
options.status.fetchError = er;
|
|
5176
|
+
}
|
|
5177
|
+
return fetchFail(er);
|
|
5178
|
+
};
|
|
5179
|
+
const fetchFail = (er)=>{
|
|
5180
|
+
const { aborted } = ac.signal;
|
|
5181
|
+
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
5182
|
+
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
5183
|
+
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
5184
|
+
const bf = p;
|
|
5185
|
+
if (this.#valList[index] === p) {
|
|
5186
|
+
const del = !noDelete || void 0 === bf.__staleWhileFetching;
|
|
5187
|
+
if (del) this.#delete(k, 'fetch');
|
|
5188
|
+
else if (!allowStaleAborted) this.#valList[index] = bf.__staleWhileFetching;
|
|
5189
|
+
}
|
|
5190
|
+
if (allowStale) {
|
|
5191
|
+
if (options.status && void 0 !== bf.__staleWhileFetching) options.status.returnedStale = true;
|
|
5192
|
+
return bf.__staleWhileFetching;
|
|
5193
|
+
}
|
|
5194
|
+
if (bf.__returned === bf) throw er;
|
|
5195
|
+
};
|
|
5196
|
+
const pcall = (res, rej)=>{
|
|
5197
|
+
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
5198
|
+
if (fmp && fmp instanceof Promise) fmp.then((v)=>res(void 0 === v ? void 0 : v), rej);
|
|
5199
|
+
ac.signal.addEventListener('abort', ()=>{
|
|
5200
|
+
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
|
5201
|
+
res(void 0);
|
|
5202
|
+
if (options.allowStaleOnFetchAbort) res = (v)=>cb(v, true);
|
|
5203
|
+
}
|
|
4995
5204
|
});
|
|
4996
5205
|
};
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5206
|
+
if (options.status) options.status.fetchDispatched = true;
|
|
5207
|
+
const p = new Promise(pcall).then(cb, eb);
|
|
5208
|
+
const bf = Object.assign(p, {
|
|
5209
|
+
__abortController: ac,
|
|
5210
|
+
__staleWhileFetching: v,
|
|
5001
5211
|
__returned: void 0
|
|
5002
5212
|
});
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5213
|
+
if (void 0 === index) {
|
|
5214
|
+
this.set(k, bf, {
|
|
5215
|
+
...fetchOpts.options,
|
|
5216
|
+
status: void 0
|
|
5217
|
+
});
|
|
5218
|
+
index = this.#keyMap.get(k);
|
|
5219
|
+
} else this.#valList[index] = bf;
|
|
5220
|
+
return bf;
|
|
5221
|
+
}
|
|
5222
|
+
#isBackgroundFetch(p) {
|
|
5223
|
+
if (!this.#hasFetchMethod) return false;
|
|
5224
|
+
const b = p;
|
|
5225
|
+
return !!b && b instanceof Promise && b.hasOwnProperty('__staleWhileFetching') && b.__abortController instanceof AC;
|
|
5226
|
+
}
|
|
5227
|
+
async fetch(k, fetchOptions = {}) {
|
|
5228
|
+
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;
|
|
5229
|
+
if (!this.#hasFetchMethod) {
|
|
5230
|
+
if (status) status.fetch = 'get';
|
|
5231
|
+
return this.get(k, {
|
|
5232
|
+
allowStale,
|
|
5233
|
+
updateAgeOnGet,
|
|
5234
|
+
noDeleteOnStaleGet,
|
|
5235
|
+
status
|
|
5236
|
+
});
|
|
5237
|
+
}
|
|
5238
|
+
const options = {
|
|
5239
|
+
allowStale,
|
|
5240
|
+
updateAgeOnGet,
|
|
5241
|
+
noDeleteOnStaleGet,
|
|
5242
|
+
ttl,
|
|
5243
|
+
noDisposeOnSet,
|
|
5244
|
+
size,
|
|
5245
|
+
sizeCalculation,
|
|
5246
|
+
noUpdateTTL,
|
|
5247
|
+
noDeleteOnFetchRejection,
|
|
5248
|
+
allowStaleOnFetchRejection,
|
|
5249
|
+
allowStaleOnFetchAbort,
|
|
5250
|
+
ignoreFetchAbort,
|
|
5251
|
+
status,
|
|
5252
|
+
signal
|
|
5253
|
+
};
|
|
5254
|
+
let index = this.#keyMap.get(k);
|
|
5255
|
+
if (void 0 === index) {
|
|
5256
|
+
if (status) status.fetch = 'miss';
|
|
5257
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
5258
|
+
return p.__returned = p;
|
|
5047
5259
|
}
|
|
5048
5260
|
{
|
|
5049
|
-
|
|
5050
|
-
if (this.#
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
}
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
if (
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5261
|
+
const v = this.#valList[index];
|
|
5262
|
+
if (this.#isBackgroundFetch(v)) {
|
|
5263
|
+
const stale = allowStale && void 0 !== v.__staleWhileFetching;
|
|
5264
|
+
if (status) {
|
|
5265
|
+
status.fetch = 'inflight';
|
|
5266
|
+
if (stale) status.returnedStale = true;
|
|
5267
|
+
}
|
|
5268
|
+
return stale ? v.__staleWhileFetching : v.__returned = v;
|
|
5269
|
+
}
|
|
5270
|
+
const isStale = this.#isStale(index);
|
|
5271
|
+
if (!forceRefresh && !isStale) {
|
|
5272
|
+
if (status) status.fetch = 'hit';
|
|
5273
|
+
this.#moveToTail(index);
|
|
5274
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
5275
|
+
if (status) this.#statusTTL(status, index);
|
|
5276
|
+
return v;
|
|
5277
|
+
}
|
|
5278
|
+
const p = this.#backgroundFetch(k, index, options, context);
|
|
5279
|
+
const hasStale = void 0 !== p.__staleWhileFetching;
|
|
5280
|
+
const staleVal = hasStale && allowStale;
|
|
5281
|
+
if (status) {
|
|
5282
|
+
status.fetch = isStale ? 'stale' : 'refresh';
|
|
5283
|
+
if (staleVal && isStale) status.returnedStale = true;
|
|
5284
|
+
}
|
|
5285
|
+
return staleVal ? p.__staleWhileFetching : p.__returned = p;
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
async forceFetch(k, fetchOptions = {}) {
|
|
5289
|
+
const v = await this.fetch(k, fetchOptions);
|
|
5290
|
+
if (void 0 === v) throw new Error('fetch() returned undefined');
|
|
5291
|
+
return v;
|
|
5292
|
+
}
|
|
5293
|
+
memo(k, memoOptions = {}) {
|
|
5294
|
+
const memoMethod = this.#memoMethod;
|
|
5295
|
+
if (!memoMethod) throw new Error('no memoMethod provided to constructor');
|
|
5296
|
+
const { context, forceRefresh, ...options } = memoOptions;
|
|
5297
|
+
const v = this.get(k, options);
|
|
5298
|
+
if (!forceRefresh && void 0 !== v) return v;
|
|
5299
|
+
const vv = memoMethod(k, v, {
|
|
5300
|
+
options,
|
|
5301
|
+
context
|
|
5087
5302
|
});
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5303
|
+
this.set(k, vv, options);
|
|
5304
|
+
return vv;
|
|
5305
|
+
}
|
|
5306
|
+
get(k, getOptions = {}) {
|
|
5307
|
+
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
|
|
5308
|
+
const index = this.#keyMap.get(k);
|
|
5309
|
+
if (void 0 !== index) {
|
|
5310
|
+
const value = this.#valList[index];
|
|
5311
|
+
const fetching = this.#isBackgroundFetch(value);
|
|
5312
|
+
if (status) this.#statusTTL(status, index);
|
|
5313
|
+
if (this.#isStale(index)) {
|
|
5314
|
+
if (status) status.get = 'stale';
|
|
5315
|
+
if (fetching) {
|
|
5316
|
+
if (status && allowStale && void 0 !== value.__staleWhileFetching) status.returnedStale = true;
|
|
5317
|
+
return allowStale ? value.__staleWhileFetching : void 0;
|
|
5318
|
+
}
|
|
5319
|
+
if (!noDeleteOnStaleGet) this.#delete(k, 'expire');
|
|
5320
|
+
if (status && allowStale) status.returnedStale = true;
|
|
5321
|
+
return allowStale ? value : void 0;
|
|
5322
|
+
}
|
|
5323
|
+
if (status) status.get = 'hit';
|
|
5324
|
+
if (fetching) return value.__staleWhileFetching;
|
|
5325
|
+
this.#moveToTail(index);
|
|
5326
|
+
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
5327
|
+
return value;
|
|
5101
5328
|
}
|
|
5102
|
-
|
|
5103
|
-
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);
|
|
5329
|
+
if (status) status.get = 'miss';
|
|
5104
5330
|
}
|
|
5105
|
-
|
|
5106
|
-
this.#
|
|
5331
|
+
#connect(p, n) {
|
|
5332
|
+
this.#prev[n] = p;
|
|
5333
|
+
this.#next[p] = n;
|
|
5107
5334
|
}
|
|
5108
|
-
#
|
|
5109
|
-
|
|
5335
|
+
#moveToTail(index) {
|
|
5336
|
+
if (index !== this.#tail) {
|
|
5337
|
+
if (index === this.#head) this.#head = this.#next[index];
|
|
5338
|
+
else this.#connect(this.#prev[index], this.#next[index]);
|
|
5339
|
+
this.#connect(this.#tail, index);
|
|
5340
|
+
this.#tail = index;
|
|
5341
|
+
}
|
|
5110
5342
|
}
|
|
5111
|
-
delete(
|
|
5112
|
-
return this.#
|
|
5343
|
+
delete(k) {
|
|
5344
|
+
return this.#delete(k, 'delete');
|
|
5113
5345
|
}
|
|
5114
|
-
#
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
if (0 !== this.#n) {
|
|
5122
|
-
let s = this.#s.get(e1);
|
|
5123
|
-
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);
|
|
5124
|
-
else {
|
|
5125
|
-
this.#R(s);
|
|
5126
|
-
let n = this.#t[s];
|
|
5127
|
-
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([
|
|
5128
|
-
n,
|
|
5129
|
-
e1,
|
|
5130
|
-
t1
|
|
5131
|
-
])), this.#s.delete(e1), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
|
|
5132
|
-
else if (s === this.#l) this.#l = this.#a[s];
|
|
5346
|
+
#delete(k, reason) {
|
|
5347
|
+
let deleted = false;
|
|
5348
|
+
if (0 !== this.#size) {
|
|
5349
|
+
const index = this.#keyMap.get(k);
|
|
5350
|
+
if (void 0 !== index) {
|
|
5351
|
+
deleted = true;
|
|
5352
|
+
if (1 === this.#size) this.#clear(reason);
|
|
5133
5353
|
else {
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
this.#
|
|
5354
|
+
this.#removeItemSize(index);
|
|
5355
|
+
const v = this.#valList[index];
|
|
5356
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5357
|
+
else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
5358
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
5359
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5360
|
+
v,
|
|
5361
|
+
k,
|
|
5362
|
+
reason
|
|
5363
|
+
]);
|
|
5364
|
+
}
|
|
5365
|
+
this.#keyMap.delete(k);
|
|
5366
|
+
this.#keyList[index] = void 0;
|
|
5367
|
+
this.#valList[index] = void 0;
|
|
5368
|
+
if (index === this.#tail) this.#tail = this.#prev[index];
|
|
5369
|
+
else if (index === this.#head) this.#head = this.#next[index];
|
|
5370
|
+
else {
|
|
5371
|
+
const pi = this.#prev[index];
|
|
5372
|
+
this.#next[pi] = this.#next[index];
|
|
5373
|
+
const ni = this.#next[index];
|
|
5374
|
+
this.#prev[ni] = this.#prev[index];
|
|
5375
|
+
}
|
|
5376
|
+
this.#size--;
|
|
5377
|
+
this.#free.push(index);
|
|
5138
5378
|
}
|
|
5139
|
-
this.#n--, this.#y.push(s);
|
|
5140
5379
|
}
|
|
5141
5380
|
}
|
|
5142
|
-
if (this.#
|
|
5143
|
-
|
|
5144
|
-
|
|
5381
|
+
if (this.#hasDisposeAfter && this.#disposed?.length) {
|
|
5382
|
+
const dt = this.#disposed;
|
|
5383
|
+
let task;
|
|
5384
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5145
5385
|
}
|
|
5146
|
-
return
|
|
5386
|
+
return deleted;
|
|
5147
5387
|
}
|
|
5148
5388
|
clear() {
|
|
5149
|
-
return this.#
|
|
5389
|
+
return this.#clear('delete');
|
|
5150
5390
|
}
|
|
5151
|
-
#
|
|
5152
|
-
for (
|
|
5153
|
-
allowStale:
|
|
5391
|
+
#clear(reason) {
|
|
5392
|
+
for (const index of this.#rindexes({
|
|
5393
|
+
allowStale: true
|
|
5154
5394
|
})){
|
|
5155
|
-
|
|
5156
|
-
if (this.#
|
|
5395
|
+
const v = this.#valList[index];
|
|
5396
|
+
if (this.#isBackgroundFetch(v)) v.__abortController.abort(new Error('deleted'));
|
|
5157
5397
|
else {
|
|
5158
|
-
|
|
5159
|
-
this.#
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5398
|
+
const k = this.#keyList[index];
|
|
5399
|
+
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
5400
|
+
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5401
|
+
v,
|
|
5402
|
+
k,
|
|
5403
|
+
reason
|
|
5163
5404
|
]);
|
|
5164
5405
|
}
|
|
5165
5406
|
}
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5407
|
+
this.#keyMap.clear();
|
|
5408
|
+
this.#valList.fill(void 0);
|
|
5409
|
+
this.#keyList.fill(void 0);
|
|
5410
|
+
if (this.#ttls && this.#starts) {
|
|
5411
|
+
this.#ttls.fill(0);
|
|
5412
|
+
this.#starts.fill(0);
|
|
5170
5413
|
}
|
|
5171
|
-
if (this.#
|
|
5172
|
-
|
|
5173
|
-
|
|
5414
|
+
if (this.#sizes) this.#sizes.fill(0);
|
|
5415
|
+
this.#head = 0;
|
|
5416
|
+
this.#tail = 0;
|
|
5417
|
+
this.#free.length = 0;
|
|
5418
|
+
this.#calculatedSize = 0;
|
|
5419
|
+
this.#size = 0;
|
|
5420
|
+
if (this.#hasDisposeAfter && this.#disposed) {
|
|
5421
|
+
const dt = this.#disposed;
|
|
5422
|
+
let task;
|
|
5423
|
+
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5174
5424
|
}
|
|
5175
5425
|
}
|
|
5176
|
-
}
|
|
5426
|
+
}
|
|
5177
5427
|
var external_fs_ = __webpack_require__("fs");
|
|
5178
5428
|
const promises_namespaceObject = require("node:fs/promises");
|
|
5179
5429
|
const external_node_events_namespaceObject = require("node:events");
|
|
@@ -5250,7 +5500,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
5250
5500
|
}
|
|
5251
5501
|
constructor(src, dest, opts){
|
|
5252
5502
|
super(src, dest, opts);
|
|
5253
|
-
this.proxyErrors = (er)=>
|
|
5503
|
+
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
5254
5504
|
src.on('error', this.proxyErrors);
|
|
5255
5505
|
}
|
|
5256
5506
|
}
|
|
@@ -5702,8 +5952,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
5702
5952
|
return: stop,
|
|
5703
5953
|
[Symbol.asyncIterator] () {
|
|
5704
5954
|
return this;
|
|
5705
|
-
}
|
|
5706
|
-
[Symbol.asyncDispose]: async ()=>{}
|
|
5955
|
+
}
|
|
5707
5956
|
};
|
|
5708
5957
|
}
|
|
5709
5958
|
[Symbol.iterator]() {
|
|
@@ -5737,8 +5986,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
5737
5986
|
return: stop,
|
|
5738
5987
|
[Symbol.iterator] () {
|
|
5739
5988
|
return this;
|
|
5740
|
-
}
|
|
5741
|
-
[Symbol.dispose]: ()=>{}
|
|
5989
|
+
}
|
|
5742
5990
|
};
|
|
5743
5991
|
}
|
|
5744
5992
|
destroy(er) {
|
|
@@ -5821,14 +6069,14 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
5821
6069
|
normalizeNocaseCache.set(s, n);
|
|
5822
6070
|
return n;
|
|
5823
6071
|
};
|
|
5824
|
-
class ResolveCache extends
|
|
6072
|
+
class ResolveCache extends LRUCache {
|
|
5825
6073
|
constructor(){
|
|
5826
6074
|
super({
|
|
5827
6075
|
max: 256
|
|
5828
6076
|
});
|
|
5829
6077
|
}
|
|
5830
6078
|
}
|
|
5831
|
-
class ChildrenCache extends
|
|
6079
|
+
class ChildrenCache extends LRUCache {
|
|
5832
6080
|
constructor(maxSize = 16384){
|
|
5833
6081
|
super({
|
|
5834
6082
|
maxSize,
|
|
@@ -6971,586 +7219,6 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
6971
7219
|
return true;
|
|
6972
7220
|
}
|
|
6973
7221
|
}
|
|
6974
|
-
const esm_proc = 'object' == typeof process && process ? process : {
|
|
6975
|
-
stdout: null,
|
|
6976
|
-
stderr: null
|
|
6977
|
-
};
|
|
6978
|
-
const esm_isStream = (s)=>!!s && 'object' == typeof s && (s instanceof esm_Minipass || s instanceof external_node_stream_namespaceObject || esm_isReadable(s) || esm_isWritable(s));
|
|
6979
|
-
const esm_isReadable = (s)=>!!s && 'object' == typeof s && s instanceof external_node_events_namespaceObject.EventEmitter && 'function' == typeof s.pipe && s.pipe !== external_node_stream_namespaceObject.Writable.prototype.pipe;
|
|
6980
|
-
const esm_isWritable = (s)=>!!s && 'object' == typeof s && s instanceof external_node_events_namespaceObject.EventEmitter && 'function' == typeof s.write && 'function' == typeof s.end;
|
|
6981
|
-
const esm_EOF = Symbol('EOF');
|
|
6982
|
-
const esm_MAYBE_EMIT_END = Symbol('maybeEmitEnd');
|
|
6983
|
-
const esm_EMITTED_END = Symbol('emittedEnd');
|
|
6984
|
-
const esm_EMITTING_END = Symbol('emittingEnd');
|
|
6985
|
-
const esm_EMITTED_ERROR = Symbol('emittedError');
|
|
6986
|
-
const esm_CLOSED = Symbol('closed');
|
|
6987
|
-
const esm_READ = Symbol('read');
|
|
6988
|
-
const esm_FLUSH = Symbol('flush');
|
|
6989
|
-
const esm_FLUSHCHUNK = Symbol('flushChunk');
|
|
6990
|
-
const esm_ENCODING = Symbol('encoding');
|
|
6991
|
-
const esm_DECODER = Symbol('decoder');
|
|
6992
|
-
const esm_FLOWING = Symbol('flowing');
|
|
6993
|
-
const esm_PAUSED = Symbol('paused');
|
|
6994
|
-
const esm_RESUME = Symbol('resume');
|
|
6995
|
-
const esm_BUFFER = Symbol('buffer');
|
|
6996
|
-
const esm_PIPES = Symbol('pipes');
|
|
6997
|
-
const esm_BUFFERLENGTH = Symbol('bufferLength');
|
|
6998
|
-
const esm_BUFFERPUSH = Symbol('bufferPush');
|
|
6999
|
-
const esm_BUFFERSHIFT = Symbol('bufferShift');
|
|
7000
|
-
const esm_OBJECTMODE = Symbol('objectMode');
|
|
7001
|
-
const esm_DESTROYED = Symbol('destroyed');
|
|
7002
|
-
const esm_ERROR = Symbol('error');
|
|
7003
|
-
const esm_EMITDATA = Symbol('emitData');
|
|
7004
|
-
const esm_EMITEND = Symbol('emitEnd');
|
|
7005
|
-
const esm_EMITEND2 = Symbol('emitEnd2');
|
|
7006
|
-
const esm_ASYNC = Symbol('async');
|
|
7007
|
-
const esm_ABORT = Symbol('abort');
|
|
7008
|
-
const esm_ABORTED = Symbol('aborted');
|
|
7009
|
-
const esm_SIGNAL = Symbol('signal');
|
|
7010
|
-
const esm_DATALISTENERS = Symbol('dataListeners');
|
|
7011
|
-
const esm_DISCARDED = Symbol('discarded');
|
|
7012
|
-
const esm_defer = (fn)=>Promise.resolve().then(fn);
|
|
7013
|
-
const esm_nodefer = (fn)=>fn();
|
|
7014
|
-
const esm_isEndish = (ev)=>'end' === ev || 'finish' === ev || 'prefinish' === ev;
|
|
7015
|
-
const esm_isArrayBufferLike = (b)=>b instanceof ArrayBuffer || !!b && 'object' == typeof b && b.constructor && 'ArrayBuffer' === b.constructor.name && b.byteLength >= 0;
|
|
7016
|
-
const esm_isArrayBufferView = (b)=>!Buffer.isBuffer(b) && ArrayBuffer.isView(b);
|
|
7017
|
-
class esm_Pipe {
|
|
7018
|
-
src;
|
|
7019
|
-
dest;
|
|
7020
|
-
opts;
|
|
7021
|
-
ondrain;
|
|
7022
|
-
constructor(src, dest, opts){
|
|
7023
|
-
this.src = src;
|
|
7024
|
-
this.dest = dest;
|
|
7025
|
-
this.opts = opts;
|
|
7026
|
-
this.ondrain = ()=>src[esm_RESUME]();
|
|
7027
|
-
this.dest.on('drain', this.ondrain);
|
|
7028
|
-
}
|
|
7029
|
-
unpipe() {
|
|
7030
|
-
this.dest.removeListener('drain', this.ondrain);
|
|
7031
|
-
}
|
|
7032
|
-
proxyErrors(_er) {}
|
|
7033
|
-
end() {
|
|
7034
|
-
this.unpipe();
|
|
7035
|
-
if (this.opts.end) this.dest.end();
|
|
7036
|
-
}
|
|
7037
|
-
}
|
|
7038
|
-
class esm_PipeProxyErrors extends esm_Pipe {
|
|
7039
|
-
unpipe() {
|
|
7040
|
-
this.src.removeListener('error', this.proxyErrors);
|
|
7041
|
-
super.unpipe();
|
|
7042
|
-
}
|
|
7043
|
-
constructor(src, dest, opts){
|
|
7044
|
-
super(src, dest, opts);
|
|
7045
|
-
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
7046
|
-
src.on('error', this.proxyErrors);
|
|
7047
|
-
}
|
|
7048
|
-
}
|
|
7049
|
-
const esm_isObjectModeOptions = (o)=>!!o.objectMode;
|
|
7050
|
-
const esm_isEncodingOptions = (o)=>!o.objectMode && !!o.encoding && 'buffer' !== o.encoding;
|
|
7051
|
-
class esm_Minipass extends external_node_events_namespaceObject.EventEmitter {
|
|
7052
|
-
[esm_FLOWING] = false;
|
|
7053
|
-
[esm_PAUSED] = false;
|
|
7054
|
-
[esm_PIPES] = [];
|
|
7055
|
-
[esm_BUFFER] = [];
|
|
7056
|
-
[esm_OBJECTMODE];
|
|
7057
|
-
[esm_ENCODING];
|
|
7058
|
-
[esm_ASYNC];
|
|
7059
|
-
[esm_DECODER];
|
|
7060
|
-
[esm_EOF] = false;
|
|
7061
|
-
[esm_EMITTED_END] = false;
|
|
7062
|
-
[esm_EMITTING_END] = false;
|
|
7063
|
-
[esm_CLOSED] = false;
|
|
7064
|
-
[esm_EMITTED_ERROR] = null;
|
|
7065
|
-
[esm_BUFFERLENGTH] = 0;
|
|
7066
|
-
[esm_DESTROYED] = false;
|
|
7067
|
-
[esm_SIGNAL];
|
|
7068
|
-
[esm_ABORTED] = false;
|
|
7069
|
-
[esm_DATALISTENERS] = 0;
|
|
7070
|
-
[esm_DISCARDED] = false;
|
|
7071
|
-
writable = true;
|
|
7072
|
-
readable = true;
|
|
7073
|
-
constructor(...args){
|
|
7074
|
-
const options = args[0] || {};
|
|
7075
|
-
super();
|
|
7076
|
-
if (options.objectMode && 'string' == typeof options.encoding) throw new TypeError('Encoding and objectMode may not be used together');
|
|
7077
|
-
if (esm_isObjectModeOptions(options)) {
|
|
7078
|
-
this[esm_OBJECTMODE] = true;
|
|
7079
|
-
this[esm_ENCODING] = null;
|
|
7080
|
-
} else if (esm_isEncodingOptions(options)) {
|
|
7081
|
-
this[esm_ENCODING] = options.encoding;
|
|
7082
|
-
this[esm_OBJECTMODE] = false;
|
|
7083
|
-
} else {
|
|
7084
|
-
this[esm_OBJECTMODE] = false;
|
|
7085
|
-
this[esm_ENCODING] = null;
|
|
7086
|
-
}
|
|
7087
|
-
this[esm_ASYNC] = !!options.async;
|
|
7088
|
-
this[esm_DECODER] = this[esm_ENCODING] ? new external_node_string_decoder_namespaceObject.StringDecoder(this[esm_ENCODING]) : null;
|
|
7089
|
-
if (options && true === options.debugExposeBuffer) Object.defineProperty(this, 'buffer', {
|
|
7090
|
-
get: ()=>this[esm_BUFFER]
|
|
7091
|
-
});
|
|
7092
|
-
if (options && true === options.debugExposePipes) Object.defineProperty(this, 'pipes', {
|
|
7093
|
-
get: ()=>this[esm_PIPES]
|
|
7094
|
-
});
|
|
7095
|
-
const { signal } = options;
|
|
7096
|
-
if (signal) {
|
|
7097
|
-
this[esm_SIGNAL] = signal;
|
|
7098
|
-
if (signal.aborted) this[esm_ABORT]();
|
|
7099
|
-
else signal.addEventListener('abort', ()=>this[esm_ABORT]());
|
|
7100
|
-
}
|
|
7101
|
-
}
|
|
7102
|
-
get bufferLength() {
|
|
7103
|
-
return this[esm_BUFFERLENGTH];
|
|
7104
|
-
}
|
|
7105
|
-
get encoding() {
|
|
7106
|
-
return this[esm_ENCODING];
|
|
7107
|
-
}
|
|
7108
|
-
set encoding(_enc) {
|
|
7109
|
-
throw new Error('Encoding must be set at instantiation time');
|
|
7110
|
-
}
|
|
7111
|
-
setEncoding(_enc) {
|
|
7112
|
-
throw new Error('Encoding must be set at instantiation time');
|
|
7113
|
-
}
|
|
7114
|
-
get objectMode() {
|
|
7115
|
-
return this[esm_OBJECTMODE];
|
|
7116
|
-
}
|
|
7117
|
-
set objectMode(_om) {
|
|
7118
|
-
throw new Error('objectMode must be set at instantiation time');
|
|
7119
|
-
}
|
|
7120
|
-
get ['async']() {
|
|
7121
|
-
return this[esm_ASYNC];
|
|
7122
|
-
}
|
|
7123
|
-
set ['async'](a) {
|
|
7124
|
-
this[esm_ASYNC] = this[esm_ASYNC] || !!a;
|
|
7125
|
-
}
|
|
7126
|
-
[esm_ABORT]() {
|
|
7127
|
-
this[esm_ABORTED] = true;
|
|
7128
|
-
this.emit('abort', this[esm_SIGNAL]?.reason);
|
|
7129
|
-
this.destroy(this[esm_SIGNAL]?.reason);
|
|
7130
|
-
}
|
|
7131
|
-
get aborted() {
|
|
7132
|
-
return this[esm_ABORTED];
|
|
7133
|
-
}
|
|
7134
|
-
set aborted(_) {}
|
|
7135
|
-
write(chunk, encoding, cb) {
|
|
7136
|
-
if (this[esm_ABORTED]) return false;
|
|
7137
|
-
if (this[esm_EOF]) throw new Error('write after end');
|
|
7138
|
-
if (this[esm_DESTROYED]) {
|
|
7139
|
-
this.emit('error', Object.assign(new Error('Cannot call write after a stream was destroyed'), {
|
|
7140
|
-
code: 'ERR_STREAM_DESTROYED'
|
|
7141
|
-
}));
|
|
7142
|
-
return true;
|
|
7143
|
-
}
|
|
7144
|
-
if ('function' == typeof encoding) {
|
|
7145
|
-
cb = encoding;
|
|
7146
|
-
encoding = 'utf8';
|
|
7147
|
-
}
|
|
7148
|
-
if (!encoding) encoding = 'utf8';
|
|
7149
|
-
const fn = this[esm_ASYNC] ? esm_defer : esm_nodefer;
|
|
7150
|
-
if (!this[esm_OBJECTMODE] && !Buffer.isBuffer(chunk)) {
|
|
7151
|
-
if (esm_isArrayBufferView(chunk)) chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
7152
|
-
else if (esm_isArrayBufferLike(chunk)) chunk = Buffer.from(chunk);
|
|
7153
|
-
else if ('string' != typeof chunk) throw new Error('Non-contiguous data written to non-objectMode stream');
|
|
7154
|
-
}
|
|
7155
|
-
if (this[esm_OBJECTMODE]) {
|
|
7156
|
-
if (this[esm_FLOWING] && 0 !== this[esm_BUFFERLENGTH]) this[esm_FLUSH](true);
|
|
7157
|
-
if (this[esm_FLOWING]) this.emit('data', chunk);
|
|
7158
|
-
else this[esm_BUFFERPUSH](chunk);
|
|
7159
|
-
if (0 !== this[esm_BUFFERLENGTH]) this.emit('readable');
|
|
7160
|
-
if (cb) fn(cb);
|
|
7161
|
-
return this[esm_FLOWING];
|
|
7162
|
-
}
|
|
7163
|
-
if (!chunk.length) {
|
|
7164
|
-
if (0 !== this[esm_BUFFERLENGTH]) this.emit('readable');
|
|
7165
|
-
if (cb) fn(cb);
|
|
7166
|
-
return this[esm_FLOWING];
|
|
7167
|
-
}
|
|
7168
|
-
if ('string' == typeof chunk && !(encoding === this[esm_ENCODING] && !this[esm_DECODER]?.lastNeed)) chunk = Buffer.from(chunk, encoding);
|
|
7169
|
-
if (Buffer.isBuffer(chunk) && this[esm_ENCODING]) chunk = this[esm_DECODER].write(chunk);
|
|
7170
|
-
if (this[esm_FLOWING] && 0 !== this[esm_BUFFERLENGTH]) this[esm_FLUSH](true);
|
|
7171
|
-
if (this[esm_FLOWING]) this.emit('data', chunk);
|
|
7172
|
-
else this[esm_BUFFERPUSH](chunk);
|
|
7173
|
-
if (0 !== this[esm_BUFFERLENGTH]) this.emit('readable');
|
|
7174
|
-
if (cb) fn(cb);
|
|
7175
|
-
return this[esm_FLOWING];
|
|
7176
|
-
}
|
|
7177
|
-
read(n) {
|
|
7178
|
-
if (this[esm_DESTROYED]) return null;
|
|
7179
|
-
this[esm_DISCARDED] = false;
|
|
7180
|
-
if (0 === this[esm_BUFFERLENGTH] || 0 === n || n && n > this[esm_BUFFERLENGTH]) {
|
|
7181
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7182
|
-
return null;
|
|
7183
|
-
}
|
|
7184
|
-
if (this[esm_OBJECTMODE]) n = null;
|
|
7185
|
-
if (this[esm_BUFFER].length > 1 && !this[esm_OBJECTMODE]) this[esm_BUFFER] = [
|
|
7186
|
-
this[esm_ENCODING] ? this[esm_BUFFER].join('') : Buffer.concat(this[esm_BUFFER], this[esm_BUFFERLENGTH])
|
|
7187
|
-
];
|
|
7188
|
-
const ret = this[esm_READ](n || null, this[esm_BUFFER][0]);
|
|
7189
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7190
|
-
return ret;
|
|
7191
|
-
}
|
|
7192
|
-
[esm_READ](n, chunk) {
|
|
7193
|
-
if (this[esm_OBJECTMODE]) this[esm_BUFFERSHIFT]();
|
|
7194
|
-
else {
|
|
7195
|
-
const c = chunk;
|
|
7196
|
-
if (n === c.length || null === n) this[esm_BUFFERSHIFT]();
|
|
7197
|
-
else if ('string' == typeof c) {
|
|
7198
|
-
this[esm_BUFFER][0] = c.slice(n);
|
|
7199
|
-
chunk = c.slice(0, n);
|
|
7200
|
-
this[esm_BUFFERLENGTH] -= n;
|
|
7201
|
-
} else {
|
|
7202
|
-
this[esm_BUFFER][0] = c.subarray(n);
|
|
7203
|
-
chunk = c.subarray(0, n);
|
|
7204
|
-
this[esm_BUFFERLENGTH] -= n;
|
|
7205
|
-
}
|
|
7206
|
-
}
|
|
7207
|
-
this.emit('data', chunk);
|
|
7208
|
-
if (!this[esm_BUFFER].length && !this[esm_EOF]) this.emit('drain');
|
|
7209
|
-
return chunk;
|
|
7210
|
-
}
|
|
7211
|
-
end(chunk, encoding, cb) {
|
|
7212
|
-
if ('function' == typeof chunk) {
|
|
7213
|
-
cb = chunk;
|
|
7214
|
-
chunk = void 0;
|
|
7215
|
-
}
|
|
7216
|
-
if ('function' == typeof encoding) {
|
|
7217
|
-
cb = encoding;
|
|
7218
|
-
encoding = 'utf8';
|
|
7219
|
-
}
|
|
7220
|
-
if (void 0 !== chunk) this.write(chunk, encoding);
|
|
7221
|
-
if (cb) this.once('end', cb);
|
|
7222
|
-
this[esm_EOF] = true;
|
|
7223
|
-
this.writable = false;
|
|
7224
|
-
if (this[esm_FLOWING] || !this[esm_PAUSED]) this[esm_MAYBE_EMIT_END]();
|
|
7225
|
-
return this;
|
|
7226
|
-
}
|
|
7227
|
-
[esm_RESUME]() {
|
|
7228
|
-
if (this[esm_DESTROYED]) return;
|
|
7229
|
-
if (!this[esm_DATALISTENERS] && !this[esm_PIPES].length) this[esm_DISCARDED] = true;
|
|
7230
|
-
this[esm_PAUSED] = false;
|
|
7231
|
-
this[esm_FLOWING] = true;
|
|
7232
|
-
this.emit('resume');
|
|
7233
|
-
if (this[esm_BUFFER].length) this[esm_FLUSH]();
|
|
7234
|
-
else if (this[esm_EOF]) this[esm_MAYBE_EMIT_END]();
|
|
7235
|
-
else this.emit('drain');
|
|
7236
|
-
}
|
|
7237
|
-
resume() {
|
|
7238
|
-
return this[esm_RESUME]();
|
|
7239
|
-
}
|
|
7240
|
-
pause() {
|
|
7241
|
-
this[esm_FLOWING] = false;
|
|
7242
|
-
this[esm_PAUSED] = true;
|
|
7243
|
-
this[esm_DISCARDED] = false;
|
|
7244
|
-
}
|
|
7245
|
-
get destroyed() {
|
|
7246
|
-
return this[esm_DESTROYED];
|
|
7247
|
-
}
|
|
7248
|
-
get flowing() {
|
|
7249
|
-
return this[esm_FLOWING];
|
|
7250
|
-
}
|
|
7251
|
-
get paused() {
|
|
7252
|
-
return this[esm_PAUSED];
|
|
7253
|
-
}
|
|
7254
|
-
[esm_BUFFERPUSH](chunk) {
|
|
7255
|
-
if (this[esm_OBJECTMODE]) this[esm_BUFFERLENGTH] += 1;
|
|
7256
|
-
else this[esm_BUFFERLENGTH] += chunk.length;
|
|
7257
|
-
this[esm_BUFFER].push(chunk);
|
|
7258
|
-
}
|
|
7259
|
-
[esm_BUFFERSHIFT]() {
|
|
7260
|
-
if (this[esm_OBJECTMODE]) this[esm_BUFFERLENGTH] -= 1;
|
|
7261
|
-
else this[esm_BUFFERLENGTH] -= this[esm_BUFFER][0].length;
|
|
7262
|
-
return this[esm_BUFFER].shift();
|
|
7263
|
-
}
|
|
7264
|
-
[esm_FLUSH](noDrain = false) {
|
|
7265
|
-
do ;
|
|
7266
|
-
while (this[esm_FLUSHCHUNK](this[esm_BUFFERSHIFT]()) && this[esm_BUFFER].length);
|
|
7267
|
-
if (!noDrain && !this[esm_BUFFER].length && !this[esm_EOF]) this.emit('drain');
|
|
7268
|
-
}
|
|
7269
|
-
[esm_FLUSHCHUNK](chunk) {
|
|
7270
|
-
this.emit('data', chunk);
|
|
7271
|
-
return this[esm_FLOWING];
|
|
7272
|
-
}
|
|
7273
|
-
pipe(dest, opts) {
|
|
7274
|
-
if (this[esm_DESTROYED]) return dest;
|
|
7275
|
-
this[esm_DISCARDED] = false;
|
|
7276
|
-
const ended = this[esm_EMITTED_END];
|
|
7277
|
-
opts = opts || {};
|
|
7278
|
-
if (dest === esm_proc.stdout || dest === esm_proc.stderr) opts.end = false;
|
|
7279
|
-
else opts.end = false !== opts.end;
|
|
7280
|
-
opts.proxyErrors = !!opts.proxyErrors;
|
|
7281
|
-
if (ended) {
|
|
7282
|
-
if (opts.end) dest.end();
|
|
7283
|
-
} else {
|
|
7284
|
-
this[esm_PIPES].push(opts.proxyErrors ? new esm_PipeProxyErrors(this, dest, opts) : new esm_Pipe(this, dest, opts));
|
|
7285
|
-
if (this[esm_ASYNC]) esm_defer(()=>this[esm_RESUME]());
|
|
7286
|
-
else this[esm_RESUME]();
|
|
7287
|
-
}
|
|
7288
|
-
return dest;
|
|
7289
|
-
}
|
|
7290
|
-
unpipe(dest) {
|
|
7291
|
-
const p = this[esm_PIPES].find((p)=>p.dest === dest);
|
|
7292
|
-
if (p) {
|
|
7293
|
-
if (1 === this[esm_PIPES].length) {
|
|
7294
|
-
if (this[esm_FLOWING] && 0 === this[esm_DATALISTENERS]) this[esm_FLOWING] = false;
|
|
7295
|
-
this[esm_PIPES] = [];
|
|
7296
|
-
} else this[esm_PIPES].splice(this[esm_PIPES].indexOf(p), 1);
|
|
7297
|
-
p.unpipe();
|
|
7298
|
-
}
|
|
7299
|
-
}
|
|
7300
|
-
addListener(ev, handler) {
|
|
7301
|
-
return this.on(ev, handler);
|
|
7302
|
-
}
|
|
7303
|
-
on(ev, handler) {
|
|
7304
|
-
const ret = super.on(ev, handler);
|
|
7305
|
-
if ('data' === ev) {
|
|
7306
|
-
this[esm_DISCARDED] = false;
|
|
7307
|
-
this[esm_DATALISTENERS]++;
|
|
7308
|
-
if (!this[esm_PIPES].length && !this[esm_FLOWING]) this[esm_RESUME]();
|
|
7309
|
-
} else if ('readable' === ev && 0 !== this[esm_BUFFERLENGTH]) super.emit('readable');
|
|
7310
|
-
else if (esm_isEndish(ev) && this[esm_EMITTED_END]) {
|
|
7311
|
-
super.emit(ev);
|
|
7312
|
-
this.removeAllListeners(ev);
|
|
7313
|
-
} else if ('error' === ev && this[esm_EMITTED_ERROR]) {
|
|
7314
|
-
const h = handler;
|
|
7315
|
-
if (this[esm_ASYNC]) esm_defer(()=>h.call(this, this[esm_EMITTED_ERROR]));
|
|
7316
|
-
else h.call(this, this[esm_EMITTED_ERROR]);
|
|
7317
|
-
}
|
|
7318
|
-
return ret;
|
|
7319
|
-
}
|
|
7320
|
-
removeListener(ev, handler) {
|
|
7321
|
-
return this.off(ev, handler);
|
|
7322
|
-
}
|
|
7323
|
-
off(ev, handler) {
|
|
7324
|
-
const ret = super.off(ev, handler);
|
|
7325
|
-
if ('data' === ev) {
|
|
7326
|
-
this[esm_DATALISTENERS] = this.listeners('data').length;
|
|
7327
|
-
if (0 === this[esm_DATALISTENERS] && !this[esm_DISCARDED] && !this[esm_PIPES].length) this[esm_FLOWING] = false;
|
|
7328
|
-
}
|
|
7329
|
-
return ret;
|
|
7330
|
-
}
|
|
7331
|
-
removeAllListeners(ev) {
|
|
7332
|
-
const ret = super.removeAllListeners(ev);
|
|
7333
|
-
if ('data' === ev || void 0 === ev) {
|
|
7334
|
-
this[esm_DATALISTENERS] = 0;
|
|
7335
|
-
if (!this[esm_DISCARDED] && !this[esm_PIPES].length) this[esm_FLOWING] = false;
|
|
7336
|
-
}
|
|
7337
|
-
return ret;
|
|
7338
|
-
}
|
|
7339
|
-
get emittedEnd() {
|
|
7340
|
-
return this[esm_EMITTED_END];
|
|
7341
|
-
}
|
|
7342
|
-
[esm_MAYBE_EMIT_END]() {
|
|
7343
|
-
if (!this[esm_EMITTING_END] && !this[esm_EMITTED_END] && !this[esm_DESTROYED] && 0 === this[esm_BUFFER].length && this[esm_EOF]) {
|
|
7344
|
-
this[esm_EMITTING_END] = true;
|
|
7345
|
-
this.emit('end');
|
|
7346
|
-
this.emit('prefinish');
|
|
7347
|
-
this.emit('finish');
|
|
7348
|
-
if (this[esm_CLOSED]) this.emit('close');
|
|
7349
|
-
this[esm_EMITTING_END] = false;
|
|
7350
|
-
}
|
|
7351
|
-
}
|
|
7352
|
-
emit(ev, ...args) {
|
|
7353
|
-
const data = args[0];
|
|
7354
|
-
if ('error' !== ev && 'close' !== ev && ev !== esm_DESTROYED && this[esm_DESTROYED]) return false;
|
|
7355
|
-
if ('data' === ev) return this[esm_OBJECTMODE] || data ? this[esm_ASYNC] ? (esm_defer(()=>this[esm_EMITDATA](data)), true) : this[esm_EMITDATA](data) : false;
|
|
7356
|
-
if ('end' === ev) return this[esm_EMITEND]();
|
|
7357
|
-
if ('close' === ev) {
|
|
7358
|
-
this[esm_CLOSED] = true;
|
|
7359
|
-
if (!this[esm_EMITTED_END] && !this[esm_DESTROYED]) return false;
|
|
7360
|
-
const ret = super.emit('close');
|
|
7361
|
-
this.removeAllListeners('close');
|
|
7362
|
-
return ret;
|
|
7363
|
-
}
|
|
7364
|
-
if ('error' === ev) {
|
|
7365
|
-
this[esm_EMITTED_ERROR] = data;
|
|
7366
|
-
super.emit(esm_ERROR, data);
|
|
7367
|
-
const ret = !this[esm_SIGNAL] || this.listeners('error').length ? super.emit('error', data) : false;
|
|
7368
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7369
|
-
return ret;
|
|
7370
|
-
} else if ('resume' === ev) {
|
|
7371
|
-
const ret = super.emit('resume');
|
|
7372
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7373
|
-
return ret;
|
|
7374
|
-
} else if ('finish' === ev || 'prefinish' === ev) {
|
|
7375
|
-
const ret = super.emit(ev);
|
|
7376
|
-
this.removeAllListeners(ev);
|
|
7377
|
-
return ret;
|
|
7378
|
-
}
|
|
7379
|
-
const ret = super.emit(ev, ...args);
|
|
7380
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7381
|
-
return ret;
|
|
7382
|
-
}
|
|
7383
|
-
[esm_EMITDATA](data) {
|
|
7384
|
-
for (const p of this[esm_PIPES])if (false === p.dest.write(data)) this.pause();
|
|
7385
|
-
const ret = this[esm_DISCARDED] ? false : super.emit('data', data);
|
|
7386
|
-
this[esm_MAYBE_EMIT_END]();
|
|
7387
|
-
return ret;
|
|
7388
|
-
}
|
|
7389
|
-
[esm_EMITEND]() {
|
|
7390
|
-
if (this[esm_EMITTED_END]) return false;
|
|
7391
|
-
this[esm_EMITTED_END] = true;
|
|
7392
|
-
this.readable = false;
|
|
7393
|
-
return this[esm_ASYNC] ? (esm_defer(()=>this[esm_EMITEND2]()), true) : this[esm_EMITEND2]();
|
|
7394
|
-
}
|
|
7395
|
-
[esm_EMITEND2]() {
|
|
7396
|
-
if (this[esm_DECODER]) {
|
|
7397
|
-
const data = this[esm_DECODER].end();
|
|
7398
|
-
if (data) {
|
|
7399
|
-
for (const p of this[esm_PIPES])p.dest.write(data);
|
|
7400
|
-
if (!this[esm_DISCARDED]) super.emit('data', data);
|
|
7401
|
-
}
|
|
7402
|
-
}
|
|
7403
|
-
for (const p of this[esm_PIPES])p.end();
|
|
7404
|
-
const ret = super.emit('end');
|
|
7405
|
-
this.removeAllListeners('end');
|
|
7406
|
-
return ret;
|
|
7407
|
-
}
|
|
7408
|
-
async collect() {
|
|
7409
|
-
const buf = Object.assign([], {
|
|
7410
|
-
dataLength: 0
|
|
7411
|
-
});
|
|
7412
|
-
if (!this[esm_OBJECTMODE]) buf.dataLength = 0;
|
|
7413
|
-
const p = this.promise();
|
|
7414
|
-
this.on('data', (c)=>{
|
|
7415
|
-
buf.push(c);
|
|
7416
|
-
if (!this[esm_OBJECTMODE]) buf.dataLength += c.length;
|
|
7417
|
-
});
|
|
7418
|
-
await p;
|
|
7419
|
-
return buf;
|
|
7420
|
-
}
|
|
7421
|
-
async concat() {
|
|
7422
|
-
if (this[esm_OBJECTMODE]) throw new Error('cannot concat in objectMode');
|
|
7423
|
-
const buf = await this.collect();
|
|
7424
|
-
return this[esm_ENCODING] ? buf.join('') : Buffer.concat(buf, buf.dataLength);
|
|
7425
|
-
}
|
|
7426
|
-
async promise() {
|
|
7427
|
-
return new Promise((resolve, reject)=>{
|
|
7428
|
-
this.on(esm_DESTROYED, ()=>reject(new Error('stream destroyed')));
|
|
7429
|
-
this.on('error', (er)=>reject(er));
|
|
7430
|
-
this.on('end', ()=>resolve());
|
|
7431
|
-
});
|
|
7432
|
-
}
|
|
7433
|
-
[Symbol.asyncIterator]() {
|
|
7434
|
-
this[esm_DISCARDED] = false;
|
|
7435
|
-
let stopped = false;
|
|
7436
|
-
const stop = async ()=>{
|
|
7437
|
-
this.pause();
|
|
7438
|
-
stopped = true;
|
|
7439
|
-
return {
|
|
7440
|
-
value: void 0,
|
|
7441
|
-
done: true
|
|
7442
|
-
};
|
|
7443
|
-
};
|
|
7444
|
-
const next = ()=>{
|
|
7445
|
-
if (stopped) return stop();
|
|
7446
|
-
const res = this.read();
|
|
7447
|
-
if (null !== res) return Promise.resolve({
|
|
7448
|
-
done: false,
|
|
7449
|
-
value: res
|
|
7450
|
-
});
|
|
7451
|
-
if (this[esm_EOF]) return stop();
|
|
7452
|
-
let resolve;
|
|
7453
|
-
let reject;
|
|
7454
|
-
const onerr = (er)=>{
|
|
7455
|
-
this.off('data', ondata);
|
|
7456
|
-
this.off('end', onend);
|
|
7457
|
-
this.off(esm_DESTROYED, ondestroy);
|
|
7458
|
-
stop();
|
|
7459
|
-
reject(er);
|
|
7460
|
-
};
|
|
7461
|
-
const ondata = (value)=>{
|
|
7462
|
-
this.off('error', onerr);
|
|
7463
|
-
this.off('end', onend);
|
|
7464
|
-
this.off(esm_DESTROYED, ondestroy);
|
|
7465
|
-
this.pause();
|
|
7466
|
-
resolve({
|
|
7467
|
-
value,
|
|
7468
|
-
done: !!this[esm_EOF]
|
|
7469
|
-
});
|
|
7470
|
-
};
|
|
7471
|
-
const onend = ()=>{
|
|
7472
|
-
this.off('error', onerr);
|
|
7473
|
-
this.off('data', ondata);
|
|
7474
|
-
this.off(esm_DESTROYED, ondestroy);
|
|
7475
|
-
stop();
|
|
7476
|
-
resolve({
|
|
7477
|
-
done: true,
|
|
7478
|
-
value: void 0
|
|
7479
|
-
});
|
|
7480
|
-
};
|
|
7481
|
-
const ondestroy = ()=>onerr(new Error('stream destroyed'));
|
|
7482
|
-
return new Promise((res, rej)=>{
|
|
7483
|
-
reject = rej;
|
|
7484
|
-
resolve = res;
|
|
7485
|
-
this.once(esm_DESTROYED, ondestroy);
|
|
7486
|
-
this.once('error', onerr);
|
|
7487
|
-
this.once('end', onend);
|
|
7488
|
-
this.once('data', ondata);
|
|
7489
|
-
});
|
|
7490
|
-
};
|
|
7491
|
-
return {
|
|
7492
|
-
next,
|
|
7493
|
-
throw: stop,
|
|
7494
|
-
return: stop,
|
|
7495
|
-
[Symbol.asyncIterator] () {
|
|
7496
|
-
return this;
|
|
7497
|
-
}
|
|
7498
|
-
};
|
|
7499
|
-
}
|
|
7500
|
-
[Symbol.iterator]() {
|
|
7501
|
-
this[esm_DISCARDED] = false;
|
|
7502
|
-
let stopped = false;
|
|
7503
|
-
const stop = ()=>{
|
|
7504
|
-
this.pause();
|
|
7505
|
-
this.off(esm_ERROR, stop);
|
|
7506
|
-
this.off(esm_DESTROYED, stop);
|
|
7507
|
-
this.off('end', stop);
|
|
7508
|
-
stopped = true;
|
|
7509
|
-
return {
|
|
7510
|
-
done: true,
|
|
7511
|
-
value: void 0
|
|
7512
|
-
};
|
|
7513
|
-
};
|
|
7514
|
-
const next = ()=>{
|
|
7515
|
-
if (stopped) return stop();
|
|
7516
|
-
const value = this.read();
|
|
7517
|
-
return null === value ? stop() : {
|
|
7518
|
-
done: false,
|
|
7519
|
-
value
|
|
7520
|
-
};
|
|
7521
|
-
};
|
|
7522
|
-
this.once('end', stop);
|
|
7523
|
-
this.once(esm_ERROR, stop);
|
|
7524
|
-
this.once(esm_DESTROYED, stop);
|
|
7525
|
-
return {
|
|
7526
|
-
next,
|
|
7527
|
-
throw: stop,
|
|
7528
|
-
return: stop,
|
|
7529
|
-
[Symbol.iterator] () {
|
|
7530
|
-
return this;
|
|
7531
|
-
}
|
|
7532
|
-
};
|
|
7533
|
-
}
|
|
7534
|
-
destroy(er) {
|
|
7535
|
-
if (this[esm_DESTROYED]) {
|
|
7536
|
-
if (er) this.emit('error', er);
|
|
7537
|
-
else this.emit(esm_DESTROYED);
|
|
7538
|
-
return this;
|
|
7539
|
-
}
|
|
7540
|
-
this[esm_DESTROYED] = true;
|
|
7541
|
-
this[esm_DISCARDED] = true;
|
|
7542
|
-
this[esm_BUFFER].length = 0;
|
|
7543
|
-
this[esm_BUFFERLENGTH] = 0;
|
|
7544
|
-
const wc = this;
|
|
7545
|
-
if ('function' == typeof wc.close && !this[esm_CLOSED]) wc.close();
|
|
7546
|
-
if (er) this.emit('error', er);
|
|
7547
|
-
else this.emit(esm_DESTROYED);
|
|
7548
|
-
return this;
|
|
7549
|
-
}
|
|
7550
|
-
static get isStream() {
|
|
7551
|
-
return esm_isStream;
|
|
7552
|
-
}
|
|
7553
|
-
}
|
|
7554
7222
|
const ignore_defaultPlatform = 'object' == typeof process && process && 'string' == typeof process.platform ? process.platform : 'linux';
|
|
7555
7223
|
class Ignore {
|
|
7556
7224
|
relative;
|
|
@@ -8029,7 +7697,7 @@ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
|
8029
7697
|
results;
|
|
8030
7698
|
constructor(patterns, path, opts){
|
|
8031
7699
|
super(patterns, path, opts);
|
|
8032
|
-
this.results = new
|
|
7700
|
+
this.results = new Minipass({
|
|
8033
7701
|
signal: this.signal,
|
|
8034
7702
|
objectMode: true
|
|
8035
7703
|
});
|
|
@@ -11542,7 +11210,7 @@ Usage:
|
|
|
11542
11210
|
type: 'boolean',
|
|
11543
11211
|
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}`
|
|
11544
11212
|
}
|
|
11545
|
-
}).version('version', 'Show version number', "1.
|
|
11213
|
+
}).version('version', 'Show version number', "1.9.0").help().epilogue(`For complete list of configuration options, please visit:
|
|
11546
11214
|
• Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
|
|
11547
11215
|
• Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
|
|
11548
11216
|
• iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
|