@snowcone-app/ui 0.10.22 → 0.11.1

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/dist/index.d.cts CHANGED
@@ -4474,6 +4474,15 @@ interface HeroProductImageProps {
4474
4474
  };
4475
4475
  /** Called with the URL of each picture once it is ON SCREEN (its <img> loaded), not when it is asked for. */
4476
4476
  onShown?: (url: string) => void;
4477
+ /**
4478
+ * URLs the SERVER already signed (the PDP's first-hero preload, heroMockupUrl.ts firstMobileHeroUrl): when the URL this
4479
+ * image builds equals one's `url`, its `signed` is used at once (no /api/sign round trip) — the same bytes the page
4480
+ * preloaded, so the hero is fetched once. Any other URL is signed as usual. Data: `data-hero-presigned`.
4481
+ */
4482
+ presigned?: ReadonlyArray<{
4483
+ url: string;
4484
+ signed: string;
4485
+ }>;
4477
4486
  }
4478
4487
  /**
4479
4488
  * Hero-compatible version of ProductImage that renders as a simple img element
@@ -4903,6 +4912,11 @@ interface MobileProductCarouselProps {
4903
4912
  * cover-adjusted resolution instead of just the container CSS width.
4904
4913
  */
4905
4914
  mockupWidth?: number;
4915
+ /** Server-signed hero URLs (the PDP's first-hero preload): a slide whose URL matches uses it, never re-signing it. */
4916
+ presignedHeroUrls?: ReadonlyArray<{
4917
+ url: string;
4918
+ signed: string;
4919
+ }>;
4906
4920
  /**
4907
4921
  * Fires when `HeroProductImage` finishes generating a mockup URL for a
4908
4922
  * given mockupId — covers the static (SDK-built) URL on first load AND
package/dist/index.d.ts CHANGED
@@ -4474,6 +4474,15 @@ interface HeroProductImageProps {
4474
4474
  };
4475
4475
  /** Called with the URL of each picture once it is ON SCREEN (its <img> loaded), not when it is asked for. */
4476
4476
  onShown?: (url: string) => void;
4477
+ /**
4478
+ * URLs the SERVER already signed (the PDP's first-hero preload, heroMockupUrl.ts firstMobileHeroUrl): when the URL this
4479
+ * image builds equals one's `url`, its `signed` is used at once (no /api/sign round trip) — the same bytes the page
4480
+ * preloaded, so the hero is fetched once. Any other URL is signed as usual. Data: `data-hero-presigned`.
4481
+ */
4482
+ presigned?: ReadonlyArray<{
4483
+ url: string;
4484
+ signed: string;
4485
+ }>;
4477
4486
  }
4478
4487
  /**
4479
4488
  * Hero-compatible version of ProductImage that renders as a simple img element
@@ -4903,6 +4912,11 @@ interface MobileProductCarouselProps {
4903
4912
  * cover-adjusted resolution instead of just the container CSS width.
4904
4913
  */
4905
4914
  mockupWidth?: number;
4915
+ /** Server-signed hero URLs (the PDP's first-hero preload): a slide whose URL matches uses it, never re-signing it. */
4916
+ presignedHeroUrls?: ReadonlyArray<{
4917
+ url: string;
4918
+ signed: string;
4919
+ }>;
4906
4920
  /**
4907
4921
  * Fires when `HeroProductImage` finishes generating a mockup URL for a
4908
4922
  * given mockupId — covers the static (SDK-built) URL on first load AND
package/dist/index.js CHANGED
@@ -17,6 +17,9 @@ import {
17
17
  useUiRouter,
18
18
  useUiSearchParams
19
19
  } from "./chunk-UVWV63VW.js";
20
+ import {
21
+ heroMockupUrl
22
+ } from "./chunk-MFDCHCN6.js";
20
23
  import {
21
24
  checkComponentStyles,
22
25
  checkTailwindConfig,
@@ -6829,7 +6832,7 @@ function RealtimeProvider({
6829
6832
  },
6830
6833
  [productContext?.product?.mockups, markEditSettled]
6831
6834
  );
6832
- const getMockupUrl3 = useCallback10((mockupId) => {
6835
+ const getMockupUrl2 = useCallback10((mockupId) => {
6833
6836
  if (pendingMockupIdsRef.current.has(mockupId)) {
6834
6837
  console.log(`[RTP] getMockupUrl("${mockupId}") \u2192 null (pending)`);
6835
6838
  return null;
@@ -6970,7 +6973,7 @@ function RealtimeProvider({
6970
6973
  flushPendingBlobs,
6971
6974
  hasPendingBlobs,
6972
6975
  // Centralized URL management
6973
- getMockupUrl: getMockupUrl3,
6976
+ getMockupUrl: getMockupUrl2,
6974
6977
  getMockupUrls,
6975
6978
  getCanvasVersion,
6976
6979
  getLatestSentVersions: getLatestSentVersionsStable,
@@ -7011,7 +7014,7 @@ function RealtimeProvider({
7011
7014
  stableSubscribePendingExportCancelled,
7012
7015
  flushPendingBlobs,
7013
7016
  hasPendingBlobs,
7014
- getMockupUrl3,
7017
+ getMockupUrl2,
7015
7018
  getMockupUrls,
7016
7019
  getCanvasVersion,
7017
7020
  getLatestSentVersionsStable,
@@ -9888,7 +9891,7 @@ var LoadingOverlayPrismCandyInline = memo2(
9888
9891
 
9889
9892
  // src/index.ts
9890
9893
  import { useRealtimeMockup as useRealtimeMockup3 } from "@snowcone-app/sdk/react";
9891
- import { getProduct as getProduct3, listProducts as listProducts4, getMockupUrl as getMockupUrl2 } from "@snowcone-app/sdk";
9894
+ import { getProduct as getProduct3, listProducts as listProducts4, getMockupUrl } from "@snowcone-app/sdk";
9892
9895
 
9893
9896
  // src/patterns/ProductPageProvider.tsx
9894
9897
  import { jsx as jsx57 } from "react/jsx-runtime";
@@ -10504,7 +10507,6 @@ import {
10504
10507
  } from "react";
10505
10508
  import {
10506
10509
  createDesignForPlacements,
10507
- getMockupUrl,
10508
10510
  resolveVariantId,
10509
10511
  resolvePreviewVariantId as resolvePreviewVariantId2,
10510
10512
  resolveMockupId,
@@ -10548,42 +10550,9 @@ function useContainerWidth(containerRef, maxWidth = 3e3) {
10548
10550
 
10549
10551
  // src/composed/HeroProductImage.tsx
10550
10552
  import { jsx as jsx61, jsxs as jsxs39 } from "react/jsx-runtime";
10551
- function slugifyPlacementKey(label) {
10552
- return label.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
10553
- }
10554
- function toPublicDesign(elements, placements) {
10555
- const design = {};
10556
- for (const el of elements) {
10557
- if (!el.placement) continue;
10558
- const match = placements.find((p) => p.label === el.placement);
10559
- const key = match?.key || slugifyPlacementKey(el.placement);
10560
- if (el.type === "color") {
10561
- if (el.hex) design[key] = { color: el.hex };
10562
- } else if (el.imageUrl) {
10563
- const aligned = el.alignment && el.alignment !== "center";
10564
- design[key] = aligned || el.tiles ? {
10565
- src: el.imageUrl,
10566
- ...aligned ? { align: el.alignment } : {},
10567
- ...el.tiles ? { tile: el.tiles } : {}
10568
- } : el.imageUrl;
10569
- }
10570
- }
10571
- return design;
10572
- }
10573
10553
  function buildHeroMockupUrl(args) {
10574
10554
  const snow = typeof window !== "undefined" && window.snowcone || {};
10575
- if (!snow.shop) return null;
10576
- const publicDesign = toPublicDesign(args.design, args.placements);
10577
- if (Object.keys(publicDesign).length === 0) return null;
10578
- return getMockupUrl(args.productCode, {
10579
- shop: snow.shop,
10580
- design: publicDesign,
10581
- ..."stripView" in args.size ? { aspect: "8:3", stripView: args.size.stripView, ...args.size.width !== void 0 ? { width: args.size.width } : {} } : { width: args.size.width },
10582
- view: args.mockupId,
10583
- variant: args.variantId,
10584
- ...args.bg ? { bg: args.bg } : {},
10585
- ...snow.resolver ? { base: snow.resolver } : {}
10586
- });
10555
+ return heroMockupUrl({ ...args, shop: snow.shop, resolver: snow.resolver });
10587
10556
  }
10588
10557
  function isCrop(stripView) {
10589
10558
  return stripView !== void 0;
@@ -10626,7 +10595,8 @@ var HeroProductImage = memo3(function HeroProductImage2({
10626
10595
  viewportPolicy = false,
10627
10596
  fit = "cover",
10628
10597
  stripView: stripViewProp,
10629
- onShown
10598
+ onShown,
10599
+ presigned
10630
10600
  }) {
10631
10601
  const stripView = typeof stripViewProp === "object" ? stripViewProp.view : stripViewProp;
10632
10602
  const cropWidth = typeof stripViewProp === "object" ? stripViewProp.width : void 0;
@@ -10748,6 +10718,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
10748
10718
  onUrlGeneratedRef.current = onUrlGenerated;
10749
10719
  const onShownRef = useRef23(onShown);
10750
10720
  onShownRef.current = onShown;
10721
+ const presignedUsedRef = useRef23(false);
10751
10722
  const layersLengthRef = useRef23(layers.length);
10752
10723
  layersLengthRef.current = layers.length;
10753
10724
  useEffect32(() => {
@@ -11097,7 +11068,11 @@ var HeroProductImage = memo3(function HeroProductImage2({
11097
11068
  onUrlGeneratedRef.current?.(finalUrl);
11098
11069
  };
11099
11070
  const signer = typeof window !== "undefined" ? window.snowcone?.signMockupUrl : void 0;
11100
- if (signer) {
11071
+ const serverSigned = presigned?.find((p) => p.url === url)?.signed;
11072
+ if (serverSigned) {
11073
+ presignedUsedRef.current = true;
11074
+ render(serverSigned);
11075
+ } else if (signer) {
11101
11076
  signer(url).then((signed) => render(signed || url)).catch(() => render(url));
11102
11077
  } else {
11103
11078
  render(url);
@@ -11253,6 +11228,7 @@ var HeroProductImage = memo3(function HeroProductImage2({
11253
11228
  "data-fit": fit,
11254
11229
  "data-strip-view": stripView,
11255
11230
  "data-strip-width": cropWidth,
11231
+ "data-hero-presigned": presignedUsedRef.current ? "server" : void 0,
11256
11232
  "data-picture-failed": imgFailed ? "E_PICTURE_UNDISPLAYED" : void 0,
11257
11233
  "data-picture-failed-src": failedSrc,
11258
11234
  "data-mockup-unavailable": unavailable ? unavailable.code : void 0,
@@ -12836,6 +12812,7 @@ var MobileProductCarousel = memo4(function MobileProductCarousel2({
12836
12812
  onZoomChange,
12837
12813
  stickyHeroContext,
12838
12814
  mockupWidth,
12815
+ presignedHeroUrls,
12839
12816
  onMockupUrlGenerated,
12840
12817
  renderImageAction,
12841
12818
  errorText,
@@ -13392,6 +13369,7 @@ var MobileProductCarousel = memo4(function MobileProductCarousel2({
13392
13369
  placement: image.placement,
13393
13370
  mockupId: image.mockupId,
13394
13371
  width: mockupWidth,
13372
+ presigned: presignedHeroUrls,
13395
13373
  realtimeUrl: image.mockupId ? realtimeMockupUrls[image.mockupId] ?? generatedUrlsRef.current.get(image.mockupId) ?? void 0 : void 0,
13396
13374
  onUrlGenerated: image.mockupId ? (url) => handleUrlGenerated(image.mockupId, url) : void 0,
13397
13375
  errorText,
@@ -15755,7 +15733,7 @@ export {
15755
15733
  formatDate,
15756
15734
  formatDateTime,
15757
15735
  getBrand,
15758
- getMockupUrl2 as getMockupUrl,
15736
+ getMockupUrl,
15759
15737
  getObservedElementCount,
15760
15738
  getObserverCount,
15761
15739
  getProduct3 as getProduct,