@swishapp/sdk 0.110.0 → 0.112.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
|
@@ -451,4 +451,4 @@ Values:
|
|
|
451
451
|
left: 0px;
|
|
452
452
|
right: 0px;
|
|
453
453
|
}
|
|
454
|
-
`),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 co(n){if(!n)return{};let e={},t=i(r=>{Object.entries(r).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){t(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${lo(s)}`;e[a]=po(s,o)}}})},"walk");return t(n),e}i(co,"flattenDesignTokens");function lo(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(lo,"toKebabCase");function po(n,e){return typeof e=="number"&&!fo(n)?`${e}px`:String(e)}i(po,"formatDesignValue");function fo(n){let e=n.toLowerCase();return e.includes("fontweight")||e.includes("scale")||e.includes("letterspacing")||e.includes("lineheight")}i(fo,"isNonPxValue");var ho=typeof HTMLElement<"u"?HTMLElement:class{},It=class extends ho{constructor(){super();this.getComponentRef=i(()=>this.componentRef,"getComponentRef");this.setComponentRef=i(t=>{this.componentRef=t},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let t=this.querySelector("template");t&&this.shadowRoot&&(this.shadowRoot.appendChild(t.content),t.remove())}static{i(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var it="0.
|
|
454
|
+
`),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 co(n){if(!n)return{};let e={},t=i(r=>{Object.entries(r).forEach(([s,o])=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o)){t(o);return}if(typeof o=="string"||typeof o=="number"){let a=s.startsWith("--")?s:`--swish-theme-${lo(s)}`;e[a]=po(s,o)}}})},"walk");return t(n),e}i(co,"flattenDesignTokens");function lo(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}i(lo,"toKebabCase");function po(n,e){return typeof e=="number"&&!fo(n)?`${e}px`:String(e)}i(po,"formatDesignValue");function fo(n){let e=n.toLowerCase();return e.includes("fontweight")||e.includes("scale")||e.includes("letterspacing")||e.includes("lineheight")}i(fo,"isNonPxValue");var ho=typeof HTMLElement<"u"?HTMLElement:class{},It=class extends ho{constructor(){super();this.getComponentRef=i(()=>this.componentRef,"getComponentRef");this.setComponentRef=i(t=>{this.componentRef=t},"setComponentRef");this.shadowRoot||this.attachShadow({mode:"open"});let t=this.querySelector("template");t&&this.shadowRoot&&(this.shadowRoot.appendChild(t.content),t.remove())}static{i(this,"SwishUiElement")}connectedCallback(){this.dispatchEvent(new CustomEvent("connected"))}};var it="0.112.0",Xd=`https://swish.app/cdn/sdk@${it}/swish.js`,Yd=i(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=Sn(n),t=new sn(e);return window.swish=t,document.dispatchEvent(new Event("swish-ready")),t.api.initAuth().then(()=>{typeof window.Shopify?.analytics?.publish=="function"&&window.Shopify.analytics.publish("swish-ready",{market:e.storefrontContext.localization.market,country:e.storefrontContext.localization.country,language:e.storefrontContext.localization.language,rootUrl:e.storefrontContext.routes.rootUrl})}),t},"createSwish"),sn=class{constructor(e){this.dom={createElementLocator:ie,createLocationObserver:pe,createPlacement:i(e=>hn(this,e),"createPlacement")};this.ui={createElement:i((e,t)=>this.swishUi.createElement(e,t),"createElement")};this.utils={copyToClipboard:ve,createShareUrl:i(e=>ye(this,e),"createShareUrl")};this.state={itemContext:Pn(this),itemState:Tn(this),itemCount:_n(this),swishQuery:On(this),effect:Q,signal:q,computed:F};this.swishOptions=e,this.events=new xe,this.swishApiPublisher=new gt(this.events);let t=[it,e.swishUi?.version].join("-");this.swishApi=new vt({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,this.events,t),this.ajaxApiPublisher=new Se(this.events),this.ajaxApi=new be({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new ft(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishOptions.productOptions,this.swishOptions.metafields),this.swishUi=new wt(this.swishOptions.swishUi,this.swishOptions.storefrontContext),this.events.subscribe(["cart-add","cart-update","cart-change","cart-clear"],()=>{this.ajaxApi.clearCache()}),customElements.get("swish-ui")||customElements.define("swish-ui",It),this.intents=new st(this,this.swishUi)}static{i(this,"SwishApp")}get options(){return this.swishOptions}get storefrontContext(){return this.swishOptions.storefrontContext}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}};export{it as VERSION,ye as buildShareListUrl,ve as copyToClipboard,Yd as createSwish,Xd as swishSdkUrl};
|