@swishapp/sdk 0.130.1-unstable.20260514175437 → 0.131.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
|
@@ -274,4 +274,4 @@ Values:
|
|
|
274
274
|
left: 0px;
|
|
275
275
|
right: 0px;
|
|
276
276
|
}
|
|
277
|
-
`),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 Ip(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-${Sp(s)}`;t[a]=xp(s,o)}}})},"walk");return n(e),t}r(Ip,"flattenDesignTokens");function Sp(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Sp,"toKebabCase");function xp(e,t){return typeof t=="number"&&!Cp(e)?`${t}px`:String(t)}r(xp,"formatDesignValue");function Cp(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(Cp,"isNonPxValue");var Ep=typeof HTMLElement<"u"?HTMLElement:class{},Vn=class extends Ep{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 De="
|
|
277
|
+
`),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 Ip(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-${Sp(s)}`;t[a]=xp(s,o)}}})},"walk");return n(e),t}r(Ip,"flattenDesignTokens");function Sp(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(Sp,"toKebabCase");function xp(e,t){return typeof t=="number"&&!Cp(e)?`${t}px`:String(t)}r(xp,"formatDesignValue");function Cp(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("letterspacing")||t.includes("lineheight")}r(Cp,"isNonPxValue");var Ep=typeof HTMLElement<"u"?HTMLElement:class{},Vn=class extends Ep{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 De="0.131.0",NS=`https://swish.app/cdn/sdk@${De}/swish.js`,US=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=Qs(e),n=new Yi(t);return globalThis.window.swish=n,document.dispatchEvent(new Event("swish-ready")),n.api.initAuth().then(()=>{typeof globalThis.window.Shopify?.analytics?.publish=="function"&&globalThis.window.Shopify.analytics.publish("swish-ready",{market:t.context.localization.market,country:t.context.localization.country,language:t.context.localization.language,rootUrl:t.context.routes.rootUrl,preRelease:De==="unstable"})}),n},"createSwish"),Yi=class{constructor(t){this._mountedPlacements=[];this.ui={createElement:r((t,n)=>this.swishUi.createElement(t,n),"createElement")};this.utils={copyToClipboard:yt,createShareUrl:r(t=>mt(this,t),"createShareUrl")};this.state={itemContext:Tr(this),itemContextFromIds:Ar,itemState:Or(this),itemCount:_r(this),swishQuery:Mr(this),effect:ae,signal:F,computed:he};this.swishOptions=t,this.events=new _t,this._i18n=is(`${t.ui.baseUrl}/i18n@${De}`,t.translations),this.swishApiPublisher=new Un(this.events);let n=De;this.swishApi=new Nn({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,n,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new Et(this.events),this.ajaxApi=new Ct({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 $n(this),this.query=Pr({events:this.events,cacheBuster:De,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()}),customElements.get("swish-ui")||customElements.define("swish-ui",Vn),this.intents=new gn(this,this.swishUi),qr(this),this._mountedPlacements=this.swishOptions.placements.map(i=>{let s=Yn(this,i);return s.mount(),{spec:i,...s}})}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{createElementLocator:ke,createLocationObserver:Ze,createPlacement:r(t=>Yn(this,t),"createPlacement"),placements:this._mountedPlacements}}};export{De as VERSION,mt as buildShareListUrl,yt as copyToClipboard,US as createSwish,An as getSwishQueryStorageKey,NS as swishSdkUrl};
|