@snowcone-app/ui 0.10.8 → 0.10.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowcone-app/ui",
3
- "version": "0.10.8",
3
+ "version": "0.10.10",
4
4
  "description": "React components for merchandise visualization and customization",
5
5
  "keywords": [
6
6
  "react",
@@ -103,7 +103,7 @@
103
103
  "react-instantsearch": "^7.15.5",
104
104
  "react-zoom-pan-pinch": "^3.6.4",
105
105
  "tailwind-merge": "^3.0.0",
106
- "@snowcone-app/sdk": "0.29.0"
106
+ "@snowcone-app/sdk": "0.29.1"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@chromatic-com/storybook": "^4.1.2",
@@ -1103,6 +1103,13 @@ export const HeroProductImage = memo(function HeroProductImage({
1103
1103
  // instead of the browser's native broken-image glyph. Reset on every new
1104
1104
  // URL attempt (below) so a fresh render can recover.
1105
1105
  const [imgFailed, setImgFailed] = useState(false);
1106
+ // What failed to display, stamped on the root as data-picture-failed(-src): a picture this browser can't show must
1107
+ // never be silent (Firefox 2026-11-12 showed none of our AVIF store pictures; the failed <img> was removed and
1108
+ // nothing said so). Host + path only: never the signature / query.
1109
+ const failedSrc = (() => {
1110
+ if (!imgFailed || !renderedUrl) return undefined;
1111
+ try { const u = new URL(renderedUrl, typeof location !== "undefined" ? location.href : "https://x"); return u.protocol === "blob:" ? "blob" : u.host + u.pathname; } catch { return "?"; }
1112
+ })();
1106
1113
  // One-shot cache-recovery retry. A reload / Safari bfcache restore can serve
1107
1114
  // a mockup from WebKit's disk cache as a CORS-less entry (cached by an
1108
1115
  // earlier non-crossorigin request), which then fails the crossorigin <img>
@@ -1222,6 +1229,8 @@ export const HeroProductImage = memo(function HeroProductImage({
1222
1229
  style={style}
1223
1230
  data-hero-image="true"
1224
1231
  data-fit={fit}
1232
+ data-picture-failed={imgFailed ? "E_PICTURE_UNDISPLAYED" : undefined}
1233
+ data-picture-failed-src={failedSrc}
1225
1234
  data-mockup-unavailable={unavailable ? unavailable.code : undefined}
1226
1235
  >
1227
1236
  {unavailable && (
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A picture this browser can't show is never silent (Firefox, 2026-11-12: none of our AVIF store pictures displayed;
3
+ * the failed <img> was removed and nothing said so). After the one retry, the root carries data-picture-failed and the
4
+ * failed URL's host + path (never the query / signature).
5
+ */
6
+ import { describe, expect, it, vi } from "vitest";
7
+ import React from "react";
8
+ import { render, waitFor, fireEvent, act, cleanup } from "@testing-library/react";
9
+ import { HeroProductImage } from "../HeroProductImage";
10
+
11
+ const ART = { src: "https://example.test/art.png" } as never;
12
+
13
+ describe("HeroProductImage: a picture that fails to display is stamped", () => {
14
+ it("after its retry fails, the root carries data-picture-failed + the src host/path, no query", async () => {
15
+ cleanup();
16
+ vi.stubGlobal("fetch", vi.fn(() => Promise.resolve(new Response(""))));
17
+ const { container } = render(<HeroProductImage productId="XTNA6J" mockupId="ORD001" realtimeUrl="https://img.example.test/ORD001?width=1200&signature=secret" artwork={ART} />);
18
+ const root = () => container.querySelector("[data-hero-image]") as HTMLElement;
19
+ await waitFor(() => expect(container.querySelector("img")).not.toBeNull());
20
+ expect(root().dataset.pictureFailed).toBeUndefined();
21
+ await act(async () => { fireEvent.error(container.querySelector("img")!); }); // first failure: one retry
22
+ await waitFor(() => expect(container.querySelector("img")).not.toBeNull());
23
+ await act(async () => { fireEvent.error(container.querySelector("img")!); }); // the retry fails too
24
+ await waitFor(() => expect(root().dataset.pictureFailed).toBe("E_PICTURE_UNDISPLAYED"));
25
+ expect(root().dataset.pictureFailedSrc).toBe("img.example.test/ORD001");
26
+ expect(root().dataset.pictureFailedSrc).not.toContain("signature");
27
+ vi.unstubAllGlobals();
28
+ });
29
+
30
+ it("a picture that loads carries no failure stamp", async () => {
31
+ cleanup();
32
+ const { container } = render(<HeroProductImage productId="XTNA6J" mockupId="ORD002" realtimeUrl="https://img.example.test/ORD002" artwork={ART} />);
33
+ await waitFor(() => expect(container.querySelector("img")).not.toBeNull());
34
+ await act(async () => { fireEvent.load(container.querySelector("img")!); });
35
+ expect((container.querySelector("[data-hero-image]") as HTMLElement).dataset.pictureFailed).toBeUndefined();
36
+ });
37
+ });
@@ -761,6 +761,7 @@ export function RealtimeProvider({
761
761
  console.error(
762
762
  `[RealtimeProvider] E_BLOB_PICTURE_BOUND: ${owner} has more than ${MAX_FRAMES_PER_PICTURE} frames waiting to be shown; dropping its oldest unshown frame (the picture on screen is kept).`
763
763
  );
764
+ ackUrl(victim); // never drawn: done with it (frame flow control), else the box waits on it until its ack timeout
764
765
  revokeBlobUrl(victim);
765
766
  }
766
767
  blobsByOwnerRef.current.set(owner, list);
@@ -772,7 +773,7 @@ export function RealtimeProvider({
772
773
  }
773
774
  registeredBlobUrlsRef.current.add(url);
774
775
  return url;
775
- }, [revokeBlobUrl]);
776
+ }, [revokeBlobUrl, ackUrl]);
776
777
 
777
778
  /** Release a picture's frames that are older than what EVERY one of its elements shows. */
778
779
  const releaseOlderFrames = useCallback((owner: string) => {