@forsakringskassan/vite-lib-config 3.6.6 → 4.0.0
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/dist/api-extractor.js +142 -29
- package/dist/vite.config.cjs +190 -48
- package/dist/vite.config.mjs +190 -48
- package/package.json +2 -2
package/dist/vite.config.cjs
CHANGED
|
@@ -1064,7 +1064,7 @@ var require_dist = __commonJS({
|
|
|
1064
1064
|
var crypto__default = /* @__PURE__ */ _interopDefaultCompat(crypto);
|
|
1065
1065
|
var require$$0__default = /* @__PURE__ */ _interopDefaultCompat(require$$0);
|
|
1066
1066
|
var require$$1__default = /* @__PURE__ */ _interopDefaultCompat(require$$1);
|
|
1067
|
-
var version2 = "5.2.
|
|
1067
|
+
var version2 = "5.2.4";
|
|
1068
1068
|
function resolveCompiler(root) {
|
|
1069
1069
|
const compiler = tryResolveCompiler(root) || tryResolveCompiler();
|
|
1070
1070
|
if (!compiler) {
|
|
@@ -3048,11 +3048,20 @@ export default (sfc, props) => {
|
|
|
3048
3048
|
}
|
|
3049
3049
|
let resolvedMap = void 0;
|
|
3050
3050
|
if (options.sourceMap) {
|
|
3051
|
-
if (
|
|
3051
|
+
if (templateMap) {
|
|
3052
|
+
const from = scriptMap ?? {
|
|
3053
|
+
file: filename,
|
|
3054
|
+
sourceRoot: "",
|
|
3055
|
+
version: 3,
|
|
3056
|
+
sources: [],
|
|
3057
|
+
sourcesContent: [],
|
|
3058
|
+
names: [],
|
|
3059
|
+
mappings: ""
|
|
3060
|
+
};
|
|
3052
3061
|
const gen = fromMap(
|
|
3053
3062
|
// version property of result.map is declared as string
|
|
3054
3063
|
// but actually it is `3`
|
|
3055
|
-
|
|
3064
|
+
from
|
|
3056
3065
|
);
|
|
3057
3066
|
const tracer = new TraceMap(
|
|
3058
3067
|
// same above
|
|
@@ -3073,7 +3082,7 @@ export default (sfc, props) => {
|
|
|
3073
3082
|
resolvedMap = toEncodedMap(gen);
|
|
3074
3083
|
resolvedMap.sourcesContent = templateMap.sourcesContent;
|
|
3075
3084
|
} else {
|
|
3076
|
-
resolvedMap = scriptMap
|
|
3085
|
+
resolvedMap = scriptMap;
|
|
3077
3086
|
}
|
|
3078
3087
|
}
|
|
3079
3088
|
if (!attachedProps.length) {
|
|
@@ -3087,21 +3096,41 @@ export default (sfc, props) => {
|
|
|
3087
3096
|
let resolvedCode = output.join("\n");
|
|
3088
3097
|
const lang = descriptor.scriptSetup?.lang || descriptor.script?.lang;
|
|
3089
3098
|
if (lang && /tsx?$/.test(lang) && !descriptor.script?.src) {
|
|
3090
|
-
const {
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3099
|
+
const { transformWithOxc } = await import("vite");
|
|
3100
|
+
if (transformWithOxc) {
|
|
3101
|
+
const { code: code2, map } = await transformWithOxc(
|
|
3102
|
+
resolvedCode,
|
|
3103
|
+
filename,
|
|
3104
|
+
{
|
|
3105
|
+
// #430 support decorators in .vue file
|
|
3106
|
+
// target can be overridden by oxc config target
|
|
3107
|
+
// @ts-ignore Rolldown-specific
|
|
3108
|
+
...options.devServer?.config.oxc,
|
|
3109
|
+
lang: "ts",
|
|
3110
|
+
sourcemap: options.sourceMap
|
|
3111
|
+
},
|
|
3112
|
+
resolvedMap
|
|
3113
|
+
);
|
|
3114
|
+
resolvedCode = code2;
|
|
3115
|
+
resolvedMap = resolvedMap ? map : resolvedMap;
|
|
3116
|
+
} else {
|
|
3117
|
+
const { code: code2, map } = await vite.transformWithEsbuild(
|
|
3118
|
+
resolvedCode,
|
|
3119
|
+
filename,
|
|
3120
|
+
{
|
|
3121
|
+
target: "esnext",
|
|
3122
|
+
charset: "utf8",
|
|
3123
|
+
// #430 support decorators in .vue file
|
|
3124
|
+
// target can be overridden by esbuild config target
|
|
3125
|
+
...options.devServer?.config.esbuild,
|
|
3126
|
+
loader: "ts",
|
|
3127
|
+
sourcemap: options.sourceMap
|
|
3128
|
+
},
|
|
3129
|
+
resolvedMap
|
|
3130
|
+
);
|
|
3131
|
+
resolvedCode = code2;
|
|
3132
|
+
resolvedMap = resolvedMap ? map : resolvedMap;
|
|
3133
|
+
}
|
|
3105
3134
|
}
|
|
3106
3135
|
return {
|
|
3107
3136
|
code: resolvedCode,
|
|
@@ -7074,14 +7103,14 @@ var Stack = class _Stack {
|
|
|
7074
7103
|
}
|
|
7075
7104
|
};
|
|
7076
7105
|
var LRUCache = class _LRUCache {
|
|
7077
|
-
//
|
|
7078
|
-
// really *need* to be protected. The rest can be modified, as they just
|
|
7079
|
-
// set defaults for various methods.
|
|
7106
|
+
// options that cannot be changed without disaster
|
|
7080
7107
|
#max;
|
|
7081
7108
|
#maxSize;
|
|
7082
7109
|
#dispose;
|
|
7110
|
+
#onInsert;
|
|
7083
7111
|
#disposeAfter;
|
|
7084
7112
|
#fetchMethod;
|
|
7113
|
+
#memoMethod;
|
|
7085
7114
|
/**
|
|
7086
7115
|
* {@link LRUCache.OptionsBase.ttl}
|
|
7087
7116
|
*/
|
|
@@ -7160,6 +7189,7 @@ var LRUCache = class _LRUCache {
|
|
|
7160
7189
|
#hasDispose;
|
|
7161
7190
|
#hasFetchMethod;
|
|
7162
7191
|
#hasDisposeAfter;
|
|
7192
|
+
#hasOnInsert;
|
|
7163
7193
|
/**
|
|
7164
7194
|
* Do not call this method unless you need to inspect the
|
|
7165
7195
|
* inner workings of the cache. If anything returned by this
|
|
@@ -7227,12 +7257,21 @@ var LRUCache = class _LRUCache {
|
|
|
7227
7257
|
get fetchMethod() {
|
|
7228
7258
|
return this.#fetchMethod;
|
|
7229
7259
|
}
|
|
7260
|
+
get memoMethod() {
|
|
7261
|
+
return this.#memoMethod;
|
|
7262
|
+
}
|
|
7230
7263
|
/**
|
|
7231
7264
|
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
|
7232
7265
|
*/
|
|
7233
7266
|
get dispose() {
|
|
7234
7267
|
return this.#dispose;
|
|
7235
7268
|
}
|
|
7269
|
+
/**
|
|
7270
|
+
* {@link LRUCache.OptionsBase.onInsert} (read-only)
|
|
7271
|
+
*/
|
|
7272
|
+
get onInsert() {
|
|
7273
|
+
return this.#onInsert;
|
|
7274
|
+
}
|
|
7236
7275
|
/**
|
|
7237
7276
|
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
|
7238
7277
|
*/
|
|
@@ -7240,7 +7279,7 @@ var LRUCache = class _LRUCache {
|
|
|
7240
7279
|
return this.#disposeAfter;
|
|
7241
7280
|
}
|
|
7242
7281
|
constructor(options) {
|
|
7243
|
-
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
|
|
7282
|
+
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
|
|
7244
7283
|
if (max !== 0 && !isPosInt(max)) {
|
|
7245
7284
|
throw new TypeError("max option must be a nonnegative integer");
|
|
7246
7285
|
}
|
|
@@ -7260,6 +7299,10 @@ var LRUCache = class _LRUCache {
|
|
|
7260
7299
|
throw new TypeError("sizeCalculation set to non-function");
|
|
7261
7300
|
}
|
|
7262
7301
|
}
|
|
7302
|
+
if (memoMethod !== void 0 && typeof memoMethod !== "function") {
|
|
7303
|
+
throw new TypeError("memoMethod must be a function if defined");
|
|
7304
|
+
}
|
|
7305
|
+
this.#memoMethod = memoMethod;
|
|
7263
7306
|
if (fetchMethod !== void 0 && typeof fetchMethod !== "function") {
|
|
7264
7307
|
throw new TypeError("fetchMethod must be a function if specified");
|
|
7265
7308
|
}
|
|
@@ -7278,6 +7321,9 @@ var LRUCache = class _LRUCache {
|
|
|
7278
7321
|
if (typeof dispose === "function") {
|
|
7279
7322
|
this.#dispose = dispose;
|
|
7280
7323
|
}
|
|
7324
|
+
if (typeof onInsert === "function") {
|
|
7325
|
+
this.#onInsert = onInsert;
|
|
7326
|
+
}
|
|
7281
7327
|
if (typeof disposeAfter === "function") {
|
|
7282
7328
|
this.#disposeAfter = disposeAfter;
|
|
7283
7329
|
this.#disposed = [];
|
|
@@ -7286,6 +7332,7 @@ var LRUCache = class _LRUCache {
|
|
|
7286
7332
|
this.#disposed = void 0;
|
|
7287
7333
|
}
|
|
7288
7334
|
this.#hasDispose = !!this.#dispose;
|
|
7335
|
+
this.#hasOnInsert = !!this.#onInsert;
|
|
7289
7336
|
this.#hasDisposeAfter = !!this.#disposeAfter;
|
|
7290
7337
|
this.noDisposeOnSet = !!noDisposeOnSet;
|
|
7291
7338
|
this.noUpdateTTL = !!noUpdateTTL;
|
|
@@ -7330,7 +7377,8 @@ var LRUCache = class _LRUCache {
|
|
|
7330
7377
|
}
|
|
7331
7378
|
}
|
|
7332
7379
|
/**
|
|
7333
|
-
* Return the
|
|
7380
|
+
* Return the number of ms left in the item's TTL. If item is not in cache,
|
|
7381
|
+
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
|
|
7334
7382
|
*/
|
|
7335
7383
|
getRemainingTTL(key) {
|
|
7336
7384
|
return this.#keyMap.has(key) ? Infinity : 0;
|
|
@@ -7346,7 +7394,7 @@ var LRUCache = class _LRUCache {
|
|
|
7346
7394
|
if (ttl !== 0 && this.ttlAutopurge) {
|
|
7347
7395
|
const t = setTimeout(() => {
|
|
7348
7396
|
if (this.#isStale(index)) {
|
|
7349
|
-
this
|
|
7397
|
+
this.#delete(this.#keyList[index], "expire");
|
|
7350
7398
|
}
|
|
7351
7399
|
}, ttl + 1);
|
|
7352
7400
|
if (t.unref) {
|
|
@@ -7583,13 +7631,14 @@ var LRUCache = class _LRUCache {
|
|
|
7583
7631
|
return this.entries();
|
|
7584
7632
|
}
|
|
7585
7633
|
/**
|
|
7586
|
-
* A String value that is used in the creation of the default string
|
|
7587
|
-
* Called by the built-in method
|
|
7634
|
+
* A String value that is used in the creation of the default string
|
|
7635
|
+
* description of an object. Called by the built-in method
|
|
7636
|
+
* `Object.prototype.toString`.
|
|
7588
7637
|
*/
|
|
7589
7638
|
[Symbol.toStringTag] = "LRUCache";
|
|
7590
7639
|
/**
|
|
7591
7640
|
* Find a value for which the supplied fn method returns a truthy value,
|
|
7592
|
-
* similar to Array.find()
|
|
7641
|
+
* similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
|
|
7593
7642
|
*/
|
|
7594
7643
|
find(fn, getOptions = {}) {
|
|
7595
7644
|
for (const i of this.#indexes()) {
|
|
@@ -7603,10 +7652,15 @@ var LRUCache = class _LRUCache {
|
|
|
7603
7652
|
}
|
|
7604
7653
|
}
|
|
7605
7654
|
/**
|
|
7606
|
-
* Call the supplied function on each item in the cache, in order from
|
|
7607
|
-
*
|
|
7608
|
-
*
|
|
7609
|
-
*
|
|
7655
|
+
* Call the supplied function on each item in the cache, in order from most
|
|
7656
|
+
* recently used to least recently used.
|
|
7657
|
+
*
|
|
7658
|
+
* `fn` is called as `fn(value, key, cache)`.
|
|
7659
|
+
*
|
|
7660
|
+
* If `thisp` is provided, function will be called in the `this`-context of
|
|
7661
|
+
* the provided object, or the cache if no `thisp` object is provided.
|
|
7662
|
+
*
|
|
7663
|
+
* Does not update age or recenty of use, or iterate over stale values.
|
|
7610
7664
|
*/
|
|
7611
7665
|
forEach(fn, thisp = this) {
|
|
7612
7666
|
for (const i of this.#indexes()) {
|
|
@@ -7638,7 +7692,7 @@ var LRUCache = class _LRUCache {
|
|
|
7638
7692
|
let deleted = false;
|
|
7639
7693
|
for (const i of this.#rindexes({ allowStale: true })) {
|
|
7640
7694
|
if (this.#isStale(i)) {
|
|
7641
|
-
this
|
|
7695
|
+
this.#delete(this.#keyList[i], "expire");
|
|
7642
7696
|
deleted = true;
|
|
7643
7697
|
}
|
|
7644
7698
|
}
|
|
@@ -7646,9 +7700,15 @@ var LRUCache = class _LRUCache {
|
|
|
7646
7700
|
}
|
|
7647
7701
|
/**
|
|
7648
7702
|
* Get the extended info about a given entry, to get its value, size, and
|
|
7649
|
-
* TTL info simultaneously.
|
|
7650
|
-
*
|
|
7651
|
-
*
|
|
7703
|
+
* TTL info simultaneously. Returns `undefined` if the key is not present.
|
|
7704
|
+
*
|
|
7705
|
+
* Unlike {@link LRUCache#dump}, which is designed to be portable and survive
|
|
7706
|
+
* serialization, the `start` value is always the current timestamp, and the
|
|
7707
|
+
* `ttl` is a calculated remaining time to live (negative if expired).
|
|
7708
|
+
*
|
|
7709
|
+
* Always returns stale values, if their info is found in the cache, so be
|
|
7710
|
+
* sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
|
|
7711
|
+
* if relevant.
|
|
7652
7712
|
*/
|
|
7653
7713
|
info(key) {
|
|
7654
7714
|
const i = this.#keyMap.get(key);
|
|
@@ -7675,7 +7735,16 @@ var LRUCache = class _LRUCache {
|
|
|
7675
7735
|
}
|
|
7676
7736
|
/**
|
|
7677
7737
|
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
7678
|
-
* passed to
|
|
7738
|
+
* passed to {@link LRUCache#load}.
|
|
7739
|
+
*
|
|
7740
|
+
* The `start` fields are calculated relative to a portable `Date.now()`
|
|
7741
|
+
* timestamp, even if `performance.now()` is available.
|
|
7742
|
+
*
|
|
7743
|
+
* Stale entries are always included in the `dump`, even if
|
|
7744
|
+
* {@link LRUCache.OptionsBase.allowStale} is false.
|
|
7745
|
+
*
|
|
7746
|
+
* Note: this returns an actual array, not a generator, so it can be more
|
|
7747
|
+
* easily passed around.
|
|
7679
7748
|
*/
|
|
7680
7749
|
dump() {
|
|
7681
7750
|
const arr = [];
|
|
@@ -7700,8 +7769,12 @@ var LRUCache = class _LRUCache {
|
|
|
7700
7769
|
}
|
|
7701
7770
|
/**
|
|
7702
7771
|
* Reset the cache and load in the items in entries in the order listed.
|
|
7703
|
-
*
|
|
7704
|
-
*
|
|
7772
|
+
*
|
|
7773
|
+
* The shape of the resulting cache may be different if the same options are
|
|
7774
|
+
* not used in both caches.
|
|
7775
|
+
*
|
|
7776
|
+
* The `start` fields are assumed to be calculated relative to a portable
|
|
7777
|
+
* `Date.now()` timestamp, even if `performance.now()` is available.
|
|
7705
7778
|
*/
|
|
7706
7779
|
load(arr) {
|
|
7707
7780
|
this.clear();
|
|
@@ -7718,6 +7791,30 @@ var LRUCache = class _LRUCache {
|
|
|
7718
7791
|
*
|
|
7719
7792
|
* Note: if `undefined` is specified as a value, this is an alias for
|
|
7720
7793
|
* {@link LRUCache#delete}
|
|
7794
|
+
*
|
|
7795
|
+
* Fields on the {@link LRUCache.SetOptions} options param will override
|
|
7796
|
+
* their corresponding values in the constructor options for the scope
|
|
7797
|
+
* of this single `set()` operation.
|
|
7798
|
+
*
|
|
7799
|
+
* If `start` is provided, then that will set the effective start
|
|
7800
|
+
* time for the TTL calculation. Note that this must be a previous
|
|
7801
|
+
* value of `performance.now()` if supported, or a previous value of
|
|
7802
|
+
* `Date.now()` if not.
|
|
7803
|
+
*
|
|
7804
|
+
* Options object may also include `size`, which will prevent
|
|
7805
|
+
* calling the `sizeCalculation` function and just use the specified
|
|
7806
|
+
* number if it is a positive integer, and `noDisposeOnSet` which
|
|
7807
|
+
* will prevent calling a `dispose` function in the case of
|
|
7808
|
+
* overwrites.
|
|
7809
|
+
*
|
|
7810
|
+
* If the `size` (or return value of `sizeCalculation`) for a given
|
|
7811
|
+
* entry is greater than `maxEntrySize`, then the item will not be
|
|
7812
|
+
* added to the cache.
|
|
7813
|
+
*
|
|
7814
|
+
* Will update the recency of the entry.
|
|
7815
|
+
*
|
|
7816
|
+
* If the value is `undefined`, then this is an alias for
|
|
7817
|
+
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
|
7721
7818
|
*/
|
|
7722
7819
|
set(k, v, setOptions = {}) {
|
|
7723
7820
|
if (v === void 0) {
|
|
@@ -7732,7 +7829,7 @@ var LRUCache = class _LRUCache {
|
|
|
7732
7829
|
status.set = "miss";
|
|
7733
7830
|
status.maxEntrySizeExceeded = true;
|
|
7734
7831
|
}
|
|
7735
|
-
this
|
|
7832
|
+
this.#delete(k, "set");
|
|
7736
7833
|
return this;
|
|
7737
7834
|
}
|
|
7738
7835
|
let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
|
|
@@ -7749,6 +7846,9 @@ var LRUCache = class _LRUCache {
|
|
|
7749
7846
|
if (status)
|
|
7750
7847
|
status.set = "add";
|
|
7751
7848
|
noUpdateTTL = false;
|
|
7849
|
+
if (this.#hasOnInsert) {
|
|
7850
|
+
this.#onInsert?.(v, k, "add");
|
|
7851
|
+
}
|
|
7752
7852
|
} else {
|
|
7753
7853
|
this.#moveToTail(index);
|
|
7754
7854
|
const oldVal = this.#valList[index];
|
|
@@ -7784,6 +7884,9 @@ var LRUCache = class _LRUCache {
|
|
|
7784
7884
|
} else if (status) {
|
|
7785
7885
|
status.set = "update";
|
|
7786
7886
|
}
|
|
7887
|
+
if (this.#hasOnInsert) {
|
|
7888
|
+
this.onInsert?.(v, k, v === oldVal ? "update" : "replace");
|
|
7889
|
+
}
|
|
7787
7890
|
}
|
|
7788
7891
|
if (ttl !== 0 && !this.#ttls) {
|
|
7789
7892
|
this.#initializeTTLTracking();
|
|
@@ -7866,6 +7969,14 @@ var LRUCache = class _LRUCache {
|
|
|
7866
7969
|
* Will return false if the item is stale, even though it is technically
|
|
7867
7970
|
* in the cache.
|
|
7868
7971
|
*
|
|
7972
|
+
* Check if a key is in the cache, without updating the recency of
|
|
7973
|
+
* use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
|
|
7974
|
+
* to `true` in either the options or the constructor.
|
|
7975
|
+
*
|
|
7976
|
+
* Will return `false` if the item is stale, even though it is technically in
|
|
7977
|
+
* the cache. The difference can be determined (if it matters) by using a
|
|
7978
|
+
* `status` argument, and inspecting the `has` field.
|
|
7979
|
+
*
|
|
7869
7980
|
* Will not update item age unless
|
|
7870
7981
|
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
7871
7982
|
*/
|
|
@@ -7948,7 +8059,7 @@ var LRUCache = class _LRUCache {
|
|
|
7948
8059
|
if (bf2.__staleWhileFetching) {
|
|
7949
8060
|
this.#valList[index] = bf2.__staleWhileFetching;
|
|
7950
8061
|
} else {
|
|
7951
|
-
this
|
|
8062
|
+
this.#delete(k, "fetch");
|
|
7952
8063
|
}
|
|
7953
8064
|
} else {
|
|
7954
8065
|
if (options.status)
|
|
@@ -7974,7 +8085,7 @@ var LRUCache = class _LRUCache {
|
|
|
7974
8085
|
if (this.#valList[index] === p) {
|
|
7975
8086
|
const del = !noDelete || bf2.__staleWhileFetching === void 0;
|
|
7976
8087
|
if (del) {
|
|
7977
|
-
this
|
|
8088
|
+
this.#delete(k, "fetch");
|
|
7978
8089
|
} else if (!allowStaleAborted) {
|
|
7979
8090
|
this.#valList[index] = bf2.__staleWhileFetching;
|
|
7980
8091
|
}
|
|
@@ -8112,6 +8223,28 @@ var LRUCache = class _LRUCache {
|
|
|
8112
8223
|
return staleVal ? p.__staleWhileFetching : p.__returned = p;
|
|
8113
8224
|
}
|
|
8114
8225
|
}
|
|
8226
|
+
async forceFetch(k, fetchOptions = {}) {
|
|
8227
|
+
const v = await this.fetch(k, fetchOptions);
|
|
8228
|
+
if (v === void 0)
|
|
8229
|
+
throw new Error("fetch() returned undefined");
|
|
8230
|
+
return v;
|
|
8231
|
+
}
|
|
8232
|
+
memo(k, memoOptions = {}) {
|
|
8233
|
+
const memoMethod = this.#memoMethod;
|
|
8234
|
+
if (!memoMethod) {
|
|
8235
|
+
throw new Error("no memoMethod provided to constructor");
|
|
8236
|
+
}
|
|
8237
|
+
const { context, forceRefresh, ...options } = memoOptions;
|
|
8238
|
+
const v = this.get(k, options);
|
|
8239
|
+
if (!forceRefresh && v !== void 0)
|
|
8240
|
+
return v;
|
|
8241
|
+
const vv = memoMethod(k, v, {
|
|
8242
|
+
options,
|
|
8243
|
+
context
|
|
8244
|
+
});
|
|
8245
|
+
this.set(k, vv, options);
|
|
8246
|
+
return vv;
|
|
8247
|
+
}
|
|
8115
8248
|
/**
|
|
8116
8249
|
* Return a value from the cache. Will update the recency of the cache
|
|
8117
8250
|
* entry found.
|
|
@@ -8131,7 +8264,7 @@ var LRUCache = class _LRUCache {
|
|
|
8131
8264
|
status.get = "stale";
|
|
8132
8265
|
if (!fetching) {
|
|
8133
8266
|
if (!noDeleteOnStaleGet) {
|
|
8134
|
-
this
|
|
8267
|
+
this.#delete(k, "expire");
|
|
8135
8268
|
}
|
|
8136
8269
|
if (status && allowStale)
|
|
8137
8270
|
status.returnedStale = true;
|
|
@@ -8175,16 +8308,20 @@ var LRUCache = class _LRUCache {
|
|
|
8175
8308
|
}
|
|
8176
8309
|
/**
|
|
8177
8310
|
* Deletes a key out of the cache.
|
|
8311
|
+
*
|
|
8178
8312
|
* Returns true if the key was deleted, false otherwise.
|
|
8179
8313
|
*/
|
|
8180
8314
|
delete(k) {
|
|
8315
|
+
return this.#delete(k, "delete");
|
|
8316
|
+
}
|
|
8317
|
+
#delete(k, reason) {
|
|
8181
8318
|
let deleted = false;
|
|
8182
8319
|
if (this.#size !== 0) {
|
|
8183
8320
|
const index = this.#keyMap.get(k);
|
|
8184
8321
|
if (index !== void 0) {
|
|
8185
8322
|
deleted = true;
|
|
8186
8323
|
if (this.#size === 1) {
|
|
8187
|
-
this
|
|
8324
|
+
this.#clear(reason);
|
|
8188
8325
|
} else {
|
|
8189
8326
|
this.#removeItemSize(index);
|
|
8190
8327
|
const v = this.#valList[index];
|
|
@@ -8192,10 +8329,10 @@ var LRUCache = class _LRUCache {
|
|
|
8192
8329
|
v.__abortController.abort(new Error("deleted"));
|
|
8193
8330
|
} else if (this.#hasDispose || this.#hasDisposeAfter) {
|
|
8194
8331
|
if (this.#hasDispose) {
|
|
8195
|
-
this.#dispose?.(v, k,
|
|
8332
|
+
this.#dispose?.(v, k, reason);
|
|
8196
8333
|
}
|
|
8197
8334
|
if (this.#hasDisposeAfter) {
|
|
8198
|
-
this.#disposed?.push([v, k,
|
|
8335
|
+
this.#disposed?.push([v, k, reason]);
|
|
8199
8336
|
}
|
|
8200
8337
|
}
|
|
8201
8338
|
this.#keyMap.delete(k);
|
|
@@ -8229,6 +8366,9 @@ var LRUCache = class _LRUCache {
|
|
|
8229
8366
|
* Clear the cache entirely, throwing away all values.
|
|
8230
8367
|
*/
|
|
8231
8368
|
clear() {
|
|
8369
|
+
return this.#clear("delete");
|
|
8370
|
+
}
|
|
8371
|
+
#clear(reason) {
|
|
8232
8372
|
for (const index of this.#rindexes({ allowStale: true })) {
|
|
8233
8373
|
const v = this.#valList[index];
|
|
8234
8374
|
if (this.#isBackgroundFetch(v)) {
|
|
@@ -8236,10 +8376,10 @@ var LRUCache = class _LRUCache {
|
|
|
8236
8376
|
} else {
|
|
8237
8377
|
const k = this.#keyList[index];
|
|
8238
8378
|
if (this.#hasDispose) {
|
|
8239
|
-
this.#dispose?.(v, k,
|
|
8379
|
+
this.#dispose?.(v, k, reason);
|
|
8240
8380
|
}
|
|
8241
8381
|
if (this.#hasDisposeAfter) {
|
|
8242
|
-
this.#disposed?.push([v, k,
|
|
8382
|
+
this.#disposed?.push([v, k, reason]);
|
|
8243
8383
|
}
|
|
8244
8384
|
}
|
|
8245
8385
|
}
|
|
@@ -9367,6 +9507,8 @@ var PathBase = class {
|
|
|
9367
9507
|
/**
|
|
9368
9508
|
* Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
|
|
9369
9509
|
* this property refers to the *parent* path, not the path object itself.
|
|
9510
|
+
*
|
|
9511
|
+
* @deprecated
|
|
9370
9512
|
*/
|
|
9371
9513
|
get path() {
|
|
9372
9514
|
return this.parentPath;
|