@powerhousedao/shared 6.0.0-dev.130 → 6.0.0-dev.131

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.
@@ -76,9 +76,10 @@ const VERSIONED_DEPENDENCIES = [
76
76
  "document-model",
77
77
  "@powerhousedao/design-system",
78
78
  "@powerhousedao/reactor-browser",
79
- "@powerhousedao/connect"
79
+ "@powerhousedao/connect",
80
+ "@powerhousedao/analytics-engine-core"
80
81
  ];
81
- const VERSIONED_DEV_DEPENDENCIES = ["@powerhousedao/ph-cli", "@powerhousedao/analytics-engine-core"];
82
+ const VERSIONED_DEV_DEPENDENCIES = ["@powerhousedao/ph-cli"];
82
83
  const DEFAULT_CONFIG = {
83
84
  documentModelsDir: "./document-models",
84
85
  editorsDir: "./editors",
@@ -121,27 +122,6 @@ const buildArgs = {
121
122
  defaultValue: () => "dist",
122
123
  defaultValueIsSerializable: true
123
124
  }),
124
- clean: flag({
125
- type: boolean,
126
- long: "clean",
127
- description: "Erase the contents of the output dir when building",
128
- defaultValue: () => true,
129
- defaultValueIsSerializable: true
130
- }),
131
- dts: flag({
132
- type: boolean,
133
- long: "dts",
134
- description: "Generate type definitions for the bundled code",
135
- defaultValue: () => true,
136
- defaultValueIsSerializable: true
137
- }),
138
- sourcemap: flag({
139
- type: boolean,
140
- long: "sourcemap",
141
- description: "Generate a sourcemap for the bundled code",
142
- defaultValue: () => true,
143
- defaultValueIsSerializable: true
144
- }),
145
125
  ...debugArgs
146
126
  };
147
127
  const packageManagerArgs = {
@@ -4024,12 +4004,12 @@ var require_validate_npm_package_license = /* @__PURE__ */ __commonJSMin(((expor
4024
4004
  };
4025
4005
  }));
4026
4006
  //#endregion
4027
- //#region ../../node_modules/.pnpm/lru-cache@11.2.6/node_modules/lru-cache/dist/commonjs/index.min.js
4007
+ //#region ../../node_modules/.pnpm/lru-cache@11.2.7/node_modules/lru-cache/dist/commonjs/index.min.js
4028
4008
  var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4029
4009
  Object.defineProperty(exports, "__esModule", { value: !0 });
4030
4010
  exports.LRUCache = void 0;
4031
- var x = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, U = /* @__PURE__ */ new Set(), R = typeof process == "object" && process ? process : {}, I = (a, t, e, i) => {
4032
- typeof R.emitWarning == "function" ? R.emitWarning(a, t, e, i) : console.error(`[${e}] ${t}: ${a}`);
4011
+ var G = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, U = /* @__PURE__ */ new Set(), R = typeof process == "object" && process ? process : {}, I = (c, t, e, i) => {
4012
+ typeof R.emitWarning == "function" ? R.emitWarning(c, t, e, i) : console.error(`[${e}] ${t}: ${c}`);
4033
4013
  }, C = globalThis.AbortController, L = globalThis.AbortSignal;
4034
4014
  if (typeof C > "u") {
4035
4015
  L = class {
@@ -4053,27 +4033,27 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4053
4033
  }
4054
4034
  }
4055
4035
  };
4056
- let a = R.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
4057
- a && (a = !1, I("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
4036
+ let c = R.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
4037
+ c && (c = !1, I("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
4058
4038
  };
4059
4039
  }
4060
- var G = (a) => !U.has(a), y = (a) => a && a === Math.floor(a) && a > 0 && isFinite(a), M = (a) => y(a) ? a <= Math.pow(2, 8) ? Uint8Array : a <= Math.pow(2, 16) ? Uint16Array : a <= Math.pow(2, 32) ? Uint32Array : a <= Number.MAX_SAFE_INTEGER ? z : null : null, z = class extends Array {
4040
+ var x = (c) => !U.has(c), y = (c) => c && c === Math.floor(c) && c > 0 && isFinite(c), M = (c) => y(c) ? c <= Math.pow(2, 8) ? Uint8Array : c <= Math.pow(2, 16) ? Uint16Array : c <= Math.pow(2, 32) ? Uint32Array : c <= Number.MAX_SAFE_INTEGER ? z : null : null, z = class extends Array {
4061
4041
  constructor(t) {
4062
4042
  super(t), this.fill(0);
4063
4043
  }
4064
- }, W = class a {
4044
+ }, W = class c {
4065
4045
  heap;
4066
4046
  length;
4067
4047
  static #o = !1;
4068
4048
  static create(t) {
4069
4049
  let e = M(t);
4070
4050
  if (!e) return [];
4071
- a.#o = !0;
4072
- let i = new a(t, e);
4073
- return a.#o = !1, i;
4051
+ c.#o = !0;
4052
+ let i = new c(t, e);
4053
+ return c.#o = !1, i;
4074
4054
  }
4075
4055
  constructor(t, e) {
4076
- if (!a.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
4056
+ if (!c.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
4077
4057
  this.heap = new e(t), this.length = 0;
4078
4058
  }
4079
4059
  push(t) {
@@ -4083,7 +4063,7 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4083
4063
  return this.heap[--this.length];
4084
4064
  }
4085
4065
  };
4086
- exports.LRUCache = class a {
4066
+ exports.LRUCache = class c {
4087
4067
  #o;
4088
4068
  #c;
4089
4069
  #w;
@@ -4148,7 +4128,7 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4148
4128
  },
4149
4129
  free: t.#b,
4150
4130
  isBackgroundFetch: (e) => t.#e(e),
4151
- backgroundFetch: (e, i, s, h) => t.#G(e, i, s, h),
4131
+ backgroundFetch: (e, i, s, n) => t.#x(e, i, s, n),
4152
4132
  moveToTail: (e) => t.#D(e),
4153
4133
  indexes: (e) => t.#F(e),
4154
4134
  rindexes: (e) => t.#O(e),
@@ -4183,30 +4163,30 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4183
4163
  return this.#S;
4184
4164
  }
4185
4165
  constructor(t) {
4186
- let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: h, updateAgeOnGet: n, updateAgeOnHas: o, allowStale: r, 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 } = t;
4166
+ let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: r, dispose: a, onInsert: w, disposeAfter: f, noDisposeOnSet: d, noUpdateTTL: g, maxSize: A = 0, maxEntrySize: p = 0, sizeCalculation: _, fetchMethod: l, memoMethod: S, noDeleteOnFetchRejection: b, noDeleteOnStaleGet: m, allowStaleOnFetchRejection: u, allowStaleOnFetchAbort: T, ignoreFetchAbort: F, perf: v } = t;
4187
4167
  if (v !== void 0 && typeof v?.now != "function") throw new TypeError("perf option must have a now() method if specified");
4188
- if (this.#m = v ?? x, e !== 0 && !y(e)) throw new TypeError("max option must be a nonnegative integer");
4168
+ if (this.#m = v ?? G, e !== 0 && !y(e)) throw new TypeError("max option must be a nonnegative integer");
4189
4169
  let O = e ? M(e) : Array;
4190
4170
  if (!O) throw new Error("invalid max value: " + e);
4191
4171
  if (this.#o = e, this.#c = A, this.maxEntrySize = p || this.#c, this.sizeCalculation = _, this.sizeCalculation) {
4192
4172
  if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
4193
4173
  if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
4194
4174
  }
4195
- if (w !== void 0 && typeof w != "function") throw new TypeError("memoMethod must be a function if defined");
4196
- if (this.#U = w, l !== void 0 && typeof l != "function") throw new TypeError("fetchMethod must be a function if specified");
4197
- 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.#I = !!this.#C, this.#f = !!this.#S, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!g, this.noDeleteOnFetchRejection = !!b, this.allowStaleOnFetchRejection = !!u, this.allowStaleOnFetchAbort = !!T, this.ignoreFetchAbort = !!F, this.maxEntrySize !== 0) {
4175
+ if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
4176
+ if (this.#U = S, l !== void 0 && typeof l != "function") throw new TypeError("fetchMethod must be a function if specified");
4177
+ if (this.#L = l, this.#v = !!l, this.#s = /* @__PURE__ */ new Map(), this.#i = new Array(e).fill(void 0), this.#t = new Array(e).fill(void 0), this.#a = new O(e), this.#u = new O(e), this.#l = 0, this.#h = 0, this.#b = W.create(e), this.#n = 0, this.#_ = 0, typeof a == "function" && (this.#w = a), typeof w == "function" && (this.#C = w), typeof f == "function" ? (this.#S = f, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#w, this.#I = !!this.#C, this.#f = !!this.#S, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!g, this.noDeleteOnFetchRejection = !!b, this.allowStaleOnFetchRejection = !!u, this.allowStaleOnFetchAbort = !!T, this.ignoreFetchAbort = !!F, this.maxEntrySize !== 0) {
4198
4178
  if (this.#c !== 0 && !y(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
4199
4179
  if (!y(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
4200
4180
  this.#B();
4201
4181
  }
4202
- if (this.allowStale = !!r, 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) {
4182
+ if (this.allowStale = !!r, this.noDeleteOnStaleGet = !!m, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = y(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
4203
4183
  if (!y(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
4204
4184
  this.#j();
4205
4185
  }
4206
4186
  if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
4207
4187
  if (!this.ttlAutopurge && !this.#o && !this.#c) {
4208
4188
  let E = "LRU_CACHE_UNBOUNDED";
4209
- G(E) && (U.add(E), I("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, a));
4189
+ x(E) && (U.add(E), I("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, c));
4210
4190
  }
4211
4191
  }
4212
4192
  getRemainingTTL(t) {
@@ -4216,41 +4196,45 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4216
4196
  let t = new z(this.#o), e = new z(this.#o);
4217
4197
  this.#d = t, this.#A = e;
4218
4198
  let i = this.ttlAutopurge ? new Array(this.#o) : void 0;
4219
- this.#g = i, this.#N = (n, o, r = this.#m.now()) => {
4220
- if (e[n] = o !== 0 ? r : 0, t[n] = o, i?.[n] && (clearTimeout(i[n]), i[n] = void 0), o !== 0 && i) {
4221
- let f = setTimeout(() => {
4222
- this.#p(n) && this.#E(this.#i[n], "expire");
4223
- }, o + 1);
4224
- f.unref && f.unref(), i[n] = f;
4199
+ this.#g = i, this.#N = (h, r, a = this.#m.now()) => {
4200
+ e[h] = r !== 0 ? a : 0, t[h] = r, s(h, r);
4201
+ }, this.#R = (h) => {
4202
+ e[h] = t[h] !== 0 ? this.#m.now() : 0, s(h, t[h]);
4203
+ };
4204
+ let s = this.ttlAutopurge ? (h, r) => {
4205
+ if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), r && r !== 0 && i) {
4206
+ let a = setTimeout(() => {
4207
+ this.#p(h) && this.#E(this.#i[h], "expire");
4208
+ }, r + 1);
4209
+ a.unref && a.unref(), i[h] = a;
4225
4210
  }
4226
- }, this.#R = (n) => {
4227
- e[n] = t[n] !== 0 ? this.#m.now() : 0;
4228
- }, this.#z = (n, o) => {
4229
- if (t[o]) {
4230
- let r = t[o], f = e[o];
4231
- if (!r || !f) return;
4232
- n.ttl = r, n.start = f, n.now = s || h();
4233
- n.remainingTTL = r - (n.now - f);
4211
+ } : () => {};
4212
+ this.#z = (h, r) => {
4213
+ if (t[r]) {
4214
+ let a = t[r], w = e[r];
4215
+ if (!a || !w) return;
4216
+ h.ttl = a, h.start = w, h.now = n || o();
4217
+ h.remainingTTL = a - (h.now - w);
4234
4218
  }
4235
4219
  };
4236
- let s = 0, h = () => {
4237
- let n = this.#m.now();
4220
+ let n = 0, o = () => {
4221
+ let h = this.#m.now();
4238
4222
  if (this.ttlResolution > 0) {
4239
- s = n;
4240
- let o = setTimeout(() => s = 0, this.ttlResolution);
4241
- o.unref && o.unref();
4223
+ n = h;
4224
+ let r = setTimeout(() => n = 0, this.ttlResolution);
4225
+ r.unref && r.unref();
4242
4226
  }
4243
- return n;
4227
+ return h;
4244
4228
  };
4245
- this.getRemainingTTL = (n) => {
4246
- let o = this.#s.get(n);
4247
- if (o === void 0) return 0;
4248
- let r = t[o], f = e[o];
4249
- if (!r || !f) return Infinity;
4250
- return r - ((s || h()) - f);
4251
- }, this.#p = (n) => {
4252
- let o = e[n], r = t[n];
4253
- return !!r && !!o && (s || h()) - o > r;
4229
+ this.getRemainingTTL = (h) => {
4230
+ let r = this.#s.get(h);
4231
+ if (r === void 0) return 0;
4232
+ let a = t[r], w = e[r];
4233
+ if (!a || !w) return Infinity;
4234
+ return a - ((n || o()) - w);
4235
+ }, this.#p = (h) => {
4236
+ let r = e[h], a = t[h];
4237
+ return !!a && !!r && (n || o()) - r > a;
4254
4238
  };
4255
4239
  }
4256
4240
  #R = () => {};
@@ -4261,17 +4245,17 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4261
4245
  let t = new z(this.#o);
4262
4246
  this.#_ = 0, this.#y = t, this.#W = (e) => {
4263
4247
  this.#_ -= t[e], t[e] = 0;
4264
- }, this.#P = (e, i, s, h) => {
4248
+ }, this.#P = (e, i, s, n) => {
4265
4249
  if (this.#e(i)) return 0;
4266
- if (!y(s)) if (h) {
4267
- if (typeof h != "function") throw new TypeError("sizeCalculation must be a function");
4268
- if (s = h(i, e), !y(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
4250
+ if (!y(s)) if (n) {
4251
+ if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
4252
+ if (s = n(i, e), !y(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
4269
4253
  } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
4270
4254
  return s;
4271
4255
  }, this.#M = (e, i, s) => {
4272
4256
  if (t[e] = i, this.#c) {
4273
- let h = this.#c - t[e];
4274
- for (; this.#_ > h;) this.#x(!0);
4257
+ let n = this.#c - t[e];
4258
+ for (; this.#_ > n;) this.#G(!0);
4275
4259
  }
4276
4260
  this.#_ += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#_);
4277
4261
  };
@@ -4321,20 +4305,20 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4321
4305
  [Symbol.toStringTag] = "LRUCache";
4322
4306
  find(t, e = {}) {
4323
4307
  for (let i of this.#F()) {
4324
- let s = this.#t[i], h = this.#e(s) ? s.__staleWhileFetching : s;
4325
- if (h !== void 0 && t(h, this.#i[i], this)) return this.get(this.#i[i], e);
4308
+ let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4309
+ if (n !== void 0 && t(n, this.#i[i], this)) return this.get(this.#i[i], e);
4326
4310
  }
4327
4311
  }
4328
4312
  forEach(t, e = this) {
4329
4313
  for (let i of this.#F()) {
4330
- let s = this.#t[i], h = this.#e(s) ? s.__staleWhileFetching : s;
4331
- h !== void 0 && t.call(e, h, this.#i[i], this);
4314
+ let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4315
+ n !== void 0 && t.call(e, n, this.#i[i], this);
4332
4316
  }
4333
4317
  }
4334
4318
  rforEach(t, e = this) {
4335
4319
  for (let i of this.#O()) {
4336
- let s = this.#t[i], h = this.#e(s) ? s.__staleWhileFetching : s;
4337
- h !== void 0 && t.call(e, h, this.#i[i], this);
4320
+ let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4321
+ n !== void 0 && t.call(e, n, this.#i[i], this);
4338
4322
  }
4339
4323
  }
4340
4324
  purgeStale() {
@@ -4347,25 +4331,25 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4347
4331
  if (e === void 0) return;
4348
4332
  let i = this.#t[e], s = this.#e(i) ? i.__staleWhileFetching : i;
4349
4333
  if (s === void 0) return;
4350
- let h = { value: s };
4334
+ let n = { value: s };
4351
4335
  if (this.#d && this.#A) {
4352
- let n = this.#d[e], o = this.#A[e];
4353
- if (n && o) h.ttl = n - (this.#m.now() - o), h.start = Date.now();
4336
+ let o = this.#d[e], h = this.#A[e];
4337
+ if (o && h) n.ttl = o - (this.#m.now() - h), n.start = Date.now();
4354
4338
  }
4355
- return this.#y && (h.size = this.#y[e]), h;
4339
+ return this.#y && (n.size = this.#y[e]), n;
4356
4340
  }
4357
4341
  dump() {
4358
4342
  let t = [];
4359
4343
  for (let e of this.#F({ allowStale: !0 })) {
4360
- let i = this.#i[e], s = this.#t[e], h = this.#e(s) ? s.__staleWhileFetching : s;
4361
- if (h === void 0 || i === void 0) continue;
4362
- let n = { value: h };
4344
+ let i = this.#i[e], s = this.#t[e], n = this.#e(s) ? s.__staleWhileFetching : s;
4345
+ if (n === void 0 || i === void 0) continue;
4346
+ let o = { value: n };
4363
4347
  if (this.#d && this.#A) {
4364
- n.ttl = this.#d[e];
4365
- let o = this.#m.now() - this.#A[e];
4366
- n.start = Math.floor(Date.now() - o);
4348
+ o.ttl = this.#d[e];
4349
+ let h = this.#m.now() - this.#A[e];
4350
+ o.start = Math.floor(Date.now() - h);
4367
4351
  }
4368
- this.#y && (n.size = this.#y[e]), t.unshift([i, n]);
4352
+ this.#y && (o.size = this.#y[e]), t.unshift([i, o]);
4369
4353
  }
4370
4354
  return t;
4371
4355
  }
@@ -4381,28 +4365,28 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4381
4365
  }
4382
4366
  set(t, e, i = {}) {
4383
4367
  if (e === void 0) return this.delete(t), this;
4384
- let { ttl: s = this.ttl, start: h, noDisposeOnSet: n = this.noDisposeOnSet, sizeCalculation: o = this.sizeCalculation, status: r } = i, { noUpdateTTL: f = this.noUpdateTTL } = i, m = this.#P(t, e, i.size || 0, o);
4385
- if (this.maxEntrySize && m > this.maxEntrySize) return r && (r.set = "miss", r.maxEntrySizeExceeded = !0), this.#E(t, "set"), this;
4386
- let c = this.#n === 0 ? void 0 : this.#s.get(t);
4387
- if (c === void 0) c = this.#n === 0 ? this.#h : this.#b.length !== 0 ? this.#b.pop() : this.#n === this.#o ? this.#x(!1) : this.#n, this.#i[c] = t, this.#t[c] = e, this.#s.set(t, c), this.#a[this.#h] = c, this.#u[c] = this.#h, this.#h = c, this.#n++, this.#M(c, m, r), r && (r.set = "add"), f = !1, this.#I && this.#C?.(e, t, "add");
4368
+ let { ttl: s = this.ttl, start: n, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: r } = i, { noUpdateTTL: a = this.noUpdateTTL } = i, w = this.#P(t, e, i.size || 0, h);
4369
+ if (this.maxEntrySize && w > this.maxEntrySize) return r && (r.set = "miss", r.maxEntrySizeExceeded = !0), this.#E(t, "set"), this;
4370
+ let f = this.#n === 0 ? void 0 : this.#s.get(t);
4371
+ if (f === void 0) f = this.#n === 0 ? this.#h : this.#b.length !== 0 ? this.#b.pop() : this.#n === this.#o ? this.#G(!1) : this.#n, this.#i[f] = t, this.#t[f] = e, this.#s.set(t, f), this.#a[this.#h] = f, this.#u[f] = this.#h, this.#h = f, this.#n++, this.#M(f, w, r), r && (r.set = "add"), a = !1, this.#I && this.#C?.(e, t, "add");
4388
4372
  else {
4389
- this.#D(c);
4390
- let d = this.#t[c];
4373
+ this.#D(f);
4374
+ let d = this.#t[f];
4391
4375
  if (e !== d) {
4392
4376
  if (this.#v && this.#e(d)) {
4393
4377
  d.__abortController.abort(/* @__PURE__ */ new Error("replaced"));
4394
4378
  let { __staleWhileFetching: g } = d;
4395
- g !== void 0 && !n && (this.#T && this.#w?.(g, t, "set"), this.#f && this.#r?.push([
4379
+ g !== void 0 && !o && (this.#T && this.#w?.(g, t, "set"), this.#f && this.#r?.push([
4396
4380
  g,
4397
4381
  t,
4398
4382
  "set"
4399
4383
  ]));
4400
- } else n || (this.#T && this.#w?.(d, t, "set"), this.#f && this.#r?.push([
4384
+ } else o || (this.#T && this.#w?.(d, t, "set"), this.#f && this.#r?.push([
4401
4385
  d,
4402
4386
  t,
4403
4387
  "set"
4404
4388
  ]));
4405
- if (this.#W(c), this.#M(c, m, r), this.#t[c] = e, r) {
4389
+ if (this.#W(f), this.#M(f, w, r), this.#t[f] = e, r) {
4406
4390
  r.set = "replace";
4407
4391
  let g = d && this.#e(d) ? d.__staleWhileFetching : d;
4408
4392
  g !== void 0 && (r.oldValue = g);
@@ -4410,7 +4394,7 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4410
4394
  } else r && (r.set = "update");
4411
4395
  this.#I && this.onInsert?.(e, t, e === d ? "update" : "replace");
4412
4396
  }
4413
- if (s !== 0 && !this.#d && this.#j(), this.#d && (f || this.#N(c, s, h), r && this.#z(r, c)), !n && this.#f && this.#r) {
4397
+ if (s !== 0 && !this.#d && this.#j(), this.#d && (a || this.#N(f, s, n), r && this.#z(r, f)), !o && this.#f && this.#r) {
4414
4398
  let d = this.#r, g;
4415
4399
  for (; g = d?.shift();) this.#S?.(...g);
4416
4400
  }
@@ -4420,7 +4404,7 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4420
4404
  try {
4421
4405
  for (; this.#n;) {
4422
4406
  let t = this.#t[this.#l];
4423
- if (this.#x(!0), this.#e(t)) {
4407
+ if (this.#G(!0), this.#e(t)) {
4424
4408
  if (t.__staleWhileFetching) return t.__staleWhileFetching;
4425
4409
  } else if (t !== void 0) return t;
4426
4410
  }
@@ -4431,7 +4415,7 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4431
4415
  }
4432
4416
  }
4433
4417
  }
4434
- #x(t) {
4418
+ #G(t) {
4435
4419
  let e = this.#l, i = this.#i[e], s = this.#t[e];
4436
4420
  return this.#v && this.#e(s) ? s.__abortController.abort(/* @__PURE__ */ new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#w?.(s, i, "evict"), this.#f && this.#r?.push([
4437
4421
  s,
@@ -4440,49 +4424,49 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4440
4424
  ])), this.#W(e), this.#g?.[e] && (clearTimeout(this.#g[e]), this.#g[e] = void 0), t && (this.#i[e] = void 0, this.#t[e] = void 0, this.#b.push(e)), this.#n === 1 ? (this.#l = this.#h = 0, this.#b.length = 0) : this.#l = this.#a[e], this.#s.delete(i), this.#n--, e;
4441
4425
  }
4442
4426
  has(t, e = {}) {
4443
- let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, h = this.#s.get(t);
4444
- if (h !== void 0) {
4445
- let n = this.#t[h];
4446
- if (this.#e(n) && n.__staleWhileFetching === void 0) return !1;
4447
- if (this.#p(h)) s && (s.has = "stale", this.#z(s, h));
4448
- else return i && this.#R(h), s && (s.has = "hit", this.#z(s, h)), !0;
4427
+ let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, n = this.#s.get(t);
4428
+ if (n !== void 0) {
4429
+ let o = this.#t[n];
4430
+ if (this.#e(o) && o.__staleWhileFetching === void 0) return !1;
4431
+ if (this.#p(n)) s && (s.has = "stale", this.#z(s, n));
4432
+ else return i && this.#R(n), s && (s.has = "hit", this.#z(s, n)), !0;
4449
4433
  } else s && (s.has = "miss");
4450
4434
  return !1;
4451
4435
  }
4452
4436
  peek(t, e = {}) {
4453
4437
  let { allowStale: i = this.allowStale } = e, s = this.#s.get(t);
4454
4438
  if (s === void 0 || !i && this.#p(s)) return;
4455
- let h = this.#t[s];
4456
- return this.#e(h) ? h.__staleWhileFetching : h;
4457
- }
4458
- #G(t, e, i, s) {
4459
- let h = e === void 0 ? void 0 : this.#t[e];
4460
- if (this.#e(h)) return h;
4461
- let n = new C(), { signal: o } = i;
4462
- o?.addEventListener("abort", () => n.abort(o.reason), { signal: n.signal });
4439
+ let n = this.#t[s];
4440
+ return this.#e(n) ? n.__staleWhileFetching : n;
4441
+ }
4442
+ #x(t, e, i, s) {
4443
+ let n = e === void 0 ? void 0 : this.#t[e];
4444
+ if (this.#e(n)) return n;
4445
+ let o = new C(), { signal: h } = i;
4446
+ h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
4463
4447
  let r = {
4464
- signal: n.signal,
4448
+ signal: o.signal,
4465
4449
  options: i,
4466
4450
  context: s
4467
- }, f = (p, _ = !1) => {
4468
- let { aborted: l } = n.signal, w = i.ignoreFetchAbort && p !== void 0, b = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && p !== void 0);
4469
- if (i.status && (l && !_ ? (i.status.fetchAborted = !0, i.status.fetchError = n.signal.reason, w && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), l && !w && !_) return c(n.signal.reason, b);
4470
- let S = g, u = this.#t[e];
4471
- return (u === g || w && _ && u === void 0) && (p === void 0 ? S.__staleWhileFetching !== void 0 ? this.#t[e] = S.__staleWhileFetching : this.#E(t, "fetch") : (i.status && (i.status.fetchUpdated = !0), this.set(t, p, r.options))), p;
4472
- }, m = (p) => (i.status && (i.status.fetchRejected = !0, i.status.fetchError = p), c(p, !1)), c = (p, _) => {
4473
- let { aborted: l } = n.signal, w = l && i.allowStaleOnFetchAbort, b = w || i.allowStaleOnFetchRejection, S = b || i.noDeleteOnFetchRejection, u = g;
4474
- if (this.#t[e] === g && (!S || !_ && u.__staleWhileFetching === void 0 ? this.#E(t, "fetch") : w || (this.#t[e] = u.__staleWhileFetching)), b) return i.status && u.__staleWhileFetching !== void 0 && (i.status.returnedStale = !0), u.__staleWhileFetching;
4451
+ }, a = (p, _ = !1) => {
4452
+ let { aborted: l } = o.signal, S = i.ignoreFetchAbort && p !== void 0, b = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && p !== void 0);
4453
+ if (i.status && (l && !_ ? (i.status.fetchAborted = !0, i.status.fetchError = o.signal.reason, S && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), l && !S && !_) return f(o.signal.reason, b);
4454
+ let m = g, u = this.#t[e];
4455
+ return (u === g || S && _ && u === void 0) && (p === void 0 ? m.__staleWhileFetching !== void 0 ? this.#t[e] = m.__staleWhileFetching : this.#E(t, "fetch") : (i.status && (i.status.fetchUpdated = !0), this.set(t, p, r.options))), p;
4456
+ }, w = (p) => (i.status && (i.status.fetchRejected = !0, i.status.fetchError = p), f(p, !1)), f = (p, _) => {
4457
+ let { aborted: l } = o.signal, S = l && i.allowStaleOnFetchAbort, b = S || i.allowStaleOnFetchRejection, m = b || i.noDeleteOnFetchRejection, u = g;
4458
+ if (this.#t[e] === g && (!m || !_ && u.__staleWhileFetching === void 0 ? this.#E(t, "fetch") : S || (this.#t[e] = u.__staleWhileFetching)), b) return i.status && u.__staleWhileFetching !== void 0 && (i.status.returnedStale = !0), u.__staleWhileFetching;
4475
4459
  if (u.__returned === u) throw p;
4476
4460
  }, d = (p, _) => {
4477
- let l = this.#L?.(t, h, r);
4478
- l && l instanceof Promise && l.then((w) => p(w === void 0 ? void 0 : w), _), n.signal.addEventListener("abort", () => {
4479
- (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (p(void 0), i.allowStaleOnFetchAbort && (p = (w) => f(w, !0)));
4461
+ let l = this.#L?.(t, n, r);
4462
+ l && l instanceof Promise && l.then((S) => p(S === void 0 ? void 0 : S), _), o.signal.addEventListener("abort", () => {
4463
+ (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (p(void 0), i.allowStaleOnFetchAbort && (p = (S) => a(S, !0)));
4480
4464
  });
4481
4465
  };
4482
4466
  i.status && (i.status.fetchDispatched = !0);
4483
- let g = new Promise(d).then(f, m), A = Object.assign(g, {
4484
- __abortController: n,
4485
- __staleWhileFetching: h,
4467
+ let g = new Promise(d).then(a, w), A = Object.assign(g, {
4468
+ __abortController: o,
4469
+ __staleWhileFetching: n,
4486
4470
  __returned: void 0
4487
4471
  });
4488
4472
  return e === void 0 ? (this.set(t, A, {
@@ -4496,42 +4480,42 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4496
4480
  return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof C;
4497
4481
  }
4498
4482
  async fetch(t, e = {}) {
4499
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: h = this.noDeleteOnStaleGet, ttl: n = this.ttl, noDisposeOnSet: o = this.noDisposeOnSet, size: r = 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: _ = !1, status: l, signal: w } = e;
4483
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: r = 0, sizeCalculation: a = this.sizeCalculation, noUpdateTTL: w = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: g = this.ignoreFetchAbort, allowStaleOnFetchAbort: A = this.allowStaleOnFetchAbort, context: p, forceRefresh: _ = !1, status: l, signal: S } = e;
4500
4484
  if (!this.#v) return l && (l.fetch = "get"), this.get(t, {
4501
4485
  allowStale: i,
4502
4486
  updateAgeOnGet: s,
4503
- noDeleteOnStaleGet: h,
4487
+ noDeleteOnStaleGet: n,
4504
4488
  status: l
4505
4489
  });
4506
4490
  let b = {
4507
4491
  allowStale: i,
4508
4492
  updateAgeOnGet: s,
4509
- noDeleteOnStaleGet: h,
4510
- ttl: n,
4511
- noDisposeOnSet: o,
4493
+ noDeleteOnStaleGet: n,
4494
+ ttl: o,
4495
+ noDisposeOnSet: h,
4512
4496
  size: r,
4513
- sizeCalculation: f,
4514
- noUpdateTTL: m,
4515
- noDeleteOnFetchRejection: c,
4497
+ sizeCalculation: a,
4498
+ noUpdateTTL: w,
4499
+ noDeleteOnFetchRejection: f,
4516
4500
  allowStaleOnFetchRejection: d,
4517
4501
  allowStaleOnFetchAbort: A,
4518
4502
  ignoreFetchAbort: g,
4519
4503
  status: l,
4520
- signal: w
4521
- }, S = this.#s.get(t);
4522
- if (S === void 0) {
4504
+ signal: S
4505
+ }, m = this.#s.get(t);
4506
+ if (m === void 0) {
4523
4507
  l && (l.fetch = "miss");
4524
- let u = this.#G(t, S, b, p);
4508
+ let u = this.#x(t, m, b, p);
4525
4509
  return u.__returned = u;
4526
4510
  } else {
4527
- let u = this.#t[S];
4511
+ let u = this.#t[m];
4528
4512
  if (this.#e(u)) {
4529
4513
  let E = i && u.__staleWhileFetching !== void 0;
4530
4514
  return l && (l.fetch = "inflight", E && (l.returnedStale = !0)), E ? u.__staleWhileFetching : u.__returned = u;
4531
4515
  }
4532
- let T = this.#p(S);
4533
- if (!_ && !T) return l && (l.fetch = "hit"), this.#D(S), s && this.#R(S), l && this.#z(l, S), u;
4534
- let F = this.#G(t, S, b, p), O = F.__staleWhileFetching !== void 0 && i;
4516
+ let T = this.#p(m);
4517
+ if (!_ && !T) return l && (l.fetch = "hit"), this.#D(m), s && this.#R(m), l && this.#z(l, m), u;
4518
+ let F = this.#x(t, m, b, p), O = F.__staleWhileFetching !== void 0 && i;
4535
4519
  return l && (l.fetch = T ? "stale" : "refresh", O && T && (l.returnedStale = !0)), O ? F.__staleWhileFetching : F.__returned = F;
4536
4520
  }
4537
4521
  }
@@ -4543,20 +4527,20 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4543
4527
  memo(t, e = {}) {
4544
4528
  let i = this.#U;
4545
4529
  if (!i) throw new Error("no memoMethod provided to constructor");
4546
- let { context: s, forceRefresh: h, ...n } = e, o = this.get(t, n);
4547
- if (!h && o !== void 0) return o;
4548
- let r = i(t, o, {
4549
- options: n,
4530
+ let { context: s, forceRefresh: n, ...o } = e, h = this.get(t, o);
4531
+ if (!n && h !== void 0) return h;
4532
+ let r = i(t, h, {
4533
+ options: o,
4550
4534
  context: s
4551
4535
  });
4552
- return this.set(t, r, n), r;
4536
+ return this.set(t, r, o), r;
4553
4537
  }
4554
4538
  get(t, e = {}) {
4555
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: h = this.noDeleteOnStaleGet, status: n } = e, o = this.#s.get(t);
4556
- if (o !== void 0) {
4557
- let r = this.#t[o], f = this.#e(r);
4558
- return n && this.#z(n, o), this.#p(o) ? (n && (n.get = "stale"), f ? (n && i && r.__staleWhileFetching !== void 0 && (n.returnedStale = !0), i ? r.__staleWhileFetching : void 0) : (h || this.#E(t, "expire"), n && i && (n.returnedStale = !0), i ? r : void 0)) : (n && (n.get = "hit"), f ? r.__staleWhileFetching : (this.#D(o), s && this.#R(o), r));
4559
- } else n && (n.get = "miss");
4539
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, h = this.#s.get(t);
4540
+ if (h !== void 0) {
4541
+ let r = this.#t[h], a = this.#e(r);
4542
+ return o && this.#z(o, h), this.#p(h) ? (o && (o.get = "stale"), a ? (o && i && r.__staleWhileFetching !== void 0 && (o.returnedStale = !0), i ? r.__staleWhileFetching : void 0) : (n || this.#E(t, "expire"), o && i && (o.returnedStale = !0), i ? r : void 0)) : (o && (o.get = "hit"), a ? r.__staleWhileFetching : (this.#D(h), s && this.#R(h), r));
4543
+ } else o && (o.get = "miss");
4560
4544
  }
4561
4545
  #k(t, e) {
4562
4546
  this.#u[e] = t, this.#a[t] = e;
@@ -4574,25 +4558,25 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4574
4558
  if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = !0, this.#n === 1) this.#V(e);
4575
4559
  else {
4576
4560
  this.#W(s);
4577
- let h = this.#t[s];
4578
- if (this.#e(h) ? h.__abortController.abort(/* @__PURE__ */ new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(h, t, e), this.#f && this.#r?.push([
4579
- h,
4561
+ let n = this.#t[s];
4562
+ if (this.#e(n) ? n.__abortController.abort(/* @__PURE__ */ new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, t, e), this.#f && this.#r?.push([
4563
+ n,
4580
4564
  t,
4581
4565
  e
4582
4566
  ])), this.#s.delete(t), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
4583
4567
  else if (s === this.#l) this.#l = this.#a[s];
4584
4568
  else {
4585
- let n = this.#u[s];
4586
- this.#a[n] = this.#a[s];
4587
- let o = this.#a[s];
4588
- this.#u[o] = this.#u[s];
4569
+ let o = this.#u[s];
4570
+ this.#a[o] = this.#a[s];
4571
+ let h = this.#a[s];
4572
+ this.#u[h] = this.#u[s];
4589
4573
  }
4590
4574
  this.#n--, this.#b.push(s);
4591
4575
  }
4592
4576
  }
4593
4577
  if (this.#f && this.#r?.length) {
4594
- let s = this.#r, h;
4595
- for (; h = s?.shift();) this.#S?.(...h);
4578
+ let s = this.#r, n;
4579
+ for (; n = s?.shift();) this.#S?.(...n);
4596
4580
  }
4597
4581
  return i;
4598
4582
  }