@swishapp/sdk 0.80.1 → 0.80.2

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.
Files changed (2) hide show
  1. package/dist/swish.js +1 -1
  2. package/package.json +1 -1
package/dist/swish.js CHANGED
@@ -450,4 +450,4 @@ Values:
450
450
  left: 0px;
451
451
  right: 0px;
452
452
  }
453
- `),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"))}};var ns=typeof HTMLElement<"u"?HTMLElement:class{},Fe=class extends ns{constructor(){super();this.getComponentRef=s(()=>this.componentRef,"getComponentRef");this.setComponentRef=s(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{s(this,"SwishUiElement")}};var He=class{static{s(this,"ShopifyBadgesUtils")}#e;constructor({getBadges:e}){this.#e=e?.bind(this)}getBadges({product:e,variant:t}){try{let r=this.getDefaultBadges({product:e,variant:t});return this.#e?this.mapBadges(this.#e({product:e,variant:t,defaultBadges:r})??[]):this.mapBadges(r)}catch(r){return console.error("Error getting badges",r),[]}}getDefaultBadges({product:e,variant:t}){let r=[];if(e?.availableForSale===!1||t?.availableForSale===!1)return r.push("Sold out"),r;let i=t?t.price.amount:e?.priceRange?.minVariantPrice.amount,o=t?t.compareAtPrice?.amount:e?.compareAtPriceRange?.minVariantPrice.amount;return o&&parseFloat(o)>parseFloat(i)&&r.push("Sale"),r}mapBadges(e){return e.map(t=>typeof t=="string"?{id:t.toLowerCase().replace(/[^a-z0-9]/g,"_"),label:t}:t)}};var rs="0.80.1",Wl=s(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=Mt(n),t=new _t(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"),_t=class{constructor(e){this.dom={createElementLocator:ce,createQueryParamsObserver:se};this.state={itemContext:Kt(this),itemState:Yt(this),itemCount:Jt(this),swishQuery:Zt(this),effect:V,signal:C,computed:q};this.swishOptions=e,this.events=new me,this.swishBadges=new He({getBadges:this.swishOptions.badges?.getBadges}),this.swishApiPublisher=new Me(this.events);let t=[rs,e.swishUi?.version].join("-");this.swishApi=new Ge({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,t),this.ajaxApiPublisher=new ye(this.events),this.ajaxApi=new he({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Be(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.metafields),this.swishUi=new je(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",Fe),this.intents=new De(this,this.swishUi)}static{s(this,"SwishApp")}get options(){return this.swishOptions}get customer(){return this.swishOptions.storefrontContext.customer}get localization(){return this.swishOptions.storefrontContext.localization}get routes(){return this.swishOptions.storefrontContext.routes}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}get ui(){return this.swishUi}};export{rs as VERSION,Wl as createSwish};
453
+ `),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"))}};var ns=typeof HTMLElement<"u"?HTMLElement:class{},Fe=class extends ns{constructor(){super();this.getComponentRef=s(()=>this.componentRef,"getComponentRef");this.setComponentRef=s(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{s(this,"SwishUiElement")}};var He=class{static{s(this,"ShopifyBadgesUtils")}#e;constructor({getBadges:e}){this.#e=e?.bind(this)}getBadges({product:e,variant:t}){try{let r=this.getDefaultBadges({product:e,variant:t});return this.#e?this.mapBadges(this.#e({product:e,variant:t,defaultBadges:r})??[]):this.mapBadges(r)}catch(r){return console.error("Error getting badges",r),[]}}getDefaultBadges({product:e,variant:t}){let r=[];if(e?.availableForSale===!1||t?.availableForSale===!1)return r.push("Sold out"),r;let i=t?t.price.amount:e?.priceRange?.minVariantPrice.amount,o=t?t.compareAtPrice?.amount:e?.compareAtPriceRange?.minVariantPrice.amount;return o&&parseFloat(o)>parseFloat(i)&&r.push("Sale"),r}mapBadges(e){return e.map(t=>typeof t=="string"?{id:t.toLowerCase().replace(/[^a-z0-9]/g,"_"),label:t}:t)}};var rs="0.80.2",Wl=s(async n=>{if(typeof window>"u")throw new Error("Swish is not supported in this environment");if(window.swish)return window.swish;let e=Mt(n),t=new _t(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"),_t=class{constructor(e){this.dom={createElementLocator:ce,createQueryParamsObserver:se};this.state={itemContext:Kt(this),itemState:Yt(this),itemCount:Jt(this),swishQuery:Zt(this),effect:V,signal:C,computed:q};this.swishOptions=e,this.events=new me,this.swishBadges=new He({getBadges:this.swishOptions.badges?.getBadges}),this.swishApiPublisher=new Me(this.events);let t=[rs,e.swishUi?.version].join("-");this.swishApi=new Ge({...this.swishOptions.swishApi,responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.storefrontContext,t),this.ajaxApiPublisher=new ye(this.events),this.ajaxApi=new he({storeDomain:this.swishOptions.storefrontApi.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Be(this.swishOptions.storefrontApi,this.swishOptions.storefrontContext,this.swishBadges,this.swishOptions.metafields),this.swishUi=new je(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",Fe),this.intents=new De(this,this.swishUi)}static{s(this,"SwishApp")}get options(){return this.swishOptions}get customer(){return this.swishOptions.storefrontContext.customer}get localization(){return this.swishOptions.storefrontContext.localization}get routes(){return this.swishOptions.storefrontContext.routes}get badges(){return this.swishBadges}get api(){return this.swishApi}get storefront(){return this.storefrontApi}get ajax(){return this.ajaxApi}get shopUrl(){return`https://${this.swishOptions.storefrontApi.storeDomain}`}get ui(){return this.swishUi}};export{rs as VERSION,Wl as createSwish};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swishapp/sdk",
3
- "version": "0.80.1",
3
+ "version": "0.80.2",
4
4
  "description": "JS SDK for Swish.",
5
5
  "author": "Swish",
6
6
  "license": "UNLICENSED",