efficient-storefront-blocks 0.126.1 → 0.126.3
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 +32 -0
- package/dist/index.js +27 -27
- package/dist/render/components/AssistantChatPanel.js +1 -1
- package/dist/render/components/ChatContext.js +1 -1
- package/dist/render/components/ProductGallery.d.ts +3 -1
- package/dist/render/components/ProductGallery.js +1 -1
- package/dist/render/components/pdp-dynamic/DynamicProductGallery.d.ts +2 -0
- package/dist/render/components/product-hero/SpinLayer.d.ts +5 -0
- package/dist/render/components/product-hero/SpinLayer.js +1 -0
- package/dist/render/lib/chat-socket.d.ts +13 -2
- package/dist/render/lib/chat-socket.js +1 -1
- package/dist/render/lib/document/blocks/commerce/ProductGallery/meta.js +1 -1
- package/dist/render/lib/document/blocks/commerce/ProductGallery/render.js +1 -1
- package/dist/render/lib/sections/spin-sets.d.ts +15 -0
- package/dist/render/lib/sections/spin-sets.js +1 -0
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as I}from"react/jsx-runtime";import{useCallback as o,useEffect as O,useMemo as R,useRef as s,useState as m}from"react";import{AssistantChat as _}from"efficient-shell/ai";import"efficient-shell/ai.css";import{api as d,API_URL as w}from"../lib/api/index.js";import{auth as r}from"../lib/auth.js";import{safeLocalStorage as S}from"efficient-web-builder/format/lib/safe-storage";import{webRuntimeSiteSlug as
|
|
1
|
+
"use client";import{jsx as I}from"react/jsx-runtime";import{useCallback as o,useEffect as O,useMemo as R,useRef as s,useState as m}from"react";import{AssistantChat as _}from"efficient-shell/ai";import"efficient-shell/ai.css";import{api as d,API_URL as w}from"../lib/api/index.js";import{auth as r}from"../lib/auth.js";import{safeLocalStorage as S}from"efficient-web-builder/format/lib/safe-storage";import{webRuntimeSiteSlug as F}from"efficient-web-builder/format/lib/web-runtime";import{ASSISTANT_LABELS as k,ASSISTANT_PLACEHOLDER as v,STOREFRONT_TOOL_LABELS as H,assistantHeaders as N,assistantSiteKey as x,assistantStorageKey as B,assistantWording as D,createAssistantFetch as K,readStoredAssistantChat as P,writeStoredAssistantChat as U}from"../lib/assistant-chat.js";import{isOffStreamMessage as j,openChatSocket as G}from"../lib/chat-socket.js";import{DEFAULT_GREETING as M,DEFAULT_TITLE as W}from"./ChatWidget.js";function $({title:p,greeting:g,onUnavailable:i}){const[A,h]=m(!1),[T,c]=m(null),n=s(""),e=s(void 0),u=s(null),l=s(i);l.current=i,O(()=>{n.current=B(x(window.location.host));const t=P(S,n.current);e.current=t?.guestToken,c(t),u.current=d.restoreSession().catch(()=>{}),h(!0)},[]);const L=o(async()=>(await u.current,N(r.getAccess(),e.current)),[]),b=R(()=>K({fetchImpl:(t,a)=>fetch(t,a),siteSlug:F,access:r.getAccess,refresh:async()=>(await d.refresh()).access,signOut:r.clear,onUnavailable:()=>l.current()}),[]),E=o(t=>{e.current=t?.guestToken,U(S,n.current,t),c(t)},[]),y=o((t,a)=>G({conversationId:t.id,credential:()=>({access:r.getAccess(),guest:e.current}),onFrame:C=>{j(C)&&a()}}),[]),f=D({title:p,greeting:g},{title:W,greeting:M});return A?I(_,{variant:"bubble",defaultOpen:!0,apiBase:`${w}/api`,getHeaders:L,fetch:b,conversationId:T?.id??null,onConversation:E,subscribe:y,title:f.title,placeholder:v,toolLabels:H,labels:{...k,emptyState:f.emptyState}}):null}export{$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as z}from"react/jsx-runtime";import{createContext as B,useCallback as f,useContext as D,useEffect as k,useMemo as F,useRef as x,useState as c}from"react";import{auth as G}from"../lib/auth.js";import{api as Q}from"../lib/api/index.js";import{chatSocketTarget as X}from"../lib/chat-socket.js";import{safeLocalStorage as I}from"efficient-web-builder/format/lib/safe-storage";import{getChatThread as Z,postChatMessage as ee,startChat as te}from"../lib/api/chat.js";const se="sf:aid",A="sf:chat",H=B(null);function ne(){const u=I.getItem(A);if(!u)return null;try{return JSON.parse(u)}catch{return null}}function fe({children:u,preview:t=!1}){const[m,y]=c(!1),[e,O]=c(null),[T,g]=c([]),[b,E]=c(!1),[v,P]=c(null),[M,C]=c(0),[N,R]=c(!1),[J,L]=c(!1),S=x(m);S.current=m;const h=x(null),_=x(e);_.current=e,k(()=>{t||O(ne())},[t]);const l=f(async r=>{try{const o=await Z(r.id,r.token);g(o.messages)}catch{}},[]),i=f(()=>(t||h.current||(h.current=Q.restoreSession().then(()=>{R(!0),_.current&&l(_.current)},()=>R(!1))),h.current),[t,l]);k(()=>{t||e&&l(e)},[t,e,l]),k(()=>{if(t||!e)return;const r={access:G.getAccess(),guest:e.token};let o=!1,s=null,n,a=3e3;const d=()=>{if(o)return;const{url:V,protocols:W}=X(e.id,r);s=new WebSocket(V,W),s.onmessage=$=>{try{const p=JSON.parse($.data);p.type==="chat_event"&&p.event==="message"&&(l(e),!S.current&&p.payload?.sender_role==="employee"&&C(q=>q+1))}catch{}},s.onclose=()=>{o||(n=setTimeout(d,a),a=Math.min(a*2,3e4))},s.onerror=()=>s?.close()};return d(),()=>{o=!0,n&&clearTimeout(n),s?.close()}},[t,e,l]);const K=f(()=>{y(!0),C(0),i()},[i]),Y=f(()=>y(!1),[]),j=f(()=>{S.current||i(),y(r=>(r||C(0),!r))},[i]),w=f(async(r,o)=>{const s=r.trim();if(!s)return!1;if(t)return g(n=>[...n,{id:`preview-${n.length}`,sender_role:"customer",sender_name:o?.name||"You",body:s,image_url:null,created_at:""}]),L(!0),!0;E(!0),P(null),await i();try{if(e){const n=await ee(e.id,e.token,s);g(a=>[...a,n])}else{const n=I.getItem(se)||"",a=await te({body:s,guestName:o?.name,guestEmail:o?.email,guestKey:n}),d={id:a.id,token:a.guest_token};I.setItem(A,JSON.stringify(d)),O(d),g(a.messages)}return!0}catch{return P("Could not send your message. Please try again shortly."),!1}finally{E(!1)}},[e,t,i]),U=F(()=>({isOpen:m,open:K,close:Y,toggle:j,messages:T,sending:b,error:v,unread:M,hasConversation:t?J:!!e,isSignedIn:N,send:w}),[m,K,Y,j,T,b,v,M,e,N,w,t,J]);return z(H.Provider,{value:U,children:u})}function de(){const u=D(H);if(!u)throw new Error("useChat must be used within <ChatProvider>");return u}export{fe as ChatProvider,de as useChat};
|
|
@@ -2,7 +2,8 @@ import { type CSSProperties } from "react";
|
|
|
2
2
|
import { type HeroView } from "./product-hero/hero-view.js";
|
|
3
3
|
import type { StoreProduct } from "../lib/catalog/store-product.js";
|
|
4
4
|
import { type HeroGalleryMode, type HeroImageFit } from "../lib/sections/hero-gallery.js";
|
|
5
|
-
|
|
5
|
+
import { type SpinSets } from "../lib/sections/spin-sets.js";
|
|
6
|
+
export default function ProductGallery({ product, view, angleIdx, onSelect, isLight, onLightbox, galleryMode, imageFit, style, takesViewHide, spin, }: {
|
|
6
7
|
product: StoreProduct;
|
|
7
8
|
view: HeroView;
|
|
8
9
|
angleIdx: number;
|
|
@@ -13,4 +14,5 @@ export default function ProductGallery({ product, view, angleIdx, onSelect, isLi
|
|
|
13
14
|
imageFit?: HeroImageFit;
|
|
14
15
|
style?: CSSProperties;
|
|
15
16
|
takesViewHide?: boolean;
|
|
17
|
+
spin?: SpinSets;
|
|
16
18
|
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,Fragment as
|
|
1
|
+
"use client";import{jsx as n,Fragment as N,jsxs as m}from"react/jsx-runtime";import{useRef as j}from"react";import{photoLabel as x}from"./product-hero/hero-view.js";import v from"./product-hero/SpinLayer.js";import{stageControls as $,useHeldStagePhoto as F}from"./product-hero/stage-photo.js";import{DEFAULT_HERO_GALLERY_MODE as z,DEFAULT_HERO_IMAGE_FIT as A,parseHeroGalleryMode as O,parseHeroImageFit as P,resolveHeroImageFit as R}from"../lib/sections/hero-gallery.js";import{spinSetFor as B}from"../lib/sections/spin-sets.js";import{productHasComposedRender as I}from"../lib/wheels/set-mode.js";import{HideTaker as C}from"efficient-web-builder/render/components/ViewHideRoot";import{swipeEnabled as V,swipeStep as G}from"efficient-web-builder/format/lib/hero-swipe";function D({product:a,view:e,angleIdx:o,onSelect:d,isLight:l,onLightbox:r,galleryMode:i=z,imageFit:c=A,style:t,takesViewHide:s=!1,spin:u=U}){const g=B(u,a.slug,e.metaValue),h=O(i),f=R(P(c),I(a)),b=n(X,{name:a.name,view:e,angleIdx:o,onSelect:d,isLight:l,onLightbox:r,fit:f,spinSet:g});return h==="stacked"?n(C,{as:"div",takes:s,"data-hero-gallery":h,"data-hero-fit":f,style:t,children:e.photos.length<2?b:m(N,{children:[n(q,{name:a.name,view:e,isLight:l,onLightbox:r,fit:f,spinSet:g}),n(w,{angleIdx:o,total:S(e),onSelect:d,children:b})]})}):m(C,{as:"div",takes:s,"data-hero-gallery":h,"data-hero-fit":f,className:h==="tiled"?"flex items-start gap-3 max-view-tablet:gap-2":void 0,style:t,children:[n("div",{className:h==="tiled"?"min-w-0 flex-1":void 0,children:b}),h!=="main"&&n(Y,{name:a.name,view:e,angleIdx:o,onSelect:d,isLight:l,tiled:h==="tiled"})]})}function S(a){return a.photos.length>0?a.photos.length:a.thumbFallbackCells}const L="relative flex aspect-square items-center justify-center overflow-hidden",U={},k=(a,e,o)=>[a,e.metaValue,o].filter(Boolean).join(" — "),T=(a,e)=>[a,e.metaValue].filter(Boolean).join(" "),H=(a,e)=>`Open ${[a,e.metaValue].filter(Boolean).join(" ")} at full resolution`;function q({name:a,view:e,isLight:o,onLightbox:d,fit:l,spinSet:r}){const i=r?n(v,{set:r,name:T(a,e)}):null;return n("div",{"data-hero-stack":!0,className:"flex flex-col gap-2 max-view-tablet:hidden",children:e.photos.map((c,t)=>{const s=k(a,e,x(e,t));return m("div",{"data-hero-stack-photo":!0,className:[L,o?"bg-bg":""].join(" "),style:{color:e.tint},children:[e.stageImage({photo:c,alt:s,label:H(a,e),onZoom:()=>d(c,s),fit:l,eager:t===0}),t===0&&i]},c)})})}function w({angleIdx:a,total:e,onSelect:o,children:d}){const l=j(null),r=j(null),i=V({count:e}),c=t=>({x:t.touches[0].clientX,y:t.touches[0].clientY});return n("div",{"data-hero-phone-stage":!0,className:"view-tablet:hidden",onTouchStart:t=>{l.current=i&&t.touches.length===1?c(t):null,r.current=l.current},onTouchMove:t=>{l.current&&(t.touches.length!==1?l.current=null:r.current=c(t))},onTouchEnd:()=>{const t=l.current,s=r.current;if(l.current=null,r.current=null,!t||!s)return;const u=G(s.x-t.x,s.y-t.y,a,e);u!==a&&o(u)},children:d})}const W=6;function X({name:a,view:e,angleIdx:o,onSelect:d,isLight:l,onLightbox:r,fit:i,spinSet:c}){const t=e.photos[Math.min(o,e.photos.length-1)],s=F(e.photos,t),u=S(e),g=u>=2,h=String(u).padStart(2,"0"),f=Math.min(o,Math.max(e.photos.length-1,0)),b=g||e.captions[f]?x(e,f):"",_=k(a,e,b),y="max-view-tablet:static",E=[`${L} max-view-tablet:col-span-2`,l?"bg-bg":""].join(" ");return m("div",{className:"relative max-view-tablet:grid max-view-tablet:grid-cols-[minmax(0,1fr)_auto] max-view-tablet:items-start max-view-tablet:gap-x-3 max-view-tablet:gap-y-2",style:{color:e.tint},children:[m("div",{className:`absolute left-0 top-0 z-10 flex items-center gap-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.2em] text-fg ${y} max-view-tablet:min-w-0 max-view-tablet:flex-wrap max-view-tablet:gap-x-2 max-view-tablet:gap-y-1`,children:[g&&m(N,{children:[m("span",{className:"text-accent",children:[String(o+1).padStart(2,"0")," / ",h]}),n("span",{className:"text-fg-dim",children:"·"})]}),n("span",{children:a}),e.metaValue&&m(N,{children:[n("span",{className:"text-fg-dim",children:"·"}),n("span",{className:"text-accent",children:e.metaValue})]})]}),g&&n("div",{className:`absolute right-5 top-5 z-10 flex gap-1 ${y}`,children:$(o,u,d).map(p=>n("button",{type:"button","aria-label":p.label,title:p.label,onClick:p.onClick,className:"flex h-7 w-7 items-center justify-center border border-fg-dim/60 text-fg transition-colors hover:border-accent hover:text-accent",children:p.glyph},p.label))}),m("div",{className:E,children:[["top-3 left-3","top-3 right-3","bottom-3 left-3","bottom-3 right-3"].map((p,M)=>n("span",{className:`absolute ${p} h-3 w-3 border border-fg-dim/40`,style:{borderTop:p.includes("top")?"1px solid var(--site-line)":"none",borderBottom:p.includes("bottom")?"1px solid var(--site-line)":"none",borderLeft:p.includes("left")?"1px solid var(--site-line)":"none",borderRight:p.includes("right")?"1px solid var(--site-line)":"none"}},M)),e.stageImage({photo:s,alt:_,label:H(a,e),onZoom:()=>r(s,_),fit:i}),c&&n(v,{set:c,name:T(a,e)})]}),m("div",{className:`absolute bottom-0 left-0 right-0 z-10 flex items-end justify-between gap-3 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-fg-dim ${y} max-view-tablet:col-span-2 max-view-tablet:flex-wrap`,children:[m("span",{className:"flex min-w-0 flex-col gap-1",children:[e.specCaption&&n("span",{children:e.specCaption}),e.referenceNote&&n("span",{"data-hero-reference-note":!0,children:e.referenceNote}),e.galleryHint&&n("span",{"data-hero-gallery-hint":!0,children:e.galleryHint})]}),n("span",{children:e.originCaption})]})]})}function Y({name:a,view:e,angleIdx:o,onSelect:d,isLight:l,tiled:r=!1}){const i=S(e);return i<2?null:n("div",{className:r?"order-[-1] flex w-16 flex-col gap-2 max-view-tablet:w-12 max-view-tablet:gap-1":"mt-2 grid grid-cols-4 gap-2 max-view-tablet:gap-1",style:!r&&i>4?{gridTemplateColumns:`repeat(${Math.min(i,W)}, minmax(0, 1fr))`}:void 0,children:Array.from({length:i}).map((c,t)=>{const s=e.photos[t];return m("button",{type:"button",onClick:()=>d(t),"aria-label":`View ${x(e,t)}`,"aria-pressed":t===o,className:["relative flex aspect-square items-center justify-center overflow-hidden transition-colors",l?"bg-bg":"",t===o?"border border-accent":"border border-transparent hover:border-fg-dim"].join(" "),style:{color:e.tint},children:[n("span",{className:"absolute top-1.5 left-2 z-10 font-mono text-[length:var(--size-label,8px)] uppercase tracking-[0.18em] text-fg-dim",children:String(t+1).padStart(2,"0")}),e.thumbImage({photo:s,alt:`${a} — ${x(e,t)}`})]},t)})})}export{D as default};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { HeroGalleryMode, HeroImageFit } from "../../lib/sections/hero-gallery.js";
|
|
2
|
+
import type { SpinSets } from "../../lib/sections/spin-sets.js";
|
|
2
3
|
interface GalleryLook {
|
|
3
4
|
galleryMode?: HeroGalleryMode;
|
|
4
5
|
imageFit?: HeroImageFit;
|
|
6
|
+
spin?: SpinSets;
|
|
5
7
|
}
|
|
6
8
|
export default function DynamicProductGallery({ editing, ...look }: {
|
|
7
9
|
editing?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as p,jsxs as T,Fragment as ut}from"react/jsx-runtime";import{useCallback as x,useEffect as k,useRef as a,useState as A}from"react";import{HALF_SIZES as j,sizedImage as U}from"efficient-web-builder/format/lib/sized-image";import{prefersReducedMotion as q}from"efficient-web-builder/render/components/useReducedMotion";import{SPIN_MAX_ZOOM as B,clampSpinZoom as mt,isFullTurn as pt,spinClampPosition as dt,spinFrameIndex as ft,spinPositionAfterDrag as G,spinStartPosition as ht}from"../../lib/sections/spin-sets.js";const xt=.25,gt=.3,bt=.85,K=24,zt=300,yt=.0015,V=4,J=1e3,wt=1920,Q=c=>U(c,{fallbackWidth:J,maxWidth:J}),Mt=c=>U(c,{fallbackWidth:wt});function vt({set:c,name:v}){const[l,nt]=A(!1),[W,et]=A(()=>ht(c)),[g,rt]=A({z:1,x:0,y:0}),[L,O]=A(0),b=a(null),z=a(0),P=a(W),F=a(1),d=a(g),y=a(null),u=a(new Map),h=a(null),S=a(0),I=a(null),m=c.frames.length,D=pt(c),Y=ft(W,m,D),_=x(t=>{const n=dt(t,m,D);return P.current=n,et(n),n},[m,D]),f=x(()=>cancelAnimationFrame(z.current),[]),w=x(t=>{d.current=t,rt(t)},[]),M=x((t,n,e)=>{const r=b.current;if(!r)return;const o=r.getBoundingClientRect(),s=d.current,i=mt(t),E=n-o.left-o.width/2,Z=e-o.top-o.height/2;if(i<=1.01){w({z:1,x:0,y:0});return}const $=r.clientWidth*(i-1)/2,H=r.clientHeight*(i-1)/2,at=E-(E-s.x)*i/s.z,lt=Z-(Z-s.y)*i/s.z;w({z:i,x:Math.max(-$,Math.min($,at)),y:Math.max(-H,Math.min(H,lt))})},[w]),N=x(()=>{const t=c.frames[0];if(I.current===t)return;I.current=t,O(0);const n=[];for(let e=0;e<V;e+=1)for(let r=e;r<m;r+=V)n.push(r);for(const e of n){const r=Q(c.frames[e]),o=new Image;o.onload=()=>{I.current===t&&O(s=>s+1)},o.sizes=j,r.srcSet&&(o.srcset=r.srcSet),o.src=r.src}},[m,c.frames]),ot=x(()=>{const t=()=>{const n=P.current+xt*F.current;_(n)!==n&&(F.current=-F.current),z.current=requestAnimationFrame(t)};z.current=requestAnimationFrame(t)},[_]),st=()=>{const t=!l;if(nt(t),f(),!t){w({z:1,x:0,y:0});return}q()||ot()};k(()=>{l&&N()},[l,N]),k(()=>{const t=b.current;if(!l||!t)return;const n=e=>{e.preventDefault(),f(),M(d.current.z*Math.exp(-e.deltaY*yt),e.clientX,e.clientY)};return t.addEventListener("wheel",n,{passive:!1}),()=>t.removeEventListener("wheel",n)},[l,f,M]),k(()=>f,[f]);const ct=t=>{if(f(),u.current.set(t.pointerId,{x:t.clientX,y:t.clientY}),t.currentTarget.setPointerCapture?.(t.pointerId),u.current.size===2){const[n,e]=[...u.current.values()];h.current={d0:Math.hypot(n.x-e.x,n.y-e.y),z0:d.current.z},y.current=null;return}if(t.pointerType==="touch"){const n=Date.now();if(n-S.current<zt){S.current=0,M(d.current.z>1.01?1:B,t.clientX,t.clientY);return}S.current=n}y.current={x0:t.clientX,f0:P.current,last:{x:t.clientX,y:t.clientY},speed:0}},it=t=>{if(!u.current.has(t.pointerId))return;if(u.current.set(t.pointerId,{x:t.clientX,y:t.clientY}),u.current.size===2&&h.current){const[o,s]=[...u.current.values()],i=Math.hypot(o.x-s.x,o.y-s.y);h.current.d0>0&&M(h.current.z0*i/h.current.d0,(o.x+s.x)/2,(o.y+s.y)/2);return}const n=y.current,e=b.current;if(!n||!e)return;const r=d.current;if(r.z>1.01){const o=e.clientWidth*(r.z-1)/2,s=e.clientHeight*(r.z-1)/2,i=Math.max(-o,Math.min(o,r.x+t.clientX-n.last.x)),E=Math.max(-s,Math.min(s,r.y+t.clientY-n.last.y));n.last={x:t.clientX,y:t.clientY},w({z:r.z,x:i,y:E});return}n.speed=t.clientX-n.last.x,n.last={x:t.clientX,y:t.clientY},_(G(n.f0,t.clientX-n.x0,e.clientWidth,m))},C=t=>{if(u.current.delete(t.pointerId),u.current.size>0)return;h.current=null;const n=y.current;y.current=null;const e=b.current;if(!n||!e||d.current.z>1.01||q())return;let r=Math.max(-K,Math.min(K,n.speed));const o=()=>{if(Math.abs(r)<gt)return;const s=G(P.current,r,e.clientWidth,m);_(s)===s&&(r*=bt,z.current=requestAnimationFrame(o))};z.current=requestAnimationFrame(o)},X=g.z>1.01,R=`translate(${g.x}px, ${g.y}px) scale(${g.z})`;return T(ut,{children:[l&&T("div",{ref:b,"data-spin-well":!0,"aria-hidden":"true",className:`absolute inset-0 z-20 select-none overflow-hidden bg-bg ${X?"cursor-move":"cursor-grab active:cursor-grabbing"}`,style:{touchAction:X?"none":"pan-y"},onPointerDown:ct,onPointerMove:it,onPointerUp:C,onPointerCancel:C,onDoubleClick:t=>{f(),M(d.current.z>1.01?1:B,t.clientX,t.clientY)},onTouchStart:t=>t.stopPropagation(),onTouchMove:t=>t.stopPropagation(),onTouchEnd:t=>t.stopPropagation(),onClick:t=>t.stopPropagation(),children:[p(tt,{sized:Q(c.frames[Y]),transform:R}),X&&p(tt,{sized:Mt(c.zoomFrames[Y]),transform:R}),p("span",{className:"pointer-events-none absolute bottom-8 left-1/2 -translate-x-1/2 whitespace-nowrap text-xs tracking-[0.04em] text-fg-dim max-view-tablet:bottom-auto max-view-tablet:top-4",children:"Drag to turn · scroll or pinch to zoom"}),L<m&&p("span",{className:"absolute inset-x-0 bottom-0 h-0.5 bg-fg/10",children:p("span",{className:"block h-full bg-fg transition-[width]",style:{width:`${L/m*100}%`}})})]}),T("button",{type:"button","data-spin-toggle":!0,"aria-pressed":l,"aria-label":l?`Show the photo of ${v}`:`Turn ${v} through 360°`,onClick:t=>{t.stopPropagation(),st()},className:"absolute bottom-6 left-6 z-30 inline-flex h-10 items-center gap-2 whitespace-nowrap border border-fg bg-bg px-4 text-xs font-medium uppercase tracking-[0.06em] text-fg transition-colors hover:bg-fg hover:text-bg max-view-tablet:bottom-4 max-view-tablet:left-4",children:[T("svg",{viewBox:"0 0 24 24","aria-hidden":"true",className:"h-4 w-4 fill-none stroke-current",strokeWidth:1.4,children:[p("path",{d:"M20 12a8 8 0 1 1-2.3-5.6"}),p("path",{d:"M20 4v4h-4"})]}),p("span",{children:l?"Show photo":"View 360°"})]})]})}function tt({sized:c,transform:v}){return p("img",{...c,sizes:j,alt:"",draggable:!1,className:"pointer-events-none absolute inset-[6%] h-[88%] w-[88%] object-contain",style:{transform:v}})}export{vt as default};
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
export declare const ACCESS_TOKEN_SUBPROTOCOL = "efficient-access-token";
|
|
2
|
+
export interface ChatSocketCredential {
|
|
3
|
+
access?: string | null;
|
|
4
|
+
guest?: string | null;
|
|
5
|
+
}
|
|
6
|
+
export interface ChatSocketTarget {
|
|
7
|
+
url: string;
|
|
8
|
+
protocols: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function chatSocketTarget(id: string, credential: ChatSocketCredential): ChatSocketTarget;
|
|
1
11
|
export declare function chatSocketUrl(id: string, token: string): string;
|
|
2
12
|
export declare function isOffStreamMessage(raw: unknown): boolean;
|
|
3
13
|
export interface ChatSocketOptions {
|
|
4
14
|
conversationId: string;
|
|
5
|
-
|
|
15
|
+
credential?: () => ChatSocketCredential;
|
|
16
|
+
token?: () => string;
|
|
6
17
|
onFrame: (raw: unknown) => void;
|
|
7
18
|
}
|
|
8
|
-
export declare function openChatSocket({ conversationId, token, onFrame }: ChatSocketOptions): () => void;
|
|
19
|
+
export declare function openChatSocket({ conversationId, credential, token, onFrame }: ChatSocketOptions): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{API_URL as
|
|
1
|
+
import{API_URL as m}from"./api/index.js";function l(){return(m||(typeof window<"u"?window.location.origin:"")).replace(/^http/,"ws")}const S="efficient-access-token";function h(o,e){const n=`${l()}/ws/chat/?conversation=${encodeURIComponent(o)}`;return e.access?{url:n,protocols:[S,e.access]}:e.guest?{url:`${n}&token=${encodeURIComponent(e.guest)}`,protocols:[]}:{url:n,protocols:[]}}function _(o,e){return`${l()}/ws/chat/?conversation=${o}&token=${encodeURIComponent(e)}`}const k=new Set(["employee","system"]);function g(o){if(typeof o!="string")return!1;try{const e=JSON.parse(o);return e.type==="chat_event"&&e.event==="message"&&typeof e.payload?.sender_role=="string"&&k.has(e.payload.sender_role)}catch{return!1}}function d({conversationId:o,credential:e,token:n,onFrame:u}){let s=!1,t=null,c,r=3e3;const a=()=>{if(s)return;const{url:f,protocols:p}=e?h(o,e()):{url:_(o,n?.()??""),protocols:[]};t=new WebSocket(f,p),t.onopen=()=>{r=3e3},t.onmessage=i=>u(i.data),t.onclose=()=>{s||(c=setTimeout(a,r),r=Math.min(r*2,3e4))},t.onerror=()=>t?.close()};return a(),()=>{s=!0,c&&clearTimeout(c),t?.close()}}export{S as ACCESS_TOKEN_SUBPROTOCOL,h as chatSocketTarget,_ as chatSocketUrl,g as isOffStreamMessage,d as openChatSocket};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_HERO_GALLERY_MODE as e,DEFAULT_HERO_IMAGE_FIT as l}from"../../../../sections/hero-gallery.js";const o={label:"Product Gallery",defaultProps:{galleryMode:e,imageFit:l}};export{o as ProductGalleryMeta};
|
|
1
|
+
import{DEFAULT_HERO_GALLERY_MODE as e,DEFAULT_HERO_IMAGE_FIT as l}from"../../../../sections/hero-gallery.js";const o={label:"Product Gallery",defaultProps:{galleryMode:e,imageFit:l,spin:{}}};export{o as ProductGalleryMeta};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import i from"../../../../../components/pdp-dynamic/DynamicProductGallery.js";import{parseHeroGalleryMode as o,parseHeroImageFit as t}from"../../../../sections/hero-gallery.js";import{parseSpinSets as a}from"../../../../sections/spin-sets.js";import{ProductGalleryMeta as m}from"./meta.js";const y={...m,render:e=>r(i,{editing:e.editor?.isEditing,galleryMode:o(e.galleryMode),imageFit:t(e.imageFit),spin:a(e.spin)})};export{y as ProductGalleryRender};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface SpinSet {
|
|
2
|
+
frames: string[];
|
|
3
|
+
zoomFrames: string[];
|
|
4
|
+
arc?: number;
|
|
5
|
+
}
|
|
6
|
+
export type SpinSets = Record<string, Record<string, SpinSet>>;
|
|
7
|
+
export declare const SPIN_MAX_ZOOM = 2;
|
|
8
|
+
export declare function parseSpinSets(v: unknown): SpinSets;
|
|
9
|
+
export declare function spinSetFor(sets: SpinSets, productSlug: string, finishName: string | undefined): SpinSet | null;
|
|
10
|
+
export declare function isFullTurn(set: SpinSet): boolean;
|
|
11
|
+
export declare function spinStartPosition(set: SpinSet): number;
|
|
12
|
+
export declare function spinFrameIndex(position: number, count: number, loop?: boolean): number;
|
|
13
|
+
export declare function spinClampPosition(position: number, count: number, loop: boolean): number;
|
|
14
|
+
export declare function spinPositionAfterDrag(start: number, dx: number, width: number, count: number): number;
|
|
15
|
+
export declare function clampSpinZoom(z: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const p=2,l=360,m=.9,f=r=>Array.isArray(r)&&r.length>0&&r.every(t=>typeof t=="string"&&t.length>0);function a(r){if(!r||typeof r!="object")return null;const{frames:t,zoomFrames:n}=r;if(!f(t)||!f(n)||t.length!==n.length)return null;const{arc:e}=r;return e===void 0?{frames:[...t],zoomFrames:[...n]}:typeof e!="number"||!(e>0&&e<=360)?null:{frames:[...t],zoomFrames:[...n],arc:e}}function h(r){if(!r||typeof r!="object"||Array.isArray(r))return{};const t={};for(const[n,e]of Object.entries(r)){if(!e||typeof e!="object"||Array.isArray(e))continue;const o={};for(const[s,u]of Object.entries(e)){const i=a(u);i&&(o[s]=i)}Object.keys(o).length>0&&(t[n]=o)}return t}function x(r,t,n){return n?r[t]?.[n]??null:null}function c(r){return r.arc===void 0||r.arc>=360}function y(r){return c(r)?0:Math.floor(r.frames.length/2)}function M(r,t,n=!0){return n?(Math.floor(r)%t+t)%t:Math.max(0,Math.min(t-1,Math.floor(r)))}function L(r,t,n){return n?r:Math.max(0,Math.min(t-1,r))}function _(r,t,n,e){return n<=0?r:r-t/n*e*.9}function g(r){return Math.max(1,Math.min(2,r))}export{p as SPIN_MAX_ZOOM,g as clampSpinZoom,c as isFullTurn,h as parseSpinSets,L as spinClampPosition,M as spinFrameIndex,_ as spinPositionAfterDrag,x as spinSetFor,y as spinStartPosition};
|