@vltpkg/cli-js 1.4.0 → 1.6.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/{access-422UGEWN.js → access-AJ654YKY.js} +13 -12
- package/{bugs-RED7Y33Q.js → bugs-N73DVYHD.js} +32 -25
- package/{build-IHMPBWRO.js → build-VZ3EZKMM.js} +65 -21
- package/{cache-FJP2RZJX.js → cache-VROEWG2C.js} +20 -17
- package/cache-unzip-src-unzip.js +58 -15
- package/{chunk-TPRK6IDA.js → chunk-22LZBDEC.js} +2 -2
- package/chunk-36UIE654.js +6248 -0
- package/{chunk-UGCKF5ZE.js → chunk-3JIN46K5.js} +1 -1
- package/{chunk-OAJ3PO3Z.js → chunk-44AWMA4F.js} +25 -13
- package/chunk-4E65BBTM.js +77 -0
- package/{chunk-SR2VOY5J.js → chunk-4GMNWW4C.js} +1 -1
- package/{chunk-5IJTPZXP.js → chunk-6D3QAFNZ.js} +1 -1
- package/{chunk-X4FVR4R5.js → chunk-75HGJVNG.js} +12 -10
- package/{chunk-THSYN5EK.js → chunk-7M2VTFLP.js} +12 -1
- package/{chunk-2AMOC4DN.js → chunk-ANW36H4T.js} +4 -4
- package/chunk-B6RIGNEO.js +626 -0
- package/{chunk-FLH4YC6W.js → chunk-BF5DRGRZ.js} +60 -15
- package/chunk-BH5CVXNY.js +115 -0
- package/{chunk-PLG3OYCX.js → chunk-CAV7FKWQ.js} +3 -2
- package/{chunk-C23TDXRG.js → chunk-CYK6I4M6.js} +1 -1
- package/chunk-DXED4ARV.js +436 -0
- package/chunk-E74WGW5C.js +49 -0
- package/{chunk-WF6KLKRN.js → chunk-EFHOWRKU.js} +103 -1
- package/chunk-EMTGRCSE.js +1111 -0
- package/{chunk-5Y4SYLJ2.js → chunk-EYGOEAJM.js} +1 -1
- package/{chunk-OVPHE4O7.js → chunk-F5LZMLAQ.js} +5335 -10902
- package/{chunk-HZXJ423P.js → chunk-FXD3IV2S.js} +4 -2
- package/chunk-GCTREKA4.js +115 -0
- package/{chunk-ZJMJ7MCT.js → chunk-GEQFMH5M.js} +1 -1
- package/{chunk-ISE4IRHF.js → chunk-GZVI75KX.js} +7 -14
- package/chunk-HOF7LEIC.js +24 -0
- package/{chunk-LHPEBLOU.js → chunk-HT6FS4VB.js} +1 -1
- package/{chunk-PHJJPY5G.js → chunk-IXAMCWIT.js} +5 -5
- package/{chunk-ASLX43R3.js → chunk-JCNI6ZHH.js} +7 -5
- package/chunk-JV5XR5JQ.js +349 -0
- package/{chunk-7T3XAYP4.js → chunk-KD5ZK72K.js} +1 -1
- package/{chunk-FZUYGJZU.js → chunk-KVWGMSPW.js} +137 -19
- package/{chunk-TO23PR7J.js → chunk-LCLRP64K.js} +14 -12
- package/{chunk-QCSUWACA.js → chunk-LGQVZTYR.js} +8 -36
- package/{chunk-5RHABCYI.js → chunk-LP3ORD3D.js} +143 -17
- package/chunk-MCDLJZXT.js +82 -0
- package/{chunk-DNRR3XMG.js → chunk-N6HV7JWC.js} +1 -1
- package/chunk-O6MQ7NN6.js +1155 -0
- package/{chunk-GIIAODRI.js → chunk-PC2HOBAQ.js} +7 -5
- package/{chunk-APMYKJI2.js → chunk-QNHBAGXQ.js} +1 -1
- package/chunk-RBQO54TG.js +59 -0
- package/chunk-SUU2WETN.js +268 -0
- package/{chunk-I7UMHYZX.js → chunk-TQQO2F56.js} +113 -1187
- package/{chunk-4UCADW6S.js → chunk-TWDSXQPN.js} +9 -7
- package/{chunk-MKWPTN3C.js → chunk-VLVMLSIF.js} +2 -2
- package/chunk-W4T5CGCO.js +52 -0
- package/{chunk-5TNXLRW2.js → chunk-YTDABXPD.js} +50 -12
- package/{ci-YSKNNO5M.js → ci-3BVMVQIT.js} +35 -13
- package/cli-package.json +3 -1
- package/{config-HO7GY3QT.js → config-2KQV7N5A.js} +16 -13
- package/{config-CSPCDMR3.js → config-EKHBW6I5.js} +12 -9
- package/{create-2TJT3AHJ.js → create-QVHNOIV3.js} +35 -29
- package/{deprecate-7FRJI2RL.js → deprecate-E254QBH6.js} +17 -15
- package/{dist-tag-WCFF5OEG.js → dist-tag-SITRFD7O.js} +13 -12
- package/{docs-JMBPTU23.js → docs-IDL2P7CA.js} +32 -25
- package/{exec-FBOUKZZ2.js → exec-7BK2W2WL.js} +35 -29
- package/{exec-cache-X3ZWM5S3.js → exec-cache-VY46L7DR.js} +27 -21
- package/{exec-local-Y3KQC22N.js → exec-local-D7R5T3DF.js} +26 -20
- package/{help-PUKVH5X7.js → help-RMRIEJQL.js} +6 -5
- package/{init-GOKAQXXZ.js → init-BGW4HJ6V.js} +15 -11
- package/{install-XFN4UFOC.js → install-U5GATZ2N.js} +144 -49
- package/{list-43JFFG5D.js → list-3VG4M2XL.js} +41 -28
- package/{login-RSTZKNKN.js → login-PHQWI6S6.js} +19 -16
- package/{logout-4576FFXZ.js → logout-DJCOGRFF.js} +13 -12
- package/{outdated-ACQ5A2Y7.js → outdated-JH3O6R3Y.js} +27 -22
- package/{pack-QQVJ3G25.js → pack-U5W5YWHK.js} +23 -18
- package/package.json +1 -1
- package/{ping-QCDQQRO5.js → ping-EKX43AOW.js} +13 -12
- package/{pkg-CSOJV7UC.js → pkg-SW5GMERT.js} +19 -14
- package/{profile-VL4HPW3N.js → profile-UGDRDMQ6.js} +13 -12
- package/{publish-2YBO6ZXE.js → publish-HTWKK3NN.js} +60 -45
- package/{query-IHHFMJRT.js → query-YE3FUVGG.js} +43 -30
- package/{registry-W7BRZZZ2.js → registry-ZGGWVLBM.js} +7 -7
- package/registry-client-src-revalidate.js +76 -22
- package/{repo-L3BXAAWS.js → repo-WDOCU6SE.js} +32 -25
- package/{reporter-5NYOHBO7.js → reporter-N5PAXB26.js} +121 -17
- package/{run-AMUUVLTI.js → run-IPARVIIQ.js} +26 -20
- package/{run-exec-5W3XWQZA.js → run-exec-C4RTREEW.js} +26 -20
- package/security-archive-src-update-expired.js +66 -21
- package/{setup-TFM4GJF7.js → setup-SYYUEHZL.js} +212 -32
- package/skills-KA2VR5Q5.js +480 -0
- package/skills-UBBMSBDQ.js +416 -0
- package/{src-4CYCUWZL.js → src-FUSTSM4J.js} +33 -22
- package/{src-I3GMULFP.js → src-QO5G2S4O.js} +11 -8
- package/{src-LUTN2ODD.js → src-W2VQULRG.js} +2 -2
- package/{token-OANOBE3G.js → token-UQNABECH.js} +15 -13
- package/{uninstall-YXTQ4AIZ.js → uninstall-FHBJ3OUV.js} +59 -18
- package/{unpublish-SZXYMYIU.js → unpublish-APJTEUBA.js} +31 -16
- package/{update-FHLMWGIM.js → update-NWZTL4S7.js} +52 -25
- package/{version-ZWFCTU5V.js → version-EMKKTL77.js} +20 -14
- package/{view-NFNJXMLV.js → view-BUUI33RV.js} +17 -15
- package/vlr.js +1 -1
- package/vlrx.js +1 -1
- package/vlt.js +1 -1
- package/vlx.js +1 -1
- package/vlxl.js +1 -1
- package/{whoami-O7GOSGCI.js → whoami-F6BSXGQ2.js} +13 -12
- package/chunk-G2YT2GWF.js +0 -120
- package/chunk-T6FBP4OU.js +0 -76
- package/chunk-U7TEQCBN.js +0 -880
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
var global = globalThis;
|
|
2
|
+
import {Buffer} from "node:buffer";
|
|
3
|
+
import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
|
|
4
|
+
globalThis.setTimeout = _vlt_setTimeout;
|
|
5
|
+
globalThis.clearTimeout = _vlt_clearTimeout;
|
|
6
|
+
globalThis.setImmediate = _vlt_setImmediate;
|
|
7
|
+
globalThis.clearImmediate = _vlt_clearImmediate;
|
|
8
|
+
globalThis.setInterval = _vlt_setInterval;
|
|
9
|
+
globalThis.clearInterval = _vlt_clearInterval;
|
|
10
|
+
import {createRequire as _vlt_createRequire} from "node:module";
|
|
11
|
+
var require = _vlt_createRequire(import.meta.filename);
|
|
12
|
+
|
|
13
|
+
// ../../src/output/src/index.ts
|
|
14
|
+
import EventEmitter from "node:events";
|
|
15
|
+
var OutputEmitter = class {
|
|
16
|
+
emitter = new EventEmitter();
|
|
17
|
+
emit(eventName, payload) {
|
|
18
|
+
this.emitter.emit(eventName, payload);
|
|
19
|
+
}
|
|
20
|
+
on(eventName, handler) {
|
|
21
|
+
this.emitter.on(eventName, handler);
|
|
22
|
+
}
|
|
23
|
+
off(eventName, handler) {
|
|
24
|
+
this.emitter.off(eventName, handler);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var emitter = new OutputEmitter();
|
|
28
|
+
var logRequest = (url, state, details = {}) => {
|
|
29
|
+
emitter.emit("request", { url, state, ...details });
|
|
30
|
+
};
|
|
31
|
+
var graphStep = (step) => {
|
|
32
|
+
emitter.emit("graphStep", { step, state: "start" });
|
|
33
|
+
return () => emitter.emit("graphStep", { step, state: "stop" });
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.vlt/~npm~lru-cache@11.5.2/node_modules/lru-cache/dist/esm/node/index.min.js
|
|
37
|
+
import { tracingChannel as G, channel as P } from "node:diagnostics_channel";
|
|
38
|
+
var S = P("lru-cache:metrics");
|
|
39
|
+
var W = G("lru-cache");
|
|
40
|
+
var L = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
|
|
41
|
+
var R = () => S.hasSubscribers || W.hasSubscribers;
|
|
42
|
+
var U = /* @__PURE__ */ new Set();
|
|
43
|
+
var M = typeof process == "object" && process ? process : {};
|
|
44
|
+
var k = (d3, e, t, i) => {
|
|
45
|
+
typeof M.emitWarning == "function" ? M.emitWarning(d3, e, t, i) : console.error(`[${t}] ${e}: ${d3}`);
|
|
46
|
+
};
|
|
47
|
+
var H = (d3) => !U.has(d3);
|
|
48
|
+
var T = (d3) => !!d3 && d3 === Math.floor(d3) && d3 > 0 && isFinite(d3);
|
|
49
|
+
var j = (d3) => T(d3) ? d3 <= Math.pow(2, 8) ? Uint8Array : d3 <= Math.pow(2, 16) ? Uint16Array : d3 <= Math.pow(2, 32) ? Uint32Array : d3 <= Number.MAX_SAFE_INTEGER ? O : null : null;
|
|
50
|
+
var O = class extends Array {
|
|
51
|
+
constructor(e) {
|
|
52
|
+
super(e), this.fill(0);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var x = class d {
|
|
56
|
+
heap;
|
|
57
|
+
length;
|
|
58
|
+
static #o = false;
|
|
59
|
+
static create(e) {
|
|
60
|
+
let t = j(e);
|
|
61
|
+
if (!t) return [];
|
|
62
|
+
d.#o = true;
|
|
63
|
+
let i = new d(e, t);
|
|
64
|
+
return d.#o = false, i;
|
|
65
|
+
}
|
|
66
|
+
constructor(e, t) {
|
|
67
|
+
if (!d.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
68
|
+
this.heap = new t(e), this.length = 0;
|
|
69
|
+
}
|
|
70
|
+
push(e) {
|
|
71
|
+
this.heap[this.length++] = e;
|
|
72
|
+
}
|
|
73
|
+
pop() {
|
|
74
|
+
return this.heap[--this.length];
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var I = class d2 {
|
|
78
|
+
#o;
|
|
79
|
+
#c;
|
|
80
|
+
#S;
|
|
81
|
+
#O;
|
|
82
|
+
#w;
|
|
83
|
+
#M;
|
|
84
|
+
#I;
|
|
85
|
+
#m;
|
|
86
|
+
get perf() {
|
|
87
|
+
return this.#m;
|
|
88
|
+
}
|
|
89
|
+
ttl;
|
|
90
|
+
ttlResolution;
|
|
91
|
+
ttlAutopurge;
|
|
92
|
+
updateAgeOnGet;
|
|
93
|
+
updateAgeOnHas;
|
|
94
|
+
allowStale;
|
|
95
|
+
noDisposeOnSet;
|
|
96
|
+
noUpdateTTL;
|
|
97
|
+
maxEntrySize;
|
|
98
|
+
sizeCalculation;
|
|
99
|
+
noDeleteOnFetchRejection;
|
|
100
|
+
noDeleteOnStaleGet;
|
|
101
|
+
allowStaleOnFetchAbort;
|
|
102
|
+
allowStaleOnFetchRejection;
|
|
103
|
+
ignoreFetchAbort;
|
|
104
|
+
backgroundFetchSize;
|
|
105
|
+
#n;
|
|
106
|
+
#b;
|
|
107
|
+
#s;
|
|
108
|
+
#i;
|
|
109
|
+
#t;
|
|
110
|
+
#l;
|
|
111
|
+
#u;
|
|
112
|
+
#a;
|
|
113
|
+
#h;
|
|
114
|
+
#y;
|
|
115
|
+
#r;
|
|
116
|
+
#_;
|
|
117
|
+
#F;
|
|
118
|
+
#d;
|
|
119
|
+
#g;
|
|
120
|
+
#T;
|
|
121
|
+
#U;
|
|
122
|
+
#f;
|
|
123
|
+
#D;
|
|
124
|
+
static unsafeExposeInternals(e) {
|
|
125
|
+
return { starts: e.#F, ttls: e.#d, autopurgeTimers: e.#g, sizes: e.#_, keyMap: e.#s, keyList: e.#i, valList: e.#t, next: e.#l, prev: e.#u, get head() {
|
|
126
|
+
return e.#a;
|
|
127
|
+
}, get tail() {
|
|
128
|
+
return e.#h;
|
|
129
|
+
}, free: e.#y, isBackgroundFetch: (t) => e.#e(t), backgroundFetch: (t, i, s, n) => e.#P(t, i, s, n), moveToTail: (t) => e.#L(t), indexes: (t) => e.#A(t), rindexes: (t) => e.#z(t), isStale: (t) => e.#p(t) };
|
|
130
|
+
}
|
|
131
|
+
get max() {
|
|
132
|
+
return this.#o;
|
|
133
|
+
}
|
|
134
|
+
get maxSize() {
|
|
135
|
+
return this.#c;
|
|
136
|
+
}
|
|
137
|
+
get calculatedSize() {
|
|
138
|
+
return this.#b;
|
|
139
|
+
}
|
|
140
|
+
get size() {
|
|
141
|
+
return this.#n;
|
|
142
|
+
}
|
|
143
|
+
get fetchMethod() {
|
|
144
|
+
return this.#M;
|
|
145
|
+
}
|
|
146
|
+
get memoMethod() {
|
|
147
|
+
return this.#I;
|
|
148
|
+
}
|
|
149
|
+
get dispose() {
|
|
150
|
+
return this.#S;
|
|
151
|
+
}
|
|
152
|
+
get onInsert() {
|
|
153
|
+
return this.#O;
|
|
154
|
+
}
|
|
155
|
+
get disposeAfter() {
|
|
156
|
+
return this.#w;
|
|
157
|
+
}
|
|
158
|
+
constructor(e) {
|
|
159
|
+
let { max: t = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: l, allowStale: h, dispose: r, onInsert: c, disposeAfter: m, noDisposeOnSet: _, noUpdateTTL: u, maxSize: g = 0, maxEntrySize: f = 0, sizeCalculation: y, fetchMethod: a, memoMethod: w, noDeleteOnFetchRejection: F, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: p, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, backgroundFetchSize: C = 1, perf: E } = e;
|
|
160
|
+
if (this.backgroundFetchSize = C, E !== void 0 && typeof E?.now != "function") throw new TypeError("perf option must have a now() method if specified");
|
|
161
|
+
if (this.#m = E ?? L, t !== 0 && !T(t)) throw new TypeError("max option must be a nonnegative integer");
|
|
162
|
+
let v = t ? j(t) : Array;
|
|
163
|
+
if (!v) throw new Error("invalid max value: " + t);
|
|
164
|
+
if (this.#o = t, this.#c = g, this.maxEntrySize = f || this.#c, this.sizeCalculation = y, this.sizeCalculation) {
|
|
165
|
+
if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
166
|
+
if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
|
|
167
|
+
}
|
|
168
|
+
if (w !== void 0 && typeof w != "function") throw new TypeError("memoMethod must be a function if defined");
|
|
169
|
+
if (this.#I = w, a !== void 0 && typeof a != "function") throw new TypeError("fetchMethod must be a function if specified");
|
|
170
|
+
if (this.#M = a, this.#U = !!a, this.#s = /* @__PURE__ */ new Map(), this.#i = Array.from({ length: t }).fill(void 0), this.#t = Array.from({ length: t }).fill(void 0), this.#l = new v(t), this.#u = new v(t), this.#a = 0, this.#h = 0, this.#y = x.create(t), this.#n = 0, this.#b = 0, typeof r == "function" && (this.#S = r), typeof c == "function" && (this.#O = c), typeof m == "function" ? (this.#w = m, this.#r = []) : (this.#w = void 0, this.#r = void 0), this.#T = !!this.#S, this.#D = !!this.#O, this.#f = !!this.#w, this.noDisposeOnSet = !!_, this.noUpdateTTL = !!u, this.noDeleteOnFetchRejection = !!F, this.allowStaleOnFetchRejection = !!p, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
|
|
171
|
+
if (this.#c !== 0 && !T(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
|
|
172
|
+
if (!T(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
173
|
+
this.#X();
|
|
174
|
+
}
|
|
175
|
+
if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!l, this.ttlResolution = T(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
|
|
176
|
+
if (!T(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
|
|
177
|
+
this.#k();
|
|
178
|
+
}
|
|
179
|
+
if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
180
|
+
if (!this.ttlAutopurge && !this.#o && !this.#c) {
|
|
181
|
+
let D = "LRU_CACHE_UNBOUNDED";
|
|
182
|
+
H(D) && (U.add(D), k("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", D, d2));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
getRemainingTTL(e) {
|
|
186
|
+
return this.#s.has(e) ? 1 / 0 : 0;
|
|
187
|
+
}
|
|
188
|
+
#k() {
|
|
189
|
+
let e = new O(this.#o), t = new O(this.#o);
|
|
190
|
+
this.#d = e, this.#F = t;
|
|
191
|
+
let i = this.ttlAutopurge ? Array.from({ length: this.#o }) : void 0;
|
|
192
|
+
this.#g = i, this.#H = (h, r, c = this.#m.now()) => {
|
|
193
|
+
t[h] = r !== 0 ? c : 0, e[h] = r, s(h, r);
|
|
194
|
+
}, this.#R = (h) => {
|
|
195
|
+
t[h] = e[h] !== 0 ? this.#m.now() : 0, s(h, e[h]);
|
|
196
|
+
};
|
|
197
|
+
let s = this.ttlAutopurge ? (h, r) => {
|
|
198
|
+
if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), r && r !== 0 && i) {
|
|
199
|
+
let c = setTimeout(() => {
|
|
200
|
+
this.#p(h) ? (this.#E(this.#i[h], "expire"), i[h] = void 0) : s(h, l(h));
|
|
201
|
+
}, r + 1);
|
|
202
|
+
c.unref && c.unref(), i[h] = c;
|
|
203
|
+
}
|
|
204
|
+
} : () => {
|
|
205
|
+
};
|
|
206
|
+
this.#v = (h, r) => {
|
|
207
|
+
if (e[r]) {
|
|
208
|
+
let c = e[r], m = t[r];
|
|
209
|
+
if (!c || !m) return;
|
|
210
|
+
h.ttl = c, h.start = m, h.now = n || o();
|
|
211
|
+
let _ = h.now - m;
|
|
212
|
+
h.remainingTTL = c - _;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
let n = 0, o = () => {
|
|
216
|
+
let h = this.#m.now();
|
|
217
|
+
if (this.ttlResolution > 0) {
|
|
218
|
+
n = h;
|
|
219
|
+
let r = setTimeout(() => n = 0, this.ttlResolution);
|
|
220
|
+
r.unref && r.unref();
|
|
221
|
+
}
|
|
222
|
+
return h;
|
|
223
|
+
};
|
|
224
|
+
this.getRemainingTTL = (h) => {
|
|
225
|
+
let r = this.#s.get(h);
|
|
226
|
+
return r === void 0 ? 0 : l(r);
|
|
227
|
+
};
|
|
228
|
+
let l = (h) => {
|
|
229
|
+
let r = e[h], c = t[h];
|
|
230
|
+
if (!r || !c) return 1 / 0;
|
|
231
|
+
let m = (n || o()) - c;
|
|
232
|
+
return r - m;
|
|
233
|
+
};
|
|
234
|
+
this.#p = (h) => {
|
|
235
|
+
let r = t[h], c = e[h];
|
|
236
|
+
return !!c && !!r && (n || o()) - r > c;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
#R = () => {
|
|
240
|
+
};
|
|
241
|
+
#v = () => {
|
|
242
|
+
};
|
|
243
|
+
#H = () => {
|
|
244
|
+
};
|
|
245
|
+
#p = () => false;
|
|
246
|
+
#X() {
|
|
247
|
+
let e = new O(this.#o);
|
|
248
|
+
this.#b = 0, this.#_ = e, this.#x = (t) => {
|
|
249
|
+
this.#b -= e[t], e[t] = 0;
|
|
250
|
+
}, this.#N = (t, i, s, n) => {
|
|
251
|
+
if (!T(s)) {
|
|
252
|
+
if (this.#e(i)) return this.backgroundFetchSize;
|
|
253
|
+
if (n) {
|
|
254
|
+
if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
|
|
255
|
+
if (s = n(i, t), !T(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
256
|
+
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
257
|
+
}
|
|
258
|
+
return s;
|
|
259
|
+
}, this.#j = (t, i, s) => {
|
|
260
|
+
if (e[t] = i, this.#c) {
|
|
261
|
+
let n = this.#c - e[t];
|
|
262
|
+
for (; this.#b > n; ) this.#G(true);
|
|
263
|
+
}
|
|
264
|
+
this.#b += e[t], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
#x = (e) => {
|
|
268
|
+
};
|
|
269
|
+
#j = (e, t, i) => {
|
|
270
|
+
};
|
|
271
|
+
#N = (e, t, i, s) => {
|
|
272
|
+
if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
273
|
+
return 0;
|
|
274
|
+
};
|
|
275
|
+
*#A({ allowStale: e = this.allowStale } = {}) {
|
|
276
|
+
if (this.#n) for (let t = this.#h; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#a); ) t = this.#u[t];
|
|
277
|
+
}
|
|
278
|
+
*#z({ allowStale: e = this.allowStale } = {}) {
|
|
279
|
+
if (this.#n) for (let t = this.#a; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#h); ) t = this.#l[t];
|
|
280
|
+
}
|
|
281
|
+
#V(e) {
|
|
282
|
+
return e !== void 0 && this.#s.get(this.#i[e]) === e;
|
|
283
|
+
}
|
|
284
|
+
*entries() {
|
|
285
|
+
for (let e of this.#A()) this.#t[e] !== void 0 && this.#i[e] !== void 0 && !this.#e(this.#t[e]) && (yield [this.#i[e], this.#t[e]]);
|
|
286
|
+
}
|
|
287
|
+
*rentries() {
|
|
288
|
+
for (let e of this.#z()) this.#t[e] !== void 0 && this.#i[e] !== void 0 && !this.#e(this.#t[e]) && (yield [this.#i[e], this.#t[e]]);
|
|
289
|
+
}
|
|
290
|
+
*keys() {
|
|
291
|
+
for (let e of this.#A()) {
|
|
292
|
+
let t = this.#i[e];
|
|
293
|
+
t !== void 0 && !this.#e(this.#t[e]) && (yield t);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
*rkeys() {
|
|
297
|
+
for (let e of this.#z()) {
|
|
298
|
+
let t = this.#i[e];
|
|
299
|
+
t !== void 0 && !this.#e(this.#t[e]) && (yield t);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
*values() {
|
|
303
|
+
for (let e of this.#A()) this.#t[e] !== void 0 && !this.#e(this.#t[e]) && (yield this.#t[e]);
|
|
304
|
+
}
|
|
305
|
+
*rvalues() {
|
|
306
|
+
for (let e of this.#z()) this.#t[e] !== void 0 && !this.#e(this.#t[e]) && (yield this.#t[e]);
|
|
307
|
+
}
|
|
308
|
+
[Symbol.iterator]() {
|
|
309
|
+
return this.entries();
|
|
310
|
+
}
|
|
311
|
+
[Symbol.toStringTag] = "LRUCache";
|
|
312
|
+
find(e, t = {}) {
|
|
313
|
+
for (let i of this.#A()) {
|
|
314
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
315
|
+
if (n !== void 0 && e(n, this.#i[i], this)) return this.#C(this.#i[i], t);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
forEach(e, t = this) {
|
|
319
|
+
for (let i of this.#A()) {
|
|
320
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
321
|
+
n !== void 0 && e.call(t, n, this.#i[i], this);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
rforEach(e, t = this) {
|
|
325
|
+
for (let i of this.#z()) {
|
|
326
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
327
|
+
n !== void 0 && e.call(t, n, this.#i[i], this);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
purgeStale() {
|
|
331
|
+
let e = false;
|
|
332
|
+
for (let t of this.#z({ allowStale: true })) this.#p(t) && (this.#E(this.#i[t], "expire"), e = true);
|
|
333
|
+
return e;
|
|
334
|
+
}
|
|
335
|
+
info(e) {
|
|
336
|
+
let t = this.#s.get(e);
|
|
337
|
+
if (t === void 0) return;
|
|
338
|
+
let i = this.#t[t], s = this.#e(i) ? i.__staleWhileFetching : i;
|
|
339
|
+
if (s === void 0) return;
|
|
340
|
+
let n = { value: s };
|
|
341
|
+
if (this.#d && this.#F) {
|
|
342
|
+
let o = this.#d[t], l = this.#F[t];
|
|
343
|
+
if (o && l) {
|
|
344
|
+
let h = o - (this.#m.now() - l);
|
|
345
|
+
n.ttl = h, n.start = Date.now();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return this.#_ && (n.size = this.#_[t]), n;
|
|
349
|
+
}
|
|
350
|
+
dump() {
|
|
351
|
+
let e = [];
|
|
352
|
+
for (let t of this.#A({ allowStale: true })) {
|
|
353
|
+
let i = this.#i[t], s = this.#t[t], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
354
|
+
if (n === void 0 || i === void 0) continue;
|
|
355
|
+
let o = { value: n };
|
|
356
|
+
if (this.#d && this.#F) {
|
|
357
|
+
o.ttl = this.#d[t];
|
|
358
|
+
let l = this.#m.now() - this.#F[t];
|
|
359
|
+
o.start = Math.floor(Date.now() - l);
|
|
360
|
+
}
|
|
361
|
+
this.#_ && (o.size = this.#_[t]), e.unshift([i, o]);
|
|
362
|
+
}
|
|
363
|
+
return e;
|
|
364
|
+
}
|
|
365
|
+
load(e) {
|
|
366
|
+
this.clear();
|
|
367
|
+
for (let [t, i] of e) {
|
|
368
|
+
if (i.start) {
|
|
369
|
+
let s = Date.now() - i.start;
|
|
370
|
+
i.start = this.#m.now() - s;
|
|
371
|
+
}
|
|
372
|
+
this.#W(t, i.value, i);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
set(e, t, i = {}) {
|
|
376
|
+
let { status: s = S.hasSubscribers ? {} : void 0 } = i;
|
|
377
|
+
i.status = s, s && (s.op = "set", s.key = e, t !== void 0 && (s.value = t), s.cache = this);
|
|
378
|
+
let n = this.#W(e, t, i);
|
|
379
|
+
return s && S.hasSubscribers && S.publish(s), n;
|
|
380
|
+
}
|
|
381
|
+
#W(e, t, i, s) {
|
|
382
|
+
let { ttl: n = this.ttl, start: o, noDisposeOnSet: l = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: r } = i, c = this.#e(t);
|
|
383
|
+
if (t === void 0) return r && (r.set = "deleted"), this.delete(e), this;
|
|
384
|
+
let { noUpdateTTL: m = this.noUpdateTTL } = i;
|
|
385
|
+
r && !c && (r.value = t);
|
|
386
|
+
let _ = this.#N(e, t, i.size || 0, h, r);
|
|
387
|
+
if (this.maxEntrySize && _ > this.maxEntrySize) return this.#E(e, "set"), r && (r.set = "miss", r.maxEntrySizeExceeded = true), this;
|
|
388
|
+
let u = this.#n === 0 ? void 0 : this.#s.get(e);
|
|
389
|
+
if (u === void 0) u = this.#n === 0 ? this.#h : this.#y.length !== 0 ? this.#y.pop() : this.#n === this.#o ? this.#G(false) : this.#n, this.#i[u] = e, this.#t[u] = t, this.#s.set(e, u), this.#l[this.#h] = u, this.#u[u] = this.#h, this.#h = u, this.#n++, this.#j(u, _, r), r && (r.set = "add"), m = false, this.#D && !c && this.#O?.(t, e, "add");
|
|
390
|
+
else {
|
|
391
|
+
this.#L(u);
|
|
392
|
+
let g = this.#t[u];
|
|
393
|
+
if (t !== g) {
|
|
394
|
+
if (!l) if (this.#e(g)) {
|
|
395
|
+
g !== s && g.__abortController.abort(new Error("replaced"));
|
|
396
|
+
let { __staleWhileFetching: f } = g;
|
|
397
|
+
f !== void 0 && f !== t && (this.#T && this.#S?.(f, e, "set"), this.#f && this.#r?.push([f, e, "set"]));
|
|
398
|
+
} else this.#T && this.#S?.(g, e, "set"), this.#f && this.#r?.push([g, e, "set"]);
|
|
399
|
+
if (this.#x(u), this.#j(u, _, r), this.#t[u] = t, !c) {
|
|
400
|
+
let f = g && this.#e(g) ? g.__staleWhileFetching : g, y = f === void 0 ? "add" : t !== f ? "replace" : "update";
|
|
401
|
+
r && (r.set = y, f !== void 0 && (r.oldValue = f)), this.#D && this.onInsert?.(t, e, y);
|
|
402
|
+
}
|
|
403
|
+
} else c || (r && (r.set = "update"), this.#D && this.onInsert?.(t, e, "update"));
|
|
404
|
+
}
|
|
405
|
+
if (n !== 0 && !this.#d && this.#k(), this.#d && (m || this.#H(u, n, o), r && this.#v(r, u)), !l && this.#f && this.#r) {
|
|
406
|
+
let g = this.#r, f;
|
|
407
|
+
for (; f = g?.shift(); ) this.#w?.(...f);
|
|
408
|
+
}
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
411
|
+
pop() {
|
|
412
|
+
try {
|
|
413
|
+
for (; this.#n; ) {
|
|
414
|
+
let e = this.#t[this.#a];
|
|
415
|
+
if (this.#G(true), this.#e(e)) {
|
|
416
|
+
if (e.__staleWhileFetching) return e.__staleWhileFetching;
|
|
417
|
+
} else if (e !== void 0) return e;
|
|
418
|
+
}
|
|
419
|
+
} finally {
|
|
420
|
+
if (this.#f && this.#r) {
|
|
421
|
+
let e = this.#r, t;
|
|
422
|
+
for (; t = e?.shift(); ) this.#w?.(...t);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
#G(e) {
|
|
427
|
+
let t = this.#a, i = this.#i[t], s = this.#t[t], n = this.#e(s);
|
|
428
|
+
n && s.__abortController.abort(new Error("evicted"));
|
|
429
|
+
let o = n ? s.__staleWhileFetching : s;
|
|
430
|
+
return (this.#T || this.#f) && o !== void 0 && (this.#T && this.#S?.(o, i, "evict"), this.#f && this.#r?.push([o, i, "evict"])), this.#x(t), this.#g?.[t] && (clearTimeout(this.#g[t]), this.#g[t] = void 0), e && (this.#i[t] = void 0, this.#t[t] = void 0, this.#y.push(t)), this.#n === 1 ? (this.#a = this.#h = 0, this.#y.length = 0) : this.#a = this.#l[t], this.#s.delete(i), this.#n--, t;
|
|
431
|
+
}
|
|
432
|
+
has(e, t = {}) {
|
|
433
|
+
let { status: i = S.hasSubscribers ? {} : void 0 } = t;
|
|
434
|
+
t.status = i, i && (i.op = "has", i.key = e, i.cache = this);
|
|
435
|
+
let s = this.#Y(e, t);
|
|
436
|
+
return S.hasSubscribers && S.publish(i), s;
|
|
437
|
+
}
|
|
438
|
+
#Y(e, t = {}) {
|
|
439
|
+
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t, n = this.#s.get(e);
|
|
440
|
+
if (n !== void 0) {
|
|
441
|
+
let o = this.#t[n];
|
|
442
|
+
if (this.#e(o) && o.__staleWhileFetching === void 0) return false;
|
|
443
|
+
if (this.#p(n)) s && (s.has = "stale", this.#v(s, n));
|
|
444
|
+
else return i && this.#R(n), s && (s.has = "hit", this.#v(s, n)), true;
|
|
445
|
+
} else s && (s.has = "miss");
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
peek(e, t = {}) {
|
|
449
|
+
let { status: i = R() ? {} : void 0 } = t;
|
|
450
|
+
i && (i.op = "peek", i.key = e, i.cache = this), t.status = i;
|
|
451
|
+
let s = this.#J(e, t);
|
|
452
|
+
return S.hasSubscribers && S.publish(i), s;
|
|
453
|
+
}
|
|
454
|
+
#J(e, t) {
|
|
455
|
+
let { status: i, allowStale: s = this.allowStale } = t, n = this.#s.get(e);
|
|
456
|
+
if (n === void 0 || !s && this.#p(n)) {
|
|
457
|
+
i && (i.peek = n === void 0 ? "miss" : "stale");
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
let o = this.#t[n], l = this.#e(o) ? o.__staleWhileFetching : o;
|
|
461
|
+
return i && (l !== void 0 ? (i.peek = "hit", i.value = l) : i.peek = "miss"), l;
|
|
462
|
+
}
|
|
463
|
+
#P(e, t, i, s) {
|
|
464
|
+
let n = t === void 0 ? void 0 : this.#t[t];
|
|
465
|
+
if (this.#e(n)) return n;
|
|
466
|
+
let o = new AbortController(), { signal: l } = i;
|
|
467
|
+
l?.addEventListener("abort", () => o.abort(l.reason), { signal: o.signal });
|
|
468
|
+
let h = { signal: o.signal, options: i, context: s }, r = (f, y = false) => {
|
|
469
|
+
let { aborted: a } = o.signal, w = i.ignoreFetchAbort && f !== void 0, F = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && f !== void 0);
|
|
470
|
+
if (i.status && (a && !y ? (i.status.fetchAborted = true, i.status.fetchError = o.signal.reason, w && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), a && !w && !y) return m(o.signal.reason, F);
|
|
471
|
+
let b = u, p = this.#t[t];
|
|
472
|
+
return (p === u || p === void 0 && w && y) && (f === void 0 ? b.__staleWhileFetching !== void 0 ? this.#t[t] = b.__staleWhileFetching : this.#E(e, "fetch") : (i.status && (i.status.fetchUpdated = true), this.#W(e, f, h.options, b))), f;
|
|
473
|
+
}, c = (f) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = f), m(f, false)), m = (f, y) => {
|
|
474
|
+
let { aborted: a } = o.signal, w = a && i.allowStaleOnFetchAbort, F = w || i.allowStaleOnFetchRejection, b = F || i.noDeleteOnFetchRejection, p = u;
|
|
475
|
+
if (this.#t[t] === u && (!b || !y && p.__staleWhileFetching === void 0 ? this.#E(e, "fetch") : w || (this.#t[t] = p.__staleWhileFetching)), F) return i.status && p.__staleWhileFetching !== void 0 && (i.status.returnedStale = true), p.__staleWhileFetching;
|
|
476
|
+
if (p.__returned === p) throw f;
|
|
477
|
+
}, _ = (f, y) => {
|
|
478
|
+
let a = this.#M?.(e, n, h);
|
|
479
|
+
o.signal.addEventListener("abort", () => {
|
|
480
|
+
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (f(void 0), i.allowStaleOnFetchAbort && (f = (w) => r(w, true)));
|
|
481
|
+
}), a && a instanceof Promise ? a.then((w) => f(w === void 0 ? void 0 : w), y) : a !== void 0 && f(a);
|
|
482
|
+
};
|
|
483
|
+
i.status && (i.status.fetchDispatched = true);
|
|
484
|
+
let u = new Promise(_).then(r, c), g = Object.assign(u, { __abortController: o, __staleWhileFetching: n, __returned: void 0 });
|
|
485
|
+
return t === void 0 ? (this.#W(e, g, { ...h.options, status: void 0 }), t = this.#s.get(e)) : this.#t[t] = g, g;
|
|
486
|
+
}
|
|
487
|
+
#e(e) {
|
|
488
|
+
if (!this.#U) return false;
|
|
489
|
+
let t = e;
|
|
490
|
+
return !!t && t instanceof Promise && t.hasOwnProperty("__staleWhileFetching") && t.__abortController instanceof AbortController;
|
|
491
|
+
}
|
|
492
|
+
fetch(e, t = {}) {
|
|
493
|
+
let i = W.hasSubscribers, { status: s = R() ? {} : void 0 } = t;
|
|
494
|
+
t.status = s, s && t.context && (s.context = t.context);
|
|
495
|
+
let n = this.#B(e, t);
|
|
496
|
+
return s && i && (s.trace = true, W.tracePromise(() => n, s).catch(() => {
|
|
497
|
+
})), n;
|
|
498
|
+
}
|
|
499
|
+
async #B(e, t = {}) {
|
|
500
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: l = this.noDisposeOnSet, size: h = 0, sizeCalculation: r = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: m = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: _ = this.allowStaleOnFetchRejection, ignoreFetchAbort: u = this.ignoreFetchAbort, allowStaleOnFetchAbort: g = this.allowStaleOnFetchAbort, context: f, forceRefresh: y = false, status: a, signal: w } = t;
|
|
501
|
+
if (a && (a.op = "fetch", a.key = e, y && (a.forceRefresh = true), a.cache = this), !this.#U) return a && (a.fetch = "get"), this.#C(e, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, status: a });
|
|
502
|
+
let F = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, ttl: o, noDisposeOnSet: l, size: h, sizeCalculation: r, noUpdateTTL: c, noDeleteOnFetchRejection: m, allowStaleOnFetchRejection: _, allowStaleOnFetchAbort: g, ignoreFetchAbort: u, status: a, signal: w }, b = this.#s.get(e);
|
|
503
|
+
if (b === void 0) {
|
|
504
|
+
a && (a.fetch = "miss");
|
|
505
|
+
let p = this.#P(e, b, F, f);
|
|
506
|
+
return p.__returned = p;
|
|
507
|
+
} else {
|
|
508
|
+
let p = this.#t[b];
|
|
509
|
+
if (this.#e(p)) {
|
|
510
|
+
let v = i && p.__staleWhileFetching !== void 0;
|
|
511
|
+
return a && (a.fetch = "inflight", v && (a.returnedStale = true)), v ? p.__staleWhileFetching : p.__returned = p;
|
|
512
|
+
}
|
|
513
|
+
let A = this.#p(b);
|
|
514
|
+
if (!y && !A) return a && (a.fetch = "hit"), this.#L(b), s && this.#R(b), a && this.#v(a, b), p;
|
|
515
|
+
let z = this.#P(e, b, F, f), E = z.__staleWhileFetching !== void 0 && i;
|
|
516
|
+
return a && (a.fetch = A ? "stale" : "refresh", E && A && (a.returnedStale = true)), E ? z.__staleWhileFetching : z.__returned = z;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
forceFetch(e, t = {}) {
|
|
520
|
+
let i = W.hasSubscribers, { status: s = R() ? {} : void 0 } = t;
|
|
521
|
+
t.status = s, s && t.context && (s.context = t.context);
|
|
522
|
+
let n = this.#K(e, t);
|
|
523
|
+
return s && i && (s.trace = true, W.tracePromise(() => n, s).catch(() => {
|
|
524
|
+
})), n;
|
|
525
|
+
}
|
|
526
|
+
async #K(e, t = {}) {
|
|
527
|
+
let i = await this.#B(e, t);
|
|
528
|
+
if (i === void 0) throw new Error("fetch() returned undefined");
|
|
529
|
+
return i;
|
|
530
|
+
}
|
|
531
|
+
memo(e, t = {}) {
|
|
532
|
+
let { status: i = S.hasSubscribers ? {} : void 0 } = t;
|
|
533
|
+
t.status = i, i && (i.op = "memo", i.key = e, t.context && (i.context = t.context), i.cache = this);
|
|
534
|
+
let s = this.#Q(e, t);
|
|
535
|
+
return i && (i.value = s), S.hasSubscribers && S.publish(i), s;
|
|
536
|
+
}
|
|
537
|
+
#Q(e, t = {}) {
|
|
538
|
+
let i = this.#I;
|
|
539
|
+
if (!i) throw new Error("no memoMethod provided to constructor");
|
|
540
|
+
let { context: s, status: n, forceRefresh: o, ...l } = t;
|
|
541
|
+
n && o && (n.forceRefresh = true);
|
|
542
|
+
let h = this.#C(e, l), r = o || h === void 0;
|
|
543
|
+
if (n && (n.memo = r ? "miss" : "hit", r || (n.value = h)), !r) return h;
|
|
544
|
+
let c = i(e, h, { options: l, context: s });
|
|
545
|
+
return n && (n.value = c), this.#W(e, c, l), c;
|
|
546
|
+
}
|
|
547
|
+
get(e, t = {}) {
|
|
548
|
+
let { status: i = S.hasSubscribers ? {} : void 0 } = t;
|
|
549
|
+
t.status = i, i && (i.op = "get", i.key = e, i.cache = this);
|
|
550
|
+
let s = this.#C(e, t);
|
|
551
|
+
return i && (s !== void 0 && (i.value = s), S.hasSubscribers && S.publish(i)), s;
|
|
552
|
+
}
|
|
553
|
+
#C(e, t = {}) {
|
|
554
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = t, l = this.#s.get(e);
|
|
555
|
+
if (l === void 0) {
|
|
556
|
+
o && (o.get = "miss");
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
let h = this.#t[l], r = this.#e(h);
|
|
560
|
+
return o && this.#v(o, l), this.#p(l) ? r ? (o && (o.get = "stale-fetching"), i && h.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = true), h.__staleWhileFetching) : void 0) : (n || this.#E(e, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = true), h) : void 0) : (o && (o.get = r ? "fetching" : "hit"), this.#L(l), s && this.#R(l), r ? h.__staleWhileFetching : h);
|
|
561
|
+
}
|
|
562
|
+
#$(e, t) {
|
|
563
|
+
this.#u[t] = e, this.#l[e] = t;
|
|
564
|
+
}
|
|
565
|
+
#L(e) {
|
|
566
|
+
e !== this.#h && (e === this.#a ? this.#a = this.#l[e] : this.#$(this.#u[e], this.#l[e]), this.#$(this.#h, e), this.#h = e);
|
|
567
|
+
}
|
|
568
|
+
delete(e) {
|
|
569
|
+
return this.#E(e, "delete");
|
|
570
|
+
}
|
|
571
|
+
#E(e, t) {
|
|
572
|
+
S.hasSubscribers && S.publish({ op: "delete", delete: t, key: e, cache: this });
|
|
573
|
+
let i = false;
|
|
574
|
+
if (this.#n !== 0) {
|
|
575
|
+
let s = this.#s.get(e);
|
|
576
|
+
if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g[s]), this.#g[s] = void 0), i = true, this.#n === 1) this.#q(t);
|
|
577
|
+
else {
|
|
578
|
+
this.#x(s);
|
|
579
|
+
let n = this.#t[s];
|
|
580
|
+
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#S?.(n, e, t), this.#f && this.#r?.push([n, e, t])), this.#s.delete(e), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
|
|
581
|
+
else if (s === this.#a) this.#a = this.#l[s];
|
|
582
|
+
else {
|
|
583
|
+
let o = this.#u[s];
|
|
584
|
+
this.#l[o] = this.#l[s];
|
|
585
|
+
let l = this.#l[s];
|
|
586
|
+
this.#u[l] = this.#u[s];
|
|
587
|
+
}
|
|
588
|
+
this.#n--, this.#y.push(s);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (this.#f && this.#r?.length) {
|
|
592
|
+
let s = this.#r, n;
|
|
593
|
+
for (; n = s?.shift(); ) this.#w?.(...n);
|
|
594
|
+
}
|
|
595
|
+
return i;
|
|
596
|
+
}
|
|
597
|
+
clear() {
|
|
598
|
+
return this.#q("delete");
|
|
599
|
+
}
|
|
600
|
+
#q(e) {
|
|
601
|
+
for (let t of this.#z({ allowStale: true })) {
|
|
602
|
+
let i = this.#t[t];
|
|
603
|
+
if (this.#e(i)) i.__abortController.abort(new Error("deleted"));
|
|
604
|
+
else {
|
|
605
|
+
let s = this.#i[t];
|
|
606
|
+
this.#T && this.#S?.(i, s, e), this.#f && this.#r?.push([i, s, e]);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
|
|
610
|
+
this.#d.fill(0), this.#F.fill(0);
|
|
611
|
+
for (let t of this.#g ?? []) t !== void 0 && clearTimeout(t);
|
|
612
|
+
this.#g?.fill(void 0);
|
|
613
|
+
}
|
|
614
|
+
if (this.#_ && this.#_.fill(0), this.#a = 0, this.#h = 0, this.#y.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
|
|
615
|
+
let t = this.#r, i;
|
|
616
|
+
for (; i = t?.shift(); ) this.#w?.(...i);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
export {
|
|
622
|
+
I,
|
|
623
|
+
emitter,
|
|
624
|
+
logRequest,
|
|
625
|
+
graphStep
|
|
626
|
+
};
|