@snowcone-app/ui 0.10.0 → 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/dist/index.js CHANGED
@@ -5742,6 +5742,7 @@ var MAX_FRAMES_PER_PICTURE = 3;
5742
5742
  var FRAME_SUPERSEDE_GRACE_MS = 2e3;
5743
5743
  var RERENDER_MIN_INTERVAL_MS = 550;
5744
5744
  var EDIT_QUIET_MS = 600;
5745
+ var EXPORT_PENDING_MAX_MS = 5e3;
5745
5746
  function mergeMockupIds(current, extra) {
5746
5747
  const out = [...current];
5747
5748
  for (const id of extra) if (!out.includes(id)) out.push(id);
@@ -5905,6 +5906,7 @@ function RealtimeProvider({
5905
5906
  const pictureViewsRef = useRef12(/* @__PURE__ */ new Map());
5906
5907
  const editLiveRef = useRef12(false);
5907
5908
  const editQuietTimerRef = useRef12(null);
5909
+ const exportPendingSinceRef = useRef12(0);
5908
5910
  const shapeApplyTimerRef = useRef12(null);
5909
5911
  const lastShapeRef = useRef12(null);
5910
5912
  const applySessionShapeRef = useRef12(null);
@@ -6207,6 +6209,7 @@ function RealtimeProvider({
6207
6209
  }
6208
6210
  });
6209
6211
  let settledVersions = 0;
6212
+ let newestSettled = 0;
6210
6213
  const due = dueByVersionRef.current;
6211
6214
  results.forEach((result) => {
6212
6215
  const v = result.requestVersion;
@@ -6216,6 +6219,7 @@ function RealtimeProvider({
6216
6219
  if (entry.due <= 1) {
6217
6220
  due.delete(v);
6218
6221
  settledVersions += 1;
6222
+ newestSettled = Math.max(newestSettled, v);
6219
6223
  } else {
6220
6224
  entry.due -= 1;
6221
6225
  }
@@ -6227,15 +6231,16 @@ function RealtimeProvider({
6227
6231
  if (!pipelineResetCooldownRef.current) {
6228
6232
  hasBlobInFlightRef.current = false;
6229
6233
  for (let i = 0; i < settledVersions; i++) pipelineSettledSubscribersRef.current.forEach((cb) => cb());
6230
- markEditSettled();
6234
+ const exportPending = exportPendingSinceRef.current > 0 && Date.now() - exportPendingSinceRef.current < EXPORT_PENDING_MAX_MS;
6235
+ if (!exportPending && newestSettled >= getLastSentVersion()) markEditSettled();
6231
6236
  }
6232
6237
  } else if (due.size === 0 && hasBlobInFlightRef.current && !hasPendingBlobs() && !pipelineResetCooldownRef.current) {
6233
6238
  hasBlobInFlightRef.current = false;
6234
6239
  pipelineSettledSubscribersRef.current.forEach((cb) => cb());
6235
- markEditSettled();
6240
+ if (!(exportPendingSinceRef.current > 0 && Date.now() - exportPendingSinceRef.current < EXPORT_PENDING_MAX_MS)) markEditSettled();
6236
6241
  }
6237
6242
  },
6238
- [hasPendingBlobs, markEditSettled]
6243
+ [hasPendingBlobs, markEditSettled, getLastSentVersion]
6239
6244
  );
6240
6245
  const runComposite = useCallback10(
6241
6246
  async (result) => {
@@ -6351,6 +6356,7 @@ function RealtimeProvider({
6351
6356
  const sendCanvasBlob = useCallback10(
6352
6357
  (placement, blob, mockupCount, baseThrottleMs) => {
6353
6358
  blobQueuedGenRef.current = pipelineGenRef.current;
6359
+ exportPendingSinceRef.current = 0;
6354
6360
  const result = sendCanvasBlobRaw(
6355
6361
  placement,
6356
6362
  blob,
@@ -6371,6 +6377,7 @@ function RealtimeProvider({
6371
6377
  const sendCanvasState = useCallback10(
6372
6378
  (placement, state, mockupCount, baseThrottleMs) => {
6373
6379
  blobQueuedGenRef.current = pipelineGenRef.current;
6380
+ exportPendingSinceRef.current = 0;
6374
6381
  const result = sendCanvasStateRaw(
6375
6382
  placement,
6376
6383
  state,
@@ -6687,6 +6694,7 @@ function RealtimeProvider({
6687
6694
  );
6688
6695
  const notifyPendingExport = useCallback10(
6689
6696
  (placement) => {
6697
+ exportPendingSinceRef.current = Date.now();
6690
6698
  if (pendingPlacementsRef.current.has(placement)) {
6691
6699
  return;
6692
6700
  }
@@ -6708,6 +6716,8 @@ function RealtimeProvider({
6708
6716
  );
6709
6717
  const notifyPendingExportCancelled = useCallback10(
6710
6718
  (placement) => {
6719
+ exportPendingSinceRef.current = 0;
6720
+ markEditSettled();
6711
6721
  if (!pendingPlacementsRef.current.has(placement)) {
6712
6722
  return;
6713
6723
  }
@@ -6728,7 +6738,7 @@ function RealtimeProvider({
6728
6738
  );
6729
6739
  pendingExportCancelledSubscribersRef.current.forEach((cb) => cb(placement));
6730
6740
  },
6731
- [productContext?.product?.mockups]
6741
+ [productContext?.product?.mockups, markEditSettled]
6732
6742
  );
6733
6743
  const getMockupUrl3 = useCallback10((mockupId) => {
6734
6744
  if (pendingMockupIdsRef.current.has(mockupId)) {