diff --git a/packages/webamp-modern-2/src/skin/ImageManager.ts b/packages/webamp-modern-2/src/skin/ImageManager.ts index 17454bde..77a8c588 100644 --- a/packages/webamp-modern-2/src/skin/ImageManager.ts +++ b/packages/webamp-modern-2/src/skin/ImageManager.ts @@ -9,9 +9,12 @@ export default class ImageManager { this._sizeCache = new Map(); } - async getUrl(filePath: string): Promise { + async getUrl(filePath: string): Promise { if (!this._urlCache.has(filePath)) { const zipFile = getCaseInsensitiveFile(this._zip, filePath); + if (zipFile == null) { + return null; + } const imgBlob = await zipFile.async("blob"); const imgUrl = await getUrlFromBlob(imgBlob); this._urlCache.set(filePath, imgUrl); diff --git a/packages/webamp-modern-2/src/skin/parse.ts b/packages/webamp-modern-2/src/skin/parse.ts index a85a3288..af6546d2 100644 --- a/packages/webamp-modern-2/src/skin/parse.ts +++ b/packages/webamp-modern-2/src/skin/parse.ts @@ -131,6 +131,7 @@ export default class SkinParser { assert(file != null, "Expected bitmap node to have a `file` attribute"); const imgUrl = await this._imageManager.getUrl(file); + assert(imgUrl != null, `Could not find bitmap at path ${file}`); const id = node.attributes.id; const x = num(node.attributes.x) ?? 0; @@ -152,14 +153,8 @@ export default class SkinParser { height = size.height; } - const bitmap = new Bitmap({ - url: imgUrl, - id, - x, - y, - width, - height, - }); + // prettier-ignore + const bitmap = new Bitmap({ url: imgUrl, id, x, y, width, height }); // TODO: Store this somewhere. For now, we can just show it. const div = document.createElement("div");