@snowcone-app/ui 0.9.8 → 0.10.0
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 +6 -0
- package/dist/index.cjs +191 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +191 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/composed/HeroProductImage.tsx +57 -1
- package/src/composed/carousels/MobileProductCarousel.tsx +3 -0
- package/src/patterns/RealtimeProvider.tsx +159 -10
- package/src/patterns/__tests__/RealtimeProvider.sessionShape.test.tsx +126 -0
- package/src/patterns/__tests__/sessionShape.test.ts +62 -0
- package/src/patterns/sessionShape.ts +82 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4396](https://github.com/snowcone-app/snowcone-monorepo/pull/4396) [`3c6ad17`](https://github.com/snowcone-app/snowcone-monorepo/commit/3c6ad17727f576ea82945605c50b9786abf7e65c) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Phone viewport policy for live pictures: a gallery that opts in (`HeroProductImage viewportPolicy`, set by `MobileProductCarousel`) reports what is in view, and the realtime session then renders, while an edit is live, only the pictures in view (+ neighbours) at the width the screen shows them (CSS width × dpr rounded up to a ladder step); when the edit stops, every picture at that width (one catch-up config, cancelled by a new edit); on Done (`setEditorOpen(false)` / `editorOpen`), the picture on screen at `mockupWidth`. One config per change of shape. Pictures carry `data-render-width`, `data-wanted-width` and `data-session-phase`. Without an opted-in gallery (desktop) nothing changes.
|
|
8
|
+
|
|
3
9
|
## 0.9.8
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -5997,6 +5997,41 @@ function useMockupBackgroundOptional() {
|
|
|
5997
5997
|
return (0, import_react24.useContext)(MockupBackgroundContext);
|
|
5998
5998
|
}
|
|
5999
5999
|
|
|
6000
|
+
// src/patterns/sessionShape.ts
|
|
6001
|
+
var WIDTH_LADDER = [400, 600, 800, 1e3, 1200, 1600, 2e3, 3e3, 4e3];
|
|
6002
|
+
function ladderWidth(devicePx) {
|
|
6003
|
+
for (const w of WIDTH_LADDER) if (w >= devicePx) return w;
|
|
6004
|
+
return WIDTH_LADDER[WIDTH_LADDER.length - 1];
|
|
6005
|
+
}
|
|
6006
|
+
function sessionShape(input) {
|
|
6007
|
+
const { allMockupIds, views, heroWidth, editorOpen, editLive } = input;
|
|
6008
|
+
if (views.size === 0) return { mockupIds: [...allMockupIds], width: heroWidth, phase: "no-policy" };
|
|
6009
|
+
const byMockup = /* @__PURE__ */ new Map();
|
|
6010
|
+
views.forEach((v, key) => {
|
|
6011
|
+
const id = v.mockupId ?? key;
|
|
6012
|
+
const prev = byMockup.get(id);
|
|
6013
|
+
byMockup.set(id, prev ? { inSet: prev.inSet || v.inSet, onScreen: prev.onScreen || v.onScreen, devicePx: Math.max(prev.devicePx, v.devicePx) } : { inSet: v.inSet, onScreen: v.onScreen, devicePx: v.devicePx });
|
|
6014
|
+
});
|
|
6015
|
+
const ordered = (pick) => allMockupIds.filter((id) => {
|
|
6016
|
+
const v = byMockup.get(id);
|
|
6017
|
+
return v ? pick(v) : false;
|
|
6018
|
+
});
|
|
6019
|
+
const inSet = ordered((v) => v.inSet);
|
|
6020
|
+
const onScreen = ordered((v) => v.onScreen);
|
|
6021
|
+
const shown = [...byMockup.values()].filter((v) => v.inSet && v.devicePx > 0).map((v) => v.devicePx);
|
|
6022
|
+
const editingWidth = shown.length ? ladderWidth(Math.max(...shown)) : heroWidth;
|
|
6023
|
+
if (!editorOpen) {
|
|
6024
|
+
const set = onScreen.length ? onScreen : inSet;
|
|
6025
|
+
return { mockupIds: set.length ? set : [...allMockupIds], width: heroWidth, phase: "done" };
|
|
6026
|
+
}
|
|
6027
|
+
if (editLive && inSet.length) return { mockupIds: inSet, width: editingWidth, phase: "editing" };
|
|
6028
|
+
return { mockupIds: [...allMockupIds], width: editingWidth, phase: "catch-up" };
|
|
6029
|
+
}
|
|
6030
|
+
function sameShape(a, b) {
|
|
6031
|
+
if (!a) return false;
|
|
6032
|
+
return a.width === b.width && [...a.mockupIds].sort().join(",") === [...b.mockupIds].sort().join(",");
|
|
6033
|
+
}
|
|
6034
|
+
|
|
6000
6035
|
// src/patterns/croppedFrameComposite.ts
|
|
6001
6036
|
var COMPOSITE_QUALITY = 0.92;
|
|
6002
6037
|
function isFullRect(rect) {
|
|
@@ -6065,6 +6100,7 @@ var MAX_CONCURRENT_BLOBS = 5;
|
|
|
6065
6100
|
var MAX_FRAMES_PER_PICTURE = 3;
|
|
6066
6101
|
var FRAME_SUPERSEDE_GRACE_MS = 2e3;
|
|
6067
6102
|
var RERENDER_MIN_INTERVAL_MS = 550;
|
|
6103
|
+
var EDIT_QUIET_MS = 600;
|
|
6068
6104
|
function mergeMockupIds(current, extra) {
|
|
6069
6105
|
const out = [...current];
|
|
6070
6106
|
for (const id of extra) if (!out.includes(id)) out.push(id);
|
|
@@ -6083,7 +6119,8 @@ function RealtimeProvider({
|
|
|
6083
6119
|
shop,
|
|
6084
6120
|
grantUrl,
|
|
6085
6121
|
initialGrant,
|
|
6086
|
-
delivery = "cropped"
|
|
6122
|
+
delivery = "cropped",
|
|
6123
|
+
editorOpen = true
|
|
6087
6124
|
}) {
|
|
6088
6125
|
const productContext = useProductOptional();
|
|
6089
6126
|
const mockupBg = useMockupBackgroundOptional();
|
|
@@ -6224,6 +6261,18 @@ function RealtimeProvider({
|
|
|
6224
6261
|
const compositeBusyRef = (0, import_react25.useRef)(/* @__PURE__ */ new Set());
|
|
6225
6262
|
const compositeCanvasRef = (0, import_react25.useRef)(null);
|
|
6226
6263
|
const requestedMockupIdsRef = (0, import_react25.useRef)([]);
|
|
6264
|
+
const pictureViewsRef = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
|
|
6265
|
+
const editLiveRef = (0, import_react25.useRef)(false);
|
|
6266
|
+
const editQuietTimerRef = (0, import_react25.useRef)(null);
|
|
6267
|
+
const shapeApplyTimerRef = (0, import_react25.useRef)(null);
|
|
6268
|
+
const lastShapeRef = (0, import_react25.useRef)(null);
|
|
6269
|
+
const applySessionShapeRef = (0, import_react25.useRef)(null);
|
|
6270
|
+
const [editorOpenState, setEditorOpenState] = (0, import_react25.useState)(editorOpen);
|
|
6271
|
+
(0, import_react25.useEffect)(() => setEditorOpenState(editorOpen), [editorOpen]);
|
|
6272
|
+
const editorOpenRef = (0, import_react25.useRef)(editorOpenState);
|
|
6273
|
+
editorOpenRef.current = editorOpenState;
|
|
6274
|
+
const heroWidthRef = (0, import_react25.useRef)(mockupWidth);
|
|
6275
|
+
heroWidthRef.current = mockupWidth;
|
|
6227
6276
|
const serverStampsVersionsRef = (0, import_react25.useRef)(false);
|
|
6228
6277
|
const pendingRerenderRef = (0, import_react25.useRef)([]);
|
|
6229
6278
|
const forceRerenderByConfigRef = (0, import_react25.useRef)(null);
|
|
@@ -6414,6 +6463,64 @@ function RealtimeProvider({
|
|
|
6414
6463
|
compositeQueueRef.current.clear();
|
|
6415
6464
|
croppedActiveRef.current = false;
|
|
6416
6465
|
}, []);
|
|
6466
|
+
const currentShape = (0, import_react25.useCallback)(
|
|
6467
|
+
() => sessionShape({
|
|
6468
|
+
allMockupIds: configuredMockupIdsRef.current,
|
|
6469
|
+
views: pictureViewsRef.current,
|
|
6470
|
+
heroWidth: heroWidthRef.current,
|
|
6471
|
+
editorOpen: editorOpenRef.current,
|
|
6472
|
+
editLive: editLiveRef.current
|
|
6473
|
+
}),
|
|
6474
|
+
[]
|
|
6475
|
+
);
|
|
6476
|
+
const applySessionShape = (0, import_react25.useCallback)(() => {
|
|
6477
|
+
const base = lastConfigBaseRef.current;
|
|
6478
|
+
if (!base || !configSentRef.current) return;
|
|
6479
|
+
const shape = currentShape();
|
|
6480
|
+
if (sameShape(lastShapeRef.current, shape)) {
|
|
6481
|
+
lastShapeRef.current = shape;
|
|
6482
|
+
return;
|
|
6483
|
+
}
|
|
6484
|
+
if (lastShapeRef.current && lastShapeRef.current.width !== shape.width) invalidateBackgrounds();
|
|
6485
|
+
lastShapeRef.current = shape;
|
|
6486
|
+
base.mockupIds = shape.mockupIds;
|
|
6487
|
+
base.width = shape.width;
|
|
6488
|
+
requestedMockupIdsRef.current = [...shape.mockupIds];
|
|
6489
|
+
sendConfigRaw({
|
|
6490
|
+
...base,
|
|
6491
|
+
placementSettings: { ...placementSettingsOverridesRef.current },
|
|
6492
|
+
...croppedActiveRef.current ? { overlayCrop: "auto" } : {}
|
|
6493
|
+
});
|
|
6494
|
+
}, [currentShape, invalidateBackgrounds, sendConfigRaw]);
|
|
6495
|
+
applySessionShapeRef.current = applySessionShape;
|
|
6496
|
+
const markEditLive = (0, import_react25.useCallback)(() => {
|
|
6497
|
+
if (editQuietTimerRef.current) {
|
|
6498
|
+
clearTimeout(editQuietTimerRef.current);
|
|
6499
|
+
editQuietTimerRef.current = null;
|
|
6500
|
+
}
|
|
6501
|
+
if (editLiveRef.current) return;
|
|
6502
|
+
editLiveRef.current = true;
|
|
6503
|
+
applySessionShapeRef.current?.();
|
|
6504
|
+
}, []);
|
|
6505
|
+
const markEditSettled = (0, import_react25.useCallback)(() => {
|
|
6506
|
+
if (!editLiveRef.current) return;
|
|
6507
|
+
if (editQuietTimerRef.current) clearTimeout(editQuietTimerRef.current);
|
|
6508
|
+
editQuietTimerRef.current = setTimeout(() => {
|
|
6509
|
+
editQuietTimerRef.current = null;
|
|
6510
|
+
editLiveRef.current = false;
|
|
6511
|
+
applySessionShapeRef.current?.();
|
|
6512
|
+
}, EDIT_QUIET_MS);
|
|
6513
|
+
}, []);
|
|
6514
|
+
(0, import_react25.useEffect)(() => {
|
|
6515
|
+
applySessionShapeRef.current?.();
|
|
6516
|
+
}, [editorOpenState]);
|
|
6517
|
+
(0, import_react25.useEffect)(
|
|
6518
|
+
() => () => {
|
|
6519
|
+
if (editQuietTimerRef.current) clearTimeout(editQuietTimerRef.current);
|
|
6520
|
+
if (shapeApplyTimerRef.current) clearTimeout(shapeApplyTimerRef.current);
|
|
6521
|
+
},
|
|
6522
|
+
[]
|
|
6523
|
+
);
|
|
6417
6524
|
const deliverResults = (0, import_react25.useCallback)(
|
|
6418
6525
|
(results) => {
|
|
6419
6526
|
if (results.length === 0) return;
|
|
@@ -6479,13 +6586,15 @@ function RealtimeProvider({
|
|
|
6479
6586
|
if (!pipelineResetCooldownRef.current) {
|
|
6480
6587
|
hasBlobInFlightRef.current = false;
|
|
6481
6588
|
for (let i = 0; i < settledVersions; i++) pipelineSettledSubscribersRef.current.forEach((cb) => cb());
|
|
6589
|
+
markEditSettled();
|
|
6482
6590
|
}
|
|
6483
6591
|
} else if (due.size === 0 && hasBlobInFlightRef.current && !hasPendingBlobs() && !pipelineResetCooldownRef.current) {
|
|
6484
6592
|
hasBlobInFlightRef.current = false;
|
|
6485
6593
|
pipelineSettledSubscribersRef.current.forEach((cb) => cb());
|
|
6594
|
+
markEditSettled();
|
|
6486
6595
|
}
|
|
6487
6596
|
},
|
|
6488
|
-
[hasPendingBlobs]
|
|
6597
|
+
[hasPendingBlobs, markEditSettled]
|
|
6489
6598
|
);
|
|
6490
6599
|
const runComposite = (0, import_react25.useCallback)(
|
|
6491
6600
|
async (result) => {
|
|
@@ -6612,10 +6721,11 @@ function RealtimeProvider({
|
|
|
6612
6721
|
lastBlobSentTimeRef.current = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
6613
6722
|
isPendingMockupsRef.current = true;
|
|
6614
6723
|
pendingBlobSubscribersRef.current.forEach((cb) => cb(placement));
|
|
6724
|
+
markEditLive();
|
|
6615
6725
|
}
|
|
6616
6726
|
return result;
|
|
6617
6727
|
},
|
|
6618
|
-
[sendCanvasBlobRaw]
|
|
6728
|
+
[sendCanvasBlobRaw, markEditLive]
|
|
6619
6729
|
);
|
|
6620
6730
|
const sendCanvasState = (0, import_react25.useCallback)(
|
|
6621
6731
|
(placement, state, mockupCount, baseThrottleMs) => {
|
|
@@ -6632,15 +6742,16 @@ function RealtimeProvider({
|
|
|
6632
6742
|
isPendingMockupsRef.current = true;
|
|
6633
6743
|
const version = getLastSentVersion();
|
|
6634
6744
|
if (version > 0) {
|
|
6635
|
-
const configured = configuredMockupIdsRef.current.length;
|
|
6745
|
+
const configured = requestedMockupIdsRef.current.length || configuredMockupIdsRef.current.length;
|
|
6636
6746
|
const expected = Math.max(1, Math.min(configured || Infinity, mockupCount || Infinity));
|
|
6637
6747
|
dueByVersionRef.current.set(version, { due: Number.isFinite(expected) ? expected : 1, at: Date.now() });
|
|
6638
6748
|
}
|
|
6639
6749
|
pendingBlobSubscribersRef.current.forEach((cb) => cb(placement));
|
|
6750
|
+
markEditLive();
|
|
6640
6751
|
}
|
|
6641
6752
|
return result;
|
|
6642
6753
|
},
|
|
6643
|
-
[sendCanvasStateRaw, getLastSentVersion]
|
|
6754
|
+
[sendCanvasStateRaw, getLastSentVersion, markEditLive]
|
|
6644
6755
|
);
|
|
6645
6756
|
const sendColorBlobTracked = (0, import_react25.useCallback)(
|
|
6646
6757
|
(placement, color) => {
|
|
@@ -6705,22 +6816,24 @@ function RealtimeProvider({
|
|
|
6705
6816
|
});
|
|
6706
6817
|
}
|
|
6707
6818
|
configuredMockupIdsRef.current = mockupIds;
|
|
6819
|
+
const shape = currentShape();
|
|
6820
|
+
lastShapeRef.current = shape;
|
|
6708
6821
|
const configPayload = useSessionGrant ? {
|
|
6709
6822
|
productId,
|
|
6710
|
-
mockupIds,
|
|
6823
|
+
mockupIds: shape.mockupIds,
|
|
6711
6824
|
variantId,
|
|
6712
6825
|
shop,
|
|
6713
|
-
width:
|
|
6826
|
+
width: shape.width,
|
|
6714
6827
|
...mockupBg ? { bg: mockupBg } : {},
|
|
6715
6828
|
...spreadCropsRef.current ? { spreadCrops: spreadCropsRef.current } : {},
|
|
6716
6829
|
placementSettings: { ...placementSettingsOverridesRef.current }
|
|
6717
6830
|
} : {
|
|
6718
6831
|
productId,
|
|
6719
|
-
mockupIds,
|
|
6832
|
+
mockupIds: shape.mockupIds,
|
|
6720
6833
|
variantId,
|
|
6721
6834
|
shop: "hTidnpNnNa",
|
|
6722
6835
|
seal: "bypass-sig-for-k6-load-test",
|
|
6723
|
-
width:
|
|
6836
|
+
width: shape.width,
|
|
6724
6837
|
...mockupBg ? { bg: mockupBg } : {},
|
|
6725
6838
|
...spreadCropsRef.current ? { spreadCrops: spreadCropsRef.current } : {},
|
|
6726
6839
|
placementSettings: { ...placementSettingsOverridesRef.current }
|
|
@@ -6732,7 +6845,7 @@ function RealtimeProvider({
|
|
|
6732
6845
|
});
|
|
6733
6846
|
}
|
|
6734
6847
|
lastConfigBaseRef.current = configPayload;
|
|
6735
|
-
requestedMockupIdsRef.current = mockupIds;
|
|
6848
|
+
requestedMockupIdsRef.current = [...shape.mockupIds];
|
|
6736
6849
|
sendConfigRaw(
|
|
6737
6850
|
croppedActiveRef.current ? { ...configPayload, overlayCrop: "auto" } : configPayload
|
|
6738
6851
|
);
|
|
@@ -6758,6 +6871,7 @@ function RealtimeProvider({
|
|
|
6758
6871
|
sendConfigRaw,
|
|
6759
6872
|
sendColorBlobTracked,
|
|
6760
6873
|
invalidateBackgrounds,
|
|
6874
|
+
currentShape,
|
|
6761
6875
|
mockupWidth,
|
|
6762
6876
|
mockupBg,
|
|
6763
6877
|
spreadCropsVersion
|
|
@@ -6947,8 +7061,9 @@ function RealtimeProvider({
|
|
|
6947
7061
|
}
|
|
6948
7062
|
console.log(`[RTP] notifyPendingExport("${placement}"): marked ${pendingIds.length} mockup(s) pending \u2014 [${pendingIds.slice(0, 5).join(", ")}${pendingIds.length > 5 ? "..." : ""}]`);
|
|
6949
7063
|
pendingBlobSubscribersRef.current.forEach((cb) => cb(placement));
|
|
7064
|
+
markEditLive();
|
|
6950
7065
|
},
|
|
6951
|
-
[productContext?.product?.mockups]
|
|
7066
|
+
[productContext?.product?.mockups, markEditLive]
|
|
6952
7067
|
);
|
|
6953
7068
|
const notifyPendingExportCancelled = (0, import_react25.useCallback)(
|
|
6954
7069
|
(placement) => {
|
|
@@ -7055,6 +7170,20 @@ function RealtimeProvider({
|
|
|
7055
7170
|
const getLatestSentVersionsRef = (0, import_react25.useRef)(getLatestSentVersions);
|
|
7056
7171
|
getLatestSentVersionsRef.current = getLatestSentVersions;
|
|
7057
7172
|
const getLatestSentVersionsStable = (0, import_react25.useCallback)(() => getLatestSentVersionsRef.current?.() ?? {}, []);
|
|
7173
|
+
const reportPictureView = (0, import_react25.useCallback)((elementKey, view) => {
|
|
7174
|
+
const views = pictureViewsRef.current;
|
|
7175
|
+
if (view) views.set(elementKey, view);
|
|
7176
|
+
else views.delete(elementKey);
|
|
7177
|
+
if (shapeApplyTimerRef.current) return;
|
|
7178
|
+
shapeApplyTimerRef.current = setTimeout(() => {
|
|
7179
|
+
shapeApplyTimerRef.current = null;
|
|
7180
|
+
applySessionShapeRef.current?.();
|
|
7181
|
+
}, 100);
|
|
7182
|
+
}, []);
|
|
7183
|
+
const getSessionShape = (0, import_react25.useCallback)(() => {
|
|
7184
|
+
const s = lastShapeRef.current;
|
|
7185
|
+
return s ? { phase: s.phase, width: s.width } : null;
|
|
7186
|
+
}, []);
|
|
7058
7187
|
const stableSubscribePipelineSettled = (0, import_react25.useCallback)(
|
|
7059
7188
|
(callback) => {
|
|
7060
7189
|
return subscribePipelineSettledRef.current(callback);
|
|
@@ -7105,6 +7234,9 @@ function RealtimeProvider({
|
|
|
7105
7234
|
getMockupUrls,
|
|
7106
7235
|
getCanvasVersion,
|
|
7107
7236
|
getLatestSentVersions: getLatestSentVersionsStable,
|
|
7237
|
+
reportPictureView,
|
|
7238
|
+
getSessionShape,
|
|
7239
|
+
setEditorOpen: setEditorOpenState,
|
|
7108
7240
|
isMockupLoading,
|
|
7109
7241
|
registerBlobUrl,
|
|
7110
7242
|
markBlobShown,
|
|
@@ -7140,6 +7272,8 @@ function RealtimeProvider({
|
|
|
7140
7272
|
getMockupUrls,
|
|
7141
7273
|
getCanvasVersion,
|
|
7142
7274
|
getLatestSentVersionsStable,
|
|
7275
|
+
reportPictureView,
|
|
7276
|
+
getSessionShape,
|
|
7143
7277
|
isMockupLoading,
|
|
7144
7278
|
registerBlobUrl,
|
|
7145
7279
|
markBlobShown,
|
|
@@ -10693,7 +10827,8 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
|
|
|
10693
10827
|
darkShimmerFadeInDuration = 300,
|
|
10694
10828
|
emptyText = "No artwork",
|
|
10695
10829
|
errorText = "Error loading",
|
|
10696
|
-
unavailableText = "Preview unavailable"
|
|
10830
|
+
unavailableText = "Preview unavailable",
|
|
10831
|
+
viewportPolicy = false
|
|
10697
10832
|
}) {
|
|
10698
10833
|
const context = useProductOptional();
|
|
10699
10834
|
const designContext = useDesignOptional();
|
|
@@ -10923,6 +11058,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
|
|
|
10923
11058
|
const sessionErrorCodeRef = (0, import_react46.useRef)(null);
|
|
10924
11059
|
sessionErrorCodeRef.current = realtimeContext?.renderError?.code ?? null;
|
|
10925
11060
|
const getCanvasVersion = realtimeContext?.getCanvasVersion;
|
|
11061
|
+
const getSessionShape = realtimeContext?.getSessionShape;
|
|
10926
11062
|
const applyRenderStamp = (0, import_react46.useCallback)(() => {
|
|
10927
11063
|
const node = containerRef.current;
|
|
10928
11064
|
if (!node) return;
|
|
@@ -10943,7 +11079,14 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
|
|
|
10943
11079
|
if (frameErrorRef.current) node.dataset.frameError = frameErrorRef.current;
|
|
10944
11080
|
else delete node.dataset.frameError;
|
|
10945
11081
|
node.dataset.renderState = refusalCodeRef.current || behind && sessionErrorCodeRef.current ? "refused" : behind ? "stale" : "current";
|
|
10946
|
-
|
|
11082
|
+
const img = node.querySelector("img");
|
|
11083
|
+
if (img?.naturalWidth) node.dataset.renderWidth = String(img.naturalWidth);
|
|
11084
|
+
const shape = getSessionShape?.();
|
|
11085
|
+
if (shape) {
|
|
11086
|
+
node.dataset.wantedWidth = String(shape.width);
|
|
11087
|
+
node.dataset.sessionPhase = shape.phase;
|
|
11088
|
+
}
|
|
11089
|
+
}, [getCanvasVersion, getLatestSentVersions, getSessionShape]);
|
|
10947
11090
|
const applyRenderStampRef = (0, import_react46.useRef)(applyRenderStamp);
|
|
10948
11091
|
applyRenderStampRef.current = applyRenderStamp;
|
|
10949
11092
|
(0, import_react46.useEffect)(() => {
|
|
@@ -10975,6 +11118,39 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
|
|
|
10975
11118
|
realtimeContext?.subscribeMockupResultById,
|
|
10976
11119
|
applyRenderStamp
|
|
10977
11120
|
]);
|
|
11121
|
+
const reportPictureView = realtimeContext?.reportPictureView;
|
|
11122
|
+
(0, import_react46.useEffect)(() => {
|
|
11123
|
+
if (!viewportPolicy || !reportPictureView || !actualMockupId) return;
|
|
11124
|
+
const node = containerRef.current;
|
|
11125
|
+
if (!node || typeof IntersectionObserver === "undefined") return;
|
|
11126
|
+
let inSet = false;
|
|
11127
|
+
const key = `${actualMockupId}#${Math.random().toString(36).slice(2, 9)}`;
|
|
11128
|
+
const report = () => {
|
|
11129
|
+
const r = node.getBoundingClientRect();
|
|
11130
|
+
const onScreen = r.width > 0 && r.right > 0 && r.left < window.innerWidth && r.bottom > 0 && r.top < window.innerHeight;
|
|
11131
|
+
reportPictureView(key, {
|
|
11132
|
+
mockupId: actualMockupId,
|
|
11133
|
+
inSet: inSet || onScreen,
|
|
11134
|
+
onScreen,
|
|
11135
|
+
devicePx: Math.round(r.width * (window.devicePixelRatio || 1))
|
|
11136
|
+
});
|
|
11137
|
+
};
|
|
11138
|
+
const io = new IntersectionObserver(
|
|
11139
|
+
(entries) => {
|
|
11140
|
+
inSet = entries.some((e) => e.isIntersecting);
|
|
11141
|
+
report();
|
|
11142
|
+
},
|
|
11143
|
+
{ rootMargin: "0px 100% 0px 100%" }
|
|
11144
|
+
);
|
|
11145
|
+
io.observe(node);
|
|
11146
|
+
const onResize = () => report();
|
|
11147
|
+
window.addEventListener("resize", onResize);
|
|
11148
|
+
return () => {
|
|
11149
|
+
io.disconnect();
|
|
11150
|
+
window.removeEventListener("resize", onResize);
|
|
11151
|
+
reportPictureView(key, null);
|
|
11152
|
+
};
|
|
11153
|
+
}, [viewportPolicy, reportPictureView, actualMockupId]);
|
|
10978
11154
|
(0, import_react46.useEffect)(() => {
|
|
10979
11155
|
if (!priorityContext || !actualMockupId || !placement) return;
|
|
10980
11156
|
priorityContext.registerMockup(actualMockupId, placement, initialPriority);
|
|
@@ -13355,7 +13531,8 @@ var MobileProductCarousel = (0, import_react56.memo)(function MobileProductCarou
|
|
|
13355
13531
|
onUrlGenerated: image.mockupId ? (url) => handleUrlGenerated(image.mockupId, url) : void 0,
|
|
13356
13532
|
errorText,
|
|
13357
13533
|
unavailableText,
|
|
13358
|
-
className: "w-full h-full object-cover cursor-pointer pointer-events-none"
|
|
13534
|
+
className: "w-full h-full object-cover cursor-pointer pointer-events-none",
|
|
13535
|
+
viewportPolicy: true
|
|
13359
13536
|
}
|
|
13360
13537
|
) : image.isRealMockup && !currentArtwork ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(LoadingOverlayPrismCandyInline, { visible: true, variant: "light" }) : /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
13361
13538
|
StaticCarouselImage,
|