initial commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
shadow$provide.module$node_modules$pixi_DOT_js$lib$assets$cache$Cache = function(global, require, module, exports) {
|
||||
var warn = require("module$node_modules$pixi_DOT_js$lib$utils$logging$warn"), convertToList = require("module$node_modules$pixi_DOT_js$lib$assets$utils$convertToList");
|
||||
"use strict";
|
||||
class CacheClass {
|
||||
constructor() {
|
||||
this._parsers = [];
|
||||
this._cache = new Map();
|
||||
this._cacheMap = new Map();
|
||||
}
|
||||
reset() {
|
||||
this._cacheMap.clear();
|
||||
this._cache.clear();
|
||||
}
|
||||
has(key) {
|
||||
return this._cache.has(key);
|
||||
}
|
||||
get(key) {
|
||||
const result = this._cache.get(key);
|
||||
result || warn.warn(`[Assets] Asset id ${key} was not found in the Cache`);
|
||||
return result;
|
||||
}
|
||||
set(key, value) {
|
||||
key = convertToList.convertToList(key);
|
||||
let cacheableAssets;
|
||||
for (var i = 0; i < this.parsers.length; i++) {
|
||||
const parser = this.parsers[i];
|
||||
if (parser.test(value)) {
|
||||
cacheableAssets = parser.getCacheableAssets(key, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const cacheableMap = new Map(Object.entries(cacheableAssets || {}));
|
||||
cacheableAssets || key.forEach(key2 => {
|
||||
cacheableMap.set(key2, value);
|
||||
});
|
||||
i = [...cacheableMap.keys()];
|
||||
const cachedAssets = {cacheKeys:i, keys:key};
|
||||
key.forEach(key2 => {
|
||||
this._cacheMap.set(key2, cachedAssets);
|
||||
});
|
||||
i.forEach(key2 => {
|
||||
const val = cacheableAssets ? cacheableAssets[key2] : value;
|
||||
this._cache.has(key2) && this._cache.get(key2) !== val && warn.warn("[Cache] already has key:", key2);
|
||||
this._cache.set(key2, cacheableMap.get(key2));
|
||||
});
|
||||
}
|
||||
remove(key) {
|
||||
this._cacheMap.has(key) ? (key = this._cacheMap.get(key), key.cacheKeys.forEach(key2 => {
|
||||
this._cache.delete(key2);
|
||||
}), key.keys.forEach(key2 => {
|
||||
this._cacheMap.delete(key2);
|
||||
})) : warn.warn(`[Assets] Asset id ${key} was not found in the Cache`);
|
||||
}
|
||||
get parsers() {
|
||||
return this._parsers;
|
||||
}
|
||||
}
|
||||
global = new CacheClass();
|
||||
exports.Cache = global;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$assets$cache$Cache.js.map
|
||||
Reference in New Issue
Block a user