@swishapp/sdk 0.148.0 → 0.148.1-unstable.20260915093137

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
@@ -366,4 +366,4 @@ swish-drawer:not([ready]) > ${e}[hidden] {
366
366
  left: 0px;
367
367
  right: 0px;
368
368
  }
369
- `),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"))}},Xa=new Map;function Ya(e){if(!e||e.trim().length===0)return[];let t=Xa.get(e);if(!t){try{t=new CSSStyleSheet,t.replaceSync(e)}catch(n){return console.warn("Ignoring invalid per-placement Custom CSS",n),[]}Xa.set(e,t)}return[t]}r(Ya,"createShadowCssStylesheets");function Ja(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-${jf(s)}`;t[a]=$f(s,o)}}})},"walk");return n(e),t}r(Ja,"flattenDesignTokens");function jf(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(jf,"toKebabCase");function $f(e,t){return typeof t=="number"&&!Hf(e)?`${t}px`:String(t)}r($f,"formatDesignValue");function Hf(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("lineheight")||t.includes("alpha")||t.includes("opacity")}r(Hf,"isNonPxValue");function Qf(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(Qf,"shallowEqualStringMap");var Gf=typeof HTMLElement<"u"?HTMLElement:class{},xi=class extends Gf{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 Za=["all","signed-in","signed-out"],$s=r(e=>Array.isArray(e)?e.map(t=>String(t).trim().toLowerCase()).filter(Boolean):[],"normalise"),zf=r(e=>e?Za.includes(e.audience)&&e.audience!=="all"||$s(e.customerTags).length>0:!1,"hasAudienceTargeting"),Wf=r((e,t)=>{if(!e)return!0;let n=Za.find(o=>o===e.audience)??"all";if(n==="signed-in"&&!t.signedIn||n==="signed-out"&&t.signedIn)return!1;let i=$s(e.customerTags);if(i.length===0)return!0;if(!t.signedIn)return!1;let s=new Set($s(t.tags));return i.some(o=>s.has(o))},"matchesAudience");var ge="0.148.0",bP=`https://swish.app/cdn/sdk@${ge}/swish.js`,IP=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=er(),n=vr(e),i=new Hs(n,t);return globalThis.window.swish=i,tr(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:ge==="unstable"})}),i},"createSwish"),Hs=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"),isDrawerOpen:r(()=>this.swishUi.isDrawerOpen(),"isDrawerOpen"),applyPreview:r(t=>this.swishUi.applyPreview(t),"applyPreview")};this.utils={copyToClipboard:It,createShareUrl:r(t=>bt(this,t),"createShareUrl")};this.state={itemContext:Mo(this),itemContextFromIds:_o,itemState:Bo(this),itemCount:Fo(this),listContext:No(),lists:jo(this),items:Ho(this),product:Ma(this),swishQuery:Vo(this),effect:ie,signal:P,computed:ne};this.swishOptions=t,this.isPreview=n,this.events=new Kt,this._i18n=Xs(`${t.ui.baseUrl}/i18n@${ge}`,t.translations),this.swishApiPublisher=new Ii(this.events);let i=ge;this.swishApi=new bi({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,i,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new Vt(this.events),this.ajaxApi=new Ft({storeDomain:this.swishOptions.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.ajaxApi.patchXhr(),this.storefrontApi=new vi(this.swishOptions.storefront,this.swishOptions.context,this.swishOptions.metafields),this.storefrontApi.setSwishApp(this),this.swishUi=new Si(this,n),this.query=Oo({events:this.events,cacheBuster:ge,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 Nt({api:this.swishApi,ajax:this.ajaxApi,events:this.events,context:this.swishOptions.context,preRelease:ge==="unstable"}),this.checkoutBridge.listen()),customElements.get("swish-ui")||customElements.define("swish-ui",xi),this.intents=new Nn(this,this.swishUi),this.placements=new Wn(this),Mi(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:qe}}get iconsSignal(){return this.swishUi.icons}get uiOptionsSignal(){return this.swishUi.uiOptions}};export{ge as VERSION,wt as allowsMultipleLists,bt as buildShareListUrl,It as copyToClipboard,IP as createSwish,ri as getSwishQueryStorageKey,zf as hasAudienceTargeting,Ne as isClassicWishlistPage,Ei as itemToProductRefs,Wf as matchesAudience,Ln as resolveDefaultView,bP as swishSdkUrl,Zt as wishlistPagePath};
369
+ `),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"))}},Xa=new Map;function Ya(e){if(!e||e.trim().length===0)return[];let t=Xa.get(e);if(!t){try{t=new CSSStyleSheet,t.replaceSync(e)}catch(n){return console.warn("Ignoring invalid per-placement Custom CSS",n),[]}Xa.set(e,t)}return[t]}r(Ya,"createShadowCssStylesheets");function Ja(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-${jf(s)}`;t[a]=$f(s,o)}}})},"walk");return n(e),t}r(Ja,"flattenDesignTokens");function jf(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(jf,"toKebabCase");function $f(e,t){return typeof t=="number"&&!Hf(e)?`${t}px`:String(t)}r($f,"formatDesignValue");function Hf(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("lineheight")||t.includes("alpha")||t.includes("opacity")}r(Hf,"isNonPxValue");function Qf(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(Qf,"shallowEqualStringMap");var Gf=typeof HTMLElement<"u"?HTMLElement:class{},xi=class extends Gf{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 Za=["all","signed-in","signed-out"],$s=r(e=>Array.isArray(e)?e.map(t=>String(t).trim().toLowerCase()).filter(Boolean):[],"normalise"),zf=r(e=>e?Za.includes(e.audience)&&e.audience!=="all"||$s(e.customerTags).length>0:!1,"hasAudienceTargeting"),Wf=r((e,t)=>{if(!e)return!0;let n=Za.find(o=>o===e.audience)??"all";if(n==="signed-in"&&!t.signedIn||n==="signed-out"&&t.signedIn)return!1;let i=$s(e.customerTags);if(i.length===0)return!0;if(!t.signedIn)return!1;let s=new Set($s(t.tags));return i.some(o=>s.has(o))},"matchesAudience");var ge="unstable",bP=`https://swish.app/cdn/sdk@${ge}/swish.js`,IP=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=er(),n=vr(e),i=new Hs(n,t);return globalThis.window.swish=i,tr(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:ge==="unstable"})}),i},"createSwish"),Hs=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"),isDrawerOpen:r(()=>this.swishUi.isDrawerOpen(),"isDrawerOpen"),applyPreview:r(t=>this.swishUi.applyPreview(t),"applyPreview")};this.utils={copyToClipboard:It,createShareUrl:r(t=>bt(this,t),"createShareUrl")};this.state={itemContext:Mo(this),itemContextFromIds:_o,itemState:Bo(this),itemCount:Fo(this),listContext:No(),lists:jo(this),items:Ho(this),product:Ma(this),swishQuery:Vo(this),effect:ie,signal:P,computed:ne};this.swishOptions=t,this.isPreview=n,this.events=new Kt,this._i18n=Xs(`${t.ui.baseUrl}/i18n@${ge}`,t.translations),this.swishApiPublisher=new Ii(this.events);let i=ge;this.swishApi=new bi({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,i,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new Vt(this.events),this.ajaxApi=new Ft({storeDomain:this.swishOptions.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.ajaxApi.patchXhr(),this.storefrontApi=new vi(this.swishOptions.storefront,this.swishOptions.context,this.swishOptions.metafields),this.storefrontApi.setSwishApp(this),this.swishUi=new Si(this,n),this.query=Oo({events:this.events,cacheBuster:ge,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 Nt({api:this.swishApi,ajax:this.ajaxApi,events:this.events,context:this.swishOptions.context,preRelease:ge==="unstable"}),this.checkoutBridge.listen()),customElements.get("swish-ui")||customElements.define("swish-ui",xi),this.intents=new Nn(this,this.swishUi),this.placements=new Wn(this),Mi(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:qe}}get iconsSignal(){return this.swishUi.icons}get uiOptionsSignal(){return this.swishUi.uiOptions}};export{ge as VERSION,wt as allowsMultipleLists,bt as buildShareListUrl,It as copyToClipboard,IP as createSwish,ri as getSwishQueryStorageKey,zf as hasAudienceTargeting,Ne as isClassicWishlistPage,Ei as itemToProductRefs,Wf as matchesAudience,Ln as resolveDefaultView,bP as swishSdkUrl,Zt as wishlistPagePath};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swishapp/sdk",
3
- "version": "0.148.0",
3
+ "version": "0.148.1-unstable.20260915093137",
4
4
  "description": "JS SDK for Swish.",
5
5
  "author": "Swish",
6
6
  "license": "UNLICENSED",