ui.shipaid.com 0.3.42 → 0.3.43
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/widget.es.js +3 -6
- package/dist/widget.iife.js +1 -1
- package/dist/widget.umd.js +1 -1
- package/package.json +1 -1
package/dist/widget.es.js
CHANGED
|
@@ -2534,21 +2534,18 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
2534
2534
|
await use(this.lang);
|
|
2535
2535
|
this.hasLoadedStrings = true;
|
|
2536
2536
|
this.fetchInterceptorCleanup = interceptFetch(async (args, promise) => {
|
|
2537
|
-
var _a, _b, _c, _d;
|
|
2538
|
-
console.debug("fetch:", args);
|
|
2537
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2539
2538
|
if (((_b = (_a = args[1]) == null ? void 0 : _a.method) == null ? void 0 : _b.toUpperCase()) !== "POST") {
|
|
2540
2539
|
return;
|
|
2541
2540
|
}
|
|
2542
|
-
console.debug("s:", 1);
|
|
2543
2541
|
if ((_d = (_c = args[1]) == null ? void 0 : _c.headers) == null ? void 0 : _d["X-ShipAid"]) {
|
|
2544
2542
|
return;
|
|
2545
2543
|
}
|
|
2546
|
-
console.debug("s:", 2);
|
|
2547
2544
|
if (!args[0].startsWith("/cart/change") && !args[0].startsWith("/cart/update")) {
|
|
2548
2545
|
return;
|
|
2549
2546
|
}
|
|
2550
|
-
|
|
2551
|
-
const button = document.querySelector(
|
|
2547
|
+
const buttonSelector = ((_f = (_e = this._store) == null ? void 0 : _e.widgetConfigurations) == null ? void 0 : _f.checkoutButtonSelector) || 'button[type="submit"][name="checkout"][form="cart"]';
|
|
2548
|
+
const button = document.querySelector(buttonSelector);
|
|
2552
2549
|
console.log("q", button);
|
|
2553
2550
|
if (!button) {
|
|
2554
2551
|
return;
|
package/dist/widget.iife.js
CHANGED
|
@@ -1023,7 +1023,7 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const Nt=u`
|
|
|
1023
1023
|
</a>
|
|
1024
1024
|
</div>
|
|
1025
1025
|
</div>
|
|
1026
|
-
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=bt){const i=await e.loader(t,e);e.translationCache={},_t(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const s=e(o,r);if(i)try{await t([o,r],s)}catch(n){console.warn(n)}return await s};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,s;if(
|
|
1026
|
+
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=bt){const i=await e.loader(t,e);e.translationCache={},_t(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const s=e(o,r);if(i)try{await t([o,r],s)}catch(n){console.warn(n)}return await s};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,s,n,a;if("POST"!==(null==(o=null==(i=t[1])?void 0:i.method)?void 0:o.toUpperCase()))return;if(null==(s=null==(r=t[1])?void 0:r.headers)?void 0:s["X-ShipAid"])return;if(!t[0].startsWith("/cart/change")&&!t[0].startsWith("/cart/update"))return;const p=(null==(a=null==(n=this._store)?void 0:n.widgetConfigurations)?void 0:a.checkoutButtonSelector)||'button[type="submit"][name="checkout"][form="cart"]',d=document.querySelector(p);if(console.log("q",d),d){d.setAttribute("disabled","true"),console.debug("button","t");try{await e,await this.updateCart(),await this.updateProtection()}finally{d.removeAttribute("disabled"),console.debug("button","f")}}}))}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.fetchInterceptorCleanup)||t.call(this)}async updateProtection(){var t,i,o,r;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const s=null==(i=this._cart.items)?void 0:i.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),n=null==(o=this._cart)?void 0:o.items[s];if(this._hasProtectionInCart=!!n,!this._store)return;const a=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&n&&(this._cart.total_price===(null==n?void 0:n.final_line_price)||!a)){const t={id:n.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return sessionStorage.removeItem(he),await this._handleRefresh(e)}const p=this._findProtectionVariant(a);if(a?(this._protectionVariant=p,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==p?void 0:p.id))return this._shouldShowWidget=!1,void ce("No matching protection variant found.");if(!(null==(r=this._protectionVariant)?void 0:r.id))return void(this._shouldShowWidget=!1);if(!n)return;if(this.supportSubscriptions){const t=this._cart.items.find((t=>{var e;return t.id!==(null==(e=this._protectionVariant)?void 0:e.id)&&!!(null==t?void 0:t.selling_plan_allocation)}));let i=null;if(!t&&(null==n?void 0:n.selling_plan_allocation))i={id:n.key,quantity:1,selling_plan:null};else if(t&&!(null==n?void 0:n.selling_plan_allocation)){const o=await this._fetchSellingPlanFromVariant(t.selling_plan_allocation.selling_plan),r=o?e(o.id):null;i={id:n.key,quantity:1,selling_plan:r}}if(i){const t=await this._fetch.post("/cart/change.js",i);await this._handleRefresh(t)}}if(p.id===n.variant_id){if(this._protectionCartItem={...n,index:s,position:s+1},1===n.quantity)return;const t={id:n.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return this._handleRefreshCart(),await this._handleRefresh(e)}const d={updates:{[n.variant_id]:0,[p.id]:1}},l=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(l)}render(){return It(this,(async()=>{var t,e,i,o,r,s;const n=document.createElement("link");n.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),n.setAttribute("rel","stylesheet"),document.head.appendChild(n);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(a){return ce(a.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._dispatchEvent(ne.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(he)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(he,JSON.stringify({loaded:!0}))))}),500),void(this.disablePolling||(setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(s=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:s.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(le("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(le("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(le("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),It(this,(async()=>{await this.updateProtection()}),[this._store,this._cart]),dt(this.renderPopups(),document.body),F`
|
|
1027
1027
|
<style>
|
|
1028
1028
|
:host {
|
|
1029
1029
|
--shipaid-primary: #002bd6;
|
package/dist/widget.umd.js
CHANGED
|
@@ -1023,7 +1023,7 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const Nt=u`
|
|
|
1023
1023
|
</a>
|
|
1024
1024
|
</div>
|
|
1025
1025
|
</div>
|
|
1026
|
-
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=bt){const i=await e.loader(t,e);e.translationCache={},_t(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const s=e(o,r);if(i)try{await t([o,r],s)}catch(n){console.warn(n)}return await s};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,s;if(
|
|
1026
|
+
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=bt){const i=await e.loader(t,e);e.translationCache={},_t(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const s=e(o,r);if(i)try{await t([o,r],s)}catch(n){console.warn(n)}return await s};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,s,n,a;if("POST"!==(null==(o=null==(i=t[1])?void 0:i.method)?void 0:o.toUpperCase()))return;if(null==(s=null==(r=t[1])?void 0:r.headers)?void 0:s["X-ShipAid"])return;if(!t[0].startsWith("/cart/change")&&!t[0].startsWith("/cart/update"))return;const p=(null==(a=null==(n=this._store)?void 0:n.widgetConfigurations)?void 0:a.checkoutButtonSelector)||'button[type="submit"][name="checkout"][form="cart"]',d=document.querySelector(p);if(console.log("q",d),d){d.setAttribute("disabled","true"),console.debug("button","t");try{await e,await this.updateCart(),await this.updateProtection()}finally{d.removeAttribute("disabled"),console.debug("button","f")}}}))}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.fetchInterceptorCleanup)||t.call(this)}async updateProtection(){var t,i,o,r;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const s=null==(i=this._cart.items)?void 0:i.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),n=null==(o=this._cart)?void 0:o.items[s];if(this._hasProtectionInCart=!!n,!this._store)return;const a=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&n&&(this._cart.total_price===(null==n?void 0:n.final_line_price)||!a)){const t={id:n.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return sessionStorage.removeItem(he),await this._handleRefresh(e)}const p=this._findProtectionVariant(a);if(a?(this._protectionVariant=p,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==p?void 0:p.id))return this._shouldShowWidget=!1,void ce("No matching protection variant found.");if(!(null==(r=this._protectionVariant)?void 0:r.id))return void(this._shouldShowWidget=!1);if(!n)return;if(this.supportSubscriptions){const t=this._cart.items.find((t=>{var e;return t.id!==(null==(e=this._protectionVariant)?void 0:e.id)&&!!(null==t?void 0:t.selling_plan_allocation)}));let i=null;if(!t&&(null==n?void 0:n.selling_plan_allocation))i={id:n.key,quantity:1,selling_plan:null};else if(t&&!(null==n?void 0:n.selling_plan_allocation)){const o=await this._fetchSellingPlanFromVariant(t.selling_plan_allocation.selling_plan),r=o?e(o.id):null;i={id:n.key,quantity:1,selling_plan:r}}if(i){const t=await this._fetch.post("/cart/change.js",i);await this._handleRefresh(t)}}if(p.id===n.variant_id){if(this._protectionCartItem={...n,index:s,position:s+1},1===n.quantity)return;const t={id:n.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return this._handleRefreshCart(),await this._handleRefresh(e)}const d={updates:{[n.variant_id]:0,[p.id]:1}},l=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(l)}render(){return It(this,(async()=>{var t,e,i,o,r,s;const n=document.createElement("link");n.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),n.setAttribute("rel","stylesheet"),document.head.appendChild(n);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(a){return ce(a.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._dispatchEvent(ne.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(he)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(he,JSON.stringify({loaded:!0}))))}),500),void(this.disablePolling||(setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(s=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:s.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(le("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(le("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(le("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),It(this,(async()=>{await this.updateProtection()}),[this._store,this._cart]),dt(this.renderPopups(),document.body),F`
|
|
1027
1027
|
<style>
|
|
1028
1028
|
:host {
|
|
1029
1029
|
--shipaid-primary: #002bd6;
|