@vltpkg/cli-js 1.0.0-rc.27 → 1.0.0-rc.29
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-6HRR4HXE.js +293 -0
- package/{bugs-CS34LDPD.js → bugs-2CAZQ32S.js} +19 -22
- package/{build-XHEFAWMN.js → build-OAWTNBMS.js} +10 -13
- package/{cache-LII2V5IM.js → cache-JTAFST6T.js} +14 -15
- package/cache-unzip-src-unzip.js +606 -575
- package/{chunk-D27QPHKI.js → chunk-2V4AQPBR.js} +67 -20
- package/{chunk-JQHMLTO5.js → chunk-3MWZTKGK.js} +419 -328
- package/{chunk-DJBBJDHI.js → chunk-7RZL7BZI.js} +159 -74
- package/chunk-7WHVJ56C.js +73 -0
- package/{chunk-LAG2R3YJ.js → chunk-BW6C3YUV.js} +6 -6
- package/{chunk-6YTJVEK2.js → chunk-CLDF5XLG.js} +11 -11
- package/{chunk-DYL7AFY7.js → chunk-CPM47YUH.js} +5 -3
- package/{chunk-QWWYZ3TT.js → chunk-D2MVJDUA.js} +1 -1
- package/{chunk-5E5GX4G6.js → chunk-FBTBHRPG.js} +1 -1
- package/{chunk-AZLX27EM.js → chunk-FXDRM4ZO.js} +296 -258
- package/chunk-G2YT2GWF.js +120 -0
- package/{chunk-INXSTZAX.js → chunk-HAGUS4HI.js} +21 -21
- package/{chunk-FI5TUER7.js → chunk-HQ4US6G3.js} +681 -687
- package/chunk-IEISSXS4.js +711 -0
- package/{chunk-TRXTSZFT.js → chunk-IYO5QKUW.js} +1 -1
- package/{chunk-DJBVQKBB.js → chunk-K3RN3BGU.js} +5 -5
- package/{chunk-P2HZ4ISK.js → chunk-LPLXAVG7.js} +54 -6
- package/{chunk-XSUIV5NF.js → chunk-M7HPHM7B.js} +14 -12
- package/{chunk-BIUCOMBH.js → chunk-MAIQR5GM.js} +5 -5
- package/{chunk-TDTJOKF2.js → chunk-NLFBANVO.js} +8 -1
- package/{chunk-XWF3GJKE.js → chunk-Q3DNNTPG.js} +27 -1
- package/{chunk-VCSVHRCS.js → chunk-R44FR7BY.js} +1269 -590
- package/{chunk-QDGZZ5FZ.js → chunk-TYV4N3S3.js} +6 -692
- package/{chunk-LKFTVDWS.js → chunk-VPKJNCKL.js} +26 -13
- package/{chunk-VTZZIXYW.js → chunk-VRIS5HAW.js} +3 -3
- package/{chunk-S5I2UOBT.js → chunk-WX2DCAG2.js} +7 -7
- package/{chunk-YR47M5L7.js → chunk-XYCCQT7N.js} +34 -39
- package/{chunk-D7U7KDEM.js → chunk-YCQTLBWF.js} +1 -1
- package/{chunk-SR66HWMM.js → chunk-ZINDEKAU.js} +144 -93
- package/{ci-EEXNEPKP.js → ci-TOJJVHI4.js} +13 -16
- package/cli-package.json +2 -1
- package/{config-4ZFJD5AY.js → config-DVAPEE5D.js} +12 -14
- package/{config-6MUU2TRJ.js → config-GOV4E2KK.js} +26 -26
- package/{create-DEKJKPYX.js → create-NGJD7K4L.js} +24 -26
- package/deprecate-WROL4AHK.js +176 -0
- package/{devtools-NOLON5YL.js → devtools-TPMVKPB5.js} +80 -77
- package/dist-tag-WZXXWXMB.js +204 -0
- package/{docs-5EKPZANX.js → docs-YCOZFMZG.js} +19 -22
- package/{exec-I4YPE6YW.js → exec-URG5OWLH.js} +24 -26
- package/{exec-cache-XEWPABLK.js → exec-cache-KHDOEH2F.js} +21 -23
- package/{exec-local-OQXG2VPW.js → exec-local-52TVUL5K.js} +19 -21
- package/{help-OG655SE5.js → help-LNSDVBGJ.js} +4 -5
- package/{init-LJH2YTBM.js → init-XNMWYATA.js} +10 -8
- package/{install-KP2FGWOR.js → install-SKUZERZJ.js} +28 -17
- package/{list-ACZ3ZSIZ.js → list-XEDVFUD5.js} +19 -21
- package/{login-VFTRKZE2.js → login-52SA2DSI.js} +6 -9
- package/{logout-Z4AVG64D.js → logout-5YYHNV5W.js} +6 -9
- package/{pack-GPJNX7RP.js → pack-B7QZHMYP.js} +14 -17
- package/package.json +1 -1
- package/{ping-B2YS4SR3.js → ping-PRGDYDRI.js} +6 -9
- package/{pkg-WUYJDFSH.js → pkg-UEIQIVVD.js} +15 -19
- package/profile-46FKVQEL.js +129 -0
- package/{publish-WTMGC4ET.js → publish-HBYHOSKH.js} +17 -20
- package/{query-UCM35VVC.js → query-5A4YLS2C.js} +19 -21
- package/registry-client-package.json +1 -1
- package/registry-client-src-revalidate.js +1157 -1032
- package/{repo-MZCPTQZU.js → repo-I6X66PHD.js} +19 -22
- package/{reporter-XRZ37LFK.js → reporter-NUXJTV4G.js} +2 -3
- package/{run-CAX4Z2SC.js → run-VEZMUMVH.js} +19 -21
- package/{run-exec-SM42FE7W.js → run-exec-6ADY4BKH.js} +19 -21
- package/security-archive-src-update-expired.js +8 -7
- package/{src-SDJWTPCU.js → src-O32QL33R.js} +20 -22
- package/token-YK6L74PA.js +206 -0
- package/{uninstall-YYPPXM2O.js → uninstall-UBUZBV7E.js} +14 -17
- package/unpublish-ZHJEKT7A.js +224 -0
- package/{update-YFUTH33A.js → update-WO4BHJF4.js} +13 -16
- package/{version-SK256WED.js → version-RLESYHML.js} +13 -16
- package/{view-CBYGJ76J.js → view-UA5HXFXG.js} +16 -17
- 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-ZT4ZEN2C.js → whoami-7H3FPR2O.js} +6 -9
- package/chunk-52LBC3AX.js +0 -75
- package/chunk-BGQCUUCA.js +0 -667
- package/chunk-E74WGW5C.js +0 -49
- package/chunk-JLJKOF75.js +0 -40
- package/chunk-YP4YNE5Y.js +0 -68
- package/token-YCURCCNR.js +0 -103
|
@@ -14,60 +14,43 @@ import {
|
|
|
14
14
|
__require
|
|
15
15
|
} from "./chunk-PZLD7RTK.js";
|
|
16
16
|
|
|
17
|
-
// ../../node_modules/.vlt/~npm~lru-cache@11.
|
|
17
|
+
// ../../node_modules/.vlt/~npm~lru-cache@11.3.5/node_modules/lru-cache/dist/commonjs/index.min.js
|
|
18
18
|
var require_index_min = __commonJS({
|
|
19
|
-
"../../node_modules/.vlt/~npm~lru-cache@11.
|
|
19
|
+
"../../node_modules/.vlt/~npm~lru-cache@11.3.5/node_modules/lru-cache/dist/commonjs/index.min.js"(exports) {
|
|
20
20
|
"use strict";
|
|
21
|
+
var G = (c, t) => () => (t || c((t = { exports: {} }).exports, t), t.exports);
|
|
22
|
+
var M = G((O) => {
|
|
23
|
+
"use strict";
|
|
24
|
+
Object.defineProperty(O, "__esModule", { value: true });
|
|
25
|
+
O.tracing = O.metrics = void 0;
|
|
26
|
+
var L = __require("node:diagnostics_channel");
|
|
27
|
+
O.metrics = (0, L.channel)("lru-cache:metrics");
|
|
28
|
+
O.tracing = (0, L.tracingChannel)("lru-cache");
|
|
29
|
+
});
|
|
21
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
31
|
exports.LRUCache = void 0;
|
|
23
|
-
var
|
|
32
|
+
var u = M();
|
|
33
|
+
var D = () => u.metrics.hasSubscribers || u.tracing.hasSubscribers;
|
|
34
|
+
var P = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
|
|
24
35
|
var U = /* @__PURE__ */ new Set();
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
typeof
|
|
36
|
+
var j = typeof process == "object" && process ? process : {};
|
|
37
|
+
var H = (c, t, e, i) => {
|
|
38
|
+
typeof j.emitWarning == "function" ? j.emitWarning(c, t, e, i) : console.error(`[${e}] ${t}: ${c}`);
|
|
28
39
|
};
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
onabort;
|
|
34
|
-
_onabort = [];
|
|
35
|
-
reason;
|
|
36
|
-
aborted = false;
|
|
37
|
-
addEventListener(i, s) {
|
|
38
|
-
this._onabort.push(s);
|
|
39
|
-
}
|
|
40
|
-
}, C = class {
|
|
41
|
-
constructor() {
|
|
42
|
-
t();
|
|
43
|
-
}
|
|
44
|
-
signal = new L();
|
|
45
|
-
abort(i) {
|
|
46
|
-
if (!this.signal.aborted) {
|
|
47
|
-
this.signal.reason = i, this.signal.aborted = true;
|
|
48
|
-
for (let s of this.signal._onabort) s(i);
|
|
49
|
-
this.signal.onabort?.(i);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
let c = R.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
|
|
54
|
-
c && (c = false, I("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", t));
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
var x = (c) => !U.has(c);
|
|
58
|
-
var y = (c) => c && c === Math.floor(c) && c > 0 && isFinite(c);
|
|
59
|
-
var M = (c) => y(c) ? c <= Math.pow(2, 8) ? Uint8Array : c <= Math.pow(2, 16) ? Uint16Array : c <= Math.pow(2, 32) ? Uint32Array : c <= Number.MAX_SAFE_INTEGER ? z : null : null;
|
|
60
|
-
var z = class extends Array {
|
|
40
|
+
var N = (c) => !U.has(c);
|
|
41
|
+
var F = (c) => !!c && c === Math.floor(c) && c > 0 && isFinite(c);
|
|
42
|
+
var I = (c) => F(c) ? c <= Math.pow(2, 8) ? Uint8Array : c <= Math.pow(2, 16) ? Uint16Array : c <= Math.pow(2, 32) ? Uint32Array : c <= Number.MAX_SAFE_INTEGER ? W : null : null;
|
|
43
|
+
var W = class extends Array {
|
|
61
44
|
constructor(t) {
|
|
62
45
|
super(t), this.fill(0);
|
|
63
46
|
}
|
|
64
47
|
};
|
|
65
|
-
var
|
|
48
|
+
var C = class c {
|
|
66
49
|
heap;
|
|
67
50
|
length;
|
|
68
51
|
static #o = false;
|
|
69
52
|
static create(t) {
|
|
70
|
-
let e =
|
|
53
|
+
let e = I(t);
|
|
71
54
|
if (!e) return [];
|
|
72
55
|
c.#o = true;
|
|
73
56
|
let i = new c(t, e);
|
|
@@ -84,17 +67,17 @@ var require_index_min = __commonJS({
|
|
|
84
67
|
return this.heap[--this.length];
|
|
85
68
|
}
|
|
86
69
|
};
|
|
87
|
-
var
|
|
70
|
+
var x = class c {
|
|
88
71
|
#o;
|
|
89
72
|
#c;
|
|
73
|
+
#m;
|
|
74
|
+
#D;
|
|
90
75
|
#w;
|
|
91
|
-
#
|
|
76
|
+
#M;
|
|
77
|
+
#j;
|
|
92
78
|
#S;
|
|
93
|
-
#L;
|
|
94
|
-
#U;
|
|
95
|
-
#m;
|
|
96
79
|
get perf() {
|
|
97
|
-
return this.#
|
|
80
|
+
return this.#S;
|
|
98
81
|
}
|
|
99
82
|
ttl;
|
|
100
83
|
ttlResolution;
|
|
@@ -112,30 +95,30 @@ var require_index_min = __commonJS({
|
|
|
112
95
|
allowStaleOnFetchRejection;
|
|
113
96
|
ignoreFetchAbort;
|
|
114
97
|
#n;
|
|
115
|
-
#
|
|
98
|
+
#b;
|
|
116
99
|
#s;
|
|
117
100
|
#i;
|
|
118
101
|
#t;
|
|
119
|
-
#a;
|
|
120
|
-
#u;
|
|
121
102
|
#l;
|
|
103
|
+
#u;
|
|
104
|
+
#a;
|
|
122
105
|
#h;
|
|
123
|
-
#b;
|
|
124
|
-
#r;
|
|
125
106
|
#y;
|
|
126
|
-
#
|
|
107
|
+
#r;
|
|
108
|
+
#_;
|
|
109
|
+
#F;
|
|
127
110
|
#d;
|
|
128
111
|
#g;
|
|
129
112
|
#T;
|
|
130
|
-
#
|
|
113
|
+
#O;
|
|
131
114
|
#f;
|
|
132
|
-
#
|
|
115
|
+
#U;
|
|
133
116
|
static unsafeExposeInternals(t) {
|
|
134
|
-
return { starts: t.#
|
|
135
|
-
return t.#
|
|
117
|
+
return { starts: t.#F, ttls: t.#d, autopurgeTimers: t.#g, sizes: t.#_, keyMap: t.#s, keyList: t.#i, valList: t.#t, next: t.#l, prev: t.#u, get head() {
|
|
118
|
+
return t.#a;
|
|
136
119
|
}, get tail() {
|
|
137
120
|
return t.#h;
|
|
138
|
-
}, free: t.#
|
|
121
|
+
}, free: t.#y, isBackgroundFetch: (e) => t.#e(e), backgroundFetch: (e, i, s, n) => t.#P(e, i, s, n), moveToTail: (e) => t.#L(e), indexes: (e) => t.#A(e), rindexes: (e) => t.#v(e), isStale: (e) => t.#p(e) };
|
|
139
122
|
}
|
|
140
123
|
get max() {
|
|
141
124
|
return this.#o;
|
|
@@ -144,196 +127,196 @@ var require_index_min = __commonJS({
|
|
|
144
127
|
return this.#c;
|
|
145
128
|
}
|
|
146
129
|
get calculatedSize() {
|
|
147
|
-
return this.#
|
|
130
|
+
return this.#b;
|
|
148
131
|
}
|
|
149
132
|
get size() {
|
|
150
133
|
return this.#n;
|
|
151
134
|
}
|
|
152
135
|
get fetchMethod() {
|
|
153
|
-
return this.#
|
|
136
|
+
return this.#M;
|
|
154
137
|
}
|
|
155
138
|
get memoMethod() {
|
|
156
|
-
return this.#
|
|
139
|
+
return this.#j;
|
|
157
140
|
}
|
|
158
141
|
get dispose() {
|
|
159
|
-
return this.#
|
|
142
|
+
return this.#m;
|
|
160
143
|
}
|
|
161
144
|
get onInsert() {
|
|
162
|
-
return this.#
|
|
145
|
+
return this.#D;
|
|
163
146
|
}
|
|
164
147
|
get disposeAfter() {
|
|
165
|
-
return this.#
|
|
148
|
+
return this.#w;
|
|
166
149
|
}
|
|
167
150
|
constructor(t) {
|
|
168
|
-
let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas:
|
|
169
|
-
if (
|
|
170
|
-
if (this.#
|
|
171
|
-
let
|
|
172
|
-
if (!
|
|
173
|
-
if (this.#o = e, this.#c =
|
|
151
|
+
let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: r, allowStale: h, dispose: a, onInsert: d, disposeAfter: f, noDisposeOnSet: p, noUpdateTTL: m, maxSize: T = 0, maxEntrySize: w = 0, sizeCalculation: y, fetchMethod: l, memoMethod: S, noDeleteOnFetchRejection: _, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: g, allowStaleOnFetchAbort: A, ignoreFetchAbort: v, perf: R } = t;
|
|
152
|
+
if (R !== void 0 && typeof R?.now != "function") throw new TypeError("perf option must have a now() method if specified");
|
|
153
|
+
if (this.#S = R ?? P, e !== 0 && !F(e)) throw new TypeError("max option must be a nonnegative integer");
|
|
154
|
+
let z = e ? I(e) : Array;
|
|
155
|
+
if (!z) throw new Error("invalid max value: " + e);
|
|
156
|
+
if (this.#o = e, this.#c = T, this.maxEntrySize = w || this.#c, this.sizeCalculation = y, this.sizeCalculation) {
|
|
174
157
|
if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
175
158
|
if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
|
|
176
159
|
}
|
|
177
160
|
if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
|
|
178
|
-
if (this.#
|
|
179
|
-
if (this.#
|
|
180
|
-
if (this.#c !== 0 && !
|
|
181
|
-
if (!
|
|
182
|
-
this.#
|
|
161
|
+
if (this.#j = S, l !== void 0 && typeof l != "function") throw new TypeError("fetchMethod must be a function if specified");
|
|
162
|
+
if (this.#M = l, this.#O = !!l, this.#s = /* @__PURE__ */ new Map(), this.#i = Array.from({ length: e }).fill(void 0), this.#t = Array.from({ length: e }).fill(void 0), this.#l = new z(e), this.#u = new z(e), this.#a = 0, this.#h = 0, this.#y = C.create(e), this.#n = 0, this.#b = 0, typeof a == "function" && (this.#m = a), typeof d == "function" && (this.#D = d), typeof f == "function" ? (this.#w = f, this.#r = []) : (this.#w = void 0, this.#r = void 0), this.#T = !!this.#m, this.#U = !!this.#D, this.#f = !!this.#w, this.noDisposeOnSet = !!p, this.noUpdateTTL = !!m, this.noDeleteOnFetchRejection = !!_, this.allowStaleOnFetchRejection = !!g, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!v, this.maxEntrySize !== 0) {
|
|
163
|
+
if (this.#c !== 0 && !F(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
|
|
164
|
+
if (!F(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
165
|
+
this.#X();
|
|
183
166
|
}
|
|
184
|
-
if (this.allowStale = !!
|
|
185
|
-
if (!
|
|
186
|
-
this.#
|
|
167
|
+
if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!r, this.ttlResolution = F(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
|
|
168
|
+
if (!F(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
|
|
169
|
+
this.#H();
|
|
187
170
|
}
|
|
188
171
|
if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
189
172
|
if (!this.ttlAutopurge && !this.#o && !this.#c) {
|
|
190
173
|
let E = "LRU_CACHE_UNBOUNDED";
|
|
191
|
-
|
|
174
|
+
N(E) && (U.add(E), H("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, c));
|
|
192
175
|
}
|
|
193
176
|
}
|
|
194
177
|
getRemainingTTL(t) {
|
|
195
178
|
return this.#s.has(t) ? 1 / 0 : 0;
|
|
196
179
|
}
|
|
197
|
-
#
|
|
198
|
-
let t = new
|
|
199
|
-
this.#d = t, this.#
|
|
200
|
-
let i = this.ttlAutopurge ?
|
|
201
|
-
this.#g = i, this.#N = (
|
|
202
|
-
e[
|
|
203
|
-
}, this.#R = (
|
|
204
|
-
e[
|
|
180
|
+
#H() {
|
|
181
|
+
let t = new W(this.#o), e = new W(this.#o);
|
|
182
|
+
this.#d = t, this.#F = e;
|
|
183
|
+
let i = this.ttlAutopurge ? Array.from({ length: this.#o }) : void 0;
|
|
184
|
+
this.#g = i, this.#N = (r, h, a = this.#S.now()) => {
|
|
185
|
+
e[r] = h !== 0 ? a : 0, t[r] = h, s(r, h);
|
|
186
|
+
}, this.#R = (r) => {
|
|
187
|
+
e[r] = t[r] !== 0 ? this.#S.now() : 0, s(r, t[r]);
|
|
205
188
|
};
|
|
206
|
-
let s = this.ttlAutopurge ? (
|
|
207
|
-
if (i?.[
|
|
189
|
+
let s = this.ttlAutopurge ? (r, h) => {
|
|
190
|
+
if (i?.[r] && (clearTimeout(i[r]), i[r] = void 0), h && h !== 0 && i) {
|
|
208
191
|
let a = setTimeout(() => {
|
|
209
|
-
this.#p(
|
|
210
|
-
},
|
|
211
|
-
a.unref && a.unref(), i[
|
|
192
|
+
this.#p(r) && this.#z(this.#i[r], "expire");
|
|
193
|
+
}, h + 1);
|
|
194
|
+
a.unref && a.unref(), i[r] = a;
|
|
212
195
|
}
|
|
213
196
|
} : () => {
|
|
214
197
|
};
|
|
215
|
-
this.#
|
|
216
|
-
if (t[
|
|
217
|
-
let a = t[
|
|
218
|
-
if (!a || !
|
|
219
|
-
|
|
220
|
-
let f =
|
|
221
|
-
|
|
198
|
+
this.#E = (r, h) => {
|
|
199
|
+
if (t[h]) {
|
|
200
|
+
let a = t[h], d = e[h];
|
|
201
|
+
if (!a || !d) return;
|
|
202
|
+
r.ttl = a, r.start = d, r.now = n || o();
|
|
203
|
+
let f = r.now - d;
|
|
204
|
+
r.remainingTTL = a - f;
|
|
222
205
|
}
|
|
223
206
|
};
|
|
224
207
|
let n = 0, o = () => {
|
|
225
|
-
let
|
|
208
|
+
let r = this.#S.now();
|
|
226
209
|
if (this.ttlResolution > 0) {
|
|
227
|
-
n =
|
|
228
|
-
let
|
|
229
|
-
|
|
210
|
+
n = r;
|
|
211
|
+
let h = setTimeout(() => n = 0, this.ttlResolution);
|
|
212
|
+
h.unref && h.unref();
|
|
230
213
|
}
|
|
231
|
-
return
|
|
214
|
+
return r;
|
|
232
215
|
};
|
|
233
|
-
this.getRemainingTTL = (
|
|
234
|
-
let
|
|
235
|
-
if (
|
|
236
|
-
let a = t[
|
|
237
|
-
if (!a || !
|
|
238
|
-
let f = (n || o()) -
|
|
216
|
+
this.getRemainingTTL = (r) => {
|
|
217
|
+
let h = this.#s.get(r);
|
|
218
|
+
if (h === void 0) return 0;
|
|
219
|
+
let a = t[h], d = e[h];
|
|
220
|
+
if (!a || !d) return 1 / 0;
|
|
221
|
+
let f = (n || o()) - d;
|
|
239
222
|
return a - f;
|
|
240
|
-
}, this.#p = (
|
|
241
|
-
let
|
|
242
|
-
return !!a && !!
|
|
223
|
+
}, this.#p = (r) => {
|
|
224
|
+
let h = e[r], a = t[r];
|
|
225
|
+
return !!a && !!h && (n || o()) - h > a;
|
|
243
226
|
};
|
|
244
227
|
}
|
|
245
228
|
#R = () => {
|
|
246
229
|
};
|
|
247
|
-
#
|
|
230
|
+
#E = () => {
|
|
248
231
|
};
|
|
249
232
|
#N = () => {
|
|
250
233
|
};
|
|
251
234
|
#p = () => false;
|
|
252
|
-
#
|
|
253
|
-
let t = new
|
|
254
|
-
this.#
|
|
255
|
-
this.#
|
|
256
|
-
}, this.#
|
|
235
|
+
#X() {
|
|
236
|
+
let t = new W(this.#o);
|
|
237
|
+
this.#b = 0, this.#_ = t, this.#C = (e) => {
|
|
238
|
+
this.#b -= t[e], t[e] = 0;
|
|
239
|
+
}, this.#k = (e, i, s, n) => {
|
|
257
240
|
if (this.#e(i)) return 0;
|
|
258
|
-
if (!
|
|
241
|
+
if (!F(s)) if (n) {
|
|
259
242
|
if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
|
|
260
|
-
if (s = n(i, e), !
|
|
243
|
+
if (s = n(i, e), !F(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
261
244
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
262
245
|
return s;
|
|
263
|
-
}, this.#
|
|
246
|
+
}, this.#I = (e, i, s) => {
|
|
264
247
|
if (t[e] = i, this.#c) {
|
|
265
248
|
let n = this.#c - t[e];
|
|
266
|
-
for (; this.#
|
|
249
|
+
for (; this.#b > n; ) this.#G(true);
|
|
267
250
|
}
|
|
268
|
-
this.#
|
|
251
|
+
this.#b += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
269
252
|
};
|
|
270
253
|
}
|
|
271
|
-
#
|
|
254
|
+
#C = (t) => {
|
|
272
255
|
};
|
|
273
|
-
#
|
|
256
|
+
#I = (t, e, i) => {
|
|
274
257
|
};
|
|
275
|
-
#
|
|
258
|
+
#k = (t, e, i, s) => {
|
|
276
259
|
if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
277
260
|
return 0;
|
|
278
261
|
};
|
|
279
|
-
*#
|
|
280
|
-
if (this.#n) for (let e = this.#h;
|
|
262
|
+
*#A({ allowStale: t = this.allowStale } = {}) {
|
|
263
|
+
if (this.#n) for (let e = this.#h; this.#V(e) && ((t || !this.#p(e)) && (yield e), e !== this.#a); ) e = this.#u[e];
|
|
281
264
|
}
|
|
282
|
-
*#
|
|
283
|
-
if (this.#n) for (let e = this.#
|
|
265
|
+
*#v({ allowStale: t = this.allowStale } = {}) {
|
|
266
|
+
if (this.#n) for (let e = this.#a; this.#V(e) && ((t || !this.#p(e)) && (yield e), e !== this.#h); ) e = this.#l[e];
|
|
284
267
|
}
|
|
285
|
-
#
|
|
268
|
+
#V(t) {
|
|
286
269
|
return t !== void 0 && this.#s.get(this.#i[t]) === t;
|
|
287
270
|
}
|
|
288
271
|
*entries() {
|
|
289
|
-
for (let t of this.#
|
|
272
|
+
for (let t of this.#A()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
|
|
290
273
|
}
|
|
291
274
|
*rentries() {
|
|
292
|
-
for (let t of this.#
|
|
275
|
+
for (let t of this.#v()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
|
|
293
276
|
}
|
|
294
277
|
*keys() {
|
|
295
|
-
for (let t of this.#
|
|
278
|
+
for (let t of this.#A()) {
|
|
296
279
|
let e = this.#i[t];
|
|
297
280
|
e !== void 0 && !this.#e(this.#t[t]) && (yield e);
|
|
298
281
|
}
|
|
299
282
|
}
|
|
300
283
|
*rkeys() {
|
|
301
|
-
for (let t of this.#
|
|
284
|
+
for (let t of this.#v()) {
|
|
302
285
|
let e = this.#i[t];
|
|
303
286
|
e !== void 0 && !this.#e(this.#t[t]) && (yield e);
|
|
304
287
|
}
|
|
305
288
|
}
|
|
306
289
|
*values() {
|
|
307
|
-
for (let t of this.#
|
|
290
|
+
for (let t of this.#A()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
|
|
308
291
|
}
|
|
309
292
|
*rvalues() {
|
|
310
|
-
for (let t of this.#
|
|
293
|
+
for (let t of this.#v()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
|
|
311
294
|
}
|
|
312
295
|
[Symbol.iterator]() {
|
|
313
296
|
return this.entries();
|
|
314
297
|
}
|
|
315
298
|
[Symbol.toStringTag] = "LRUCache";
|
|
316
299
|
find(t, e = {}) {
|
|
317
|
-
for (let i of this.#
|
|
300
|
+
for (let i of this.#A()) {
|
|
318
301
|
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
319
|
-
if (n !== void 0 && t(n, this.#i[i], this)) return this
|
|
302
|
+
if (n !== void 0 && t(n, this.#i[i], this)) return this.#x(this.#i[i], e);
|
|
320
303
|
}
|
|
321
304
|
}
|
|
322
305
|
forEach(t, e = this) {
|
|
323
|
-
for (let i of this.#
|
|
306
|
+
for (let i of this.#A()) {
|
|
324
307
|
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
325
308
|
n !== void 0 && t.call(e, n, this.#i[i], this);
|
|
326
309
|
}
|
|
327
310
|
}
|
|
328
311
|
rforEach(t, e = this) {
|
|
329
|
-
for (let i of this.#
|
|
312
|
+
for (let i of this.#v()) {
|
|
330
313
|
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
331
314
|
n !== void 0 && t.call(e, n, this.#i[i], this);
|
|
332
315
|
}
|
|
333
316
|
}
|
|
334
317
|
purgeStale() {
|
|
335
318
|
let t = false;
|
|
336
|
-
for (let e of this.#
|
|
319
|
+
for (let e of this.#v({ allowStale: true })) this.#p(e) && (this.#z(this.#i[e], "expire"), t = true);
|
|
337
320
|
return t;
|
|
338
321
|
}
|
|
339
322
|
info(t) {
|
|
@@ -342,27 +325,27 @@ var require_index_min = __commonJS({
|
|
|
342
325
|
let i = this.#t[e], s = this.#e(i) ? i.__staleWhileFetching : i;
|
|
343
326
|
if (s === void 0) return;
|
|
344
327
|
let n = { value: s };
|
|
345
|
-
if (this.#d && this.#
|
|
346
|
-
let o = this.#d[e],
|
|
347
|
-
if (o &&
|
|
348
|
-
let
|
|
349
|
-
n.ttl =
|
|
328
|
+
if (this.#d && this.#F) {
|
|
329
|
+
let o = this.#d[e], r = this.#F[e];
|
|
330
|
+
if (o && r) {
|
|
331
|
+
let h = o - (this.#S.now() - r);
|
|
332
|
+
n.ttl = h, n.start = Date.now();
|
|
350
333
|
}
|
|
351
334
|
}
|
|
352
|
-
return this.#
|
|
335
|
+
return this.#_ && (n.size = this.#_[e]), n;
|
|
353
336
|
}
|
|
354
337
|
dump() {
|
|
355
338
|
let t = [];
|
|
356
|
-
for (let e of this.#
|
|
339
|
+
for (let e of this.#A({ allowStale: true })) {
|
|
357
340
|
let i = this.#i[e], s = this.#t[e], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
358
341
|
if (n === void 0 || i === void 0) continue;
|
|
359
342
|
let o = { value: n };
|
|
360
|
-
if (this.#d && this.#
|
|
343
|
+
if (this.#d && this.#F) {
|
|
361
344
|
o.ttl = this.#d[e];
|
|
362
|
-
let
|
|
363
|
-
o.start = Math.floor(Date.now() -
|
|
345
|
+
let r = this.#S.now() - this.#F[e];
|
|
346
|
+
o.start = Math.floor(Date.now() - r);
|
|
364
347
|
}
|
|
365
|
-
this.#
|
|
348
|
+
this.#_ && (o.size = this.#_[e]), t.unshift([i, o]);
|
|
366
349
|
}
|
|
367
350
|
return t;
|
|
368
351
|
}
|
|
@@ -371,44 +354,53 @@ var require_index_min = __commonJS({
|
|
|
371
354
|
for (let [e, i] of t) {
|
|
372
355
|
if (i.start) {
|
|
373
356
|
let s = Date.now() - i.start;
|
|
374
|
-
i.start = this.#
|
|
357
|
+
i.start = this.#S.now() - s;
|
|
375
358
|
}
|
|
376
|
-
this
|
|
359
|
+
this.#W(e, i.value, i);
|
|
377
360
|
}
|
|
378
361
|
}
|
|
379
362
|
set(t, e, i = {}) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
363
|
+
let { status: s = u.metrics.hasSubscribers ? {} : void 0 } = i;
|
|
364
|
+
i.status = s, s && (s.op = "set", s.key = t, e !== void 0 && (s.value = e));
|
|
365
|
+
let n = this.#W(t, e, i);
|
|
366
|
+
return s && u.metrics.hasSubscribers && u.metrics.publish(s), n;
|
|
367
|
+
}
|
|
368
|
+
#W(t, e, i = {}) {
|
|
369
|
+
let { ttl: s = this.ttl, start: n, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: r = this.sizeCalculation, status: h } = i;
|
|
370
|
+
if (e === void 0) return h && (h.set = "deleted"), this.delete(t), this;
|
|
371
|
+
let { noUpdateTTL: a = this.noUpdateTTL } = i;
|
|
372
|
+
h && !this.#e(e) && (h.value = e);
|
|
373
|
+
let d = this.#k(t, e, i.size || 0, r, h);
|
|
374
|
+
if (this.maxEntrySize && d > this.maxEntrySize) return this.#z(t, "set"), h && (h.set = "miss", h.maxEntrySizeExceeded = true), this;
|
|
383
375
|
let f = this.#n === 0 ? void 0 : this.#s.get(t);
|
|
384
|
-
if (f === void 0) f = this.#n === 0 ? this.#h : this.#
|
|
376
|
+
if (f === void 0) f = this.#n === 0 ? this.#h : this.#y.length !== 0 ? this.#y.pop() : this.#n === this.#o ? this.#G(false) : this.#n, this.#i[f] = t, this.#t[f] = e, this.#s.set(t, f), this.#l[this.#h] = f, this.#u[f] = this.#h, this.#h = f, this.#n++, this.#I(f, d, h), h && (h.set = "add"), a = false, this.#U && this.#D?.(e, t, "add");
|
|
385
377
|
else {
|
|
386
|
-
this.#
|
|
387
|
-
let
|
|
388
|
-
if (e !==
|
|
389
|
-
if (this.#
|
|
390
|
-
|
|
391
|
-
let { __staleWhileFetching:
|
|
392
|
-
|
|
393
|
-
} else o || (this.#T && this.#
|
|
394
|
-
if (this.#
|
|
395
|
-
|
|
396
|
-
let
|
|
397
|
-
|
|
378
|
+
this.#L(f);
|
|
379
|
+
let p = this.#t[f];
|
|
380
|
+
if (e !== p) {
|
|
381
|
+
if (this.#O && this.#e(p)) {
|
|
382
|
+
p.__abortController.abort(new Error("replaced"));
|
|
383
|
+
let { __staleWhileFetching: m } = p;
|
|
384
|
+
m !== void 0 && !o && (this.#T && this.#m?.(m, t, "set"), this.#f && this.#r?.push([m, t, "set"]));
|
|
385
|
+
} else o || (this.#T && this.#m?.(p, t, "set"), this.#f && this.#r?.push([p, t, "set"]));
|
|
386
|
+
if (this.#C(f), this.#I(f, d, h), this.#t[f] = e, h) {
|
|
387
|
+
h.set = "replace";
|
|
388
|
+
let m = p && this.#e(p) ? p.__staleWhileFetching : p;
|
|
389
|
+
m !== void 0 && (h.oldValue = m);
|
|
398
390
|
}
|
|
399
|
-
} else
|
|
400
|
-
this.#
|
|
391
|
+
} else h && (h.set = "update");
|
|
392
|
+
this.#U && this.onInsert?.(e, t, e === p ? "update" : "replace");
|
|
401
393
|
}
|
|
402
|
-
if (s !== 0 && !this.#d && this.#
|
|
403
|
-
let
|
|
404
|
-
for (;
|
|
394
|
+
if (s !== 0 && !this.#d && this.#H(), this.#d && (a || this.#N(f, s, n), h && this.#E(h, f)), !o && this.#f && this.#r) {
|
|
395
|
+
let p = this.#r, m;
|
|
396
|
+
for (; m = p?.shift(); ) this.#w?.(...m);
|
|
405
397
|
}
|
|
406
398
|
return this;
|
|
407
399
|
}
|
|
408
400
|
pop() {
|
|
409
401
|
try {
|
|
410
402
|
for (; this.#n; ) {
|
|
411
|
-
let t = this.#t[this.#
|
|
403
|
+
let t = this.#t[this.#a];
|
|
412
404
|
if (this.#G(true), this.#e(t)) {
|
|
413
405
|
if (t.__staleWhileFetching) return t.__staleWhileFetching;
|
|
414
406
|
} else if (t !== void 0) return t;
|
|
@@ -416,157 +408,203 @@ var require_index_min = __commonJS({
|
|
|
416
408
|
} finally {
|
|
417
409
|
if (this.#f && this.#r) {
|
|
418
410
|
let t = this.#r, e;
|
|
419
|
-
for (; e = t?.shift(); ) this.#
|
|
411
|
+
for (; e = t?.shift(); ) this.#w?.(...e);
|
|
420
412
|
}
|
|
421
413
|
}
|
|
422
414
|
}
|
|
423
415
|
#G(t) {
|
|
424
|
-
let e = this.#
|
|
425
|
-
return this.#
|
|
416
|
+
let e = this.#a, i = this.#i[e], s = this.#t[e];
|
|
417
|
+
return this.#O && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#m?.(s, i, "evict"), this.#f && this.#r?.push([s, i, "evict"])), this.#C(e), this.#g?.[e] && (clearTimeout(this.#g[e]), this.#g[e] = void 0), t && (this.#i[e] = void 0, this.#t[e] = void 0, this.#y.push(e)), this.#n === 1 ? (this.#a = this.#h = 0, this.#y.length = 0) : this.#a = this.#l[e], this.#s.delete(i), this.#n--, e;
|
|
426
418
|
}
|
|
427
419
|
has(t, e = {}) {
|
|
420
|
+
let { status: i = u.metrics.hasSubscribers ? {} : void 0 } = e;
|
|
421
|
+
e.status = i, i && (i.op = "has", i.key = t);
|
|
422
|
+
let s = this.#Y(t, e);
|
|
423
|
+
return u.metrics.hasSubscribers && u.metrics.publish(i), s;
|
|
424
|
+
}
|
|
425
|
+
#Y(t, e = {}) {
|
|
428
426
|
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, n = this.#s.get(t);
|
|
429
427
|
if (n !== void 0) {
|
|
430
428
|
let o = this.#t[n];
|
|
431
429
|
if (this.#e(o) && o.__staleWhileFetching === void 0) return false;
|
|
432
|
-
if (this.#p(n)) s && (s.has = "stale", this.#
|
|
433
|
-
else return i && this.#R(n), s && (s.has = "hit", this.#
|
|
430
|
+
if (this.#p(n)) s && (s.has = "stale", this.#E(s, n));
|
|
431
|
+
else return i && this.#R(n), s && (s.has = "hit", this.#E(s, n)), true;
|
|
434
432
|
} else s && (s.has = "miss");
|
|
435
433
|
return false;
|
|
436
434
|
}
|
|
437
435
|
peek(t, e = {}) {
|
|
438
|
-
let {
|
|
439
|
-
|
|
440
|
-
let
|
|
441
|
-
return
|
|
436
|
+
let { status: i = D() ? {} : void 0 } = e;
|
|
437
|
+
i && (i.op = "peek", i.key = t), e.status = i;
|
|
438
|
+
let s = this.#J(t, e);
|
|
439
|
+
return u.metrics.hasSubscribers && u.metrics.publish(i), s;
|
|
440
|
+
}
|
|
441
|
+
#J(t, e) {
|
|
442
|
+
let { status: i, allowStale: s = this.allowStale } = e, n = this.#s.get(t);
|
|
443
|
+
if (n === void 0 || !s && this.#p(n)) {
|
|
444
|
+
i && (i.peek = n === void 0 ? "miss" : "stale");
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
let o = this.#t[n], r = this.#e(o) ? o.__staleWhileFetching : o;
|
|
448
|
+
return i && (r !== void 0 ? (i.peek = "hit", i.value = r) : i.peek = "miss"), r;
|
|
442
449
|
}
|
|
443
|
-
#
|
|
450
|
+
#P(t, e, i, s) {
|
|
444
451
|
let n = e === void 0 ? void 0 : this.#t[e];
|
|
445
452
|
if (this.#e(n)) return n;
|
|
446
|
-
let o = new
|
|
447
|
-
|
|
448
|
-
let
|
|
449
|
-
let { aborted: l } = o.signal, S = i.ignoreFetchAbort &&
|
|
450
|
-
if (i.status && (l && !
|
|
451
|
-
let
|
|
452
|
-
return (
|
|
453
|
-
},
|
|
454
|
-
let { aborted: l } = o.signal, S = l && i.allowStaleOnFetchAbort,
|
|
455
|
-
if (this.#t[e] ===
|
|
456
|
-
if (
|
|
457
|
-
},
|
|
458
|
-
let l = this.#
|
|
459
|
-
l && l instanceof Promise && l.then((S) =>
|
|
460
|
-
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (
|
|
453
|
+
let o = new AbortController(), { signal: r } = i;
|
|
454
|
+
r?.addEventListener("abort", () => o.abort(r.reason), { signal: o.signal });
|
|
455
|
+
let h = { signal: o.signal, options: i, context: s }, a = (w, y = false) => {
|
|
456
|
+
let { aborted: l } = o.signal, S = i.ignoreFetchAbort && w !== void 0, _ = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && w !== void 0);
|
|
457
|
+
if (i.status && (l && !y ? (i.status.fetchAborted = true, i.status.fetchError = o.signal.reason, S && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), l && !S && !y) return f(o.signal.reason, _);
|
|
458
|
+
let b = m, g = this.#t[e];
|
|
459
|
+
return (g === m || g === void 0 && S && y) && (w === void 0 ? b.__staleWhileFetching !== void 0 ? this.#t[e] = b.__staleWhileFetching : this.#z(t, "fetch") : (i.status && (i.status.fetchUpdated = true), this.#W(t, w, h.options))), w;
|
|
460
|
+
}, d = (w) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = w), f(w, false)), f = (w, y) => {
|
|
461
|
+
let { aborted: l } = o.signal, S = l && i.allowStaleOnFetchAbort, _ = S || i.allowStaleOnFetchRejection, b = _ || i.noDeleteOnFetchRejection, g = m;
|
|
462
|
+
if (this.#t[e] === m && (!b || !y && g.__staleWhileFetching === void 0 ? this.#z(t, "fetch") : S || (this.#t[e] = g.__staleWhileFetching)), _) return i.status && g.__staleWhileFetching !== void 0 && (i.status.returnedStale = true), g.__staleWhileFetching;
|
|
463
|
+
if (g.__returned === g) throw w;
|
|
464
|
+
}, p = (w, y) => {
|
|
465
|
+
let l = this.#M?.(t, n, h);
|
|
466
|
+
l && l instanceof Promise && l.then((S) => w(S === void 0 ? void 0 : S), y), o.signal.addEventListener("abort", () => {
|
|
467
|
+
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (w(void 0), i.allowStaleOnFetchAbort && (w = (S) => a(S, true)));
|
|
461
468
|
});
|
|
462
469
|
};
|
|
463
470
|
i.status && (i.status.fetchDispatched = true);
|
|
464
|
-
let
|
|
465
|
-
return e === void 0 ? (this
|
|
471
|
+
let m = new Promise(p).then(a, d), T = Object.assign(m, { __abortController: o, __staleWhileFetching: n, __returned: void 0 });
|
|
472
|
+
return e === void 0 ? (this.#W(t, T, { ...h.options, status: void 0 }), e = this.#s.get(t)) : this.#t[e] = T, T;
|
|
466
473
|
}
|
|
467
474
|
#e(t) {
|
|
468
|
-
if (!this.#
|
|
475
|
+
if (!this.#O) return false;
|
|
469
476
|
let e = t;
|
|
470
|
-
return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
let
|
|
474
|
-
|
|
475
|
-
let
|
|
476
|
-
|
|
477
|
+
return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof AbortController;
|
|
478
|
+
}
|
|
479
|
+
fetch(t, e = {}) {
|
|
480
|
+
let i = u.tracing.hasSubscribers, { status: s = D() ? {} : void 0 } = e;
|
|
481
|
+
e.status = s, s && e.context && (s.context = e.context);
|
|
482
|
+
let n = this.#q(t, e);
|
|
483
|
+
return s && D() && i && (s.trace = true, u.tracing.tracePromise(() => n, s).catch(() => {
|
|
484
|
+
})), n;
|
|
485
|
+
}
|
|
486
|
+
async #q(t, e = {}) {
|
|
487
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: r = this.noDisposeOnSet, size: h = 0, sizeCalculation: a = this.sizeCalculation, noUpdateTTL: d = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: p = this.allowStaleOnFetchRejection, ignoreFetchAbort: m = this.ignoreFetchAbort, allowStaleOnFetchAbort: T = this.allowStaleOnFetchAbort, context: w, forceRefresh: y = false, status: l, signal: S } = e;
|
|
488
|
+
if (l && (l.op = "fetch", l.key = t, y && (l.forceRefresh = true)), !this.#O) return l && (l.fetch = "get"), this.#x(t, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, status: l });
|
|
489
|
+
let _ = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, ttl: o, noDisposeOnSet: r, size: h, sizeCalculation: a, noUpdateTTL: d, noDeleteOnFetchRejection: f, allowStaleOnFetchRejection: p, allowStaleOnFetchAbort: T, ignoreFetchAbort: m, status: l, signal: S }, b = this.#s.get(t);
|
|
490
|
+
if (b === void 0) {
|
|
477
491
|
l && (l.fetch = "miss");
|
|
478
|
-
let
|
|
479
|
-
return
|
|
492
|
+
let g = this.#P(t, b, _, w);
|
|
493
|
+
return g.__returned = g;
|
|
480
494
|
} else {
|
|
481
|
-
let
|
|
482
|
-
if (this.#e(
|
|
483
|
-
let E = i &&
|
|
484
|
-
return l && (l.fetch = "inflight", E && (l.returnedStale = true)), E ?
|
|
495
|
+
let g = this.#t[b];
|
|
496
|
+
if (this.#e(g)) {
|
|
497
|
+
let E = i && g.__staleWhileFetching !== void 0;
|
|
498
|
+
return l && (l.fetch = "inflight", E && (l.returnedStale = true)), E ? g.__staleWhileFetching : g.__returned = g;
|
|
485
499
|
}
|
|
486
|
-
let
|
|
487
|
-
if (!
|
|
488
|
-
let
|
|
489
|
-
return l && (l.fetch =
|
|
500
|
+
let A = this.#p(b);
|
|
501
|
+
if (!y && !A) return l && (l.fetch = "hit"), this.#L(b), s && this.#R(b), l && this.#E(l, b), g;
|
|
502
|
+
let v = this.#P(t, b, _, w), z = v.__staleWhileFetching !== void 0 && i;
|
|
503
|
+
return l && (l.fetch = A ? "stale" : "refresh", z && A && (l.returnedStale = true)), z ? v.__staleWhileFetching : v.__returned = v;
|
|
490
504
|
}
|
|
491
505
|
}
|
|
492
|
-
|
|
493
|
-
let i =
|
|
506
|
+
forceFetch(t, e = {}) {
|
|
507
|
+
let i = u.tracing.hasSubscribers, { status: s = D() ? {} : void 0 } = e;
|
|
508
|
+
e.status = s, s && e.context && (s.context = e.context);
|
|
509
|
+
let n = this.#K(t, e);
|
|
510
|
+
return s && D() && i && (s.trace = true, u.tracing.tracePromise(() => n, s).catch(() => {
|
|
511
|
+
})), n;
|
|
512
|
+
}
|
|
513
|
+
async #K(t, e = {}) {
|
|
514
|
+
let i = await this.#q(t, e);
|
|
494
515
|
if (i === void 0) throw new Error("fetch() returned undefined");
|
|
495
516
|
return i;
|
|
496
517
|
}
|
|
497
518
|
memo(t, e = {}) {
|
|
498
|
-
let i =
|
|
519
|
+
let { status: i = u.metrics.hasSubscribers ? {} : void 0 } = e;
|
|
520
|
+
e.status = i, i && (i.op = "memo", i.key = t, e.context && (i.context = e.context));
|
|
521
|
+
let s = this.#Q(t, e);
|
|
522
|
+
return i && (i.value = s), u.metrics.hasSubscribers && u.metrics.publish(i), s;
|
|
523
|
+
}
|
|
524
|
+
#Q(t, e = {}) {
|
|
525
|
+
let i = this.#j;
|
|
499
526
|
if (!i) throw new Error("no memoMethod provided to constructor");
|
|
500
|
-
let { context: s,
|
|
501
|
-
|
|
502
|
-
let
|
|
503
|
-
|
|
527
|
+
let { context: s, status: n, forceRefresh: o, ...r } = e;
|
|
528
|
+
n && o && (n.forceRefresh = true);
|
|
529
|
+
let h = this.#x(t, r), a = o || h === void 0;
|
|
530
|
+
if (n && (n.memo = a ? "miss" : "hit", a || (n.value = h)), !a) return h;
|
|
531
|
+
let d = i(t, h, { options: r, context: s });
|
|
532
|
+
return n && (n.value = d), this.#W(t, d, r), d;
|
|
504
533
|
}
|
|
505
534
|
get(t, e = {}) {
|
|
506
|
-
let {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
535
|
+
let { status: i = u.metrics.hasSubscribers ? {} : void 0 } = e;
|
|
536
|
+
e.status = i, i && (i.op = "get", i.key = t);
|
|
537
|
+
let s = this.#x(t, e);
|
|
538
|
+
return i && (s !== void 0 && (i.value = s), u.metrics.hasSubscribers && u.metrics.publish(i)), s;
|
|
539
|
+
}
|
|
540
|
+
#x(t, e = {}) {
|
|
541
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, r = this.#s.get(t);
|
|
542
|
+
if (r === void 0) {
|
|
543
|
+
o && (o.get = "miss");
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
let h = this.#t[r], a = this.#e(h);
|
|
547
|
+
return o && this.#E(o, r), this.#p(r) ? a ? (o && (o.get = "stale-fetching"), i && h.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = true), h.__staleWhileFetching) : void 0) : (n || this.#z(t, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = true), h) : void 0) : (o && (o.get = a ? "fetching" : "hit"), this.#L(r), s && this.#R(r), a ? h.__staleWhileFetching : h);
|
|
511
548
|
}
|
|
512
|
-
#
|
|
513
|
-
this.#u[e] = t, this.#
|
|
549
|
+
#B(t, e) {
|
|
550
|
+
this.#u[e] = t, this.#l[t] = e;
|
|
514
551
|
}
|
|
515
|
-
#
|
|
516
|
-
t !== this.#h && (t === this.#
|
|
552
|
+
#L(t) {
|
|
553
|
+
t !== this.#h && (t === this.#a ? this.#a = this.#l[t] : this.#B(this.#u[t], this.#l[t]), this.#B(this.#h, t), this.#h = t);
|
|
517
554
|
}
|
|
518
555
|
delete(t) {
|
|
519
|
-
return this.#
|
|
556
|
+
return this.#z(t, "delete");
|
|
520
557
|
}
|
|
521
|
-
#
|
|
558
|
+
#z(t, e) {
|
|
559
|
+
u.metrics.hasSubscribers && u.metrics.publish({ op: "delete", delete: e, key: t });
|
|
522
560
|
let i = false;
|
|
523
561
|
if (this.#n !== 0) {
|
|
524
562
|
let s = this.#s.get(t);
|
|
525
|
-
if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = true, this.#n === 1) this
|
|
563
|
+
if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = true, this.#n === 1) this.#$(e);
|
|
526
564
|
else {
|
|
527
|
-
this.#
|
|
565
|
+
this.#C(s);
|
|
528
566
|
let n = this.#t[s];
|
|
529
|
-
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#
|
|
530
|
-
else if (s === this.#
|
|
567
|
+
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#m?.(n, t, e), this.#f && this.#r?.push([n, t, e])), this.#s.delete(t), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
|
|
568
|
+
else if (s === this.#a) this.#a = this.#l[s];
|
|
531
569
|
else {
|
|
532
570
|
let o = this.#u[s];
|
|
533
|
-
this.#
|
|
534
|
-
let
|
|
535
|
-
this.#u[
|
|
571
|
+
this.#l[o] = this.#l[s];
|
|
572
|
+
let r = this.#l[s];
|
|
573
|
+
this.#u[r] = this.#u[s];
|
|
536
574
|
}
|
|
537
|
-
this.#n--, this.#
|
|
575
|
+
this.#n--, this.#y.push(s);
|
|
538
576
|
}
|
|
539
577
|
}
|
|
540
578
|
if (this.#f && this.#r?.length) {
|
|
541
579
|
let s = this.#r, n;
|
|
542
|
-
for (; n = s?.shift(); ) this.#
|
|
580
|
+
for (; n = s?.shift(); ) this.#w?.(...n);
|
|
543
581
|
}
|
|
544
582
|
return i;
|
|
545
583
|
}
|
|
546
584
|
clear() {
|
|
547
|
-
return this
|
|
585
|
+
return this.#$("delete");
|
|
548
586
|
}
|
|
549
|
-
|
|
550
|
-
for (let e of this.#
|
|
587
|
+
#$(t) {
|
|
588
|
+
for (let e of this.#v({ allowStale: true })) {
|
|
551
589
|
let i = this.#t[e];
|
|
552
590
|
if (this.#e(i)) i.__abortController.abort(new Error("deleted"));
|
|
553
591
|
else {
|
|
554
592
|
let s = this.#i[e];
|
|
555
|
-
this.#T && this.#
|
|
593
|
+
this.#T && this.#m?.(i, s, t), this.#f && this.#r?.push([i, s, t]);
|
|
556
594
|
}
|
|
557
595
|
}
|
|
558
|
-
if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#
|
|
559
|
-
this.#d.fill(0), this.#
|
|
596
|
+
if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
|
|
597
|
+
this.#d.fill(0), this.#F.fill(0);
|
|
560
598
|
for (let e of this.#g ?? []) e !== void 0 && clearTimeout(e);
|
|
561
599
|
this.#g?.fill(void 0);
|
|
562
600
|
}
|
|
563
|
-
if (this.#
|
|
601
|
+
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) {
|
|
564
602
|
let e = this.#r, i;
|
|
565
|
-
for (; i = e?.shift(); ) this.#
|
|
603
|
+
for (; i = e?.shift(); ) this.#w?.(...i);
|
|
566
604
|
}
|
|
567
605
|
}
|
|
568
606
|
};
|
|
569
|
-
exports.LRUCache =
|
|
607
|
+
exports.LRUCache = x;
|
|
570
608
|
}
|
|
571
609
|
});
|
|
572
610
|
|