@snowcone-app/ui 0.10.17 → 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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.20
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`cec468f`](https://github.com/snowcone-app/snowcone-monorepo/commit/cec468fc5799297a192a5183edbf1a6b460c6d56)]:
8
+ - @snowcone-app/sdk@0.31.4
9
+
10
+ ## 0.10.19
11
+
12
+ ### Patch Changes
13
+
14
+ - [#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).
15
+
16
+ - Updated dependencies [[`5fda4b9`](https://github.com/snowcone-app/snowcone-monorepo/commit/5fda4b9c7fbb226c1bd61024cf01c38ac31bddeb)]:
17
+ - @snowcone-app/sdk@0.31.3
18
+
19
+ ## 0.10.18
20
+
21
+ ### Patch Changes
22
+
23
+ - [#5680](https://github.com/snowcone-app/snowcone-monorepo/pull/5680) [`792b4f5`](https://github.com/snowcone-app/snowcone-monorepo/commit/792b4f55b2b662906d3aeacf5d246524f2444dd0) Thanks [@kevinsproles](https://github.com/kevinsproles)! - The desktop product-page hero of a plate asks for only the part of its 8:3 strip the window shows. SDK: `getMockupUrl` takes `stripView` (`view=<r>@<f>`, with `aspect: "8:3"` and no width; a crop written as the scene alias `view` throws `E_VIEW_IS_STRIP_VIEW`), re-exports the view grid (`mockupViewFor`, `canonicalMockupView`, `MOCKUP_VIEW_SHAPES`, `MOCKUP_VIEW_PLACES`, `MockupView`), and the catalog product type carries `mockups[].strip` (`{ shape: "8:3", productX }`). UI: `HeroProductImage` takes `stripView` (a crop, or `"whole-strip"`) and `onShown`; `CarouselImage` carries `strip`.
24
+
25
+ - Updated dependencies [[`792b4f5`](https://github.com/snowcone-app/snowcone-monorepo/commit/792b4f55b2b662906d3aeacf5d246524f2444dd0)]:
26
+ - @snowcone-app/sdk@0.31.2
27
+
3
28
  ## 0.10.17
4
29
 
5
30
  ### 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: sendConfigRaw,
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,
@@ -10873,13 +10910,20 @@ function buildHeroMockupUrl(args) {
10873
10910
  return (0, import_sdk11.getMockupUrl)(args.productCode, {
10874
10911
  shop: snow.shop,
10875
10912
  design: publicDesign,
10876
- width: args.width,
10913
+ ..."stripView" in args.size ? { aspect: "8:3", stripView: args.size.stripView } : { width: args.size.width, ...args.size.aspect ? { aspect: args.size.aspect } : {} },
10877
10914
  view: args.mockupId,
10878
10915
  variant: args.variantId,
10879
10916
  ...args.bg ? { bg: args.bg } : {},
10880
10917
  ...snow.resolver ? { base: snow.resolver } : {}
10881
10918
  });
10882
10919
  }
10920
+ function isCrop(stripView) {
10921
+ return stripView !== void 0 && stripView !== "whole-strip";
10922
+ }
10923
+ function heroSize(stripView, width) {
10924
+ if (isCrop(stripView)) return { stripView };
10925
+ return stripView === "whole-strip" ? { width, aspect: "8:3" } : { width };
10926
+ }
10883
10927
  var EMPTY_IMAGES = [];
10884
10928
  var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
10885
10929
  productId,
@@ -10912,7 +10956,9 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
10912
10956
  errorText = "Error loading",
10913
10957
  unavailableText = "Preview unavailable",
10914
10958
  viewportPolicy = false,
10915
- fit = "cover"
10959
+ fit = "cover",
10960
+ stripView,
10961
+ onShown
10916
10962
  }) {
10917
10963
  const context = useProductOptional();
10918
10964
  const designContext = useDesignOptional();
@@ -10949,7 +10995,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
10949
10995
  }
10950
10996
  if (context?.loading) return null;
10951
10997
  if (!effectiveArtworkSrc || effectiveArtworkSrc.trim() === "") return null;
10952
- if (!actualProductId || !actualMockupId || !actualGvid || actualGvid === "default" || !width) return null;
10998
+ if (!actualProductId || !actualMockupId || !actualGvid || actualGvid === "default" || !(isCrop(stripView) || width)) return null;
10953
10999
  const allPlacements = product?.placements || context?.product?.placements || [];
10954
11000
  if (allPlacements.length === 0) return null;
10955
11001
  const placementDesigns = {};
@@ -10974,10 +11020,11 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
10974
11020
  placements: allPlacements,
10975
11021
  mockupId: actualMockupId,
10976
11022
  variantId: actualGvid,
10977
- width,
11023
+ size: heroSize(stripView, width),
10978
11024
  bg: mockupBg
10979
11025
  });
10980
11026
  }, [
11027
+ stripView,
10981
11028
  realtimeUrl,
10982
11029
  mode,
10983
11030
  context?.loading,
@@ -11028,6 +11075,8 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
11028
11075
  const isPendingExportRef = (0, import_react46.useRef)(false);
11029
11076
  const onUrlGeneratedRef = (0, import_react46.useRef)(onUrlGenerated);
11030
11077
  onUrlGeneratedRef.current = onUrlGenerated;
11078
+ const onShownRef = (0, import_react46.useRef)(onShown);
11079
+ onShownRef.current = onShown;
11031
11080
  const layersLengthRef = (0, import_react46.useRef)(layers.length);
11032
11081
  layersLengthRef.current = layers.length;
11033
11082
  (0, import_react46.useEffect)(() => {
@@ -11336,7 +11385,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
11336
11385
  setTargetUrl(null);
11337
11386
  return;
11338
11387
  }
11339
- if (!actualProductId || !actualMockupId || !actualGvid || actualGvid === "default" || !width) {
11388
+ if (!actualProductId || !actualMockupId || !actualGvid || actualGvid === "default" || !(isCrop(stripView) || width)) {
11340
11389
  return;
11341
11390
  }
11342
11391
  const allPlacements = product?.placements || context?.product?.placements || [];
@@ -11350,7 +11399,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
11350
11399
  placements: allPlacements,
11351
11400
  mockupId: actualMockupId,
11352
11401
  variantId: actualGvid,
11353
- width,
11402
+ size: heroSize(stripView, width),
11354
11403
  bg: mockupBg
11355
11404
  });
11356
11405
  if (!url) return;
@@ -11395,6 +11444,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
11395
11444
  mockupBg,
11396
11445
  images,
11397
11446
  width,
11447
+ stripView,
11398
11448
  effects,
11399
11449
  // Use primitive values extracted at the top of the component
11400
11450
  artworkSrc,
@@ -11529,6 +11579,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
11529
11579
  "data-hero-image": "true",
11530
11580
  "data-mockup-id": actualMockupId || void 0,
11531
11581
  "data-fit": fit,
11582
+ "data-strip-view": stripView,
11532
11583
  "data-picture-failed": imgFailed ? "E_PICTURE_UNDISPLAYED" : void 0,
11533
11584
  "data-picture-failed-src": failedSrc,
11534
11585
  "data-mockup-unavailable": unavailable ? unavailable.code : void 0,
@@ -11567,6 +11618,7 @@ var HeroProductImage = (0, import_react46.memo)(function HeroProductImage2({
11567
11618
  onLoad();
11568
11619
  }
11569
11620
  onUrlGeneratedRef.current?.(renderedUrl);
11621
+ if (renderedUrl) onShownRef.current?.(renderedUrl);
11570
11622
  },
11571
11623
  onError: () => {
11572
11624
  if (renderedUrl && retriedUrlRef.current !== renderedUrl) {