@module-federation/bridge-react 0.16.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/__tests__/bridge.spec.tsx +10 -10
  3. package/__tests__/createLazyComponent.spec.tsx +209 -0
  4. package/__tests__/prefetch.spec.ts +156 -0
  5. package/__tests__/router.spec.tsx +3 -3
  6. package/__tests__/setupTests.ts +8 -0
  7. package/dist/{bridge-base-P6pEjY1q.js → bridge-base-BoshEggF.mjs} +1 -1
  8. package/dist/{bridge-base-BBH982Tz.cjs → bridge-base-UGCwcMnG.js} +1 -1
  9. package/dist/data-fetch-server-middleware.cjs.js +163 -0
  10. package/dist/data-fetch-server-middleware.d.ts +15 -0
  11. package/dist/data-fetch-server-middleware.es.js +164 -0
  12. package/dist/data-fetch-utils.cjs.js +24 -0
  13. package/dist/data-fetch-utils.d.ts +81 -0
  14. package/dist/data-fetch-utils.es.js +26 -0
  15. package/dist/index-C0fDZB5b.js +45 -0
  16. package/dist/index-CqxytsLY.mjs +46 -0
  17. package/dist/index.cjs.js +35 -9
  18. package/dist/index.d.ts +141 -1
  19. package/dist/index.es.js +39 -13
  20. package/dist/index.esm-BCeUd-x9.mjs +418 -0
  21. package/dist/index.esm-j_1sIRzg.js +417 -0
  22. package/dist/lazy-load-component-plugin-B80Ud11k.js +521 -0
  23. package/dist/lazy-load-component-plugin-_UbR2mWQ.mjs +522 -0
  24. package/dist/lazy-load-component-plugin.cjs.js +6 -0
  25. package/dist/lazy-load-component-plugin.d.ts +16 -0
  26. package/dist/lazy-load-component-plugin.es.js +6 -0
  27. package/dist/lazy-utils.cjs.js +24 -0
  28. package/dist/lazy-utils.d.ts +149 -0
  29. package/dist/lazy-utils.es.js +24 -0
  30. package/dist/plugin.d.ts +13 -4
  31. package/dist/prefetch-BaKIdUwP.js +1338 -0
  32. package/dist/prefetch-YpJYjpWC.mjs +1339 -0
  33. package/dist/router-v5.cjs.js +1 -1
  34. package/dist/router-v5.d.ts +9 -0
  35. package/dist/router-v5.es.js +1 -1
  36. package/dist/router-v6.cjs.js +1 -1
  37. package/dist/router-v6.d.ts +9 -0
  38. package/dist/router-v6.es.js +1 -1
  39. package/dist/router.cjs.js +1 -1
  40. package/dist/router.d.ts +9 -0
  41. package/dist/router.es.js +1 -1
  42. package/dist/utils-C4oPJV34.mjs +2016 -0
  43. package/dist/utils-iEVlDmyk.js +2015 -0
  44. package/dist/v18.cjs.js +1 -1
  45. package/dist/v18.d.ts +9 -0
  46. package/dist/v18.es.js +1 -1
  47. package/dist/v19.cjs.js +1 -1
  48. package/dist/v19.d.ts +9 -0
  49. package/dist/v19.es.js +1 -1
  50. package/jest.config.ts +21 -0
  51. package/package.json +48 -6
  52. package/project.json +4 -8
  53. package/src/index.ts +32 -1
  54. package/src/lazy/AwaitDataFetch.tsx +215 -0
  55. package/src/lazy/constant.ts +30 -0
  56. package/src/lazy/createLazyComponent.tsx +411 -0
  57. package/src/lazy/data-fetch/cache.ts +291 -0
  58. package/src/lazy/data-fetch/call-data-fetch.ts +13 -0
  59. package/src/lazy/data-fetch/data-fetch-server-middleware.ts +196 -0
  60. package/src/lazy/data-fetch/index.ts +16 -0
  61. package/src/lazy/data-fetch/inject-data-fetch.ts +109 -0
  62. package/src/lazy/data-fetch/prefetch.ts +106 -0
  63. package/src/lazy/data-fetch/runtime-plugin.ts +115 -0
  64. package/src/lazy/index.ts +35 -0
  65. package/src/lazy/logger.ts +6 -0
  66. package/src/lazy/types.ts +75 -0
  67. package/src/lazy/utils.ts +372 -0
  68. package/src/lazy/wrapNoSSR.tsx +10 -0
  69. package/src/plugins/lazy-load-component-plugin.spec.ts +21 -0
  70. package/src/plugins/lazy-load-component-plugin.ts +57 -0
  71. package/src/provider/plugin.ts +4 -4
  72. package/src/remote/component.tsx +3 -3
  73. package/src/remote/create.tsx +18 -5
  74. package/tsconfig.json +1 -1
  75. package/tsconfig.spec.json +26 -0
  76. package/vite.config.ts +13 -0
  77. package/vitest.config.ts +6 -1
  78. package/dist/index-Cv3p6r66.cjs +0 -235
  79. package/dist/index-D4yt7Udv.js +0 -236
  80. package/src/.eslintrc.js +0 -9
@@ -0,0 +1,2016 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
+ var __privateWrapper = (obj, member, setter, getter) => ({
13
+ set _(value) {
14
+ __privateSet(obj, member, value, setter);
15
+ },
16
+ get _() {
17
+ return __privateGet(obj, member, getter);
18
+ }
19
+ });
20
+ var _a, _constructing, _b, _c, _max, _maxSize, _dispose, _disposeAfter, _fetchMethod, _memoMethod, _size, _calculatedSize, _keyMap, _keyList, _valList, _next, _prev, _head, _tail, _free, _disposed, _sizes, _starts, _ttls, _hasDispose, _hasFetchMethod, _hasDisposeAfter, _LRUCache_instances, initializeTTLTracking_fn, _updateItemAge, _statusTTL, _setItemTTL, _isStale, initializeSizeTracking_fn, _removeItemSize, _addItemSize, _requireSize, indexes_fn, rindexes_fn, isValidIndex_fn, evict_fn, backgroundFetch_fn, isBackgroundFetch_fn, connect_fn, moveToTail_fn, delete_fn, clear_fn;
21
+ import { c as createLogger, i as isBrowserEnv, a as composeKeyWithSeparator } from "./index.esm-BCeUd-x9.mjs";
22
+ const PLUGIN_IDENTIFIER = "[ Module Federation React ]";
23
+ const DOWNGRADE_KEY = "_mfSSRDowngrade";
24
+ const DATA_FETCH_FUNCTION = "_mfDataFetch";
25
+ const FS_HREF = "_mfFSHref";
26
+ const ERROR_TYPE = {
27
+ DATA_FETCH: 1,
28
+ LOAD_REMOTE: 2,
29
+ UNKNOWN: 3
30
+ };
31
+ const WRAP_DATA_FETCH_ID_IDENTIFIER = "wrap_dfip_identifier";
32
+ var MF_DATA_FETCH_TYPE = /* @__PURE__ */ ((MF_DATA_FETCH_TYPE2) => {
33
+ MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2["FETCH_SERVER"] = 1] = "FETCH_SERVER";
34
+ MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2["FETCH_CLIENT"] = 2] = "FETCH_CLIENT";
35
+ return MF_DATA_FETCH_TYPE2;
36
+ })(MF_DATA_FETCH_TYPE || {});
37
+ var MF_DATA_FETCH_STATUS = /* @__PURE__ */ ((MF_DATA_FETCH_STATUS2) => {
38
+ MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["LOADED"] = 1] = "LOADED";
39
+ MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["LOADING"] = 2] = "LOADING";
40
+ MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["AWAIT"] = 0] = "AWAIT";
41
+ MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["ERROR"] = 3] = "ERROR";
42
+ return MF_DATA_FETCH_STATUS2;
43
+ })(MF_DATA_FETCH_STATUS || {});
44
+ const DATA_FETCH_IDENTIFIER = "data";
45
+ const DATA_FETCH_CLIENT_SUFFIX = ".client";
46
+ const DATA_FETCH_QUERY = "x-mf-data-fetch";
47
+ const DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
48
+ const LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
49
+ const logger = createLogger(PLUGIN_IDENTIFIER);
50
+ const perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
51
+ const warned = /* @__PURE__ */ new Set();
52
+ const PROCESS = typeof process === "object" && !!process ? process : {};
53
+ const emitWarning = (msg, type, code, fn) => {
54
+ typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
55
+ };
56
+ let AC = globalThis.AbortController;
57
+ let AS = globalThis.AbortSignal;
58
+ if (typeof AC === "undefined") {
59
+ AS = class AbortSignal {
60
+ constructor() {
61
+ __publicField(this, "onabort");
62
+ __publicField(this, "_onabort", []);
63
+ __publicField(this, "reason");
64
+ __publicField(this, "aborted", false);
65
+ }
66
+ addEventListener(_, fn) {
67
+ this._onabort.push(fn);
68
+ }
69
+ };
70
+ AC = class AbortController {
71
+ constructor() {
72
+ __publicField(this, "signal", new AS());
73
+ warnACPolyfill();
74
+ }
75
+ abort(reason) {
76
+ var _a2, _b2;
77
+ if (this.signal.aborted)
78
+ return;
79
+ this.signal.reason = reason;
80
+ this.signal.aborted = true;
81
+ for (const fn of this.signal._onabort) {
82
+ fn(reason);
83
+ }
84
+ (_b2 = (_a2 = this.signal).onabort) == null ? void 0 : _b2.call(_a2, reason);
85
+ }
86
+ };
87
+ let printACPolyfillWarning = ((_a = PROCESS.env) == null ? void 0 : _a.LRU_CACHE_IGNORE_AC_WARNING) !== "1";
88
+ const warnACPolyfill = () => {
89
+ if (!printACPolyfillWarning)
90
+ return;
91
+ printACPolyfillWarning = false;
92
+ 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);
93
+ };
94
+ }
95
+ const shouldWarn = (code) => !warned.has(code);
96
+ const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
97
+ const 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;
98
+ class ZeroArray extends Array {
99
+ constructor(size) {
100
+ super(size);
101
+ this.fill(0);
102
+ }
103
+ }
104
+ const _Stack = class _Stack {
105
+ constructor(max, HeapCls) {
106
+ __publicField(this, "heap");
107
+ __publicField(this, "length");
108
+ if (!__privateGet(_Stack, _constructing)) {
109
+ throw new TypeError("instantiate Stack using Stack.create(n)");
110
+ }
111
+ this.heap = new HeapCls(max);
112
+ this.length = 0;
113
+ }
114
+ static create(max) {
115
+ const HeapCls = getUintArray(max);
116
+ if (!HeapCls)
117
+ return [];
118
+ __privateSet(_Stack, _constructing, true);
119
+ const s = new _Stack(max, HeapCls);
120
+ __privateSet(_Stack, _constructing, false);
121
+ return s;
122
+ }
123
+ push(n) {
124
+ this.heap[this.length++] = n;
125
+ }
126
+ pop() {
127
+ return this.heap[--this.length];
128
+ }
129
+ };
130
+ _constructing = new WeakMap();
131
+ // private constructor
132
+ __privateAdd(_Stack, _constructing, false);
133
+ let Stack = _Stack;
134
+ const _LRUCache = class _LRUCache {
135
+ constructor(options) {
136
+ __privateAdd(this, _LRUCache_instances);
137
+ // options that cannot be changed without disaster
138
+ __privateAdd(this, _max);
139
+ __privateAdd(this, _maxSize);
140
+ __privateAdd(this, _dispose);
141
+ __privateAdd(this, _disposeAfter);
142
+ __privateAdd(this, _fetchMethod);
143
+ __privateAdd(this, _memoMethod);
144
+ /**
145
+ * {@link LRUCache.OptionsBase.ttl}
146
+ */
147
+ __publicField(this, "ttl");
148
+ /**
149
+ * {@link LRUCache.OptionsBase.ttlResolution}
150
+ */
151
+ __publicField(this, "ttlResolution");
152
+ /**
153
+ * {@link LRUCache.OptionsBase.ttlAutopurge}
154
+ */
155
+ __publicField(this, "ttlAutopurge");
156
+ /**
157
+ * {@link LRUCache.OptionsBase.updateAgeOnGet}
158
+ */
159
+ __publicField(this, "updateAgeOnGet");
160
+ /**
161
+ * {@link LRUCache.OptionsBase.updateAgeOnHas}
162
+ */
163
+ __publicField(this, "updateAgeOnHas");
164
+ /**
165
+ * {@link LRUCache.OptionsBase.allowStale}
166
+ */
167
+ __publicField(this, "allowStale");
168
+ /**
169
+ * {@link LRUCache.OptionsBase.noDisposeOnSet}
170
+ */
171
+ __publicField(this, "noDisposeOnSet");
172
+ /**
173
+ * {@link LRUCache.OptionsBase.noUpdateTTL}
174
+ */
175
+ __publicField(this, "noUpdateTTL");
176
+ /**
177
+ * {@link LRUCache.OptionsBase.maxEntrySize}
178
+ */
179
+ __publicField(this, "maxEntrySize");
180
+ /**
181
+ * {@link LRUCache.OptionsBase.sizeCalculation}
182
+ */
183
+ __publicField(this, "sizeCalculation");
184
+ /**
185
+ * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
186
+ */
187
+ __publicField(this, "noDeleteOnFetchRejection");
188
+ /**
189
+ * {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
190
+ */
191
+ __publicField(this, "noDeleteOnStaleGet");
192
+ /**
193
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
194
+ */
195
+ __publicField(this, "allowStaleOnFetchAbort");
196
+ /**
197
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
198
+ */
199
+ __publicField(this, "allowStaleOnFetchRejection");
200
+ /**
201
+ * {@link LRUCache.OptionsBase.ignoreFetchAbort}
202
+ */
203
+ __publicField(this, "ignoreFetchAbort");
204
+ // computed properties
205
+ __privateAdd(this, _size);
206
+ __privateAdd(this, _calculatedSize);
207
+ __privateAdd(this, _keyMap);
208
+ __privateAdd(this, _keyList);
209
+ __privateAdd(this, _valList);
210
+ __privateAdd(this, _next);
211
+ __privateAdd(this, _prev);
212
+ __privateAdd(this, _head);
213
+ __privateAdd(this, _tail);
214
+ __privateAdd(this, _free);
215
+ __privateAdd(this, _disposed);
216
+ __privateAdd(this, _sizes);
217
+ __privateAdd(this, _starts);
218
+ __privateAdd(this, _ttls);
219
+ __privateAdd(this, _hasDispose);
220
+ __privateAdd(this, _hasFetchMethod);
221
+ __privateAdd(this, _hasDisposeAfter);
222
+ // conditionally set private methods related to TTL
223
+ __privateAdd(this, _updateItemAge, () => {
224
+ });
225
+ __privateAdd(this, _statusTTL, () => {
226
+ });
227
+ __privateAdd(this, _setItemTTL, () => {
228
+ });
229
+ /* c8 ignore stop */
230
+ __privateAdd(this, _isStale, () => false);
231
+ __privateAdd(this, _removeItemSize, (_i) => {
232
+ });
233
+ __privateAdd(this, _addItemSize, (_i, _s, _st) => {
234
+ });
235
+ __privateAdd(this, _requireSize, (_k, _v, size, sizeCalculation) => {
236
+ if (size || sizeCalculation) {
237
+ throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
238
+ }
239
+ return 0;
240
+ });
241
+ /**
242
+ * A String value that is used in the creation of the default string
243
+ * description of an object. Called by the built-in method
244
+ * `Object.prototype.toString`.
245
+ */
246
+ __publicField(this, _b, "LRUCache");
247
+ const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
248
+ if (max !== 0 && !isPosInt(max)) {
249
+ throw new TypeError("max option must be a nonnegative integer");
250
+ }
251
+ const UintArray = max ? getUintArray(max) : Array;
252
+ if (!UintArray) {
253
+ throw new Error("invalid max value: " + max);
254
+ }
255
+ __privateSet(this, _max, max);
256
+ __privateSet(this, _maxSize, maxSize);
257
+ this.maxEntrySize = maxEntrySize || __privateGet(this, _maxSize);
258
+ this.sizeCalculation = sizeCalculation;
259
+ if (this.sizeCalculation) {
260
+ if (!__privateGet(this, _maxSize) && !this.maxEntrySize) {
261
+ throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
262
+ }
263
+ if (typeof this.sizeCalculation !== "function") {
264
+ throw new TypeError("sizeCalculation set to non-function");
265
+ }
266
+ }
267
+ if (memoMethod !== void 0 && typeof memoMethod !== "function") {
268
+ throw new TypeError("memoMethod must be a function if defined");
269
+ }
270
+ __privateSet(this, _memoMethod, memoMethod);
271
+ if (fetchMethod !== void 0 && typeof fetchMethod !== "function") {
272
+ throw new TypeError("fetchMethod must be a function if specified");
273
+ }
274
+ __privateSet(this, _fetchMethod, fetchMethod);
275
+ __privateSet(this, _hasFetchMethod, !!fetchMethod);
276
+ __privateSet(this, _keyMap, /* @__PURE__ */ new Map());
277
+ __privateSet(this, _keyList, new Array(max).fill(void 0));
278
+ __privateSet(this, _valList, new Array(max).fill(void 0));
279
+ __privateSet(this, _next, new UintArray(max));
280
+ __privateSet(this, _prev, new UintArray(max));
281
+ __privateSet(this, _head, 0);
282
+ __privateSet(this, _tail, 0);
283
+ __privateSet(this, _free, Stack.create(max));
284
+ __privateSet(this, _size, 0);
285
+ __privateSet(this, _calculatedSize, 0);
286
+ if (typeof dispose === "function") {
287
+ __privateSet(this, _dispose, dispose);
288
+ }
289
+ if (typeof disposeAfter === "function") {
290
+ __privateSet(this, _disposeAfter, disposeAfter);
291
+ __privateSet(this, _disposed, []);
292
+ } else {
293
+ __privateSet(this, _disposeAfter, void 0);
294
+ __privateSet(this, _disposed, void 0);
295
+ }
296
+ __privateSet(this, _hasDispose, !!__privateGet(this, _dispose));
297
+ __privateSet(this, _hasDisposeAfter, !!__privateGet(this, _disposeAfter));
298
+ this.noDisposeOnSet = !!noDisposeOnSet;
299
+ this.noUpdateTTL = !!noUpdateTTL;
300
+ this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
301
+ this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
302
+ this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
303
+ this.ignoreFetchAbort = !!ignoreFetchAbort;
304
+ if (this.maxEntrySize !== 0) {
305
+ if (__privateGet(this, _maxSize) !== 0) {
306
+ if (!isPosInt(__privateGet(this, _maxSize))) {
307
+ throw new TypeError("maxSize must be a positive integer if specified");
308
+ }
309
+ }
310
+ if (!isPosInt(this.maxEntrySize)) {
311
+ throw new TypeError("maxEntrySize must be a positive integer if specified");
312
+ }
313
+ __privateMethod(this, _LRUCache_instances, initializeSizeTracking_fn).call(this);
314
+ }
315
+ this.allowStale = !!allowStale;
316
+ this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
317
+ this.updateAgeOnGet = !!updateAgeOnGet;
318
+ this.updateAgeOnHas = !!updateAgeOnHas;
319
+ this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
320
+ this.ttlAutopurge = !!ttlAutopurge;
321
+ this.ttl = ttl || 0;
322
+ if (this.ttl) {
323
+ if (!isPosInt(this.ttl)) {
324
+ throw new TypeError("ttl must be a positive integer if specified");
325
+ }
326
+ __privateMethod(this, _LRUCache_instances, initializeTTLTracking_fn).call(this);
327
+ }
328
+ if (__privateGet(this, _max) === 0 && this.ttl === 0 && __privateGet(this, _maxSize) === 0) {
329
+ throw new TypeError("At least one of max, maxSize, or ttl is required");
330
+ }
331
+ if (!this.ttlAutopurge && !__privateGet(this, _max) && !__privateGet(this, _maxSize)) {
332
+ const code = "LRU_CACHE_UNBOUNDED";
333
+ if (shouldWarn(code)) {
334
+ warned.add(code);
335
+ const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
336
+ emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache);
337
+ }
338
+ }
339
+ }
340
+ /**
341
+ * Do not call this method unless you need to inspect the
342
+ * inner workings of the cache. If anything returned by this
343
+ * object is modified in any way, strange breakage may occur.
344
+ *
345
+ * These fields are private for a reason!
346
+ *
347
+ * @internal
348
+ */
349
+ static unsafeExposeInternals(c) {
350
+ return {
351
+ // properties
352
+ starts: __privateGet(c, _starts),
353
+ ttls: __privateGet(c, _ttls),
354
+ sizes: __privateGet(c, _sizes),
355
+ keyMap: __privateGet(c, _keyMap),
356
+ keyList: __privateGet(c, _keyList),
357
+ valList: __privateGet(c, _valList),
358
+ next: __privateGet(c, _next),
359
+ prev: __privateGet(c, _prev),
360
+ get head() {
361
+ return __privateGet(c, _head);
362
+ },
363
+ get tail() {
364
+ return __privateGet(c, _tail);
365
+ },
366
+ free: __privateGet(c, _free),
367
+ // methods
368
+ isBackgroundFetch: (p) => {
369
+ var _a2;
370
+ return __privateMethod(_a2 = c, _LRUCache_instances, isBackgroundFetch_fn).call(_a2, p);
371
+ },
372
+ backgroundFetch: (k, index, options, context) => {
373
+ var _a2;
374
+ return __privateMethod(_a2 = c, _LRUCache_instances, backgroundFetch_fn).call(_a2, k, index, options, context);
375
+ },
376
+ moveToTail: (index) => {
377
+ var _a2;
378
+ return __privateMethod(_a2 = c, _LRUCache_instances, moveToTail_fn).call(_a2, index);
379
+ },
380
+ indexes: (options) => {
381
+ var _a2;
382
+ return __privateMethod(_a2 = c, _LRUCache_instances, indexes_fn).call(_a2, options);
383
+ },
384
+ rindexes: (options) => {
385
+ var _a2;
386
+ return __privateMethod(_a2 = c, _LRUCache_instances, rindexes_fn).call(_a2, options);
387
+ },
388
+ isStale: (index) => {
389
+ var _a2;
390
+ return __privateGet(_a2 = c, _isStale).call(_a2, index);
391
+ }
392
+ };
393
+ }
394
+ // Protected read-only members
395
+ /**
396
+ * {@link LRUCache.OptionsBase.max} (read-only)
397
+ */
398
+ get max() {
399
+ return __privateGet(this, _max);
400
+ }
401
+ /**
402
+ * {@link LRUCache.OptionsBase.maxSize} (read-only)
403
+ */
404
+ get maxSize() {
405
+ return __privateGet(this, _maxSize);
406
+ }
407
+ /**
408
+ * The total computed size of items in the cache (read-only)
409
+ */
410
+ get calculatedSize() {
411
+ return __privateGet(this, _calculatedSize);
412
+ }
413
+ /**
414
+ * The number of items stored in the cache (read-only)
415
+ */
416
+ get size() {
417
+ return __privateGet(this, _size);
418
+ }
419
+ /**
420
+ * {@link LRUCache.OptionsBase.fetchMethod} (read-only)
421
+ */
422
+ get fetchMethod() {
423
+ return __privateGet(this, _fetchMethod);
424
+ }
425
+ get memoMethod() {
426
+ return __privateGet(this, _memoMethod);
427
+ }
428
+ /**
429
+ * {@link LRUCache.OptionsBase.dispose} (read-only)
430
+ */
431
+ get dispose() {
432
+ return __privateGet(this, _dispose);
433
+ }
434
+ /**
435
+ * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
436
+ */
437
+ get disposeAfter() {
438
+ return __privateGet(this, _disposeAfter);
439
+ }
440
+ /**
441
+ * Return the number of ms left in the item's TTL. If item is not in cache,
442
+ * returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
443
+ */
444
+ getRemainingTTL(key) {
445
+ return __privateGet(this, _keyMap).has(key) ? Infinity : 0;
446
+ }
447
+ /**
448
+ * Return a generator yielding `[key, value]` pairs,
449
+ * in order from most recently used to least recently used.
450
+ */
451
+ *entries() {
452
+ for (const i of __privateMethod(this, _LRUCache_instances, indexes_fn).call(this)) {
453
+ if (__privateGet(this, _valList)[i] !== void 0 && __privateGet(this, _keyList)[i] !== void 0 && !__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, __privateGet(this, _valList)[i])) {
454
+ yield [__privateGet(this, _keyList)[i], __privateGet(this, _valList)[i]];
455
+ }
456
+ }
457
+ }
458
+ /**
459
+ * Inverse order version of {@link LRUCache.entries}
460
+ *
461
+ * Return a generator yielding `[key, value]` pairs,
462
+ * in order from least recently used to most recently used.
463
+ */
464
+ *rentries() {
465
+ for (const i of __privateMethod(this, _LRUCache_instances, rindexes_fn).call(this)) {
466
+ if (__privateGet(this, _valList)[i] !== void 0 && __privateGet(this, _keyList)[i] !== void 0 && !__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, __privateGet(this, _valList)[i])) {
467
+ yield [__privateGet(this, _keyList)[i], __privateGet(this, _valList)[i]];
468
+ }
469
+ }
470
+ }
471
+ /**
472
+ * Return a generator yielding the keys in the cache,
473
+ * in order from most recently used to least recently used.
474
+ */
475
+ *keys() {
476
+ for (const i of __privateMethod(this, _LRUCache_instances, indexes_fn).call(this)) {
477
+ const k = __privateGet(this, _keyList)[i];
478
+ if (k !== void 0 && !__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, __privateGet(this, _valList)[i])) {
479
+ yield k;
480
+ }
481
+ }
482
+ }
483
+ /**
484
+ * Inverse order version of {@link LRUCache.keys}
485
+ *
486
+ * Return a generator yielding the keys in the cache,
487
+ * in order from least recently used to most recently used.
488
+ */
489
+ *rkeys() {
490
+ for (const i of __privateMethod(this, _LRUCache_instances, rindexes_fn).call(this)) {
491
+ const k = __privateGet(this, _keyList)[i];
492
+ if (k !== void 0 && !__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, __privateGet(this, _valList)[i])) {
493
+ yield k;
494
+ }
495
+ }
496
+ }
497
+ /**
498
+ * Return a generator yielding the values in the cache,
499
+ * in order from most recently used to least recently used.
500
+ */
501
+ *values() {
502
+ for (const i of __privateMethod(this, _LRUCache_instances, indexes_fn).call(this)) {
503
+ const v = __privateGet(this, _valList)[i];
504
+ if (v !== void 0 && !__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, __privateGet(this, _valList)[i])) {
505
+ yield __privateGet(this, _valList)[i];
506
+ }
507
+ }
508
+ }
509
+ /**
510
+ * Inverse order version of {@link LRUCache.values}
511
+ *
512
+ * Return a generator yielding the values in the cache,
513
+ * in order from least recently used to most recently used.
514
+ */
515
+ *rvalues() {
516
+ for (const i of __privateMethod(this, _LRUCache_instances, rindexes_fn).call(this)) {
517
+ const v = __privateGet(this, _valList)[i];
518
+ if (v !== void 0 && !__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, __privateGet(this, _valList)[i])) {
519
+ yield __privateGet(this, _valList)[i];
520
+ }
521
+ }
522
+ }
523
+ /**
524
+ * Iterating over the cache itself yields the same results as
525
+ * {@link LRUCache.entries}
526
+ */
527
+ [(_c = Symbol.iterator, _b = Symbol.toStringTag, _c)]() {
528
+ return this.entries();
529
+ }
530
+ /**
531
+ * Find a value for which the supplied fn method returns a truthy value,
532
+ * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
533
+ */
534
+ find(fn, getOptions = {}) {
535
+ for (const i of __privateMethod(this, _LRUCache_instances, indexes_fn).call(this)) {
536
+ const v = __privateGet(this, _valList)[i];
537
+ const value = __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v) ? v.__staleWhileFetching : v;
538
+ if (value === void 0)
539
+ continue;
540
+ if (fn(value, __privateGet(this, _keyList)[i], this)) {
541
+ return this.get(__privateGet(this, _keyList)[i], getOptions);
542
+ }
543
+ }
544
+ }
545
+ /**
546
+ * Call the supplied function on each item in the cache, in order from most
547
+ * recently used to least recently used.
548
+ *
549
+ * `fn` is called as `fn(value, key, cache)`.
550
+ *
551
+ * If `thisp` is provided, function will be called in the `this`-context of
552
+ * the provided object, or the cache if no `thisp` object is provided.
553
+ *
554
+ * Does not update age or recenty of use, or iterate over stale values.
555
+ */
556
+ forEach(fn, thisp = this) {
557
+ for (const i of __privateMethod(this, _LRUCache_instances, indexes_fn).call(this)) {
558
+ const v = __privateGet(this, _valList)[i];
559
+ const value = __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v) ? v.__staleWhileFetching : v;
560
+ if (value === void 0)
561
+ continue;
562
+ fn.call(thisp, value, __privateGet(this, _keyList)[i], this);
563
+ }
564
+ }
565
+ /**
566
+ * The same as {@link LRUCache.forEach} but items are iterated over in
567
+ * reverse order. (ie, less recently used items are iterated over first.)
568
+ */
569
+ rforEach(fn, thisp = this) {
570
+ for (const i of __privateMethod(this, _LRUCache_instances, rindexes_fn).call(this)) {
571
+ const v = __privateGet(this, _valList)[i];
572
+ const value = __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v) ? v.__staleWhileFetching : v;
573
+ if (value === void 0)
574
+ continue;
575
+ fn.call(thisp, value, __privateGet(this, _keyList)[i], this);
576
+ }
577
+ }
578
+ /**
579
+ * Delete any stale entries. Returns true if anything was removed,
580
+ * false otherwise.
581
+ */
582
+ purgeStale() {
583
+ let deleted = false;
584
+ for (const i of __privateMethod(this, _LRUCache_instances, rindexes_fn).call(this, { allowStale: true })) {
585
+ if (__privateGet(this, _isStale).call(this, i)) {
586
+ __privateMethod(this, _LRUCache_instances, delete_fn).call(this, __privateGet(this, _keyList)[i], "expire");
587
+ deleted = true;
588
+ }
589
+ }
590
+ return deleted;
591
+ }
592
+ /**
593
+ * Get the extended info about a given entry, to get its value, size, and
594
+ * TTL info simultaneously. Returns `undefined` if the key is not present.
595
+ *
596
+ * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
597
+ * serialization, the `start` value is always the current timestamp, and the
598
+ * `ttl` is a calculated remaining time to live (negative if expired).
599
+ *
600
+ * Always returns stale values, if their info is found in the cache, so be
601
+ * sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
602
+ * if relevant.
603
+ */
604
+ info(key) {
605
+ const i = __privateGet(this, _keyMap).get(key);
606
+ if (i === void 0)
607
+ return void 0;
608
+ const v = __privateGet(this, _valList)[i];
609
+ const value = __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v) ? v.__staleWhileFetching : v;
610
+ if (value === void 0)
611
+ return void 0;
612
+ const entry = { value };
613
+ if (__privateGet(this, _ttls) && __privateGet(this, _starts)) {
614
+ const ttl = __privateGet(this, _ttls)[i];
615
+ const start = __privateGet(this, _starts)[i];
616
+ if (ttl && start) {
617
+ const remain = ttl - (perf.now() - start);
618
+ entry.ttl = remain;
619
+ entry.start = Date.now();
620
+ }
621
+ }
622
+ if (__privateGet(this, _sizes)) {
623
+ entry.size = __privateGet(this, _sizes)[i];
624
+ }
625
+ return entry;
626
+ }
627
+ /**
628
+ * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
629
+ * passed to {@link LRLUCache#load}.
630
+ *
631
+ * The `start` fields are calculated relative to a portable `Date.now()`
632
+ * timestamp, even if `performance.now()` is available.
633
+ *
634
+ * Stale entries are always included in the `dump`, even if
635
+ * {@link LRUCache.OptionsBase.allowStale} is false.
636
+ *
637
+ * Note: this returns an actual array, not a generator, so it can be more
638
+ * easily passed around.
639
+ */
640
+ dump() {
641
+ const arr = [];
642
+ for (const i of __privateMethod(this, _LRUCache_instances, indexes_fn).call(this, { allowStale: true })) {
643
+ const key = __privateGet(this, _keyList)[i];
644
+ const v = __privateGet(this, _valList)[i];
645
+ const value = __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v) ? v.__staleWhileFetching : v;
646
+ if (value === void 0 || key === void 0)
647
+ continue;
648
+ const entry = { value };
649
+ if (__privateGet(this, _ttls) && __privateGet(this, _starts)) {
650
+ entry.ttl = __privateGet(this, _ttls)[i];
651
+ const age = perf.now() - __privateGet(this, _starts)[i];
652
+ entry.start = Math.floor(Date.now() - age);
653
+ }
654
+ if (__privateGet(this, _sizes)) {
655
+ entry.size = __privateGet(this, _sizes)[i];
656
+ }
657
+ arr.unshift([key, entry]);
658
+ }
659
+ return arr;
660
+ }
661
+ /**
662
+ * Reset the cache and load in the items in entries in the order listed.
663
+ *
664
+ * The shape of the resulting cache may be different if the same options are
665
+ * not used in both caches.
666
+ *
667
+ * The `start` fields are assumed to be calculated relative to a portable
668
+ * `Date.now()` timestamp, even if `performance.now()` is available.
669
+ */
670
+ load(arr) {
671
+ this.clear();
672
+ for (const [key, entry] of arr) {
673
+ if (entry.start) {
674
+ const age = Date.now() - entry.start;
675
+ entry.start = perf.now() - age;
676
+ }
677
+ this.set(key, entry.value, entry);
678
+ }
679
+ }
680
+ /**
681
+ * Add a value to the cache.
682
+ *
683
+ * Note: if `undefined` is specified as a value, this is an alias for
684
+ * {@link LRUCache#delete}
685
+ *
686
+ * Fields on the {@link LRUCache.SetOptions} options param will override
687
+ * their corresponding values in the constructor options for the scope
688
+ * of this single `set()` operation.
689
+ *
690
+ * If `start` is provided, then that will set the effective start
691
+ * time for the TTL calculation. Note that this must be a previous
692
+ * value of `performance.now()` if supported, or a previous value of
693
+ * `Date.now()` if not.
694
+ *
695
+ * Options object may also include `size`, which will prevent
696
+ * calling the `sizeCalculation` function and just use the specified
697
+ * number if it is a positive integer, and `noDisposeOnSet` which
698
+ * will prevent calling a `dispose` function in the case of
699
+ * overwrites.
700
+ *
701
+ * If the `size` (or return value of `sizeCalculation`) for a given
702
+ * entry is greater than `maxEntrySize`, then the item will not be
703
+ * added to the cache.
704
+ *
705
+ * Will update the recency of the entry.
706
+ *
707
+ * If the value is `undefined`, then this is an alias for
708
+ * `cache.delete(key)`. `undefined` is never stored in the cache.
709
+ */
710
+ set(k, v, setOptions = {}) {
711
+ var _a2, _b2, _c2, _d, _e;
712
+ if (v === void 0) {
713
+ this.delete(k);
714
+ return this;
715
+ }
716
+ const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status } = setOptions;
717
+ let { noUpdateTTL = this.noUpdateTTL } = setOptions;
718
+ const size = __privateGet(this, _requireSize).call(this, k, v, setOptions.size || 0, sizeCalculation);
719
+ if (this.maxEntrySize && size > this.maxEntrySize) {
720
+ if (status) {
721
+ status.set = "miss";
722
+ status.maxEntrySizeExceeded = true;
723
+ }
724
+ __privateMethod(this, _LRUCache_instances, delete_fn).call(this, k, "set");
725
+ return this;
726
+ }
727
+ let index = __privateGet(this, _size) === 0 ? void 0 : __privateGet(this, _keyMap).get(k);
728
+ if (index === void 0) {
729
+ index = __privateGet(this, _size) === 0 ? __privateGet(this, _tail) : __privateGet(this, _free).length !== 0 ? __privateGet(this, _free).pop() : __privateGet(this, _size) === __privateGet(this, _max) ? __privateMethod(this, _LRUCache_instances, evict_fn).call(this, false) : __privateGet(this, _size);
730
+ __privateGet(this, _keyList)[index] = k;
731
+ __privateGet(this, _valList)[index] = v;
732
+ __privateGet(this, _keyMap).set(k, index);
733
+ __privateGet(this, _next)[__privateGet(this, _tail)] = index;
734
+ __privateGet(this, _prev)[index] = __privateGet(this, _tail);
735
+ __privateSet(this, _tail, index);
736
+ __privateWrapper(this, _size)._++;
737
+ __privateGet(this, _addItemSize).call(this, index, size, status);
738
+ if (status)
739
+ status.set = "add";
740
+ noUpdateTTL = false;
741
+ } else {
742
+ __privateMethod(this, _LRUCache_instances, moveToTail_fn).call(this, index);
743
+ const oldVal = __privateGet(this, _valList)[index];
744
+ if (v !== oldVal) {
745
+ if (__privateGet(this, _hasFetchMethod) && __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, oldVal)) {
746
+ oldVal.__abortController.abort(new Error("replaced"));
747
+ const { __staleWhileFetching: s } = oldVal;
748
+ if (s !== void 0 && !noDisposeOnSet) {
749
+ if (__privateGet(this, _hasDispose)) {
750
+ (_a2 = __privateGet(this, _dispose)) == null ? void 0 : _a2.call(this, s, k, "set");
751
+ }
752
+ if (__privateGet(this, _hasDisposeAfter)) {
753
+ (_b2 = __privateGet(this, _disposed)) == null ? void 0 : _b2.push([s, k, "set"]);
754
+ }
755
+ }
756
+ } else if (!noDisposeOnSet) {
757
+ if (__privateGet(this, _hasDispose)) {
758
+ (_c2 = __privateGet(this, _dispose)) == null ? void 0 : _c2.call(this, oldVal, k, "set");
759
+ }
760
+ if (__privateGet(this, _hasDisposeAfter)) {
761
+ (_d = __privateGet(this, _disposed)) == null ? void 0 : _d.push([oldVal, k, "set"]);
762
+ }
763
+ }
764
+ __privateGet(this, _removeItemSize).call(this, index);
765
+ __privateGet(this, _addItemSize).call(this, index, size, status);
766
+ __privateGet(this, _valList)[index] = v;
767
+ if (status) {
768
+ status.set = "replace";
769
+ const oldValue = oldVal && __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, oldVal) ? oldVal.__staleWhileFetching : oldVal;
770
+ if (oldValue !== void 0)
771
+ status.oldValue = oldValue;
772
+ }
773
+ } else if (status) {
774
+ status.set = "update";
775
+ }
776
+ }
777
+ if (ttl !== 0 && !__privateGet(this, _ttls)) {
778
+ __privateMethod(this, _LRUCache_instances, initializeTTLTracking_fn).call(this);
779
+ }
780
+ if (__privateGet(this, _ttls)) {
781
+ if (!noUpdateTTL) {
782
+ __privateGet(this, _setItemTTL).call(this, index, ttl, start);
783
+ }
784
+ if (status)
785
+ __privateGet(this, _statusTTL).call(this, status, index);
786
+ }
787
+ if (!noDisposeOnSet && __privateGet(this, _hasDisposeAfter) && __privateGet(this, _disposed)) {
788
+ const dt = __privateGet(this, _disposed);
789
+ let task;
790
+ while (task = dt == null ? void 0 : dt.shift()) {
791
+ (_e = __privateGet(this, _disposeAfter)) == null ? void 0 : _e.call(this, ...task);
792
+ }
793
+ }
794
+ return this;
795
+ }
796
+ /**
797
+ * Evict the least recently used item, returning its value or
798
+ * `undefined` if cache is empty.
799
+ */
800
+ pop() {
801
+ var _a2;
802
+ try {
803
+ while (__privateGet(this, _size)) {
804
+ const val = __privateGet(this, _valList)[__privateGet(this, _head)];
805
+ __privateMethod(this, _LRUCache_instances, evict_fn).call(this, true);
806
+ if (__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, val)) {
807
+ if (val.__staleWhileFetching) {
808
+ return val.__staleWhileFetching;
809
+ }
810
+ } else if (val !== void 0) {
811
+ return val;
812
+ }
813
+ }
814
+ } finally {
815
+ if (__privateGet(this, _hasDisposeAfter) && __privateGet(this, _disposed)) {
816
+ const dt = __privateGet(this, _disposed);
817
+ let task;
818
+ while (task = dt == null ? void 0 : dt.shift()) {
819
+ (_a2 = __privateGet(this, _disposeAfter)) == null ? void 0 : _a2.call(this, ...task);
820
+ }
821
+ }
822
+ }
823
+ }
824
+ /**
825
+ * Check if a key is in the cache, without updating the recency of use.
826
+ * Will return false if the item is stale, even though it is technically
827
+ * in the cache.
828
+ *
829
+ * Check if a key is in the cache, without updating the recency of
830
+ * use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
831
+ * to `true` in either the options or the constructor.
832
+ *
833
+ * Will return `false` if the item is stale, even though it is technically in
834
+ * the cache. The difference can be determined (if it matters) by using a
835
+ * `status` argument, and inspecting the `has` field.
836
+ *
837
+ * Will not update item age unless
838
+ * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
839
+ */
840
+ has(k, hasOptions = {}) {
841
+ const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
842
+ const index = __privateGet(this, _keyMap).get(k);
843
+ if (index !== void 0) {
844
+ const v = __privateGet(this, _valList)[index];
845
+ if (__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v) && v.__staleWhileFetching === void 0) {
846
+ return false;
847
+ }
848
+ if (!__privateGet(this, _isStale).call(this, index)) {
849
+ if (updateAgeOnHas) {
850
+ __privateGet(this, _updateItemAge).call(this, index);
851
+ }
852
+ if (status) {
853
+ status.has = "hit";
854
+ __privateGet(this, _statusTTL).call(this, status, index);
855
+ }
856
+ return true;
857
+ } else if (status) {
858
+ status.has = "stale";
859
+ __privateGet(this, _statusTTL).call(this, status, index);
860
+ }
861
+ } else if (status) {
862
+ status.has = "miss";
863
+ }
864
+ return false;
865
+ }
866
+ /**
867
+ * Like {@link LRUCache#get} but doesn't update recency or delete stale
868
+ * items.
869
+ *
870
+ * Returns `undefined` if the item is stale, unless
871
+ * {@link LRUCache.OptionsBase.allowStale} is set.
872
+ */
873
+ peek(k, peekOptions = {}) {
874
+ const { allowStale = this.allowStale } = peekOptions;
875
+ const index = __privateGet(this, _keyMap).get(k);
876
+ if (index === void 0 || !allowStale && __privateGet(this, _isStale).call(this, index)) {
877
+ return;
878
+ }
879
+ const v = __privateGet(this, _valList)[index];
880
+ return __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v) ? v.__staleWhileFetching : v;
881
+ }
882
+ async fetch(k, fetchOptions = {}) {
883
+ const {
884
+ // get options
885
+ allowStale = this.allowStale,
886
+ updateAgeOnGet = this.updateAgeOnGet,
887
+ noDeleteOnStaleGet = this.noDeleteOnStaleGet,
888
+ // set options
889
+ ttl = this.ttl,
890
+ noDisposeOnSet = this.noDisposeOnSet,
891
+ size = 0,
892
+ sizeCalculation = this.sizeCalculation,
893
+ noUpdateTTL = this.noUpdateTTL,
894
+ // fetch exclusive options
895
+ noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
896
+ allowStaleOnFetchRejection = this.allowStaleOnFetchRejection,
897
+ ignoreFetchAbort = this.ignoreFetchAbort,
898
+ allowStaleOnFetchAbort = this.allowStaleOnFetchAbort,
899
+ context,
900
+ forceRefresh = false,
901
+ status,
902
+ signal
903
+ } = fetchOptions;
904
+ if (!__privateGet(this, _hasFetchMethod)) {
905
+ if (status)
906
+ status.fetch = "get";
907
+ return this.get(k, {
908
+ allowStale,
909
+ updateAgeOnGet,
910
+ noDeleteOnStaleGet,
911
+ status
912
+ });
913
+ }
914
+ const options = {
915
+ allowStale,
916
+ updateAgeOnGet,
917
+ noDeleteOnStaleGet,
918
+ ttl,
919
+ noDisposeOnSet,
920
+ size,
921
+ sizeCalculation,
922
+ noUpdateTTL,
923
+ noDeleteOnFetchRejection,
924
+ allowStaleOnFetchRejection,
925
+ allowStaleOnFetchAbort,
926
+ ignoreFetchAbort,
927
+ status,
928
+ signal
929
+ };
930
+ let index = __privateGet(this, _keyMap).get(k);
931
+ if (index === void 0) {
932
+ if (status)
933
+ status.fetch = "miss";
934
+ const p = __privateMethod(this, _LRUCache_instances, backgroundFetch_fn).call(this, k, index, options, context);
935
+ return p.__returned = p;
936
+ } else {
937
+ const v = __privateGet(this, _valList)[index];
938
+ if (__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
939
+ const stale = allowStale && v.__staleWhileFetching !== void 0;
940
+ if (status) {
941
+ status.fetch = "inflight";
942
+ if (stale)
943
+ status.returnedStale = true;
944
+ }
945
+ return stale ? v.__staleWhileFetching : v.__returned = v;
946
+ }
947
+ const isStale = __privateGet(this, _isStale).call(this, index);
948
+ if (!forceRefresh && !isStale) {
949
+ if (status)
950
+ status.fetch = "hit";
951
+ __privateMethod(this, _LRUCache_instances, moveToTail_fn).call(this, index);
952
+ if (updateAgeOnGet) {
953
+ __privateGet(this, _updateItemAge).call(this, index);
954
+ }
955
+ if (status)
956
+ __privateGet(this, _statusTTL).call(this, status, index);
957
+ return v;
958
+ }
959
+ const p = __privateMethod(this, _LRUCache_instances, backgroundFetch_fn).call(this, k, index, options, context);
960
+ const hasStale = p.__staleWhileFetching !== void 0;
961
+ const staleVal = hasStale && allowStale;
962
+ if (status) {
963
+ status.fetch = isStale ? "stale" : "refresh";
964
+ if (staleVal && isStale)
965
+ status.returnedStale = true;
966
+ }
967
+ return staleVal ? p.__staleWhileFetching : p.__returned = p;
968
+ }
969
+ }
970
+ async forceFetch(k, fetchOptions = {}) {
971
+ const v = await this.fetch(k, fetchOptions);
972
+ if (v === void 0)
973
+ throw new Error("fetch() returned undefined");
974
+ return v;
975
+ }
976
+ memo(k, memoOptions = {}) {
977
+ const memoMethod = __privateGet(this, _memoMethod);
978
+ if (!memoMethod) {
979
+ throw new Error("no memoMethod provided to constructor");
980
+ }
981
+ const { context, forceRefresh, ...options } = memoOptions;
982
+ const v = this.get(k, options);
983
+ if (!forceRefresh && v !== void 0)
984
+ return v;
985
+ const vv = memoMethod(k, v, {
986
+ options,
987
+ context
988
+ });
989
+ this.set(k, vv, options);
990
+ return vv;
991
+ }
992
+ /**
993
+ * Return a value from the cache. Will update the recency of the cache
994
+ * entry found.
995
+ *
996
+ * If the key is not found, get() will return `undefined`.
997
+ */
998
+ get(k, getOptions = {}) {
999
+ const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status } = getOptions;
1000
+ const index = __privateGet(this, _keyMap).get(k);
1001
+ if (index !== void 0) {
1002
+ const value = __privateGet(this, _valList)[index];
1003
+ const fetching = __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, value);
1004
+ if (status)
1005
+ __privateGet(this, _statusTTL).call(this, status, index);
1006
+ if (__privateGet(this, _isStale).call(this, index)) {
1007
+ if (status)
1008
+ status.get = "stale";
1009
+ if (!fetching) {
1010
+ if (!noDeleteOnStaleGet) {
1011
+ __privateMethod(this, _LRUCache_instances, delete_fn).call(this, k, "expire");
1012
+ }
1013
+ if (status && allowStale)
1014
+ status.returnedStale = true;
1015
+ return allowStale ? value : void 0;
1016
+ } else {
1017
+ if (status && allowStale && value.__staleWhileFetching !== void 0) {
1018
+ status.returnedStale = true;
1019
+ }
1020
+ return allowStale ? value.__staleWhileFetching : void 0;
1021
+ }
1022
+ } else {
1023
+ if (status)
1024
+ status.get = "hit";
1025
+ if (fetching) {
1026
+ return value.__staleWhileFetching;
1027
+ }
1028
+ __privateMethod(this, _LRUCache_instances, moveToTail_fn).call(this, index);
1029
+ if (updateAgeOnGet) {
1030
+ __privateGet(this, _updateItemAge).call(this, index);
1031
+ }
1032
+ return value;
1033
+ }
1034
+ } else if (status) {
1035
+ status.get = "miss";
1036
+ }
1037
+ }
1038
+ /**
1039
+ * Deletes a key out of the cache.
1040
+ *
1041
+ * Returns true if the key was deleted, false otherwise.
1042
+ */
1043
+ delete(k) {
1044
+ return __privateMethod(this, _LRUCache_instances, delete_fn).call(this, k, "delete");
1045
+ }
1046
+ /**
1047
+ * Clear the cache entirely, throwing away all values.
1048
+ */
1049
+ clear() {
1050
+ return __privateMethod(this, _LRUCache_instances, clear_fn).call(this, "delete");
1051
+ }
1052
+ };
1053
+ _max = new WeakMap();
1054
+ _maxSize = new WeakMap();
1055
+ _dispose = new WeakMap();
1056
+ _disposeAfter = new WeakMap();
1057
+ _fetchMethod = new WeakMap();
1058
+ _memoMethod = new WeakMap();
1059
+ _size = new WeakMap();
1060
+ _calculatedSize = new WeakMap();
1061
+ _keyMap = new WeakMap();
1062
+ _keyList = new WeakMap();
1063
+ _valList = new WeakMap();
1064
+ _next = new WeakMap();
1065
+ _prev = new WeakMap();
1066
+ _head = new WeakMap();
1067
+ _tail = new WeakMap();
1068
+ _free = new WeakMap();
1069
+ _disposed = new WeakMap();
1070
+ _sizes = new WeakMap();
1071
+ _starts = new WeakMap();
1072
+ _ttls = new WeakMap();
1073
+ _hasDispose = new WeakMap();
1074
+ _hasFetchMethod = new WeakMap();
1075
+ _hasDisposeAfter = new WeakMap();
1076
+ _LRUCache_instances = new WeakSet();
1077
+ initializeTTLTracking_fn = function() {
1078
+ const ttls = new ZeroArray(__privateGet(this, _max));
1079
+ const starts = new ZeroArray(__privateGet(this, _max));
1080
+ __privateSet(this, _ttls, ttls);
1081
+ __privateSet(this, _starts, starts);
1082
+ __privateSet(this, _setItemTTL, (index, ttl, start = perf.now()) => {
1083
+ starts[index] = ttl !== 0 ? start : 0;
1084
+ ttls[index] = ttl;
1085
+ if (ttl !== 0 && this.ttlAutopurge) {
1086
+ const t = setTimeout(() => {
1087
+ if (__privateGet(this, _isStale).call(this, index)) {
1088
+ __privateMethod(this, _LRUCache_instances, delete_fn).call(this, __privateGet(this, _keyList)[index], "expire");
1089
+ }
1090
+ }, ttl + 1);
1091
+ if (t.unref) {
1092
+ t.unref();
1093
+ }
1094
+ }
1095
+ });
1096
+ __privateSet(this, _updateItemAge, (index) => {
1097
+ starts[index] = ttls[index] !== 0 ? perf.now() : 0;
1098
+ });
1099
+ __privateSet(this, _statusTTL, (status, index) => {
1100
+ if (ttls[index]) {
1101
+ const ttl = ttls[index];
1102
+ const start = starts[index];
1103
+ if (!ttl || !start)
1104
+ return;
1105
+ status.ttl = ttl;
1106
+ status.start = start;
1107
+ status.now = cachedNow || getNow();
1108
+ const age = status.now - start;
1109
+ status.remainingTTL = ttl - age;
1110
+ }
1111
+ });
1112
+ let cachedNow = 0;
1113
+ const getNow = () => {
1114
+ const n = perf.now();
1115
+ if (this.ttlResolution > 0) {
1116
+ cachedNow = n;
1117
+ const t = setTimeout(() => cachedNow = 0, this.ttlResolution);
1118
+ if (t.unref) {
1119
+ t.unref();
1120
+ }
1121
+ }
1122
+ return n;
1123
+ };
1124
+ this.getRemainingTTL = (key) => {
1125
+ const index = __privateGet(this, _keyMap).get(key);
1126
+ if (index === void 0) {
1127
+ return 0;
1128
+ }
1129
+ const ttl = ttls[index];
1130
+ const start = starts[index];
1131
+ if (!ttl || !start) {
1132
+ return Infinity;
1133
+ }
1134
+ const age = (cachedNow || getNow()) - start;
1135
+ return ttl - age;
1136
+ };
1137
+ __privateSet(this, _isStale, (index) => {
1138
+ const s = starts[index];
1139
+ const t = ttls[index];
1140
+ return !!t && !!s && (cachedNow || getNow()) - s > t;
1141
+ });
1142
+ };
1143
+ _updateItemAge = new WeakMap();
1144
+ _statusTTL = new WeakMap();
1145
+ _setItemTTL = new WeakMap();
1146
+ _isStale = new WeakMap();
1147
+ initializeSizeTracking_fn = function() {
1148
+ const sizes = new ZeroArray(__privateGet(this, _max));
1149
+ __privateSet(this, _calculatedSize, 0);
1150
+ __privateSet(this, _sizes, sizes);
1151
+ __privateSet(this, _removeItemSize, (index) => {
1152
+ __privateSet(this, _calculatedSize, __privateGet(this, _calculatedSize) - sizes[index]);
1153
+ sizes[index] = 0;
1154
+ });
1155
+ __privateSet(this, _requireSize, (k, v, size, sizeCalculation) => {
1156
+ if (__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
1157
+ return 0;
1158
+ }
1159
+ if (!isPosInt(size)) {
1160
+ if (sizeCalculation) {
1161
+ if (typeof sizeCalculation !== "function") {
1162
+ throw new TypeError("sizeCalculation must be a function");
1163
+ }
1164
+ size = sizeCalculation(v, k);
1165
+ if (!isPosInt(size)) {
1166
+ throw new TypeError("sizeCalculation return invalid (expect positive integer)");
1167
+ }
1168
+ } else {
1169
+ throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
1170
+ }
1171
+ }
1172
+ return size;
1173
+ });
1174
+ __privateSet(this, _addItemSize, (index, size, status) => {
1175
+ sizes[index] = size;
1176
+ if (__privateGet(this, _maxSize)) {
1177
+ const maxSize = __privateGet(this, _maxSize) - sizes[index];
1178
+ while (__privateGet(this, _calculatedSize) > maxSize) {
1179
+ __privateMethod(this, _LRUCache_instances, evict_fn).call(this, true);
1180
+ }
1181
+ }
1182
+ __privateSet(this, _calculatedSize, __privateGet(this, _calculatedSize) + sizes[index]);
1183
+ if (status) {
1184
+ status.entrySize = size;
1185
+ status.totalCalculatedSize = __privateGet(this, _calculatedSize);
1186
+ }
1187
+ });
1188
+ };
1189
+ _removeItemSize = new WeakMap();
1190
+ _addItemSize = new WeakMap();
1191
+ _requireSize = new WeakMap();
1192
+ indexes_fn = function* ({ allowStale = this.allowStale } = {}) {
1193
+ if (__privateGet(this, _size)) {
1194
+ for (let i = __privateGet(this, _tail); true; ) {
1195
+ if (!__privateMethod(this, _LRUCache_instances, isValidIndex_fn).call(this, i)) {
1196
+ break;
1197
+ }
1198
+ if (allowStale || !__privateGet(this, _isStale).call(this, i)) {
1199
+ yield i;
1200
+ }
1201
+ if (i === __privateGet(this, _head)) {
1202
+ break;
1203
+ } else {
1204
+ i = __privateGet(this, _prev)[i];
1205
+ }
1206
+ }
1207
+ }
1208
+ };
1209
+ rindexes_fn = function* ({ allowStale = this.allowStale } = {}) {
1210
+ if (__privateGet(this, _size)) {
1211
+ for (let i = __privateGet(this, _head); true; ) {
1212
+ if (!__privateMethod(this, _LRUCache_instances, isValidIndex_fn).call(this, i)) {
1213
+ break;
1214
+ }
1215
+ if (allowStale || !__privateGet(this, _isStale).call(this, i)) {
1216
+ yield i;
1217
+ }
1218
+ if (i === __privateGet(this, _tail)) {
1219
+ break;
1220
+ } else {
1221
+ i = __privateGet(this, _next)[i];
1222
+ }
1223
+ }
1224
+ }
1225
+ };
1226
+ isValidIndex_fn = function(index) {
1227
+ return index !== void 0 && __privateGet(this, _keyMap).get(__privateGet(this, _keyList)[index]) === index;
1228
+ };
1229
+ evict_fn = function(free) {
1230
+ var _a2, _b2;
1231
+ const head = __privateGet(this, _head);
1232
+ const k = __privateGet(this, _keyList)[head];
1233
+ const v = __privateGet(this, _valList)[head];
1234
+ if (__privateGet(this, _hasFetchMethod) && __privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
1235
+ v.__abortController.abort(new Error("evicted"));
1236
+ } else if (__privateGet(this, _hasDispose) || __privateGet(this, _hasDisposeAfter)) {
1237
+ if (__privateGet(this, _hasDispose)) {
1238
+ (_a2 = __privateGet(this, _dispose)) == null ? void 0 : _a2.call(this, v, k, "evict");
1239
+ }
1240
+ if (__privateGet(this, _hasDisposeAfter)) {
1241
+ (_b2 = __privateGet(this, _disposed)) == null ? void 0 : _b2.push([v, k, "evict"]);
1242
+ }
1243
+ }
1244
+ __privateGet(this, _removeItemSize).call(this, head);
1245
+ if (free) {
1246
+ __privateGet(this, _keyList)[head] = void 0;
1247
+ __privateGet(this, _valList)[head] = void 0;
1248
+ __privateGet(this, _free).push(head);
1249
+ }
1250
+ if (__privateGet(this, _size) === 1) {
1251
+ __privateSet(this, _head, __privateSet(this, _tail, 0));
1252
+ __privateGet(this, _free).length = 0;
1253
+ } else {
1254
+ __privateSet(this, _head, __privateGet(this, _next)[head]);
1255
+ }
1256
+ __privateGet(this, _keyMap).delete(k);
1257
+ __privateWrapper(this, _size)._--;
1258
+ return head;
1259
+ };
1260
+ backgroundFetch_fn = function(k, index, options, context) {
1261
+ const v = index === void 0 ? void 0 : __privateGet(this, _valList)[index];
1262
+ if (__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
1263
+ return v;
1264
+ }
1265
+ const ac = new AC();
1266
+ const { signal } = options;
1267
+ signal == null ? void 0 : signal.addEventListener("abort", () => ac.abort(signal.reason), {
1268
+ signal: ac.signal
1269
+ });
1270
+ const fetchOpts = {
1271
+ signal: ac.signal,
1272
+ options,
1273
+ context
1274
+ };
1275
+ const cb = (v2, updateCache = false) => {
1276
+ const { aborted } = ac.signal;
1277
+ const ignoreAbort = options.ignoreFetchAbort && v2 !== void 0;
1278
+ if (options.status) {
1279
+ if (aborted && !updateCache) {
1280
+ options.status.fetchAborted = true;
1281
+ options.status.fetchError = ac.signal.reason;
1282
+ if (ignoreAbort)
1283
+ options.status.fetchAbortIgnored = true;
1284
+ } else {
1285
+ options.status.fetchResolved = true;
1286
+ }
1287
+ }
1288
+ if (aborted && !ignoreAbort && !updateCache) {
1289
+ return fetchFail(ac.signal.reason);
1290
+ }
1291
+ const bf2 = p;
1292
+ if (__privateGet(this, _valList)[index] === p) {
1293
+ if (v2 === void 0) {
1294
+ if (bf2.__staleWhileFetching) {
1295
+ __privateGet(this, _valList)[index] = bf2.__staleWhileFetching;
1296
+ } else {
1297
+ __privateMethod(this, _LRUCache_instances, delete_fn).call(this, k, "fetch");
1298
+ }
1299
+ } else {
1300
+ if (options.status)
1301
+ options.status.fetchUpdated = true;
1302
+ this.set(k, v2, fetchOpts.options);
1303
+ }
1304
+ }
1305
+ return v2;
1306
+ };
1307
+ const eb = (er) => {
1308
+ if (options.status) {
1309
+ options.status.fetchRejected = true;
1310
+ options.status.fetchError = er;
1311
+ }
1312
+ return fetchFail(er);
1313
+ };
1314
+ const fetchFail = (er) => {
1315
+ const { aborted } = ac.signal;
1316
+ const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
1317
+ const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
1318
+ const noDelete = allowStale || options.noDeleteOnFetchRejection;
1319
+ const bf2 = p;
1320
+ if (__privateGet(this, _valList)[index] === p) {
1321
+ const del = !noDelete || bf2.__staleWhileFetching === void 0;
1322
+ if (del) {
1323
+ __privateMethod(this, _LRUCache_instances, delete_fn).call(this, k, "fetch");
1324
+ } else if (!allowStaleAborted) {
1325
+ __privateGet(this, _valList)[index] = bf2.__staleWhileFetching;
1326
+ }
1327
+ }
1328
+ if (allowStale) {
1329
+ if (options.status && bf2.__staleWhileFetching !== void 0) {
1330
+ options.status.returnedStale = true;
1331
+ }
1332
+ return bf2.__staleWhileFetching;
1333
+ } else if (bf2.__returned === bf2) {
1334
+ throw er;
1335
+ }
1336
+ };
1337
+ const pcall = (res, rej) => {
1338
+ var _a2;
1339
+ const fmp = (_a2 = __privateGet(this, _fetchMethod)) == null ? void 0 : _a2.call(this, k, v, fetchOpts);
1340
+ if (fmp && fmp instanceof Promise) {
1341
+ fmp.then((v2) => res(v2 === void 0 ? void 0 : v2), rej);
1342
+ }
1343
+ ac.signal.addEventListener("abort", () => {
1344
+ if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
1345
+ res(void 0);
1346
+ if (options.allowStaleOnFetchAbort) {
1347
+ res = (v2) => cb(v2, true);
1348
+ }
1349
+ }
1350
+ });
1351
+ };
1352
+ if (options.status)
1353
+ options.status.fetchDispatched = true;
1354
+ const p = new Promise(pcall).then(cb, eb);
1355
+ const bf = Object.assign(p, {
1356
+ __abortController: ac,
1357
+ __staleWhileFetching: v,
1358
+ __returned: void 0
1359
+ });
1360
+ if (index === void 0) {
1361
+ this.set(k, bf, { ...fetchOpts.options, status: void 0 });
1362
+ index = __privateGet(this, _keyMap).get(k);
1363
+ } else {
1364
+ __privateGet(this, _valList)[index] = bf;
1365
+ }
1366
+ return bf;
1367
+ };
1368
+ isBackgroundFetch_fn = function(p) {
1369
+ if (!__privateGet(this, _hasFetchMethod))
1370
+ return false;
1371
+ const b = p;
1372
+ return !!b && b instanceof Promise && b.hasOwnProperty("__staleWhileFetching") && b.__abortController instanceof AC;
1373
+ };
1374
+ connect_fn = function(p, n) {
1375
+ __privateGet(this, _prev)[n] = p;
1376
+ __privateGet(this, _next)[p] = n;
1377
+ };
1378
+ moveToTail_fn = function(index) {
1379
+ if (index !== __privateGet(this, _tail)) {
1380
+ if (index === __privateGet(this, _head)) {
1381
+ __privateSet(this, _head, __privateGet(this, _next)[index]);
1382
+ } else {
1383
+ __privateMethod(this, _LRUCache_instances, connect_fn).call(this, __privateGet(this, _prev)[index], __privateGet(this, _next)[index]);
1384
+ }
1385
+ __privateMethod(this, _LRUCache_instances, connect_fn).call(this, __privateGet(this, _tail), index);
1386
+ __privateSet(this, _tail, index);
1387
+ }
1388
+ };
1389
+ delete_fn = function(k, reason) {
1390
+ var _a2, _b2, _c2, _d;
1391
+ let deleted = false;
1392
+ if (__privateGet(this, _size) !== 0) {
1393
+ const index = __privateGet(this, _keyMap).get(k);
1394
+ if (index !== void 0) {
1395
+ deleted = true;
1396
+ if (__privateGet(this, _size) === 1) {
1397
+ __privateMethod(this, _LRUCache_instances, clear_fn).call(this, reason);
1398
+ } else {
1399
+ __privateGet(this, _removeItemSize).call(this, index);
1400
+ const v = __privateGet(this, _valList)[index];
1401
+ if (__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
1402
+ v.__abortController.abort(new Error("deleted"));
1403
+ } else if (__privateGet(this, _hasDispose) || __privateGet(this, _hasDisposeAfter)) {
1404
+ if (__privateGet(this, _hasDispose)) {
1405
+ (_a2 = __privateGet(this, _dispose)) == null ? void 0 : _a2.call(this, v, k, reason);
1406
+ }
1407
+ if (__privateGet(this, _hasDisposeAfter)) {
1408
+ (_b2 = __privateGet(this, _disposed)) == null ? void 0 : _b2.push([v, k, reason]);
1409
+ }
1410
+ }
1411
+ __privateGet(this, _keyMap).delete(k);
1412
+ __privateGet(this, _keyList)[index] = void 0;
1413
+ __privateGet(this, _valList)[index] = void 0;
1414
+ if (index === __privateGet(this, _tail)) {
1415
+ __privateSet(this, _tail, __privateGet(this, _prev)[index]);
1416
+ } else if (index === __privateGet(this, _head)) {
1417
+ __privateSet(this, _head, __privateGet(this, _next)[index]);
1418
+ } else {
1419
+ const pi = __privateGet(this, _prev)[index];
1420
+ __privateGet(this, _next)[pi] = __privateGet(this, _next)[index];
1421
+ const ni = __privateGet(this, _next)[index];
1422
+ __privateGet(this, _prev)[ni] = __privateGet(this, _prev)[index];
1423
+ }
1424
+ __privateWrapper(this, _size)._--;
1425
+ __privateGet(this, _free).push(index);
1426
+ }
1427
+ }
1428
+ }
1429
+ if (__privateGet(this, _hasDisposeAfter) && ((_c2 = __privateGet(this, _disposed)) == null ? void 0 : _c2.length)) {
1430
+ const dt = __privateGet(this, _disposed);
1431
+ let task;
1432
+ while (task = dt == null ? void 0 : dt.shift()) {
1433
+ (_d = __privateGet(this, _disposeAfter)) == null ? void 0 : _d.call(this, ...task);
1434
+ }
1435
+ }
1436
+ return deleted;
1437
+ };
1438
+ clear_fn = function(reason) {
1439
+ var _a2, _b2, _c2;
1440
+ for (const index of __privateMethod(this, _LRUCache_instances, rindexes_fn).call(this, { allowStale: true })) {
1441
+ const v = __privateGet(this, _valList)[index];
1442
+ if (__privateMethod(this, _LRUCache_instances, isBackgroundFetch_fn).call(this, v)) {
1443
+ v.__abortController.abort(new Error("deleted"));
1444
+ } else {
1445
+ const k = __privateGet(this, _keyList)[index];
1446
+ if (__privateGet(this, _hasDispose)) {
1447
+ (_a2 = __privateGet(this, _dispose)) == null ? void 0 : _a2.call(this, v, k, reason);
1448
+ }
1449
+ if (__privateGet(this, _hasDisposeAfter)) {
1450
+ (_b2 = __privateGet(this, _disposed)) == null ? void 0 : _b2.push([v, k, reason]);
1451
+ }
1452
+ }
1453
+ }
1454
+ __privateGet(this, _keyMap).clear();
1455
+ __privateGet(this, _valList).fill(void 0);
1456
+ __privateGet(this, _keyList).fill(void 0);
1457
+ if (__privateGet(this, _ttls) && __privateGet(this, _starts)) {
1458
+ __privateGet(this, _ttls).fill(0);
1459
+ __privateGet(this, _starts).fill(0);
1460
+ }
1461
+ if (__privateGet(this, _sizes)) {
1462
+ __privateGet(this, _sizes).fill(0);
1463
+ }
1464
+ __privateSet(this, _head, 0);
1465
+ __privateSet(this, _tail, 0);
1466
+ __privateGet(this, _free).length = 0;
1467
+ __privateSet(this, _calculatedSize, 0);
1468
+ __privateSet(this, _size, 0);
1469
+ if (__privateGet(this, _hasDisposeAfter) && __privateGet(this, _disposed)) {
1470
+ const dt = __privateGet(this, _disposed);
1471
+ let task;
1472
+ while (task = dt == null ? void 0 : dt.shift()) {
1473
+ (_c2 = __privateGet(this, _disposeAfter)) == null ? void 0 : _c2.call(this, ...task);
1474
+ }
1475
+ }
1476
+ };
1477
+ let LRUCache = _LRUCache;
1478
+ const CacheSize = {
1479
+ KB: 1024,
1480
+ MB: 1024 * 1024,
1481
+ GB: 1024 * 1024 * 1024
1482
+ };
1483
+ const CacheTime = {
1484
+ SECOND: 1e3,
1485
+ MINUTE: 60 * 1e3,
1486
+ HOUR: 60 * 60 * 1e3,
1487
+ DAY: 24 * 60 * 60 * 1e3,
1488
+ WEEK: 7 * 24 * 60 * 60 * 1e3,
1489
+ MONTH: 30 * 24 * 60 * 60 * 1e3
1490
+ };
1491
+ function getTagKeyMap() {
1492
+ const dataFetchCache = getDataFetchCache();
1493
+ if (!dataFetchCache || !dataFetchCache.tagKeyMap) {
1494
+ const tagKeyMap = /* @__PURE__ */ new Map();
1495
+ globalThis.__MF_DATA_FETCH_CACHE__ || (globalThis.__MF_DATA_FETCH_CACHE__ = {});
1496
+ globalThis.__MF_DATA_FETCH_CACHE__.tagKeyMap = tagKeyMap;
1497
+ return tagKeyMap;
1498
+ }
1499
+ return dataFetchCache.tagKeyMap;
1500
+ }
1501
+ function addTagKeyRelation(tag, key) {
1502
+ const tagKeyMap = getTagKeyMap();
1503
+ let keys = tagKeyMap.get(tag);
1504
+ if (!keys) {
1505
+ keys = /* @__PURE__ */ new Set();
1506
+ tagKeyMap.set(tag, keys);
1507
+ }
1508
+ keys.add(key);
1509
+ }
1510
+ function getCacheConfig() {
1511
+ const dataFetchCache = getDataFetchCache();
1512
+ if (!dataFetchCache || !dataFetchCache.cacheConfig) {
1513
+ const cacheConfig = {
1514
+ maxSize: CacheSize.GB
1515
+ };
1516
+ globalThis.__MF_DATA_FETCH_CACHE__ || (globalThis.__MF_DATA_FETCH_CACHE__ = {});
1517
+ globalThis.__MF_DATA_FETCH_CACHE__.cacheConfig = cacheConfig;
1518
+ return cacheConfig;
1519
+ }
1520
+ return dataFetchCache.cacheConfig;
1521
+ }
1522
+ function configureCache(config) {
1523
+ const cacheConfig = getCacheConfig();
1524
+ Object.assign(cacheConfig, config);
1525
+ }
1526
+ function getLRUCache() {
1527
+ const dataFetchCache = getDataFetchCache();
1528
+ const cacheConfig = getCacheConfig();
1529
+ if (!dataFetchCache || !dataFetchCache.cacheStore) {
1530
+ const cacheStore = new LRUCache({
1531
+ maxSize: cacheConfig.maxSize ?? CacheSize.GB,
1532
+ sizeCalculation: (value) => {
1533
+ if (!value.size) {
1534
+ return 1;
1535
+ }
1536
+ let size = 0;
1537
+ for (const [k, item] of value.entries()) {
1538
+ size += k.length * 2;
1539
+ size += estimateObjectSize(item.data);
1540
+ size += 8;
1541
+ }
1542
+ return size;
1543
+ },
1544
+ updateAgeOnGet: true,
1545
+ updateAgeOnHas: true
1546
+ });
1547
+ globalThis.__MF_DATA_FETCH_CACHE__ || (globalThis.__MF_DATA_FETCH_CACHE__ = {});
1548
+ globalThis.__MF_DATA_FETCH_CACHE__.cacheStore = cacheStore;
1549
+ return cacheStore;
1550
+ }
1551
+ return dataFetchCache.cacheStore;
1552
+ }
1553
+ function estimateObjectSize(data) {
1554
+ const type = typeof data;
1555
+ if (type === "number") return 8;
1556
+ if (type === "boolean") return 4;
1557
+ if (type === "string") return Math.max(data.length * 2, 1);
1558
+ if (data === null || data === void 0) return 1;
1559
+ if (ArrayBuffer.isView(data)) {
1560
+ return Math.max(data.byteLength, 1);
1561
+ }
1562
+ if (Array.isArray(data)) {
1563
+ return Math.max(
1564
+ data.reduce((acc, item) => acc + estimateObjectSize(item), 0),
1565
+ 1
1566
+ );
1567
+ }
1568
+ if (data instanceof Map || data instanceof Set) {
1569
+ return 1024;
1570
+ }
1571
+ if (data instanceof Date) {
1572
+ return 8;
1573
+ }
1574
+ if (type === "object") {
1575
+ return Math.max(
1576
+ Object.entries(data).reduce(
1577
+ (acc, [key, value]) => acc + key.length * 2 + estimateObjectSize(value),
1578
+ 0
1579
+ ),
1580
+ 1
1581
+ );
1582
+ }
1583
+ return 1;
1584
+ }
1585
+ function generateKey(dataFetchOptions) {
1586
+ return JSON.stringify(dataFetchOptions, (_, value) => {
1587
+ if (value && typeof value === "object" && !Array.isArray(value)) {
1588
+ return Object.keys(value).sort().reduce((result, key) => {
1589
+ result[key] = value[key];
1590
+ return result;
1591
+ }, {});
1592
+ }
1593
+ return value;
1594
+ });
1595
+ }
1596
+ function cache(fn, options) {
1597
+ const {
1598
+ tag = "default",
1599
+ maxAge = CacheTime.MINUTE * 5,
1600
+ revalidate = 0,
1601
+ onCache,
1602
+ getKey
1603
+ } = options || {};
1604
+ const tags = Array.isArray(tag) ? tag : [tag];
1605
+ return async (dataFetchOptions) => {
1606
+ if (dataFetchOptions.isDowngrade || !dataFetchOptions._id) {
1607
+ return fn(dataFetchOptions);
1608
+ }
1609
+ const store = getLRUCache();
1610
+ const now = Date.now();
1611
+ const storeKey = dataFetchOptions._id;
1612
+ const cacheKey = getKey ? getKey(dataFetchOptions) : generateKey(dataFetchOptions);
1613
+ tags.forEach((t) => addTagKeyRelation(t, cacheKey));
1614
+ let cacheStore = store.get(cacheKey);
1615
+ if (!cacheStore) {
1616
+ cacheStore = /* @__PURE__ */ new Map();
1617
+ }
1618
+ const cached = cacheStore.get(storeKey);
1619
+ if (cached) {
1620
+ const age = now - cached.timestamp;
1621
+ if (age < maxAge) {
1622
+ if (onCache) {
1623
+ const useCache = onCache({
1624
+ status: "hit",
1625
+ key: cacheKey,
1626
+ params: dataFetchOptions,
1627
+ result: cached.data
1628
+ });
1629
+ if (!useCache) {
1630
+ return fn(dataFetchOptions);
1631
+ }
1632
+ }
1633
+ return cached.data;
1634
+ }
1635
+ if (revalidate > 0 && age < maxAge + revalidate) {
1636
+ if (onCache) {
1637
+ onCache({
1638
+ status: "stale",
1639
+ key: cacheKey,
1640
+ params: dataFetchOptions,
1641
+ result: cached.data
1642
+ });
1643
+ }
1644
+ if (!cached.isRevalidating) {
1645
+ cached.isRevalidating = true;
1646
+ Promise.resolve().then(async () => {
1647
+ try {
1648
+ const newData = await fn(dataFetchOptions);
1649
+ cacheStore.set(storeKey, {
1650
+ data: newData,
1651
+ timestamp: Date.now(),
1652
+ isRevalidating: false
1653
+ });
1654
+ store.set(cacheKey, cacheStore);
1655
+ } catch (error) {
1656
+ cached.isRevalidating = false;
1657
+ console.error("Background revalidation failed:", error);
1658
+ }
1659
+ });
1660
+ }
1661
+ return cached.data;
1662
+ }
1663
+ }
1664
+ const data = await fn(dataFetchOptions);
1665
+ cacheStore.set(storeKey, {
1666
+ data,
1667
+ timestamp: now,
1668
+ isRevalidating: false
1669
+ });
1670
+ store.set(cacheKey, cacheStore);
1671
+ if (onCache) {
1672
+ onCache({
1673
+ status: "miss",
1674
+ key: cacheKey,
1675
+ params: dataFetchOptions,
1676
+ result: data
1677
+ });
1678
+ }
1679
+ return data;
1680
+ };
1681
+ }
1682
+ function revalidateTag(tag) {
1683
+ const tagKeyMap = getTagKeyMap();
1684
+ const keys = tagKeyMap.get(tag);
1685
+ const lruCache = getLRUCache();
1686
+ if (keys) {
1687
+ keys.forEach((key) => {
1688
+ lruCache == null ? void 0 : lruCache.delete(key);
1689
+ });
1690
+ }
1691
+ }
1692
+ function clearStore() {
1693
+ var _a2;
1694
+ const lruCache = getLRUCache();
1695
+ const tagKeyMap = getTagKeyMap();
1696
+ lruCache == null ? void 0 : lruCache.clear();
1697
+ (_a2 = globalThis.__MF_DATA_FETCH_CACHE__) == null ? true : delete _a2.cacheStore;
1698
+ tagKeyMap.clear();
1699
+ }
1700
+ const getDataFetchInfo = ({
1701
+ name,
1702
+ alias,
1703
+ id,
1704
+ remoteSnapshot
1705
+ }) => {
1706
+ if (!remoteSnapshot) {
1707
+ return;
1708
+ }
1709
+ if (!("modules" in remoteSnapshot)) {
1710
+ return;
1711
+ }
1712
+ const regex = new RegExp(`^${name}(/[^/].*|)$`);
1713
+ const nameOrAlias = regex.test(id) ? name : alias || name;
1714
+ const expose = id.replace(nameOrAlias, "");
1715
+ let dataFetchName = "";
1716
+ let dataFetchId = "";
1717
+ let dataFetchKey = "";
1718
+ if (expose.startsWith("/")) {
1719
+ dataFetchName = `${expose.slice(1)}.${DATA_FETCH_IDENTIFIER}`;
1720
+ dataFetchId = `${id}.${DATA_FETCH_IDENTIFIER}`;
1721
+ dataFetchKey = `${name}${expose}.${DATA_FETCH_IDENTIFIER}`;
1722
+ } else if (expose === "") {
1723
+ dataFetchName = DATA_FETCH_IDENTIFIER;
1724
+ dataFetchId = `${id}/${DATA_FETCH_IDENTIFIER}`;
1725
+ dataFetchKey = `${name}/${DATA_FETCH_IDENTIFIER}`;
1726
+ } else {
1727
+ return;
1728
+ }
1729
+ if (!dataFetchName || !dataFetchId || !dataFetchKey) {
1730
+ return;
1731
+ }
1732
+ if (!remoteSnapshot.modules.find(
1733
+ (module) => module.moduleName === dataFetchName
1734
+ )) {
1735
+ return;
1736
+ }
1737
+ return {
1738
+ dataFetchName,
1739
+ dataFetchId,
1740
+ dataFetchKey
1741
+ };
1742
+ };
1743
+ function initDataFetchMap() {
1744
+ globalThis.__MF_DATA_FETCH_MAP__ || (globalThis.__MF_DATA_FETCH_MAP__ = {});
1745
+ }
1746
+ function getDataFetchItem(id) {
1747
+ var _a2;
1748
+ return (_a2 = globalThis.__MF_DATA_FETCH_MAP__) == null ? void 0 : _a2[id];
1749
+ }
1750
+ function getDataFetchMap() {
1751
+ return globalThis.__MF_DATA_FETCH_MAP__;
1752
+ }
1753
+ function getDataFetchCache() {
1754
+ return globalThis.__MF_DATA_FETCH_CACHE__;
1755
+ }
1756
+ const flushDataFetch = () => {
1757
+ globalThis.__MF_DATA_FETCH_MAP__ = {};
1758
+ globalThis[DOWNGRADE_KEY] = void 0;
1759
+ clearStore();
1760
+ };
1761
+ function setDataFetchItemLoadedStatus(id) {
1762
+ const dataFetchItem = getDataFetchItem(id);
1763
+ if (!dataFetchItem) {
1764
+ return;
1765
+ }
1766
+ dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;
1767
+ }
1768
+ const wrapDataFetchId = (id) => {
1769
+ return `${WRAP_DATA_FETCH_ID_IDENTIFIER}${id}${WRAP_DATA_FETCH_ID_IDENTIFIER}`;
1770
+ };
1771
+ const getDataFetchIdWithErrorMsgs = (errMsgs) => {
1772
+ const firstIdentifierIndex = errMsgs.indexOf(WRAP_DATA_FETCH_ID_IDENTIFIER);
1773
+ if (firstIdentifierIndex === -1) {
1774
+ return void 0;
1775
+ }
1776
+ const secondIdentifierIndex = errMsgs.indexOf(
1777
+ WRAP_DATA_FETCH_ID_IDENTIFIER,
1778
+ firstIdentifierIndex + WRAP_DATA_FETCH_ID_IDENTIFIER.length
1779
+ );
1780
+ if (secondIdentifierIndex === -1) {
1781
+ return void 0;
1782
+ }
1783
+ return errMsgs.substring(
1784
+ firstIdentifierIndex + WRAP_DATA_FETCH_ID_IDENTIFIER.length,
1785
+ secondIdentifierIndex
1786
+ );
1787
+ };
1788
+ async function fetchData(id, params, remoteInfo) {
1789
+ var _a2;
1790
+ const callFetchData = async () => {
1791
+ const item = getDataFetchItem(id);
1792
+ if (!item) {
1793
+ return;
1794
+ }
1795
+ const [fetchDataFnArr, ..._rest] = item;
1796
+ const fetchDataFn = await fetchDataFnArr[2];
1797
+ if (!fetchDataFn) {
1798
+ return;
1799
+ }
1800
+ return fetchDataFn({
1801
+ ...params,
1802
+ _id: id
1803
+ });
1804
+ };
1805
+ if (isBrowserEnv()) {
1806
+ const dataFetchItem = getDataFetchItem(id);
1807
+ if (!dataFetchItem) {
1808
+ throw new Error(`dataFetchItem not found, id: ${id}`);
1809
+ }
1810
+ if ((_a2 = dataFetchItem[1]) == null ? void 0 : _a2[0]) {
1811
+ return dataFetchItem[1][0];
1812
+ }
1813
+ if (isCSROnly()) {
1814
+ logger.debug("==========csr only!");
1815
+ return callFetchData();
1816
+ }
1817
+ if (remoteInfo) {
1818
+ return callDowngrade(id, params, remoteInfo);
1819
+ }
1820
+ const mfDowngrade = getDowngradeTag();
1821
+ if (mfDowngrade && (typeof mfDowngrade === "boolean" || mfDowngrade.includes(id))) {
1822
+ return callDowngrade(id, { ...params, isDowngrade: true });
1823
+ }
1824
+ let res;
1825
+ let rej;
1826
+ const p = new Promise((resolve, reject) => {
1827
+ res = resolve;
1828
+ rej = reject;
1829
+ });
1830
+ dataFetchItem[1] = [p, res, rej];
1831
+ dataFetchItem[2] = MF_DATA_FETCH_STATUS.AWAIT;
1832
+ return dataFetchItem[1][0];
1833
+ }
1834
+ return callFetchData();
1835
+ }
1836
+ function getDataFetchMapKey(dataFetchInfo, hostInfo) {
1837
+ if (!dataFetchInfo || !hostInfo) {
1838
+ return;
1839
+ }
1840
+ const { dataFetchKey } = dataFetchInfo;
1841
+ return composeKeyWithSeparator(dataFetchKey, hostInfo.name, hostInfo.version);
1842
+ }
1843
+ async function loadDataFetchModule(instance, id) {
1844
+ return instance.loadRemote(id).then((m) => {
1845
+ if (m && typeof m === "object" && "fetchData" in m && typeof m.fetchData === "function") {
1846
+ return m.fetchData;
1847
+ }
1848
+ throw new Error(
1849
+ `fetchData not found in remote ${id}, ${JSON.stringify(m)}`
1850
+ );
1851
+ });
1852
+ }
1853
+ function isDataLoaderExpose(exposeKey) {
1854
+ return exposeKey.endsWith(DATA_FETCH_IDENTIFIER) || exposeKey.endsWith(DATA_FETCH_CLIENT_SUFFIX);
1855
+ }
1856
+ function getDowngradeTag() {
1857
+ return globalThis[DOWNGRADE_KEY];
1858
+ }
1859
+ function callAllDowngrade() {
1860
+ const dataFetchMap = getDataFetchMap();
1861
+ if (!dataFetchMap) {
1862
+ return;
1863
+ }
1864
+ Object.keys(dataFetchMap).forEach((key) => {
1865
+ callDowngrade(key);
1866
+ });
1867
+ }
1868
+ async function callDowngrade(id, params, remoteInfo) {
1869
+ const dataFetchMap = getDataFetchMap();
1870
+ if (!dataFetchMap) {
1871
+ return;
1872
+ }
1873
+ const mfDataFetch = dataFetchMap[id];
1874
+ if ((mfDataFetch == null ? void 0 : mfDataFetch[2]) === MF_DATA_FETCH_STATUS.AWAIT) {
1875
+ mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADING;
1876
+ let promise;
1877
+ let res;
1878
+ let rej;
1879
+ if (mfDataFetch[1]) {
1880
+ promise = mfDataFetch[1][0];
1881
+ res = mfDataFetch[1][1];
1882
+ rej = mfDataFetch[1][2];
1883
+ } else {
1884
+ promise = new Promise((resolve, reject) => {
1885
+ res = resolve;
1886
+ rej = reject;
1887
+ });
1888
+ mfDataFetch[1] = [promise, res, rej];
1889
+ }
1890
+ const dataFetchType = mfDataFetch[0][1];
1891
+ if (dataFetchType === MF_DATA_FETCH_TYPE.FETCH_CLIENT) {
1892
+ try {
1893
+ mfDataFetch[0][0]().then(async (getDataFetchFn) => {
1894
+ return getDataFetchFn({
1895
+ ...params,
1896
+ isDowngrade: true,
1897
+ _id: id
1898
+ }).then((data) => {
1899
+ mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADED;
1900
+ res && res(data);
1901
+ });
1902
+ });
1903
+ } catch (e) {
1904
+ mfDataFetch[2] = MF_DATA_FETCH_STATUS.ERROR;
1905
+ rej && rej(e);
1906
+ }
1907
+ } else if (dataFetchType === MF_DATA_FETCH_TYPE.FETCH_SERVER) {
1908
+ try {
1909
+ const currentUrl = new URL(window.location.href);
1910
+ currentUrl.searchParams.set(DATA_FETCH_QUERY, encodeURIComponent(id));
1911
+ if (params) {
1912
+ currentUrl.searchParams.set(
1913
+ "params",
1914
+ encodeURIComponent(JSON.stringify(params))
1915
+ );
1916
+ }
1917
+ if (remoteInfo) {
1918
+ currentUrl.searchParams.set(
1919
+ "remoteInfo",
1920
+ encodeURIComponent(JSON.stringify(remoteInfo))
1921
+ );
1922
+ }
1923
+ const fetchServerQuery = globalThis.FEDERATION_SERVER_QUERY;
1924
+ if (fetchServerQuery && typeof fetchServerQuery === "object") {
1925
+ Object.keys(fetchServerQuery).forEach((key) => {
1926
+ currentUrl.searchParams.set(
1927
+ key,
1928
+ JSON.stringify(fetchServerQuery[key])
1929
+ );
1930
+ });
1931
+ }
1932
+ const fetchUrl = currentUrl.toString();
1933
+ const data = await fetch(fetchUrl).then((res2) => res2.json());
1934
+ mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADED;
1935
+ res && res(data);
1936
+ } catch (e) {
1937
+ mfDataFetch[2] = MF_DATA_FETCH_STATUS.ERROR;
1938
+ rej && rej(e);
1939
+ }
1940
+ }
1941
+ return promise;
1942
+ }
1943
+ }
1944
+ function isCSROnly() {
1945
+ return window._SSR_DATA === void 0;
1946
+ }
1947
+ function isServerEnv() {
1948
+ return typeof window === "undefined";
1949
+ }
1950
+ function setSSREnv({
1951
+ fetchServerQuery
1952
+ }) {
1953
+ globalThis.FEDERATION_SSR = true;
1954
+ globalThis.FEDERATION_SERVER_QUERY = fetchServerQuery;
1955
+ }
1956
+ function getLoadedRemoteInfos(id, instance) {
1957
+ if (!instance) {
1958
+ return;
1959
+ }
1960
+ const { name, expose } = instance.remoteHandler.idToRemoteMap[id] || {};
1961
+ if (!name) {
1962
+ return;
1963
+ }
1964
+ const module = instance.moduleCache.get(name);
1965
+ if (!module) {
1966
+ return;
1967
+ }
1968
+ const { remoteSnapshot } = instance.snapshotHandler.getGlobalRemoteInfo(
1969
+ module.remoteInfo
1970
+ );
1971
+ return {
1972
+ ...module.remoteInfo,
1973
+ snapshot: remoteSnapshot,
1974
+ expose
1975
+ };
1976
+ }
1977
+ export {
1978
+ DOWNGRADE_KEY as A,
1979
+ getDowngradeTag as B,
1980
+ CacheSize as C,
1981
+ DATA_FETCH_QUERY as D,
1982
+ ERROR_TYPE as E,
1983
+ FS_HREF as F,
1984
+ callAllDowngrade as G,
1985
+ callDowngrade as H,
1986
+ getDataFetchCache as I,
1987
+ flushDataFetch as J,
1988
+ LOAD_REMOTE_ERROR_PREFIX as L,
1989
+ MF_DATA_FETCH_STATUS as M,
1990
+ loadDataFetchModule as a,
1991
+ CacheTime as b,
1992
+ configureCache as c,
1993
+ generateKey as d,
1994
+ cache as e,
1995
+ fetchData as f,
1996
+ getDataFetchMap as g,
1997
+ clearStore as h,
1998
+ initDataFetchMap as i,
1999
+ isDataLoaderExpose as j,
2000
+ getDataFetchInfo as k,
2001
+ logger as l,
2002
+ getDataFetchMapKey as m,
2003
+ getDataFetchItem as n,
2004
+ DATA_FETCH_CLIENT_SUFFIX as o,
2005
+ MF_DATA_FETCH_TYPE as p,
2006
+ isCSROnly as q,
2007
+ revalidateTag as r,
2008
+ setSSREnv as s,
2009
+ isServerEnv as t,
2010
+ getDataFetchIdWithErrorMsgs as u,
2011
+ DATA_FETCH_ERROR_PREFIX as v,
2012
+ wrapDataFetchId as w,
2013
+ DATA_FETCH_FUNCTION as x,
2014
+ getLoadedRemoteInfos as y,
2015
+ setDataFetchItemLoadedStatus as z
2016
+ };