weapp-vite 6.6.3 → 6.6.4

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.
@@ -82,7 +82,7 @@ var require_re = __commonJS({
82
82
  var src = exports.src = [];
83
83
  var safeSrc = exports.safeSrc = [];
84
84
  var t3 = exports.t = {};
85
- var R = 0;
85
+ var R2 = 0;
86
86
  var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
87
87
  var safeRegexReplacements = [
88
88
  ["\\s", 1],
@@ -97,7 +97,7 @@ var require_re = __commonJS({
97
97
  };
98
98
  var createToken = (name, value, isGlobal) => {
99
99
  const safe = makeSafeRegex(value);
100
- const index = R++;
100
+ const index = R2++;
101
101
  debug4(name, index, value);
102
102
  t3[name] = index;
103
103
  src[index] = value;
@@ -180,19 +180,19 @@ var require_identifiers = __commonJS({
180
180
  "use strict";
181
181
  init_esm_shims();
182
182
  var numeric2 = /^[0-9]+$/;
183
- var compareIdentifiers = (a, b) => {
184
- if (typeof a === "number" && typeof b === "number") {
185
- return a === b ? 0 : a < b ? -1 : 1;
183
+ var compareIdentifiers = (a3, b) => {
184
+ if (typeof a3 === "number" && typeof b === "number") {
185
+ return a3 === b ? 0 : a3 < b ? -1 : 1;
186
186
  }
187
- const anum = numeric2.test(a);
187
+ const anum = numeric2.test(a3);
188
188
  const bnum = numeric2.test(b);
189
189
  if (anum && bnum) {
190
- a = +a;
190
+ a3 = +a3;
191
191
  b = +b;
192
192
  }
193
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
193
+ return a3 === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a3 < b ? -1 : 1;
194
194
  };
195
- var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
195
+ var rcompareIdentifiers = (a3, b) => compareIdentifiers(b, a3);
196
196
  module.exports = {
197
197
  compareIdentifiers,
198
198
  rcompareIdentifiers
@@ -324,19 +324,19 @@ var require_semver = __commonJS({
324
324
  }
325
325
  let i = 0;
326
326
  do {
327
- const a = this.prerelease[i];
327
+ const a3 = this.prerelease[i];
328
328
  const b = other.prerelease[i];
329
- debug4("prerelease compare", i, a, b);
330
- if (a === void 0 && b === void 0) {
329
+ debug4("prerelease compare", i, a3, b);
330
+ if (a3 === void 0 && b === void 0) {
331
331
  return 0;
332
332
  } else if (b === void 0) {
333
333
  return 1;
334
- } else if (a === void 0) {
334
+ } else if (a3 === void 0) {
335
335
  return -1;
336
- } else if (a === b) {
336
+ } else if (a3 === b) {
337
337
  continue;
338
338
  } else {
339
- return compareIdentifiers(a, b);
339
+ return compareIdentifiers(a3, b);
340
340
  }
341
341
  } while (++i);
342
342
  }
@@ -346,19 +346,19 @@ var require_semver = __commonJS({
346
346
  }
347
347
  let i = 0;
348
348
  do {
349
- const a = this.build[i];
349
+ const a3 = this.build[i];
350
350
  const b = other.build[i];
351
- debug4("build compare", i, a, b);
352
- if (a === void 0 && b === void 0) {
351
+ debug4("build compare", i, a3, b);
352
+ if (a3 === void 0 && b === void 0) {
353
353
  return 0;
354
354
  } else if (b === void 0) {
355
355
  return 1;
356
- } else if (a === void 0) {
356
+ } else if (a3 === void 0) {
357
357
  return -1;
358
- } else if (a === b) {
358
+ } else if (a3 === b) {
359
359
  continue;
360
360
  } else {
361
- return compareIdentifiers(a, b);
361
+ return compareIdentifiers(a3, b);
362
362
  }
363
363
  } while (++i);
364
364
  }
@@ -486,7 +486,7 @@ var require_compare = __commonJS({
486
486
  "use strict";
487
487
  init_esm_shims();
488
488
  var SemVer = require_semver();
489
- var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
489
+ var compare = (a3, b, loose) => new SemVer(a3, loose).compare(new SemVer(b, loose));
490
490
  module.exports = compare;
491
491
  }
492
492
  });
@@ -497,7 +497,7 @@ var require_gte = __commonJS({
497
497
  "use strict";
498
498
  init_esm_shims();
499
499
  var compare = require_compare();
500
- var gte2 = (a, b, loose) => compare(a, b, loose) >= 0;
500
+ var gte2 = (a3, b, loose) => compare(a3, b, loose) >= 0;
501
501
  module.exports = gte2;
502
502
  }
503
503
  });
@@ -507,7 +507,7 @@ var require_lrucache = __commonJS({
507
507
  "../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/lrucache.js"(exports, module) {
508
508
  "use strict";
509
509
  init_esm_shims();
510
- var LRUCache2 = class {
510
+ var LRUCache = class {
511
511
  constructor() {
512
512
  this.max = 1e3;
513
513
  this.map = /* @__PURE__ */ new Map();
@@ -537,7 +537,7 @@ var require_lrucache = __commonJS({
537
537
  return this;
538
538
  }
539
539
  };
540
- module.exports = LRUCache2;
540
+ module.exports = LRUCache;
541
541
  }
542
542
  });
543
543
 
@@ -547,7 +547,7 @@ var require_eq = __commonJS({
547
547
  "use strict";
548
548
  init_esm_shims();
549
549
  var compare = require_compare();
550
- var eq = (a, b, loose) => compare(a, b, loose) === 0;
550
+ var eq = (a3, b, loose) => compare(a3, b, loose) === 0;
551
551
  module.exports = eq;
552
552
  }
553
553
  });
@@ -558,7 +558,7 @@ var require_neq = __commonJS({
558
558
  "use strict";
559
559
  init_esm_shims();
560
560
  var compare = require_compare();
561
- var neq = (a, b, loose) => compare(a, b, loose) !== 0;
561
+ var neq = (a3, b, loose) => compare(a3, b, loose) !== 0;
562
562
  module.exports = neq;
563
563
  }
564
564
  });
@@ -569,7 +569,7 @@ var require_gt = __commonJS({
569
569
  "use strict";
570
570
  init_esm_shims();
571
571
  var compare = require_compare();
572
- var gt = (a, b, loose) => compare(a, b, loose) > 0;
572
+ var gt = (a3, b, loose) => compare(a3, b, loose) > 0;
573
573
  module.exports = gt;
574
574
  }
575
575
  });
@@ -580,7 +580,7 @@ var require_lt = __commonJS({
580
580
  "use strict";
581
581
  init_esm_shims();
582
582
  var compare = require_compare();
583
- var lt = (a, b, loose) => compare(a, b, loose) < 0;
583
+ var lt = (a3, b, loose) => compare(a3, b, loose) < 0;
584
584
  module.exports = lt;
585
585
  }
586
586
  });
@@ -591,7 +591,7 @@ var require_lte = __commonJS({
591
591
  "use strict";
592
592
  init_esm_shims();
593
593
  var compare = require_compare();
594
- var lte2 = (a, b, loose) => compare(a, b, loose) <= 0;
594
+ var lte2 = (a3, b, loose) => compare(a3, b, loose) <= 0;
595
595
  module.exports = lte2;
596
596
  }
597
597
  });
@@ -607,38 +607,38 @@ var require_cmp = __commonJS({
607
607
  var gte2 = require_gte();
608
608
  var lt = require_lt();
609
609
  var lte2 = require_lte();
610
- var cmp = (a, op, b, loose) => {
610
+ var cmp = (a3, op, b, loose) => {
611
611
  switch (op) {
612
612
  case "===":
613
- if (typeof a === "object") {
614
- a = a.version;
613
+ if (typeof a3 === "object") {
614
+ a3 = a3.version;
615
615
  }
616
616
  if (typeof b === "object") {
617
617
  b = b.version;
618
618
  }
619
- return a === b;
619
+ return a3 === b;
620
620
  case "!==":
621
- if (typeof a === "object") {
622
- a = a.version;
621
+ if (typeof a3 === "object") {
622
+ a3 = a3.version;
623
623
  }
624
624
  if (typeof b === "object") {
625
625
  b = b.version;
626
626
  }
627
- return a !== b;
627
+ return a3 !== b;
628
628
  case "":
629
629
  case "=":
630
630
  case "==":
631
- return eq(a, b, loose);
631
+ return eq(a3, b, loose);
632
632
  case "!=":
633
- return neq(a, b, loose);
633
+ return neq(a3, b, loose);
634
634
  case ">":
635
- return gt(a, b, loose);
635
+ return gt(a3, b, loose);
636
636
  case ">=":
637
- return gte2(a, b, loose);
637
+ return gte2(a3, b, loose);
638
638
  case "<":
639
- return lt(a, b, loose);
639
+ return lt(a3, b, loose);
640
640
  case "<=":
641
- return lte2(a, b, loose);
641
+ return lte2(a3, b, loose);
642
642
  default:
643
643
  throw new TypeError(`Invalid operator: ${op}`);
644
644
  }
@@ -953,20 +953,20 @@ var require_range = __commonJS({
953
953
  };
954
954
  var replaceTilde = (comp, options) => {
955
955
  const r2 = options.loose ? re[t3.TILDELOOSE] : re[t3.TILDE];
956
- return comp.replace(r2, (_, M, m, p, pr) => {
957
- debug4("tilde", comp, _, M, m, p, pr);
956
+ return comp.replace(r2, (_, M2, m, p, pr) => {
957
+ debug4("tilde", comp, _, M2, m, p, pr);
958
958
  let ret;
959
- if (isX(M)) {
959
+ if (isX(M2)) {
960
960
  ret = "";
961
961
  } else if (isX(m)) {
962
- ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
962
+ ret = `>=${M2}.0.0 <${+M2 + 1}.0.0-0`;
963
963
  } else if (isX(p)) {
964
- ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
964
+ ret = `>=${M2}.${m}.0 <${M2}.${+m + 1}.0-0`;
965
965
  } else if (pr) {
966
966
  debug4("replaceTilde pr", pr);
967
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
967
+ ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${+m + 1}.0-0`;
968
968
  } else {
969
- ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
969
+ ret = `>=${M2}.${m}.${p} <${M2}.${+m + 1}.0-0`;
970
970
  }
971
971
  debug4("tilde return", ret);
972
972
  return ret;
@@ -978,41 +978,41 @@ var require_range = __commonJS({
978
978
  var replaceCaret = (comp, options) => {
979
979
  debug4("caret", comp, options);
980
980
  const r2 = options.loose ? re[t3.CARETLOOSE] : re[t3.CARET];
981
- const z = options.includePrerelease ? "-0" : "";
982
- return comp.replace(r2, (_, M, m, p, pr) => {
983
- debug4("caret", comp, _, M, m, p, pr);
981
+ const z2 = options.includePrerelease ? "-0" : "";
982
+ return comp.replace(r2, (_, M2, m, p, pr) => {
983
+ debug4("caret", comp, _, M2, m, p, pr);
984
984
  let ret;
985
- if (isX(M)) {
985
+ if (isX(M2)) {
986
986
  ret = "";
987
987
  } else if (isX(m)) {
988
- ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
988
+ ret = `>=${M2}.0.0${z2} <${+M2 + 1}.0.0-0`;
989
989
  } else if (isX(p)) {
990
- if (M === "0") {
991
- ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
990
+ if (M2 === "0") {
991
+ ret = `>=${M2}.${m}.0${z2} <${M2}.${+m + 1}.0-0`;
992
992
  } else {
993
- ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
993
+ ret = `>=${M2}.${m}.0${z2} <${+M2 + 1}.0.0-0`;
994
994
  }
995
995
  } else if (pr) {
996
996
  debug4("replaceCaret pr", pr);
997
- if (M === "0") {
997
+ if (M2 === "0") {
998
998
  if (m === "0") {
999
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
999
+ ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${m}.${+p + 1}-0`;
1000
1000
  } else {
1001
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1001
+ ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${+m + 1}.0-0`;
1002
1002
  }
1003
1003
  } else {
1004
- ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1004
+ ret = `>=${M2}.${m}.${p}-${pr} <${+M2 + 1}.0.0-0`;
1005
1005
  }
1006
1006
  } else {
1007
1007
  debug4("no pr");
1008
- if (M === "0") {
1008
+ if (M2 === "0") {
1009
1009
  if (m === "0") {
1010
- ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
1010
+ ret = `>=${M2}.${m}.${p}${z2} <${M2}.${m}.${+p + 1}-0`;
1011
1011
  } else {
1012
- ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
1012
+ ret = `>=${M2}.${m}.${p}${z2} <${M2}.${+m + 1}.0-0`;
1013
1013
  }
1014
1014
  } else {
1015
- ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1015
+ ret = `>=${M2}.${m}.${p} <${+M2 + 1}.0.0-0`;
1016
1016
  }
1017
1017
  }
1018
1018
  debug4("caret return", ret);
@@ -1026,9 +1026,9 @@ var require_range = __commonJS({
1026
1026
  var replaceXRange = (comp, options) => {
1027
1027
  comp = comp.trim();
1028
1028
  const r2 = options.loose ? re[t3.XRANGELOOSE] : re[t3.XRANGE];
1029
- return comp.replace(r2, (ret, gtlt, M, m, p, pr) => {
1030
- debug4("xRange", comp, ret, gtlt, M, m, p, pr);
1031
- const xM = isX(M);
1029
+ return comp.replace(r2, (ret, gtlt, M2, m, p, pr) => {
1030
+ debug4("xRange", comp, ret, gtlt, M2, m, p, pr);
1031
+ const xM = isX(M2);
1032
1032
  const xm = xM || isX(m);
1033
1033
  const xp = xm || isX(p);
1034
1034
  const anyX = xp;
@@ -1050,7 +1050,7 @@ var require_range = __commonJS({
1050
1050
  if (gtlt === ">") {
1051
1051
  gtlt = ">=";
1052
1052
  if (xm) {
1053
- M = +M + 1;
1053
+ M2 = +M2 + 1;
1054
1054
  m = 0;
1055
1055
  p = 0;
1056
1056
  } else {
@@ -1060,7 +1060,7 @@ var require_range = __commonJS({
1060
1060
  } else if (gtlt === "<=") {
1061
1061
  gtlt = "<";
1062
1062
  if (xm) {
1063
- M = +M + 1;
1063
+ M2 = +M2 + 1;
1064
1064
  } else {
1065
1065
  m = +m + 1;
1066
1066
  }
@@ -1068,11 +1068,11 @@ var require_range = __commonJS({
1068
1068
  if (gtlt === "<") {
1069
1069
  pr = "-0";
1070
1070
  }
1071
- ret = `${gtlt + M}.${m}.${p}${pr}`;
1071
+ ret = `${gtlt + M2}.${m}.${p}${pr}`;
1072
1072
  } else if (xm) {
1073
- ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1073
+ ret = `>=${M2}.0.0${pr} <${+M2 + 1}.0.0-0`;
1074
1074
  } else if (xp) {
1075
- ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1075
+ ret = `>=${M2}.${m}.0${pr} <${M2}.${+m + 1}.0-0`;
1076
1076
  }
1077
1077
  debug4("xRange return", ret);
1078
1078
  return ret;
@@ -1256,7 +1256,7 @@ var require_eventemitter3 = __commonJS({
1256
1256
  if (listeners.fn) return 1;
1257
1257
  return listeners.length;
1258
1258
  };
1259
- EventEmitter4.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
1259
+ EventEmitter4.prototype.emit = function emit(event, a1, a22, a3, a4, a5) {
1260
1260
  var evt = prefix ? prefix + event : event;
1261
1261
  if (!this._events[evt]) return false;
1262
1262
  var listeners = this._events[evt], len = arguments.length, args, i;
@@ -1268,13 +1268,13 @@ var require_eventemitter3 = __commonJS({
1268
1268
  case 2:
1269
1269
  return listeners.fn.call(listeners.context, a1), true;
1270
1270
  case 3:
1271
- return listeners.fn.call(listeners.context, a1, a2), true;
1271
+ return listeners.fn.call(listeners.context, a1, a22), true;
1272
1272
  case 4:
1273
- return listeners.fn.call(listeners.context, a1, a2, a3), true;
1273
+ return listeners.fn.call(listeners.context, a1, a22, a3), true;
1274
1274
  case 5:
1275
- return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
1275
+ return listeners.fn.call(listeners.context, a1, a22, a3, a4), true;
1276
1276
  case 6:
1277
- return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
1277
+ return listeners.fn.call(listeners.context, a1, a22, a3, a4, a5), true;
1278
1278
  }
1279
1279
  for (i = 1, args = new Array(len - 1); i < len; i++) {
1280
1280
  args[i - 1] = arguments[i];
@@ -1292,10 +1292,10 @@ var require_eventemitter3 = __commonJS({
1292
1292
  listeners[i].fn.call(listeners[i].context, a1);
1293
1293
  break;
1294
1294
  case 3:
1295
- listeners[i].fn.call(listeners[i].context, a1, a2);
1295
+ listeners[i].fn.call(listeners[i].context, a1, a22);
1296
1296
  break;
1297
1297
  case 4:
1298
- listeners[i].fn.call(listeners[i].context, a1, a2, a3);
1298
+ listeners[i].fn.call(listeners[i].context, a1, a22, a3);
1299
1299
  break;
1300
1300
  default:
1301
1301
  if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
@@ -1708,7 +1708,7 @@ function resolveImportee(importee, jsonPath, aliasEntries) {
1708
1708
  if (!jsonPath) {
1709
1709
  return importee;
1710
1710
  }
1711
- const matchedEntry = aliasEntries.find((x) => matches(x.find, importee));
1711
+ const matchedEntry = aliasEntries.find((x2) => matches(x2.find, importee));
1712
1712
  if (!matchedEntry) {
1713
1713
  return importee;
1714
1714
  }
@@ -2211,1426 +2211,546 @@ init_esm_shims();
2211
2211
  init_esm_shims();
2212
2212
  import { removeExtensionDeep as removeExtensionDeep3 } from "@weapp-core/shared";
2213
2213
 
2214
- // ../../node_modules/.pnpm/lru-cache@11.2.5/node_modules/lru-cache/dist/esm/index.js
2214
+ // ../../node_modules/.pnpm/lru-cache@11.2.6/node_modules/lru-cache/dist/esm/index.min.js
2215
2215
  init_esm_shims();
2216
- var defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
2217
- var warned = /* @__PURE__ */ new Set();
2218
- var PROCESS = typeof process === "object" && !!process ? process : {};
2219
- var emitWarning = (msg, type, code, fn) => {
2220
- typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
2216
+ var M = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
2217
+ var I = /* @__PURE__ */ new Set();
2218
+ var R = typeof process == "object" && process ? process : {};
2219
+ var x = (a3, t3, e, i) => {
2220
+ typeof R.emitWarning == "function" ? R.emitWarning(a3, t3, e, i) : console.error(`[${e}] ${t3}: ${a3}`);
2221
2221
  };
2222
- var AC = globalThis.AbortController;
2223
- var AS = globalThis.AbortSignal;
2224
- if (typeof AC === "undefined") {
2225
- AS = class AbortSignal {
2222
+ var C = globalThis.AbortController;
2223
+ var D = globalThis.AbortSignal;
2224
+ if (typeof C > "u") {
2225
+ D = class {
2226
2226
  onabort;
2227
2227
  _onabort = [];
2228
2228
  reason;
2229
2229
  aborted = false;
2230
- addEventListener(_, fn) {
2231
- this._onabort.push(fn);
2230
+ addEventListener(i, s) {
2231
+ this._onabort.push(s);
2232
2232
  }
2233
- };
2234
- AC = class AbortController {
2233
+ }, C = class {
2235
2234
  constructor() {
2236
- warnACPolyfill();
2235
+ t3();
2237
2236
  }
2238
- signal = new AS();
2239
- abort(reason) {
2240
- if (this.signal.aborted)
2241
- return;
2242
- this.signal.reason = reason;
2243
- this.signal.aborted = true;
2244
- for (const fn of this.signal._onabort) {
2245
- fn(reason);
2237
+ signal = new D();
2238
+ abort(i) {
2239
+ if (!this.signal.aborted) {
2240
+ this.signal.reason = i, this.signal.aborted = true;
2241
+ for (let s of this.signal._onabort) s(i);
2242
+ this.signal.onabort?.(i);
2246
2243
  }
2247
- this.signal.onabort?.(reason);
2248
2244
  }
2249
2245
  };
2250
- let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
2251
- const warnACPolyfill = () => {
2252
- if (!printACPolyfillWarning)
2253
- return;
2254
- printACPolyfillWarning = false;
2255
- emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill);
2246
+ let a3 = R.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t3 = () => {
2247
+ a3 && (a3 = false, x("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", t3));
2256
2248
  };
2257
2249
  }
2258
- var shouldWarn = (code) => !warned.has(code);
2259
- var isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
2260
- var getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null;
2261
- var ZeroArray = class extends Array {
2262
- constructor(size) {
2263
- super(size);
2264
- this.fill(0);
2250
+ var G = (a3) => !I.has(a3);
2251
+ var y = (a3) => a3 && a3 === Math.floor(a3) && a3 > 0 && isFinite(a3);
2252
+ var U = (a3) => y(a3) ? a3 <= Math.pow(2, 8) ? Uint8Array : a3 <= Math.pow(2, 16) ? Uint16Array : a3 <= Math.pow(2, 32) ? Uint32Array : a3 <= Number.MAX_SAFE_INTEGER ? z : null : null;
2253
+ var z = class extends Array {
2254
+ constructor(t3) {
2255
+ super(t3), this.fill(0);
2265
2256
  }
2266
2257
  };
2267
- var Stack = class _Stack {
2258
+ var W = class a {
2268
2259
  heap;
2269
2260
  length;
2270
- // private constructor
2271
- static #constructing = false;
2272
- static create(max) {
2273
- const HeapCls = getUintArray(max);
2274
- if (!HeapCls)
2275
- return [];
2276
- _Stack.#constructing = true;
2277
- const s = new _Stack(max, HeapCls);
2278
- _Stack.#constructing = false;
2279
- return s;
2261
+ static #o = false;
2262
+ static create(t3) {
2263
+ let e = U(t3);
2264
+ if (!e) return [];
2265
+ a.#o = true;
2266
+ let i = new a(t3, e);
2267
+ return a.#o = false, i;
2280
2268
  }
2281
- constructor(max, HeapCls) {
2282
- if (!_Stack.#constructing) {
2283
- throw new TypeError("instantiate Stack using Stack.create(n)");
2284
- }
2285
- this.heap = new HeapCls(max);
2286
- this.length = 0;
2269
+ constructor(t3, e) {
2270
+ if (!a.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
2271
+ this.heap = new e(t3), this.length = 0;
2287
2272
  }
2288
- push(n) {
2289
- this.heap[this.length++] = n;
2273
+ push(t3) {
2274
+ this.heap[this.length++] = t3;
2290
2275
  }
2291
2276
  pop() {
2292
2277
  return this.heap[--this.length];
2293
2278
  }
2294
2279
  };
2295
- var LRUCache = class _LRUCache {
2296
- // options that cannot be changed without disaster
2297
- #max;
2298
- #maxSize;
2299
- #dispose;
2300
- #onInsert;
2301
- #disposeAfter;
2302
- #fetchMethod;
2303
- #memoMethod;
2304
- #perf;
2305
- /**
2306
- * {@link LRUCache.OptionsBase.perf}
2307
- */
2280
+ var L = class a2 {
2281
+ #o;
2282
+ #c;
2283
+ #w;
2284
+ #C;
2285
+ #S;
2286
+ #L;
2287
+ #I;
2288
+ #m;
2308
2289
  get perf() {
2309
- return this.#perf;
2290
+ return this.#m;
2310
2291
  }
2311
- /**
2312
- * {@link LRUCache.OptionsBase.ttl}
2313
- */
2314
2292
  ttl;
2315
- /**
2316
- * {@link LRUCache.OptionsBase.ttlResolution}
2317
- */
2318
2293
  ttlResolution;
2319
- /**
2320
- * {@link LRUCache.OptionsBase.ttlAutopurge}
2321
- */
2322
2294
  ttlAutopurge;
2323
- /**
2324
- * {@link LRUCache.OptionsBase.updateAgeOnGet}
2325
- */
2326
2295
  updateAgeOnGet;
2327
- /**
2328
- * {@link LRUCache.OptionsBase.updateAgeOnHas}
2329
- */
2330
2296
  updateAgeOnHas;
2331
- /**
2332
- * {@link LRUCache.OptionsBase.allowStale}
2333
- */
2334
2297
  allowStale;
2335
- /**
2336
- * {@link LRUCache.OptionsBase.noDisposeOnSet}
2337
- */
2338
2298
  noDisposeOnSet;
2339
- /**
2340
- * {@link LRUCache.OptionsBase.noUpdateTTL}
2341
- */
2342
2299
  noUpdateTTL;
2343
- /**
2344
- * {@link LRUCache.OptionsBase.maxEntrySize}
2345
- */
2346
2300
  maxEntrySize;
2347
- /**
2348
- * {@link LRUCache.OptionsBase.sizeCalculation}
2349
- */
2350
2301
  sizeCalculation;
2351
- /**
2352
- * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
2353
- */
2354
2302
  noDeleteOnFetchRejection;
2355
- /**
2356
- * {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
2357
- */
2358
2303
  noDeleteOnStaleGet;
2359
- /**
2360
- * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
2361
- */
2362
2304
  allowStaleOnFetchAbort;
2363
- /**
2364
- * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
2365
- */
2366
2305
  allowStaleOnFetchRejection;
2367
- /**
2368
- * {@link LRUCache.OptionsBase.ignoreFetchAbort}
2369
- */
2370
2306
  ignoreFetchAbort;
2371
- // computed properties
2372
- #size;
2373
- #calculatedSize;
2374
- #keyMap;
2375
- #keyList;
2376
- #valList;
2377
- #next;
2378
- #prev;
2379
- #head;
2380
- #tail;
2381
- #free;
2382
- #disposed;
2383
- #sizes;
2384
- #starts;
2385
- #ttls;
2386
- #autopurgeTimers;
2387
- #hasDispose;
2388
- #hasFetchMethod;
2389
- #hasDisposeAfter;
2390
- #hasOnInsert;
2391
- /**
2392
- * Do not call this method unless you need to inspect the
2393
- * inner workings of the cache. If anything returned by this
2394
- * object is modified in any way, strange breakage may occur.
2395
- *
2396
- * These fields are private for a reason!
2397
- *
2398
- * @internal
2399
- */
2400
- static unsafeExposeInternals(c) {
2401
- return {
2402
- // properties
2403
- starts: c.#starts,
2404
- ttls: c.#ttls,
2405
- autopurgeTimers: c.#autopurgeTimers,
2406
- sizes: c.#sizes,
2407
- keyMap: c.#keyMap,
2408
- keyList: c.#keyList,
2409
- valList: c.#valList,
2410
- next: c.#next,
2411
- prev: c.#prev,
2412
- get head() {
2413
- return c.#head;
2414
- },
2415
- get tail() {
2416
- return c.#tail;
2417
- },
2418
- free: c.#free,
2419
- // methods
2420
- isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
2421
- backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
2422
- moveToTail: (index) => c.#moveToTail(index),
2423
- indexes: (options) => c.#indexes(options),
2424
- rindexes: (options) => c.#rindexes(options),
2425
- isStale: (index) => c.#isStale(index)
2426
- };
2307
+ #n;
2308
+ #_;
2309
+ #s;
2310
+ #i;
2311
+ #t;
2312
+ #a;
2313
+ #u;
2314
+ #l;
2315
+ #h;
2316
+ #b;
2317
+ #r;
2318
+ #y;
2319
+ #A;
2320
+ #d;
2321
+ #g;
2322
+ #T;
2323
+ #v;
2324
+ #f;
2325
+ #x;
2326
+ static unsafeExposeInternals(t3) {
2327
+ return { starts: t3.#A, ttls: t3.#d, autopurgeTimers: t3.#g, sizes: t3.#y, keyMap: t3.#s, keyList: t3.#i, valList: t3.#t, next: t3.#a, prev: t3.#u, get head() {
2328
+ return t3.#l;
2329
+ }, get tail() {
2330
+ return t3.#h;
2331
+ }, free: t3.#b, isBackgroundFetch: (e) => t3.#e(e), backgroundFetch: (e, i, s, h) => t3.#G(e, i, s, h), moveToTail: (e) => t3.#D(e), indexes: (e) => t3.#F(e), rindexes: (e) => t3.#O(e), isStale: (e) => t3.#p(e) };
2427
2332
  }
2428
- // Protected read-only members
2429
- /**
2430
- * {@link LRUCache.OptionsBase.max} (read-only)
2431
- */
2432
2333
  get max() {
2433
- return this.#max;
2334
+ return this.#o;
2434
2335
  }
2435
- /**
2436
- * {@link LRUCache.OptionsBase.maxSize} (read-only)
2437
- */
2438
2336
  get maxSize() {
2439
- return this.#maxSize;
2337
+ return this.#c;
2440
2338
  }
2441
- /**
2442
- * The total computed size of items in the cache (read-only)
2443
- */
2444
2339
  get calculatedSize() {
2445
- return this.#calculatedSize;
2340
+ return this.#_;
2446
2341
  }
2447
- /**
2448
- * The number of items stored in the cache (read-only)
2449
- */
2450
2342
  get size() {
2451
- return this.#size;
2343
+ return this.#n;
2452
2344
  }
2453
- /**
2454
- * {@link LRUCache.OptionsBase.fetchMethod} (read-only)
2455
- */
2456
2345
  get fetchMethod() {
2457
- return this.#fetchMethod;
2346
+ return this.#L;
2458
2347
  }
2459
2348
  get memoMethod() {
2460
- return this.#memoMethod;
2349
+ return this.#I;
2461
2350
  }
2462
- /**
2463
- * {@link LRUCache.OptionsBase.dispose} (read-only)
2464
- */
2465
2351
  get dispose() {
2466
- return this.#dispose;
2352
+ return this.#w;
2467
2353
  }
2468
- /**
2469
- * {@link LRUCache.OptionsBase.onInsert} (read-only)
2470
- */
2471
2354
  get onInsert() {
2472
- return this.#onInsert;
2355
+ return this.#C;
2473
2356
  }
2474
- /**
2475
- * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
2476
- */
2477
2357
  get disposeAfter() {
2478
- return this.#disposeAfter;
2479
- }
2480
- constructor(options) {
2481
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf } = options;
2482
- if (perf !== void 0) {
2483
- if (typeof perf?.now !== "function") {
2484
- throw new TypeError("perf option must have a now() method if specified");
2485
- }
2486
- }
2487
- this.#perf = perf ?? defaultPerf;
2488
- if (max !== 0 && !isPosInt(max)) {
2489
- throw new TypeError("max option must be a nonnegative integer");
2490
- }
2491
- const UintArray = max ? getUintArray(max) : Array;
2492
- if (!UintArray) {
2493
- throw new Error("invalid max value: " + max);
2494
- }
2495
- this.#max = max;
2496
- this.#maxSize = maxSize;
2497
- this.maxEntrySize = maxEntrySize || this.#maxSize;
2498
- this.sizeCalculation = sizeCalculation;
2499
- if (this.sizeCalculation) {
2500
- if (!this.#maxSize && !this.maxEntrySize) {
2501
- throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
2502
- }
2503
- if (typeof this.sizeCalculation !== "function") {
2504
- throw new TypeError("sizeCalculation set to non-function");
2505
- }
2506
- }
2507
- if (memoMethod !== void 0 && typeof memoMethod !== "function") {
2508
- throw new TypeError("memoMethod must be a function if defined");
2509
- }
2510
- this.#memoMethod = memoMethod;
2511
- if (fetchMethod !== void 0 && typeof fetchMethod !== "function") {
2512
- throw new TypeError("fetchMethod must be a function if specified");
2513
- }
2514
- this.#fetchMethod = fetchMethod;
2515
- this.#hasFetchMethod = !!fetchMethod;
2516
- this.#keyMap = /* @__PURE__ */ new Map();
2517
- this.#keyList = new Array(max).fill(void 0);
2518
- this.#valList = new Array(max).fill(void 0);
2519
- this.#next = new UintArray(max);
2520
- this.#prev = new UintArray(max);
2521
- this.#head = 0;
2522
- this.#tail = 0;
2523
- this.#free = Stack.create(max);
2524
- this.#size = 0;
2525
- this.#calculatedSize = 0;
2526
- if (typeof dispose === "function") {
2527
- this.#dispose = dispose;
2528
- }
2529
- if (typeof onInsert === "function") {
2530
- this.#onInsert = onInsert;
2531
- }
2532
- if (typeof disposeAfter === "function") {
2533
- this.#disposeAfter = disposeAfter;
2534
- this.#disposed = [];
2535
- } else {
2536
- this.#disposeAfter = void 0;
2537
- this.#disposed = void 0;
2538
- }
2539
- this.#hasDispose = !!this.#dispose;
2540
- this.#hasOnInsert = !!this.#onInsert;
2541
- this.#hasDisposeAfter = !!this.#disposeAfter;
2542
- this.noDisposeOnSet = !!noDisposeOnSet;
2543
- this.noUpdateTTL = !!noUpdateTTL;
2544
- this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
2545
- this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
2546
- this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
2547
- this.ignoreFetchAbort = !!ignoreFetchAbort;
2548
- if (this.maxEntrySize !== 0) {
2549
- if (this.#maxSize !== 0) {
2550
- if (!isPosInt(this.#maxSize)) {
2551
- throw new TypeError("maxSize must be a positive integer if specified");
2552
- }
2553
- }
2554
- if (!isPosInt(this.maxEntrySize)) {
2555
- throw new TypeError("maxEntrySize must be a positive integer if specified");
2556
- }
2557
- this.#initializeSizeTracking();
2558
- }
2559
- this.allowStale = !!allowStale;
2560
- this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
2561
- this.updateAgeOnGet = !!updateAgeOnGet;
2562
- this.updateAgeOnHas = !!updateAgeOnHas;
2563
- this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
2564
- this.ttlAutopurge = !!ttlAutopurge;
2565
- this.ttl = ttl || 0;
2566
- if (this.ttl) {
2567
- if (!isPosInt(this.ttl)) {
2568
- throw new TypeError("ttl must be a positive integer if specified");
2569
- }
2570
- this.#initializeTTLTracking();
2571
- }
2572
- if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
2573
- throw new TypeError("At least one of max, maxSize, or ttl is required");
2574
- }
2575
- if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
2576
- const code = "LRU_CACHE_UNBOUNDED";
2577
- if (shouldWarn(code)) {
2578
- warned.add(code);
2579
- const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
2580
- emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache);
2358
+ return this.#S;
2359
+ }
2360
+ constructor(t3) {
2361
+ let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: h, updateAgeOnGet: n, updateAgeOnHas: o, allowStale: r2, dispose: f, onInsert: m, disposeAfter: c, noDisposeOnSet: d, noUpdateTTL: g, maxSize: A = 0, maxEntrySize: p = 0, sizeCalculation: _, fetchMethod: l, memoMethod: w, noDeleteOnFetchRejection: b, noDeleteOnStaleGet: S, allowStaleOnFetchRejection: u, allowStaleOnFetchAbort: T, ignoreFetchAbort: F, perf: v } = t3;
2362
+ if (v !== void 0 && typeof v?.now != "function") throw new TypeError("perf option must have a now() method if specified");
2363
+ if (this.#m = v ?? M, e !== 0 && !y(e)) throw new TypeError("max option must be a nonnegative integer");
2364
+ let O = e ? U(e) : Array;
2365
+ if (!O) throw new Error("invalid max value: " + e);
2366
+ if (this.#o = e, this.#c = A, this.maxEntrySize = p || this.#c, this.sizeCalculation = _, this.sizeCalculation) {
2367
+ if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
2368
+ if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
2369
+ }
2370
+ if (w !== void 0 && typeof w != "function") throw new TypeError("memoMethod must be a function if defined");
2371
+ if (this.#I = w, l !== void 0 && typeof l != "function") throw new TypeError("fetchMethod must be a function if specified");
2372
+ 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 f == "function" && (this.#w = f), typeof m == "function" && (this.#C = m), typeof c == "function" ? (this.#S = c, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#w, this.#x = !!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) {
2373
+ if (this.#c !== 0 && !y(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
2374
+ if (!y(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
2375
+ this.#B();
2376
+ }
2377
+ if (this.allowStale = !!r2, this.noDeleteOnStaleGet = !!S, this.updateAgeOnGet = !!n, this.updateAgeOnHas = !!o, this.ttlResolution = y(s) || s === 0 ? s : 1, this.ttlAutopurge = !!h, this.ttl = i || 0, this.ttl) {
2378
+ if (!y(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
2379
+ this.#j();
2380
+ }
2381
+ if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
2382
+ if (!this.ttlAutopurge && !this.#o && !this.#c) {
2383
+ let E = "LRU_CACHE_UNBOUNDED";
2384
+ G(E) && (I.add(E), x("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, a2));
2385
+ }
2386
+ }
2387
+ getRemainingTTL(t3) {
2388
+ return this.#s.has(t3) ? 1 / 0 : 0;
2389
+ }
2390
+ #j() {
2391
+ let t3 = new z(this.#o), e = new z(this.#o);
2392
+ this.#d = t3, this.#A = e;
2393
+ let i = this.ttlAutopurge ? new Array(this.#o) : void 0;
2394
+ this.#g = i, this.#N = (n, o, r2 = this.#m.now()) => {
2395
+ if (e[n] = o !== 0 ? r2 : 0, t3[n] = o, i?.[n] && (clearTimeout(i[n]), i[n] = void 0), o !== 0 && i) {
2396
+ let f = setTimeout(() => {
2397
+ this.#p(n) && this.#E(this.#i[n], "expire");
2398
+ }, o + 1);
2399
+ f.unref && f.unref(), i[n] = f;
2400
+ }
2401
+ }, this.#R = (n) => {
2402
+ e[n] = t3[n] !== 0 ? this.#m.now() : 0;
2403
+ }, this.#z = (n, o) => {
2404
+ if (t3[o]) {
2405
+ let r2 = t3[o], f = e[o];
2406
+ if (!r2 || !f) return;
2407
+ n.ttl = r2, n.start = f, n.now = s || h();
2408
+ let m = n.now - f;
2409
+ n.remainingTTL = r2 - m;
2581
2410
  }
2582
- }
2583
- }
2584
- /**
2585
- * Return the number of ms left in the item's TTL. If item is not in cache,
2586
- * returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
2587
- */
2588
- getRemainingTTL(key) {
2589
- return this.#keyMap.has(key) ? Infinity : 0;
2590
- }
2591
- #initializeTTLTracking() {
2592
- const ttls = new ZeroArray(this.#max);
2593
- const starts = new ZeroArray(this.#max);
2594
- this.#ttls = ttls;
2595
- this.#starts = starts;
2596
- const purgeTimers = this.ttlAutopurge ? new Array(this.#max) : void 0;
2597
- this.#autopurgeTimers = purgeTimers;
2598
- this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
2599
- starts[index] = ttl !== 0 ? start : 0;
2600
- ttls[index] = ttl;
2601
- if (purgeTimers?.[index]) {
2602
- clearTimeout(purgeTimers[index]);
2603
- purgeTimers[index] = void 0;
2604
- }
2605
- if (ttl !== 0 && purgeTimers) {
2606
- const t3 = setTimeout(() => {
2607
- if (this.#isStale(index)) {
2608
- this.#delete(this.#keyList[index], "expire");
2609
- }
2610
- }, ttl + 1);
2611
- if (t3.unref) {
2612
- t3.unref();
2613
- }
2614
- purgeTimers[index] = t3;
2615
- }
2616
- };
2617
- this.#updateItemAge = (index) => {
2618
- starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
2619
2411
  };
2620
- this.#statusTTL = (status, index) => {
2621
- if (ttls[index]) {
2622
- const ttl = ttls[index];
2623
- const start = starts[index];
2624
- if (!ttl || !start)
2625
- return;
2626
- status.ttl = ttl;
2627
- status.start = start;
2628
- status.now = cachedNow || getNow();
2629
- const age = status.now - start;
2630
- status.remainingTTL = ttl - age;
2631
- }
2632
- };
2633
- let cachedNow = 0;
2634
- const getNow = () => {
2635
- const n = this.#perf.now();
2412
+ let s = 0, h = () => {
2413
+ let n = this.#m.now();
2636
2414
  if (this.ttlResolution > 0) {
2637
- cachedNow = n;
2638
- const t3 = setTimeout(() => cachedNow = 0, this.ttlResolution);
2639
- if (t3.unref) {
2640
- t3.unref();
2641
- }
2415
+ s = n;
2416
+ let o = setTimeout(() => s = 0, this.ttlResolution);
2417
+ o.unref && o.unref();
2642
2418
  }
2643
2419
  return n;
2644
2420
  };
2645
- this.getRemainingTTL = (key) => {
2646
- const index = this.#keyMap.get(key);
2647
- if (index === void 0) {
2648
- return 0;
2649
- }
2650
- const ttl = ttls[index];
2651
- const start = starts[index];
2652
- if (!ttl || !start) {
2653
- return Infinity;
2654
- }
2655
- const age = (cachedNow || getNow()) - start;
2656
- return ttl - age;
2657
- };
2658
- this.#isStale = (index) => {
2659
- const s = starts[index];
2660
- const t3 = ttls[index];
2661
- return !!t3 && !!s && (cachedNow || getNow()) - s > t3;
2421
+ this.getRemainingTTL = (n) => {
2422
+ let o = this.#s.get(n);
2423
+ if (o === void 0) return 0;
2424
+ let r2 = t3[o], f = e[o];
2425
+ if (!r2 || !f) return 1 / 0;
2426
+ let m = (s || h()) - f;
2427
+ return r2 - m;
2428
+ }, this.#p = (n) => {
2429
+ let o = e[n], r2 = t3[n];
2430
+ return !!r2 && !!o && (s || h()) - o > r2;
2662
2431
  };
2663
2432
  }
2664
- // conditionally set private methods related to TTL
2665
- #updateItemAge = () => {
2433
+ #R = () => {
2666
2434
  };
2667
- #statusTTL = () => {
2435
+ #z = () => {
2668
2436
  };
2669
- #setItemTTL = () => {
2437
+ #N = () => {
2670
2438
  };
2671
- /* c8 ignore stop */
2672
- #isStale = () => false;
2673
- #initializeSizeTracking() {
2674
- const sizes = new ZeroArray(this.#max);
2675
- this.#calculatedSize = 0;
2676
- this.#sizes = sizes;
2677
- this.#removeItemSize = (index) => {
2678
- this.#calculatedSize -= sizes[index];
2679
- sizes[index] = 0;
2680
- };
2681
- this.#requireSize = (k, v, size, sizeCalculation) => {
2682
- if (this.#isBackgroundFetch(v)) {
2683
- return 0;
2684
- }
2685
- if (!isPosInt(size)) {
2686
- if (sizeCalculation) {
2687
- if (typeof sizeCalculation !== "function") {
2688
- throw new TypeError("sizeCalculation must be a function");
2689
- }
2690
- size = sizeCalculation(v, k);
2691
- if (!isPosInt(size)) {
2692
- throw new TypeError("sizeCalculation return invalid (expect positive integer)");
2693
- }
2694
- } else {
2695
- throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
2696
- }
2697
- }
2698
- return size;
2699
- };
2700
- this.#addItemSize = (index, size, status) => {
2701
- sizes[index] = size;
2702
- if (this.#maxSize) {
2703
- const maxSize = this.#maxSize - sizes[index];
2704
- while (this.#calculatedSize > maxSize) {
2705
- this.#evict(true);
2706
- }
2707
- }
2708
- this.#calculatedSize += sizes[index];
2709
- if (status) {
2710
- status.entrySize = size;
2711
- status.totalCalculatedSize = this.#calculatedSize;
2712
- }
2439
+ #p = () => false;
2440
+ #B() {
2441
+ let t3 = new z(this.#o);
2442
+ this.#_ = 0, this.#y = t3, this.#W = (e) => {
2443
+ this.#_ -= t3[e], t3[e] = 0;
2444
+ }, this.#P = (e, i, s, h) => {
2445
+ if (this.#e(i)) return 0;
2446
+ if (!y(s)) if (h) {
2447
+ if (typeof h != "function") throw new TypeError("sizeCalculation must be a function");
2448
+ if (s = h(i, e), !y(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
2449
+ } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
2450
+ return s;
2451
+ }, this.#U = (e, i, s) => {
2452
+ if (t3[e] = i, this.#c) {
2453
+ let h = this.#c - t3[e];
2454
+ for (; this.#_ > h; ) this.#M(true);
2455
+ }
2456
+ this.#_ += t3[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#_);
2713
2457
  };
2714
2458
  }
2715
- #removeItemSize = (_i) => {
2459
+ #W = (t3) => {
2716
2460
  };
2717
- #addItemSize = (_i, _s, _st) => {
2461
+ #U = (t3, e, i) => {
2718
2462
  };
2719
- #requireSize = (_k, _v, size, sizeCalculation) => {
2720
- if (size || sizeCalculation) {
2721
- throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
2722
- }
2463
+ #P = (t3, e, i, s) => {
2464
+ if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
2723
2465
  return 0;
2724
2466
  };
2725
- *#indexes({ allowStale = this.allowStale } = {}) {
2726
- if (this.#size) {
2727
- for (let i = this.#tail; true; ) {
2728
- if (!this.#isValidIndex(i)) {
2729
- break;
2730
- }
2731
- if (allowStale || !this.#isStale(i)) {
2732
- yield i;
2733
- }
2734
- if (i === this.#head) {
2735
- break;
2736
- } else {
2737
- i = this.#prev[i];
2738
- }
2739
- }
2740
- }
2467
+ *#F({ allowStale: t3 = this.allowStale } = {}) {
2468
+ if (this.#n) for (let e = this.#h; !(!this.#H(e) || ((t3 || !this.#p(e)) && (yield e), e === this.#l)); ) e = this.#u[e];
2741
2469
  }
2742
- *#rindexes({ allowStale = this.allowStale } = {}) {
2743
- if (this.#size) {
2744
- for (let i = this.#head; true; ) {
2745
- if (!this.#isValidIndex(i)) {
2746
- break;
2747
- }
2748
- if (allowStale || !this.#isStale(i)) {
2749
- yield i;
2750
- }
2751
- if (i === this.#tail) {
2752
- break;
2753
- } else {
2754
- i = this.#next[i];
2755
- }
2756
- }
2757
- }
2470
+ *#O({ allowStale: t3 = this.allowStale } = {}) {
2471
+ if (this.#n) for (let e = this.#l; !(!this.#H(e) || ((t3 || !this.#p(e)) && (yield e), e === this.#h)); ) e = this.#a[e];
2758
2472
  }
2759
- #isValidIndex(index) {
2760
- return index !== void 0 && this.#keyMap.get(this.#keyList[index]) === index;
2473
+ #H(t3) {
2474
+ return t3 !== void 0 && this.#s.get(this.#i[t3]) === t3;
2761
2475
  }
2762
- /**
2763
- * Return a generator yielding `[key, value]` pairs,
2764
- * in order from most recently used to least recently used.
2765
- */
2766
2476
  *entries() {
2767
- for (const i of this.#indexes()) {
2768
- if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
2769
- yield [this.#keyList[i], this.#valList[i]];
2770
- }
2771
- }
2477
+ for (let t3 of this.#F()) this.#t[t3] !== void 0 && this.#i[t3] !== void 0 && !this.#e(this.#t[t3]) && (yield [this.#i[t3], this.#t[t3]]);
2772
2478
  }
2773
- /**
2774
- * Inverse order version of {@link LRUCache.entries}
2775
- *
2776
- * Return a generator yielding `[key, value]` pairs,
2777
- * in order from least recently used to most recently used.
2778
- */
2779
2479
  *rentries() {
2780
- for (const i of this.#rindexes()) {
2781
- if (this.#valList[i] !== void 0 && this.#keyList[i] !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
2782
- yield [this.#keyList[i], this.#valList[i]];
2783
- }
2784
- }
2480
+ for (let t3 of this.#O()) this.#t[t3] !== void 0 && this.#i[t3] !== void 0 && !this.#e(this.#t[t3]) && (yield [this.#i[t3], this.#t[t3]]);
2785
2481
  }
2786
- /**
2787
- * Return a generator yielding the keys in the cache,
2788
- * in order from most recently used to least recently used.
2789
- */
2790
2482
  *keys() {
2791
- for (const i of this.#indexes()) {
2792
- const k = this.#keyList[i];
2793
- if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
2794
- yield k;
2795
- }
2483
+ for (let t3 of this.#F()) {
2484
+ let e = this.#i[t3];
2485
+ e !== void 0 && !this.#e(this.#t[t3]) && (yield e);
2796
2486
  }
2797
2487
  }
2798
- /**
2799
- * Inverse order version of {@link LRUCache.keys}
2800
- *
2801
- * Return a generator yielding the keys in the cache,
2802
- * in order from least recently used to most recently used.
2803
- */
2804
2488
  *rkeys() {
2805
- for (const i of this.#rindexes()) {
2806
- const k = this.#keyList[i];
2807
- if (k !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
2808
- yield k;
2809
- }
2489
+ for (let t3 of this.#O()) {
2490
+ let e = this.#i[t3];
2491
+ e !== void 0 && !this.#e(this.#t[t3]) && (yield e);
2810
2492
  }
2811
2493
  }
2812
- /**
2813
- * Return a generator yielding the values in the cache,
2814
- * in order from most recently used to least recently used.
2815
- */
2816
2494
  *values() {
2817
- for (const i of this.#indexes()) {
2818
- const v = this.#valList[i];
2819
- if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
2820
- yield this.#valList[i];
2821
- }
2822
- }
2495
+ for (let t3 of this.#F()) this.#t[t3] !== void 0 && !this.#e(this.#t[t3]) && (yield this.#t[t3]);
2823
2496
  }
2824
- /**
2825
- * Inverse order version of {@link LRUCache.values}
2826
- *
2827
- * Return a generator yielding the values in the cache,
2828
- * in order from least recently used to most recently used.
2829
- */
2830
2497
  *rvalues() {
2831
- for (const i of this.#rindexes()) {
2832
- const v = this.#valList[i];
2833
- if (v !== void 0 && !this.#isBackgroundFetch(this.#valList[i])) {
2834
- yield this.#valList[i];
2835
- }
2836
- }
2498
+ for (let t3 of this.#O()) this.#t[t3] !== void 0 && !this.#e(this.#t[t3]) && (yield this.#t[t3]);
2837
2499
  }
2838
- /**
2839
- * Iterating over the cache itself yields the same results as
2840
- * {@link LRUCache.entries}
2841
- */
2842
2500
  [Symbol.iterator]() {
2843
2501
  return this.entries();
2844
2502
  }
2845
- /**
2846
- * A String value that is used in the creation of the default string
2847
- * description of an object. Called by the built-in method
2848
- * `Object.prototype.toString`.
2849
- */
2850
2503
  [Symbol.toStringTag] = "LRUCache";
2851
- /**
2852
- * Find a value for which the supplied fn method returns a truthy value,
2853
- * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
2854
- */
2855
- find(fn, getOptions2 = {}) {
2856
- for (const i of this.#indexes()) {
2857
- const v = this.#valList[i];
2858
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
2859
- if (value === void 0)
2860
- continue;
2861
- if (fn(value, this.#keyList[i], this)) {
2862
- return this.get(this.#keyList[i], getOptions2);
2863
- }
2504
+ find(t3, e = {}) {
2505
+ for (let i of this.#F()) {
2506
+ let s = this.#t[i], h = this.#e(s) ? s.__staleWhileFetching : s;
2507
+ if (h !== void 0 && t3(h, this.#i[i], this)) return this.get(this.#i[i], e);
2864
2508
  }
2865
2509
  }
2866
- /**
2867
- * Call the supplied function on each item in the cache, in order from most
2868
- * recently used to least recently used.
2869
- *
2870
- * `fn` is called as `fn(value, key, cache)`.
2871
- *
2872
- * If `thisp` is provided, function will be called in the `this`-context of
2873
- * the provided object, or the cache if no `thisp` object is provided.
2874
- *
2875
- * Does not update age or recenty of use, or iterate over stale values.
2876
- */
2877
- forEach(fn, thisp = this) {
2878
- for (const i of this.#indexes()) {
2879
- const v = this.#valList[i];
2880
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
2881
- if (value === void 0)
2882
- continue;
2883
- fn.call(thisp, value, this.#keyList[i], this);
2510
+ forEach(t3, e = this) {
2511
+ for (let i of this.#F()) {
2512
+ let s = this.#t[i], h = this.#e(s) ? s.__staleWhileFetching : s;
2513
+ h !== void 0 && t3.call(e, h, this.#i[i], this);
2884
2514
  }
2885
2515
  }
2886
- /**
2887
- * The same as {@link LRUCache.forEach} but items are iterated over in
2888
- * reverse order. (ie, less recently used items are iterated over first.)
2889
- */
2890
- rforEach(fn, thisp = this) {
2891
- for (const i of this.#rindexes()) {
2892
- const v = this.#valList[i];
2893
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
2894
- if (value === void 0)
2895
- continue;
2896
- fn.call(thisp, value, this.#keyList[i], this);
2516
+ rforEach(t3, e = this) {
2517
+ for (let i of this.#O()) {
2518
+ let s = this.#t[i], h = this.#e(s) ? s.__staleWhileFetching : s;
2519
+ h !== void 0 && t3.call(e, h, this.#i[i], this);
2897
2520
  }
2898
2521
  }
2899
- /**
2900
- * Delete any stale entries. Returns true if anything was removed,
2901
- * false otherwise.
2902
- */
2903
2522
  purgeStale() {
2904
- let deleted = false;
2905
- for (const i of this.#rindexes({ allowStale: true })) {
2906
- if (this.#isStale(i)) {
2907
- this.#delete(this.#keyList[i], "expire");
2908
- deleted = true;
2909
- }
2910
- }
2911
- return deleted;
2523
+ let t3 = false;
2524
+ for (let e of this.#O({ allowStale: true })) this.#p(e) && (this.#E(this.#i[e], "expire"), t3 = true);
2525
+ return t3;
2912
2526
  }
2913
- /**
2914
- * Get the extended info about a given entry, to get its value, size, and
2915
- * TTL info simultaneously. Returns `undefined` if the key is not present.
2916
- *
2917
- * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
2918
- * serialization, the `start` value is always the current timestamp, and the
2919
- * `ttl` is a calculated remaining time to live (negative if expired).
2920
- *
2921
- * Always returns stale values, if their info is found in the cache, so be
2922
- * sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
2923
- * if relevant.
2924
- */
2925
- info(key) {
2926
- const i = this.#keyMap.get(key);
2927
- if (i === void 0)
2928
- return void 0;
2929
- const v = this.#valList[i];
2930
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
2931
- if (value === void 0)
2932
- return void 0;
2933
- const entry = { value };
2934
- if (this.#ttls && this.#starts) {
2935
- const ttl = this.#ttls[i];
2936
- const start = this.#starts[i];
2937
- if (ttl && start) {
2938
- const remain = ttl - (this.#perf.now() - start);
2939
- entry.ttl = remain;
2940
- entry.start = Date.now();
2527
+ info(t3) {
2528
+ let e = this.#s.get(t3);
2529
+ if (e === void 0) return;
2530
+ let i = this.#t[e], s = this.#e(i) ? i.__staleWhileFetching : i;
2531
+ if (s === void 0) return;
2532
+ let h = { value: s };
2533
+ if (this.#d && this.#A) {
2534
+ let n = this.#d[e], o = this.#A[e];
2535
+ if (n && o) {
2536
+ let r2 = n - (this.#m.now() - o);
2537
+ h.ttl = r2, h.start = Date.now();
2941
2538
  }
2942
2539
  }
2943
- if (this.#sizes) {
2944
- entry.size = this.#sizes[i];
2945
- }
2946
- return entry;
2540
+ return this.#y && (h.size = this.#y[e]), h;
2947
2541
  }
2948
- /**
2949
- * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
2950
- * passed to {@link LRUCache#load}.
2951
- *
2952
- * The `start` fields are calculated relative to a portable `Date.now()`
2953
- * timestamp, even if `performance.now()` is available.
2954
- *
2955
- * Stale entries are always included in the `dump`, even if
2956
- * {@link LRUCache.OptionsBase.allowStale} is false.
2957
- *
2958
- * Note: this returns an actual array, not a generator, so it can be more
2959
- * easily passed around.
2960
- */
2961
2542
  dump() {
2962
- const arr = [];
2963
- for (const i of this.#indexes({ allowStale: true })) {
2964
- const key = this.#keyList[i];
2965
- const v = this.#valList[i];
2966
- const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
2967
- if (value === void 0 || key === void 0)
2968
- continue;
2969
- const entry = { value };
2970
- if (this.#ttls && this.#starts) {
2971
- entry.ttl = this.#ttls[i];
2972
- const age = this.#perf.now() - this.#starts[i];
2973
- entry.start = Math.floor(Date.now() - age);
2974
- }
2975
- if (this.#sizes) {
2976
- entry.size = this.#sizes[i];
2543
+ let t3 = [];
2544
+ for (let e of this.#F({ allowStale: true })) {
2545
+ let i = this.#i[e], s = this.#t[e], h = this.#e(s) ? s.__staleWhileFetching : s;
2546
+ if (h === void 0 || i === void 0) continue;
2547
+ let n = { value: h };
2548
+ if (this.#d && this.#A) {
2549
+ n.ttl = this.#d[e];
2550
+ let o = this.#m.now() - this.#A[e];
2551
+ n.start = Math.floor(Date.now() - o);
2977
2552
  }
2978
- arr.unshift([key, entry]);
2553
+ this.#y && (n.size = this.#y[e]), t3.unshift([i, n]);
2979
2554
  }
2980
- return arr;
2555
+ return t3;
2981
2556
  }
2982
- /**
2983
- * Reset the cache and load in the items in entries in the order listed.
2984
- *
2985
- * The shape of the resulting cache may be different if the same options are
2986
- * not used in both caches.
2987
- *
2988
- * The `start` fields are assumed to be calculated relative to a portable
2989
- * `Date.now()` timestamp, even if `performance.now()` is available.
2990
- */
2991
- load(arr) {
2557
+ load(t3) {
2992
2558
  this.clear();
2993
- for (const [key, entry] of arr) {
2994
- if (entry.start) {
2995
- const age = Date.now() - entry.start;
2996
- entry.start = this.#perf.now() - age;
2559
+ for (let [e, i] of t3) {
2560
+ if (i.start) {
2561
+ let s = Date.now() - i.start;
2562
+ i.start = this.#m.now() - s;
2997
2563
  }
2998
- this.set(key, entry.value, entry);
2564
+ this.set(e, i.value, i);
2999
2565
  }
3000
2566
  }
3001
- /**
3002
- * Add a value to the cache.
3003
- *
3004
- * Note: if `undefined` is specified as a value, this is an alias for
3005
- * {@link LRUCache#delete}
3006
- *
3007
- * Fields on the {@link LRUCache.SetOptions} options param will override
3008
- * their corresponding values in the constructor options for the scope
3009
- * of this single `set()` operation.
3010
- *
3011
- * If `start` is provided, then that will set the effective start
3012
- * time for the TTL calculation. Note that this must be a previous
3013
- * value of `performance.now()` if supported, or a previous value of
3014
- * `Date.now()` if not.
3015
- *
3016
- * Options object may also include `size`, which will prevent
3017
- * calling the `sizeCalculation` function and just use the specified
3018
- * number if it is a positive integer, and `noDisposeOnSet` which
3019
- * will prevent calling a `dispose` function in the case of
3020
- * overwrites.
3021
- *
3022
- * If the `size` (or return value of `sizeCalculation`) for a given
3023
- * entry is greater than `maxEntrySize`, then the item will not be
3024
- * added to the cache.
3025
- *
3026
- * Will update the recency of the entry.
3027
- *
3028
- * If the value is `undefined`, then this is an alias for
3029
- * `cache.delete(key)`. `undefined` is never stored in the cache.
3030
- */
3031
- set(k, v, setOptions = {}) {
3032
- if (v === void 0) {
3033
- this.delete(k);
3034
- return this;
3035
- }
3036
- const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
3037
- let { noUpdateTTL = this.noUpdateTTL } = setOptions;
3038
- const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
3039
- if (this.maxEntrySize && size > this.maxEntrySize) {
3040
- if (status) {
3041
- status.set = "miss";
3042
- status.maxEntrySizeExceeded = true;
3043
- }
3044
- this.#delete(k, "set");
3045
- return this;
3046
- }
3047
- let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
3048
- if (index === void 0) {
3049
- index = this.#size === 0 ? this.#tail : this.#free.length !== 0 ? this.#free.pop() : this.#size === this.#max ? this.#evict(false) : this.#size;
3050
- this.#keyList[index] = k;
3051
- this.#valList[index] = v;
3052
- this.#keyMap.set(k, index);
3053
- this.#next[this.#tail] = index;
3054
- this.#prev[index] = this.#tail;
3055
- this.#tail = index;
3056
- this.#size++;
3057
- this.#addItemSize(index, size, status);
3058
- if (status)
3059
- status.set = "add";
3060
- noUpdateTTL = false;
3061
- if (this.#hasOnInsert) {
3062
- this.#onInsert?.(v, k, "add");
3063
- }
3064
- } else {
3065
- this.#moveToTail(index);
3066
- const oldVal = this.#valList[index];
3067
- if (v !== oldVal) {
3068
- if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
3069
- oldVal.__abortController.abort(new Error("replaced"));
3070
- const { __staleWhileFetching: s } = oldVal;
3071
- if (s !== void 0 && !noDisposeOnSet) {
3072
- if (this.#hasDispose) {
3073
- this.#dispose?.(s, k, "set");
3074
- }
3075
- if (this.#hasDisposeAfter) {
3076
- this.#disposed?.push([s, k, "set"]);
3077
- }
3078
- }
3079
- } else if (!noDisposeOnSet) {
3080
- if (this.#hasDispose) {
3081
- this.#dispose?.(oldVal, k, "set");
3082
- }
3083
- if (this.#hasDisposeAfter) {
3084
- this.#disposed?.push([oldVal, k, "set"]);
3085
- }
3086
- }
3087
- this.#removeItemSize(index);
3088
- this.#addItemSize(index, size, status);
3089
- this.#valList[index] = v;
3090
- if (status) {
3091
- status.set = "replace";
3092
- const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
3093
- if (oldValue !== void 0)
3094
- status.oldValue = oldValue;
3095
- }
3096
- } else if (status) {
3097
- status.set = "update";
3098
- }
3099
- if (this.#hasOnInsert) {
3100
- this.onInsert?.(v, k, v === oldVal ? "update" : "replace");
3101
- }
3102
- }
3103
- if (ttl !== 0 && !this.#ttls) {
3104
- this.#initializeTTLTracking();
3105
- }
3106
- if (this.#ttls) {
3107
- if (!noUpdateTTL) {
3108
- this.#setItemTTL(index, ttl, start);
3109
- }
3110
- if (status)
3111
- this.#statusTTL(status, index);
3112
- }
3113
- if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
3114
- const dt = this.#disposed;
3115
- let task;
3116
- while (task = dt?.shift()) {
3117
- this.#disposeAfter?.(...task);
3118
- }
2567
+ set(t3, e, i = {}) {
2568
+ if (e === void 0) return this.delete(t3), this;
2569
+ let { ttl: s = this.ttl, start: h, noDisposeOnSet: n = this.noDisposeOnSet, sizeCalculation: o = this.sizeCalculation, status: r2 } = i, { noUpdateTTL: f = this.noUpdateTTL } = i, m = this.#P(t3, e, i.size || 0, o);
2570
+ if (this.maxEntrySize && m > this.maxEntrySize) return r2 && (r2.set = "miss", r2.maxEntrySizeExceeded = true), this.#E(t3, "set"), this;
2571
+ let c = this.#n === 0 ? void 0 : this.#s.get(t3);
2572
+ if (c === void 0) c = this.#n === 0 ? this.#h : this.#b.length !== 0 ? this.#b.pop() : this.#n === this.#o ? this.#M(false) : this.#n, this.#i[c] = t3, this.#t[c] = e, this.#s.set(t3, c), this.#a[this.#h] = c, this.#u[c] = this.#h, this.#h = c, this.#n++, this.#U(c, m, r2), r2 && (r2.set = "add"), f = false, this.#x && this.#C?.(e, t3, "add");
2573
+ else {
2574
+ this.#D(c);
2575
+ let d = this.#t[c];
2576
+ if (e !== d) {
2577
+ if (this.#v && this.#e(d)) {
2578
+ d.__abortController.abort(new Error("replaced"));
2579
+ let { __staleWhileFetching: g } = d;
2580
+ g !== void 0 && !n && (this.#T && this.#w?.(g, t3, "set"), this.#f && this.#r?.push([g, t3, "set"]));
2581
+ } else n || (this.#T && this.#w?.(d, t3, "set"), this.#f && this.#r?.push([d, t3, "set"]));
2582
+ if (this.#W(c), this.#U(c, m, r2), this.#t[c] = e, r2) {
2583
+ r2.set = "replace";
2584
+ let g = d && this.#e(d) ? d.__staleWhileFetching : d;
2585
+ g !== void 0 && (r2.oldValue = g);
2586
+ }
2587
+ } else r2 && (r2.set = "update");
2588
+ this.#x && this.onInsert?.(e, t3, e === d ? "update" : "replace");
2589
+ }
2590
+ if (s !== 0 && !this.#d && this.#j(), this.#d && (f || this.#N(c, s, h), r2 && this.#z(r2, c)), !n && this.#f && this.#r) {
2591
+ let d = this.#r, g;
2592
+ for (; g = d?.shift(); ) this.#S?.(...g);
3119
2593
  }
3120
2594
  return this;
3121
2595
  }
3122
- /**
3123
- * Evict the least recently used item, returning its value or
3124
- * `undefined` if cache is empty.
3125
- */
3126
2596
  pop() {
3127
2597
  try {
3128
- while (this.#size) {
3129
- const val = this.#valList[this.#head];
3130
- this.#evict(true);
3131
- if (this.#isBackgroundFetch(val)) {
3132
- if (val.__staleWhileFetching) {
3133
- return val.__staleWhileFetching;
3134
- }
3135
- } else if (val !== void 0) {
3136
- return val;
3137
- }
2598
+ for (; this.#n; ) {
2599
+ let t3 = this.#t[this.#l];
2600
+ if (this.#M(true), this.#e(t3)) {
2601
+ if (t3.__staleWhileFetching) return t3.__staleWhileFetching;
2602
+ } else if (t3 !== void 0) return t3;
3138
2603
  }
3139
2604
  } finally {
3140
- if (this.#hasDisposeAfter && this.#disposed) {
3141
- const dt = this.#disposed;
3142
- let task;
3143
- while (task = dt?.shift()) {
3144
- this.#disposeAfter?.(...task);
3145
- }
2605
+ if (this.#f && this.#r) {
2606
+ let t3 = this.#r, e;
2607
+ for (; e = t3?.shift(); ) this.#S?.(...e);
3146
2608
  }
3147
2609
  }
3148
2610
  }
3149
- #evict(free) {
3150
- const head = this.#head;
3151
- const k = this.#keyList[head];
3152
- const v = this.#valList[head];
3153
- if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
3154
- v.__abortController.abort(new Error("evicted"));
3155
- } else if (this.#hasDispose || this.#hasDisposeAfter) {
3156
- if (this.#hasDispose) {
3157
- this.#dispose?.(v, k, "evict");
3158
- }
3159
- if (this.#hasDisposeAfter) {
3160
- this.#disposed?.push([v, k, "evict"]);
3161
- }
3162
- }
3163
- this.#removeItemSize(head);
3164
- if (this.#autopurgeTimers?.[head]) {
3165
- clearTimeout(this.#autopurgeTimers[head]);
3166
- this.#autopurgeTimers[head] = void 0;
3167
- }
3168
- if (free) {
3169
- this.#keyList[head] = void 0;
3170
- this.#valList[head] = void 0;
3171
- this.#free.push(head);
3172
- }
3173
- if (this.#size === 1) {
3174
- this.#head = this.#tail = 0;
3175
- this.#free.length = 0;
3176
- } else {
3177
- this.#head = this.#next[head];
3178
- }
3179
- this.#keyMap.delete(k);
3180
- this.#size--;
3181
- return head;
2611
+ #M(t3) {
2612
+ let e = this.#l, i = this.#i[e], s = this.#t[e];
2613
+ 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), t3 && (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;
3182
2614
  }
3183
- /**
3184
- * Check if a key is in the cache, without updating the recency of use.
3185
- * Will return false if the item is stale, even though it is technically
3186
- * in the cache.
3187
- *
3188
- * Check if a key is in the cache, without updating the recency of
3189
- * use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
3190
- * to `true` in either the options or the constructor.
3191
- *
3192
- * Will return `false` if the item is stale, even though it is technically in
3193
- * the cache. The difference can be determined (if it matters) by using a
3194
- * `status` argument, and inspecting the `has` field.
3195
- *
3196
- * Will not update item age unless
3197
- * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
3198
- */
3199
- has(k, hasOptions = {}) {
3200
- const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
3201
- const index = this.#keyMap.get(k);
3202
- if (index !== void 0) {
3203
- const v = this.#valList[index];
3204
- if (this.#isBackgroundFetch(v) && v.__staleWhileFetching === void 0) {
3205
- return false;
3206
- }
3207
- if (!this.#isStale(index)) {
3208
- if (updateAgeOnHas) {
3209
- this.#updateItemAge(index);
3210
- }
3211
- if (status) {
3212
- status.has = "hit";
3213
- this.#statusTTL(status, index);
3214
- }
3215
- return true;
3216
- } else if (status) {
3217
- status.has = "stale";
3218
- this.#statusTTL(status, index);
3219
- }
3220
- } else if (status) {
3221
- status.has = "miss";
3222
- }
2615
+ has(t3, e = {}) {
2616
+ let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, h = this.#s.get(t3);
2617
+ if (h !== void 0) {
2618
+ let n = this.#t[h];
2619
+ if (this.#e(n) && n.__staleWhileFetching === void 0) return false;
2620
+ if (this.#p(h)) s && (s.has = "stale", this.#z(s, h));
2621
+ else return i && this.#R(h), s && (s.has = "hit", this.#z(s, h)), true;
2622
+ } else s && (s.has = "miss");
3223
2623
  return false;
3224
2624
  }
3225
- /**
3226
- * Like {@link LRUCache#get} but doesn't update recency or delete stale
3227
- * items.
3228
- *
3229
- * Returns `undefined` if the item is stale, unless
3230
- * {@link LRUCache.OptionsBase.allowStale} is set.
3231
- */
3232
- peek(k, peekOptions = {}) {
3233
- const { allowStale = this.allowStale } = peekOptions;
3234
- const index = this.#keyMap.get(k);
3235
- if (index === void 0 || !allowStale && this.#isStale(index)) {
3236
- return;
3237
- }
3238
- const v = this.#valList[index];
3239
- return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
3240
- }
3241
- #backgroundFetch(k, index, options, context) {
3242
- const v = index === void 0 ? void 0 : this.#valList[index];
3243
- if (this.#isBackgroundFetch(v)) {
3244
- return v;
3245
- }
3246
- const ac = new AC();
3247
- const { signal } = options;
3248
- signal?.addEventListener("abort", () => ac.abort(signal.reason), {
3249
- signal: ac.signal
3250
- });
3251
- const fetchOpts = {
3252
- signal: ac.signal,
3253
- options,
3254
- context
3255
- };
3256
- const cb = (v2, updateCache = false) => {
3257
- const { aborted } = ac.signal;
3258
- const ignoreAbort = options.ignoreFetchAbort && v2 !== void 0;
3259
- const proceed = options.ignoreFetchAbort || !!(options.allowStaleOnFetchAbort && v2 !== void 0);
3260
- if (options.status) {
3261
- if (aborted && !updateCache) {
3262
- options.status.fetchAborted = true;
3263
- options.status.fetchError = ac.signal.reason;
3264
- if (ignoreAbort)
3265
- options.status.fetchAbortIgnored = true;
3266
- } else {
3267
- options.status.fetchResolved = true;
3268
- }
3269
- }
3270
- if (aborted && !ignoreAbort && !updateCache) {
3271
- return fetchFail(ac.signal.reason, proceed);
3272
- }
3273
- const bf2 = p;
3274
- const vl = this.#valList[index];
3275
- if (vl === p || ignoreAbort && updateCache && vl === void 0) {
3276
- if (v2 === void 0) {
3277
- if (bf2.__staleWhileFetching !== void 0) {
3278
- this.#valList[index] = bf2.__staleWhileFetching;
3279
- } else {
3280
- this.#delete(k, "fetch");
3281
- }
3282
- } else {
3283
- if (options.status)
3284
- options.status.fetchUpdated = true;
3285
- this.set(k, v2, fetchOpts.options);
3286
- }
3287
- }
3288
- return v2;
3289
- };
3290
- const eb = (er) => {
3291
- if (options.status) {
3292
- options.status.fetchRejected = true;
3293
- options.status.fetchError = er;
3294
- }
3295
- return fetchFail(er, false);
3296
- };
3297
- const fetchFail = (er, proceed) => {
3298
- const { aborted } = ac.signal;
3299
- const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
3300
- const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
3301
- const noDelete = allowStale || options.noDeleteOnFetchRejection;
3302
- const bf2 = p;
3303
- if (this.#valList[index] === p) {
3304
- const del = !noDelete || !proceed && bf2.__staleWhileFetching === void 0;
3305
- if (del) {
3306
- this.#delete(k, "fetch");
3307
- } else if (!allowStaleAborted) {
3308
- this.#valList[index] = bf2.__staleWhileFetching;
3309
- }
3310
- }
3311
- if (allowStale) {
3312
- if (options.status && bf2.__staleWhileFetching !== void 0) {
3313
- options.status.returnedStale = true;
3314
- }
3315
- return bf2.__staleWhileFetching;
3316
- } else if (bf2.__returned === bf2) {
3317
- throw er;
3318
- }
3319
- };
3320
- const pcall = (res, rej) => {
3321
- const fmp = this.#fetchMethod?.(k, v, fetchOpts);
3322
- if (fmp && fmp instanceof Promise) {
3323
- fmp.then((v2) => res(v2 === void 0 ? void 0 : v2), rej);
3324
- }
3325
- ac.signal.addEventListener("abort", () => {
3326
- if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
3327
- res(void 0);
3328
- if (options.allowStaleOnFetchAbort) {
3329
- res = (v2) => cb(v2, true);
3330
- }
3331
- }
2625
+ peek(t3, e = {}) {
2626
+ let { allowStale: i = this.allowStale } = e, s = this.#s.get(t3);
2627
+ if (s === void 0 || !i && this.#p(s)) return;
2628
+ let h = this.#t[s];
2629
+ return this.#e(h) ? h.__staleWhileFetching : h;
2630
+ }
2631
+ #G(t3, e, i, s) {
2632
+ let h = e === void 0 ? void 0 : this.#t[e];
2633
+ if (this.#e(h)) return h;
2634
+ let n = new C(), { signal: o } = i;
2635
+ o?.addEventListener("abort", () => n.abort(o.reason), { signal: n.signal });
2636
+ let r2 = { signal: n.signal, options: i, context: s }, f = (p, _ = false) => {
2637
+ let { aborted: l } = n.signal, w = i.ignoreFetchAbort && p !== void 0, b = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && p !== void 0);
2638
+ if (i.status && (l && !_ ? (i.status.fetchAborted = true, i.status.fetchError = n.signal.reason, w && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), l && !w && !_) return c(n.signal.reason, b);
2639
+ let S = g, u = this.#t[e];
2640
+ return (u === g || w && _ && u === void 0) && (p === void 0 ? S.__staleWhileFetching !== void 0 ? this.#t[e] = S.__staleWhileFetching : this.#E(t3, "fetch") : (i.status && (i.status.fetchUpdated = true), this.set(t3, p, r2.options))), p;
2641
+ }, m = (p) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = p), c(p, false)), c = (p, _) => {
2642
+ let { aborted: l } = n.signal, w = l && i.allowStaleOnFetchAbort, b = w || i.allowStaleOnFetchRejection, S = b || i.noDeleteOnFetchRejection, u = g;
2643
+ if (this.#t[e] === g && (!S || !_ && u.__staleWhileFetching === void 0 ? this.#E(t3, "fetch") : w || (this.#t[e] = u.__staleWhileFetching)), b) return i.status && u.__staleWhileFetching !== void 0 && (i.status.returnedStale = true), u.__staleWhileFetching;
2644
+ if (u.__returned === u) throw p;
2645
+ }, d = (p, _) => {
2646
+ let l = this.#L?.(t3, h, r2);
2647
+ l && l instanceof Promise && l.then((w) => p(w === void 0 ? void 0 : w), _), n.signal.addEventListener("abort", () => {
2648
+ (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (p(void 0), i.allowStaleOnFetchAbort && (p = (w) => f(w, true)));
3332
2649
  });
3333
2650
  };
3334
- if (options.status)
3335
- options.status.fetchDispatched = true;
3336
- const p = new Promise(pcall).then(cb, eb);
3337
- const bf = Object.assign(p, {
3338
- __abortController: ac,
3339
- __staleWhileFetching: v,
3340
- __returned: void 0
3341
- });
3342
- if (index === void 0) {
3343
- this.set(k, bf, { ...fetchOpts.options, status: void 0 });
3344
- index = this.#keyMap.get(k);
2651
+ i.status && (i.status.fetchDispatched = true);
2652
+ let g = new Promise(d).then(f, m), A = Object.assign(g, { __abortController: n, __staleWhileFetching: h, __returned: void 0 });
2653
+ return e === void 0 ? (this.set(t3, A, { ...r2.options, status: void 0 }), e = this.#s.get(t3)) : this.#t[e] = A, A;
2654
+ }
2655
+ #e(t3) {
2656
+ if (!this.#v) return false;
2657
+ let e = t3;
2658
+ return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof C;
2659
+ }
2660
+ async fetch(t3, e = {}) {
2661
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: h = this.noDeleteOnStaleGet, ttl: n = this.ttl, noDisposeOnSet: o = this.noDisposeOnSet, size: r2 = 0, sizeCalculation: f = this.sizeCalculation, noUpdateTTL: m = this.noUpdateTTL, noDeleteOnFetchRejection: c = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: g = this.ignoreFetchAbort, allowStaleOnFetchAbort: A = this.allowStaleOnFetchAbort, context: p, forceRefresh: _ = false, status: l, signal: w } = e;
2662
+ if (!this.#v) return l && (l.fetch = "get"), this.get(t3, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: h, status: l });
2663
+ let b = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: h, ttl: n, noDisposeOnSet: o, size: r2, sizeCalculation: f, noUpdateTTL: m, noDeleteOnFetchRejection: c, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: A, ignoreFetchAbort: g, status: l, signal: w }, S = this.#s.get(t3);
2664
+ if (S === void 0) {
2665
+ l && (l.fetch = "miss");
2666
+ let u = this.#G(t3, S, b, p);
2667
+ return u.__returned = u;
3345
2668
  } else {
3346
- this.#valList[index] = bf;
3347
- }
3348
- return bf;
3349
- }
3350
- #isBackgroundFetch(p) {
3351
- if (!this.#hasFetchMethod)
3352
- return false;
3353
- const b = p;
3354
- return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC;
3355
- }
3356
- async fetch(k, fetchOptions = {}) {
3357
- const {
3358
- // get options
3359
- allowStale = this.allowStale,
3360
- updateAgeOnGet = this.updateAgeOnGet,
3361
- noDeleteOnStaleGet = this.noDeleteOnStaleGet,
3362
- // set options
3363
- ttl = this.ttl,
3364
- noDisposeOnSet = this.noDisposeOnSet,
3365
- size = 0,
3366
- sizeCalculation = this.sizeCalculation,
3367
- noUpdateTTL = this.noUpdateTTL,
3368
- // fetch exclusive options
3369
- noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
3370
- allowStaleOnFetchRejection = this.allowStaleOnFetchRejection,
3371
- ignoreFetchAbort = this.ignoreFetchAbort,
3372
- allowStaleOnFetchAbort = this.allowStaleOnFetchAbort,
3373
- context,
3374
- forceRefresh = false,
3375
- status,
3376
- signal
3377
- } = fetchOptions;
3378
- if (!this.#hasFetchMethod) {
3379
- if (status)
3380
- status.fetch = "get";
3381
- return this.get(k, {
3382
- allowStale,
3383
- updateAgeOnGet,
3384
- noDeleteOnStaleGet,
3385
- status
3386
- });
3387
- }
3388
- const options = {
3389
- allowStale,
3390
- updateAgeOnGet,
3391
- noDeleteOnStaleGet,
3392
- ttl,
3393
- noDisposeOnSet,
3394
- size,
3395
- sizeCalculation,
3396
- noUpdateTTL,
3397
- noDeleteOnFetchRejection,
3398
- allowStaleOnFetchRejection,
3399
- allowStaleOnFetchAbort,
3400
- ignoreFetchAbort,
3401
- status,
3402
- signal
3403
- };
3404
- let index = this.#keyMap.get(k);
3405
- if (index === void 0) {
3406
- if (status)
3407
- status.fetch = "miss";
3408
- const p = this.#backgroundFetch(k, index, options, context);
3409
- return p.__returned = p;
3410
- } else {
3411
- const v = this.#valList[index];
3412
- if (this.#isBackgroundFetch(v)) {
3413
- const stale = allowStale && v.__staleWhileFetching !== void 0;
3414
- if (status) {
3415
- status.fetch = "inflight";
3416
- if (stale)
3417
- status.returnedStale = true;
3418
- }
3419
- return stale ? v.__staleWhileFetching : v.__returned = v;
3420
- }
3421
- const isStale = this.#isStale(index);
3422
- if (!forceRefresh && !isStale) {
3423
- if (status)
3424
- status.fetch = "hit";
3425
- this.#moveToTail(index);
3426
- if (updateAgeOnGet) {
3427
- this.#updateItemAge(index);
3428
- }
3429
- if (status)
3430
- this.#statusTTL(status, index);
3431
- return v;
3432
- }
3433
- const p = this.#backgroundFetch(k, index, options, context);
3434
- const hasStale = p.__staleWhileFetching !== void 0;
3435
- const staleVal = hasStale && allowStale;
3436
- if (status) {
3437
- status.fetch = isStale ? "stale" : "refresh";
3438
- if (staleVal && isStale)
3439
- status.returnedStale = true;
3440
- }
3441
- return staleVal ? p.__staleWhileFetching : p.__returned = p;
3442
- }
3443
- }
3444
- async forceFetch(k, fetchOptions = {}) {
3445
- const v = await this.fetch(k, fetchOptions);
3446
- if (v === void 0)
3447
- throw new Error("fetch() returned undefined");
3448
- return v;
3449
- }
3450
- memo(k, memoOptions = {}) {
3451
- const memoMethod = this.#memoMethod;
3452
- if (!memoMethod) {
3453
- throw new Error("no memoMethod provided to constructor");
3454
- }
3455
- const { context, forceRefresh, ...options } = memoOptions;
3456
- const v = this.get(k, options);
3457
- if (!forceRefresh && v !== void 0)
3458
- return v;
3459
- const vv = memoMethod(k, v, {
3460
- options,
3461
- context
3462
- });
3463
- this.set(k, vv, options);
3464
- return vv;
3465
- }
3466
- /**
3467
- * Return a value from the cache. Will update the recency of the cache
3468
- * entry found.
3469
- *
3470
- * If the key is not found, get() will return `undefined`.
3471
- */
3472
- get(k, getOptions2 = {}) {
3473
- const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions2;
3474
- const index = this.#keyMap.get(k);
3475
- if (index !== void 0) {
3476
- const value = this.#valList[index];
3477
- const fetching = this.#isBackgroundFetch(value);
3478
- if (status)
3479
- this.#statusTTL(status, index);
3480
- if (this.#isStale(index)) {
3481
- if (status)
3482
- status.get = "stale";
3483
- if (!fetching) {
3484
- if (!noDeleteOnStaleGet) {
3485
- this.#delete(k, "expire");
3486
- }
3487
- if (status && allowStale)
3488
- status.returnedStale = true;
3489
- return allowStale ? value : void 0;
3490
- } else {
3491
- if (status && allowStale && value.__staleWhileFetching !== void 0) {
3492
- status.returnedStale = true;
3493
- }
3494
- return allowStale ? value.__staleWhileFetching : void 0;
3495
- }
3496
- } else {
3497
- if (status)
3498
- status.get = "hit";
3499
- if (fetching) {
3500
- return value.__staleWhileFetching;
3501
- }
3502
- this.#moveToTail(index);
3503
- if (updateAgeOnGet) {
3504
- this.#updateItemAge(index);
3505
- }
3506
- return value;
2669
+ let u = this.#t[S];
2670
+ if (this.#e(u)) {
2671
+ let E = i && u.__staleWhileFetching !== void 0;
2672
+ return l && (l.fetch = "inflight", E && (l.returnedStale = true)), E ? u.__staleWhileFetching : u.__returned = u;
3507
2673
  }
3508
- } else if (status) {
3509
- status.get = "miss";
2674
+ let T = this.#p(S);
2675
+ if (!_ && !T) return l && (l.fetch = "hit"), this.#D(S), s && this.#R(S), l && this.#z(l, S), u;
2676
+ let F = this.#G(t3, S, b, p), O = F.__staleWhileFetching !== void 0 && i;
2677
+ return l && (l.fetch = T ? "stale" : "refresh", O && T && (l.returnedStale = true)), O ? F.__staleWhileFetching : F.__returned = F;
3510
2678
  }
3511
2679
  }
3512
- #connect(p, n) {
3513
- this.#prev[n] = p;
3514
- this.#next[p] = n;
3515
- }
3516
- #moveToTail(index) {
3517
- if (index !== this.#tail) {
3518
- if (index === this.#head) {
3519
- this.#head = this.#next[index];
3520
- } else {
3521
- this.#connect(this.#prev[index], this.#next[index]);
3522
- }
3523
- this.#connect(this.#tail, index);
3524
- this.#tail = index;
3525
- }
2680
+ async forceFetch(t3, e = {}) {
2681
+ let i = await this.fetch(t3, e);
2682
+ if (i === void 0) throw new Error("fetch() returned undefined");
2683
+ return i;
3526
2684
  }
3527
- /**
3528
- * Deletes a key out of the cache.
3529
- *
3530
- * Returns true if the key was deleted, false otherwise.
3531
- */
3532
- delete(k) {
3533
- return this.#delete(k, "delete");
3534
- }
3535
- #delete(k, reason) {
3536
- let deleted = false;
3537
- if (this.#size !== 0) {
3538
- const index = this.#keyMap.get(k);
3539
- if (index !== void 0) {
3540
- if (this.#autopurgeTimers?.[index]) {
3541
- clearTimeout(this.#autopurgeTimers?.[index]);
3542
- this.#autopurgeTimers[index] = void 0;
3543
- }
3544
- deleted = true;
3545
- if (this.#size === 1) {
3546
- this.#clear(reason);
3547
- } else {
3548
- this.#removeItemSize(index);
3549
- const v = this.#valList[index];
3550
- if (this.#isBackgroundFetch(v)) {
3551
- v.__abortController.abort(new Error("deleted"));
3552
- } else if (this.#hasDispose || this.#hasDisposeAfter) {
3553
- if (this.#hasDispose) {
3554
- this.#dispose?.(v, k, reason);
3555
- }
3556
- if (this.#hasDisposeAfter) {
3557
- this.#disposed?.push([v, k, reason]);
3558
- }
3559
- }
3560
- this.#keyMap.delete(k);
3561
- this.#keyList[index] = void 0;
3562
- this.#valList[index] = void 0;
3563
- if (index === this.#tail) {
3564
- this.#tail = this.#prev[index];
3565
- } else if (index === this.#head) {
3566
- this.#head = this.#next[index];
3567
- } else {
3568
- const pi = this.#prev[index];
3569
- this.#next[pi] = this.#next[index];
3570
- const ni = this.#next[index];
3571
- this.#prev[ni] = this.#prev[index];
3572
- }
3573
- this.#size--;
3574
- this.#free.push(index);
2685
+ memo(t3, e = {}) {
2686
+ let i = this.#I;
2687
+ if (!i) throw new Error("no memoMethod provided to constructor");
2688
+ let { context: s, forceRefresh: h, ...n } = e, o = this.get(t3, n);
2689
+ if (!h && o !== void 0) return o;
2690
+ let r2 = i(t3, o, { options: n, context: s });
2691
+ return this.set(t3, r2, n), r2;
2692
+ }
2693
+ get(t3, e = {}) {
2694
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: h = this.noDeleteOnStaleGet, status: n } = e, o = this.#s.get(t3);
2695
+ if (o !== void 0) {
2696
+ let r2 = this.#t[o], f = this.#e(r2);
2697
+ return n && this.#z(n, o), this.#p(o) ? (n && (n.get = "stale"), f ? (n && i && r2.__staleWhileFetching !== void 0 && (n.returnedStale = true), i ? r2.__staleWhileFetching : void 0) : (h || this.#E(t3, "expire"), n && i && (n.returnedStale = true), i ? r2 : void 0)) : (n && (n.get = "hit"), f ? r2.__staleWhileFetching : (this.#D(o), s && this.#R(o), r2));
2698
+ } else n && (n.get = "miss");
2699
+ }
2700
+ #k(t3, e) {
2701
+ this.#u[e] = t3, this.#a[t3] = e;
2702
+ }
2703
+ #D(t3) {
2704
+ t3 !== this.#h && (t3 === this.#l ? this.#l = this.#a[t3] : this.#k(this.#u[t3], this.#a[t3]), this.#k(this.#h, t3), this.#h = t3);
2705
+ }
2706
+ delete(t3) {
2707
+ return this.#E(t3, "delete");
2708
+ }
2709
+ #E(t3, e) {
2710
+ let i = false;
2711
+ if (this.#n !== 0) {
2712
+ let s = this.#s.get(t3);
2713
+ 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);
2714
+ else {
2715
+ this.#W(s);
2716
+ let h = this.#t[s];
2717
+ if (this.#e(h) ? h.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(h, t3, e), this.#f && this.#r?.push([h, t3, e])), this.#s.delete(t3), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
2718
+ else if (s === this.#l) this.#l = this.#a[s];
2719
+ else {
2720
+ let n = this.#u[s];
2721
+ this.#a[n] = this.#a[s];
2722
+ let o = this.#a[s];
2723
+ this.#u[o] = this.#u[s];
3575
2724
  }
2725
+ this.#n--, this.#b.push(s);
3576
2726
  }
3577
2727
  }
3578
- if (this.#hasDisposeAfter && this.#disposed?.length) {
3579
- const dt = this.#disposed;
3580
- let task;
3581
- while (task = dt?.shift()) {
3582
- this.#disposeAfter?.(...task);
3583
- }
2728
+ if (this.#f && this.#r?.length) {
2729
+ let s = this.#r, h;
2730
+ for (; h = s?.shift(); ) this.#S?.(...h);
3584
2731
  }
3585
- return deleted;
2732
+ return i;
3586
2733
  }
3587
- /**
3588
- * Clear the cache entirely, throwing away all values.
3589
- */
3590
2734
  clear() {
3591
- return this.#clear("delete");
2735
+ return this.#V("delete");
3592
2736
  }
3593
- #clear(reason) {
3594
- for (const index of this.#rindexes({ allowStale: true })) {
3595
- const v = this.#valList[index];
3596
- if (this.#isBackgroundFetch(v)) {
3597
- v.__abortController.abort(new Error("deleted"));
3598
- } else {
3599
- const k = this.#keyList[index];
3600
- if (this.#hasDispose) {
3601
- this.#dispose?.(v, k, reason);
3602
- }
3603
- if (this.#hasDisposeAfter) {
3604
- this.#disposed?.push([v, k, reason]);
3605
- }
3606
- }
3607
- }
3608
- this.#keyMap.clear();
3609
- this.#valList.fill(void 0);
3610
- this.#keyList.fill(void 0);
3611
- if (this.#ttls && this.#starts) {
3612
- this.#ttls.fill(0);
3613
- this.#starts.fill(0);
3614
- for (const t3 of this.#autopurgeTimers ?? []) {
3615
- if (t3 !== void 0)
3616
- clearTimeout(t3);
2737
+ #V(t3) {
2738
+ for (let e of this.#O({ allowStale: true })) {
2739
+ let i = this.#t[e];
2740
+ if (this.#e(i)) i.__abortController.abort(new Error("deleted"));
2741
+ else {
2742
+ let s = this.#i[e];
2743
+ this.#T && this.#w?.(i, s, t3), this.#f && this.#r?.push([i, s, t3]);
3617
2744
  }
3618
- this.#autopurgeTimers?.fill(void 0);
3619
2745
  }
3620
- if (this.#sizes) {
3621
- this.#sizes.fill(0);
2746
+ if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#A) {
2747
+ this.#d.fill(0), this.#A.fill(0);
2748
+ for (let e of this.#g ?? []) e !== void 0 && clearTimeout(e);
2749
+ this.#g?.fill(void 0);
3622
2750
  }
3623
- this.#head = 0;
3624
- this.#tail = 0;
3625
- this.#free.length = 0;
3626
- this.#calculatedSize = 0;
3627
- this.#size = 0;
3628
- if (this.#hasDisposeAfter && this.#disposed) {
3629
- const dt = this.#disposed;
3630
- let task;
3631
- while (task = dt?.shift()) {
3632
- this.#disposeAfter?.(...task);
3633
- }
2751
+ 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) {
2752
+ let e = this.#r, i;
2753
+ for (; i = e?.shift(); ) this.#S?.(...i);
3634
2754
  }
3635
2755
  }
3636
2756
  };
@@ -4778,7 +3898,7 @@ function collectAllComponentNames(options) {
4778
3898
  for (const key of manifestCache.keys()) {
4779
3899
  names.add(key);
4780
3900
  }
4781
- return Array.from(names).sort((a, b) => a.localeCompare(b));
3901
+ return Array.from(names).sort((a3, b) => a3.localeCompare(b));
4782
3902
  }
4783
3903
  async function writeManifestFile(options) {
4784
3904
  const {
@@ -4798,7 +3918,7 @@ async function writeManifestFile(options) {
4798
3918
  manifestMap.set(componentName, match2.value.from);
4799
3919
  }
4800
3920
  const manifest = Object.fromEntries(
4801
- Array.from(manifestMap.entries()).sort(([a], [b]) => a.localeCompare(b))
3921
+ Array.from(manifestMap.entries()).sort(([a3], [b]) => a3.localeCompare(b))
4802
3922
  );
4803
3923
  manifestCache.clear();
4804
3924
  for (const [componentName, fromPath] of manifestMap.entries()) {
@@ -4940,7 +4060,7 @@ function createHtmlCustomDataDefinition(componentNames, getMetadata, baseTags =
4940
4060
  ...combinedTypes.keys(),
4941
4061
  ...docs.keys()
4942
4062
  ]);
4943
- const attributes = Array.from(attributeNames2).sort((a, b) => a.localeCompare(b)).map((propName) => {
4063
+ const attributes = Array.from(attributeNames2).sort((a3, b) => a3.localeCompare(b)).map((propName) => {
4944
4064
  const type = combinedTypes.get(propName);
4945
4065
  const doc = docs.get(propName);
4946
4066
  const pieces = [];
@@ -5011,7 +4131,7 @@ function mergeHtmlCustomDataTags(baseTags, extraTags) {
5011
4131
  references: mergedReferences
5012
4132
  });
5013
4133
  }
5014
- return Array.from(tagMap.values()).sort((a, b) => a.name.localeCompare(b.name));
4134
+ return Array.from(tagMap.values()).sort((a3, b) => a3.name.localeCompare(b.name));
5015
4135
  }
5016
4136
  function mergeHtmlAttributes(baseAttributes, extraAttributes) {
5017
4137
  if (!baseAttributes?.length) {
@@ -5042,7 +4162,7 @@ function mergeHtmlAttributes(baseAttributes, extraAttributes) {
5042
4162
  values: mergeAttributeValues(existing.values, attr.values)
5043
4163
  });
5044
4164
  }
5045
- return Array.from(attrMap.values()).sort((a, b) => a.name.localeCompare(b.name));
4165
+ return Array.from(attrMap.values()).sort((a3, b) => a3.name.localeCompare(b.name));
5046
4166
  }
5047
4167
  function mergeAttributeValues(baseValues, extraValues) {
5048
4168
  if (!baseValues?.length) {
@@ -5131,7 +4251,7 @@ function formatComponentEntry(name, props) {
5131
4251
  }
5132
4252
  const lines = [`${indent}${key}: {`];
5133
4253
  const innerIndent = `${indent} `;
5134
- const entries = Array.from(props.entries()).sort((a, b) => a[0].localeCompare(b[0]));
4254
+ const entries = Array.from(props.entries()).sort((a3, b) => a3[0].localeCompare(b[0]));
5135
4255
  for (const [propName, type] of entries) {
5136
4256
  const formattedProp = formatPropertyKey(propName);
5137
4257
  lines.push(`${innerIndent}readonly ${formattedProp}?: ${type};`);
@@ -5173,7 +4293,7 @@ function formatPropsType(props) {
5173
4293
  if (!props || props.size === 0) {
5174
4294
  return "Record<string, any>";
5175
4295
  }
5176
- const entries = Array.from(props.entries()).sort((a, b) => a[0].localeCompare(b[0]));
4296
+ const entries = Array.from(props.entries()).sort((a3, b) => a3[0].localeCompare(b[0]));
5177
4297
  const lines = ["{"];
5178
4298
  for (const [propName, type] of entries) {
5179
4299
  const key = formatPropertyKey(propName);
@@ -8624,7 +7744,7 @@ function createResolverHelpers(state) {
8624
7744
  }
8625
7745
 
8626
7746
  // src/runtime/autoImport/service/index.ts
8627
- var logWarnCache = new LRUCache({
7747
+ var logWarnCache = new L({
8628
7748
  max: 512,
8629
7749
  ttl: 1e3 * 60 * 60
8630
7750
  });
@@ -8927,11 +8047,11 @@ function cloneCandidate(candidate) {
8927
8047
  jsonPath: candidate.jsonPath
8928
8048
  };
8929
8049
  }
8930
- function areSetsEqual(a, b) {
8931
- if (a.size !== b.size) {
8050
+ function areSetsEqual(a3, b) {
8051
+ if (a3.size !== b.size) {
8932
8052
  return false;
8933
8053
  }
8934
- for (const value of a) {
8054
+ for (const value of a3) {
8935
8055
  if (!b.has(value)) {
8936
8056
  return false;
8937
8057
  }
@@ -9118,31 +8238,31 @@ async function scanRoutes(ctx, candidatesMap) {
9118
8238
  const entries = Array.from(entriesSet);
9119
8239
  const subPackageList = Array.from(subPackages.entries()).map(([root, value]) => {
9120
8240
  const pagesArray = Array.from(value);
9121
- pagesArray.sort((a, b) => a.localeCompare(b));
8241
+ pagesArray.sort((a3, b) => a3.localeCompare(b));
9122
8242
  return {
9123
8243
  root,
9124
8244
  pages: pagesArray
9125
8245
  };
9126
8246
  });
9127
- pages.sort((a, b) => {
9128
- if (a === "pages/index/index") {
8247
+ pages.sort((a3, b) => {
8248
+ if (a3 === "pages/index/index") {
9129
8249
  return -1;
9130
8250
  }
9131
8251
  if (b === "pages/index/index") {
9132
8252
  return 1;
9133
8253
  }
9134
- return a.localeCompare(b);
8254
+ return a3.localeCompare(b);
9135
8255
  });
9136
- entries.sort((a, b) => {
9137
- if (a === "pages/index/index") {
8256
+ entries.sort((a3, b) => {
8257
+ if (a3 === "pages/index/index") {
9138
8258
  return -1;
9139
8259
  }
9140
8260
  if (b === "pages/index/index") {
9141
8261
  return 1;
9142
8262
  }
9143
- return a.localeCompare(b);
8263
+ return a3.localeCompare(b);
9144
8264
  });
9145
- subPackageList.sort((a, b) => a.root.localeCompare(b.root));
8265
+ subPackageList.sort((a3, b) => a3.root.localeCompare(b.root));
9146
8266
  const snapshot = {
9147
8267
  pages,
9148
8268
  entries,
@@ -16247,17 +15367,17 @@ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, ba
16247
15367
  }
16248
15368
  throw exportsNotFound(packageSubpath, packageJsonUrl, base);
16249
15369
  }
16250
- function patternKeyCompare(a, b) {
16251
- const aPatternIndex = a.indexOf("*");
15370
+ function patternKeyCompare(a3, b) {
15371
+ const aPatternIndex = a3.indexOf("*");
16252
15372
  const bPatternIndex = b.indexOf("*");
16253
- const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
15373
+ const baseLengthA = aPatternIndex === -1 ? a3.length : aPatternIndex + 1;
16254
15374
  const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
16255
15375
  if (baseLengthA > baseLengthB) return -1;
16256
15376
  if (baseLengthB > baseLengthA) return 1;
16257
15377
  if (aPatternIndex === -1) return 1;
16258
15378
  if (bPatternIndex === -1) return -1;
16259
- if (a.length > b.length) return -1;
16260
- if (b.length > a.length) return 1;
15379
+ if (a3.length > b.length) return -1;
15380
+ if (b.length > a3.length) return 1;
16261
15381
  return 0;
16262
15382
  }
16263
15383
  function packageImportsResolve(name, base, conditions) {
@@ -18805,8 +17925,8 @@ init_esm_shims();
18805
17925
 
18806
17926
  // ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
18807
17927
  init_esm_shims();
18808
- var balanced = (a, b, str) => {
18809
- const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
17928
+ var balanced = (a3, b, str) => {
17929
+ const ma = a3 instanceof RegExp ? maybeMatch(a3, str) : a3;
18810
17930
  const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
18811
17931
  const r2 = ma !== null && mb != null && range(ma, mb, str);
18812
17932
  return r2 && {
@@ -18821,13 +17941,13 @@ var maybeMatch = (reg, str) => {
18821
17941
  const m = str.match(reg);
18822
17942
  return m ? m[0] : null;
18823
17943
  };
18824
- var range = (a, b, str) => {
17944
+ var range = (a3, b, str) => {
18825
17945
  let begs, beg, left, right = void 0, result;
18826
- let ai = str.indexOf(a);
17946
+ let ai = str.indexOf(a3);
18827
17947
  let bi = str.indexOf(b, ai + 1);
18828
17948
  let i = ai;
18829
17949
  if (ai >= 0 && bi > 0) {
18830
- if (a === b) {
17950
+ if (a3 === b) {
18831
17951
  return [ai, bi];
18832
17952
  }
18833
17953
  begs = [];
@@ -18835,7 +17955,7 @@ var range = (a, b, str) => {
18835
17955
  while (i >= 0 && !result) {
18836
17956
  if (i === ai) {
18837
17957
  begs.push(i);
18838
- ai = str.indexOf(a, i + 1);
17958
+ ai = str.indexOf(a3, i + 1);
18839
17959
  } else if (begs.length === 1) {
18840
17960
  const r2 = begs.pop();
18841
17961
  if (r2 !== void 0)
@@ -18918,11 +18038,11 @@ function embrace(str) {
18918
18038
  function isPadded(el) {
18919
18039
  return /^-?0\d/.test(el);
18920
18040
  }
18921
- function lte(i, y) {
18922
- return i <= y;
18041
+ function lte(i, y2) {
18042
+ return i <= y2;
18923
18043
  }
18924
- function gte(i, y) {
18925
- return i >= y;
18044
+ function gte(i, y2) {
18045
+ return i >= y2;
18926
18046
  }
18927
18047
  function expand_(str, isTop) {
18928
18048
  const expansions = [];
@@ -18962,19 +18082,19 @@ function expand_(str, isTop) {
18962
18082
  }
18963
18083
  let N;
18964
18084
  if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
18965
- const x = numeric(n[0]);
18966
- const y = numeric(n[1]);
18085
+ const x2 = numeric(n[0]);
18086
+ const y2 = numeric(n[1]);
18967
18087
  const width = Math.max(n[0].length, n[1].length);
18968
18088
  let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
18969
18089
  let test = lte;
18970
- const reverse = y < x;
18090
+ const reverse = y2 < x2;
18971
18091
  if (reverse) {
18972
18092
  incr *= -1;
18973
18093
  test = gte;
18974
18094
  }
18975
18095
  const pad = n.some(isPadded);
18976
18096
  N = [];
18977
- for (let i = x; test(i, y); i += incr) {
18097
+ for (let i = x2; test(i, y2); i += incr) {
18978
18098
  let c;
18979
18099
  if (isAlphaSequence) {
18980
18100
  c = String.fromCharCode(i);
@@ -18986,11 +18106,11 @@ function expand_(str, isTop) {
18986
18106
  if (pad) {
18987
18107
  const need = width - c.length;
18988
18108
  if (need > 0) {
18989
- const z = new Array(need + 1).join("0");
18109
+ const z2 = new Array(need + 1).join("0");
18990
18110
  if (i < 0) {
18991
- c = "-" + z + c.slice(1);
18111
+ c = "-" + z2 + c.slice(1);
18992
18112
  } else {
18993
- c = z + c;
18113
+ c = z2 + c;
18994
18114
  }
18995
18115
  }
18996
18116
  }
@@ -19707,7 +18827,7 @@ var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
19707
18827
  var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
19708
18828
  var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
19709
18829
  minimatch.filter = filter;
19710
- var ext = (a, b = {}) => Object.assign({}, a, b);
18830
+ var ext = (a3, b = {}) => Object.assign({}, a3, b);
19711
18831
  var defaults = (def) => {
19712
18832
  if (!def || typeof def !== "object" || !Object.keys(def).length) {
19713
18833
  return minimatch;
@@ -20064,30 +19184,30 @@ var Minimatch = class {
20064
19184
  }
20065
19185
  return globParts.filter((gs) => gs.length);
20066
19186
  }
20067
- partsMatch(a, b, emptyGSMatch = false) {
19187
+ partsMatch(a3, b, emptyGSMatch = false) {
20068
19188
  let ai = 0;
20069
19189
  let bi = 0;
20070
19190
  let result = [];
20071
19191
  let which = "";
20072
- while (ai < a.length && bi < b.length) {
20073
- if (a[ai] === b[bi]) {
20074
- result.push(which === "b" ? b[bi] : a[ai]);
19192
+ while (ai < a3.length && bi < b.length) {
19193
+ if (a3[ai] === b[bi]) {
19194
+ result.push(which === "b" ? b[bi] : a3[ai]);
20075
19195
  ai++;
20076
19196
  bi++;
20077
- } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
20078
- result.push(a[ai]);
19197
+ } else if (emptyGSMatch && a3[ai] === "**" && b[bi] === a3[ai + 1]) {
19198
+ result.push(a3[ai]);
20079
19199
  ai++;
20080
- } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
19200
+ } else if (emptyGSMatch && b[bi] === "**" && a3[ai] === b[bi + 1]) {
20081
19201
  result.push(b[bi]);
20082
19202
  bi++;
20083
- } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
19203
+ } else if (a3[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
20084
19204
  if (which === "b")
20085
19205
  return false;
20086
19206
  which = "a";
20087
- result.push(a[ai]);
19207
+ result.push(a3[ai]);
20088
19208
  ai++;
20089
19209
  bi++;
20090
- } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
19210
+ } else if (b[bi] === "*" && a3[ai] && (this.options.dot || !a3[ai].startsWith(".")) && a3[ai] !== "**") {
20091
19211
  if (which === "a")
20092
19212
  return false;
20093
19213
  which = "b";
@@ -20098,7 +19218,7 @@ var Minimatch = class {
20098
19218
  return false;
20099
19219
  }
20100
19220
  }
20101
- return a.length === b.length && result;
19221
+ return a3.length === b.length && result;
20102
19222
  }
20103
19223
  parseNegate() {
20104
19224
  if (this.nonegate)
@@ -20586,8 +19706,8 @@ var Minipass = class extends EventEmitter {
20586
19706
  * behavior. Ie, a sync stream can be made async, but an async stream
20587
19707
  * cannot be safely made sync.
20588
19708
  */
20589
- set ["async"](a) {
20590
- this[ASYNC] = this[ASYNC] || !!a;
19709
+ set ["async"](a3) {
19710
+ this[ASYNC] = this[ASYNC] || !!a3;
20591
19711
  }
20592
19712
  // drop everything and get out of the flow completely
20593
19713
  [ABORT]() {
@@ -21299,7 +20419,7 @@ var ENOREALPATH = 512;
21299
20419
  var ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
21300
20420
  var TYPEMASK = 1023;
21301
20421
  var entToType = (s) => s.isFile() ? IFREG : s.isDirectory() ? IFDIR : s.isSymbolicLink() ? IFLNK : s.isCharacterDevice() ? IFCHR : s.isBlockDevice() ? IFBLK : s.isSocket() ? IFSOCK : s.isFIFO() ? IFIFO : UNKNOWN;
21302
- var normalizeCache = new LRUCache({ max: 2 ** 12 });
20422
+ var normalizeCache = new L({ max: 2 ** 12 });
21303
20423
  var normalize2 = (s) => {
21304
20424
  const c = normalizeCache.get(s);
21305
20425
  if (c)
@@ -21308,7 +20428,7 @@ var normalize2 = (s) => {
21308
20428
  normalizeCache.set(s, n);
21309
20429
  return n;
21310
20430
  };
21311
- var normalizeNocaseCache = new LRUCache({ max: 2 ** 12 });
20431
+ var normalizeNocaseCache = new L({ max: 2 ** 12 });
21312
20432
  var normalizeNocase = (s) => {
21313
20433
  const c = normalizeNocaseCache.get(s);
21314
20434
  if (c)
@@ -21317,17 +20437,17 @@ var normalizeNocase = (s) => {
21317
20437
  normalizeNocaseCache.set(s, n);
21318
20438
  return n;
21319
20439
  };
21320
- var ResolveCache = class extends LRUCache {
20440
+ var ResolveCache = class extends L {
21321
20441
  constructor() {
21322
20442
  super({ max: 256 });
21323
20443
  }
21324
20444
  };
21325
- var ChildrenCache = class extends LRUCache {
20445
+ var ChildrenCache = class extends L {
21326
20446
  constructor(maxSize = 16 * 1024) {
21327
20447
  super({
21328
20448
  maxSize,
21329
20449
  // parent + children
21330
- sizeCalculation: (a) => a.length + 1
20450
+ sizeCalculation: (a3) => a3.length + 1
21331
20451
  });
21332
20452
  }
21333
20453
  };
@@ -24665,7 +23785,7 @@ var wrap = (fn) => async (path81, opt) => {
24665
23785
  path81 = await glob(path81, options.glob);
24666
23786
  }
24667
23787
  if (Array.isArray(path81)) {
24668
- return !!(await Promise.all(path81.map((p) => fn(path_arg_default(p, options), options)))).reduce((a, b) => a && b, true);
23788
+ return !!(await Promise.all(path81.map((p) => fn(path_arg_default(p, options), options)))).reduce((a3, b) => a3 && b, true);
24669
23789
  } else {
24670
23790
  return !!await fn(path_arg_default(path81, options), options);
24671
23791
  }
@@ -24676,7 +23796,7 @@ var wrapSync = (fn) => (path81, opt) => {
24676
23796
  path81 = globSync(path81, options.glob);
24677
23797
  }
24678
23798
  if (Array.isArray(path81)) {
24679
- return !!path81.map((p) => fn(path_arg_default(p, options), options)).reduce((a, b) => a && b, true);
23799
+ return !!path81.map((p) => fn(path_arg_default(p, options), options)).reduce((a3, b) => a3 && b, true);
24680
23800
  } else {
24681
23801
  return !!fn(path_arg_default(path81, options), options);
24682
23802
  }
@@ -28661,9 +27781,9 @@ function analyzeAppJson(json) {
28661
27781
  const entries = [];
28662
27782
  const pages = json.pages ?? [];
28663
27783
  const components = Object.values(get3(json, "usingComponents") ?? {});
28664
- const subPackages = [...json.subPackages ?? [], ...json.subpackages ?? []].filter((x) => !x.independent).reduce(
27784
+ const subPackages = [...json.subPackages ?? [], ...json.subpackages ?? []].filter((x2) => !x2.independent).reduce(
28665
27785
  (acc, cur) => {
28666
- acc.push(...(cur.pages ?? []).map((x) => `${cur.root}/${x}`));
27786
+ acc.push(...(cur.pages ?? []).map((x2) => `${cur.root}/${x2}`));
28667
27787
  if (cur.entry) {
28668
27788
  acc.push(`${cur.root}/${removeExtension(cur.entry)}`);
28669
27789
  }
@@ -31295,7 +30415,7 @@ async function cssPostProcess(code, options) {
31295
30415
  }
31296
30416
 
31297
30417
  // src/plugins/css/shared/preprocessor.ts
31298
- var cssCodeCache = new LRUCache({
30418
+ var cssCodeCache = new L({
31299
30419
  max: 512
31300
30420
  });
31301
30421
  var sharedStyleCache = /* @__PURE__ */ new Map();
@@ -32875,7 +31995,7 @@ import { defu as defu4 } from "@weapp-core/shared";
32875
31995
 
32876
31996
  // src/wxml/scan/cache.ts
32877
31997
  init_esm_shims();
32878
- var scanWxmlCache = new LRUCache(
31998
+ var scanWxmlCache = new L(
32879
31999
  {
32880
32000
  max: 512
32881
32001
  }
@@ -35557,7 +34677,7 @@ function parseWxml(options) {
35557
34677
  );
35558
34678
  parser.end();
35559
34679
  if (removalRanges.length > 1) {
35560
- removalRanges.sort((a, b) => b.start - a.start);
34680
+ removalRanges.sort((a3, b) => b.start - a3.start);
35561
34681
  }
35562
34682
  const token = {
35563
34683
  components,
@@ -36847,7 +35967,7 @@ init_esm_shims();
36847
35967
  import { removeExtension as removeExtension3 } from "@weapp-core/shared";
36848
35968
  import fs34 from "fs-extra";
36849
35969
  import path69 from "pathe";
36850
- var wxsCodeCache = new LRUCache({
35970
+ var wxsCodeCache = new L({
36851
35971
  max: 512
36852
35972
  });
36853
35973
  async function transformWxsFile(state, wxsPath) {
@@ -38233,9 +37353,9 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
38233
37353
  }
38234
37354
  if (keys.length > 0) {
38235
37355
  await Promise.all(
38236
- keys.map((x) => {
37356
+ keys.map((x2) => {
38237
37357
  return buildPackage({
38238
- dep: x,
37358
+ dep: x2,
38239
37359
  outDir,
38240
37360
  options,
38241
37361
  isDependenciesCacheOutdate
@@ -38269,9 +37389,9 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
38269
37389
  });
38270
37390
  if (keys.length > 0) {
38271
37391
  await Promise.all(
38272
- keys.filter((x) => isBuiltin(x)).map((x) => {
37392
+ keys.filter((x2) => isBuiltin(x2)).map((x2) => {
38273
37393
  return buildPackage({
38274
- dep: `${x}/`,
37394
+ dep: `${x2}/`,
38275
37395
  outDir,
38276
37396
  options,
38277
37397
  isDependenciesCacheOutdate
@@ -38451,49 +37571,49 @@ function createNpmService(ctx) {
38451
37571
  );
38452
37572
  await cache2.writeDependenciesCache();
38453
37573
  const targetDirs = [
38454
- ...subRelations.map((x) => {
37574
+ ...subRelations.map((x2) => {
38455
37575
  return {
38456
- npmDistDir: path75.resolve(ctx.configService.cwd, x.miniprogramNpmDistDir, npmDistDirName)
37576
+ npmDistDir: path75.resolve(ctx.configService.cwd, x2.miniprogramNpmDistDir, npmDistDirName)
38457
37577
  };
38458
37578
  }),
38459
- ...[...ctx.scanService.independentSubPackageMap.values()].map((x) => {
38460
- const dependencies2 = x.subPackage.dependencies;
37579
+ ...[...ctx.scanService.independentSubPackageMap.values()].map((x2) => {
37580
+ const dependencies2 = x2.subPackage.dependencies;
38461
37581
  return {
38462
- root: x.subPackage.root,
37582
+ root: x2.subPackage.root,
38463
37583
  dependencies: dependencies2,
38464
- npmDistDir: path75.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir, x.subPackage.root, npmDistDirName)
37584
+ npmDistDir: path75.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir, x2.subPackage.root, npmDistDirName)
38465
37585
  };
38466
37586
  })
38467
37587
  ];
38468
- await Promise.all(targetDirs.map(async (x) => {
38469
- if (x.root) {
38470
- const isDependenciesCacheOutdate2 = await cache2.checkDependenciesCacheOutdate(x.root);
38471
- if (isDependenciesCacheOutdate2 || !await fs38.pathExists(x.npmDistDir)) {
38472
- await fs38.copy(outDir, x.npmDistDir, {
37588
+ await Promise.all(targetDirs.map(async (x2) => {
37589
+ if (x2.root) {
37590
+ const isDependenciesCacheOutdate2 = await cache2.checkDependenciesCacheOutdate(x2.root);
37591
+ if (isDependenciesCacheOutdate2 || !await fs38.pathExists(x2.npmDistDir)) {
37592
+ await fs38.copy(outDir, x2.npmDistDir, {
38473
37593
  overwrite: true,
38474
37594
  filter: (src) => {
38475
- if (Array.isArray(x.dependencies)) {
37595
+ if (Array.isArray(x2.dependencies)) {
38476
37596
  const relPath = toPosixPath(path75.relative(outDir, src));
38477
37597
  if (relPath === "") {
38478
37598
  return true;
38479
37599
  }
38480
- return regExpTest(x.dependencies, relPath);
37600
+ return regExpTest(x2.dependencies, relPath);
38481
37601
  }
38482
37602
  return true;
38483
37603
  }
38484
37604
  });
38485
37605
  }
38486
- await cache2.writeDependenciesCache(x.root);
37606
+ await cache2.writeDependenciesCache(x2.root);
38487
37607
  } else {
38488
- await fs38.copy(outDir, x.npmDistDir, {
37608
+ await fs38.copy(outDir, x2.npmDistDir, {
38489
37609
  overwrite: true,
38490
37610
  filter: (src) => {
38491
- if (Array.isArray(x.dependencies)) {
37611
+ if (Array.isArray(x2.dependencies)) {
38492
37612
  const relPath = toPosixPath(path75.relative(outDir, src));
38493
37613
  if (relPath === "") {
38494
37614
  return true;
38495
37615
  }
38496
- return regExpTest(x.dependencies, relPath);
37616
+ return regExpTest(x2.dependencies, relPath);
38497
37617
  }
38498
37618
  return true;
38499
37619
  }
@@ -38652,7 +37772,7 @@ var PriorityQueue = class {
38652
37772
  this.#queue.push(element);
38653
37773
  return;
38654
37774
  }
38655
- const index = lowerBound(this.#queue, element, (a, b) => b.priority - a.priority);
37775
+ const index = lowerBound(this.#queue, element, (a3, b) => b.priority - a3.priority);
38656
37776
  this.#queue.splice(index, 0, element);
38657
37777
  }
38658
37778
  setPriority(id, priority) {
@@ -39381,7 +38501,7 @@ var FileCache = class {
39381
38501
  constructor(max = 1024) {
39382
38502
  this.mtimeMap = /* @__PURE__ */ new Map();
39383
38503
  this.signatureMap = /* @__PURE__ */ new Map();
39384
- this.cache = new LRUCache({
38504
+ this.cache = new L({
39385
38505
  max,
39386
38506
  dispose: (_value, key) => {
39387
38507
  this.mtimeMap.delete(key);
@@ -40384,11 +39504,11 @@ function createWxmlService(ctx) {
40384
39504
  cache2.set(filepath, res);
40385
39505
  await addDeps(
40386
39506
  filepath,
40387
- res.deps.filter((x) => isImportTag(x.tagName) && isTemplate(x.value)).map((x) => {
40388
- if (x.value.startsWith("/")) {
40389
- return path80.resolve(configService.absoluteSrcRoot, x.value.slice(1));
39507
+ res.deps.filter((x2) => isImportTag(x2.tagName) && isTemplate(x2.value)).map((x2) => {
39508
+ if (x2.value.startsWith("/")) {
39509
+ return path80.resolve(configService.absoluteSrcRoot, x2.value.slice(1));
40390
39510
  } else {
40391
- return path80.resolve(dirname5, x.value);
39511
+ return path80.resolve(dirname5, x2.value);
40392
39512
  }
40393
39513
  })
40394
39514
  );