bookcover-3d-web 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/svg.js +10 -1
  2. package/package.json +1 -1
package/dist/svg.js CHANGED
@@ -31,7 +31,16 @@ export async function svg_to_bitmap(svg, w_pt, h_pt) {
31
31
  img.onerror = () => reject(new Error('[cover-3d] SVG failed to load as image'));
32
32
  img.src = url;
33
33
  });
34
- return createImageBitmap(img);
34
+ // onload alone doesn't guarantee nested embedded rasters (e.g. a user's
35
+ // background photo embedded in the panel SVG) have finished decoding —
36
+ // notably on Safari, this can race and snapshot a blank background.
37
+ // decode() is spec-guaranteed to wait until the image is fully paintable.
38
+ await img.decode();
39
+ // Must be awaited here (not returned directly) — the blob URL is revoked in
40
+ // `finally` right after this call returns, and on Safari that can race ahead of
41
+ // createImageBitmap still reading from the img element, capturing a blank bitmap.
42
+ const bitmap = await createImageBitmap(img);
43
+ return bitmap;
35
44
  }
36
45
  finally {
37
46
  URL.revokeObjectURL(url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bookcover-3d-web",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "license": "MIT-0",
5
5
  "repository": {
6
6
  "type": "git",