@swishapp/sdk 0.138.1-unstable.20260626083313 → 0.139.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/dist/swish.js +1 -1
- package/package.json +1 -1
package/dist/swish.js
CHANGED
|
@@ -281,4 +281,4 @@ Values:
|
|
|
281
281
|
left: 0px;
|
|
282
282
|
right: 0px;
|
|
283
283
|
}
|
|
284
|
-
`),document.documentElement.setAttribute("swish-locked",""))}unlockScroll(){this.scrollLockRefCount>0&&this.scrollLockRefCount--,this.scrollLockRefCount===0&&(this.scrollLockStyleSheet&&this.scrollLockStyleSheet.replaceSync(""),window.scrollTo({top:this.scrollPositionBeforeLock,behavior:"instant"}),this.scrollPositionBeforeLock=0,document.documentElement.removeAttribute("swish-locked"))}};function Ko(e){if(!e)return{};let t={},n=r(i=>{Object.entries(i).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){n(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${Kp(s)}`;t[a]=Wp(s,o)}}})},"walk");return n(e),t}r(Ko,"flattenDesignTokens");function Kp(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Kp,"toKebabCase");function Wp(e,t){return typeof t=="number"&&!Xp(e)?`${t}px`:String(t)}r(Wp,"formatDesignValue");function Xp(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(Xp,"isNonPxValue");function Jp(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let i of n)if(e[i]!==t[i])return!1;return!0}r(Jp,"shallowEqualStringMap");var Yp=typeof HTMLElement<"u"?HTMLElement:class{},Jn=class extends Yp{constructor(){super();this.getComponentRef=r(()=>this.componentRef,"getComponentRef");this.setComponentRef=r(n=>{this.componentRef=n},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let n=this.querySelector("template");n&&this.shadowRoot&&(this.shadowRoot.appendChild(n.content),n.remove())}static{r(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var he="
|
|
284
|
+
`),document.documentElement.setAttribute("swish-locked",""))}unlockScroll(){this.scrollLockRefCount>0&&this.scrollLockRefCount--,this.scrollLockRefCount===0&&(this.scrollLockStyleSheet&&this.scrollLockStyleSheet.replaceSync(""),window.scrollTo({top:this.scrollPositionBeforeLock,behavior:"instant"}),this.scrollPositionBeforeLock=0,document.documentElement.removeAttribute("swish-locked"))}};function Ko(e){if(!e)return{};let t={},n=r(i=>{Object.entries(i).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){n(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${Kp(s)}`;t[a]=Wp(s,o)}}})},"walk");return n(e),t}r(Ko,"flattenDesignTokens");function Kp(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Kp,"toKebabCase");function Wp(e,t){return typeof t=="number"&&!Xp(e)?`${t}px`:String(t)}r(Wp,"formatDesignValue");function Xp(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(Xp,"isNonPxValue");function Jp(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let i of n)if(e[i]!==t[i])return!1;return!0}r(Jp,"shallowEqualStringMap");var Yp=typeof HTMLElement<"u"?HTMLElement:class{},Jn=class extends Yp{constructor(){super();this.getComponentRef=r(()=>this.componentRef,"getComponentRef");this.setComponentRef=r(n=>{this.componentRef=n},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let n=this.querySelector("template");n&&this.shadowRoot&&(this.shadowRoot.appendChild(n.content),n.remove())}static{r(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var he="0.139.0",zx=`https://swish.app/cdn/sdk@${he}/swish.js`,Kx=r(async e=>{if(globalThis.window===void 0)throw new Error("Swish is not supported in this environment");if(globalThis.window.swish)return globalThis.window.swish;let t=ms(),n=Ms(e),i=new os(n,t);return globalThis.window.swish=i,ys(i,{baseUrl:e.customiser?.baseUrl,shop:n.context.myshopifyDomain}),document.dispatchEvent(new Event("swish-ready")),i.api.initAuth().then(()=>{typeof globalThis.window.Shopify?.analytics?.publish=="function"&&globalThis.window.Shopify.analytics.publish("swish-ready",{market:n.context.localization.market,country:n.context.localization.country,language:n.context.localization.language,rootUrl:n.context.routes.rootUrl,preRelease:he==="unstable"})}),i},"createSwish"),os=class{constructor(t,n){this.ui={createElement:r((t,n)=>this.swishUi.createElement(t,n),"createElement"),showDrawer:r(t=>this.swishUi.showDrawer(t),"showDrawer"),hideDrawer:r(()=>this.swishUi.hideDrawer(),"hideDrawer"),applyPreview:r(t=>this.swishUi.applyPreview(t),"applyPreview")};this.utils={copyToClipboard:ft,createShareUrl:r(t=>ht(this,t),"createShareUrl")};this.state={itemContext:Qr(this),itemContextFromIds:Hr,itemState:Kr(this),itemCount:Wr(this),swishQuery:Xr(this),effect:X,signal:L,computed:re};this.swishOptions=t,this.isPreview=n,this.events=new qt,this._i18n=ds(`${t.ui.baseUrl}/i18n@${he}`,t.translations),this.swishApiPublisher=new Wn(this.events);let i=he;this.swishApi=new Kn({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,i,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new At(this.events),this.ajaxApi=new kt({storeDomain:this.swishOptions.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Qn(this.swishOptions.storefront,this.swishOptions.context,this.swishOptions.metafields),this.swishUi=new Xn(this,n),this.query=$r({events:this.events,cacheBuster:he,customerId:this.swishOptions.context.customer.id,storeDomain:this.swishOptions.context.myshopifyDomain}),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),n||(this.checkoutBridge=new Pt({api:this.swishApi,ajax:this.ajaxApi,events:this.events,context:this.swishOptions.context,preRelease:he==="unstable"}),this.checkoutBridge.listen()),customElements.get("swish-ui")||customElements.define("swish-ui",Jn),this.intents=new In(this,this.swishUi),this.placements=new Pn(this),ri(this),this.swishUi.initListDetailPage(),n||this.placements.mountConfigured(this.swishOptions.placements)}static{r(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.context}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get i18n(){return this._i18n}get shopUrl(){return`https://${this.swishOptions.storefront.storeDomain}`}get dom(){return{createLocationObserver:ze}}get iconsSignal(){return this.swishUi.icons}get uiOptionsSignal(){return this.swishUi.uiOptions}};export{he as VERSION,ht as buildShareListUrl,ft as copyToClipboard,Kx as createSwish,Bn as getSwishQueryStorageKey,zx as swishSdkUrl};
|