@snowcone-app/ui 0.4.7 → 0.4.8

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.4.7",
3
+ "version": "0.4.8",
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.20.0"
106
+ "@snowcone-app/sdk": "0.20.1"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@chromatic-com/storybook": "^4.1.2",
@@ -42,6 +42,7 @@ import type { RealtimeRenderError } from "@snowcone-app/sdk";
42
42
  import { readEnv } from "../lib/env";
43
43
  import { useProductOptional } from "./Product";
44
44
  import type { ReactProductContext } from "./Product";
45
+ import { useMockupBackgroundOptional } from "./MockupBackground";
45
46
 
46
47
  // Default artboard size for export calculations (matches @snowcone-app/canvas default)
47
48
  const DEFAULT_ARTBOARD_SIZE = 2000;
@@ -273,6 +274,9 @@ export function RealtimeProvider({
273
274
  grantUrl,
274
275
  }: RealtimeProviderProps) {
275
276
  const productContext = useProductOptional();
277
+ // Page background for renders (see MockupBackground) — sent on the config so
278
+ // realtime results match static `bg=` mockup URLs.
279
+ const mockupBg = useMockupBackgroundOptional();
276
280
 
277
281
  const [isEnabled, setIsEnabled] = useState(autoEnable);
278
282
 
@@ -305,6 +309,7 @@ export function RealtimeProvider({
305
309
 
306
310
  // Track last sent variantId to detect when we need to re-send config
307
311
  const lastSentVariantIdRef = useRef<string | null>(null);
312
+ const lastSentBgRef = useRef<string | undefined>(undefined);
308
313
 
309
314
  // Track last sent colors to prevent duplicates
310
315
  const lastSentColorsRef = useRef<Record<string, string>>({});
@@ -577,6 +582,7 @@ export function RealtimeProvider({
577
582
  disconnect();
578
583
  configSentRef.current = false;
579
584
  lastSentVariantIdRef.current = null;
585
+ lastSentBgRef.current = undefined;
580
586
  lastSentColorsRef.current = {};
581
587
  };
582
588
  }
@@ -611,8 +617,10 @@ export function RealtimeProvider({
611
617
  const isFirstSend = !configSentRef.current;
612
618
  const variantChanged = lastSentVariantIdRef.current !== null &&
613
619
  lastSentVariantIdRef.current !== variantId;
620
+ // 3. Background changed (theme flip swaps the MockupBackground hex)
621
+ const bgChanged = configSentRef.current && lastSentBgRef.current !== mockupBg;
614
622
 
615
- if (!isFirstSend && !variantChanged) {
623
+ if (!isFirstSend && !variantChanged && !bgChanged) {
616
624
  return; // Nothing changed, skip
617
625
  }
618
626
 
@@ -637,6 +645,7 @@ export function RealtimeProvider({
637
645
  variantId,
638
646
  shop: shop as string,
639
647
  width: mockupWidth,
648
+ ...(mockupBg ? { bg: mockupBg } : {}),
640
649
  placementSettings: { ...placementSettingsOverridesRef.current },
641
650
  }
642
651
  : {
@@ -646,6 +655,7 @@ export function RealtimeProvider({
646
655
  shop: "hTidnpNnNa",
647
656
  seal: "bypass-sig-for-k6-load-test",
648
657
  width: mockupWidth,
658
+ ...(mockupBg ? { bg: mockupBg } : {}),
649
659
  placementSettings: { ...placementSettingsOverridesRef.current },
650
660
  };
651
661
 
@@ -662,6 +672,7 @@ export function RealtimeProvider({
662
672
 
663
673
  configSentRef.current = true;
664
674
  lastSentVariantIdRef.current = variantId;
675
+ lastSentBgRef.current = mockupBg;
665
676
 
666
677
  // Send default colors for color placements
667
678
  setTimeout(() => {
@@ -682,6 +693,7 @@ export function RealtimeProvider({
682
693
  sendConfigRaw,
683
694
  sendColorBlobTracked,
684
695
  mockupWidth,
696
+ mockupBg,
685
697
  ]);
686
698
 
687
699
  // Watch for color placement changes