@snowcone-app/ui 0.11.4 → 0.11.6
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/CHANGELOG.md +16 -0
- package/dist/index.cjs +17 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/composed/__tests__/HeroProductImage.ssr-match.test.tsx +34 -15
- package/src/patterns/RealtimeProvider.tsx +21 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snowcone-app/ui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
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.31.
|
|
106
|
+
"@snowcone-app/sdk": "0.31.12"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@chromatic-com/storybook": "^4.1.2",
|
|
@@ -30,21 +30,23 @@ const SHOP = "2e2c853b83";
|
|
|
30
30
|
const PRODUCTS = { AKTGA7, BC43BE, NBYVCX, KVJVVA } as unknown as Record<string, CatalogProduct & { mockups: Array<{ id: string }>; placements: Array<{ label: string }> }>;
|
|
31
31
|
|
|
32
32
|
/** The phone carousel's first slide, as page-client + MobileProductCarousel mount it. */
|
|
33
|
-
function FirstSlide({ product, bg, presigned }: { product: (typeof PRODUCTS)[string]; bg
|
|
33
|
+
function FirstSlide({ product, bg, presigned, art = "default" }: { product: (typeof PRODUCTS)[string]; bg?: string; presigned?: Array<{ url: string; signed: string }>; art?: string }) {
|
|
34
34
|
const first = ordinaryMockups(product.mockups)[0];
|
|
35
|
+
const hero = (
|
|
36
|
+
<HeroProductImage
|
|
37
|
+
productId={product.id}
|
|
38
|
+
artwork={{ type: "regular", src: art } as never}
|
|
39
|
+
placement={product.placements[0].label}
|
|
40
|
+
mockupId={first.id}
|
|
41
|
+
width={MOBILE_HERO_WIDTH}
|
|
42
|
+
viewportPolicy
|
|
43
|
+
presigned={presigned}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
// No bg = the storefront's PDP since 2026-11-24: no MockupBackground, the renderer paints the SHOP's colour.
|
|
35
47
|
return (
|
|
36
|
-
<Product productId={product.id} productData={product} initialPlacements={{ Front: { imageUrl:
|
|
37
|
-
<MockupBackground bg={bg}>
|
|
38
|
-
<HeroProductImage
|
|
39
|
-
productId={product.id}
|
|
40
|
-
artwork={{ type: "regular", src: "default" } as never}
|
|
41
|
-
placement={product.placements[0].label}
|
|
42
|
-
mockupId={first.id}
|
|
43
|
-
width={MOBILE_HERO_WIDTH}
|
|
44
|
-
viewportPolicy
|
|
45
|
-
presigned={presigned}
|
|
46
|
-
/>
|
|
47
|
-
</MockupBackground>
|
|
48
|
+
<Product productId={product.id} productData={product} initialPlacements={{ Front: { imageUrl: art, alignment: "center" as never } }} dataMode="auto">
|
|
49
|
+
{bg ? <MockupBackground bg={bg}>{hero}</MockupBackground> : hero}
|
|
48
50
|
</Product>
|
|
49
51
|
);
|
|
50
52
|
}
|
|
@@ -66,14 +68,15 @@ describe("the server's first phone hero URL is the URL the client requests (no d
|
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
for (const [id, product] of Object.entries(PRODUCTS)) {
|
|
69
|
-
for (const bg of ["f5f5f5", "0a0a0a"]) {
|
|
70
|
-
it(`${id} bg ${bg}: client URL === firstMobileHeroUrl`, async () => {
|
|
71
|
+
for (const bg of [undefined, "f5f5f5", "0a0a0a"]) {
|
|
72
|
+
it(`${id} ${bg ? `bg ${bg}` : "no bg (the shop's colour)"}: client URL === firstMobileHeroUrl`, async () => {
|
|
71
73
|
const server = firstMobileHeroUrl({ product, artworkSrc: "default", shop: SHOP, bg });
|
|
72
74
|
expect(server, "the server builds a URL for every live set product").toBeTruthy();
|
|
73
75
|
const { container } = render(<FirstSlide product={product} bg={bg} />);
|
|
74
76
|
const src = await requested(container);
|
|
75
77
|
expect(src).toBe(`${server}&signature=client`);
|
|
76
78
|
expect(new URL(server!).searchParams.get("width")).toBe(String(MOBILE_HERO_WIDTH));
|
|
79
|
+
expect(new URL(server!).searchParams.get("bg")).toBe(bg ?? null);
|
|
77
80
|
});
|
|
78
81
|
}
|
|
79
82
|
}
|
|
@@ -99,4 +102,20 @@ describe("the server's first phone hero URL is the URL the client requests (no d
|
|
|
99
102
|
expect(firstMobileHeroUrl({ product: PRODUCTS.AKTGA7, artworkSrc: "default", shop: undefined })).toBeNull();
|
|
100
103
|
expect(firstMobileHeroUrl({ product: PRODUCTS.AKTGA7, artworkSrc: "", shop: SHOP })).toBeNull();
|
|
101
104
|
});
|
|
105
|
+
|
|
106
|
+
// A PUBLISHED pairing's page (/product/<slug>) mounts the hero with the pairing RECORD's art (page-client
|
|
107
|
+
// initialPlacements.Front.imageUrl = artwork.src = pairing.mockupThumbnailUrl || design.previewUrl); the server signs
|
|
108
|
+
// that same URL (www lib/first-hero-preload.ts publishedPairingHeroPreloads, lead 2026-11-19).
|
|
109
|
+
const RECORD_ART = "https://2e2c853b83.storage.snowcone.app/persisted/3fa2ae64c674c5fa.png";
|
|
110
|
+
for (const [id, product] of Object.entries(PRODUCTS)) {
|
|
111
|
+
for (const bg of ["f5f5f5", "0a0a0a"]) {
|
|
112
|
+
it(`${id} bg ${bg}, a pairing's record art: client URL === firstMobileHeroUrl`, async () => {
|
|
113
|
+
const server = firstMobileHeroUrl({ product, artworkSrc: RECORD_ART, shop: SHOP, bg });
|
|
114
|
+
expect(server).toBeTruthy();
|
|
115
|
+
expect(server).not.toBe(firstMobileHeroUrl({ product, artworkSrc: "default", shop: SHOP, bg })); // it is the art's URL
|
|
116
|
+
const { container } = render(<FirstSlide product={product} bg={bg} art={RECORD_ART} />);
|
|
117
|
+
expect(await requested(container)).toBe(`${server}&signature=client`);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
102
121
|
});
|
|
@@ -490,12 +490,17 @@ export function RealtimeProvider({
|
|
|
490
490
|
() => new Map(),
|
|
491
491
|
);
|
|
492
492
|
|
|
493
|
+
const resetSessionRef = useRef<() => void>(() => {});
|
|
493
494
|
const realtimeMockup = useRealtimeMockup({
|
|
494
495
|
wsUrl,
|
|
495
496
|
getToken: useSessionGrant ? getToken : undefined,
|
|
496
497
|
onConnected: (sessionId) => {
|
|
497
498
|
},
|
|
498
499
|
onDisconnected: () => {
|
|
500
|
+
// The socket dropped (the sdk reconnects on its own): the next session is new, so forget what this one was
|
|
501
|
+
// sent, exactly as the connect effect's cleanup does. When isConnected flips back the config effect sends a
|
|
502
|
+
// fresh full-frame config and the backgrounds re-seed before cropped delivery resumes.
|
|
503
|
+
resetSessionRef.current();
|
|
499
504
|
},
|
|
500
505
|
onConfigReceived: () => {
|
|
501
506
|
},
|
|
@@ -1505,6 +1510,20 @@ export function RealtimeProvider({
|
|
|
1505
1510
|
[sendColorBlob]
|
|
1506
1511
|
);
|
|
1507
1512
|
|
|
1513
|
+
const resetSession = useCallback(() => {
|
|
1514
|
+
configSentRef.current = false;
|
|
1515
|
+
dueByVersionRef.current.clear(); // versions restart at 1 on the next socket
|
|
1516
|
+
setUnavailableMockups((prev) => (prev.size ? new Map() : prev)); // a fixed mockup stops being refused
|
|
1517
|
+
lastSentVariantIdRef.current = null;
|
|
1518
|
+
lastSentBgRef.current = undefined;
|
|
1519
|
+
lastSentSpreadCropsRef.current = "null";
|
|
1520
|
+
lastSentColorsRef.current = {};
|
|
1521
|
+
// A new session must re-seed backgrounds before cropped delivery.
|
|
1522
|
+
invalidateBackgrounds();
|
|
1523
|
+
lastConfigBaseRef.current = null;
|
|
1524
|
+
}, [invalidateBackgrounds]);
|
|
1525
|
+
resetSessionRef.current = resetSession;
|
|
1526
|
+
|
|
1508
1527
|
// Connect when enabled
|
|
1509
1528
|
useEffect(() => {
|
|
1510
1529
|
if (isEnabled) {
|
|
@@ -1512,19 +1531,10 @@ export function RealtimeProvider({
|
|
|
1512
1531
|
|
|
1513
1532
|
return () => {
|
|
1514
1533
|
disconnect();
|
|
1515
|
-
|
|
1516
|
-
dueByVersionRef.current.clear(); // versions restart at 1 on the next socket
|
|
1517
|
-
setUnavailableMockups((prev) => (prev.size ? new Map() : prev)); // a fixed mockup stops being refused
|
|
1518
|
-
lastSentVariantIdRef.current = null;
|
|
1519
|
-
lastSentBgRef.current = undefined;
|
|
1520
|
-
lastSentSpreadCropsRef.current = "null";
|
|
1521
|
-
lastSentColorsRef.current = {};
|
|
1522
|
-
// A new session must re-seed backgrounds before cropped delivery.
|
|
1523
|
-
invalidateBackgrounds();
|
|
1524
|
-
lastConfigBaseRef.current = null;
|
|
1534
|
+
resetSession();
|
|
1525
1535
|
};
|
|
1526
1536
|
}
|
|
1527
|
-
}, [isEnabled, connect, disconnect, wsUrl,
|
|
1537
|
+
}, [isEnabled, connect, disconnect, wsUrl, resetSession]);
|
|
1528
1538
|
|
|
1529
1539
|
// Clear pending state when mockup results arrive
|
|
1530
1540
|
useEffect(() => {
|