@snowcone-app/ui 0.10.18 → 0.10.21
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 +23 -0
- package/dist/index.cjs +38 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +38 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/patterns/RealtimeProvider.tsx +63 -2
- package/src/patterns/__tests__/RealtimeProvider.views.test.tsx +90 -0
- package/src/patterns/__tests__/croppedFrameComposite.test.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`23dee39`](https://github.com/snowcone-app/snowcone-monorepo/commit/23dee39f7dbc3d2f922ac8dd308f8ec93facc94c)]:
|
|
8
|
+
- @snowcone-app/sdk@0.31.5
|
|
9
|
+
|
|
10
|
+
## 0.10.20
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`cec468f`](https://github.com/snowcone-app/snowcone-monorepo/commit/cec468fc5799297a192a5183edbf1a6b460c6d56)]:
|
|
15
|
+
- @snowcone-app/sdk@0.31.4
|
|
16
|
+
|
|
17
|
+
## 0.10.19
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#5682](https://github.com/snowcone-app/snowcone-monorepo/pull/5682) [`5fda4b9`](https://github.com/snowcone-app/snowcone-monorepo/commit/5fda4b9c7fbb226c1bd61024cf01c38ac31bddeb) Thanks [@kevinsproles](https://github.com/kevinsproles)! - The editor's live preview is cropped like the product page's hero. SDK: the realtime config takes `views: { <mockupId>: MockupView }` (that mockup's live frame is `aspect=8:3&view=<v>`, the hero's crop); `sendConfig` sends only the views of the config's own `mockupIds` and throws before sending what the box refuses (`E_VIEW_PARAM_INVALID` off the grid, `E_REALTIME_VIEWS_WITH_CROP_RECT` beside an overlayCrop rect); `sessionViews` is exported. UI: `RealtimeProvider` gets `setMockupViews(views)` (carried on every config it sends; a change re-sends the config and re-seeds the cropped-delivery backgrounds) and `frameViewOf(url)` (which crop a frame it handed out is).
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`5fda4b9`](https://github.com/snowcone-app/snowcone-monorepo/commit/5fda4b9c7fbb226c1bd61024cf01c38ac31bddeb)]:
|
|
24
|
+
- @snowcone-app/sdk@0.31.3
|
|
25
|
+
|
|
3
26
|
## 0.10.18
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -6226,7 +6226,7 @@ function RealtimeProvider({
|
|
|
6226
6226
|
sendCanvasBlob: sendCanvasBlobRaw,
|
|
6227
6227
|
sendCanvasState: sendCanvasStateRaw,
|
|
6228
6228
|
sendColorBlob,
|
|
6229
|
-
sendConfig:
|
|
6229
|
+
sendConfig: sendConfigHook,
|
|
6230
6230
|
updateMockupIds: updateMockupIdsRaw,
|
|
6231
6231
|
updatePlacementSettings: updatePlacementSettingsRaw,
|
|
6232
6232
|
connect,
|
|
@@ -6239,6 +6239,18 @@ function RealtimeProvider({
|
|
|
6239
6239
|
isFrameSuperseded,
|
|
6240
6240
|
ackFrame
|
|
6241
6241
|
} = realtimeMockup;
|
|
6242
|
+
const viewsRef = (0, import_react25.useRef)({});
|
|
6243
|
+
const sentViewsRef = (0, import_react25.useRef)({});
|
|
6244
|
+
const frameViewsRef = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
|
|
6245
|
+
const sendConfigRaw = (0, import_react25.useCallback)(
|
|
6246
|
+
(config) => {
|
|
6247
|
+
const views = viewsRef.current;
|
|
6248
|
+
const withViews = Object.keys(views).length > 0 ? { ...config, views: { ...views } } : config;
|
|
6249
|
+
sentViewsRef.current = withViews.views ?? {};
|
|
6250
|
+
return sendConfigHook(withViews);
|
|
6251
|
+
},
|
|
6252
|
+
[sendConfigHook]
|
|
6253
|
+
);
|
|
6242
6254
|
const isFrameSupersededRef = (0, import_react25.useRef)(isFrameSuperseded);
|
|
6243
6255
|
isFrameSupersededRef.current = isFrameSuperseded;
|
|
6244
6256
|
const mockupResultsRef = (0, import_react25.useRef)([]);
|
|
@@ -6497,6 +6509,23 @@ function RealtimeProvider({
|
|
|
6497
6509
|
compositeQueueRef.current.clear();
|
|
6498
6510
|
croppedActiveRef.current = false;
|
|
6499
6511
|
}, []);
|
|
6512
|
+
const setMockupViews = (0, import_react25.useCallback)(
|
|
6513
|
+
(views) => {
|
|
6514
|
+
const key = (v) => JSON.stringify(Object.keys(v).sort().map((k) => [k, v[k]]));
|
|
6515
|
+
if (key(views) === key(viewsRef.current)) return;
|
|
6516
|
+
viewsRef.current = { ...views };
|
|
6517
|
+
const base = lastConfigBaseRef.current;
|
|
6518
|
+
if (!base || !configSentRef.current) return;
|
|
6519
|
+
invalidateBackgrounds();
|
|
6520
|
+
requestedMockupIdsRef.current = base.mockupIds ?? [];
|
|
6521
|
+
sendConfigRaw({
|
|
6522
|
+
...base,
|
|
6523
|
+
placementSettings: { ...placementSettingsOverridesRef.current }
|
|
6524
|
+
});
|
|
6525
|
+
},
|
|
6526
|
+
[invalidateBackgrounds, sendConfigRaw]
|
|
6527
|
+
);
|
|
6528
|
+
const frameViewOf = (0, import_react25.useCallback)((url) => frameViewsRef.current.get(url), []);
|
|
6500
6529
|
const currentShape = (0, import_react25.useCallback)(
|
|
6501
6530
|
() => sessionShape({
|
|
6502
6531
|
allMockupIds: configuredMockupIdsRef.current,
|
|
@@ -6583,6 +6612,10 @@ function RealtimeProvider({
|
|
|
6583
6612
|
const watched = (mockupSubscribersByIdRef.current.get(result.mockupId)?.size ?? 0) > 0;
|
|
6584
6613
|
if (!watched || shownUrl === result.imageUrl) ackFrameRef.current?.(result.mockupId, seq);
|
|
6585
6614
|
});
|
|
6615
|
+
results.forEach((result) => {
|
|
6616
|
+
frameViewsRef.current.set(result.imageUrl, sentViewsRef.current[result.mockupId] ?? null);
|
|
6617
|
+
if (frameViewsRef.current.size > 512) frameViewsRef.current.delete(frameViewsRef.current.keys().next().value);
|
|
6618
|
+
});
|
|
6586
6619
|
const clearedPlacements = /* @__PURE__ */ new Set();
|
|
6587
6620
|
results.forEach((result) => {
|
|
6588
6621
|
const wasPending = pendingMockupIdsRef.current.has(result.mockupId);
|
|
@@ -7318,6 +7351,8 @@ function RealtimeProvider({
|
|
|
7318
7351
|
reportPictureView,
|
|
7319
7352
|
getSessionShape,
|
|
7320
7353
|
setEditorOpen: setEditorOpenState,
|
|
7354
|
+
setMockupViews,
|
|
7355
|
+
frameViewOf,
|
|
7321
7356
|
isMockupLoading,
|
|
7322
7357
|
registerBlobUrl,
|
|
7323
7358
|
markBlobShown,
|
|
@@ -7356,6 +7391,8 @@ function RealtimeProvider({
|
|
|
7356
7391
|
getLatestSentVersionsStable,
|
|
7357
7392
|
reportPictureView,
|
|
7358
7393
|
getSessionShape,
|
|
7394
|
+
setMockupViews,
|
|
7395
|
+
frameViewOf,
|
|
7359
7396
|
isMockupLoading,
|
|
7360
7397
|
registerBlobUrl,
|
|
7361
7398
|
markBlobShown,
|