@snowcone-app/ui 0.4.8 → 0.4.9
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 +9 -0
- package/dist/index.cjs +25 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/patterns/RealtimeProvider.tsx +73 -1
package/dist/index.d.cts
CHANGED
|
@@ -2929,6 +2929,24 @@ interface RealtimeContextValue {
|
|
|
2929
2929
|
tiles?: number;
|
|
2930
2930
|
alignment?: string;
|
|
2931
2931
|
}>) => boolean;
|
|
2932
|
+
/**
|
|
2933
|
+
* Declare spread-mode crop geometry (ADR-0060) for canvases that run
|
|
2934
|
+
* combined spread/group artboards: artboard name → artboard dims + piece
|
|
2935
|
+
* rects keyed by the product's placement labels. Sent on the realtime
|
|
2936
|
+
* config (re-sent when it changes) so the server can slice each rendered
|
|
2937
|
+
* spread canvas_state into per-placement images. Pass undefined to clear.
|
|
2938
|
+
*/
|
|
2939
|
+
setSpreadCrops: (crops: Record<string, {
|
|
2940
|
+
width: number;
|
|
2941
|
+
height: number;
|
|
2942
|
+
pieces: Array<{
|
|
2943
|
+
placement: string;
|
|
2944
|
+
x: number;
|
|
2945
|
+
y: number;
|
|
2946
|
+
width: number;
|
|
2947
|
+
height: number;
|
|
2948
|
+
}>;
|
|
2949
|
+
}> | undefined) => void;
|
|
2932
2950
|
getMockupResultsImmediate: () => MockupResult[];
|
|
2933
2951
|
subscribeMockupResults: (callback: (results: MockupResult[]) => void) => () => void;
|
|
2934
2952
|
subscribeMockupResultById: (mockupId: string, callback: (result: MockupResult) => void) => () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -2929,6 +2929,24 @@ interface RealtimeContextValue {
|
|
|
2929
2929
|
tiles?: number;
|
|
2930
2930
|
alignment?: string;
|
|
2931
2931
|
}>) => boolean;
|
|
2932
|
+
/**
|
|
2933
|
+
* Declare spread-mode crop geometry (ADR-0060) for canvases that run
|
|
2934
|
+
* combined spread/group artboards: artboard name → artboard dims + piece
|
|
2935
|
+
* rects keyed by the product's placement labels. Sent on the realtime
|
|
2936
|
+
* config (re-sent when it changes) so the server can slice each rendered
|
|
2937
|
+
* spread canvas_state into per-placement images. Pass undefined to clear.
|
|
2938
|
+
*/
|
|
2939
|
+
setSpreadCrops: (crops: Record<string, {
|
|
2940
|
+
width: number;
|
|
2941
|
+
height: number;
|
|
2942
|
+
pieces: Array<{
|
|
2943
|
+
placement: string;
|
|
2944
|
+
x: number;
|
|
2945
|
+
y: number;
|
|
2946
|
+
width: number;
|
|
2947
|
+
height: number;
|
|
2948
|
+
}>;
|
|
2949
|
+
}> | undefined) => void;
|
|
2932
2950
|
getMockupResultsImmediate: () => MockupResult[];
|
|
2933
2951
|
subscribeMockupResults: (callback: (results: MockupResult[]) => void) => () => void;
|
|
2934
2952
|
subscribeMockupResultById: (mockupId: string, callback: (result: MockupResult) => void) => () => void;
|
package/dist/index.js
CHANGED
|
@@ -5611,6 +5611,9 @@ function RealtimeProvider({
|
|
|
5611
5611
|
const placementSettingsOverridesRef = useRef12({});
|
|
5612
5612
|
const lastSentVariantIdRef = useRef12(null);
|
|
5613
5613
|
const lastSentBgRef = useRef12(void 0);
|
|
5614
|
+
const spreadCropsRef = useRef12(void 0);
|
|
5615
|
+
const [spreadCropsVersion, setSpreadCropsVersion] = useState17(0);
|
|
5616
|
+
const lastSentSpreadCropsRef = useRef12("null");
|
|
5614
5617
|
const lastSentColorsRef = useRef12({});
|
|
5615
5618
|
const realtimeMockup = useRealtimeMockup2({
|
|
5616
5619
|
wsUrl,
|
|
@@ -5797,6 +5800,7 @@ function RealtimeProvider({
|
|
|
5797
5800
|
configSentRef.current = false;
|
|
5798
5801
|
lastSentVariantIdRef.current = null;
|
|
5799
5802
|
lastSentBgRef.current = void 0;
|
|
5803
|
+
lastSentSpreadCropsRef.current = "null";
|
|
5800
5804
|
lastSentColorsRef.current = {};
|
|
5801
5805
|
};
|
|
5802
5806
|
}
|
|
@@ -5819,7 +5823,9 @@ function RealtimeProvider({
|
|
|
5819
5823
|
const isFirstSend = !configSentRef.current;
|
|
5820
5824
|
const variantChanged = lastSentVariantIdRef.current !== null && lastSentVariantIdRef.current !== variantId;
|
|
5821
5825
|
const bgChanged = configSentRef.current && lastSentBgRef.current !== mockupBg;
|
|
5822
|
-
|
|
5826
|
+
const spreadCropsJson = JSON.stringify(spreadCropsRef.current ?? null);
|
|
5827
|
+
const spreadCropsChanged = configSentRef.current && lastSentSpreadCropsRef.current !== spreadCropsJson;
|
|
5828
|
+
if (!isFirstSend && !variantChanged && !bgChanged && !spreadCropsChanged) {
|
|
5823
5829
|
return;
|
|
5824
5830
|
}
|
|
5825
5831
|
const mockupIds = [];
|
|
@@ -5837,6 +5843,7 @@ function RealtimeProvider({
|
|
|
5837
5843
|
shop,
|
|
5838
5844
|
width: mockupWidth,
|
|
5839
5845
|
...mockupBg ? { bg: mockupBg } : {},
|
|
5846
|
+
...spreadCropsRef.current ? { spreadCrops: spreadCropsRef.current } : {},
|
|
5840
5847
|
placementSettings: { ...placementSettingsOverridesRef.current }
|
|
5841
5848
|
} : {
|
|
5842
5849
|
productId,
|
|
@@ -5846,6 +5853,7 @@ function RealtimeProvider({
|
|
|
5846
5853
|
seal: "bypass-sig-for-k6-load-test",
|
|
5847
5854
|
width: mockupWidth,
|
|
5848
5855
|
...mockupBg ? { bg: mockupBg } : {},
|
|
5856
|
+
...spreadCropsRef.current ? { spreadCrops: spreadCropsRef.current } : {},
|
|
5849
5857
|
placementSettings: { ...placementSettingsOverridesRef.current }
|
|
5850
5858
|
};
|
|
5851
5859
|
if (variantChanged) {
|
|
@@ -5858,6 +5866,7 @@ function RealtimeProvider({
|
|
|
5858
5866
|
configSentRef.current = true;
|
|
5859
5867
|
lastSentVariantIdRef.current = variantId;
|
|
5860
5868
|
lastSentBgRef.current = mockupBg;
|
|
5869
|
+
lastSentSpreadCropsRef.current = spreadCropsJson;
|
|
5861
5870
|
setTimeout(() => {
|
|
5862
5871
|
const colorPlacements = placements.filter((p) => p.type === "color");
|
|
5863
5872
|
colorPlacements.forEach((p) => {
|
|
@@ -5876,7 +5885,8 @@ function RealtimeProvider({
|
|
|
5876
5885
|
sendConfigRaw,
|
|
5877
5886
|
sendColorBlobTracked,
|
|
5878
5887
|
mockupWidth,
|
|
5879
|
-
mockupBg
|
|
5888
|
+
mockupBg,
|
|
5889
|
+
spreadCropsVersion
|
|
5880
5890
|
]);
|
|
5881
5891
|
useEffect17(() => {
|
|
5882
5892
|
if (!isEnabled || !isConnected || !isConfigured || !productContext?.product)
|
|
@@ -5910,6 +5920,17 @@ function RealtimeProvider({
|
|
|
5910
5920
|
},
|
|
5911
5921
|
[updatePlacementSettingsRaw]
|
|
5912
5922
|
);
|
|
5923
|
+
const setSpreadCrops = useCallback10(
|
|
5924
|
+
(crops) => {
|
|
5925
|
+
const next = crops && Object.keys(crops).length > 0 ? crops : void 0;
|
|
5926
|
+
if (JSON.stringify(next ?? null) === JSON.stringify(spreadCropsRef.current ?? null)) {
|
|
5927
|
+
return;
|
|
5928
|
+
}
|
|
5929
|
+
spreadCropsRef.current = next;
|
|
5930
|
+
setSpreadCropsVersion((v) => v + 1);
|
|
5931
|
+
},
|
|
5932
|
+
[]
|
|
5933
|
+
);
|
|
5913
5934
|
const enableRealtime = useCallback10(() => {
|
|
5914
5935
|
setIsEnabled(true);
|
|
5915
5936
|
}, []);
|
|
@@ -6195,6 +6216,7 @@ function RealtimeProvider({
|
|
|
6195
6216
|
sendCanvasState,
|
|
6196
6217
|
updateMockupIds: updateMockupIdsRaw,
|
|
6197
6218
|
updatePlacementSettings: updatePlacementSettingsWrapped,
|
|
6219
|
+
setSpreadCrops,
|
|
6198
6220
|
getMockupResultsImmediate: () => mockupResultsRef.current,
|
|
6199
6221
|
subscribeMockupResults: stableSubscribeMockupResults,
|
|
6200
6222
|
subscribeMockupResultById: stableSubscribeMockupResultById,
|
|
@@ -6231,6 +6253,7 @@ function RealtimeProvider({
|
|
|
6231
6253
|
sendCanvasState,
|
|
6232
6254
|
updateMockupIdsRaw,
|
|
6233
6255
|
updatePlacementSettingsWrapped,
|
|
6256
|
+
setSpreadCrops,
|
|
6234
6257
|
stableSubscribeMockupResults,
|
|
6235
6258
|
stableSubscribeMockupResultById,
|
|
6236
6259
|
notifyPendingExport,
|