util-helpers 4.23.1 → 4.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/util-helpers.js +23 -18
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/VERSION.js +1 -1
- package/esm/getImageInfo.js +5 -3
- package/esm/index.js +1 -1
- package/esm/loadImage.js +5 -3
- package/esm/loadImageWithBlob.js +4 -3
- package/esm/utils/getCacheKey.js +15 -0
- package/lib/VERSION.js +1 -1
- package/lib/getImageInfo.js +4 -2
- package/lib/index.js +1 -1
- package/lib/loadImage.js +4 -2
- package/lib/loadImageWithBlob.js +4 -3
- package/lib/utils/getCacheKey.js +17 -0
- package/package.json +4 -3
- package/types/utils/getCacheKey.d.ts +2 -0
- package/types/utils/Cache.d.ts +0 -14
package/dist/util-helpers.js
CHANGED
|
@@ -200,11 +200,6 @@
|
|
|
200
200
|
return isNil(value) ? '' : baseToString(value);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
var defaultTo = function (value, defaultValue) {
|
|
204
|
-
return value == null || value !== value ? defaultValue : value;
|
|
205
|
-
};
|
|
206
|
-
var defaultTo$1 = defaultTo;
|
|
207
|
-
|
|
208
203
|
var blobExisted = typeof Blob !== stringUndefined;
|
|
209
204
|
function isBlob(value) {
|
|
210
205
|
if (blobExisted && value instanceof Blob) {
|
|
@@ -283,6 +278,7 @@
|
|
|
283
278
|
|
|
284
279
|
var idCounter = 0;
|
|
285
280
|
function uniqueId(prefix) {
|
|
281
|
+
if (prefix === void 0) { prefix = ''; }
|
|
286
282
|
var id = ++idCounter;
|
|
287
283
|
return toString(prefix) + id;
|
|
288
284
|
}
|
|
@@ -1687,7 +1683,6 @@
|
|
|
1687
1683
|
function stringify(value, replacer) {
|
|
1688
1684
|
return JSON.stringify(value, replacer);
|
|
1689
1685
|
}
|
|
1690
|
-
var inWindow = typeof window !== 'undefined' && typeof window === 'object' && window.window === window;
|
|
1691
1686
|
|
|
1692
1687
|
var cache = {};
|
|
1693
1688
|
var MemoryStorage = /** @class */ (function () {
|
|
@@ -1973,10 +1968,6 @@
|
|
|
1973
1968
|
return Cache;
|
|
1974
1969
|
}(EmitterPro));
|
|
1975
1970
|
|
|
1976
|
-
new Storage(inWindow ? window.localStorage : undefined);
|
|
1977
|
-
|
|
1978
|
-
new Storage(inWindow ? window.sessionStorage : undefined);
|
|
1979
|
-
|
|
1980
1971
|
var AsyncMemo = (function () {
|
|
1981
1972
|
function AsyncMemo(options) {
|
|
1982
1973
|
this.promiseCache = {};
|
|
@@ -2011,6 +2002,17 @@
|
|
|
2011
2002
|
return AsyncMemo;
|
|
2012
2003
|
}());
|
|
2013
2004
|
|
|
2005
|
+
var wm = new WeakMap();
|
|
2006
|
+
var getCacheKey = function (obj) {
|
|
2007
|
+
if (typeof obj === 'string' || !obj) {
|
|
2008
|
+
return obj;
|
|
2009
|
+
}
|
|
2010
|
+
if (!wm.has(obj)) {
|
|
2011
|
+
wm.set(obj, uniqueId('__uh_cache_key__'));
|
|
2012
|
+
}
|
|
2013
|
+
return wm.get(obj);
|
|
2014
|
+
};
|
|
2015
|
+
|
|
2014
2016
|
var asyncMemo$2 = new AsyncMemo({ max: 1, maxStrategy: 'replaced' });
|
|
2015
2017
|
asyncMemo$2.cache.on('del', function (k, v) {
|
|
2016
2018
|
try {
|
|
@@ -2027,8 +2029,9 @@
|
|
|
2027
2029
|
var _cacheOptions = {
|
|
2028
2030
|
useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false,
|
|
2029
2031
|
autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions,
|
|
2030
|
-
cacheKey:
|
|
2032
|
+
cacheKey: cacheOptionsIsObject ? cacheOptions.cacheKey : undefined
|
|
2031
2033
|
};
|
|
2034
|
+
var cacheKey = _cacheOptions.useCache ? getCacheKey(_cacheOptions.cacheKey || img) : undefined;
|
|
2032
2035
|
return asyncMemo$2
|
|
2033
2036
|
.run(function () {
|
|
2034
2037
|
return new Promise(function (resolve, reject) {
|
|
@@ -2052,7 +2055,7 @@
|
|
|
2052
2055
|
})
|
|
2053
2056
|
.catch(reject);
|
|
2054
2057
|
});
|
|
2055
|
-
},
|
|
2058
|
+
}, cacheKey)
|
|
2056
2059
|
.then(function (res) { return res.data; });
|
|
2057
2060
|
}
|
|
2058
2061
|
|
|
@@ -2224,8 +2227,9 @@
|
|
|
2224
2227
|
var _cacheOptions = {
|
|
2225
2228
|
useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false,
|
|
2226
2229
|
autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions,
|
|
2227
|
-
cacheKey:
|
|
2230
|
+
cacheKey: cacheOptionsIsObject ? cacheOptions.cacheKey : undefined
|
|
2228
2231
|
};
|
|
2232
|
+
var cacheKey = _cacheOptions.useCache ? getCacheKey(_cacheOptions.cacheKey || img) : undefined;
|
|
2229
2233
|
return asyncMemo$1
|
|
2230
2234
|
.run(function () {
|
|
2231
2235
|
return loadImageWithBlob(img, false, ajaxOptions).then(function (_a) {
|
|
@@ -2246,7 +2250,7 @@
|
|
|
2246
2250
|
r: _cacheOptions.autoRevokeOnDel
|
|
2247
2251
|
};
|
|
2248
2252
|
});
|
|
2249
|
-
},
|
|
2253
|
+
}, cacheKey)
|
|
2250
2254
|
.then(function (res) { return res.data; });
|
|
2251
2255
|
}
|
|
2252
2256
|
|
|
@@ -2266,8 +2270,9 @@
|
|
|
2266
2270
|
var _cacheOptions = {
|
|
2267
2271
|
useCache: cacheOptionsIsObject ? cacheOptions.useCache !== false : cacheOptions !== false,
|
|
2268
2272
|
autoRevokeOnDel: cacheOptionsIsObject ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions,
|
|
2269
|
-
cacheKey:
|
|
2273
|
+
cacheKey: cacheOptionsIsObject ? cacheOptions.cacheKey : undefined
|
|
2270
2274
|
};
|
|
2275
|
+
var cacheKey = _cacheOptions.useCache ? getCacheKey(_cacheOptions.cacheKey || img) : undefined;
|
|
2271
2276
|
return asyncMemo
|
|
2272
2277
|
.run(function () {
|
|
2273
2278
|
return new Promise(function (resolve, reject) {
|
|
@@ -2292,7 +2297,7 @@
|
|
|
2292
2297
|
};
|
|
2293
2298
|
image.src = url;
|
|
2294
2299
|
});
|
|
2295
|
-
},
|
|
2300
|
+
}, cacheKey)
|
|
2296
2301
|
.then(function (res) { return res.data; });
|
|
2297
2302
|
}
|
|
2298
2303
|
|
|
@@ -2645,9 +2650,9 @@
|
|
|
2645
2650
|
return internalFindTreeSelect(tree, predicate, childrenField);
|
|
2646
2651
|
}
|
|
2647
2652
|
|
|
2648
|
-
var VERSION = "4.23.
|
|
2653
|
+
var VERSION = "4.23.3";
|
|
2649
2654
|
|
|
2650
|
-
var version = "4.23.
|
|
2655
|
+
var version = "4.23.3";
|
|
2651
2656
|
|
|
2652
2657
|
exports.AsyncMemo = AsyncMemo;
|
|
2653
2658
|
exports.VERSION = VERSION;
|