@swishapp/sdk 0.141.0 → 0.141.1-unstable.20260727164822
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.
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type PublicEventName = "cart-add" | "cart-update" | "cart-change" | "cart-clear" | "item-create" | "item-update" | "item-delete" | "item-lists-update" | "list-create" | "list-update" | "list-delete" | "notification-update" | "notification-delete" | "token-update";
|
|
2
|
+
export type InternalEventName = "auth-cache-clear" | "drawer-state-change" | "placement-warning";
|
|
3
|
+
export type EventName = PublicEventName | InternalEventName;
|
|
2
4
|
export declare class EventBus {
|
|
3
5
|
private readonly eventBus;
|
|
4
6
|
subscribe(type: EventName | EventName[], callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): () => void;
|
|
@@ -77,6 +77,8 @@ export declare class StorefrontApiClient {
|
|
|
77
77
|
errors: ResponseErrors | null;
|
|
78
78
|
}>;
|
|
79
79
|
/**
|
|
80
|
+
* Internal — do not document. Customiser preview seeding only.
|
|
81
|
+
*
|
|
80
82
|
* Loads a page of products straight from the store's root `products` field —
|
|
81
83
|
* works on any store without requiring a collection handle (unlike
|
|
82
84
|
* `loadCollectionProducts`, whose `handle: "all"` returns null on stores that
|
package/dist/swish.js
CHANGED
|
@@ -325,4 +325,4 @@ Values:
|
|
|
325
325
|
left: 0px;
|
|
326
326
|
right: 0px;
|
|
327
327
|
}
|
|
328
|
-
`),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 pa(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-${fh(s)}`;t[a]=mh(s,o)}}})},"walk");return n(e),t}r(pa,"flattenDesignTokens");function fh(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(fh,"toKebabCase");function mh(e,t){return typeof t=="number"&&!yh(e)?`${t}px`:String(t)}r(mh,"formatDesignValue");function yh(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("lineheight")}r(yh,"isNonPxValue");function vh(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(vh,"shallowEqualStringMap");var gh=typeof HTMLElement<"u"?HTMLElement:class{},si=class extends gh{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 fe="
|
|
328
|
+
`),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 pa(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-${fh(s)}`;t[a]=mh(s,o)}}})},"walk");return n(e),t}r(pa,"flattenDesignTokens");function fh(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").toLowerCase()}r(fh,"toKebabCase");function mh(e,t){return typeof t=="number"&&!yh(e)?`${t}px`:String(t)}r(mh,"formatDesignValue");function yh(e){let t=e.toLowerCase();return t.includes("fontweight")||t.includes("scale")||t.includes("lineheight")}r(yh,"isNonPxValue");function vh(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(vh,"shallowEqualStringMap");var gh=typeof HTMLElement<"u"?HTMLElement:class{},si=class extends gh{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 fe="unstable",jC=`https://swish.app/cdn/sdk@${fe}/swish.js`,UC=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=xs(),n=$s(e),i=new hs(n,t);return globalThis.window.swish=i,Cs(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:fe==="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:yt,createShareUrl:r(t=>mt(this,t),"createShareUrl")};this.state={itemContext:eo(this),itemContextFromIds:Zr,itemState:io(this),itemCount:so(this),swishQuery:ro(this),effect:X,signal:L,computed:ae};this.swishOptions=t,this.isPreview=n,this.events=new Vt,this._i18n=ws(`${t.ui.baseUrl}/i18n@${fe}`,t.translations),this.swishApiPublisher=new ni(this.events);let i=fe;this.swishApi=new ti({responseInterceptor:this.swishApiPublisher.processFetchResponse},this.swishOptions.context,this.events,i,this.swishOptions.auth.tokenUrl),this.ajaxApiPublisher=new Lt(this.events),this.ajaxApi=new Dt({storeDomain:this.swishOptions.storefront.storeDomain,responseInterceptor:this.ajaxApiPublisher.processFetchResponse}),this.ajaxApi.patchFetch(),this.storefrontApi=new Jn(this.swishOptions.storefront,this.swishOptions.context,this.swishOptions.metafields),this.storefrontApi.setSwishApp(this),this.swishUi=new ii(this,n),this.query=Jr({events:this.events,cacheBuster:fe,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 Ot({api:this.swishApi,ajax:this.ajaxApi,events:this.events,context:this.swishOptions.context,preRelease:fe==="unstable"}),this.checkoutBridge.listen()),customElements.get("swish-ui")||customElements.define("swish-ui",si),this.intents=new En(this,this.swishUi),this.placements=new _n(this),hi(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{fe as VERSION,mt as buildShareListUrl,yt as copyToClipboard,UC as createSwish,Hn as getSwishQueryStorageKey,oi as itemToProductRefs,jC as swishSdkUrl};
|