@pixi/assets
Advanced tools
Comparing version 7.1.1 to 7.1.2
@@ -86,2 +86,5 @@ 'use strict'; | ||
} | ||
if (!this.resolver.hasKey(url)) { | ||
this.resolver.add(url, url); | ||
} | ||
return url; | ||
@@ -88,0 +91,0 @@ }); |
@@ -46,5 +46,2 @@ 'use strict'; | ||
async load(url, options) { | ||
if (!globalThis.navigator.onLine) { | ||
throw new Error("[loadWebFont] Cannot load font - navigator is offline"); | ||
} | ||
const fonts = core.settings.ADAPTER.getFontFaceSet(); | ||
@@ -51,0 +48,0 @@ if (fonts) { |
@@ -55,2 +55,3 @@ import type { PreferOrder, ResolveAsset, ResolverBundle, ResolverManifest, ResolveURLParser } from './types'; | ||
export declare class Resolver { | ||
private _defaultBundleIdentifierOptions; | ||
/** The character that is used to connect the bundleId and the assetId when generating a bundle asset id key */ | ||
@@ -288,2 +289,12 @@ private _bundleIdConnector; | ||
/** | ||
* Checks if an asset with a given key exists in the resolver | ||
* @param key - The key of the asset | ||
*/ | ||
hasKey(key: string): boolean; | ||
/** | ||
* Checks if a bundle with the given key exists in the resolver | ||
* @param key - The key of the bundle | ||
*/ | ||
hasBundle(key: string): boolean; | ||
/** | ||
* Internal function for figuring out what prefer criteria an asset should use. | ||
@@ -290,0 +301,0 @@ * @param assets |
@@ -12,5 +12,10 @@ 'use strict'; | ||
constructor() { | ||
this._bundleIdConnector = "-"; | ||
this._createBundleAssetId = (bundleId, assetId) => `${bundleId}${this._bundleIdConnector}${assetId}`; | ||
this._extractAssetIdFromBundle = (bundleId, assetBundleId) => assetBundleId.replace(`${bundleId}${this._bundleIdConnector}`, ""); | ||
this._defaultBundleIdentifierOptions = { | ||
connector: "-", | ||
createBundleAssetId: (bundleId, assetId) => `${bundleId}${this._bundleIdConnector}${assetId}`, | ||
extractAssetIdFromBundle: (bundleId, assetBundleId) => assetBundleId.replace(`${bundleId}${this._bundleIdConnector}`, "") | ||
}; | ||
this._bundleIdConnector = this._defaultBundleIdentifierOptions.connector; | ||
this._createBundleAssetId = this._defaultBundleIdentifierOptions.createBundleAssetId; | ||
this._extractAssetIdFromBundle = this._defaultBundleIdentifierOptions.extractAssetIdFromBundle; | ||
this._assetMap = {}; | ||
@@ -55,8 +60,11 @@ this._preferredOrder = []; | ||
reset() { | ||
this.setBundleIdentifier(this._defaultBundleIdentifierOptions); | ||
this._assetMap = {}; | ||
this._preferredOrder = []; | ||
this._resolverHash = {}; | ||
this._assetMap = {}; | ||
this._rootPath = null; | ||
this._basePath = null; | ||
this._manifest = null; | ||
this._bundles = {}; | ||
this._defaultSearchParams = null; | ||
} | ||
@@ -107,3 +115,3 @@ setDefaultSearchParams(searchParams) { | ||
keys.forEach((key) => { | ||
if (this._assetMap[key]) { | ||
if (this.hasKey(key)) { | ||
console.warn(`[Resolver] already has key: ${key} overwriting`); | ||
@@ -222,2 +230,8 @@ } | ||
} | ||
hasKey(key) { | ||
return !!this._assetMap[key]; | ||
} | ||
hasBundle(key) { | ||
return !!this._bundles[key]; | ||
} | ||
_getPreferredOrder(assets) { | ||
@@ -224,0 +238,0 @@ for (let i = 0; i < assets.length; i++) { |
{ | ||
"name": "@pixi/assets", | ||
"version": "7.1.1", | ||
"version": "7.1.2", | ||
"description": "Asset manager for PixiJS, loading resolving and Cacheing", | ||
@@ -52,3 +52,3 @@ "keywords": [ | ||
], | ||
"gitHead": "99b26d1d5a18760019b034c69c5979ca5e6c536b" | ||
"gitHead": "27e65c73bb36a06fd00d6da5bf460bbee9f6c984" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
435113
4041