sdfsdfs
This commit is contained in:
54
node_modules/pixi.js/lib/assets/cache/Cache.d.ts
generated
vendored
Normal file
54
node_modules/pixi.js/lib/assets/cache/Cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import type { CacheParser } from './CacheParser';
|
||||
/**
|
||||
* A single Cache for all assets.
|
||||
*
|
||||
* When assets are added to the cache via set they normally are added to the cache as key-value pairs.
|
||||
*
|
||||
* With this cache, you can add parsers that will take the object and convert it to a list of assets that can be cached.
|
||||
* for example a cacheSpritesheet parser will add all of the textures found within its sprite sheet directly to the cache.
|
||||
*
|
||||
* This gives devs the flexibility to cache any type of object however we want.
|
||||
*
|
||||
* It is not intended that this class is created by developers - it is part of the Asset package.
|
||||
* This is the first major system of PixiJS' main Assets class.
|
||||
* @example
|
||||
* import { Cache } from 'pixi.js';
|
||||
*
|
||||
* Cache.set('bunny', bunnyTexture);
|
||||
* @class Cache
|
||||
* @memberof assets
|
||||
*/
|
||||
declare class CacheClass {
|
||||
private readonly _parsers;
|
||||
private readonly _cache;
|
||||
private readonly _cacheMap;
|
||||
/** Clear all entries. */
|
||||
reset(): void;
|
||||
/**
|
||||
* Check if the key exists
|
||||
* @param key - The key to check
|
||||
*/
|
||||
has(key: any): boolean;
|
||||
/**
|
||||
* Fetch entry by key
|
||||
* @param key - The key of the entry to get
|
||||
*/
|
||||
get<T = any>(key: any): T;
|
||||
/**
|
||||
* Set a value by key or keys name
|
||||
* @param key - The key or keys to set
|
||||
* @param value - The value to store in the cache or from which cacheable assets will be derived.
|
||||
*/
|
||||
set(key: any | any[], value: unknown): void;
|
||||
/**
|
||||
* Remove entry by key
|
||||
*
|
||||
* This function will also remove any associated alias from the cache also.
|
||||
* @param key - The key of the entry to remove
|
||||
*/
|
||||
remove(key: any): void;
|
||||
/** All loader parsers registered */
|
||||
get parsers(): CacheParser[];
|
||||
}
|
||||
export declare const Cache: CacheClass;
|
||||
export {};
|
101
node_modules/pixi.js/lib/assets/cache/Cache.js
generated
vendored
Normal file
101
node_modules/pixi.js/lib/assets/cache/Cache.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
|
||||
var warn = require('../../utils/logging/warn.js');
|
||||
var convertToList = require('../utils/convertToList.js');
|
||||
|
||||
"use strict";
|
||||
class CacheClass {
|
||||
constructor() {
|
||||
this._parsers = [];
|
||||
this._cache = /* @__PURE__ */ new Map();
|
||||
this._cacheMap = /* @__PURE__ */ new Map();
|
||||
}
|
||||
/** Clear all entries. */
|
||||
reset() {
|
||||
this._cacheMap.clear();
|
||||
this._cache.clear();
|
||||
}
|
||||
/**
|
||||
* Check if the key exists
|
||||
* @param key - The key to check
|
||||
*/
|
||||
has(key) {
|
||||
return this._cache.has(key);
|
||||
}
|
||||
/**
|
||||
* Fetch entry by key
|
||||
* @param key - The key of the entry to get
|
||||
*/
|
||||
get(key) {
|
||||
const result = this._cache.get(key);
|
||||
if (!result) {
|
||||
warn.warn(`[Assets] Asset id ${key} was not found in the Cache`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Set a value by key or keys name
|
||||
* @param key - The key or keys to set
|
||||
* @param value - The value to store in the cache or from which cacheable assets will be derived.
|
||||
*/
|
||||
set(key, value) {
|
||||
const keys = convertToList.convertToList(key);
|
||||
let cacheableAssets;
|
||||
for (let i = 0; i < this.parsers.length; i++) {
|
||||
const parser = this.parsers[i];
|
||||
if (parser.test(value)) {
|
||||
cacheableAssets = parser.getCacheableAssets(keys, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const cacheableMap = new Map(Object.entries(cacheableAssets || {}));
|
||||
if (!cacheableAssets) {
|
||||
keys.forEach((key2) => {
|
||||
cacheableMap.set(key2, value);
|
||||
});
|
||||
}
|
||||
const cacheKeys = [...cacheableMap.keys()];
|
||||
const cachedAssets = {
|
||||
cacheKeys,
|
||||
keys
|
||||
};
|
||||
keys.forEach((key2) => {
|
||||
this._cacheMap.set(key2, cachedAssets);
|
||||
});
|
||||
cacheKeys.forEach((key2) => {
|
||||
const val = cacheableAssets ? cacheableAssets[key2] : value;
|
||||
if (this._cache.has(key2) && this._cache.get(key2) !== val) {
|
||||
warn.warn("[Cache] already has key:", key2);
|
||||
}
|
||||
this._cache.set(key2, cacheableMap.get(key2));
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Remove entry by key
|
||||
*
|
||||
* This function will also remove any associated alias from the cache also.
|
||||
* @param key - The key of the entry to remove
|
||||
*/
|
||||
remove(key) {
|
||||
if (!this._cacheMap.has(key)) {
|
||||
warn.warn(`[Assets] Asset id ${key} was not found in the Cache`);
|
||||
return;
|
||||
}
|
||||
const cacheMap = this._cacheMap.get(key);
|
||||
const cacheKeys = cacheMap.cacheKeys;
|
||||
cacheKeys.forEach((key2) => {
|
||||
this._cache.delete(key2);
|
||||
});
|
||||
cacheMap.keys.forEach((key2) => {
|
||||
this._cacheMap.delete(key2);
|
||||
});
|
||||
}
|
||||
/** All loader parsers registered */
|
||||
get parsers() {
|
||||
return this._parsers;
|
||||
}
|
||||
}
|
||||
const Cache = new CacheClass();
|
||||
|
||||
exports.Cache = Cache;
|
||||
//# sourceMappingURL=Cache.js.map
|
1
node_modules/pixi.js/lib/assets/cache/Cache.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/assets/cache/Cache.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
99
node_modules/pixi.js/lib/assets/cache/Cache.mjs
generated
vendored
Normal file
99
node_modules/pixi.js/lib/assets/cache/Cache.mjs
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
import { warn } from '../../utils/logging/warn.mjs';
|
||||
import { convertToList } from '../utils/convertToList.mjs';
|
||||
|
||||
"use strict";
|
||||
class CacheClass {
|
||||
constructor() {
|
||||
this._parsers = [];
|
||||
this._cache = /* @__PURE__ */ new Map();
|
||||
this._cacheMap = /* @__PURE__ */ new Map();
|
||||
}
|
||||
/** Clear all entries. */
|
||||
reset() {
|
||||
this._cacheMap.clear();
|
||||
this._cache.clear();
|
||||
}
|
||||
/**
|
||||
* Check if the key exists
|
||||
* @param key - The key to check
|
||||
*/
|
||||
has(key) {
|
||||
return this._cache.has(key);
|
||||
}
|
||||
/**
|
||||
* Fetch entry by key
|
||||
* @param key - The key of the entry to get
|
||||
*/
|
||||
get(key) {
|
||||
const result = this._cache.get(key);
|
||||
if (!result) {
|
||||
warn(`[Assets] Asset id ${key} was not found in the Cache`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Set a value by key or keys name
|
||||
* @param key - The key or keys to set
|
||||
* @param value - The value to store in the cache or from which cacheable assets will be derived.
|
||||
*/
|
||||
set(key, value) {
|
||||
const keys = convertToList(key);
|
||||
let cacheableAssets;
|
||||
for (let i = 0; i < this.parsers.length; i++) {
|
||||
const parser = this.parsers[i];
|
||||
if (parser.test(value)) {
|
||||
cacheableAssets = parser.getCacheableAssets(keys, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const cacheableMap = new Map(Object.entries(cacheableAssets || {}));
|
||||
if (!cacheableAssets) {
|
||||
keys.forEach((key2) => {
|
||||
cacheableMap.set(key2, value);
|
||||
});
|
||||
}
|
||||
const cacheKeys = [...cacheableMap.keys()];
|
||||
const cachedAssets = {
|
||||
cacheKeys,
|
||||
keys
|
||||
};
|
||||
keys.forEach((key2) => {
|
||||
this._cacheMap.set(key2, cachedAssets);
|
||||
});
|
||||
cacheKeys.forEach((key2) => {
|
||||
const val = cacheableAssets ? cacheableAssets[key2] : value;
|
||||
if (this._cache.has(key2) && this._cache.get(key2) !== val) {
|
||||
warn("[Cache] already has key:", key2);
|
||||
}
|
||||
this._cache.set(key2, cacheableMap.get(key2));
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Remove entry by key
|
||||
*
|
||||
* This function will also remove any associated alias from the cache also.
|
||||
* @param key - The key of the entry to remove
|
||||
*/
|
||||
remove(key) {
|
||||
if (!this._cacheMap.has(key)) {
|
||||
warn(`[Assets] Asset id ${key} was not found in the Cache`);
|
||||
return;
|
||||
}
|
||||
const cacheMap = this._cacheMap.get(key);
|
||||
const cacheKeys = cacheMap.cacheKeys;
|
||||
cacheKeys.forEach((key2) => {
|
||||
this._cache.delete(key2);
|
||||
});
|
||||
cacheMap.keys.forEach((key2) => {
|
||||
this._cacheMap.delete(key2);
|
||||
});
|
||||
}
|
||||
/** All loader parsers registered */
|
||||
get parsers() {
|
||||
return this._parsers;
|
||||
}
|
||||
}
|
||||
const Cache = new CacheClass();
|
||||
|
||||
export { Cache };
|
||||
//# sourceMappingURL=Cache.mjs.map
|
1
node_modules/pixi.js/lib/assets/cache/Cache.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/assets/cache/Cache.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
32
node_modules/pixi.js/lib/assets/cache/CacheParser.d.ts
generated
vendored
Normal file
32
node_modules/pixi.js/lib/assets/cache/CacheParser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { ExtensionMetadata } from '../../extensions/Extensions';
|
||||
/**
|
||||
* For every asset that is cached, it will call the parsers test function
|
||||
* the flow is as follows:
|
||||
*
|
||||
* 1. `cacheParser.test()`: Test the asset.
|
||||
* 2. `cacheParser.getCacheableAssets()`: If the test passes call the getCacheableAssets function with the asset
|
||||
*
|
||||
* Useful if you want to add more than just a raw asset to the cache
|
||||
* (for example a spritesheet will want to make all its sub textures easily accessible in the cache)
|
||||
* @memberof assets
|
||||
*/
|
||||
export interface CacheParser<T = any> {
|
||||
/** The extension type of this cache parser */
|
||||
extension?: ExtensionMetadata;
|
||||
/** A config to adjust the parser */
|
||||
config?: Record<string, any>;
|
||||
/**
|
||||
* Gets called by the cache when a dev caches an asset
|
||||
* @param asset - the asset to test
|
||||
*/
|
||||
test: (asset: T) => boolean;
|
||||
/**
|
||||
* If the test passes, this function is called to get the cacheable assets
|
||||
* an example may be that a spritesheet object will return all the sub textures it has so they can
|
||||
* be cached.
|
||||
* @param keys - The keys to cache the assets under
|
||||
* @param asset - The asset to get the cacheable assets from
|
||||
* @returns A key-value pair of cacheable assets
|
||||
*/
|
||||
getCacheableAssets: (keys: string[], asset: T) => Record<string, any>;
|
||||
}
|
4
node_modules/pixi.js/lib/assets/cache/CacheParser.js
generated
vendored
Normal file
4
node_modules/pixi.js/lib/assets/cache/CacheParser.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
"use strict";
|
||||
//# sourceMappingURL=CacheParser.js.map
|
1
node_modules/pixi.js/lib/assets/cache/CacheParser.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/assets/cache/CacheParser.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CacheParser.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
2
node_modules/pixi.js/lib/assets/cache/CacheParser.mjs
generated
vendored
Normal file
2
node_modules/pixi.js/lib/assets/cache/CacheParser.mjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=CacheParser.mjs.map
|
1
node_modules/pixi.js/lib/assets/cache/CacheParser.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/assets/cache/CacheParser.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CacheParser.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
7
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.d.ts
generated
vendored
Normal file
7
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Texture } from '../../../rendering/renderers/shared/texture/Texture';
|
||||
import type { CacheParser } from '../CacheParser';
|
||||
/**
|
||||
* Returns an object of textures from an array of textures to be cached
|
||||
* @memberof assets
|
||||
*/
|
||||
export declare const cacheTextureArray: CacheParser<Texture[]>;
|
25
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.js
generated
vendored
Normal file
25
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var Extensions = require('../../../extensions/Extensions.js');
|
||||
var Texture = require('../../../rendering/renderers/shared/texture/Texture.js');
|
||||
|
||||
"use strict";
|
||||
const cacheTextureArray = {
|
||||
extension: {
|
||||
type: Extensions.ExtensionType.CacheParser,
|
||||
name: "cacheTextureArray"
|
||||
},
|
||||
test: (asset) => Array.isArray(asset) && asset.every((t) => t instanceof Texture.Texture),
|
||||
getCacheableAssets: (keys, asset) => {
|
||||
const out = {};
|
||||
keys.forEach((key) => {
|
||||
asset.forEach((item, i) => {
|
||||
out[key + (i === 0 ? "" : i + 1)] = item;
|
||||
});
|
||||
});
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
exports.cacheTextureArray = cacheTextureArray;
|
||||
//# sourceMappingURL=cacheTextureArray.js.map
|
1
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cacheTextureArray.js","sources":["../../../../src/assets/cache/parsers/cacheTextureArray.ts"],"sourcesContent":["import { ExtensionType } from '../../../extensions/Extensions';\nimport { Texture } from '../../../rendering/renderers/shared/texture/Texture';\n\nimport type { CacheParser } from '../CacheParser';\n\n/**\n * Returns an object of textures from an array of textures to be cached\n * @memberof assets\n */\nexport const cacheTextureArray: CacheParser<Texture[]> = {\n extension: {\n type: ExtensionType.CacheParser,\n name: 'cacheTextureArray',\n },\n\n test: (asset: any[]) => Array.isArray(asset) && asset.every((t) => t instanceof Texture),\n\n getCacheableAssets: (keys: string[], asset: Texture[]) =>\n {\n const out: Record<string, Texture> = {};\n\n keys.forEach((key: string) =>\n {\n asset.forEach((item: Texture, i: number) =>\n {\n out[key + (i === 0 ? '' : i + 1)] = item;\n });\n });\n\n return out;\n }\n};\n"],"names":["ExtensionType","Texture"],"mappings":";;;;;;AASO,MAAM,iBAA4C,GAAA;AAAA,EACrD,SAAW,EAAA;AAAA,IACP,MAAMA,wBAAc,CAAA,WAAA;AAAA,IACpB,IAAM,EAAA,mBAAA;AAAA,GACV;AAAA,EAEA,IAAM,EAAA,CAAC,KAAiB,KAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAK,IAAA,KAAA,CAAM,KAAM,CAAA,CAAC,CAAM,KAAA,CAAA,YAAaC,eAAO,CAAA;AAAA,EAEvF,kBAAA,EAAoB,CAAC,IAAA,EAAgB,KACrC,KAAA;AACI,IAAA,MAAM,MAA+B,EAAC,CAAA;AAEtC,IAAK,IAAA,CAAA,OAAA,CAAQ,CAAC,GACd,KAAA;AACI,MAAM,KAAA,CAAA,OAAA,CAAQ,CAAC,IAAA,EAAe,CAC9B,KAAA;AACI,QAAA,GAAA,CAAI,OAAO,CAAM,KAAA,CAAA,GAAI,EAAK,GAAA,CAAA,GAAI,EAAE,CAAI,GAAA,IAAA,CAAA;AAAA,OACvC,CAAA,CAAA;AAAA,KACJ,CAAA,CAAA;AAED,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AACJ;;;;"}
|
23
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.mjs
generated
vendored
Normal file
23
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.mjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ExtensionType } from '../../../extensions/Extensions.mjs';
|
||||
import { Texture } from '../../../rendering/renderers/shared/texture/Texture.mjs';
|
||||
|
||||
"use strict";
|
||||
const cacheTextureArray = {
|
||||
extension: {
|
||||
type: ExtensionType.CacheParser,
|
||||
name: "cacheTextureArray"
|
||||
},
|
||||
test: (asset) => Array.isArray(asset) && asset.every((t) => t instanceof Texture),
|
||||
getCacheableAssets: (keys, asset) => {
|
||||
const out = {};
|
||||
keys.forEach((key) => {
|
||||
asset.forEach((item, i) => {
|
||||
out[key + (i === 0 ? "" : i + 1)] = item;
|
||||
});
|
||||
});
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
export { cacheTextureArray };
|
||||
//# sourceMappingURL=cacheTextureArray.mjs.map
|
1
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/assets/cache/parsers/cacheTextureArray.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cacheTextureArray.mjs","sources":["../../../../src/assets/cache/parsers/cacheTextureArray.ts"],"sourcesContent":["import { ExtensionType } from '../../../extensions/Extensions';\nimport { Texture } from '../../../rendering/renderers/shared/texture/Texture';\n\nimport type { CacheParser } from '../CacheParser';\n\n/**\n * Returns an object of textures from an array of textures to be cached\n * @memberof assets\n */\nexport const cacheTextureArray: CacheParser<Texture[]> = {\n extension: {\n type: ExtensionType.CacheParser,\n name: 'cacheTextureArray',\n },\n\n test: (asset: any[]) => Array.isArray(asset) && asset.every((t) => t instanceof Texture),\n\n getCacheableAssets: (keys: string[], asset: Texture[]) =>\n {\n const out: Record<string, Texture> = {};\n\n keys.forEach((key: string) =>\n {\n asset.forEach((item: Texture, i: number) =>\n {\n out[key + (i === 0 ? '' : i + 1)] = item;\n });\n });\n\n return out;\n }\n};\n"],"names":[],"mappings":";;;;AASO,MAAM,iBAA4C,GAAA;AAAA,EACrD,SAAW,EAAA;AAAA,IACP,MAAM,aAAc,CAAA,WAAA;AAAA,IACpB,IAAM,EAAA,mBAAA;AAAA,GACV;AAAA,EAEA,IAAM,EAAA,CAAC,KAAiB,KAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAK,IAAA,KAAA,CAAM,KAAM,CAAA,CAAC,CAAM,KAAA,CAAA,YAAa,OAAO,CAAA;AAAA,EAEvF,kBAAA,EAAoB,CAAC,IAAA,EAAgB,KACrC,KAAA;AACI,IAAA,MAAM,MAA+B,EAAC,CAAA;AAEtC,IAAK,IAAA,CAAA,OAAA,CAAQ,CAAC,GACd,KAAA;AACI,MAAM,KAAA,CAAA,OAAA,CAAQ,CAAC,IAAA,EAAe,CAC9B,KAAA;AACI,QAAA,GAAA,CAAI,OAAO,CAAM,KAAA,CAAA,GAAI,EAAK,GAAA,CAAA,GAAI,EAAE,CAAI,GAAA,IAAA,CAAA;AAAA,OACvC,CAAA,CAAA;AAAA,KACJ,CAAA,CAAA;AAED,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AACJ;;;;"}
|
Reference in New Issue
Block a user