@revley/sandbox-checkout-package 0.2.0 → 0.2.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.
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/index.d.ts +7 -2
- package/dist/esm/index.js +1 -1
- package/dist/iife/index.global.js +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var T=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var I=(s,a,l,_)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of x(a))!C.call(s,c)&&c!==l&&T(s,c,{get:()=>a[c],enumerable:!(_=S(a,c))||_.enumerable});return s};var H=s=>I(T({},"__esModule",{value:!0}),s);var q={};module.exports=H(q);var M=(s,a)=>{var k,v;if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let l=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],_=!1,c=(...t)=>_?console.debug("[checkout-intercept]",...t):void 0,A=t=>t.replace(/\/+$/,""),U=t=>t.endsWith(".myshopify.com")||t===location.hostname;function b(t,i=location.origin){try{return t instanceof URL?t:new URL(String(t),i)}catch{return null}}function d(t){let i=b(t);if(!i||!U(i.hostname))return!1;let n=A(i.pathname),e=l.some(r=>r.test(n));return e&&c("detected checkout-like URL:",String(i)),e}async function m(){let i=await(await fetch("/cart.js")).json(),n={},e=["_fbp","_fbc","_fbq","_ig_","_igbp","_igshid","_igsh","_ig_visitor_id","_gclid","_gcl_au","_gcl_aw","_gcl_dc","_gcl_gb","_ttp","_tt_enable_cookie","_scid","_sctr","_pin_unauth","_pin_id","_twitter_ads_id","_li_ss","_uetsid","_uetvid","_amzn","_amzn_ads_","_yclid","_ycl_","_rdt_uid","_quora_","_tb_","_ob_","_criteo_","_adobe_","_ttd_","_dv360_","_fbcv","_shopify_pixel_"],r=g=>e.some(p=>g===p||g.startsWith(p)||g.includes(p));document.cookie&&document.cookie.split(";").forEach(g=>{let p=g.trim();if(p){let[h,...E]=p.split("="),P=E.join("=");h&&P&&r(h)&&(n[h]=P)}});let u=`gid://shopify/Cart/${i.token}`,f=await(await fetch(`${a}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:s,cartId:u,cookies:n})})).text();if(console.log("checkoutUrl",f),!f){console.error("No checkout ID received from backend");return}let L=b(f);if(!L){console.error("Invalid checkout URL received from backend:",f);return}location.assign(L.href)}let y=!1;function o(t){return y||!d(t)?!1:(y=!0,m(),!0)}if(window.__isCheckoutLike=d,window.__maybeRedirect=o,(k=window.Shopify)!=null&&k.designMode)return;{let t=window.location,i=t.assign.bind(t),n=t.replace.bind(t);try{Object.defineProperty(t,"assign",{value:e=>{o(e)||i(e)},writable:!0,configurable:!0}),Object.defineProperty(t,"replace",{value:e=>{o(e)||n(e)},writable:!0,configurable:!0})}catch(e){c("Could not override location methods, relying on Service Worker:",e)}}{let t=window.open;window.open=function(i,n,e){return i&&o(i)?null:t.call(window,i,n,e)}}{let t=history.pushState.bind(history),i=history.replaceState.bind(history);history.pushState=function(n,e,r){if(!(r!=null&&o(r)))return t(n,e,r)},history.replaceState=function(n,e,r){if(!(r!=null&&o(r)))return i(n,e,r)},addEventListener("popstate",()=>void o(location.href),!0)}{let t=i=>i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||i.button!==0;addEventListener("click",i=>{let n=i;if(n.defaultPrevented||t(n))return;let e=i.target;for(;e&&e.nodeType===1&&e.tagName!=="A";)e=e.parentElement;let r=e;!r||!r.href||d(r.href)&&(n.preventDefault(),n.stopPropagation(),m())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{if(w(this))return t.call(this);let n=this.getAttribute("action")||"";if(o(n)||Array.from(this.elements).some(r=>(r==null?void 0:r.name)==="checkout")&&o("/checkout"))return}catch{}return t.call(this)},addEventListener("submit",i=>{try{let n=i.target;if(w(n))return;let e=(n==null?void 0:n.getAttribute("action"))||"",r=Array.from((n==null?void 0:n.elements)||[]);(d(e)||r.some(u=>(u==null?void 0:u.name)==="checkout"))&&(i.preventDefault(),i.stopPropagation(),m())}catch{}},!0)}{let t=location.href;setInterval(()=>{location.href!==t&&(t=location.href,o(t))},250)}{let t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(n,e,r,u,R){try{typeof e=="string"&&d(e)&&o(e)}catch{}return t.call(this,n,e,!!r,u,R)}}{let t=window.fetch.bind(window);window.fetch=function(n,e){try{let r=typeof n=="string"||n instanceof URL?String(n):n.url;r&&d(r)&&o(r)}catch{}return t(n,e)}}let w=t=>t?Array.from(t.elements).some(i=>{var e,r;let n=i;return((e=n.name)==null?void 0:e.includes("__kaching_bundles"))||((r=n.name)==null?void 0:r.includes("kaching"))||t.classList.contains("kaching-form")}):!1;{let t={},i;(v=window.kachingCartApi)!=null&&v.updateTieredPromotionsBar&&(i=window.kachingCartApi.updateTieredPromotionsBar,Object.assign(t,window.kachingCartApi)),window.kachingCartApi=new Proxy(t,{get(n,e){return e==="updateTieredPromotionsBar"?async function(...r){i&&await i.apply(this,r),m()}:n[e]},set(n,e,r){return e==="updateTieredPromotionsBar"&&(i=r,c("Kaching updateTieredPromotionsBar captured")),n[e]=r,!0}})}},j=()=>{let s=document.currentScript;if(!s)return;let a=s.dataset.revleyStoreId,l=s.dataset.revleyCheckoutHost;a&&l&&M(a,l)};j();
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
declare global {
|
|
2
2
|
interface Window {
|
|
3
|
-
|
|
3
|
+
kachingCartApi: {
|
|
4
|
+
updateTieredPromotionsBar: () => void;
|
|
5
|
+
};
|
|
4
6
|
}
|
|
5
7
|
}
|
|
6
8
|
|
|
@@ -46,7 +48,10 @@ interface Item {
|
|
|
46
48
|
line_price?: number;
|
|
47
49
|
original_line_price?: number;
|
|
48
50
|
total_discount?: number;
|
|
49
|
-
discounts?:
|
|
51
|
+
discounts?: {
|
|
52
|
+
amount: number;
|
|
53
|
+
title: string;
|
|
54
|
+
}[];
|
|
50
55
|
sku?: string;
|
|
51
56
|
grams?: number;
|
|
52
57
|
vendor?: string;
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var A=(c,d)=>{if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let p=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],R=!1,_=(...t)=>R?console.debug("[checkout-intercept]",...t):void 0,L=t=>t.replace(/\/+$/,""),P=t=>t.endsWith(".myshopify.com")||t===location.hostname;function h(t,n=location.origin){try{return t instanceof URL?t:new URL(String(t),n)}catch{return null}}function s(t){let n=h(t);if(!n||!P(n.hostname))return!1;let i=L(n.pathname),e=p.some(r=>r.test(i));return e&&_("detected checkout-like URL:",String(n)),e}async function g(){let n=await(await fetch("/cart.js")).json(),i={},e=["_fbp","_fbc","_fbq","_ig_","_igbp","_igshid","_igsh","_ig_visitor_id","_gclid","_gcl_au","_gcl_aw","_gcl_dc","_gcl_gb","_ttp","_tt_enable_cookie","_scid","_sctr","_pin_unauth","_pin_id","_twitter_ads_id","_li_ss","_uetsid","_uetvid","_amzn","_amzn_ads_","_yclid","_ycl_","_rdt_uid","_quora_","_tb_","_ob_","_criteo_","_adobe_","_ttd_","_dv360_","_fbcv","_shopify_pixel_"],r=u=>e.some(a=>u===a||u.startsWith(a)||u.includes(a));document.cookie&&document.cookie.split(";").forEach(u=>{let a=u.trim();if(a){let[f,...T]=a.split("="),v=T.join("=");f&&v&&r(f)&&(i[f]=v)}});let l=`gid://shopify/Cart/${n.token}`,m=await(await fetch(`${d}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:c,cartId:l,cookies:i})})).text();if(console.log("checkoutUrl",m),!m){console.error("No checkout ID received from backend");return}let k=h(m);if(!k){console.error("Invalid checkout URL received from backend:",m);return}location.assign(k.href)}let b=!1;function o(t){return b||!s(t)?!1:(b=!0,g(),!0)}if(window.__isCheckoutLike=s,window.__maybeRedirect=o,window.Shopify?.designMode)return;{let t=window.location,n=t.assign.bind(t),i=t.replace.bind(t);try{Object.defineProperty(t,"assign",{value:e=>{o(e)||n(e)},writable:!0,configurable:!0}),Object.defineProperty(t,"replace",{value:e=>{o(e)||i(e)},writable:!0,configurable:!0})}catch(e){_("Could not override location methods, relying on Service Worker:",e)}}{let t=window.open;window.open=function(n,i,e){return n&&o(n)?null:t.call(window,n,i,e)}}{let t=history.pushState.bind(history),n=history.replaceState.bind(history);history.pushState=function(i,e,r){if(!(r!=null&&o(r)))return t(i,e,r)},history.replaceState=function(i,e,r){if(!(r!=null&&o(r)))return n(i,e,r)},addEventListener("popstate",()=>void o(location.href),!0)}{let t=n=>n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0;addEventListener("click",n=>{let i=n;if(i.defaultPrevented||t(i))return;let e=n.target;for(;e&&e.nodeType===1&&e.tagName!=="A";)e=e.parentElement;let r=e;!r||!r.href||s(r.href)&&(i.preventDefault(),i.stopPropagation(),g())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{if(y(this))return t.call(this);let i=this.getAttribute("action")||"";if(o(i)||Array.from(this.elements).some(r=>r?.name==="checkout")&&o("/checkout"))return}catch{}return t.call(this)},addEventListener("submit",n=>{try{let i=n.target;if(y(i))return;let e=i?.getAttribute("action")||"",r=Array.from(i?.elements||[]);(s(e)||r.some(l=>l?.name==="checkout"))&&(n.preventDefault(),n.stopPropagation(),g())}catch{}},!0)}{let t=location.href;setInterval(()=>{location.href!==t&&(t=location.href,o(t))},250)}{let t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(i,e,r,l,w){try{typeof e=="string"&&s(e)&&o(e)}catch{}return t.call(this,i,e,!!r,l,w)}}{let t=window.fetch.bind(window);window.fetch=function(i,e){try{let r=typeof i=="string"||i instanceof URL?String(i):i.url;r&&s(r)&&o(r)}catch{}return t(i,e)}}let y=t=>t?Array.from(t.elements).some(n=>{let i=n;return i.name?.includes("__kaching_bundles")||i.name?.includes("kaching")||t.classList.contains("kaching-form")}):!1;{let t={},n;window.kachingCartApi?.updateTieredPromotionsBar&&(n=window.kachingCartApi.updateTieredPromotionsBar,Object.assign(t,window.kachingCartApi)),window.kachingCartApi=new Proxy(t,{get(i,e){return e==="updateTieredPromotionsBar"?async function(...r){n&&await n.apply(this,r),g()}:i[e]},set(i,e,r){return e==="updateTieredPromotionsBar"&&(n=r,_("Kaching updateTieredPromotionsBar captured")),i[e]=r,!0}})}},U=()=>{let c=document.currentScript;if(!c)return;let d=c.dataset.revleyStoreId,p=c.dataset.revleyCheckoutHost;d&&p&&A(d,p)};U();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var SandboxCheckoutPkg=(()=>{var
|
|
1
|
+
"use strict";var SandboxCheckoutPkg=(()=>{var T=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var I=(s,a,l,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of x(a))!C.call(s,c)&&c!==l&&T(s,c,{get:()=>a[c],enumerable:!(m=S(a,c))||m.enumerable});return s};var H=s=>I(T({},"__esModule",{value:!0}),s);var q={};var M=(s,a)=>{var k,v;if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let l=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],m=!1,c=(...t)=>m?console.debug("[checkout-intercept]",...t):void 0,A=t=>t.replace(/\/+$/,""),U=t=>t.endsWith(".myshopify.com")||t===location.hostname;function b(t,i=location.origin){try{return t instanceof URL?t:new URL(String(t),i)}catch(e){return null}}function d(t){let i=b(t);if(!i||!U(i.hostname))return!1;let e=A(i.pathname),n=l.some(r=>r.test(e));return n&&c("detected checkout-like URL:",String(i)),n}async function f(){let i=await(await fetch("/cart.js")).json(),e={},n=["_fbp","_fbc","_fbq","_ig_","_igbp","_igshid","_igsh","_ig_visitor_id","_gclid","_gcl_au","_gcl_aw","_gcl_dc","_gcl_gb","_ttp","_tt_enable_cookie","_scid","_sctr","_pin_unauth","_pin_id","_twitter_ads_id","_li_ss","_uetsid","_uetvid","_amzn","_amzn_ads_","_yclid","_ycl_","_rdt_uid","_quora_","_tb_","_ob_","_criteo_","_adobe_","_ttd_","_dv360_","_fbcv","_shopify_pixel_"],r=_=>n.some(p=>_===p||_.startsWith(p)||_.includes(p));document.cookie&&document.cookie.split(";").forEach(_=>{let p=_.trim();if(p){let[h,...E]=p.split("="),P=E.join("=");h&&P&&r(h)&&(e[h]=P)}});let u=`gid://shopify/Cart/${i.token}`,g=await(await fetch(`${a}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:s,cartId:u,cookies:e})})).text();if(console.log("checkoutUrl",g),!g){console.error("No checkout ID received from backend");return}let L=b(g);if(!L){console.error("Invalid checkout URL received from backend:",g);return}location.assign(L.href)}let y=!1;function o(t){return y||!d(t)?!1:(y=!0,f(),!0)}if(window.__isCheckoutLike=d,window.__maybeRedirect=o,(k=window.Shopify)!=null&&k.designMode)return;{let t=window.location,i=t.assign.bind(t),e=t.replace.bind(t);try{Object.defineProperty(t,"assign",{value:n=>{o(n)||i(n)},writable:!0,configurable:!0}),Object.defineProperty(t,"replace",{value:n=>{o(n)||e(n)},writable:!0,configurable:!0})}catch(n){c("Could not override location methods, relying on Service Worker:",n)}}{let t=window.open;window.open=function(i,e,n){return i&&o(i)?null:t.call(window,i,e,n)}}{let t=history.pushState.bind(history),i=history.replaceState.bind(history);history.pushState=function(e,n,r){if(!(r!=null&&o(r)))return t(e,n,r)},history.replaceState=function(e,n,r){if(!(r!=null&&o(r)))return i(e,n,r)},addEventListener("popstate",()=>void o(location.href),!0)}{let t=i=>i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||i.button!==0;addEventListener("click",i=>{let e=i;if(e.defaultPrevented||t(e))return;let n=i.target;for(;n&&n.nodeType===1&&n.tagName!=="A";)n=n.parentElement;let r=n;!r||!r.href||d(r.href)&&(e.preventDefault(),e.stopPropagation(),f())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{if(w(this))return t.call(this);let e=this.getAttribute("action")||"";if(o(e)||Array.from(this.elements).some(r=>(r==null?void 0:r.name)==="checkout")&&o("/checkout"))return}catch(e){}return t.call(this)},addEventListener("submit",i=>{try{let e=i.target;if(w(e))return;let n=(e==null?void 0:e.getAttribute("action"))||"",r=Array.from((e==null?void 0:e.elements)||[]);(d(n)||r.some(u=>(u==null?void 0:u.name)==="checkout"))&&(i.preventDefault(),i.stopPropagation(),f())}catch(e){}},!0)}{let t=location.href;setInterval(()=>{location.href!==t&&(t=location.href,o(t))},250)}{let t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(e,n,r,u,R){try{typeof n=="string"&&d(n)&&o(n)}catch(g){}return t.call(this,e,n,!!r,u,R)}}{let t=window.fetch.bind(window);window.fetch=function(e,n){try{let r=typeof e=="string"||e instanceof URL?String(e):e.url;r&&d(r)&&o(r)}catch(r){}return t(e,n)}}let w=t=>t?Array.from(t.elements).some(i=>{var n,r;let e=i;return((n=e.name)==null?void 0:n.includes("__kaching_bundles"))||((r=e.name)==null?void 0:r.includes("kaching"))||t.classList.contains("kaching-form")}):!1;{let t={},i;(v=window.kachingCartApi)!=null&&v.updateTieredPromotionsBar&&(i=window.kachingCartApi.updateTieredPromotionsBar,Object.assign(t,window.kachingCartApi)),window.kachingCartApi=new Proxy(t,{get(e,n){return n==="updateTieredPromotionsBar"?async function(...r){i&&await i.apply(this,r),f()}:e[n]},set(e,n,r){return n==="updateTieredPromotionsBar"&&(i=r,c("Kaching updateTieredPromotionsBar captured")),e[n]=r,!0}})}},j=()=>{let s=document.currentScript;if(!s)return;let a=s.dataset.revleyStoreId,l=s.dataset.revleyCheckoutHost;a&&l&&M(a,l)};j();return H(q);})();
|