@lightspeed/crane-api 1.1.1 → 2.0.0
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 +25 -0
- package/dist/index.d.mts +12259 -428
- package/dist/index.d.ts +12259 -428
- package/dist/index.mjs +1 -1
- package/package.json +4 -1
- package/types.d.ts +9 -0
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSSRApp as le,getCurrentInstance as ue,ref as m,computed as o,reactive as T}from"vue";import{renderToString as se}from"vue/server-renderer";function y(e){return{app:le(e)}}const b=new Map;function d(){const e=(r,i,l,c,v,s,u)=>{b.set(r._uid,{context:m(i),content:m(l),design:m(c),defaults:m(v),site:m(s?.site??{}),category:m(s?.category),storeData:m(s?.storeData),globalDesign:m(u)})},t=(r,i,l,c,v,s)=>{const u=b.get(r._uid);u!==void 0&&(u.content.value=i,u.design.value=l,u.defaults.value=c,u.site.value=v.site??{},u.category.value=v.category,u.globalDesign.value=s,u.storeData.value=v.storeData)},n=ue()?.appContext.app._uid??-1,a=b.get(n);return{init:e,update:t,context:a?.context,content:a?.content,design:a?.design,defaults:a?.defaults,site:a?.site,category:a?.category,storeData:a?.storeData,globalDesign:a?.globalDesign}}function ce(e,t){return{init:()=>{const{app:n}=y(e);return t?.init?.(n),{mount:(a,r)=>{d().init(n,r.context,r.data.content,r.data.design,r.data.defaults,r.data.externalContent,r.context.globalDesign),t?.mount?.(n,a,r),n.mount(a)},update:a=>{d().update(n,a.data.content,a.data.design,a.data.defaults,a.data.externalContent,a.context.globalDesign),t?.update?.(n,a)},unmount:()=>{t?.unmount?.(n),n.unmount()}}}}}function ve(){return globalThis.window.instantsite}function de(e,t){return{init:()=>{const{app:n}=y(e);return t?.init?.(n),{render:async(a,r)=>(d().init(n,a,r.content,r.design,r.defaults,r.externalContent,a.globalDesign),t?.render?.(n,a,r),{html:await se(n,{context:a}),state:{context:a,data:r}})}}}}var D=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(D||{}),G=(e=>(e.COLOR="COLOR",e.GRADIENT="GRADIENT",e.NONE="NONE",e))(G||{}),N=(e=>(e.SOLID="SOLID",e.OUTLINE="OUTLINE",e.TEXT="TEXT",e))(N||{}),h=(e=>(e.SMALL="SMALL",e.MEDIUM="MEDIUM",e.LARGE="LARGE",e))(h||{}),w=(e=>(e.ROUND_CORNER="ROUND_CORNER",e.RECTANGLE="RECTANGLE",e.PILL="PILL",e))(w||{}),M=(e=>(e.COLOR="COLOR",e.GRADIENT="GRADIENT",e))(M||{}),U=(e=>(e.SECTION="SECTION",e.HEADER="HEADER",e.FOOTER="FOOTER",e))(U||{}),P=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e[e.Layout=3]="Layout",e[e.Asset=4]="Asset",e[e.SharedFiles=5]="SharedFiles",e))(P||{}),B=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.PageTemplateDescriptor=6]="PageTemplateDescriptor",e[e.TemplateAsset=7]="TemplateAsset",e[e.Layout=8]="Layout",e[e.LayoutSettings=9]="LayoutSettings",e[e.LayoutAsset=10]="LayoutAsset",e[e.SlotServer=11]="SlotServer",e[e.SlotClient=12]="SlotClient",e[e.SharedTranslation=13]="SharedTranslation",e))(B||{}),x=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE="GO_TO_STORE",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(x||{}),Ee=(e=>(e.TEXTAREA="TEXTAREA",e.INPUTBOX="INPUTBOX",e.SELECTBOX="SELECTBOX",e.IMAGE="IMAGE",e.TOGGLE="TOGGLE",e.BUTTON="BUTTON",e.DECK="DECK",e.MENU="MENU",e.NAVIGATION_MENU="NAVIGATION_MENU",e.LOGO="LOGO",e.INFO="INFO",e.DIVIDER="DIVIDER",e.CATEGORY_SELECTOR="CATEGORY_SELECTOR",e.PRODUCT_SELECTOR="PRODUCT_SELECTOR",e))(Ee||{}),k=(e=>(e.TEXT="TEXT",e.BUTTON="BUTTON",e.IMAGE="IMAGE",e.TOGGLE="TOGGLE",e.SELECTBOX="SELECTBOX",e.BACKGROUND="BACKGROUND",e.COLOR_PICKER="COLOR_PICKER",e.LOGO="LOGO",e.DIVIDER="DIVIDER",e))(k||{}),K=(e=>(e.PRODUCT="PRODUCT",e.CATALOG="CATALOG",e.CATEGORY="CATEGORY",e.HOME="HOME",e.CUSTOM="CUSTOM",e))(K||{}),$=(e=>(e.HOME="home",e.CATALOG="catalog",e.CATEGORY="category",e.PRODUCT="product",e))($||{}),Y=(e=>(e.CONTENT="Content",e.DESIGN="Design",e))(Y||{}),z=(e=>(e.ORIGINAL="original",e.WEBP_LOW_RES="webp-200x200",e.WEBP_HI_2X_RES="webp-2000x2000",e.MOBILE_WEBP_LOW_RES="cropped-webp-100x200",e.MOBILE_WEBP_HI_RES="cropped-webp-1000x2000",e))(z||{}),X=(e=>(e.TILE_LOADED="tile-loaded",e.TILE_UNLOADED="tile-unloaded",e))(X||{});const Te={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"},ge={PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},fe={CATEGORY_TITLE:"MAIN_TITLE",PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},Oe={TOP_BAR:"TOP_BAR",GALLERY:"GALLERY",SIDEBAR:"SIDEBAR",DESCRIPTION:"DESCRIPTION",REVIEW_LIST:"REVIEW_LIST",RELATED_PRODUCTS:"RELATED_PRODUCTS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},O={HYPER_LINK:"HYPER_LINK",SCROLL_TO_TILE:"SCROLL_TO_TILE",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"};function pe(e){if("tileId"in e)return e.tileId;if("tileIdForScroll"in e)return e.tileIdForScroll}function me(e){if("pageId"in e)return e.pageId;if("pageIdForNavigate"in e)return e.pageIdForNavigate}function Le(e){if("pageUrl"in e)return e.pageUrl;switch(me(e)){case"products":return"/products";case"cart":return"/cart";case"account":return"/account";case"search":return"/search";case"home":default:return"/"}}function _e(e){if("categoryId"in e)return e.categoryId}const F=(e,t,n)=>{if(!e||t)return;const{type:a,link:r,email:i,phone:l}=e,c=Le(e),v=_e(e);switch(a){case O.HYPER_LINK:if(r)return()=>window.open(r,"_blank");break;case O.GO_TO_STORE:case O.GO_TO_STORE_LINK:return()=>window.open("/products","_self");case O.GO_TO_CATEGORY:case O.GO_TO_CATEGORY_LINK:const s=n?.find(u=>u.id===v)?.url;return s===void 0?()=>window.open("/404","_self"):()=>window.open(s,"_self");case O.MAIL_LINK:if(i)return()=>window.open(`mailto:${i}`,"_self");break;case O.TEL_LINK:if(l)return()=>window.open(`tel:${l}`,"_self");break;case O.SCROLL_TO_TILE:if(typeof document<"u")return()=>{const u=pe(e);document.getElementById(`tile-${u}`)?.scrollIntoView()};break;case O.GO_TO_PAGE:if(c)return()=>window.open(c,"_self");break;default:console.error(`Unknown type of ActionLink: ${a}`)}};function Ie(e){return"title"in e&&"type"in e}function Ce(e,t,n,a){const r=o(()=>{const _=e.value[t];if(_!==void 0){if(Ie(_))return _;throw new Error(`Element ${t} is not action link`)}}),i=o(()=>r.value?.title),l=o(()=>r.value?.type),c=o(()=>r.value?.link),v=o(()=>r.value?.email),s=o(()=>r.value?.phone),u=o(()=>r.value?.tileId?`tile-${r.value?.tileId}`:null),E=o(()=>r.value?.type==="GO_TO_STORE_LINK"?"products":r.value?.pageId),g=o(()=>r.value?.pageUrl),I=o(()=>!!i.value),p=o(()=>!!c.value),L=F(r.value,n,a);return T({title:i,type:l,link:c,email:v,phone:s,tileDivId:u,pageId:E,pageUrl:g,hasTitle:I,hasLink:p,performAction:L})}function W(e,t){const n=d(),a=o(()=>!!n.site?.value?.isPreviewMode),r=o(()=>n.category?.value?.categories??[]),i=o(()=>t!==void 0?t:n.content.value!==void 0?n.content.value:{});return Ce(i,e,a.value,r.value)}function H({content:e,elementName:t,errorMessage:n,validatorFn:a}){return o(()=>{const r=e.value?.[t];if(r!==void 0){if(a(r))return r;throw new Error(n)}})}function Re(e){return typeof e=="object"&&e!==null&&"categories"in e}function Se(e){return o(()=>e.value.reduce((t,n)=>(t[n.id]=n,t),{}))}function be(e){return e!==void 0}function Ae(e){return!!e?.trim()}function ye({name:e,customName:t,selectionType:n}){return n==="ROOT"?e:Ae(t)?t:e}function De(e,t){return be(e)&&t}function V({itemId:e,id:t,alt:n,name:a,nameTranslated:r,customName:i,enabled:l,productsCount:c,url:v,imageUrl:s,thumbnailImageUrl:u,imageBorderInfo:E,selectionType:g}){return{itemId:e||t.toString(),id:t,alt:n,name:ye({name:a,customName:i,selectionType:g}),nameTranslated:r,label:a,enabled:l,url:v,productsCount:c,imageUrl:s,thumbnailImageUrl:u,imageBorderInfo:E,showCategory:De(t,l)}}function j(e,t,n){const a=d(),r=o(()=>t!==void 0?t:a.content.value),i=H({content:r,elementName:e,errorMessage:`Element ${e} is not a category selector type`,validatorFn:Re}),l=o(()=>n??a.storeData?.value),c=o(()=>i.value?.categories.selectionType??"ROOT"),v=o(()=>l.value?.categories??[]),s=o(()=>i.value?.categories?.categoryIds??[]),u=o(()=>{const I=Se(v);return c.value==="MANUAL"?i.value?.categories?.items?.map(p=>{const L=I.value[p.id];return V({...p,...L,selectionType:c.value})})??[]:l?.value?.categories.map(p=>V({...p,selectionType:c.value}))??[]}),E=o(()=>i.value!==void 0),g=o(()=>u.value!==void 0&&u.value.length>0);return T({categories:u,categoryIds:s,hasContent:E,hasCategories:g})}function Ge(e){return typeof e=="object"&&e!==null&&("products"in e||"product"in e)}function J(e,t,n){const a=d(),r=o(()=>t!==void 0?t:a.content.value),i=H({content:r,elementName:e,errorMessage:`Element ${e} is not a product selector type`,validatorFn:Ge}),l=o(()=>n??a.storeData?.value),c=o(()=>i.value?.products?.selectionType??"MANUAL"),v=o(()=>i.value?.products?.productIds??[]),s=o(()=>i.value?.product?.id),u=o(()=>i.value?.categoryId?parseInt(i.value.categoryId,10):void 0),E=o(()=>{if(v.value&&u.value&&c.value==="CATEGORY")return l?.value?.products.filter(_=>_?.defaultCategoryId===u.value)??[];if(typeof u.value=="number"&&u.value===0&&c.value==="CATEGORY")return l?.value?.products??[];const L=s.value?[s.value]:v.value??[];return l?.value?.products?.filter(_=>L.includes(_.id))??[]}),g=o(()=>l?.value?.categories.filter(L=>L.id===u?.value)??[]),I=o(()=>i.value!==void 0&&E.value.length>0),p=o(()=>E.value!==void 0&&E.value.length>0);return T({products:E,categories:g,categoryId:u,hasContent:I,hasProducts:p})}function Ne(e){return"bucket"in e&&"borderInfo"in e&&"set"in e}function C(e,t){const n=new RegExp(/^https?:\/\//);return e!=null&&n.test(e)?e:`${t}/${e}`}function he(e,t){const n=o(()=>{const s=e.value[t];if(s!==void 0){if(Ne(s))return s;throw new Error(`Element ${t} is not image`)}}),a=o(()=>n.value===void 0?"":d().context.value.imageBuckets?.[n.value?.bucket]),r=o(()=>n.value!==void 0),i=o(()=>C(n.value?.set?.["cropped-webp-100x200"]?.url,a.value)),l=o(()=>C(n.value?.set?.["cropped-webp-1000x2000"]?.url,a.value)),c=o(()=>C(n.value?.set?.["webp-200x200"]?.url,a.value)),v=o(()=>C(n.value?.set?.["webp-2000x2000"]?.url,a.value));return T({hasContent:r,lowResolutionMobileImage:i,highResolutionMobileImage:l,lowResolutionDesktopImage:c,highResolutionDesktopImage:v})}function q(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return he(a,e)}function we(e,t){const n=o(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not inputbox`)}}),a=o(()=>n.value!==void 0&&n.value.length>0),r=o(()=>n.value);return T({hasContent:a,value:r})}function Q(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return we(a,e)}function Me(e,t){const n=o(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not selectbox`)}}),a=o(()=>n.value!==void 0),r=o(()=>n.value);return T({hasContent:a,value:r})}function Z(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return Me(a,e)}function Ue(e,t){const n=o(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not textarea`)}}),a=o(()=>n.value!==void 0),r=o(()=>n.value);return T({hasContent:a,value:r})}function ee(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return Ue(a,e)}function Pe(e){return"enabled"in e}function Be(e,t){const n=o(()=>{const i=e.value[t];if(i!==void 0){if(Pe(i))return i;throw new Error(`Element ${t} is not toggle`)}}),a=o(()=>n.value!==void 0),r=o(()=>n.value?.enabled);return T({hasContent:a,value:r})}function te(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return Be(a,e)}var ne=(e=>(e.INPUTBOX="INPUTBOX",e.TEXTAREA="TEXTAREA",e.BUTTON="BUTTON",e.IMAGE="IMAGE",e.TOGGLE="TOGGLE",e.SELECTBOX="SELECTBOX",e.CATEGORY_SELECTOR="CATEGORY_SELECTOR",e.PRODUCT_SELECTOR="PRODUCT_SELECTOR",e))(ne||{});function xe(e){if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.cards)&&t.cards.every(n=>typeof n.settings=="object"&&n.settings!==null)}function ke(e,t,n,a){if(e==null)throw Error("Could not get a reactive ref for undefined Card");const r=e.settings[n];if(r===void 0)return r;switch(t){case"TEXTAREA":return ee(n,e.settings);case"INPUTBOX":return Q(n,e.settings);case"SELECTBOX":return Z(n,e.settings);case"IMAGE":return q(n,e.settings);case"TOGGLE":return te(n,e.settings);case"BUTTON":return W(n,e.settings);case"CATEGORY_SELECTOR":return j(n,e.settings,a);case"PRODUCT_SELECTOR":return J(n,e.settings,a);default:return}}function Ke(e){const t=d(),n=o(()=>t.storeData?.value),a=o(()=>{const l=t.content.value[e];if(l!==void 0){if(xe(l))return l;throw new Error(`Element ${e} is not of DECK type`)}}),r=o(()=>a.value!==void 0&&a.value.cards.length>0),i=o(()=>a.value?.cards);return T({hasContent:r,cards:i,getReactiveRef:(l,c,v)=>ke(l,c,v,n.value)})}function $e(e){return"type"in e&&("text"in e||"image"in e)}function R(e,t){const n=new RegExp(/^https?:\/\//);return e!==void 0&&n.test(e)?e:`${t}/${e}`}function Ye(){const e=d(),t=o(()=>{const l=e.content.value.logo;if(l!==void 0){if($e(l))return l;throw new Error("Element logo is not LOGO")}}),n=o(()=>t.value?.type),a=o(()=>t.value?.text),r=o(()=>t.value?.image===void 0?"":e.context.value.imageBuckets?.[t.value.image.bucket]),i=o(()=>({lowResolutionMobileImage:R(t.value?.image?.set?.["cropped-webp-100x200"]?.url,r.value),highResolutionMobileImage:R(t.value?.image?.set?.["cropped-webp-1000x2000"]?.url,r.value),lowResolutionDesktopImage:R(t.value?.image?.set?.["webp-200x200"]?.url,r.value),highResolutionDesktopImage:R(t.value?.image?.set?.["webp-2000x2000"]?.url,r.value)}));return T({type:n,text:a,image:i})}function ze(e){return e!==null&&"items"in e}function oe(e){const t=d(),n=o(()=>{const l=t.content.value[e];if(l!==void 0){if(ze(l))return l;throw new Error(`Element ${e} is not an menu`)}}),a=o(()=>!!t.site?.value?.isPreviewMode),r=o(()=>n.value!==void 0),i=o(()=>n.value?.items?n.value.items.map(l=>({...l,performAction:F(l,a.value)})):[]);return T({hasContent:r,items:i})}const Xe="menu";function Fe(){return oe(Xe)}function We(){return globalThis.craneSharedTranslation??{}}function He(){const e=d(),t=o(()=>e.site?.value),n=o(()=>We()),a=o(()=>{const r=t.value?.languages;return r?r.find(i=>i.selected)?.code??r.find(i=>i.main)?.code??"en":"en"});return{t:r=>{const i=n.value;if(!i||Object.keys(i).length===0)return r;const l=a.value,c=i[l]?.[r];if(c!==void 0)return c;if(l!=="en"){const v=i.en?.[r];if(v!==void 0)return v}return r},currentLanguageCode:a}}function ae(e,t){if(t===void 0)return;if(!t.startsWith("global."))return t.replaceAll("_"," ");const n=t.split(".").at(2);if(n!==void 0)return e.fontFamily?e.fontFamily[n].replaceAll("_"," "):void 0}function S(e,t,n){return t?ae(e,t):ae(e,n)}function re(e,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const n=t.split(".").at(2);if(n!==void 0)return e.textSize?e.textSize[n]:void 0}function A(e,t,n){return t?re(e,t):re(e,n)}function ie(e,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const n=t.split(".").at(2);if(n!==void 0)return e.color?e.color[n]:void 0}function f(e,t,n){return t?ie(e,t):ie(e,n)}function Ve(e,t,n){return{visible:t?.visible??n?.visible??!1,width:t?.width??n?.width??1,color:f(e,t?.color,n?.color)}}function je(e){const t=d(),n=o(()=>{const r=t.design.value[e],i=t.defaults.value[e],l=t.globalDesign.value;return{background:{type:r?.background?.type??i?.background?.type,solid:{color:f(l,r?.background?.solid?.color,i?.background?.solid?.color)},gradient:{fromColor:f(l,r?.background?.gradient?.fromColor,i?.background?.gradient?.fromColor),toColor:f(l,r?.background?.gradient?.toColor,i?.background?.gradient?.toColor)}}}}),a=o(()=>n.value?.background);return T({background:a})}function Je(e){const t=d(),n=o(()=>{const s=t.design.value[e],u=t.defaults.value[e],E=t.globalDesign.value;return{appearance:s?.appearance??u?.appearance,font:S(E,s?.font,u?.font),size:s?.size??u?.size,style:s?.style??u?.style,color:f(E,s?.color,u?.color),visible:s?.visible??u?.visible??!1}}),a=o(()=>n.value?.appearance),r=o(()=>n.value?.font),i=o(()=>n.value?.size),l=o(()=>n.value?.style),c=o(()=>n.value?.color),v=o(()=>n.value?.visible);return T({appearance:a,font:r,size:i,style:l,color:c,visible:v})}function qe(e){const t=d(),n=o(()=>{const i=t.design.value[e],l=t.defaults.value[e],c=t.globalDesign.value;return{overlay:{type:i?.overlay?.type??l?.overlay?.type,solid:{color:f(c,i?.overlay?.solid?.color,l?.overlay?.solid?.color)},gradient:{fromColor:f(c,i?.overlay?.gradient?.fromColor,l?.overlay?.gradient?.fromColor),toColor:f(c,i?.overlay?.gradient?.toColor,l?.overlay?.gradient?.toColor)}},visible:i?.visible??l?.visible??!1}}),a=o(()=>n.value?.overlay),r=o(()=>n.value?.visible);return T({overlay:a,visible:r})}function Qe(){const e=d(),t=o(()=>e.design.value.layout),n=o(()=>t.value);return T({layout:n})}function Ze(){const e=d();return o(()=>{const t=e.design.value.logo,n=e.defaults.value.logo,a=e.globalDesign.value;return{font:S(a,t?.font,n?.font),size:A(a,t?.size,n?.size),bold:t?.bold??n?.bold,italic:t?.italic??n?.italic,color:f(a,t?.color,n?.color),visible:t?.visible??n?.visible??!1,spacing:t?.spacing??n?.spacing??0,capitalization:t?.capitalization??n?.capitalization??"none",frame:Ve(a,t?.frame,n?.frame)}})}function et(e){const t=d(),n=o(()=>{const r=t.design.value[e],i=t.defaults.value[e];return{value:r?.value??i?.value}}),a=o(()=>n.value?.value);return T({value:a})}function tt(e){const t=d(),n=o(()=>{const s=t.design.value[e],u=t.defaults.value[e],E=t.globalDesign.value;return{font:S(E,s?.font,u?.font),size:A(E,s?.size,u?.size),bold:s?.bold??u?.bold,italic:s?.italic??u?.italic,color:f(E,s?.color,u?.color),visible:s?.visible??u?.visible??!1}}),a=o(()=>n.value?.font),r=o(()=>n.value?.size),i=o(()=>n.value?.bold),l=o(()=>n.value?.italic),c=o(()=>n.value?.color),v=o(()=>n.value?.visible);return T({font:a,size:r,bold:i,italic:l,color:c,visible:v})}function nt(e){const t=d(),n=o(()=>{const u=t.design.value[e],E=t.defaults.value[e],g=t.globalDesign.value;return{font:S(g,u?.font,E?.font),size:A(g,u?.size,E?.size),bold:u?.bold??E?.bold,italic:u?.italic??E?.italic,color:f(g,u?.color,E?.color),visible:u?.visible??E?.visible??!1,whiteSpace:"pre-wrap"}}),a=o(()=>n.value?.font),r=o(()=>n.value?.size),i=o(()=>n.value?.bold),l=o(()=>n.value?.italic),c=o(()=>n.value?.color),v=o(()=>n.value?.visible),s=o(()=>n.value?.whiteSpace);return T({font:a,size:r,bold:i,italic:l,color:c,visible:v,whiteSpace:s})}function ot(e){const t=d(),n=o(()=>{const r=t.design.value[e],i=t.defaults.value[e];return{enabled:r?.enabled??i?.enabled}}),a=o(()=>n.value?.enabled);return T({enabled:a})}export{x as ActionLinkTypeEnum,M as BackgroundStyleEnum,N as ButtonAppearanceEnum,w as ButtonShapeEnum,h as ButtonSizeEnum,D as ButtonTypeEnum,ge as CatalogLayoutSlot,fe as CategoryLayoutSlot,B as ConfigTypeEnum,k as DesignEditorType,ne as EditorTypes,z as ImageSet,X as InstantsiteJsEvent,G as OverlayTypeEnum,P as PluginTypeEnum,Oe as ProductLayoutSlot,$ as ReservedTemplatePageNameEnum,U as SectionTypeEnum,Te as TemplateCategoriesList,K as TemplatePageEnum,Y as ValidationTypeEnum,ce as createVueClientApp,de as createVueServerApp,je as useBackgroundElementDesign,W as useButtonElementContent,Je as useButtonElementDesign,j as useCategorySelectorElementContent,Ke as useDeckElementContent,q as useImageElementContent,qe as useImageElementDesign,Q as useInputboxElementContent,ve as useInstantsiteJsApi,Qe as useLayoutElementDesign,Ye as useLogoElementContent,Ze as useLogoElementDesign,oe as useMenuElementContent,Fe as useNavigationMenuElementContent,J as useProductSelectorElementContent,Z as useSelectboxElementContent,et as useSelectboxElementDesign,tt as useTextElementDesign,ee as useTextareaElementContent,nt as useTextareaElementDesign,te as useToggleElementContent,ot as useToggleElementDesign,He as useTranslation,d as useVueBaseProps};
|
|
1
|
+
import{createSSRApp as Oe,getCurrentInstance as Te,ref as _,computed as a,reactive as O}from"vue";import{renderToString as ge}from"vue/server-renderer";import{z as p}from"zod";function M(e){return{app:Oe(e)}}const w=new Map;function E(){const e=(r,i,u,d,v,c,s,l)=>{w.set(r._uid,{context:_(i),content:_(u),design:_(d),defaults:_(v),site:_(c?.site??{}),category:_(c?.category),storeData:_(c?.storeData),globalDesign:_(s),tileId:_(l??void 0)})},t=(r,i,u,d,v,c,s)=>{const l=w.get(r._uid);l!==void 0&&(l.content.value=i,l.design.value=u,l.defaults.value=d,l.site.value=v.site??{},l.category.value=v.category,l.globalDesign.value=c,l.storeData.value=v.storeData,l.tileId.value=s)},n=Te()?.appContext.app._uid??-1,o=w.get(n);return{init:e,update:t,context:o?.context,content:o?.content,design:o?.design,defaults:o?.defaults,site:o?.site,category:o?.category,storeData:o?.storeData,globalDesign:o?.globalDesign,tileId:o?.tileId}}function fe(e,t){return{init:()=>{const{app:n}=M(e);return t?.init?.(n),{mount:(o,r)=>{E().init(n,r.context,r.data.content,r.data.design,r.data.defaults,r.data.externalContent,r.context.globalDesign,r.data.tileId),t?.mount?.(n,o,r),n.mount(o)},update:o=>{E().update(n,o.data.content,o.data.design,o.data.defaults,o.data.externalContent,o.context.globalDesign,o.data.tileId),t?.update?.(n,o)},unmount:()=>{t?.unmount?.(n),n.unmount()}}}}}function pe(){return globalThis.window.instantsite}function me(e,t){return{init:()=>{const{app:n}=M(e);return t?.init?.(n),{render:async(o,r)=>(E().init(n,o,r.content,r.design,r.defaults,r.externalContent,o.globalDesign,r.tileId),t?.render?.(n,o,r),{html:await ge(n,{context:o}),state:{context:o,data:r}})}}}}const U={SCROLL_TO_TILE:"SCROLL_TO_TILE",HYPER_LINK:"HYPER_LINK",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"};p.enum(Object.values(U));const Ie=U,x={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};p.enum(Object.values(x));const Le=x,P={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};p.enum(Object.values(P));const _e=P,k={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};p.enum(Object.values(k));const Ce=k,K={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};p.enum(Object.values(K));const Re=K,$={COLOR:"COLOR",GRADIENT:"GRADIENT"};p.enum(Object.values($));const be=$,X={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"};p.enum(Object.values(X));const ye=X;var z=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e[e.Layout=3]="Layout",e[e.Asset=4]="Asset",e[e.SharedFiles=5]="SharedFiles",e))(z||{}),Y=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.PageTemplateDescriptor=6]="PageTemplateDescriptor",e[e.TemplateAsset=7]="TemplateAsset",e[e.Layout=8]="Layout",e[e.LayoutSettings=9]="LayoutSettings",e[e.LayoutAsset=10]="LayoutAsset",e[e.SlotServer=11]="SlotServer",e[e.SlotClient=12]="SlotClient",e[e.SharedTranslation=13]="SharedTranslation",e[e.CollectionDescriptor=14]="CollectionDescriptor",e[e.CollectionAsset=15]="CollectionAsset",e))(Y||{}),F=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE="GO_TO_STORE",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(F||{});const I={TEXTAREA:"TEXTAREA",INPUTBOX:"INPUTBOX",SELECTBOX:"SELECTBOX",IMAGE:"IMAGE",TOGGLE:"TOGGLE",BUTTON:"BUTTON",DECK:"DECK",MENU:"MENU",NAVIGATION_MENU:"NAVIGATION_MENU",LOGO:"LOGO",INFO:"INFO",DIVIDER:"DIVIDER",PRODUCT_SELECTOR:"PRODUCT_SELECTOR",CATEGORY_SELECTOR:"CATEGORY_SELECTOR"};p.enum(Object.values(I));const V={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER"};p.enum(Object.values(V));const Se=V,j={CONTENT:"Content",DESIGN:"Design"};p.enum(Object.values(j));const Ae=j,W={TEXT:"TEXT",IMAGE:"IMAGE"};p.enum(Object.values(W));const Ge=W;var H=(e=>(e.ORIGINAL="original",e.WEBP_LOW_RES="webp-200x200",e.WEBP_HI_2X_RES="webp-2000x2000",e.MOBILE_WEBP_LOW_RES="cropped-webp-100x200",e.MOBILE_WEBP_HI_RES="cropped-webp-1000x2000",e))(H||{}),J=(e=>(e.TILE_LOADED="tile-loaded",e.TILE_UNLOADED="tile-unloaded",e))(J||{});const Ne={PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},De={CATEGORY_TITLE:"MAIN_TITLE",PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},he={TOP_BAR:"TOP_BAR",GALLERY:"GALLERY",SIDEBAR:"SIDEBAR",DESCRIPTION:"DESCRIPTION",REVIEW_LIST:"REVIEW_LIST",RELATED_PRODUCTS:"RELATED_PRODUCTS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},q={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"};p.enum(Object.values(q));const we=q;function Q(e){if(!e||e.length===0)return[];const t=[];function n(o){if(t.push({id:o.id,name:o.name,url:o.urlPath}),o.children&&o.children.length>0)for(const r of o.children)n(r)}for(const o of e)n(o);return t}const C={HYPER_LINK:"HYPER_LINK",SCROLL_TO_TILE:"SCROLL_TO_TILE",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"};function Be(e){if("tileId"in e)return e.tileId;if("tileIdForScroll"in e)return e.tileIdForScroll}function Me(e){if("pageId"in e)return e.pageId;if("pageIdForNavigate"in e)return e.pageIdForNavigate}function Ue(e,t){if("pageUrl"in e)return e.pageUrl;const n=Me(e);switch(n){case"products":return"/products";case"cart":return"/cart";case"account":return"/account";case"search":return"/search";case"home":return"/"}if(t){const o=t.find(r=>r.pageId===n);if(o)return o.url}return"/"}function xe(e){if("categoryId"in e)return e.categoryId}const Z=(e,t,n)=>{if(!e||t)return;const{type:o,link:r,email:i,phone:u}=e,d=E().site?.value?.pages,v=Ue(e,d),c=xe(e);switch(o){case C.HYPER_LINK:if(r){const l=e.linkTarget??"_blank";return()=>window.open(r,l)}break;case C.GO_TO_STORE:case C.GO_TO_STORE_LINK:return()=>window.open("/products","_self");case C.GO_TO_CATEGORY:case C.GO_TO_CATEGORY_LINK:const s=n?.find(l=>l.id===c)?.url;return s===void 0?()=>window.open("/404","_self"):()=>window.open(s,"_self");case C.MAIL_LINK:if(i)return()=>window.open(`mailto:${i}`,"_self");break;case C.TEL_LINK:if(u)return()=>window.open(`tel:${u}`,"_self");break;case C.SCROLL_TO_TILE:if(typeof document<"u")return()=>{const l=Be(e);document.getElementById(`tile-${l}`)?.scrollIntoView()};break;case C.GO_TO_PAGE:if(v)return()=>window.open(v,"_self");break;default:console.error(`Unknown type of ActionLink: ${o}`)}};function Pe(e){return"title"in e&&"type"in e}function ke(e,t,n,o){const r=a(()=>{const L=e.value[t];if(L!==void 0){if(Pe(L))return L;throw new Error(`Element ${t} is not action link`)}}),i=a(()=>r.value?.title),u=a(()=>r.value?.type),d=a(()=>r.value?.link),v=a(()=>r.value?.email),c=a(()=>r.value?.phone),s=a(()=>r.value?.tileId?`tile-${r.value?.tileId}`:null),l=a(()=>r.value?.type==="GO_TO_STORE_LINK"?"products":r.value?.pageId),T=a(()=>r.value?.pageUrl),G=a(()=>!!i.value),S=a(()=>!!d.value),A=Z(r.value,n,o);return O({title:i,type:u,link:d,email:v,phone:c,tileDivId:s,pageId:l,pageUrl:T,hasTitle:G,hasLink:S,performAction:A})}function ee(e,t){const n=E(),o=a(()=>!!n.site?.value?.isPreviewMode),r=a(()=>{const u=n.category?.value?.categoryTree;return Q(u)}),i=a(()=>t!==void 0?t:n.content.value!==void 0?n.content.value:{});return ke(i,e,o.value,r.value)}function te({content:e,elementName:t,errorMessage:n,validatorFn:o}){return a(()=>{const r=e.value?.[t];if(r!==void 0){if(o(r))return r;throw new Error(n)}})}function Ke(e){return typeof e=="object"&&e!==null&&"categories"in e}function $e(e){return a(()=>e.value.reduce((t,n)=>(t[n.id]=n,t),{}))}function Xe(e){return e!==void 0}function ze(e){return!!e?.trim()}function Ye({name:e,customName:t,selectionType:n}){return n==="ROOT"?e:ze(t)?t:e}function Fe(e,t){return Xe(e)&&t}function ne({itemId:e,id:t,alt:n,name:o,nameTranslated:r,customName:i,enabled:u,productsCount:d,url:v,imageUrl:c,thumbnailImageUrl:s,imageBorderInfo:l,selectionType:T}){return{itemId:e||t.toString(),id:t,alt:n,name:Ye({name:o,customName:i,selectionType:T}),nameTranslated:r,label:o,enabled:u,url:v,productsCount:d,imageUrl:c,thumbnailImageUrl:s,imageBorderInfo:l,showCategory:Fe(t,u)}}function oe(e,t,n){const o=E(),r=a(()=>t!==void 0?t:o.content.value),i=te({content:r,elementName:e,errorMessage:`Element ${e} is not a category selector type`,validatorFn:Ke}),u=a(()=>n??o.storeData?.value),d=a(()=>i.value?.categories.selectionType??"ROOT"),v=a(()=>u.value?.categories??[]),c=a(()=>i.value?.categories?.categoryIds??[]),s=a(()=>{const G=$e(v);return d.value==="MANUAL"?i.value?.categories?.items?.map(S=>{const A=G.value[S.id];return ne({...S,...A,selectionType:d.value})})??[]:u?.value?.categories.map(S=>ne({...S,selectionType:d.value}))??[]}),l=a(()=>i.value!==void 0),T=a(()=>s.value!==void 0&&s.value.length>0);return O({categories:s,categoryIds:c,hasContent:l,hasCategories:T})}function Ve(e){return typeof e=="object"&&e!==null&&("products"in e||"product"in e)}function ae(e,t,n){const o=E(),r=a(()=>t!==void 0?t:o.content.value),i=te({content:r,elementName:e,errorMessage:`Element ${e} is not a product selector type`,validatorFn:Ve}),u=a(()=>n??o.storeData?.value),d=a(()=>i.value?.products?.selectionType??"MANUAL"),v=a(()=>i.value?.products?.productIds??[]),c=a(()=>i.value?.product?.id),s=a(()=>typeof i.value?.categoryId=="number"?i.value.categoryId:void 0),l=a(()=>{if(d.value==="CATEGORY")return s.value===0?u?.value?.products.filter(L=>L?.defaultCategoryId===0)??[]:u?.value?.products.filter(L=>s.value&&L?.categoryIds?.includes(s.value))??[];const A=c.value?[c.value]:v.value??[];return u?.value?.products?.filter(L=>A.includes(L.id))??[]}),T=a(()=>u?.value?.categories.filter(A=>A.id===s?.value)??[]),G=a(()=>i.value!==void 0&&l.value.length>0),S=a(()=>l.value!==void 0&&l.value.length>0);return O({products:l,categories:T,categoryId:s,hasContent:G,hasProducts:S})}function je(e){return"bucket"in e&&"borderInfo"in e&&"set"in e}function N(e,t){const n=new RegExp(/^https?:\/\//);return e!=null&&n.test(e)?e:`${t}/${e}`}function We(e,t){const n=a(()=>{const c=e.value[t];if(c!==void 0){if(je(c))return c;throw new Error(`Element ${t} is not image`)}}),o=a(()=>n.value===void 0?"":E().context.value.imageBuckets?.[n.value?.bucket]),r=a(()=>n.value!==void 0),i=a(()=>N(n.value?.set?.["cropped-webp-100x200"]?.url,o.value)),u=a(()=>N(n.value?.set?.["cropped-webp-1000x2000"]?.url,o.value)),d=a(()=>N(n.value?.set?.["webp-200x200"]?.url,o.value)),v=a(()=>N(n.value?.set?.["webp-2000x2000"]?.url,o.value));return O({hasContent:r,lowResolutionMobileImage:i,highResolutionMobileImage:u,lowResolutionDesktopImage:d,highResolutionDesktopImage:v})}function re(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return We(o,e)}function He(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not inputbox`)}}),o=a(()=>n.value!==void 0&&n.value.length>0),r=a(()=>n.value);return O({hasContent:o,value:r})}function ie(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return He(o,e)}function Je(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not selectbox`)}}),o=a(()=>n.value!==void 0),r=a(()=>n.value);return O({hasContent:o,value:r})}function le(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return Je(o,e)}function qe(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not textarea`)}}),o=a(()=>n.value!==void 0),r=a(()=>n.value);return O({hasContent:o,value:r})}function ue(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return qe(o,e)}function Qe(e){return"enabled"in e}function Ze(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(Qe(i))return i;throw new Error(`Element ${t} is not toggle`)}}),o=a(()=>n.value!==void 0),r=a(()=>n.value?.enabled);return O({hasContent:o,value:r})}function se(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return Ze(o,e)}function et(e){if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.cards)&&t.cards.every(n=>typeof n.settings=="object"&&n.settings!==null)}function tt(e,t,n,o){if(e==null)throw Error("Could not get a reactive ref for undefined Card");const r=e.settings[n];if(r===void 0)return r;switch(t){case I.TEXTAREA:return ue(n,e.settings);case I.INPUTBOX:return ie(n,e.settings);case I.SELECTBOX:return le(n,e.settings);case I.IMAGE:return re(n,e.settings);case I.TOGGLE:return se(n,e.settings);case I.BUTTON:return ee(n,e.settings);case I.CATEGORY_SELECTOR:return oe(n,e.settings,o);case I.PRODUCT_SELECTOR:return ae(n,e.settings,o);default:return}}function nt(e){const t=E(),n=a(()=>t.storeData?.value),o=a(()=>{const u=t.content.value[e];if(u!==void 0){if(et(u))return u;throw new Error(`Element ${e} is not of DECK type`)}}),r=a(()=>o.value!==void 0&&o.value.cards.length>0),i=a(()=>o.value?.cards);return O({hasContent:r,cards:i,getReactiveRef:(u,d,v)=>tt(u,d,v,n.value)})}function ot(e){return"type"in e&&("text"in e||"image"in e)}function D(e,t){const n=new RegExp(/^https?:\/\//);return e!==void 0&&n.test(e)?e:`${t}/${e}`}function at(){const e=E(),t=a(()=>{const u=e.content.value.logo;if(u!==void 0){if(ot(u))return u;throw new Error("Element logo is not LOGO")}}),n=a(()=>t.value?.type),o=a(()=>t.value?.text),r=a(()=>t.value?.image===void 0?"":e.context.value.imageBuckets?.[t.value.image.bucket]),i=a(()=>({lowResolutionMobileImage:D(t.value?.image?.set?.["cropped-webp-100x200"]?.url,r.value),highResolutionMobileImage:D(t.value?.image?.set?.["cropped-webp-1000x2000"]?.url,r.value),lowResolutionDesktopImage:D(t.value?.image?.set?.["webp-200x200"]?.url,r.value),highResolutionDesktopImage:D(t.value?.image?.set?.["webp-2000x2000"]?.url,r.value)}));return O({type:n,text:o,image:i})}function rt(e){return e!==null&&"items"in e}function ce(e){const t=E(),n=a(()=>{const l=t.content.value[e];if(l!==void 0){if(rt(l))return l;throw new Error(`Element ${e} is not an menu`)}}),o=a(()=>!!t.site?.value?.isPreviewMode),r=a(()=>{const l=t.category?.value?.categoryTree;return Q(l)}),i=a(()=>n.value!==void 0);function u(l){if(l)try{return new URL(l).pathname}catch{return l}}function d(l){return l?.map(T=>({...T,url:u(T.url)??T.url}))}const v=a(()=>d(r.value));function c(l){const T=Z(l,o.value,v.value);return{...l,performAction:T,nestedItems:l.nestedItems?.map(c)}}const s=a(()=>n.value?.items?n.value.items.map(c):[]);return O({hasContent:i,items:s})}const it="menu";function lt(){return ce(it)}function ut(){return globalThis.craneSharedTranslation??{}}function st(){const e=E(),t=a(()=>e.site?.value),n=a(()=>ut()),o=a(()=>{const r=t.value?.languages;return r?r.find(i=>i.selected)?.code??r.find(i=>i.main)?.code??"en":"en"});return{t:r=>{const i=n.value;if(!i||Object.keys(i).length===0)return r;const u=o.value,d=i[u]?.[r];if(d!==void 0)return d;if(u!=="en"){const v=i.en?.[r];if(v!==void 0)return v}return r},currentLanguageCode:o}}function de(e,t){if(t===void 0)return;if(!t.startsWith("global."))return t.replaceAll("_"," ");const n=t.split(".").at(2);if(n!==void 0)return e.fontFamily?e.fontFamily[n].replaceAll("_"," "):void 0}function h(e,t,n){return t?de(e,t):de(e,n)}function ve(e,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const n=t.split(".").at(2);if(n!==void 0)return e.textSize?e.textSize[n]:void 0}function B(e,t,n){return t?ve(e,t):ve(e,n)}function Ee(e,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const n=t.split(".").at(2);if(n!==void 0)return e.color?e.color[n]:void 0}function m(e,t,n){return t?Ee(e,t):Ee(e,n)}function ct(e,t,n){return{visible:t?.visible??n?.visible??!1,width:t?.width??n?.width??1,color:m(e,t?.color,n?.color)}}function dt(e){const t=E(),n=a(()=>{const r=t.design.value[e],i=t.defaults.value[e],u=t.globalDesign.value;return{background:{type:r?.background?.type??i?.background?.type,solid:{color:m(u,r?.background?.solid?.color,i?.background?.solid?.color)},gradient:{fromColor:m(u,r?.background?.gradient?.fromColor,i?.background?.gradient?.fromColor),toColor:m(u,r?.background?.gradient?.toColor,i?.background?.gradient?.toColor)}}}}),o=a(()=>n.value?.background);return O({background:o})}function vt(e){const t=E(),n=a(()=>{const c=t.design.value[e],s=t.defaults.value[e],l=t.globalDesign.value;return{appearance:c?.appearance??s?.appearance,font:h(l,c?.font,s?.font),size:c?.size??s?.size,style:c?.style??s?.style,color:m(l,c?.color,s?.color),visible:c?.visible??s?.visible??!1}}),o=a(()=>n.value?.appearance),r=a(()=>n.value?.font),i=a(()=>n.value?.size),u=a(()=>n.value?.style),d=a(()=>n.value?.color),v=a(()=>n.value?.visible);return O({appearance:o,font:r,size:i,style:u,color:d,visible:v})}function Et(e){const t=E(),n=a(()=>{const i=t.design.value[e],u=t.defaults.value[e],d=t.globalDesign.value;return{overlay:{type:i?.overlay?.type??u?.overlay?.type,solid:{color:m(d,i?.overlay?.solid?.color,u?.overlay?.solid?.color)},gradient:{fromColor:m(d,i?.overlay?.gradient?.fromColor,u?.overlay?.gradient?.fromColor),toColor:m(d,i?.overlay?.gradient?.toColor,u?.overlay?.gradient?.toColor)}},visible:i?.visible??u?.visible??!1}}),o=a(()=>n.value?.overlay),r=a(()=>n.value?.visible);return O({overlay:o,visible:r})}function Ot(){const e=E(),t=a(()=>e.design.value.layout),n=a(()=>t.value);return O({layout:n})}function Tt(){const e=E();return a(()=>{const t=e.design.value.logo,n=e.defaults.value.logo,o=e.globalDesign.value;return{font:h(o,t?.font,n?.font),size:B(o,t?.size,n?.size),bold:t?.bold??n?.bold,italic:t?.italic??n?.italic,color:m(o,t?.color,n?.color),visible:t?.visible??n?.visible??!1,spacing:t?.spacing??n?.spacing??0,capitalization:t?.capitalization??n?.capitalization??"none",frame:ct(o,t?.frame,n?.frame)}})}function gt(e){const t=E(),n=a(()=>{const r=t.design.value[e],i=t.defaults.value[e];return{value:r?.value??i?.value}}),o=a(()=>n.value?.value);return O({value:o})}function ft(e){const t=E(),n=a(()=>{const c=t.design.value[e],s=t.defaults.value[e],l=t.globalDesign.value;return{font:h(l,c?.font,s?.font),size:B(l,c?.size,s?.size),bold:c?.bold??s?.bold,italic:c?.italic??s?.italic,color:m(l,c?.color,s?.color),visible:c?.visible??s?.visible??!1}}),o=a(()=>n.value?.font),r=a(()=>n.value?.size),i=a(()=>n.value?.bold),u=a(()=>n.value?.italic),d=a(()=>n.value?.color),v=a(()=>n.value?.visible);return O({font:o,size:r,bold:i,italic:u,color:d,visible:v})}function pt(e){const t=E(),n=a(()=>{const s=t.design.value[e],l=t.defaults.value[e],T=t.globalDesign.value;return{font:h(T,s?.font,l?.font),size:B(T,s?.size,l?.size),bold:s?.bold??l?.bold,italic:s?.italic??l?.italic,color:m(T,s?.color,l?.color),visible:s?.visible??l?.visible??!1,whiteSpace:"pre-wrap"}}),o=a(()=>n.value?.font),r=a(()=>n.value?.size),i=a(()=>n.value?.bold),u=a(()=>n.value?.italic),d=a(()=>n.value?.color),v=a(()=>n.value?.visible),c=a(()=>n.value?.whiteSpace);return O({font:o,size:r,bold:i,italic:u,color:d,visible:v,whiteSpace:c})}function mt(e){const t=E(),n=a(()=>{const r=t.design.value[e],i=t.defaults.value[e];return{enabled:r?.enabled??i?.enabled}}),o=a(()=>n.value?.enabled);return O({enabled:o})}function g(e){return t=>"type"in t?t:{type:e,...t}}function f(e){return t=>{const{type:n,defaults:o,...r}=t,i=o?g(e)(o):void 0;return{type:e,...r,...i!==void 0?{defaults:i}:{}}}}const It={inputbox:f("INPUTBOX"),textarea:f("TEXTAREA"),button:f("BUTTON"),image:f("IMAGE"),toggle:f("TOGGLE"),selectbox:f("SELECTBOX"),deck:f("DECK"),menu:f("MENU"),navigationMenu:f("NAVIGATION_MENU"),logo:f("LOGO"),productSelector:f("PRODUCT_SELECTOR"),categorySelector:f("CATEGORY_SELECTOR"),divider:f("DIVIDER"),info:f("INFO"),default:{inputbox:g("INPUTBOX"),textarea:g("TEXTAREA"),button:g("BUTTON"),selectbox:g("SELECTBOX"),image:g("IMAGE"),toggle:g("TOGGLE"),divider:g("DIVIDER"),info:g("INFO"),deck:g("DECK"),logo:g("LOGO"),menu:g("MENU"),navigationMenu:g("NAVIGATION_MENU"),productSelector:g("PRODUCT_SELECTOR"),categorySelector:g("CATEGORY_SELECTOR")}};function R(e){return t=>"type"in t?t:{type:e,...t}}function b(e){return t=>{const{type:n,defaults:o,...r}=t,i=o?R(e)(o):void 0;return{type:e,...r,...i!==void 0?{defaults:i}:{}}}}const Lt={text:b("TEXT"),button:b("BUTTON"),image:b("IMAGE"),toggle:b("TOGGLE"),selectbox:b("SELECTBOX"),background:b("BACKGROUND"),colorPicker:b("COLOR_PICKER"),logo:b("LOGO"),divider:b("DIVIDER"),default:{text:R("TEXT"),button:R("BUTTON"),image:R("IMAGE"),toggle:R("TOGGLE"),selectbox:R("SELECTBOX"),background:R("BACKGROUND"),colorPicker:R("COLOR_PICKER"),logo:R("LOGO")}};function y(e){return t=>{const{type:n,defaults:o,...r}=t,i=o,u=i&&!("type"in i)?{...i,type:e}:o;return{type:e,...r,...u!==void 0?{defaults:u}:{}}}}const _t={init:e=>({...e}),designOverride:{text:y("TEXT"),button:y("BUTTON"),image:y("IMAGE"),toggle:y("TOGGLE"),selectbox:y("SELECTBOX"),background:y("BACKGROUND"),colorPicker:y("COLOR_PICKER"),logo:y("LOGO"),divider:y("DIVIDER")}},Ct={init:e=>e},Rt={configuration:e=>({...e}),page:e=>({...e})},bt={default:e=>{const{type:t,...n}=e;return{type:"default",...n}},custom:e=>{const{type:t,...n}=e;return{type:"custom",...n}},store:(e={})=>{const{type:t,...n}=e;return{type:"store",...n}}},yt={init:e=>({...e})};export{F as ActionLinkTypeEnum,be as BackgroundStyleEnum,_e as ButtonAppearanceEnum,Re as ButtonShapeEnum,Ce as ButtonSizeEnum,Ie as ButtonTypeEnum,Ne as CatalogLayoutSlot,De as CategoryLayoutSlot,Y as ConfigTypeEnum,Se as DesignEditorType,I as EditorTypes,H as ImageSet,J as InstantsiteJsEvent,Ge as LogoTypeEnum,Le as OverlayTypeEnum,z as PluginTypeEnum,he as ProductLayoutSlot,ye as SectionTypeEnum,we as TemplateCategoriesList,Ae as ValidationTypeEnum,It as content,fe as createVueClientApp,me as createVueServerApp,Lt as design,_t as layout,bt as section,Ct as showcase,Rt as template,yt as translation,dt as useBackgroundElementDesign,ee as useButtonElementContent,vt as useButtonElementDesign,oe as useCategorySelectorElementContent,nt as useDeckElementContent,re as useImageElementContent,Et as useImageElementDesign,ie as useInputboxElementContent,pe as useInstantsiteJsApi,Ot as useLayoutElementDesign,at as useLogoElementContent,Tt as useLogoElementDesign,ce as useMenuElementContent,lt as useNavigationMenuElementContent,ae as useProductSelectorElementContent,le as useSelectboxElementContent,gt as useSelectboxElementDesign,ft as useTextElementDesign,ue as useTextareaElementContent,pt as useTextareaElementDesign,se as useToggleElementContent,mt as useToggleElementDesign,st as useTranslation,E as useVueBaseProps};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightspeed/crane-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
"unbuild": "^3.5.0",
|
|
46
46
|
"vue": "^3.3.4"
|
|
47
47
|
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"zod": "4.1.13"
|
|
50
|
+
},
|
|
48
51
|
"peerDependencies": {
|
|
49
52
|
"vue": "^3.3.4"
|
|
50
53
|
},
|
package/types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ interface ButtonContentData {
|
|
|
18
18
|
readonly title: string;
|
|
19
19
|
readonly type: ActionLinkType;
|
|
20
20
|
readonly link?: string;
|
|
21
|
+
readonly linkTarget?: string;
|
|
21
22
|
readonly email?: string;
|
|
22
23
|
readonly phone?: string;
|
|
23
24
|
readonly tileId?: string;
|
|
@@ -87,6 +88,7 @@ interface ActionLink {
|
|
|
87
88
|
title?: string;
|
|
88
89
|
type?: ActionLinkType;
|
|
89
90
|
link?: string;
|
|
91
|
+
linkTarget?: string;
|
|
90
92
|
email?: string;
|
|
91
93
|
phone?: string;
|
|
92
94
|
tileIdForScroll?: string;
|
|
@@ -323,6 +325,12 @@ interface LegalPage {
|
|
|
323
325
|
readonly url: string | undefined;
|
|
324
326
|
}
|
|
325
327
|
|
|
328
|
+
interface PageInfo {
|
|
329
|
+
readonly pageId: string;
|
|
330
|
+
readonly title: string;
|
|
331
|
+
readonly url: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
326
334
|
interface SiteContent {
|
|
327
335
|
readonly isPreviewMode: boolean;
|
|
328
336
|
readonly reportAbuse?: ReportAbuse;
|
|
@@ -331,6 +339,7 @@ interface SiteContent {
|
|
|
331
339
|
readonly account?: Account;
|
|
332
340
|
readonly cart?: Cart;
|
|
333
341
|
readonly legalPages?: LegalPage[];
|
|
342
|
+
readonly pages?: PageInfo[];
|
|
334
343
|
}
|
|
335
344
|
|
|
336
345
|
interface ImageBorderInfo {
|