xframelib 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -189
- package/dist/assets/worker-iconv-KS7y7NCM.js +5405 -0
- package/dist/assets/worker-webcache-C22MEJ3V.js +956 -0
- package/dist/assets/worker-xmath-CbuRtVJ1.js +450 -0
- package/dist/controls/ADivider.vue.d.ts +8 -12
- package/dist/controls/ScaleContainer/index.vue.d.ts +13 -0
- package/dist/controls/ScrollSnapContainer/index.vue.d.ts +25 -0
- package/dist/controls/index.d.ts +4 -1
- package/dist/controls/layoutcontainer/LayoutManager.d.ts +8 -2
- package/dist/controls/layoutcontainer/layout.vue.d.ts +22 -35
- package/dist/controls/popover/index.vue.d.ts +33 -0
- package/dist/controls/routertransition/RouterTransition.vue.d.ts +2 -1
- package/dist/controls/routertransition/RouterTransitionAnimate.vue.d.ts +2 -1
- package/dist/controls/routertransition/SuspenseWithError.vue.d.ts +3 -2
- package/dist/controls/splitpanes/pane.vue.d.ts +3 -2
- package/dist/controls/splitpanes/splitpanes.vue.d.ts +3 -2
- package/dist/controls/xwindow/XWindow.vue.d.ts +10 -19
- package/dist/controls/xwindow/XWindowManager.d.ts +3 -3
- package/dist/controls/xwindow/index.d.ts +2 -2
- package/dist/directives/dbClickDirective.d.ts +5 -0
- package/dist/directives/index.d.ts +5 -2
- package/dist/directives/mediaDirective.d.ts +7 -0
- package/dist/index.css +1 -408
- package/dist/index.js +1 -12
- package/dist/utils/H5Tool.d.ts +18 -7
- package/dist/utils/IsTool.d.ts +4 -0
- package/dist/utils/Screen.d.ts +30 -0
- package/dist/utils/WebCacheTool.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/workers/index.d.ts +3 -9
- package/package.json +25 -23
- package/dist/assets/worker-iconv-BsNle8M5.js +0 -22
- package/dist/assets/worker-webcache-CkCFZE0-.js +0 -6
- package/dist/assets/worker-xmath-AxRk6MsK.js +0 -6
- /package/dist/directives/{repeatClick.d.ts → repeatClickDirective.d.ts} +0 -0
|
@@ -0,0 +1,956 @@
|
|
|
1
|
+
var t = Object.defineProperty;
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2019 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/ const e = Symbol("Comlink.proxy"), i = Symbol("Comlink.endpoint"), s = Symbol("Comlink.releaseProxy"), n = Symbol("Comlink.finalizer"), h = Symbol("Comlink.thrown"), r = (t) => "object" == typeof t && null !== t || "function" == typeof t, o = new Map([["proxy", {
|
|
7
|
+
canHandle: (t) => r(t) && t[e],
|
|
8
|
+
serialize(t) {
|
|
9
|
+
const { port1: e, port2: i } = new MessageChannel();
|
|
10
|
+
return a(t, e), [i, [i]];
|
|
11
|
+
},
|
|
12
|
+
deserialize: (t) => (t.start(), function(t) {
|
|
13
|
+
const e = /* @__PURE__ */ new Map();
|
|
14
|
+
return t.addEventListener("message", (function(t) {
|
|
15
|
+
const { data: i } = t;
|
|
16
|
+
if (!i || !i.id) return;
|
|
17
|
+
const s = e.get(i.id);
|
|
18
|
+
if (s) try {
|
|
19
|
+
s(i);
|
|
20
|
+
} finally {
|
|
21
|
+
e.delete(i.id);
|
|
22
|
+
}
|
|
23
|
+
})), p(t, e, [], void 0);
|
|
24
|
+
}(t))
|
|
25
|
+
}], ["throw", {
|
|
26
|
+
canHandle: (t) => r(t) && h in t,
|
|
27
|
+
serialize({ value: t }) {
|
|
28
|
+
let e;
|
|
29
|
+
return e = t instanceof Error ? {
|
|
30
|
+
isError: !0,
|
|
31
|
+
value: {
|
|
32
|
+
message: t.message,
|
|
33
|
+
name: t.name,
|
|
34
|
+
stack: t.stack
|
|
35
|
+
}
|
|
36
|
+
} : {
|
|
37
|
+
isError: !1,
|
|
38
|
+
value: t
|
|
39
|
+
}, [e, []];
|
|
40
|
+
},
|
|
41
|
+
deserialize(t) {
|
|
42
|
+
if (t.isError) throw Object.assign(new Error(t.value.message), t.value);
|
|
43
|
+
throw t.value;
|
|
44
|
+
}
|
|
45
|
+
}]]);
|
|
46
|
+
function a(t, i = globalThis, s = ["*"]) {
|
|
47
|
+
i.addEventListener("message", (function r(o) {
|
|
48
|
+
if (!o || !o.data) return;
|
|
49
|
+
if (!function(t, e) {
|
|
50
|
+
for (const i of t) {
|
|
51
|
+
if (e === i || "*" === i) return !0;
|
|
52
|
+
if (i instanceof RegExp && i.test(e)) return !0;
|
|
53
|
+
}
|
|
54
|
+
return !1;
|
|
55
|
+
}(s, o.origin)) return void console.warn(`Invalid origin '${o.origin}' for comlink proxy`);
|
|
56
|
+
const { id: c, type: u, path: f } = Object.assign({ path: [] }, o.data), d = (o.data.argumentList || []).map(w);
|
|
57
|
+
let p;
|
|
58
|
+
try {
|
|
59
|
+
const i = f.slice(0, -1).reduce(((t, e) => t[e]), t), s = f.reduce(((t, e) => t[e]), t);
|
|
60
|
+
switch (u) {
|
|
61
|
+
case "GET":
|
|
62
|
+
p = s;
|
|
63
|
+
break;
|
|
64
|
+
case "SET":
|
|
65
|
+
i[f.slice(-1)[0]] = w(o.data.value), p = !0;
|
|
66
|
+
break;
|
|
67
|
+
case "APPLY":
|
|
68
|
+
p = s.apply(i, d);
|
|
69
|
+
break;
|
|
70
|
+
case "CONSTRUCT":
|
|
71
|
+
p = function(t) {
|
|
72
|
+
return Object.assign(t, { [e]: !0 });
|
|
73
|
+
}(new s(...d));
|
|
74
|
+
break;
|
|
75
|
+
case "ENDPOINT":
|
|
76
|
+
{
|
|
77
|
+
const { port1: e, port2: i } = new MessageChannel();
|
|
78
|
+
a(t, i), p = function(t, e) {
|
|
79
|
+
return v.set(t, e), t;
|
|
80
|
+
}(e, [e]);
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "RELEASE":
|
|
84
|
+
p = void 0;
|
|
85
|
+
break;
|
|
86
|
+
default: return;
|
|
87
|
+
}
|
|
88
|
+
} catch (t) {
|
|
89
|
+
p = {
|
|
90
|
+
value: t,
|
|
91
|
+
[h]: 0
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
Promise.resolve(p).catch(((t) => ({
|
|
95
|
+
value: t,
|
|
96
|
+
[h]: 0
|
|
97
|
+
}))).then(((e) => {
|
|
98
|
+
const [s, h] = m(e);
|
|
99
|
+
i.postMessage(Object.assign(Object.assign({}, s), { id: c }), h), "RELEASE" === u && (i.removeEventListener("message", r), l(i), n in t && "function" == typeof t[n] && t[n]());
|
|
100
|
+
})).catch(((t) => {
|
|
101
|
+
const [e, s] = m({
|
|
102
|
+
value: /* @__PURE__ */ new TypeError("Unserializable return value"),
|
|
103
|
+
[h]: 0
|
|
104
|
+
});
|
|
105
|
+
i.postMessage(Object.assign(Object.assign({}, e), { id: c }), s);
|
|
106
|
+
}));
|
|
107
|
+
})), i.start && i.start();
|
|
108
|
+
}
|
|
109
|
+
function l(t) {
|
|
110
|
+
(function(t) {
|
|
111
|
+
return "MessagePort" === t.constructor.name;
|
|
112
|
+
})(t) && t.close();
|
|
113
|
+
}
|
|
114
|
+
function c(t) {
|
|
115
|
+
if (t) throw new Error("Proxy has been released and is not useable");
|
|
116
|
+
}
|
|
117
|
+
function u(t) {
|
|
118
|
+
return y(t, /* @__PURE__ */ new Map(), { type: "RELEASE" }).then((() => {
|
|
119
|
+
l(t);
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
const f = /* @__PURE__ */ new WeakMap(), d = "FinalizationRegistry" in globalThis && new FinalizationRegistry(((t) => {
|
|
123
|
+
const e = (f.get(t) || 0) - 1;
|
|
124
|
+
f.set(t, e), 0 === e && u(t);
|
|
125
|
+
}));
|
|
126
|
+
function p(t, e, n = [], h = function() {}) {
|
|
127
|
+
let r = !1;
|
|
128
|
+
const o = new Proxy(h, {
|
|
129
|
+
get(i, h) {
|
|
130
|
+
if (c(r), h === s) return () => {
|
|
131
|
+
(function(t) {
|
|
132
|
+
d && d.unregister(t);
|
|
133
|
+
})(o), u(t), e.clear(), r = !0;
|
|
134
|
+
};
|
|
135
|
+
if ("then" === h) {
|
|
136
|
+
if (0 === n.length) return { then: () => o };
|
|
137
|
+
const i = y(t, e, {
|
|
138
|
+
type: "GET",
|
|
139
|
+
path: n.map(((t) => t.toString()))
|
|
140
|
+
}).then(w);
|
|
141
|
+
return i.then.bind(i);
|
|
142
|
+
}
|
|
143
|
+
return p(t, e, [...n, h]);
|
|
144
|
+
},
|
|
145
|
+
set(i, s, h) {
|
|
146
|
+
c(r);
|
|
147
|
+
const [o, a] = m(h);
|
|
148
|
+
return y(t, e, {
|
|
149
|
+
type: "SET",
|
|
150
|
+
path: [...n, s].map(((t) => t.toString())),
|
|
151
|
+
value: o
|
|
152
|
+
}, a).then(w);
|
|
153
|
+
},
|
|
154
|
+
apply(s, h, o) {
|
|
155
|
+
c(r);
|
|
156
|
+
const a = n[n.length - 1];
|
|
157
|
+
if (a === i) return y(t, e, { type: "ENDPOINT" }).then(w);
|
|
158
|
+
if ("bind" === a) return p(t, e, n.slice(0, -1));
|
|
159
|
+
const [l, u] = g(o);
|
|
160
|
+
return y(t, e, {
|
|
161
|
+
type: "APPLY",
|
|
162
|
+
path: n.map(((t) => t.toString())),
|
|
163
|
+
argumentList: l
|
|
164
|
+
}, u).then(w);
|
|
165
|
+
},
|
|
166
|
+
construct(i, s) {
|
|
167
|
+
c(r);
|
|
168
|
+
const [h, o] = g(s);
|
|
169
|
+
return y(t, e, {
|
|
170
|
+
type: "CONSTRUCT",
|
|
171
|
+
path: n.map(((t) => t.toString())),
|
|
172
|
+
argumentList: h
|
|
173
|
+
}, o).then(w);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return function(t, e) {
|
|
177
|
+
const i = (f.get(e) || 0) + 1;
|
|
178
|
+
f.set(e, i), d && d.register(t, e, t);
|
|
179
|
+
}(o, t), o;
|
|
180
|
+
}
|
|
181
|
+
function g(t) {
|
|
182
|
+
const e = t.map(m);
|
|
183
|
+
return [e.map(((t) => t[0])), (i = e.map(((t) => t[1])), Array.prototype.concat.apply([], i))];
|
|
184
|
+
var i;
|
|
185
|
+
}
|
|
186
|
+
const v = /* @__PURE__ */ new WeakMap();
|
|
187
|
+
function m(t) {
|
|
188
|
+
for (const [e, i] of o) if (i.canHandle(t)) {
|
|
189
|
+
const [s, n] = i.serialize(t);
|
|
190
|
+
return [{
|
|
191
|
+
type: "HANDLER",
|
|
192
|
+
name: e,
|
|
193
|
+
value: s
|
|
194
|
+
}, n];
|
|
195
|
+
}
|
|
196
|
+
return [{
|
|
197
|
+
type: "RAW",
|
|
198
|
+
value: t
|
|
199
|
+
}, v.get(t) || []];
|
|
200
|
+
}
|
|
201
|
+
function w(t) {
|
|
202
|
+
switch (t.type) {
|
|
203
|
+
case "HANDLER": return o.get(t.name).deserialize(t.value);
|
|
204
|
+
case "RAW": return t.value;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function y(t, e, i, s) {
|
|
208
|
+
return new Promise(((n) => {
|
|
209
|
+
const h = new Array(4).fill(0).map((() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16))).join("-");
|
|
210
|
+
e.set(h, n), t.start && t.start(), t.postMessage(Object.assign({ id: h }, i), s);
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
var S = { hasSubscribers: !1 }, b = S, T = S, _ = "object" == typeof performance && performance && "function" == typeof performance.now ? performance : Date, E = () => b.hasSubscribers || T.hasSubscribers, A = /* @__PURE__ */ new Set(), O = "object" == typeof process && process ? process : {}, F = (t) => !!t && t === Math.floor(t) && t > 0 && isFinite(t), x = (t) => F(t) ? t <= Math.pow(2, 8) ? Uint8Array : t <= Math.pow(2, 16) ? Uint16Array : t <= Math.pow(2, 32) ? Uint32Array : t <= Number.MAX_SAFE_INTEGER ? z : null : null, z = class extends Array {
|
|
214
|
+
constructor(t) {
|
|
215
|
+
super(t), this.fill(0);
|
|
216
|
+
}
|
|
217
|
+
}, k = class t {
|
|
218
|
+
heap;
|
|
219
|
+
length;
|
|
220
|
+
static #t = !1;
|
|
221
|
+
static create(e) {
|
|
222
|
+
let i = x(e);
|
|
223
|
+
if (!i) return [];
|
|
224
|
+
t.#t = !0;
|
|
225
|
+
let s = new t(e, i);
|
|
226
|
+
return t.#t = !1, s;
|
|
227
|
+
}
|
|
228
|
+
constructor(e, i) {
|
|
229
|
+
if (!t.#t) throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
230
|
+
this.heap = new i(e), this.length = 0;
|
|
231
|
+
}
|
|
232
|
+
push(t) {
|
|
233
|
+
this.heap[this.length++] = t;
|
|
234
|
+
}
|
|
235
|
+
pop() {
|
|
236
|
+
return this.heap[--this.length];
|
|
237
|
+
}
|
|
238
|
+
}, C = class t {
|
|
239
|
+
#t;
|
|
240
|
+
#e;
|
|
241
|
+
#i;
|
|
242
|
+
#s;
|
|
243
|
+
#n;
|
|
244
|
+
#h;
|
|
245
|
+
#r;
|
|
246
|
+
#o;
|
|
247
|
+
get perf() {
|
|
248
|
+
return this.#o;
|
|
249
|
+
}
|
|
250
|
+
ttl;
|
|
251
|
+
ttlResolution;
|
|
252
|
+
ttlAutopurge;
|
|
253
|
+
updateAgeOnGet;
|
|
254
|
+
updateAgeOnHas;
|
|
255
|
+
allowStale;
|
|
256
|
+
noDisposeOnSet;
|
|
257
|
+
noUpdateTTL;
|
|
258
|
+
maxEntrySize;
|
|
259
|
+
sizeCalculation;
|
|
260
|
+
noDeleteOnFetchRejection;
|
|
261
|
+
noDeleteOnStaleGet;
|
|
262
|
+
allowStaleOnFetchAbort;
|
|
263
|
+
allowStaleOnFetchRejection;
|
|
264
|
+
ignoreFetchAbort;
|
|
265
|
+
#a;
|
|
266
|
+
#l;
|
|
267
|
+
#c;
|
|
268
|
+
#u;
|
|
269
|
+
#f;
|
|
270
|
+
#d;
|
|
271
|
+
#p;
|
|
272
|
+
#g;
|
|
273
|
+
#v;
|
|
274
|
+
#m;
|
|
275
|
+
#w;
|
|
276
|
+
#y;
|
|
277
|
+
#S;
|
|
278
|
+
#b;
|
|
279
|
+
#T;
|
|
280
|
+
#_;
|
|
281
|
+
#E;
|
|
282
|
+
#A;
|
|
283
|
+
#O;
|
|
284
|
+
static unsafeExposeInternals(t) {
|
|
285
|
+
return {
|
|
286
|
+
starts: t.#S,
|
|
287
|
+
ttls: t.#b,
|
|
288
|
+
autopurgeTimers: t.#T,
|
|
289
|
+
sizes: t.#y,
|
|
290
|
+
keyMap: t.#c,
|
|
291
|
+
keyList: t.#u,
|
|
292
|
+
valList: t.#f,
|
|
293
|
+
next: t.#d,
|
|
294
|
+
prev: t.#p,
|
|
295
|
+
get head() {
|
|
296
|
+
return t.#g;
|
|
297
|
+
},
|
|
298
|
+
get tail() {
|
|
299
|
+
return t.#v;
|
|
300
|
+
},
|
|
301
|
+
free: t.#m,
|
|
302
|
+
isBackgroundFetch: (e) => t.#F(e),
|
|
303
|
+
backgroundFetch: (e, i, s, n) => t.#x(e, i, s, n),
|
|
304
|
+
moveToTail: (e) => t.#z(e),
|
|
305
|
+
indexes: (e) => t.#k(e),
|
|
306
|
+
rindexes: (e) => t.#C(e),
|
|
307
|
+
isStale: (e) => t.#R(e)
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
get max() {
|
|
311
|
+
return this.#t;
|
|
312
|
+
}
|
|
313
|
+
get maxSize() {
|
|
314
|
+
return this.#e;
|
|
315
|
+
}
|
|
316
|
+
get calculatedSize() {
|
|
317
|
+
return this.#l;
|
|
318
|
+
}
|
|
319
|
+
get size() {
|
|
320
|
+
return this.#a;
|
|
321
|
+
}
|
|
322
|
+
get fetchMethod() {
|
|
323
|
+
return this.#h;
|
|
324
|
+
}
|
|
325
|
+
get memoMethod() {
|
|
326
|
+
return this.#r;
|
|
327
|
+
}
|
|
328
|
+
get dispose() {
|
|
329
|
+
return this.#i;
|
|
330
|
+
}
|
|
331
|
+
get onInsert() {
|
|
332
|
+
return this.#s;
|
|
333
|
+
}
|
|
334
|
+
get disposeAfter() {
|
|
335
|
+
return this.#n;
|
|
336
|
+
}
|
|
337
|
+
constructor(e) {
|
|
338
|
+
let { max: i = 0, ttl: s, ttlResolution: n = 1, ttlAutopurge: h, updateAgeOnGet: r, updateAgeOnHas: o, allowStale: a, dispose: l, onInsert: c, disposeAfter: u, noDisposeOnSet: f, noUpdateTTL: d, maxSize: p = 0, maxEntrySize: g = 0, sizeCalculation: v, fetchMethod: m, memoMethod: w, noDeleteOnFetchRejection: y, noDeleteOnStaleGet: S, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: T, ignoreFetchAbort: E, perf: z } = e;
|
|
339
|
+
if (void 0 !== z && "function" != typeof z?.now) throw new TypeError("perf option must have a now() method if specified");
|
|
340
|
+
if (this.#o = z ?? _, 0 !== i && !F(i)) throw new TypeError("max option must be a nonnegative integer");
|
|
341
|
+
let C = i ? x(i) : Array;
|
|
342
|
+
if (!C) throw new Error("invalid max value: " + i);
|
|
343
|
+
if (this.#t = i, this.#e = p, this.maxEntrySize = g || this.#e, this.sizeCalculation = v, this.sizeCalculation) {
|
|
344
|
+
if (!this.#e && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
345
|
+
if ("function" != typeof this.sizeCalculation) throw new TypeError("sizeCalculation set to non-function");
|
|
346
|
+
}
|
|
347
|
+
if (void 0 !== w && "function" != typeof w) throw new TypeError("memoMethod must be a function if defined");
|
|
348
|
+
if (this.#r = w, void 0 !== m && "function" != typeof m) throw new TypeError("fetchMethod must be a function if specified");
|
|
349
|
+
if (this.#h = m, this.#E = !!m, this.#c = /* @__PURE__ */ new Map(), this.#u = Array.from({ length: i }).fill(void 0), this.#f = Array.from({ length: i }).fill(void 0), this.#d = new C(i), this.#p = new C(i), this.#g = 0, this.#v = 0, this.#m = k.create(i), this.#a = 0, this.#l = 0, "function" == typeof l && (this.#i = l), "function" == typeof c && (this.#s = c), "function" == typeof u ? (this.#n = u, this.#w = []) : (this.#n = void 0, this.#w = void 0), this.#_ = !!this.#i, this.#O = !!this.#s, this.#A = !!this.#n, this.noDisposeOnSet = !!f, this.noUpdateTTL = !!d, this.noDeleteOnFetchRejection = !!y, this.allowStaleOnFetchRejection = !!b, this.allowStaleOnFetchAbort = !!T, this.ignoreFetchAbort = !!E, 0 !== this.maxEntrySize) {
|
|
350
|
+
if (0 !== this.#e && !F(this.#e)) throw new TypeError("maxSize must be a positive integer if specified");
|
|
351
|
+
if (!F(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
352
|
+
this.#j();
|
|
353
|
+
}
|
|
354
|
+
if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!S, this.updateAgeOnGet = !!r, this.updateAgeOnHas = !!o, this.ttlResolution = F(n) || 0 === n ? n : 1, this.ttlAutopurge = !!h, this.ttl = s || 0, this.ttl) {
|
|
355
|
+
if (!F(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
|
|
356
|
+
this.#D();
|
|
357
|
+
}
|
|
358
|
+
if (0 === this.#t && 0 === this.ttl && 0 === this.#e) throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
359
|
+
if (!this.ttlAutopurge && !this.#t && !this.#e) {
|
|
360
|
+
let e = "LRU_CACHE_UNBOUNDED";
|
|
361
|
+
((t) => !A.has(t))(e) && (A.add(e), ((t, e, i, s) => {
|
|
362
|
+
"function" == typeof O.emitWarning ? O.emitWarning(t, e, i, s) : console.error(`[${i}] ${e}: ${t}`);
|
|
363
|
+
})("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", e, t));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
getRemainingTTL(t) {
|
|
367
|
+
return this.#c.has(t) ? Infinity : 0;
|
|
368
|
+
}
|
|
369
|
+
#D() {
|
|
370
|
+
let t = new z(this.#t), e = new z(this.#t);
|
|
371
|
+
this.#b = t, this.#S = e;
|
|
372
|
+
let i = this.ttlAutopurge ? Array.from({ length: this.#t }) : void 0;
|
|
373
|
+
this.#T = i, this.#W = (i, n, h = this.#o.now()) => {
|
|
374
|
+
e[i] = 0 !== n ? h : 0, t[i] = n, s(i, n);
|
|
375
|
+
}, this.#M = (i) => {
|
|
376
|
+
e[i] = 0 !== t[i] ? this.#o.now() : 0, s(i, t[i]);
|
|
377
|
+
};
|
|
378
|
+
let s = this.ttlAutopurge ? (t, e) => {
|
|
379
|
+
if (i?.[t] && (clearTimeout(i[t]), i[t] = void 0), e && 0 !== e && i) {
|
|
380
|
+
let s = setTimeout((() => {
|
|
381
|
+
this.#R(t) && this.#L(this.#u[t], "expire");
|
|
382
|
+
}), e + 1);
|
|
383
|
+
s.unref && s.unref(), i[t] = s;
|
|
384
|
+
}
|
|
385
|
+
} : () => {};
|
|
386
|
+
this.#G = (i, s) => {
|
|
387
|
+
if (t[s]) {
|
|
388
|
+
let r = t[s], o = e[s];
|
|
389
|
+
if (!r || !o) return;
|
|
390
|
+
i.ttl = r, i.start = o, i.now = n || h(), i.remainingTTL = r - (i.now - o);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
let n = 0, h = () => {
|
|
394
|
+
let t = this.#o.now();
|
|
395
|
+
if (this.ttlResolution > 0) {
|
|
396
|
+
n = t;
|
|
397
|
+
let e = setTimeout((() => n = 0), this.ttlResolution);
|
|
398
|
+
e.unref && e.unref();
|
|
399
|
+
}
|
|
400
|
+
return t;
|
|
401
|
+
};
|
|
402
|
+
this.getRemainingTTL = (i) => {
|
|
403
|
+
let s = this.#c.get(i);
|
|
404
|
+
if (void 0 === s) return 0;
|
|
405
|
+
let r = t[s], o = e[s];
|
|
406
|
+
return r && o ? r - ((n || h()) - o) : Infinity;
|
|
407
|
+
}, this.#R = (i) => {
|
|
408
|
+
let s = e[i], r = t[i];
|
|
409
|
+
return !!r && !!s && (n || h()) - s > r;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
#M = () => {};
|
|
413
|
+
#G = () => {};
|
|
414
|
+
#W = () => {};
|
|
415
|
+
#R = () => !1;
|
|
416
|
+
#j() {
|
|
417
|
+
let t = new z(this.#t);
|
|
418
|
+
this.#l = 0, this.#y = t, this.#U = (e) => {
|
|
419
|
+
this.#l -= t[e], t[e] = 0;
|
|
420
|
+
}, this.#P = (t, e, i, s) => {
|
|
421
|
+
if (this.#F(e)) return 0;
|
|
422
|
+
if (!F(i)) {
|
|
423
|
+
if (!s) throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
424
|
+
if ("function" != typeof s) throw new TypeError("sizeCalculation must be a function");
|
|
425
|
+
if (i = s(e, t), !F(i)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
426
|
+
}
|
|
427
|
+
return i;
|
|
428
|
+
}, this.#N = (e, i, s) => {
|
|
429
|
+
if (t[e] = i, this.#e) {
|
|
430
|
+
let i = this.#e - t[e];
|
|
431
|
+
for (; this.#l > i;) this.#H(!0);
|
|
432
|
+
}
|
|
433
|
+
this.#l += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#l);
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
#U = (t) => {};
|
|
437
|
+
#N = (t, e, i) => {};
|
|
438
|
+
#P = (t, e, i, s) => {
|
|
439
|
+
if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
440
|
+
return 0;
|
|
441
|
+
};
|
|
442
|
+
*#k({ allowStale: t = this.allowStale } = {}) {
|
|
443
|
+
if (this.#a) for (let e = this.#v; this.#I(e) && ((t || !this.#R(e)) && (yield e), e !== this.#g);) e = this.#p[e];
|
|
444
|
+
}
|
|
445
|
+
*#C({ allowStale: t = this.allowStale } = {}) {
|
|
446
|
+
if (this.#a) for (let e = this.#g; this.#I(e) && ((t || !this.#R(e)) && (yield e), e !== this.#v);) e = this.#d[e];
|
|
447
|
+
}
|
|
448
|
+
#I(t) {
|
|
449
|
+
return void 0 !== t && this.#c.get(this.#u[t]) === t;
|
|
450
|
+
}
|
|
451
|
+
*entries() {
|
|
452
|
+
for (let t of this.#k()) void 0 !== this.#f[t] && void 0 !== this.#u[t] && !this.#F(this.#f[t]) && (yield [this.#u[t], this.#f[t]]);
|
|
453
|
+
}
|
|
454
|
+
*rentries() {
|
|
455
|
+
for (let t of this.#C()) void 0 !== this.#f[t] && void 0 !== this.#u[t] && !this.#F(this.#f[t]) && (yield [this.#u[t], this.#f[t]]);
|
|
456
|
+
}
|
|
457
|
+
*keys() {
|
|
458
|
+
for (let t of this.#k()) {
|
|
459
|
+
let e = this.#u[t];
|
|
460
|
+
void 0 !== e && !this.#F(this.#f[t]) && (yield e);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
*rkeys() {
|
|
464
|
+
for (let t of this.#C()) {
|
|
465
|
+
let e = this.#u[t];
|
|
466
|
+
void 0 !== e && !this.#F(this.#f[t]) && (yield e);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
*values() {
|
|
470
|
+
for (let t of this.#k()) void 0 !== this.#f[t] && !this.#F(this.#f[t]) && (yield this.#f[t]);
|
|
471
|
+
}
|
|
472
|
+
*rvalues() {
|
|
473
|
+
for (let t of this.#C()) void 0 !== this.#f[t] && !this.#F(this.#f[t]) && (yield this.#f[t]);
|
|
474
|
+
}
|
|
475
|
+
[Symbol.iterator]() {
|
|
476
|
+
return this.entries();
|
|
477
|
+
}
|
|
478
|
+
[Symbol.toStringTag] = "LRUCache";
|
|
479
|
+
find(t, e = {}) {
|
|
480
|
+
for (let i of this.#k()) {
|
|
481
|
+
let s = this.#f[i], n = this.#F(s) ? s.__staleWhileFetching : s;
|
|
482
|
+
if (void 0 !== n && t(n, this.#u[i], this)) return this.#$(this.#u[i], e);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
forEach(t, e = this) {
|
|
486
|
+
for (let i of this.#k()) {
|
|
487
|
+
let s = this.#f[i], n = this.#F(s) ? s.__staleWhileFetching : s;
|
|
488
|
+
void 0 !== n && t.call(e, n, this.#u[i], this);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
rforEach(t, e = this) {
|
|
492
|
+
for (let i of this.#C()) {
|
|
493
|
+
let s = this.#f[i], n = this.#F(s) ? s.__staleWhileFetching : s;
|
|
494
|
+
void 0 !== n && t.call(e, n, this.#u[i], this);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
purgeStale() {
|
|
498
|
+
let t = !1;
|
|
499
|
+
for (let e of this.#C({ allowStale: !0 })) this.#R(e) && (this.#L(this.#u[e], "expire"), t = !0);
|
|
500
|
+
return t;
|
|
501
|
+
}
|
|
502
|
+
info(t) {
|
|
503
|
+
let e = this.#c.get(t);
|
|
504
|
+
if (void 0 === e) return;
|
|
505
|
+
let i = this.#f[e], s = this.#F(i) ? i.__staleWhileFetching : i;
|
|
506
|
+
if (void 0 === s) return;
|
|
507
|
+
let n = { value: s };
|
|
508
|
+
if (this.#b && this.#S) {
|
|
509
|
+
let t = this.#b[e], i = this.#S[e];
|
|
510
|
+
t && i && (n.ttl = t - (this.#o.now() - i), n.start = Date.now());
|
|
511
|
+
}
|
|
512
|
+
return this.#y && (n.size = this.#y[e]), n;
|
|
513
|
+
}
|
|
514
|
+
dump() {
|
|
515
|
+
let t = [];
|
|
516
|
+
for (let e of this.#k({ allowStale: !0 })) {
|
|
517
|
+
let i = this.#u[e], s = this.#f[e], n = this.#F(s) ? s.__staleWhileFetching : s;
|
|
518
|
+
if (void 0 === n || void 0 === i) continue;
|
|
519
|
+
let h = { value: n };
|
|
520
|
+
if (this.#b && this.#S) {
|
|
521
|
+
h.ttl = this.#b[e];
|
|
522
|
+
let t = this.#o.now() - this.#S[e];
|
|
523
|
+
h.start = Math.floor(Date.now() - t);
|
|
524
|
+
}
|
|
525
|
+
this.#y && (h.size = this.#y[e]), t.unshift([i, h]);
|
|
526
|
+
}
|
|
527
|
+
return t;
|
|
528
|
+
}
|
|
529
|
+
load(t) {
|
|
530
|
+
this.clear();
|
|
531
|
+
for (let [e, i] of t) {
|
|
532
|
+
if (i.start) {
|
|
533
|
+
let t = Date.now() - i.start;
|
|
534
|
+
i.start = this.#o.now() - t;
|
|
535
|
+
}
|
|
536
|
+
this.#B(e, i.value, i);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
set(t, e, i = {}) {
|
|
540
|
+
let { status: s = b.hasSubscribers ? {} : void 0 } = i;
|
|
541
|
+
i.status = s, s && (s.op = "set", s.key = t, void 0 !== e && (s.value = e));
|
|
542
|
+
let n = this.#B(t, e, i);
|
|
543
|
+
return s && b.hasSubscribers && b.publish(s), n;
|
|
544
|
+
}
|
|
545
|
+
#B(t, e, i = {}) {
|
|
546
|
+
let { ttl: s = this.ttl, start: n, noDisposeOnSet: h = this.noDisposeOnSet, sizeCalculation: r = this.sizeCalculation, status: o } = i;
|
|
547
|
+
if (void 0 === e) return o && (o.set = "deleted"), this.delete(t), this;
|
|
548
|
+
let { noUpdateTTL: a = this.noUpdateTTL } = i;
|
|
549
|
+
o && !this.#F(e) && (o.value = e);
|
|
550
|
+
let l = this.#P(t, e, i.size || 0, r, o);
|
|
551
|
+
if (this.maxEntrySize && l > this.maxEntrySize) return this.#L(t, "set"), o && (o.set = "miss", o.maxEntrySizeExceeded = !0), this;
|
|
552
|
+
let c = 0 === this.#a ? void 0 : this.#c.get(t);
|
|
553
|
+
if (void 0 === c) c = 0 === this.#a ? this.#v : 0 !== this.#m.length ? this.#m.pop() : this.#a === this.#t ? this.#H(!1) : this.#a, this.#u[c] = t, this.#f[c] = e, this.#c.set(t, c), this.#d[this.#v] = c, this.#p[c] = this.#v, this.#v = c, this.#a++, this.#N(c, l, o), o && (o.set = "add"), a = !1, this.#O && this.#s?.(e, t, "add");
|
|
554
|
+
else {
|
|
555
|
+
this.#z(c);
|
|
556
|
+
let i = this.#f[c];
|
|
557
|
+
if (e !== i) {
|
|
558
|
+
if (this.#E && this.#F(i)) {
|
|
559
|
+
i.__abortController.abort(/* @__PURE__ */ new Error("replaced"));
|
|
560
|
+
let { __staleWhileFetching: e } = i;
|
|
561
|
+
void 0 !== e && !h && (this.#_ && this.#i?.(e, t, "set"), this.#A && this.#w?.push([
|
|
562
|
+
e,
|
|
563
|
+
t,
|
|
564
|
+
"set"
|
|
565
|
+
]));
|
|
566
|
+
} else h || (this.#_ && this.#i?.(i, t, "set"), this.#A && this.#w?.push([
|
|
567
|
+
i,
|
|
568
|
+
t,
|
|
569
|
+
"set"
|
|
570
|
+
]));
|
|
571
|
+
if (this.#U(c), this.#N(c, l, o), this.#f[c] = e, o) {
|
|
572
|
+
o.set = "replace";
|
|
573
|
+
let t = i && this.#F(i) ? i.__staleWhileFetching : i;
|
|
574
|
+
void 0 !== t && (o.oldValue = t);
|
|
575
|
+
}
|
|
576
|
+
} else o && (o.set = "update");
|
|
577
|
+
this.#O && this.onInsert?.(e, t, e === i ? "update" : "replace");
|
|
578
|
+
}
|
|
579
|
+
if (0 !== s && !this.#b && this.#D(), this.#b && (a || this.#W(c, s, n), o && this.#G(o, c)), !h && this.#A && this.#w) {
|
|
580
|
+
let t, e = this.#w;
|
|
581
|
+
for (; t = e?.shift();) this.#n?.(...t);
|
|
582
|
+
}
|
|
583
|
+
return this;
|
|
584
|
+
}
|
|
585
|
+
pop() {
|
|
586
|
+
try {
|
|
587
|
+
for (; this.#a;) {
|
|
588
|
+
let t = this.#f[this.#g];
|
|
589
|
+
if (this.#H(!0), this.#F(t)) {
|
|
590
|
+
if (t.__staleWhileFetching) return t.__staleWhileFetching;
|
|
591
|
+
} else if (void 0 !== t) return t;
|
|
592
|
+
}
|
|
593
|
+
} finally {
|
|
594
|
+
if (this.#A && this.#w) {
|
|
595
|
+
let t, e = this.#w;
|
|
596
|
+
for (; t = e?.shift();) this.#n?.(...t);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
#H(t) {
|
|
601
|
+
let e = this.#g, i = this.#u[e], s = this.#f[e];
|
|
602
|
+
return this.#E && this.#F(s) ? s.__abortController.abort(/* @__PURE__ */ new Error("evicted")) : (this.#_ || this.#A) && (this.#_ && this.#i?.(s, i, "evict"), this.#A && this.#w?.push([
|
|
603
|
+
s,
|
|
604
|
+
i,
|
|
605
|
+
"evict"
|
|
606
|
+
])), this.#U(e), this.#T?.[e] && (clearTimeout(this.#T[e]), this.#T[e] = void 0), t && (this.#u[e] = void 0, this.#f[e] = void 0, this.#m.push(e)), 1 === this.#a ? (this.#g = this.#v = 0, this.#m.length = 0) : this.#g = this.#d[e], this.#c.delete(i), this.#a--, e;
|
|
607
|
+
}
|
|
608
|
+
has(t, e = {}) {
|
|
609
|
+
let { status: i = b.hasSubscribers ? {} : void 0 } = e;
|
|
610
|
+
e.status = i, i && (i.op = "has", i.key = t);
|
|
611
|
+
let s = this.#X(t, e);
|
|
612
|
+
return b.hasSubscribers && b.publish(i), s;
|
|
613
|
+
}
|
|
614
|
+
#X(t, e = {}) {
|
|
615
|
+
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, n = this.#c.get(t);
|
|
616
|
+
if (void 0 !== n) {
|
|
617
|
+
let t = this.#f[n];
|
|
618
|
+
if (this.#F(t) && void 0 === t.__staleWhileFetching) return !1;
|
|
619
|
+
if (!this.#R(n)) return i && this.#M(n), s && (s.has = "hit", this.#G(s, n)), !0;
|
|
620
|
+
s && (s.has = "stale", this.#G(s, n));
|
|
621
|
+
} else s && (s.has = "miss");
|
|
622
|
+
return !1;
|
|
623
|
+
}
|
|
624
|
+
peek(t, e = {}) {
|
|
625
|
+
let { status: i = E() ? {} : void 0 } = e;
|
|
626
|
+
i && (i.op = "peek", i.key = t), e.status = i;
|
|
627
|
+
let s = this.#Y(t, e);
|
|
628
|
+
return b.hasSubscribers && b.publish(i), s;
|
|
629
|
+
}
|
|
630
|
+
#Y(t, e) {
|
|
631
|
+
let { status: i, allowStale: s = this.allowStale } = e, n = this.#c.get(t);
|
|
632
|
+
if (void 0 === n || !s && this.#R(n)) return void (i && (i.peek = void 0 === n ? "miss" : "stale"));
|
|
633
|
+
let h = this.#f[n], r = this.#F(h) ? h.__staleWhileFetching : h;
|
|
634
|
+
return i && (void 0 !== r ? (i.peek = "hit", i.value = r) : i.peek = "miss"), r;
|
|
635
|
+
}
|
|
636
|
+
#x(t, e, i, s) {
|
|
637
|
+
let n = void 0 === e ? void 0 : this.#f[e];
|
|
638
|
+
if (this.#F(n)) return n;
|
|
639
|
+
let h = new AbortController(), { signal: r } = i;
|
|
640
|
+
r?.addEventListener("abort", (() => h.abort(r.reason)), { signal: h.signal });
|
|
641
|
+
let o = {
|
|
642
|
+
signal: h.signal,
|
|
643
|
+
options: i,
|
|
644
|
+
context: s
|
|
645
|
+
}, a = (s, n = !1) => {
|
|
646
|
+
let { aborted: r } = h.signal, a = i.ignoreFetchAbort && void 0 !== s, u = i.ignoreFetchAbort || !(!i.allowStaleOnFetchAbort || void 0 === s);
|
|
647
|
+
if (i.status && (r && !n ? (i.status.fetchAborted = !0, i.status.fetchError = h.signal.reason, a && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), r && !a && !n) return l(h.signal.reason, u);
|
|
648
|
+
let f = c, d = this.#f[e];
|
|
649
|
+
return (d === c || void 0 === d && a && n) && (void 0 === s ? void 0 !== f.__staleWhileFetching ? this.#f[e] = f.__staleWhileFetching : this.#L(t, "fetch") : (i.status && (i.status.fetchUpdated = !0), this.#B(t, s, o.options))), s;
|
|
650
|
+
}, l = (s, n) => {
|
|
651
|
+
let { aborted: r } = h.signal, o = r && i.allowStaleOnFetchAbort, a = o || i.allowStaleOnFetchRejection, l = a || i.noDeleteOnFetchRejection, u = c;
|
|
652
|
+
if (this.#f[e] === c && (!l || !n && void 0 === u.__staleWhileFetching ? this.#L(t, "fetch") : o || (this.#f[e] = u.__staleWhileFetching)), a) return i.status && void 0 !== u.__staleWhileFetching && (i.status.returnedStale = !0), u.__staleWhileFetching;
|
|
653
|
+
if (u.__returned === u) throw s;
|
|
654
|
+
};
|
|
655
|
+
i.status && (i.status.fetchDispatched = !0);
|
|
656
|
+
let c = new Promise(((e, s) => {
|
|
657
|
+
let r = this.#h?.(t, n, o);
|
|
658
|
+
r && r instanceof Promise && r.then(((t) => e(void 0 === t ? void 0 : t)), s), h.signal.addEventListener("abort", (() => {
|
|
659
|
+
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (e(void 0), i.allowStaleOnFetchAbort && (e = (t) => a(t, !0)));
|
|
660
|
+
}));
|
|
661
|
+
})).then(a, ((t) => (i.status && (i.status.fetchRejected = !0, i.status.fetchError = t), l(t, !1)))), u = Object.assign(c, {
|
|
662
|
+
__abortController: h,
|
|
663
|
+
__staleWhileFetching: n,
|
|
664
|
+
__returned: void 0
|
|
665
|
+
});
|
|
666
|
+
return void 0 === e ? (this.#B(t, u, {
|
|
667
|
+
...o.options,
|
|
668
|
+
status: void 0
|
|
669
|
+
}), e = this.#c.get(t)) : this.#f[e] = u, u;
|
|
670
|
+
}
|
|
671
|
+
#F(t) {
|
|
672
|
+
if (!this.#E) return !1;
|
|
673
|
+
let e = t;
|
|
674
|
+
return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof AbortController;
|
|
675
|
+
}
|
|
676
|
+
fetch(t, e = {}) {
|
|
677
|
+
let i = T.hasSubscribers, { status: s = E() ? {} : void 0 } = e;
|
|
678
|
+
e.status = s, s && e.context && (s.context = e.context);
|
|
679
|
+
let n = this.#q(t, e);
|
|
680
|
+
return s && i && (s.trace = !0, T.tracePromise((() => n), s).catch((() => {}))), n;
|
|
681
|
+
}
|
|
682
|
+
async #q(t, e = {}) {
|
|
683
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: h = this.ttl, noDisposeOnSet: r = this.noDisposeOnSet, size: o = 0, sizeCalculation: a = this.sizeCalculation, noUpdateTTL: l = this.noUpdateTTL, noDeleteOnFetchRejection: c = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: u = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: d = this.allowStaleOnFetchAbort, context: p, forceRefresh: g = !1, status: v, signal: m } = e;
|
|
684
|
+
if (v && (v.op = "fetch", v.key = t, g && (v.forceRefresh = !0)), !this.#E) return v && (v.fetch = "get"), this.#$(t, {
|
|
685
|
+
allowStale: i,
|
|
686
|
+
updateAgeOnGet: s,
|
|
687
|
+
noDeleteOnStaleGet: n,
|
|
688
|
+
status: v
|
|
689
|
+
});
|
|
690
|
+
let w = {
|
|
691
|
+
allowStale: i,
|
|
692
|
+
updateAgeOnGet: s,
|
|
693
|
+
noDeleteOnStaleGet: n,
|
|
694
|
+
ttl: h,
|
|
695
|
+
noDisposeOnSet: r,
|
|
696
|
+
size: o,
|
|
697
|
+
sizeCalculation: a,
|
|
698
|
+
noUpdateTTL: l,
|
|
699
|
+
noDeleteOnFetchRejection: c,
|
|
700
|
+
allowStaleOnFetchRejection: u,
|
|
701
|
+
allowStaleOnFetchAbort: d,
|
|
702
|
+
ignoreFetchAbort: f,
|
|
703
|
+
status: v,
|
|
704
|
+
signal: m
|
|
705
|
+
}, y = this.#c.get(t);
|
|
706
|
+
if (void 0 === y) {
|
|
707
|
+
v && (v.fetch = "miss");
|
|
708
|
+
let e = this.#x(t, y, w, p);
|
|
709
|
+
return e.__returned = e;
|
|
710
|
+
}
|
|
711
|
+
{
|
|
712
|
+
let e = this.#f[y];
|
|
713
|
+
if (this.#F(e)) {
|
|
714
|
+
let t = i && void 0 !== e.__staleWhileFetching;
|
|
715
|
+
return v && (v.fetch = "inflight", t && (v.returnedStale = !0)), t ? e.__staleWhileFetching : e.__returned = e;
|
|
716
|
+
}
|
|
717
|
+
let n = this.#R(y);
|
|
718
|
+
if (!g && !n) return v && (v.fetch = "hit"), this.#z(y), s && this.#M(y), v && this.#G(v, y), e;
|
|
719
|
+
let h = this.#x(t, y, w, p), r = void 0 !== h.__staleWhileFetching && i;
|
|
720
|
+
return v && (v.fetch = n ? "stale" : "refresh", r && n && (v.returnedStale = !0)), r ? h.__staleWhileFetching : h.__returned = h;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
forceFetch(t, e = {}) {
|
|
724
|
+
let i = T.hasSubscribers, { status: s = E() ? {} : void 0 } = e;
|
|
725
|
+
e.status = s, s && e.context && (s.context = e.context);
|
|
726
|
+
let n = this.#K(t, e);
|
|
727
|
+
return s && i && (s.trace = !0, T.tracePromise((() => n), s).catch((() => {}))), n;
|
|
728
|
+
}
|
|
729
|
+
async #K(t, e = {}) {
|
|
730
|
+
let i = await this.#q(t, e);
|
|
731
|
+
if (void 0 === i) throw new Error("fetch() returned undefined");
|
|
732
|
+
return i;
|
|
733
|
+
}
|
|
734
|
+
memo(t, e = {}) {
|
|
735
|
+
let { status: i = b.hasSubscribers ? {} : void 0 } = e;
|
|
736
|
+
e.status = i, i && (i.op = "memo", i.key = t, e.context && (i.context = e.context));
|
|
737
|
+
let s = this.#Q(t, e);
|
|
738
|
+
return i && (i.value = s), b.hasSubscribers && b.publish(i), s;
|
|
739
|
+
}
|
|
740
|
+
#Q(t, e = {}) {
|
|
741
|
+
let i = this.#r;
|
|
742
|
+
if (!i) throw new Error("no memoMethod provided to constructor");
|
|
743
|
+
let { context: s, status: n, forceRefresh: h, ...r } = e;
|
|
744
|
+
n && h && (n.forceRefresh = !0);
|
|
745
|
+
let o = this.#$(t, r), a = h || void 0 === o;
|
|
746
|
+
if (n && (n.memo = a ? "miss" : "hit", a || (n.value = o)), !a) return o;
|
|
747
|
+
let l = i(t, o, {
|
|
748
|
+
options: r,
|
|
749
|
+
context: s
|
|
750
|
+
});
|
|
751
|
+
return n && (n.value = l), this.#B(t, l, r), l;
|
|
752
|
+
}
|
|
753
|
+
get(t, e = {}) {
|
|
754
|
+
let { status: i = b.hasSubscribers ? {} : void 0 } = e;
|
|
755
|
+
e.status = i, i && (i.op = "get", i.key = t);
|
|
756
|
+
let s = this.#$(t, e);
|
|
757
|
+
return i && (void 0 !== s && (i.value = s), b.hasSubscribers && b.publish(i)), s;
|
|
758
|
+
}
|
|
759
|
+
#$(t, e = {}) {
|
|
760
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: h } = e, r = this.#c.get(t);
|
|
761
|
+
if (void 0 === r) return void (h && (h.get = "miss"));
|
|
762
|
+
let o = this.#f[r], a = this.#F(o);
|
|
763
|
+
return h && this.#G(h, r), this.#R(r) ? a ? (h && (h.get = "stale-fetching"), i && void 0 !== o.__staleWhileFetching ? (h && (h.returnedStale = !0), o.__staleWhileFetching) : void 0) : (n || this.#L(t, "expire"), h && (h.get = "stale"), i ? (h && (h.returnedStale = !0), o) : void 0) : (h && (h.get = a ? "fetching" : "hit"), this.#z(r), s && this.#M(r), a ? o.__staleWhileFetching : o);
|
|
764
|
+
}
|
|
765
|
+
#V(t, e) {
|
|
766
|
+
this.#p[e] = t, this.#d[t] = e;
|
|
767
|
+
}
|
|
768
|
+
#z(t) {
|
|
769
|
+
t !== this.#v && (t === this.#g ? this.#g = this.#d[t] : this.#V(this.#p[t], this.#d[t]), this.#V(this.#v, t), this.#v = t);
|
|
770
|
+
}
|
|
771
|
+
delete(t) {
|
|
772
|
+
return this.#L(t, "delete");
|
|
773
|
+
}
|
|
774
|
+
#L(t, e) {
|
|
775
|
+
b.hasSubscribers && b.publish({
|
|
776
|
+
op: "delete",
|
|
777
|
+
delete: e,
|
|
778
|
+
key: t
|
|
779
|
+
});
|
|
780
|
+
let i = !1;
|
|
781
|
+
if (0 !== this.#a) {
|
|
782
|
+
let s = this.#c.get(t);
|
|
783
|
+
if (void 0 !== s) if (this.#T?.[s] && (clearTimeout(this.#T?.[s]), this.#T[s] = void 0), i = !0, 1 === this.#a) this.#J(e);
|
|
784
|
+
else {
|
|
785
|
+
this.#U(s);
|
|
786
|
+
let i = this.#f[s];
|
|
787
|
+
if (this.#F(i) ? i.__abortController.abort(/* @__PURE__ */ new Error("deleted")) : (this.#_ || this.#A) && (this.#_ && this.#i?.(i, t, e), this.#A && this.#w?.push([
|
|
788
|
+
i,
|
|
789
|
+
t,
|
|
790
|
+
e
|
|
791
|
+
])), this.#c.delete(t), this.#u[s] = void 0, this.#f[s] = void 0, s === this.#v) this.#v = this.#p[s];
|
|
792
|
+
else if (s === this.#g) this.#g = this.#d[s];
|
|
793
|
+
else {
|
|
794
|
+
let t = this.#p[s];
|
|
795
|
+
this.#d[t] = this.#d[s];
|
|
796
|
+
let e = this.#d[s];
|
|
797
|
+
this.#p[e] = this.#p[s];
|
|
798
|
+
}
|
|
799
|
+
this.#a--, this.#m.push(s);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
if (this.#A && this.#w?.length) {
|
|
803
|
+
let t, e = this.#w;
|
|
804
|
+
for (; t = e?.shift();) this.#n?.(...t);
|
|
805
|
+
}
|
|
806
|
+
return i;
|
|
807
|
+
}
|
|
808
|
+
clear() {
|
|
809
|
+
return this.#J("delete");
|
|
810
|
+
}
|
|
811
|
+
#J(t) {
|
|
812
|
+
for (let e of this.#C({ allowStale: !0 })) {
|
|
813
|
+
let i = this.#f[e];
|
|
814
|
+
if (this.#F(i)) i.__abortController.abort(/* @__PURE__ */ new Error("deleted"));
|
|
815
|
+
else {
|
|
816
|
+
let s = this.#u[e];
|
|
817
|
+
this.#_ && this.#i?.(i, s, t), this.#A && this.#w?.push([
|
|
818
|
+
i,
|
|
819
|
+
s,
|
|
820
|
+
t
|
|
821
|
+
]);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
if (this.#c.clear(), this.#f.fill(void 0), this.#u.fill(void 0), this.#b && this.#S) {
|
|
825
|
+
this.#b.fill(0), this.#S.fill(0);
|
|
826
|
+
for (let t of this.#T ?? []) void 0 !== t && clearTimeout(t);
|
|
827
|
+
this.#T?.fill(void 0);
|
|
828
|
+
}
|
|
829
|
+
if (this.#y && this.#y.fill(0), this.#g = 0, this.#v = 0, this.#m.length = 0, this.#l = 0, this.#a = 0, this.#A && this.#w) {
|
|
830
|
+
let t, e = this.#w;
|
|
831
|
+
for (; t = e?.shift();) this.#n?.(...t);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}, R = class {
|
|
835
|
+
static defaultOptions = {
|
|
836
|
+
max: 1e3,
|
|
837
|
+
ttl: 18e5
|
|
838
|
+
};
|
|
839
|
+
static cache = new C(this.defaultOptions);
|
|
840
|
+
static createCache(t = this.defaultOptions) {
|
|
841
|
+
return new C(t);
|
|
842
|
+
}
|
|
843
|
+
static set(t, e, i = this.cache) {
|
|
844
|
+
let s = i;
|
|
845
|
+
s || (s = this.cache), s.set(t, e);
|
|
846
|
+
}
|
|
847
|
+
static get(t, e = this.cache) {
|
|
848
|
+
let i = e;
|
|
849
|
+
return i || (i = this.cache), i.get(t);
|
|
850
|
+
}
|
|
851
|
+
static remove(t, e = this.cache) {
|
|
852
|
+
let i = e;
|
|
853
|
+
return i || (i = this.cache), i.del(t);
|
|
854
|
+
}
|
|
855
|
+
static has(t, e = this.cache) {
|
|
856
|
+
let i = e;
|
|
857
|
+
return i || (i = this.cache), i.has(t);
|
|
858
|
+
}
|
|
859
|
+
static count(t = this.cache) {
|
|
860
|
+
let e = t;
|
|
861
|
+
return e || (e = this.cache), e.size;
|
|
862
|
+
}
|
|
863
|
+
static maxSize(t = this.cache) {
|
|
864
|
+
let e = t;
|
|
865
|
+
return e || (e = this.cache), e.max;
|
|
866
|
+
}
|
|
867
|
+
static peek(t, e = this.cache) {
|
|
868
|
+
let i = e;
|
|
869
|
+
return i || (i = this.cache), i.peek(t);
|
|
870
|
+
}
|
|
871
|
+
static keys(t = this.cache) {
|
|
872
|
+
let e = t;
|
|
873
|
+
return e || (e = this.cache), e.keys();
|
|
874
|
+
}
|
|
875
|
+
static clear(t = this.cache) {
|
|
876
|
+
let e = t;
|
|
877
|
+
e || (e = this.cache), e.clear();
|
|
878
|
+
}
|
|
879
|
+
}, j = ((e, i) => {
|
|
880
|
+
let s = {};
|
|
881
|
+
for (var n in e) t(s, n, {
|
|
882
|
+
get: e[n],
|
|
883
|
+
enumerable: !0
|
|
884
|
+
});
|
|
885
|
+
return i || t(s, Symbol.toStringTag, { value: "Module" }), s;
|
|
886
|
+
})({
|
|
887
|
+
clear: () => $,
|
|
888
|
+
count: () => N,
|
|
889
|
+
createCache: () => W,
|
|
890
|
+
get: () => G,
|
|
891
|
+
getCacheObject: () => M,
|
|
892
|
+
has: () => P,
|
|
893
|
+
keys: () => B,
|
|
894
|
+
maxSize: () => H,
|
|
895
|
+
peek: () => I,
|
|
896
|
+
remove: () => U,
|
|
897
|
+
set: () => L
|
|
898
|
+
});
|
|
899
|
+
const D = /* @__PURE__ */ new Map();
|
|
900
|
+
async function W(t, e = void 0) {
|
|
901
|
+
const i = {
|
|
902
|
+
max: 1e3,
|
|
903
|
+
ttl: 18e5
|
|
904
|
+
};
|
|
905
|
+
let s = i;
|
|
906
|
+
e && (s = {
|
|
907
|
+
...i,
|
|
908
|
+
...e
|
|
909
|
+
});
|
|
910
|
+
const n = R.createCache(s);
|
|
911
|
+
return D.set(t, n), n;
|
|
912
|
+
}
|
|
913
|
+
async function M(t = "") {
|
|
914
|
+
let e;
|
|
915
|
+
return e = D.has(t) ? D.get(t) : await W(t), e;
|
|
916
|
+
}
|
|
917
|
+
async function L(t, e, i = "") {
|
|
918
|
+
const s = await M(i);
|
|
919
|
+
return !!s && (R.set(t, e, s), !0);
|
|
920
|
+
}
|
|
921
|
+
async function G(t, e = "") {
|
|
922
|
+
const i = await M(e);
|
|
923
|
+
if (i) {
|
|
924
|
+
const e = R.get(t, i);
|
|
925
|
+
return console.log("666000", t, e), e;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
async function U(t, e = "") {
|
|
929
|
+
const i = await M(e);
|
|
930
|
+
if (i) return R.remove(t, i);
|
|
931
|
+
}
|
|
932
|
+
async function P(t, e = "") {
|
|
933
|
+
const i = await M(e);
|
|
934
|
+
return !!i && R.has(t, i);
|
|
935
|
+
}
|
|
936
|
+
async function N(t = "") {
|
|
937
|
+
const e = await M(t);
|
|
938
|
+
return e ? R.count(e) : 0;
|
|
939
|
+
}
|
|
940
|
+
async function H(t = "") {
|
|
941
|
+
const e = await M(t);
|
|
942
|
+
return e ? R.maxSize(e) : 0;
|
|
943
|
+
}
|
|
944
|
+
async function I(t, e = "") {
|
|
945
|
+
const i = await M(e);
|
|
946
|
+
return !!i && R.peek(t, i);
|
|
947
|
+
}
|
|
948
|
+
async function $(t = "") {
|
|
949
|
+
const e = await M(t);
|
|
950
|
+
return e && R.clear(e), !1;
|
|
951
|
+
}
|
|
952
|
+
async function B(t = "") {
|
|
953
|
+
const e = await M(t);
|
|
954
|
+
if (e) return R.keys(e);
|
|
955
|
+
}
|
|
956
|
+
a(j);
|