@snowcone-app/ui 0.10.18 → 0.10.20
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 +16 -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/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import * as React$1 from 'react';
|
|
|
5
5
|
import React__default, { ReactNode, CSSProperties, RefObject } from 'react';
|
|
6
6
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
7
7
|
import { VariantProps } from 'class-variance-authority';
|
|
8
|
-
import { ProductPriceOptions, CatalogProduct, ImageAlignment, OptionSelection, ProductContext as ProductContext$1, WebSocketConfig, DesignElement, RealtimeRenderError, ProductArtAlignmentOptions, ProductArtAlignmentContext,
|
|
8
|
+
import { ProductPriceOptions, CatalogProduct, ImageAlignment, OptionSelection, ProductContext as ProductContext$1, WebSocketConfig, DesignElement, RealtimeRenderError, MockupView, ProductArtAlignmentOptions, ProductArtAlignmentContext, ArtworkData } from '@snowcone-app/sdk';
|
|
9
9
|
export { ArtworkData, AspectRatio, ImageAlignment, ProductArtAlignmentContext, ProductArtAlignmentOptions, ProductData, ProductMockupData, ProductPlacement, ProductVariant, WebSocketConfig, describeProductArtAlignment, getMockupUrl, getProduct, getSnapPoints, listProducts } from '@snowcone-app/sdk';
|
|
10
10
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
11
11
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
@@ -3091,6 +3091,17 @@ interface RealtimeContextValue {
|
|
|
3091
3091
|
} | null;
|
|
3092
3092
|
/** The design editor opened or closed (Done). Drives the viewport policy's phase; see `editorOpen`. */
|
|
3093
3093
|
setEditorOpen: (open: boolean) => void;
|
|
3094
|
+
/**
|
|
3095
|
+
* The crop of each plate's 8:3 strip the page's hero shows (`view=<r>@<f>`, lane shapes #5520): those mockups' live
|
|
3096
|
+
* frames come as the same crop (rendercenter rc#898), so an edit drops into the hero's box. Re-sent on every config;
|
|
3097
|
+
* a change re-sends the config and re-seeds the cropped-delivery backgrounds (they are the old crop). `{}` = none.
|
|
3098
|
+
*/
|
|
3099
|
+
setMockupViews: (views: Readonly<Record<string, MockupView>>) => void;
|
|
3100
|
+
/**
|
|
3101
|
+
* What a frame URL this provider handed out is: the view it was rendered as, `null` for a full 16:9 frame, `undefined`
|
|
3102
|
+
* for a URL it did not hand out (a static picture).
|
|
3103
|
+
*/
|
|
3104
|
+
frameViewOf: (url: string) => MockupView | null | undefined;
|
|
3094
3105
|
flushPendingBlobs: () => void;
|
|
3095
3106
|
hasPendingBlobs: () => boolean;
|
|
3096
3107
|
subscribePipelineSettled: (callback: () => void) => () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as React$1 from 'react';
|
|
|
5
5
|
import React__default, { ReactNode, CSSProperties, RefObject } from 'react';
|
|
6
6
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
7
7
|
import { VariantProps } from 'class-variance-authority';
|
|
8
|
-
import { ProductPriceOptions, CatalogProduct, ImageAlignment, OptionSelection, ProductContext as ProductContext$1, WebSocketConfig, DesignElement, RealtimeRenderError, ProductArtAlignmentOptions, ProductArtAlignmentContext,
|
|
8
|
+
import { ProductPriceOptions, CatalogProduct, ImageAlignment, OptionSelection, ProductContext as ProductContext$1, WebSocketConfig, DesignElement, RealtimeRenderError, MockupView, ProductArtAlignmentOptions, ProductArtAlignmentContext, ArtworkData } from '@snowcone-app/sdk';
|
|
9
9
|
export { ArtworkData, AspectRatio, ImageAlignment, ProductArtAlignmentContext, ProductArtAlignmentOptions, ProductData, ProductMockupData, ProductPlacement, ProductVariant, WebSocketConfig, describeProductArtAlignment, getMockupUrl, getProduct, getSnapPoints, listProducts } from '@snowcone-app/sdk';
|
|
10
10
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
11
11
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
@@ -3091,6 +3091,17 @@ interface RealtimeContextValue {
|
|
|
3091
3091
|
} | null;
|
|
3092
3092
|
/** The design editor opened or closed (Done). Drives the viewport policy's phase; see `editorOpen`. */
|
|
3093
3093
|
setEditorOpen: (open: boolean) => void;
|
|
3094
|
+
/**
|
|
3095
|
+
* The crop of each plate's 8:3 strip the page's hero shows (`view=<r>@<f>`, lane shapes #5520): those mockups' live
|
|
3096
|
+
* frames come as the same crop (rendercenter rc#898), so an edit drops into the hero's box. Re-sent on every config;
|
|
3097
|
+
* a change re-sends the config and re-seeds the cropped-delivery backgrounds (they are the old crop). `{}` = none.
|
|
3098
|
+
*/
|
|
3099
|
+
setMockupViews: (views: Readonly<Record<string, MockupView>>) => void;
|
|
3100
|
+
/**
|
|
3101
|
+
* What a frame URL this provider handed out is: the view it was rendered as, `null` for a full 16:9 frame, `undefined`
|
|
3102
|
+
* for a URL it did not hand out (a static picture).
|
|
3103
|
+
*/
|
|
3104
|
+
frameViewOf: (url: string) => MockupView | null | undefined;
|
|
3094
3105
|
flushPendingBlobs: () => void;
|
|
3095
3106
|
hasPendingBlobs: () => boolean;
|
|
3096
3107
|
subscribePipelineSettled: (callback: () => void) => () => void;
|
package/dist/index.js
CHANGED
|
@@ -5852,7 +5852,7 @@ function RealtimeProvider({
|
|
|
5852
5852
|
sendCanvasBlob: sendCanvasBlobRaw,
|
|
5853
5853
|
sendCanvasState: sendCanvasStateRaw,
|
|
5854
5854
|
sendColorBlob,
|
|
5855
|
-
sendConfig:
|
|
5855
|
+
sendConfig: sendConfigHook,
|
|
5856
5856
|
updateMockupIds: updateMockupIdsRaw,
|
|
5857
5857
|
updatePlacementSettings: updatePlacementSettingsRaw,
|
|
5858
5858
|
connect,
|
|
@@ -5865,6 +5865,18 @@ function RealtimeProvider({
|
|
|
5865
5865
|
isFrameSuperseded,
|
|
5866
5866
|
ackFrame
|
|
5867
5867
|
} = realtimeMockup;
|
|
5868
|
+
const viewsRef = useRef12({});
|
|
5869
|
+
const sentViewsRef = useRef12({});
|
|
5870
|
+
const frameViewsRef = useRef12(/* @__PURE__ */ new Map());
|
|
5871
|
+
const sendConfigRaw = useCallback10(
|
|
5872
|
+
(config) => {
|
|
5873
|
+
const views = viewsRef.current;
|
|
5874
|
+
const withViews = Object.keys(views).length > 0 ? { ...config, views: { ...views } } : config;
|
|
5875
|
+
sentViewsRef.current = withViews.views ?? {};
|
|
5876
|
+
return sendConfigHook(withViews);
|
|
5877
|
+
},
|
|
5878
|
+
[sendConfigHook]
|
|
5879
|
+
);
|
|
5868
5880
|
const isFrameSupersededRef = useRef12(isFrameSuperseded);
|
|
5869
5881
|
isFrameSupersededRef.current = isFrameSuperseded;
|
|
5870
5882
|
const mockupResultsRef = useRef12([]);
|
|
@@ -6123,6 +6135,23 @@ function RealtimeProvider({
|
|
|
6123
6135
|
compositeQueueRef.current.clear();
|
|
6124
6136
|
croppedActiveRef.current = false;
|
|
6125
6137
|
}, []);
|
|
6138
|
+
const setMockupViews = useCallback10(
|
|
6139
|
+
(views) => {
|
|
6140
|
+
const key = (v) => JSON.stringify(Object.keys(v).sort().map((k) => [k, v[k]]));
|
|
6141
|
+
if (key(views) === key(viewsRef.current)) return;
|
|
6142
|
+
viewsRef.current = { ...views };
|
|
6143
|
+
const base = lastConfigBaseRef.current;
|
|
6144
|
+
if (!base || !configSentRef.current) return;
|
|
6145
|
+
invalidateBackgrounds();
|
|
6146
|
+
requestedMockupIdsRef.current = base.mockupIds ?? [];
|
|
6147
|
+
sendConfigRaw({
|
|
6148
|
+
...base,
|
|
6149
|
+
placementSettings: { ...placementSettingsOverridesRef.current }
|
|
6150
|
+
});
|
|
6151
|
+
},
|
|
6152
|
+
[invalidateBackgrounds, sendConfigRaw]
|
|
6153
|
+
);
|
|
6154
|
+
const frameViewOf = useCallback10((url) => frameViewsRef.current.get(url), []);
|
|
6126
6155
|
const currentShape = useCallback10(
|
|
6127
6156
|
() => sessionShape({
|
|
6128
6157
|
allMockupIds: configuredMockupIdsRef.current,
|
|
@@ -6209,6 +6238,10 @@ function RealtimeProvider({
|
|
|
6209
6238
|
const watched = (mockupSubscribersByIdRef.current.get(result.mockupId)?.size ?? 0) > 0;
|
|
6210
6239
|
if (!watched || shownUrl === result.imageUrl) ackFrameRef.current?.(result.mockupId, seq);
|
|
6211
6240
|
});
|
|
6241
|
+
results.forEach((result) => {
|
|
6242
|
+
frameViewsRef.current.set(result.imageUrl, sentViewsRef.current[result.mockupId] ?? null);
|
|
6243
|
+
if (frameViewsRef.current.size > 512) frameViewsRef.current.delete(frameViewsRef.current.keys().next().value);
|
|
6244
|
+
});
|
|
6212
6245
|
const clearedPlacements = /* @__PURE__ */ new Set();
|
|
6213
6246
|
results.forEach((result) => {
|
|
6214
6247
|
const wasPending = pendingMockupIdsRef.current.has(result.mockupId);
|
|
@@ -6944,6 +6977,8 @@ function RealtimeProvider({
|
|
|
6944
6977
|
reportPictureView,
|
|
6945
6978
|
getSessionShape,
|
|
6946
6979
|
setEditorOpen: setEditorOpenState,
|
|
6980
|
+
setMockupViews,
|
|
6981
|
+
frameViewOf,
|
|
6947
6982
|
isMockupLoading,
|
|
6948
6983
|
registerBlobUrl,
|
|
6949
6984
|
markBlobShown,
|
|
@@ -6982,6 +7017,8 @@ function RealtimeProvider({
|
|
|
6982
7017
|
getLatestSentVersionsStable,
|
|
6983
7018
|
reportPictureView,
|
|
6984
7019
|
getSessionShape,
|
|
7020
|
+
setMockupViews,
|
|
7021
|
+
frameViewOf,
|
|
6985
7022
|
isMockupLoading,
|
|
6986
7023
|
registerBlobUrl,
|
|
6987
7024
|
markBlobShown,
|