@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.
Files changed (85) hide show
  1. package/access-6HRR4HXE.js +293 -0
  2. package/{bugs-CS34LDPD.js → bugs-2CAZQ32S.js} +19 -22
  3. package/{build-XHEFAWMN.js → build-OAWTNBMS.js} +10 -13
  4. package/{cache-LII2V5IM.js → cache-JTAFST6T.js} +14 -15
  5. package/cache-unzip-src-unzip.js +606 -575
  6. package/{chunk-D27QPHKI.js → chunk-2V4AQPBR.js} +67 -20
  7. package/{chunk-JQHMLTO5.js → chunk-3MWZTKGK.js} +419 -328
  8. package/{chunk-DJBBJDHI.js → chunk-7RZL7BZI.js} +159 -74
  9. package/chunk-7WHVJ56C.js +73 -0
  10. package/{chunk-LAG2R3YJ.js → chunk-BW6C3YUV.js} +6 -6
  11. package/{chunk-6YTJVEK2.js → chunk-CLDF5XLG.js} +11 -11
  12. package/{chunk-DYL7AFY7.js → chunk-CPM47YUH.js} +5 -3
  13. package/{chunk-QWWYZ3TT.js → chunk-D2MVJDUA.js} +1 -1
  14. package/{chunk-5E5GX4G6.js → chunk-FBTBHRPG.js} +1 -1
  15. package/{chunk-AZLX27EM.js → chunk-FXDRM4ZO.js} +296 -258
  16. package/chunk-G2YT2GWF.js +120 -0
  17. package/{chunk-INXSTZAX.js → chunk-HAGUS4HI.js} +21 -21
  18. package/{chunk-FI5TUER7.js → chunk-HQ4US6G3.js} +681 -687
  19. package/chunk-IEISSXS4.js +711 -0
  20. package/{chunk-TRXTSZFT.js → chunk-IYO5QKUW.js} +1 -1
  21. package/{chunk-DJBVQKBB.js → chunk-K3RN3BGU.js} +5 -5
  22. package/{chunk-P2HZ4ISK.js → chunk-LPLXAVG7.js} +54 -6
  23. package/{chunk-XSUIV5NF.js → chunk-M7HPHM7B.js} +14 -12
  24. package/{chunk-BIUCOMBH.js → chunk-MAIQR5GM.js} +5 -5
  25. package/{chunk-TDTJOKF2.js → chunk-NLFBANVO.js} +8 -1
  26. package/{chunk-XWF3GJKE.js → chunk-Q3DNNTPG.js} +27 -1
  27. package/{chunk-VCSVHRCS.js → chunk-R44FR7BY.js} +1269 -590
  28. package/{chunk-QDGZZ5FZ.js → chunk-TYV4N3S3.js} +6 -692
  29. package/{chunk-LKFTVDWS.js → chunk-VPKJNCKL.js} +26 -13
  30. package/{chunk-VTZZIXYW.js → chunk-VRIS5HAW.js} +3 -3
  31. package/{chunk-S5I2UOBT.js → chunk-WX2DCAG2.js} +7 -7
  32. package/{chunk-YR47M5L7.js → chunk-XYCCQT7N.js} +34 -39
  33. package/{chunk-D7U7KDEM.js → chunk-YCQTLBWF.js} +1 -1
  34. package/{chunk-SR66HWMM.js → chunk-ZINDEKAU.js} +144 -93
  35. package/{ci-EEXNEPKP.js → ci-TOJJVHI4.js} +13 -16
  36. package/cli-package.json +2 -1
  37. package/{config-4ZFJD5AY.js → config-DVAPEE5D.js} +12 -14
  38. package/{config-6MUU2TRJ.js → config-GOV4E2KK.js} +26 -26
  39. package/{create-DEKJKPYX.js → create-NGJD7K4L.js} +24 -26
  40. package/deprecate-WROL4AHK.js +176 -0
  41. package/{devtools-NOLON5YL.js → devtools-TPMVKPB5.js} +80 -77
  42. package/dist-tag-WZXXWXMB.js +204 -0
  43. package/{docs-5EKPZANX.js → docs-YCOZFMZG.js} +19 -22
  44. package/{exec-I4YPE6YW.js → exec-URG5OWLH.js} +24 -26
  45. package/{exec-cache-XEWPABLK.js → exec-cache-KHDOEH2F.js} +21 -23
  46. package/{exec-local-OQXG2VPW.js → exec-local-52TVUL5K.js} +19 -21
  47. package/{help-OG655SE5.js → help-LNSDVBGJ.js} +4 -5
  48. package/{init-LJH2YTBM.js → init-XNMWYATA.js} +10 -8
  49. package/{install-KP2FGWOR.js → install-SKUZERZJ.js} +28 -17
  50. package/{list-ACZ3ZSIZ.js → list-XEDVFUD5.js} +19 -21
  51. package/{login-VFTRKZE2.js → login-52SA2DSI.js} +6 -9
  52. package/{logout-Z4AVG64D.js → logout-5YYHNV5W.js} +6 -9
  53. package/{pack-GPJNX7RP.js → pack-B7QZHMYP.js} +14 -17
  54. package/package.json +1 -1
  55. package/{ping-B2YS4SR3.js → ping-PRGDYDRI.js} +6 -9
  56. package/{pkg-WUYJDFSH.js → pkg-UEIQIVVD.js} +15 -19
  57. package/profile-46FKVQEL.js +129 -0
  58. package/{publish-WTMGC4ET.js → publish-HBYHOSKH.js} +17 -20
  59. package/{query-UCM35VVC.js → query-5A4YLS2C.js} +19 -21
  60. package/registry-client-package.json +1 -1
  61. package/registry-client-src-revalidate.js +1157 -1032
  62. package/{repo-MZCPTQZU.js → repo-I6X66PHD.js} +19 -22
  63. package/{reporter-XRZ37LFK.js → reporter-NUXJTV4G.js} +2 -3
  64. package/{run-CAX4Z2SC.js → run-VEZMUMVH.js} +19 -21
  65. package/{run-exec-SM42FE7W.js → run-exec-6ADY4BKH.js} +19 -21
  66. package/security-archive-src-update-expired.js +8 -7
  67. package/{src-SDJWTPCU.js → src-O32QL33R.js} +20 -22
  68. package/token-YK6L74PA.js +206 -0
  69. package/{uninstall-YYPPXM2O.js → uninstall-UBUZBV7E.js} +14 -17
  70. package/unpublish-ZHJEKT7A.js +224 -0
  71. package/{update-YFUTH33A.js → update-WO4BHJF4.js} +13 -16
  72. package/{version-SK256WED.js → version-RLESYHML.js} +13 -16
  73. package/{view-CBYGJ76J.js → view-UA5HXFXG.js} +16 -17
  74. package/vlr.js +1 -1
  75. package/vlrx.js +1 -1
  76. package/vlt.js +1 -1
  77. package/vlx.js +1 -1
  78. package/vlxl.js +1 -1
  79. package/{whoami-ZT4ZEN2C.js → whoami-7H3FPR2O.js} +6 -9
  80. package/chunk-52LBC3AX.js +0 -75
  81. package/chunk-BGQCUUCA.js +0 -667
  82. package/chunk-E74WGW5C.js +0 -49
  83. package/chunk-JLJKOF75.js +0 -40
  84. package/chunk-YP4YNE5Y.js +0 -68
  85. 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.2.7/node_modules/lru-cache/dist/commonjs/index.min.js
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.2.7/node_modules/lru-cache/dist/commonjs/index.min.js"(exports) {
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 G = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
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 R = typeof process == "object" && process ? process : {};
26
- var I = (c, t, e, i) => {
27
- typeof R.emitWarning == "function" ? R.emitWarning(c, t, e, i) : console.error(`[${e}] ${t}: ${c}`);
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 C = globalThis.AbortController;
30
- var L = globalThis.AbortSignal;
31
- if (typeof C > "u") {
32
- L = class {
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 W = class c {
48
+ var C = class c {
66
49
  heap;
67
50
  length;
68
51
  static #o = false;
69
52
  static create(t) {
70
- let e = M(t);
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 D = class c {
70
+ var x = class c {
88
71
  #o;
89
72
  #c;
73
+ #m;
74
+ #D;
90
75
  #w;
91
- #C;
76
+ #M;
77
+ #j;
92
78
  #S;
93
- #L;
94
- #U;
95
- #m;
96
79
  get perf() {
97
- return this.#m;
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
- #A;
107
+ #r;
108
+ #_;
109
+ #F;
127
110
  #d;
128
111
  #g;
129
112
  #T;
130
- #v;
113
+ #O;
131
114
  #f;
132
- #I;
115
+ #U;
133
116
  static unsafeExposeInternals(t) {
134
- return { starts: t.#A, ttls: t.#d, autopurgeTimers: t.#g, sizes: t.#y, keyMap: t.#s, keyList: t.#i, valList: t.#t, next: t.#a, prev: t.#u, get head() {
135
- return t.#l;
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.#b, isBackgroundFetch: (e) => t.#e(e), backgroundFetch: (e, i, s, n) => t.#x(e, i, s, n), moveToTail: (e) => t.#D(e), indexes: (e) => t.#F(e), rindexes: (e) => t.#O(e), isStale: (e) => t.#p(e) };
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.#L;
136
+ return this.#M;
154
137
  }
155
138
  get memoMethod() {
156
- return this.#U;
139
+ return this.#j;
157
140
  }
158
141
  get dispose() {
159
- return this.#w;
142
+ return this.#m;
160
143
  }
161
144
  get onInsert() {
162
- return this.#C;
145
+ return this.#D;
163
146
  }
164
147
  get disposeAfter() {
165
- return this.#S;
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: h, allowStale: r, dispose: a, onInsert: w, disposeAfter: f, noDisposeOnSet: d, noUpdateTTL: g, maxSize: A = 0, maxEntrySize: p = 0, sizeCalculation: _, fetchMethod: l, memoMethod: S, noDeleteOnFetchRejection: b, noDeleteOnStaleGet: m, allowStaleOnFetchRejection: u, allowStaleOnFetchAbort: T, ignoreFetchAbort: F, perf: v } = t;
169
- if (v !== void 0 && typeof v?.now != "function") throw new TypeError("perf option must have a now() method if specified");
170
- if (this.#m = v ?? G, e !== 0 && !y(e)) throw new TypeError("max option must be a nonnegative integer");
171
- let O = e ? M(e) : Array;
172
- if (!O) throw new Error("invalid max value: " + e);
173
- if (this.#o = e, this.#c = A, this.maxEntrySize = p || this.#c, this.sizeCalculation = _, this.sizeCalculation) {
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.#U = S, l !== void 0 && typeof l != "function") throw new TypeError("fetchMethod must be a function if specified");
179
- if (this.#L = l, this.#v = !!l, this.#s = /* @__PURE__ */ new Map(), this.#i = new Array(e).fill(void 0), this.#t = new Array(e).fill(void 0), this.#a = new O(e), this.#u = new O(e), this.#l = 0, this.#h = 0, this.#b = W.create(e), this.#n = 0, this.#_ = 0, typeof a == "function" && (this.#w = a), typeof w == "function" && (this.#C = w), typeof f == "function" ? (this.#S = f, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#w, this.#I = !!this.#C, this.#f = !!this.#S, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!g, this.noDeleteOnFetchRejection = !!b, this.allowStaleOnFetchRejection = !!u, this.allowStaleOnFetchAbort = !!T, this.ignoreFetchAbort = !!F, this.maxEntrySize !== 0) {
180
- if (this.#c !== 0 && !y(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
181
- if (!y(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
182
- this.#B();
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 = !!r, this.noDeleteOnStaleGet = !!m, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = y(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
185
- if (!y(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
186
- this.#j();
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
- x(E) && (U.add(E), I("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, c));
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
- #j() {
198
- let t = new z(this.#o), e = new z(this.#o);
199
- this.#d = t, this.#A = e;
200
- let i = this.ttlAutopurge ? new Array(this.#o) : void 0;
201
- this.#g = i, this.#N = (h, r, a = this.#m.now()) => {
202
- e[h] = r !== 0 ? a : 0, t[h] = r, s(h, r);
203
- }, this.#R = (h) => {
204
- e[h] = t[h] !== 0 ? this.#m.now() : 0, s(h, t[h]);
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 ? (h, r) => {
207
- if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), r && r !== 0 && 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(h) && this.#E(this.#i[h], "expire");
210
- }, r + 1);
211
- a.unref && a.unref(), i[h] = a;
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.#z = (h, r) => {
216
- if (t[r]) {
217
- let a = t[r], w = e[r];
218
- if (!a || !w) return;
219
- h.ttl = a, h.start = w, h.now = n || o();
220
- let f = h.now - w;
221
- h.remainingTTL = a - f;
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 h = this.#m.now();
208
+ let r = this.#S.now();
226
209
  if (this.ttlResolution > 0) {
227
- n = h;
228
- let r = setTimeout(() => n = 0, this.ttlResolution);
229
- r.unref && r.unref();
210
+ n = r;
211
+ let h = setTimeout(() => n = 0, this.ttlResolution);
212
+ h.unref && h.unref();
230
213
  }
231
- return h;
214
+ return r;
232
215
  };
233
- this.getRemainingTTL = (h) => {
234
- let r = this.#s.get(h);
235
- if (r === void 0) return 0;
236
- let a = t[r], w = e[r];
237
- if (!a || !w) return 1 / 0;
238
- let f = (n || o()) - w;
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 = (h) => {
241
- let r = e[h], a = t[h];
242
- return !!a && !!r && (n || o()) - r > 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
- #z = () => {
230
+ #E = () => {
248
231
  };
249
232
  #N = () => {
250
233
  };
251
234
  #p = () => false;
252
- #B() {
253
- let t = new z(this.#o);
254
- this.#_ = 0, this.#y = t, this.#W = (e) => {
255
- this.#_ -= t[e], t[e] = 0;
256
- }, this.#P = (e, i, s, n) => {
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 (!y(s)) if (n) {
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), !y(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
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.#M = (e, i, s) => {
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.#_ > n; ) this.#G(true);
249
+ for (; this.#b > n; ) this.#G(true);
267
250
  }
268
- this.#_ += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#_);
251
+ this.#b += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
269
252
  };
270
253
  }
271
- #W = (t) => {
254
+ #C = (t) => {
272
255
  };
273
- #M = (t, e, i) => {
256
+ #I = (t, e, i) => {
274
257
  };
275
- #P = (t, e, i, s) => {
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
- *#F({ allowStale: t = this.allowStale } = {}) {
280
- if (this.#n) for (let e = this.#h; !(!this.#H(e) || ((t || !this.#p(e)) && (yield e), e === this.#l)); ) e = this.#u[e];
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
- *#O({ allowStale: t = this.allowStale } = {}) {
283
- if (this.#n) for (let e = this.#l; !(!this.#H(e) || ((t || !this.#p(e)) && (yield e), e === this.#h)); ) e = this.#a[e];
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
- #H(t) {
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.#F()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
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.#O()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
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.#F()) {
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.#O()) {
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.#F()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
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.#O()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
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.#F()) {
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.get(this.#i[i], e);
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.#F()) {
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.#O()) {
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.#O({ allowStale: true })) this.#p(e) && (this.#E(this.#i[e], "expire"), t = true);
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.#A) {
346
- let o = this.#d[e], h = this.#A[e];
347
- if (o && h) {
348
- let r = o - (this.#m.now() - h);
349
- n.ttl = r, n.start = Date.now();
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.#y && (n.size = this.#y[e]), n;
335
+ return this.#_ && (n.size = this.#_[e]), n;
353
336
  }
354
337
  dump() {
355
338
  let t = [];
356
- for (let e of this.#F({ allowStale: true })) {
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.#A) {
343
+ if (this.#d && this.#F) {
361
344
  o.ttl = this.#d[e];
362
- let h = this.#m.now() - this.#A[e];
363
- o.start = Math.floor(Date.now() - h);
345
+ let r = this.#S.now() - this.#F[e];
346
+ o.start = Math.floor(Date.now() - r);
364
347
  }
365
- this.#y && (o.size = this.#y[e]), t.unshift([i, o]);
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.#m.now() - s;
357
+ i.start = this.#S.now() - s;
375
358
  }
376
- this.set(e, i.value, i);
359
+ this.#W(e, i.value, i);
377
360
  }
378
361
  }
379
362
  set(t, e, i = {}) {
380
- if (e === void 0) return this.delete(t), this;
381
- let { ttl: s = this.ttl, start: n, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: r } = i, { noUpdateTTL: a = this.noUpdateTTL } = i, w = this.#P(t, e, i.size || 0, h);
382
- if (this.maxEntrySize && w > this.maxEntrySize) return r && (r.set = "miss", r.maxEntrySizeExceeded = true), this.#E(t, "set"), this;
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.#b.length !== 0 ? this.#b.pop() : this.#n === this.#o ? this.#G(false) : this.#n, this.#i[f] = t, this.#t[f] = e, this.#s.set(t, f), this.#a[this.#h] = f, this.#u[f] = this.#h, this.#h = f, this.#n++, this.#M(f, w, r), r && (r.set = "add"), a = false, this.#I && this.#C?.(e, t, "add");
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.#D(f);
387
- let d = this.#t[f];
388
- if (e !== d) {
389
- if (this.#v && this.#e(d)) {
390
- d.__abortController.abort(new Error("replaced"));
391
- let { __staleWhileFetching: g } = d;
392
- g !== void 0 && !o && (this.#T && this.#w?.(g, t, "set"), this.#f && this.#r?.push([g, t, "set"]));
393
- } else o || (this.#T && this.#w?.(d, t, "set"), this.#f && this.#r?.push([d, t, "set"]));
394
- if (this.#W(f), this.#M(f, w, r), this.#t[f] = e, r) {
395
- r.set = "replace";
396
- let g = d && this.#e(d) ? d.__staleWhileFetching : d;
397
- g !== void 0 && (r.oldValue = g);
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 r && (r.set = "update");
400
- this.#I && this.onInsert?.(e, t, e === d ? "update" : "replace");
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.#j(), this.#d && (a || this.#N(f, s, n), r && this.#z(r, f)), !o && this.#f && this.#r) {
403
- let d = this.#r, g;
404
- for (; g = d?.shift(); ) this.#S?.(...g);
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.#l];
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.#S?.(...e);
411
+ for (; e = t?.shift(); ) this.#w?.(...e);
420
412
  }
421
413
  }
422
414
  }
423
415
  #G(t) {
424
- let e = this.#l, i = this.#i[e], s = this.#t[e];
425
- return this.#v && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#w?.(s, i, "evict"), this.#f && this.#r?.push([s, i, "evict"])), this.#W(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.#b.push(e)), this.#n === 1 ? (this.#l = this.#h = 0, this.#b.length = 0) : this.#l = this.#a[e], this.#s.delete(i), this.#n--, e;
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.#z(s, n));
433
- else return i && this.#R(n), s && (s.has = "hit", this.#z(s, n)), true;
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 { allowStale: i = this.allowStale } = e, s = this.#s.get(t);
439
- if (s === void 0 || !i && this.#p(s)) return;
440
- let n = this.#t[s];
441
- return this.#e(n) ? n.__staleWhileFetching : n;
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
- #x(t, e, i, s) {
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 C(), { signal: h } = i;
447
- h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
448
- let r = { signal: o.signal, options: i, context: s }, a = (p, _ = false) => {
449
- let { aborted: l } = o.signal, S = i.ignoreFetchAbort && p !== void 0, b = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && p !== void 0);
450
- if (i.status && (l && !_ ? (i.status.fetchAborted = true, i.status.fetchError = o.signal.reason, S && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), l && !S && !_) return f(o.signal.reason, b);
451
- let m = g, u = this.#t[e];
452
- return (u === g || S && _ && u === void 0) && (p === void 0 ? m.__staleWhileFetching !== void 0 ? this.#t[e] = m.__staleWhileFetching : this.#E(t, "fetch") : (i.status && (i.status.fetchUpdated = true), this.set(t, p, r.options))), p;
453
- }, w = (p) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = p), f(p, false)), f = (p, _) => {
454
- let { aborted: l } = o.signal, S = l && i.allowStaleOnFetchAbort, b = S || i.allowStaleOnFetchRejection, m = b || i.noDeleteOnFetchRejection, u = g;
455
- if (this.#t[e] === g && (!m || !_ && u.__staleWhileFetching === void 0 ? this.#E(t, "fetch") : S || (this.#t[e] = u.__staleWhileFetching)), b) return i.status && u.__staleWhileFetching !== void 0 && (i.status.returnedStale = true), u.__staleWhileFetching;
456
- if (u.__returned === u) throw p;
457
- }, d = (p, _) => {
458
- let l = this.#L?.(t, n, r);
459
- l && l instanceof Promise && l.then((S) => p(S === void 0 ? void 0 : S), _), o.signal.addEventListener("abort", () => {
460
- (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (p(void 0), i.allowStaleOnFetchAbort && (p = (S) => a(S, true)));
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 g = new Promise(d).then(a, w), A = Object.assign(g, { __abortController: o, __staleWhileFetching: n, __returned: void 0 });
465
- return e === void 0 ? (this.set(t, A, { ...r.options, status: void 0 }), e = this.#s.get(t)) : this.#t[e] = A, A;
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.#v) return false;
475
+ if (!this.#O) return false;
469
476
  let e = t;
470
- return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof C;
471
- }
472
- async fetch(t, e = {}) {
473
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: r = 0, sizeCalculation: a = this.sizeCalculation, noUpdateTTL: w = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: g = this.ignoreFetchAbort, allowStaleOnFetchAbort: A = this.allowStaleOnFetchAbort, context: p, forceRefresh: _ = false, status: l, signal: S } = e;
474
- if (!this.#v) return l && (l.fetch = "get"), this.get(t, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, status: l });
475
- let b = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, ttl: o, noDisposeOnSet: h, size: r, sizeCalculation: a, noUpdateTTL: w, noDeleteOnFetchRejection: f, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: A, ignoreFetchAbort: g, status: l, signal: S }, m = this.#s.get(t);
476
- if (m === void 0) {
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 u = this.#x(t, m, b, p);
479
- return u.__returned = u;
492
+ let g = this.#P(t, b, _, w);
493
+ return g.__returned = g;
480
494
  } else {
481
- let u = this.#t[m];
482
- if (this.#e(u)) {
483
- let E = i && u.__staleWhileFetching !== void 0;
484
- return l && (l.fetch = "inflight", E && (l.returnedStale = true)), E ? u.__staleWhileFetching : u.__returned = u;
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 T = this.#p(m);
487
- if (!_ && !T) return l && (l.fetch = "hit"), this.#D(m), s && this.#R(m), l && this.#z(l, m), u;
488
- let F = this.#x(t, m, b, p), O = F.__staleWhileFetching !== void 0 && i;
489
- return l && (l.fetch = T ? "stale" : "refresh", O && T && (l.returnedStale = true)), O ? F.__staleWhileFetching : F.__returned = F;
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
- async forceFetch(t, e = {}) {
493
- let i = await this.fetch(t, e);
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 = this.#U;
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, forceRefresh: n, ...o } = e, h = this.get(t, o);
501
- if (!n && h !== void 0) return h;
502
- let r = i(t, h, { options: o, context: s });
503
- return this.set(t, r, o), r;
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 { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, h = this.#s.get(t);
507
- if (h !== void 0) {
508
- let r = this.#t[h], a = this.#e(r);
509
- return o && this.#z(o, h), this.#p(h) ? (o && (o.get = "stale"), a ? (o && i && r.__staleWhileFetching !== void 0 && (o.returnedStale = true), i ? r.__staleWhileFetching : void 0) : (n || this.#E(t, "expire"), o && i && (o.returnedStale = true), i ? r : void 0)) : (o && (o.get = "hit"), a ? r.__staleWhileFetching : (this.#D(h), s && this.#R(h), r));
510
- } else o && (o.get = "miss");
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
- #k(t, e) {
513
- this.#u[e] = t, this.#a[t] = e;
549
+ #B(t, e) {
550
+ this.#u[e] = t, this.#l[t] = e;
514
551
  }
515
- #D(t) {
516
- t !== this.#h && (t === this.#l ? this.#l = this.#a[t] : this.#k(this.#u[t], this.#a[t]), this.#k(this.#h, t), this.#h = t);
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.#E(t, "delete");
556
+ return this.#z(t, "delete");
520
557
  }
521
- #E(t, e) {
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.#V(e);
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.#W(s);
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.#w?.(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];
530
- else if (s === this.#l) this.#l = this.#a[s];
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.#a[o] = this.#a[s];
534
- let h = this.#a[s];
535
- this.#u[h] = this.#u[s];
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.#b.push(s);
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.#S?.(...n);
580
+ for (; n = s?.shift(); ) this.#w?.(...n);
543
581
  }
544
582
  return i;
545
583
  }
546
584
  clear() {
547
- return this.#V("delete");
585
+ return this.#$("delete");
548
586
  }
549
- #V(t) {
550
- for (let e of this.#O({ allowStale: true })) {
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.#w?.(i, s, t), this.#f && this.#r?.push([i, s, t]);
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.#A) {
559
- this.#d.fill(0), this.#A.fill(0);
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.#y && this.#y.fill(0), this.#l = 0, this.#h = 0, this.#b.length = 0, this.#_ = 0, this.#n = 0, this.#f && this.#r) {
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.#S?.(...i);
603
+ for (; i = e?.shift(); ) this.#w?.(...i);
566
604
  }
567
605
  }
568
606
  };
569
- exports.LRUCache = D;
607
+ exports.LRUCache = x;
570
608
  }
571
609
  });
572
610