@snowcone-app/ui 0.13.0 → 0.13.2
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 +12 -0
- package/dist/index.cjs +135 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +133 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/composed/HeroProductImage.tsx +137 -64
- package/src/composed/__tests__/HeroProductImage.mountsOnLiveFrame.test.tsx +147 -0
- package/src/composed/__tests__/HeroProductImage.swap.test.tsx +105 -0
- package/src/patterns/RealtimeProvider.tsx +32 -1
- package/src/patterns/__tests__/RealtimeProvider.blobLifecycle.test.tsx +73 -0
- package/src/personalization/PersonalizationProvider.tsx +43 -1
- package/src/personalization/__tests__/PersonalizationProvider.last-keystroke.test.tsx +81 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#6692](https://github.com/snowcone-app/snowcone-monorepo/pull/6692) [`96079cb`](https://github.com/snowcone-app/snowcone-monorepo/commit/96079cb697b9c2051f64e39370ff1f3fc2d7c6ec) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Gallery pictures that mount after their live frames arrived (a phone carousel slide swiped to after an edit): the provider's replayed frame is kept too (not only a `realtimeUrl` handed in), while a non-live URL handed in at mount (a static picture of an older variant) is still replaced. `data-render-version` / `data-render-state` now describe what the element paints: a non-live picture puts the version back to 0 (stale), never "current". A picture whose newest frame can no longer be loaded is forgotten and re-rendered alone (`E_FRAME_LOST`), once until it shows a picture again.
|
|
8
|
+
|
|
9
|
+
## 0.13.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#6688](https://github.com/snowcone-app/snowcone-monorepo/pull/6688) [`27379aa`](https://github.com/snowcone-app/snowcone-monorepo/commit/27379aab04800d7b9b6e07915b9a320cc763994c) Thanks [@kevinsproles](https://github.com/kevinsproles)! - HeroProductImage double-buffers its picture: the next one loads hidden in its own `<img>` above the shown one and shows once decoded (at once for a live frame, a fade for another picture), so typing never paints a frame without a picture (`data-hero-incoming`). A picture mounted with a live frame (the phone carousel's slide 3) keeps it instead of its static picture. PersonalizationProvider exports 250 ms after the last keystroke (was 100 ms) and always exports the last keystroke once typing settles (the canvas auto-export could drop it: "Hello Kev!" rendered and printed as "Hello Kev").
|
|
14
|
+
|
|
3
15
|
## 0.13.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -357,6 +357,7 @@ __export(src_exports, {
|
|
|
357
357
|
checkTailwindConfig: () => checkTailwindConfig,
|
|
358
358
|
checkThemeTokens: () => checkThemeTokens,
|
|
359
359
|
createScrollDirectionTracker: () => createScrollDirectionTracker,
|
|
360
|
+
decodedPicture: () => decodedPicture,
|
|
360
361
|
describeProductArtAlignment: () => import_sdk16.describeProductArtAlignment,
|
|
361
362
|
firstView: () => firstView,
|
|
362
363
|
firstViewAnchorOfSlide: () => firstViewAnchorOfSlide,
|
|
@@ -383,6 +384,7 @@ __export(src_exports, {
|
|
|
383
384
|
normalizeHex: () => normalizeHex,
|
|
384
385
|
observe: () => observe,
|
|
385
386
|
pictureRenderState: () => pictureRenderState,
|
|
387
|
+
pictureSwapOf: () => pictureSwapOf,
|
|
386
388
|
placementArtFor: () => placementArtFor,
|
|
387
389
|
runConfigChecks: () => runConfigChecks,
|
|
388
390
|
scrollInputAboveKeyboard: () => scrollInputAboveKeyboard,
|
|
@@ -6403,6 +6405,8 @@ function RealtimeProvider({
|
|
|
6403
6405
|
const rerenderTimerRef = (0, import_react25.useRef)(null);
|
|
6404
6406
|
const fullFrameRerenderIdsRef = (0, import_react25.useRef)(/* @__PURE__ */ new Set());
|
|
6405
6407
|
const fullFrameRerenderTimerRef = (0, import_react25.useRef)(null);
|
|
6408
|
+
const rerenderFullFrameRef = (0, import_react25.useRef)(null);
|
|
6409
|
+
const lostFrameAskedRef = (0, import_react25.useRef)(/* @__PURE__ */ new Set());
|
|
6406
6410
|
(0, import_react25.useEffect)(
|
|
6407
6411
|
() => () => {
|
|
6408
6412
|
if (fullFrameRerenderTimerRef.current) clearTimeout(fullFrameRerenderTimerRef.current);
|
|
@@ -6454,6 +6458,7 @@ function RealtimeProvider({
|
|
|
6454
6458
|
}, [revokeBlobUrl]);
|
|
6455
6459
|
const markBlobShown = (0, import_react25.useCallback)((owner, url, consumer = "default") => {
|
|
6456
6460
|
ackUrl(url);
|
|
6461
|
+
lostFrameAskedRef.current.delete(owner);
|
|
6457
6462
|
const list = blobsByOwnerRef.current.get(owner);
|
|
6458
6463
|
if (!list || list.indexOf(url) < 0) return;
|
|
6459
6464
|
const shown = shownBlobByOwnerRef.current.get(owner) ?? /* @__PURE__ */ new Map();
|
|
@@ -6463,6 +6468,22 @@ function RealtimeProvider({
|
|
|
6463
6468
|
}, [releaseOlderFrames, ackUrl]);
|
|
6464
6469
|
const frameFailed = (0, import_react25.useCallback)((url) => {
|
|
6465
6470
|
ackUrl(url);
|
|
6471
|
+
if (!url.startsWith("blob:")) return;
|
|
6472
|
+
let mockupId;
|
|
6473
|
+
mockupUrlCacheRef.current.forEach((entry, id) => {
|
|
6474
|
+
if (entry.url === url) mockupId = id;
|
|
6475
|
+
});
|
|
6476
|
+
if (!mockupId) return;
|
|
6477
|
+
if (pendingMockupIdsRef.current.has(mockupId)) return;
|
|
6478
|
+
if (compositeQueueRef.current.has(mockupId) || compositeBusyRef.current.has(mockupId)) return;
|
|
6479
|
+
if (lostFrameAskedRef.current.has(mockupId)) return;
|
|
6480
|
+
lostFrameAskedRef.current.add(mockupId);
|
|
6481
|
+
console.error(
|
|
6482
|
+
`[RealtimeProvider] E_FRAME_LOST: ${mockupId}'s newest frame could not be loaded (gone before any element drew it); re-rendering that picture.`
|
|
6483
|
+
);
|
|
6484
|
+
mockupUrlCacheRef.current.delete(mockupId);
|
|
6485
|
+
mockupResultsRef.current = mockupResultsRef.current.filter((r) => r.imageUrl !== url);
|
|
6486
|
+
rerenderFullFrameRef.current?.(mockupId);
|
|
6466
6487
|
}, [ackUrl]);
|
|
6467
6488
|
const releaseBlobConsumer = (0, import_react25.useCallback)((owner, consumer) => {
|
|
6468
6489
|
const shown = shownBlobByOwnerRef.current.get(owner);
|
|
@@ -6569,6 +6590,7 @@ function RealtimeProvider({
|
|
|
6569
6590
|
},
|
|
6570
6591
|
[sendFullFrameConfig, forceRerenderByConfig, sendRerenderPaced]
|
|
6571
6592
|
);
|
|
6593
|
+
rerenderFullFrameRef.current = rerenderFullFrame;
|
|
6572
6594
|
const maybeFlipCrop = (0, import_react25.useCallback)(() => {
|
|
6573
6595
|
if (!croppedDeliveryEnabled || !cropCapableRef.current) return;
|
|
6574
6596
|
if (croppedActiveRef.current) return;
|
|
@@ -11140,6 +11162,23 @@ function heroSize(stripView, cropWidth, width) {
|
|
|
11140
11162
|
if (isCrop(stripView)) return cropWidth !== void 0 ? { stripView, width: cropWidth } : { stripView };
|
|
11141
11163
|
return { width };
|
|
11142
11164
|
}
|
|
11165
|
+
function pictureSwapOf(shownUrl, nextUrl) {
|
|
11166
|
+
if (!shownUrl) return "instant";
|
|
11167
|
+
return nextUrl.startsWith("blob:") || shownUrl.startsWith("blob:") ? "instant" : "crossfade";
|
|
11168
|
+
}
|
|
11169
|
+
function decodedPicture(img) {
|
|
11170
|
+
if (typeof img.decode === "function") {
|
|
11171
|
+
return img.decode().catch((e) => {
|
|
11172
|
+
if (img.complete && img.naturalWidth > 0) return;
|
|
11173
|
+
throw e;
|
|
11174
|
+
});
|
|
11175
|
+
}
|
|
11176
|
+
return new Promise((resolve, reject) => {
|
|
11177
|
+
if (img.complete) return resolve();
|
|
11178
|
+
img.onload = () => resolve();
|
|
11179
|
+
img.onerror = () => reject(new Error("E_FRAME_UNAVAILABLE"));
|
|
11180
|
+
});
|
|
11181
|
+
}
|
|
11143
11182
|
var EMPTY_IMAGES = [];
|
|
11144
11183
|
var DESIGN_BUSY_RETRY_MS = 1500;
|
|
11145
11184
|
function blockingSessionError(error) {
|
|
@@ -11304,7 +11343,13 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11304
11343
|
const priorityRegisteredRef = (0, import_react48.useRef)(false);
|
|
11305
11344
|
const onLoadCalledRef = (0, import_react48.useRef)(false);
|
|
11306
11345
|
const prevArtworkSrcRef = (0, import_react48.useRef)(void 0);
|
|
11307
|
-
const
|
|
11346
|
+
const artIdentityRef = (0, import_react48.useRef)(void 0);
|
|
11347
|
+
artIdentityRef.current = artIdentity(artworkSrc || selectedArtworkSrc, placementArtKey);
|
|
11348
|
+
const mountedOnLiveFrame = !!realtimeUrl && (realtimeUrl.startsWith("blob:") || !!actualMockupId && realtimeUrl === realtimeContext?.getMockupUrl?.(actualMockupId));
|
|
11349
|
+
const realtimeArtworkSrcRef = (0, import_react48.useRef)(
|
|
11350
|
+
mountedOnLiveFrame ? artIdentity(artworkSrc || selectedArtworkSrc, placementArtKey) : void 0
|
|
11351
|
+
);
|
|
11352
|
+
const artSeenRef = (0, import_react48.useRef)(false);
|
|
11308
11353
|
const hasReceivedRealtimeRef = (0, import_react48.useRef)(false);
|
|
11309
11354
|
const isPendingExportRef = (0, import_react48.useRef)(false);
|
|
11310
11355
|
const onUrlGeneratedRef = (0, import_react48.useRef)(onUrlGenerated);
|
|
@@ -11363,6 +11408,7 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11363
11408
|
const handleMockupResult = (result) => {
|
|
11364
11409
|
if (!result?.imageUrl) return;
|
|
11365
11410
|
hasReceivedRealtimeRef.current = true;
|
|
11411
|
+
realtimeArtworkSrcRef.current = artIdentityRef.current;
|
|
11366
11412
|
isPendingExportRef.current = false;
|
|
11367
11413
|
const cachedUrl = realtimeContext.getMockupUrl(result.mockupId);
|
|
11368
11414
|
if (!cachedUrl) return;
|
|
@@ -11414,7 +11460,11 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11414
11460
|
const frameErrorRef = (0, import_react48.useRef)(null);
|
|
11415
11461
|
const showVersionOf = (0, import_react48.useCallback)((url) => {
|
|
11416
11462
|
const e = versionByUrlRef.current.get(url);
|
|
11417
|
-
if (!e
|
|
11463
|
+
if (!e) {
|
|
11464
|
+
renderVersionRef.current = 0;
|
|
11465
|
+
renderVersionsRef.current = null;
|
|
11466
|
+
return;
|
|
11467
|
+
}
|
|
11418
11468
|
renderVersionRef.current = e.v;
|
|
11419
11469
|
renderVersionsRef.current = e.versions;
|
|
11420
11470
|
frameErrorRef.current = null;
|
|
@@ -11558,8 +11608,11 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11558
11608
|
lastUrlRef.current = null;
|
|
11559
11609
|
prevArtworkSrcRef.current = currentSrc;
|
|
11560
11610
|
onLoadCalledRef.current = false;
|
|
11561
|
-
|
|
11562
|
-
|
|
11611
|
+
if (artSeenRef.current) {
|
|
11612
|
+
hasReceivedRealtimeRef.current = false;
|
|
11613
|
+
realtimeArtworkSrcRef.current = void 0;
|
|
11614
|
+
}
|
|
11615
|
+
artSeenRef.current = true;
|
|
11563
11616
|
}
|
|
11564
11617
|
}, [artworkSrc, selectedArtworkSrc, placementArtKey]);
|
|
11565
11618
|
const contextSelectionRef = (0, import_react48.useRef)(context?.selection);
|
|
@@ -11714,8 +11767,9 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11714
11767
|
const topLayer = layers[layers.length - 1];
|
|
11715
11768
|
const displayUrl = topLayer?.url || realtimeUrl || initialStaticUrl;
|
|
11716
11769
|
const CROSSFADE_MS = 400;
|
|
11717
|
-
const [
|
|
11718
|
-
const
|
|
11770
|
+
const [incoming, setIncoming] = (0, import_react48.useState)(null);
|
|
11771
|
+
const incomingRef = (0, import_react48.useRef)(incoming);
|
|
11772
|
+
incomingRef.current = incoming;
|
|
11719
11773
|
const [renderedUrl, setRenderedUrl] = (0, import_react48.useState)(displayUrl);
|
|
11720
11774
|
const renderedUrlRef = (0, import_react48.useRef)(renderedUrl);
|
|
11721
11775
|
renderedUrlRef.current = renderedUrl;
|
|
@@ -11747,32 +11801,35 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11747
11801
|
setRenderedUrl(displayUrl);
|
|
11748
11802
|
return;
|
|
11749
11803
|
}
|
|
11750
|
-
const
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
requestAnimationFrame(() => setShowNew(true));
|
|
11759
|
-
});
|
|
11760
|
-
};
|
|
11761
|
-
if (preload.complete) startCrossfade();
|
|
11762
|
-
else preload.onload = startCrossfade;
|
|
11763
|
-
preload.onerror = () => {
|
|
11764
|
-
frameErrorRef.current = "E_FRAME_UNAVAILABLE";
|
|
11765
|
-
frameFailedRef.current?.(displayUrl);
|
|
11766
|
-
applyRenderStampRef.current?.();
|
|
11767
|
-
};
|
|
11768
|
-
return () => {
|
|
11769
|
-
preload.onload = null;
|
|
11770
|
-
preload.onerror = null;
|
|
11771
|
-
};
|
|
11804
|
+
const skipped = incomingRef.current;
|
|
11805
|
+
if (displayUrl === renderedUrlRef.current) {
|
|
11806
|
+
if (skipped && !skipped.ready) frameFailedRef.current?.(skipped.url);
|
|
11807
|
+
setIncoming(null);
|
|
11808
|
+
return;
|
|
11809
|
+
}
|
|
11810
|
+
if (skipped && !skipped.ready && skipped.url !== displayUrl) frameFailedRef.current?.(skipped.url);
|
|
11811
|
+
setIncoming({ url: displayUrl, kind: pictureSwapOf(renderedUrlRef.current, displayUrl), ready: false });
|
|
11772
11812
|
}, [displayUrl]);
|
|
11773
|
-
const
|
|
11774
|
-
|
|
11775
|
-
|
|
11813
|
+
const onIncomingError = (0, import_react48.useCallback)((url) => {
|
|
11814
|
+
if (incomingRef.current?.url !== url) return;
|
|
11815
|
+
frameErrorRef.current = "E_FRAME_UNAVAILABLE";
|
|
11816
|
+
frameFailedRef.current?.(url);
|
|
11817
|
+
applyRenderStampRef.current?.();
|
|
11818
|
+
setIncoming(null);
|
|
11819
|
+
}, []);
|
|
11820
|
+
const onIncomingLoad = (0, import_react48.useCallback)((el, url) => {
|
|
11821
|
+
(typeof el.decode === "function" ? decodedPicture(el) : Promise.resolve()).then(
|
|
11822
|
+
() => {
|
|
11823
|
+
const cur = incomingRef.current;
|
|
11824
|
+
if (!cur || cur.url !== url) return;
|
|
11825
|
+
setIncoming({ ...cur, ready: true });
|
|
11826
|
+
if (cur.kind === "instant") setRenderedUrl(url);
|
|
11827
|
+
},
|
|
11828
|
+
() => onIncomingError(url)
|
|
11829
|
+
);
|
|
11830
|
+
}, [onIncomingError]);
|
|
11831
|
+
const onIncomingShown = (0, import_react48.useCallback)((url) => {
|
|
11832
|
+
if (incomingRef.current?.url === url) setRenderedUrl(url);
|
|
11776
11833
|
}, []);
|
|
11777
11834
|
const handleLoaderExited = (0, import_react48.useCallback)(() => setLoaderMounted(false), []);
|
|
11778
11835
|
if (!hasArtwork) {
|
|
@@ -11831,6 +11888,7 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11831
11888
|
"data-picture-failed-src": failedSrc,
|
|
11832
11889
|
"data-mockup-unavailable": unavailable ? unavailable.code : void 0,
|
|
11833
11890
|
"data-design-refused": designRefused ?? void 0,
|
|
11891
|
+
"data-hero-incoming": incoming ? incoming.ready ? "showing" : "loading" : void 0,
|
|
11834
11892
|
children: [
|
|
11835
11893
|
unavailable && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11836
11894
|
"div",
|
|
@@ -11867,6 +11925,7 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11867
11925
|
}
|
|
11868
11926
|
onUrlGeneratedRef.current?.(renderedUrl);
|
|
11869
11927
|
if (renderedUrl) onShownRef.current?.(renderedUrl);
|
|
11928
|
+
if (renderedUrl && incomingRef.current?.url === renderedUrl) setIncoming(null);
|
|
11870
11929
|
},
|
|
11871
11930
|
onError: () => {
|
|
11872
11931
|
if (renderedUrl && retriedUrlRef.current !== renderedUrl) {
|
|
@@ -11911,7 +11970,7 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11911
11970
|
},
|
|
11912
11971
|
retryNonce
|
|
11913
11972
|
),
|
|
11914
|
-
imgFailed && !
|
|
11973
|
+
imgFailed && !incoming?.ready && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "absolute inset-0 flex items-center justify-center bg-muted", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "text-muted-foreground text-xs", children: unavailableText }) }),
|
|
11915
11974
|
realtimeContext?.renderError && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11916
11975
|
"div",
|
|
11917
11976
|
{
|
|
@@ -11922,20 +11981,26 @@ var HeroProductImage = (0, import_react48.memo)(function HeroProductImage2({
|
|
|
11922
11981
|
children: realtimeContext.renderError.retryable ? realtimeContext.renderError.message : `Render blocked: ${realtimeContext.renderError.code} \u2014 ${realtimeContext.renderError.message}`
|
|
11923
11982
|
}
|
|
11924
11983
|
),
|
|
11925
|
-
|
|
11984
|
+
incoming && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11926
11985
|
"img",
|
|
11927
11986
|
{
|
|
11928
11987
|
alt: "",
|
|
11988
|
+
"aria-hidden": true,
|
|
11929
11989
|
crossOrigin: "anonymous",
|
|
11930
11990
|
className: `absolute inset-0 w-full h-full ${fit === "whole" ? "object-contain" : "object-cover"}`,
|
|
11931
|
-
src:
|
|
11991
|
+
src: incoming.url,
|
|
11992
|
+
loading: "eager",
|
|
11993
|
+
decoding: "async",
|
|
11932
11994
|
style: {
|
|
11933
|
-
opacity:
|
|
11934
|
-
transition: `opacity ${CROSSFADE_MS}ms ease-in-out
|
|
11995
|
+
opacity: incoming.ready ? 1 : 0,
|
|
11996
|
+
transition: incoming.kind === "crossfade" ? `opacity ${CROSSFADE_MS}ms ease-in-out` : void 0,
|
|
11935
11997
|
pointerEvents: "none"
|
|
11936
11998
|
},
|
|
11937
|
-
|
|
11938
|
-
|
|
11999
|
+
onLoad: (e) => onIncomingLoad(e.currentTarget, incoming.url),
|
|
12000
|
+
onError: () => onIncomingError(incoming.url),
|
|
12001
|
+
onTransitionEnd: () => onIncomingShown(incoming.url)
|
|
12002
|
+
},
|
|
12003
|
+
incoming.url
|
|
11939
12004
|
),
|
|
11940
12005
|
loaderMounted && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
11941
12006
|
LoadingOverlayPrismCandyInline,
|
|
@@ -17168,6 +17233,7 @@ function createBridgeFromCanvas(canvasModule) {
|
|
|
17168
17233
|
}) });
|
|
17169
17234
|
};
|
|
17170
17235
|
}
|
|
17236
|
+
var PERSONALIZATION_EXPORT_DEBOUNCE_MS = 250;
|
|
17171
17237
|
var cachedCanvasComponent = null;
|
|
17172
17238
|
var cachedBridgeComponent = null;
|
|
17173
17239
|
var cachedSerialize = null;
|
|
@@ -17226,10 +17292,30 @@ function PersonalizationProvider({
|
|
|
17226
17292
|
}
|
|
17227
17293
|
};
|
|
17228
17294
|
}, []);
|
|
17295
|
+
const canvasRef = (0, import_react71.useRef)(null);
|
|
17296
|
+
const lastChangeAtRef = (0, import_react71.useRef)(0);
|
|
17297
|
+
const lastExportAtRef = (0, import_react71.useRef)(0);
|
|
17229
17298
|
const updateField = (0, import_react71.useCallback)((key, value) => {
|
|
17230
17299
|
setIsActive(true);
|
|
17300
|
+
lastChangeAtRef.current = Date.now();
|
|
17231
17301
|
setPersonValues((prev) => ({ ...prev, [key]: value }));
|
|
17232
17302
|
}, []);
|
|
17303
|
+
const settleMs = (exportConfig?.debounceMs ?? PERSONALIZATION_EXPORT_DEBOUNCE_MS) + (exportConfig?.maxWaitMs ?? 1e3) + 300;
|
|
17304
|
+
(0, import_react71.useEffect)(() => {
|
|
17305
|
+
if (!isActive || lastChangeAtRef.current === 0) return;
|
|
17306
|
+
const changedAt = lastChangeAtRef.current;
|
|
17307
|
+
const timer = setTimeout(() => {
|
|
17308
|
+
if (lastExportAtRef.current >= changedAt) return;
|
|
17309
|
+
const exportArtboards = canvasRef.current?.exportArtboards;
|
|
17310
|
+
if (!exportArtboards) return;
|
|
17311
|
+
void exportArtboards({ format: "blob", scale: exportConfig?.scale ?? 1, all: false }).then((exports2) => {
|
|
17312
|
+
if (lastChangeAtRef.current !== changedAt || lastExportAtRef.current >= changedAt) return;
|
|
17313
|
+
if (exports2 && Object.keys(exports2).length > 0) handleExportRef.current?.(exports2);
|
|
17314
|
+
}).catch(() => {
|
|
17315
|
+
});
|
|
17316
|
+
}, settleMs);
|
|
17317
|
+
return () => clearTimeout(timer);
|
|
17318
|
+
}, [personValues, isActive, settleMs, exportConfig?.scale]);
|
|
17233
17319
|
const reset = (0, import_react71.useCallback)(() => {
|
|
17234
17320
|
setPersonValues({});
|
|
17235
17321
|
setIsActive(false);
|
|
@@ -17237,6 +17323,7 @@ function PersonalizationProvider({
|
|
|
17237
17323
|
}, []);
|
|
17238
17324
|
const handleExport = (0, import_react71.useCallback)(
|
|
17239
17325
|
(exports2) => {
|
|
17326
|
+
lastExportAtRef.current = Date.now();
|
|
17240
17327
|
const newUrls = {};
|
|
17241
17328
|
for (const [name, data] of Object.entries(exports2)) {
|
|
17242
17329
|
if (blobUrlsRef.current[name]) {
|
|
@@ -17269,6 +17356,10 @@ function PersonalizationProvider({
|
|
|
17269
17356
|
},
|
|
17270
17357
|
[realtime, placementOverride]
|
|
17271
17358
|
);
|
|
17359
|
+
const handleExportRef = (0, import_react71.useRef)(null);
|
|
17360
|
+
(0, import_react71.useEffect)(() => {
|
|
17361
|
+
handleExportRef.current = handleExport;
|
|
17362
|
+
}, [handleExport]);
|
|
17272
17363
|
const handleExportScheduled = (0, import_react71.useCallback)(() => {
|
|
17273
17364
|
setIsExporting(true);
|
|
17274
17365
|
}, []);
|
|
@@ -17303,13 +17394,16 @@ function PersonalizationProvider({
|
|
|
17303
17394
|
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17304
17395
|
CanvasComponent,
|
|
17305
17396
|
{
|
|
17397
|
+
ref: canvasRef,
|
|
17306
17398
|
initialElements: canvasState?.elements,
|
|
17307
17399
|
artboards: canvasState?.artboards,
|
|
17308
17400
|
kit: "embed-only",
|
|
17309
17401
|
inheritTheme: true,
|
|
17310
17402
|
autoExportConfig: {
|
|
17311
17403
|
enabled: true,
|
|
17312
|
-
|
|
17404
|
+
// Typing cadence (~100-200 ms a key): one render per pause, not one per key (each render is a new picture
|
|
17405
|
+
// on every mockup); maxWaitMs still shows progress during a long burst.
|
|
17406
|
+
debounceMs: exportConfig?.debounceMs ?? PERSONALIZATION_EXPORT_DEBOUNCE_MS,
|
|
17313
17407
|
maxWaitMs: exportConfig?.maxWaitMs ?? 1e3
|
|
17314
17408
|
},
|
|
17315
17409
|
autoExportFormat: "blob",
|
|
@@ -17710,6 +17804,7 @@ function usePersonalizationShimmer(containerRef, safetyTimeoutMs = 1e4) {
|
|
|
17710
17804
|
checkTailwindConfig,
|
|
17711
17805
|
checkThemeTokens,
|
|
17712
17806
|
createScrollDirectionTracker,
|
|
17807
|
+
decodedPicture,
|
|
17713
17808
|
describeProductArtAlignment,
|
|
17714
17809
|
firstView,
|
|
17715
17810
|
firstViewAnchorOfSlide,
|
|
@@ -17736,6 +17831,7 @@ function usePersonalizationShimmer(containerRef, safetyTimeoutMs = 1e4) {
|
|
|
17736
17831
|
normalizeHex,
|
|
17737
17832
|
observe,
|
|
17738
17833
|
pictureRenderState,
|
|
17834
|
+
pictureSwapOf,
|
|
17739
17835
|
placementArtFor,
|
|
17740
17836
|
runConfigChecks,
|
|
17741
17837
|
scrollInputAboveKeyboard,
|