mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-25 22:23:42 +08:00
[ts][pixi-v7][pixi-v8] Fix asset loaders not throwing when http response is not ok. See #3042.
This commit is contained in:
parent
80a1f4d38b
commit
592d57f114
@ -68,9 +68,10 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
||||
async load (url: string): Promise<RawAtlas> {
|
||||
const response = await settings.ADAPTER.fetch(url);
|
||||
|
||||
const txt = await response.text();
|
||||
if (!response.ok)
|
||||
throw new Error(`[${loaderName}] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
||||
|
||||
return txt;
|
||||
return await response.text();
|
||||
},
|
||||
|
||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||
@ -106,7 +107,6 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
||||
// we will wait for all promises for the textures at the same time at the end.
|
||||
const textureLoadingPromises = [];
|
||||
|
||||
|
||||
// setting preferCreateImageBitmap to false for loadTextures loader to allow loading PMA images
|
||||
let oldPreferCreateImageBitmap = true;
|
||||
for (const parser of loader.parsers) {
|
||||
|
||||
@ -65,9 +65,10 @@ const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAss
|
||||
async load (url: string): Promise<SkeletonBinaryAsset> {
|
||||
const response = await settings.ADAPTER.fetch(url);
|
||||
|
||||
const buffer = new Uint8Array(await response.arrayBuffer());
|
||||
if (!response.ok)
|
||||
throw new Error(`[${loaderName}] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
||||
|
||||
return buffer;
|
||||
return new Uint8Array(await response.arrayBuffer());
|
||||
},
|
||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||
const isJsonSpineModel = checkExtension(options.src as string, ".json") && isJson(asset);
|
||||
|
||||
@ -83,9 +83,10 @@ const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtl
|
||||
async load (url: string): Promise<RawAtlas> {
|
||||
const response = await DOMAdapter.get().fetch(url);
|
||||
|
||||
const txt = await response.text();
|
||||
if (!response.ok)
|
||||
throw new Error(`[${loaderName}] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
||||
|
||||
return txt;
|
||||
return await response.text();
|
||||
},
|
||||
|
||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||
|
||||
@ -72,9 +72,10 @@ const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAss
|
||||
async load (url: string): Promise<SkeletonBinaryAsset> {
|
||||
const response = await DOMAdapter.get().fetch(url);
|
||||
|
||||
const buffer = new Uint8Array(await response.arrayBuffer());
|
||||
if (!response.ok)
|
||||
throw new Error(`[${loaderName}] Failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
||||
|
||||
return buffer;
|
||||
return new Uint8Array(await response.arrayBuffer());
|
||||
},
|
||||
testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
|
||||
const isJsonSpineModel = checkExtension(options.src as string, '.json') && isJson(asset);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user