@snowcone-app/ui 0.11.5 → 0.11.7
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/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.7",
|
|
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.13"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@chromatic-com/storybook": "^4.1.2",
|
|
@@ -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(() => {
|