@snowcone-app/ui 0.9.8 → 0.10.1

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4445](https://github.com/snowcone-app/snowcone-monorepo/pull/4445) [`13b12bb`](https://github.com/snowcone-app/snowcone-monorepo/commit/13b12bbfec1a24e3efb4c5814a47de12f44bbb63) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Phone editor: the catch-up (every picture) starts only when the edit's own newest version has landed and no further export is on its way. On a slow link the editor-open frames were still arriving when a drag began; their settle started a 31-picture catch-up mid-gesture, and the edit's frames queued behind it (21 s). An announced export that never goes out stops holding the edit after 5 s; one cancelled as a no-op releases it at once.
8
+
9
+ ## 0.10.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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.
14
+
3
15
  ## 0.9.8
4
16
 
5
17
  ### 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,8 @@ 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;
6104
+ var EXPORT_PENDING_MAX_MS = 5e3;
6068
6105
  function mergeMockupIds(current, extra) {
6069
6106
  const out = [...current];
6070
6107
  for (const id of extra) if (!out.includes(id)) out.push(id);
@@ -6083,7 +6120,8 @@ function RealtimeProvider({
6083
6120
  shop,
6084
6121
  grantUrl,
6085
6122
  initialGrant,
6086
- delivery = "cropped"
6123
+ delivery = "cropped",
6124
+ editorOpen = true
6087
6125
  }) {
6088
6126
  const productContext = useProductOptional();
6089
6127
  const mockupBg = useMockupBackgroundOptional();
@@ -6224,6 +6262,19 @@ function RealtimeProvider({
6224
6262
  const compositeBusyRef = (0, import_react25.useRef)(/* @__PURE__ */ new Set());
6225
6263
  const compositeCanvasRef = (0, import_react25.useRef)(null);
6226
6264
  const requestedMockupIdsRef = (0, import_react25.useRef)([]);
6265
+ const pictureViewsRef = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
6266
+ const editLiveRef = (0, import_react25.useRef)(false);
6267
+ const editQuietTimerRef = (0, import_react25.useRef)(null);
6268
+ const exportPendingSinceRef = (0, import_react25.useRef)(0);
6269
+ const shapeApplyTimerRef = (0, import_react25.useRef)(null);
6270
+ const lastShapeRef = (0, import_react25.useRef)(null);
6271
+ const applySessionShapeRef = (0, import_react25.useRef)(null);
6272
+ const [editorOpenState, setEditorOpenState] = (0, import_react25.useState)(editorOpen);
6273
+ (0, import_react25.useEffect)(() => setEditorOpenState(editorOpen), [editorOpen]);
6274
+ const editorOpenRef = (0, import_react25.useRef)(editorOpenState);
6275
+ editorOpenRef.current = editorOpenState;
6276
+ const heroWidthRef = (0, import_react25.useRef)(mockupWidth);
6277
+ heroWidthRef.current = mockupWidth;
6227
6278
  const serverStampsVersionsRef = (0, import_react25.useRef)(false);
6228
6279
  const pendingRerenderRef = (0, import_react25.useRef)([]);
6229
6280
  const forceRerenderByConfigRef = (0, import_react25.useRef)(null);
@@ -6414,6 +6465,64 @@ function RealtimeProvider({
6414
6465
  compositeQueueRef.current.clear();
6415
6466
  croppedActiveRef.current = false;
6416
6467
  }, []);
6468
+ const currentShape = (0, import_react25.useCallback)(
6469
+ () => sessionShape({
6470
+ allMockupIds: configuredMockupIdsRef.current,
6471
+ views: pictureViewsRef.current,
6472
+ heroWidth: heroWidthRef.current,
6473
+ editorOpen: editorOpenRef.current,
6474
+ editLive: editLiveRef.current
6475
+ }),
6476
+ []
6477
+ );
6478
+ const applySessionShape = (0, import_react25.useCallback)(() => {
6479
+ const base = lastConfigBaseRef.current;
6480
+ if (!base || !configSentRef.current) return;
6481
+ const shape = currentShape();
6482
+ if (sameShape(lastShapeRef.current, shape)) {
6483
+ lastShapeRef.current = shape;
6484
+ return;
6485
+ }
6486
+ if (lastShapeRef.current && lastShapeRef.current.width !== shape.width) invalidateBackgrounds();
6487
+ lastShapeRef.current = shape;
6488
+ base.mockupIds = shape.mockupIds;
6489
+ base.width = shape.width;
6490
+ requestedMockupIdsRef.current = [...shape.mockupIds];
6491
+ sendConfigRaw({
6492
+ ...base,
6493
+ placementSettings: { ...placementSettingsOverridesRef.current },
6494
+ ...croppedActiveRef.current ? { overlayCrop: "auto" } : {}
6495
+ });
6496
+ }, [currentShape, invalidateBackgrounds, sendConfigRaw]);
6497
+ applySessionShapeRef.current = applySessionShape;
6498
+ const markEditLive = (0, import_react25.useCallback)(() => {
6499
+ if (editQuietTimerRef.current) {
6500
+ clearTimeout(editQuietTimerRef.current);
6501
+ editQuietTimerRef.current = null;
6502
+ }
6503
+ if (editLiveRef.current) return;
6504
+ editLiveRef.current = true;
6505
+ applySessionShapeRef.current?.();
6506
+ }, []);
6507
+ const markEditSettled = (0, import_react25.useCallback)(() => {
6508
+ if (!editLiveRef.current) return;
6509
+ if (editQuietTimerRef.current) clearTimeout(editQuietTimerRef.current);
6510
+ editQuietTimerRef.current = setTimeout(() => {
6511
+ editQuietTimerRef.current = null;
6512
+ editLiveRef.current = false;
6513
+ applySessionShapeRef.current?.();
6514
+ }, EDIT_QUIET_MS);
6515
+ }, []);
6516
+ (0, import_react25.useEffect)(() => {
6517
+ applySessionShapeRef.current?.();
6518
+ }, [editorOpenState]);
6519
+ (0, import_react25.useEffect)(
6520
+ () => () => {
6521
+ if (editQuietTimerRef.current) clearTimeout(editQuietTimerRef.current);
6522
+ if (shapeApplyTimerRef.current) clearTimeout(shapeApplyTimerRef.current);
6523
+ },
6524
+ []
6525
+ );
6417
6526
  const deliverResults = (0, import_react25.useCallback)(
6418
6527
  (results) => {
6419
6528
  if (results.length === 0) return;
@@ -6459,6 +6568,7 @@ function RealtimeProvider({
6459
6568
  }
6460
6569
  });
6461
6570
  let settledVersions = 0;
6571
+ let newestSettled = 0;
6462
6572
  const due = dueByVersionRef.current;
6463
6573
  results.forEach((result) => {
6464
6574
  const v = result.requestVersion;
@@ -6468,6 +6578,7 @@ function RealtimeProvider({
6468
6578
  if (entry.due <= 1) {
6469
6579
  due.delete(v);
6470
6580
  settledVersions += 1;
6581
+ newestSettled = Math.max(newestSettled, v);
6471
6582
  } else {
6472
6583
  entry.due -= 1;
6473
6584
  }
@@ -6479,13 +6590,16 @@ function RealtimeProvider({
6479
6590
  if (!pipelineResetCooldownRef.current) {
6480
6591
  hasBlobInFlightRef.current = false;
6481
6592
  for (let i = 0; i < settledVersions; i++) pipelineSettledSubscribersRef.current.forEach((cb) => cb());
6593
+ const exportPending = exportPendingSinceRef.current > 0 && Date.now() - exportPendingSinceRef.current < EXPORT_PENDING_MAX_MS;
6594
+ if (!exportPending && newestSettled >= getLastSentVersion()) markEditSettled();
6482
6595
  }
6483
6596
  } else if (due.size === 0 && hasBlobInFlightRef.current && !hasPendingBlobs() && !pipelineResetCooldownRef.current) {
6484
6597
  hasBlobInFlightRef.current = false;
6485
6598
  pipelineSettledSubscribersRef.current.forEach((cb) => cb());
6599
+ if (!(exportPendingSinceRef.current > 0 && Date.now() - exportPendingSinceRef.current < EXPORT_PENDING_MAX_MS)) markEditSettled();
6486
6600
  }
6487
6601
  },
6488
- [hasPendingBlobs]
6602
+ [hasPendingBlobs, markEditSettled, getLastSentVersion]
6489
6603
  );
6490
6604
  const runComposite = (0, import_react25.useCallback)(
6491
6605
  async (result) => {
@@ -6601,6 +6715,7 @@ function RealtimeProvider({
6601
6715
  const sendCanvasBlob = (0, import_react25.useCallback)(
6602
6716
  (placement, blob, mockupCount, baseThrottleMs) => {
6603
6717
  blobQueuedGenRef.current = pipelineGenRef.current;
6718
+ exportPendingSinceRef.current = 0;
6604
6719
  const result = sendCanvasBlobRaw(
6605
6720
  placement,
6606
6721
  blob,
@@ -6612,14 +6727,16 @@ function RealtimeProvider({
6612
6727
  lastBlobSentTimeRef.current = (/* @__PURE__ */ new Date()).toLocaleTimeString();
6613
6728
  isPendingMockupsRef.current = true;
6614
6729
  pendingBlobSubscribersRef.current.forEach((cb) => cb(placement));
6730
+ markEditLive();
6615
6731
  }
6616
6732
  return result;
6617
6733
  },
6618
- [sendCanvasBlobRaw]
6734
+ [sendCanvasBlobRaw, markEditLive]
6619
6735
  );
6620
6736
  const sendCanvasState = (0, import_react25.useCallback)(
6621
6737
  (placement, state, mockupCount, baseThrottleMs) => {
6622
6738
  blobQueuedGenRef.current = pipelineGenRef.current;
6739
+ exportPendingSinceRef.current = 0;
6623
6740
  const result = sendCanvasStateRaw(
6624
6741
  placement,
6625
6742
  state,
@@ -6632,15 +6749,16 @@ function RealtimeProvider({
6632
6749
  isPendingMockupsRef.current = true;
6633
6750
  const version = getLastSentVersion();
6634
6751
  if (version > 0) {
6635
- const configured = configuredMockupIdsRef.current.length;
6752
+ const configured = requestedMockupIdsRef.current.length || configuredMockupIdsRef.current.length;
6636
6753
  const expected = Math.max(1, Math.min(configured || Infinity, mockupCount || Infinity));
6637
6754
  dueByVersionRef.current.set(version, { due: Number.isFinite(expected) ? expected : 1, at: Date.now() });
6638
6755
  }
6639
6756
  pendingBlobSubscribersRef.current.forEach((cb) => cb(placement));
6757
+ markEditLive();
6640
6758
  }
6641
6759
  return result;
6642
6760
  },
6643
- [sendCanvasStateRaw, getLastSentVersion]
6761
+ [sendCanvasStateRaw, getLastSentVersion, markEditLive]
6644
6762
  );
6645
6763
  const sendColorBlobTracked = (0, import_react25.useCallback)(
6646
6764
  (placement, color) => {
@@ -6705,22 +6823,24 @@ function RealtimeProvider({
6705
6823
  });
6706
6824
  }
6707
6825
  configuredMockupIdsRef.current = mockupIds;
6826
+ const shape = currentShape();
6827
+ lastShapeRef.current = shape;
6708
6828
  const configPayload = useSessionGrant ? {
6709
6829
  productId,
6710
- mockupIds,
6830
+ mockupIds: shape.mockupIds,
6711
6831
  variantId,
6712
6832
  shop,
6713
- width: mockupWidth,
6833
+ width: shape.width,
6714
6834
  ...mockupBg ? { bg: mockupBg } : {},
6715
6835
  ...spreadCropsRef.current ? { spreadCrops: spreadCropsRef.current } : {},
6716
6836
  placementSettings: { ...placementSettingsOverridesRef.current }
6717
6837
  } : {
6718
6838
  productId,
6719
- mockupIds,
6839
+ mockupIds: shape.mockupIds,
6720
6840
  variantId,
6721
6841
  shop: "hTidnpNnNa",
6722
6842
  seal: "bypass-sig-for-k6-load-test",
6723
- width: mockupWidth,
6843
+ width: shape.width,
6724
6844
  ...mockupBg ? { bg: mockupBg } : {},
6725
6845
  ...spreadCropsRef.current ? { spreadCrops: spreadCropsRef.current } : {},
6726
6846
  placementSettings: { ...placementSettingsOverridesRef.current }
@@ -6732,7 +6852,7 @@ function RealtimeProvider({
6732
6852
  });
6733
6853
  }
6734
6854
  lastConfigBaseRef.current = configPayload;
6735
- requestedMockupIdsRef.current = mockupIds;
6855
+ requestedMockupIdsRef.current = [...shape.mockupIds];
6736
6856
  sendConfigRaw(
6737
6857
  croppedActiveRef.current ? { ...configPayload, overlayCrop: "auto" } : configPayload
6738
6858
  );
@@ -6758,6 +6878,7 @@ function RealtimeProvider({
6758
6878
  sendConfigRaw,
6759
6879
  sendColorBlobTracked,
6760
6880
  invalidateBackgrounds,
6881
+ currentShape,
6761
6882
  mockupWidth,
6762
6883
  mockupBg,
6763
6884
  spreadCropsVersion
@@ -6932,6 +7053,7 @@ function RealtimeProvider({
6932
7053
  );
6933
7054
  const notifyPendingExport = (0, import_react25.useCallback)(
6934
7055
  (placement) => {
7056
+ exportPendingSinceRef.current = Date.now();
6935
7057
  if (pendingPlacementsRef.current.has(placement)) {
6936
7058
  return;
6937
7059
  }
@@ -6947,11 +7069,14 @@ function RealtimeProvider({
6947
7069
  }
6948
7070
  console.log(`[RTP] notifyPendingExport("${placement}"): marked ${pendingIds.length} mockup(s) pending \u2014 [${pendingIds.slice(0, 5).join(", ")}${pendingIds.length > 5 ? "..." : ""}]`);
6949
7071
  pendingBlobSubscribersRef.current.forEach((cb) => cb(placement));
7072
+ markEditLive();
6950
7073
  },
6951
- [productContext?.product?.mockups]
7074
+ [productContext?.product?.mockups, markEditLive]
6952
7075
  );
6953
7076
  const notifyPendingExportCancelled = (0, import_react25.useCallback)(
6954
7077
  (placement) => {
7078
+ exportPendingSinceRef.current = 0;
7079
+ markEditSettled();
6955
7080
  if (!pendingPlacementsRef.current.has(placement)) {
6956
7081
  return;
6957
7082
  }
@@ -6972,7 +7097,7 @@ function RealtimeProvider({
6972
7097
  );
6973
7098
  pendingExportCancelledSubscribersRef.current.forEach((cb) => cb(placement));
6974
7099
  },
6975
- [productContext?.product?.mockups]
7100
+ [productContext?.product?.mockups, markEditSettled]
6976
7101
  );
6977
7102
  const getMockupUrl3 = (0, import_react25.useCallback)((mockupId) => {
6978
7103
  if (pendingMockupIdsRef.current.has(mockupId)) {
@@ -7055,6 +7180,20 @@ function RealtimeProvider({
7055
7180
  const getLatestSentVersionsRef = (0, import_react25.useRef)(getLatestSentVersions);
7056
7181
  getLatestSentVersionsRef.current = getLatestSentVersions;
7057
7182
  const getLatestSentVersionsStable = (0, import_react25.useCallback)(() => getLatestSentVersionsRef.current?.() ?? {}, []);
7183
+ const reportPictureView = (0, import_react25.useCallback)((elementKey, view) => {
7184
+ const views = pictureViewsRef.current;
7185
+ if (view) views.set(elementKey, view);
7186
+ else views.delete(elementKey);
7187
+ if (shapeApplyTimerRef.current) return;
7188
+ shapeApplyTimerRef.current = setTimeout(() => {
7189
+ shapeApplyTimerRef.current = null;
7190
+ applySessionShapeRef.current?.();
7191
+ }, 100);
7192
+ }, []);
7193
+ const getSessionShape = (0, import_react25.useCallback)(() => {
7194
+ const s = lastShapeRef.current;
7195
+ return s ? { phase: s.phase, width: s.width } : null;
7196
+ }, []);
7058
7197
  const stableSubscribePipelineSettled = (0, import_react25.useCallback)(
7059
7198
  (callback) => {
7060
7199
  return subscribePipelineSettledRef.current(callback);
@@ -7105,6 +7244,9 @@ function RealtimeProvider({
7105
7244
  getMockupUrls,
7106
7245
  getCanvasVersion,
7107
7246
  getLatestSentVersions: getLatestSentVersionsStable,
7247
+ reportPictureView,
7248
+ getSessionShape,
7249
+ setEditorOpen: setEditorOpenState,
7108
7250
  isMockupLoading,
7109
7251
  registerBlobUrl,
7110
7252
  markBlobShown,
@@ -7140,6 +7282,8 @@ function RealtimeProvider({
7140
7282
  getMockupUrls,
7141
7283
  getCanvasVersion,
7142
7284
  getLatestSentVersionsStable,
7285
+ reportPictureView,
7286
+ getSessionShape,
7143
7287
  isMockupLoading,
7144
7288
  registerBlobUrl,
7145
7289
  markBlobShown,
@@ -10693,7 +10837,8 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
10693
10837
  darkShimmerFadeInDuration = 300,
10694
10838
  emptyText = "No artwork",
10695
10839
  errorText = "Error loading",
10696
- unavailableText = "Preview unavailable"
10840
+ unavailableText = "Preview unavailable",
10841
+ viewportPolicy = false
10697
10842
  }) {
10698
10843
  const context = useProductOptional();
10699
10844
  const designContext = useDesignOptional();
@@ -10923,6 +11068,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
10923
11068
  const sessionErrorCodeRef = (0, import_react46.useRef)(null);
10924
11069
  sessionErrorCodeRef.current = realtimeContext?.renderError?.code ?? null;
10925
11070
  const getCanvasVersion = realtimeContext?.getCanvasVersion;
11071
+ const getSessionShape = realtimeContext?.getSessionShape;
10926
11072
  const applyRenderStamp = (0, import_react46.useCallback)(() => {
10927
11073
  const node = containerRef.current;
10928
11074
  if (!node) return;
@@ -10943,7 +11089,14 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
10943
11089
  if (frameErrorRef.current) node.dataset.frameError = frameErrorRef.current;
10944
11090
  else delete node.dataset.frameError;
10945
11091
  node.dataset.renderState = refusalCodeRef.current || behind && sessionErrorCodeRef.current ? "refused" : behind ? "stale" : "current";
10946
- }, [getCanvasVersion, getLatestSentVersions]);
11092
+ const img = node.querySelector("img");
11093
+ if (img?.naturalWidth) node.dataset.renderWidth = String(img.naturalWidth);
11094
+ const shape = getSessionShape?.();
11095
+ if (shape) {
11096
+ node.dataset.wantedWidth = String(shape.width);
11097
+ node.dataset.sessionPhase = shape.phase;
11098
+ }
11099
+ }, [getCanvasVersion, getLatestSentVersions, getSessionShape]);
10947
11100
  const applyRenderStampRef = (0, import_react46.useRef)(applyRenderStamp);
10948
11101
  applyRenderStampRef.current = applyRenderStamp;
10949
11102
  (0, import_react46.useEffect)(() => {
@@ -10975,6 +11128,39 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
10975
11128
  realtimeContext?.subscribeMockupResultById,
10976
11129
  applyRenderStamp
10977
11130
  ]);
11131
+ const reportPictureView = realtimeContext?.reportPictureView;
11132
+ (0, import_react46.useEffect)(() => {
11133
+ if (!viewportPolicy || !reportPictureView || !actualMockupId) return;
11134
+ const node = containerRef.current;
11135
+ if (!node || typeof IntersectionObserver === "undefined") return;
11136
+ let inSet = false;
11137
+ const key = `${actualMockupId}#${Math.random().toString(36).slice(2, 9)}`;
11138
+ const report = () => {
11139
+ const r = node.getBoundingClientRect();
11140
+ const onScreen = r.width > 0 && r.right > 0 && r.left < window.innerWidth && r.bottom > 0 && r.top < window.innerHeight;
11141
+ reportPictureView(key, {
11142
+ mockupId: actualMockupId,
11143
+ inSet: inSet || onScreen,
11144
+ onScreen,
11145
+ devicePx: Math.round(r.width * (window.devicePixelRatio || 1))
11146
+ });
11147
+ };
11148
+ const io = new IntersectionObserver(
11149
+ (entries) => {
11150
+ inSet = entries.some((e) => e.isIntersecting);
11151
+ report();
11152
+ },
11153
+ { rootMargin: "0px 100% 0px 100%" }
11154
+ );
11155
+ io.observe(node);
11156
+ const onResize = () => report();
11157
+ window.addEventListener("resize", onResize);
11158
+ return () => {
11159
+ io.disconnect();
11160
+ window.removeEventListener("resize", onResize);
11161
+ reportPictureView(key, null);
11162
+ };
11163
+ }, [viewportPolicy, reportPictureView, actualMockupId]);
10978
11164
  (0, import_react46.useEffect)(() => {
10979
11165
  if (!priorityContext || !actualMockupId || !placement) return;
10980
11166
  priorityContext.registerMockup(actualMockupId, placement, initialPriority);
@@ -13355,7 +13541,8 @@ var MobileProductCarousel = (0, import_react56.memo)(function MobileProductCarou
13355
13541
  onUrlGenerated: image.mockupId ? (url) => handleUrlGenerated(image.mockupId, url) : void 0,
13356
13542
  errorText,
13357
13543
  unavailableText,
13358
- className: "w-full h-full object-cover cursor-pointer pointer-events-none"
13544
+ className: "w-full h-full object-cover cursor-pointer pointer-events-none",
13545
+ viewportPolicy: true
13359
13546
  }
13360
13547
  ) : image.isRealMockup && !currentArtwork ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(LoadingOverlayPrismCandyInline, { visible: true, variant: "light" }) : /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13361
13548
  StaticCarouselImage,