@snowcone-app/ui 0.9.7 → 0.9.8
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 +13 -0
- package/dist/index.cjs +40 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +40 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/composed/HeroProductImage.tsx +11 -1
- package/src/patterns/RealtimeProvider.tsx +52 -12
- package/src/patterns/__tests__/RealtimeProvider.blobLifecycle.test.tsx +57 -0
- package/src/patterns/__tests__/RealtimeProvider.cropDelivery.test.tsx +27 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4403](https://github.com/snowcone-app/snowcone-monorepo/pull/4403) [`9214d20`](https://github.com/snowcone-app/snowcone-monorepo/commit/9214d20624e19ffbb9e2cb9ac4965d9466d06fee) Thanks [@kevinsproles](https://github.com/kevinsproles)! - A composited frame is released only when EVERY element showing that picture has moved past it (`markBlobShown(mockupId, url, consumer)`, `releaseBlobConsumer` on unmount). The phone product page renders each picture twice; releasing on the first element's load revoked the frame its twin was still loading, so the twin kept its old image.
|
|
8
|
+
|
|
9
|
+
- [#4415](https://github.com/snowcone-app/snowcone-monorepo/pull/4415) [`ccc4cf3`](https://github.com/snowcone-app/snowcone-monorepo/commit/ccc4cf371c5f4845e679b8c295e0335881664e96) Thanks [@kevinsproles](https://github.com/kevinsproles)! - The SDK reports `isFrameSuperseded(url)`: true once a newer ws frame for the same mockup has arrived and the old one was revoked. The UI uses it when a cropped frame fails to load: a superseded frame is dropped at once instead of waiting on the 2 s grace, which a 31-picture batch can outlast (React only sees the newer frame with the batch's `all_mockups_rendered`). Before, the grace fired first, cropped delivery went off for the session and a visible picture could stay one version behind.
|
|
10
|
+
|
|
11
|
+
`all_mockups_rendered` now merges its batch into `mockupResults` instead of replacing it. A short batch (a `rerender` answer) landing right after a full one replaced it, React coalesced the two updates, and every other picture kept its previous version.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`ccc4cf3`](https://github.com/snowcone-app/snowcone-monorepo/commit/ccc4cf371c5f4845e679b8c295e0335881664e96)]:
|
|
14
|
+
- @snowcone-app/sdk@0.26.0
|
|
15
|
+
|
|
3
16
|
## 0.9.7
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -6181,8 +6181,11 @@ function RealtimeProvider({
|
|
|
6181
6181
|
hasPendingBlobs,
|
|
6182
6182
|
getLastSentVersion,
|
|
6183
6183
|
getLatestSentVersions,
|
|
6184
|
-
rerender: rerenderRaw
|
|
6184
|
+
rerender: rerenderRaw,
|
|
6185
|
+
isFrameSuperseded
|
|
6185
6186
|
} = realtimeMockup;
|
|
6187
|
+
const isFrameSupersededRef = (0, import_react25.useRef)(isFrameSuperseded);
|
|
6188
|
+
isFrameSupersededRef.current = isFrameSuperseded;
|
|
6186
6189
|
const mockupResultsRef = (0, import_react25.useRef)([]);
|
|
6187
6190
|
const mockupSubscribersRef = (0, import_react25.useRef)(
|
|
6188
6191
|
/* @__PURE__ */ new Set()
|
|
@@ -6248,9 +6251,9 @@ function RealtimeProvider({
|
|
|
6248
6251
|
const url = URL.createObjectURL(blobOrUrl);
|
|
6249
6252
|
if (owner) {
|
|
6250
6253
|
const list = [url, ...blobsByOwnerRef.current.get(owner) ?? []];
|
|
6251
|
-
const shown = shownBlobByOwnerRef.current.get(owner);
|
|
6254
|
+
const shown = new Set(shownBlobByOwnerRef.current.get(owner)?.values() ?? []);
|
|
6252
6255
|
while (list.length > MAX_FRAMES_PER_PICTURE) {
|
|
6253
|
-
const victimIdx = [...list.keys()].reverse().find((i) => i > 0 && list[i]
|
|
6256
|
+
const victimIdx = [...list.keys()].reverse().find((i) => i > 0 && !shown.has(list[i]));
|
|
6254
6257
|
if (victimIdx === void 0) break;
|
|
6255
6258
|
const [victim] = list.splice(victimIdx, 1);
|
|
6256
6259
|
console.error(
|
|
@@ -6268,15 +6271,28 @@ function RealtimeProvider({
|
|
|
6268
6271
|
registeredBlobUrlsRef.current.add(url);
|
|
6269
6272
|
return url;
|
|
6270
6273
|
}, [revokeBlobUrl]);
|
|
6271
|
-
const
|
|
6274
|
+
const releaseOlderFrames = (0, import_react25.useCallback)((owner) => {
|
|
6272
6275
|
const list = blobsByOwnerRef.current.get(owner);
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
list.slice(
|
|
6278
|
-
blobsByOwnerRef.current.set(owner, list.slice(0,
|
|
6276
|
+
const shown = shownBlobByOwnerRef.current.get(owner);
|
|
6277
|
+
if (!list || !shown || shown.size === 0) return;
|
|
6278
|
+
const oldestShownIdx = Math.max(...[...shown.values()].map((u) => list.indexOf(u)));
|
|
6279
|
+
if (oldestShownIdx < 0) return;
|
|
6280
|
+
list.slice(oldestShownIdx + 1).forEach(revokeBlobUrl);
|
|
6281
|
+
blobsByOwnerRef.current.set(owner, list.slice(0, oldestShownIdx + 1));
|
|
6279
6282
|
}, [revokeBlobUrl]);
|
|
6283
|
+
const markBlobShown = (0, import_react25.useCallback)((owner, url, consumer = "default") => {
|
|
6284
|
+
const list = blobsByOwnerRef.current.get(owner);
|
|
6285
|
+
if (!list || list.indexOf(url) < 0) return;
|
|
6286
|
+
const shown = shownBlobByOwnerRef.current.get(owner) ?? /* @__PURE__ */ new Map();
|
|
6287
|
+
shown.set(consumer, url);
|
|
6288
|
+
shownBlobByOwnerRef.current.set(owner, shown);
|
|
6289
|
+
releaseOlderFrames(owner);
|
|
6290
|
+
}, [releaseOlderFrames]);
|
|
6291
|
+
const releaseBlobConsumer = (0, import_react25.useCallback)((owner, consumer) => {
|
|
6292
|
+
const shown = shownBlobByOwnerRef.current.get(owner);
|
|
6293
|
+
if (!shown?.delete(consumer)) return;
|
|
6294
|
+
releaseOlderFrames(owner);
|
|
6295
|
+
}, [releaseOlderFrames]);
|
|
6280
6296
|
const croppedDeliveryEnabled = delivery !== "full-frame";
|
|
6281
6297
|
const sendCropConfig = (0, import_react25.useCallback)(
|
|
6282
6298
|
(withCrop) => {
|
|
@@ -6500,6 +6516,7 @@ function RealtimeProvider({
|
|
|
6500
6516
|
if (gen !== sceneGenRef.current || compositeQueueRef.current.has(result.mockupId) || processedFrameRef.current.get(result.mockupId) !== result.imageUrl) {
|
|
6501
6517
|
return;
|
|
6502
6518
|
}
|
|
6519
|
+
if (isFrameSupersededRef.current?.(result.imageUrl)) return;
|
|
6503
6520
|
const message = err instanceof Error ? err.message : String(err);
|
|
6504
6521
|
if (result.imageUrl.startsWith("blob:") && message.startsWith("E_OVERLAY_FRAME_LOAD") && message.includes(result.imageUrl.slice(0, 160))) {
|
|
6505
6522
|
const failedUrl = result.imageUrl;
|
|
@@ -7091,6 +7108,7 @@ function RealtimeProvider({
|
|
|
7091
7108
|
isMockupLoading,
|
|
7092
7109
|
registerBlobUrl,
|
|
7093
7110
|
markBlobShown,
|
|
7111
|
+
releaseBlobConsumer,
|
|
7094
7112
|
// WebRTC streaming
|
|
7095
7113
|
subscribeRTCTiming
|
|
7096
7114
|
}),
|
|
@@ -7124,7 +7142,8 @@ function RealtimeProvider({
|
|
|
7124
7142
|
getLatestSentVersionsStable,
|
|
7125
7143
|
isMockupLoading,
|
|
7126
7144
|
registerBlobUrl,
|
|
7127
|
-
markBlobShown
|
|
7145
|
+
markBlobShown,
|
|
7146
|
+
releaseBlobConsumer
|
|
7128
7147
|
]
|
|
7129
7148
|
);
|
|
7130
7149
|
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(RealtimeContext.Provider, { value: contextValue, children });
|
|
@@ -10880,6 +10899,15 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
|
|
|
10880
10899
|
const arrivedVersionRef = (0, import_react46.useRef)(0);
|
|
10881
10900
|
const versionByUrlRef = (0, import_react46.useRef)(/* @__PURE__ */ new Map());
|
|
10882
10901
|
const loadedUrlRef = (0, import_react46.useRef)(null);
|
|
10902
|
+
const blobConsumerRef = (0, import_react46.useRef)(`el-${Math.random().toString(36).slice(2, 10)}`);
|
|
10903
|
+
const releaseBlobConsumer = realtimeContext?.releaseBlobConsumer;
|
|
10904
|
+
(0, import_react46.useEffect)(() => {
|
|
10905
|
+
const id = actualMockupId;
|
|
10906
|
+
const consumer = blobConsumerRef.current;
|
|
10907
|
+
return () => {
|
|
10908
|
+
if (id) releaseBlobConsumer?.(id, consumer);
|
|
10909
|
+
};
|
|
10910
|
+
}, [actualMockupId, releaseBlobConsumer]);
|
|
10883
10911
|
const frameErrorRef = (0, import_react46.useRef)(null);
|
|
10884
10912
|
const showVersionOf = (0, import_react46.useCallback)((url) => {
|
|
10885
10913
|
const e = versionByUrlRef.current.get(url);
|
|
@@ -11249,7 +11277,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
|
|
|
11249
11277
|
if (renderedUrl) {
|
|
11250
11278
|
loadedUrlRef.current = renderedUrl;
|
|
11251
11279
|
showVersionOf(renderedUrl);
|
|
11252
|
-
if (actualMockupId) realtimeContext?.markBlobShown?.(actualMockupId, renderedUrl);
|
|
11280
|
+
if (actualMockupId) realtimeContext?.markBlobShown?.(actualMockupId, renderedUrl, blobConsumerRef.current);
|
|
11253
11281
|
applyRenderStampRef.current?.();
|
|
11254
11282
|
}
|
|
11255
11283
|
if (!onLoadCalledRef.current && onLoad) {
|