@revley/sandbox-checkout-package 0.2.22 → 0.2.24

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 +1 @@
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(?:\/|$|\?|#)/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),await new Promise(u=>setTimeout(u,1e3*1e4)),await 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();
1
+ "use strict";var A=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var w=(s,r,u,R)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of X(r))!N.call(s,l)&&l!==u&&A(s,l,{get:()=>r[l],enumerable:!(R=B(r,l))||R.enumerable});return s};var v=s=>w(A({},"__esModule",{value:!0}),s);var U={};module.exports=v(U);var L=(s,r)=>{var y,S;if(console.log("SANDBOX-REDIRECT: Initializing checkout intercept",{storeId:s,checkoutHost:r}),window.__checkoutInterceptInstalled){console.log("SANDBOX-REDIRECT: Already installed, skipping");return}window.__checkoutInterceptInstalled=!0,console.log("SANDBOX-REDIRECT: Installation complete");let u=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts(?:\/|$|\?|#)/i],R=!1,l=(...e)=>R?console.debug("[checkout-intercept]",...e):void 0,I=e=>e.replace(/\/+$/,""),k=e=>e.endsWith(".myshopify.com")||e===location.hostname;function D(e,o=location.origin){try{return e instanceof URL?e:new URL(String(e),o)}catch{return null}}function d(e){let o=D(e);if(!o)return console.log("SANDBOX-REDIRECT: isCheckoutLike - invalid URL",e),!1;if(!k(o.hostname))return console.log("SANDBOX-REDIRECT: isCheckoutLike - not Shopify host",o.hostname),!1;let t=I(o.pathname),n=u.some(i=>i.test(t));return n?(console.log("SANDBOX-REDIRECT: \u2705 Detected checkout-like URL:",String(o)),l("detected checkout-like URL:",String(o))):console.log("SANDBOX-REDIRECT: isCheckoutLike - path doesn't match patterns",t),n}async function h(){console.log("SANDBOX-REDIRECT: \u{1F680} jumpToCustomCheckout started"),console.log("SANDBOX-REDIRECT: Fetching /cart.js");let o=await(await fetch("/cart.js")).json();console.log("SANDBOX-REDIRECT: Cart data received",{token:o.token,itemCount:o.item_count,totalPrice:o.total_price});let t={},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_"],i=p=>n.some(g=>p===g||p.startsWith(g)||p.includes(g));document.cookie&&document.cookie.split(";").forEach(p=>{let g=p.trim();if(g){let[f,...O]=g.split("="),T=O.join("=");f&&T&&i(f)&&(t[f]=T)}}),console.log("SANDBOX-REDIRECT: Pixel cookies collected",{count:Object.keys(t).length});let c=`gid://shopify/Cart/${o.token}`;console.log("SANDBOX-REDIRECT: Sending checkout request to backend",{endpoint:`${r}/checkout`,cartId:c,storeId:s});let m=await(await fetch(`${r}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:s,cartId:c,cookies:t})})).text();if(console.log("SANDBOX-REDIRECT: Checkout URL received from backend",m),!m){console.error("SANDBOX-REDIRECT: \u274C No checkout ID received from backend");return}let _=D(m);if(!_){console.error("SANDBOX-REDIRECT: \u274C Invalid checkout URL received from backend:",m);return}console.log("SANDBOX-REDIRECT: \u2705 Redirecting to:",_.href),location.assign(_.href)}let E=!1;function a(e){return console.log("SANDBOX-REDIRECT: maybeRedirect called",{targetUrl:String(e),redirected:E}),E?(console.log("SANDBOX-REDIRECT: Already redirected, skipping"),!1):d(e)?(console.log("SANDBOX-REDIRECT: \u{1F3AF} Triggering redirect"),E=!0,h(),!0):(console.log("SANDBOX-REDIRECT: URL is not checkout-like, skipping"),!1)}if(window.__isCheckoutLike=d,window.__maybeRedirect=a,(y=window.Shopify)!=null&&y.designMode){console.log("SANDBOX-REDIRECT: In Shopify design mode, interceptors disabled");return}console.log("SANDBOX-REDIRECT: Setting up interceptors");{let e=window.location,o=e.assign.bind(e),t=e.replace.bind(e);try{Object.defineProperty(e,"assign",{value:n=>{console.log("SANDBOX-REDIRECT: location.assign intercepted",n),a(n)||o(n)},writable:!0,configurable:!0}),Object.defineProperty(e,"replace",{value:n=>{console.log("SANDBOX-REDIRECT: location.replace intercepted",n),a(n)||t(n)},writable:!0,configurable:!0}),console.log("SANDBOX-REDIRECT: \u2705 location.assign/replace interceptors installed")}catch(n){console.error("SANDBOX-REDIRECT: \u274C Failed to override location methods:",n),l("Could not override location methods, relying on Service Worker:",n)}}{let e=window.open;window.open=function(o,t,n){return console.log("SANDBOX-REDIRECT: window.open intercepted",{url:o,target:t}),o&&a(o)?null:e.call(window,o,t,n)},console.log("SANDBOX-REDIRECT: \u2705 window.open interceptor installed")}{let e=history.pushState.bind(history),o=history.replaceState.bind(history);history.pushState=function(t,n,i){if(console.log("SANDBOX-REDIRECT: history.pushState intercepted",i),!(i!=null&&a(i)))return e(t,n,i)},history.replaceState=function(t,n,i){if(console.log("SANDBOX-REDIRECT: history.replaceState intercepted",i),!(i!=null&&a(i)))return o(t,n,i)},addEventListener("popstate",()=>{console.log("SANDBOX-REDIRECT: popstate event fired",location.href),a(location.href)},!0),console.log("SANDBOX-REDIRECT: \u2705 History API interceptors installed")}{let e=o=>o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0;addEventListener("click",o=>{let t=o;if(t.defaultPrevented||e(t))return;let n=o.target;for(;n&&n.nodeType===1&&n.tagName!=="A";)n=n.parentElement;let i=n;!i||!i.href||(console.log("SANDBOX-REDIRECT: Link click intercepted",i.href),d(i.href)&&(console.log("SANDBOX-REDIRECT: \u{1F517} Checkout link clicked, preventing default"),t.preventDefault(),t.stopPropagation(),h()))},!0),console.log("SANDBOX-REDIRECT: \u2705 Link click interceptor installed")}{let e=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{if(console.log("SANDBOX-REDIRECT: Form.submit() intercepted",this.action),b(this))return console.log("SANDBOX-REDIRECT: Kaching form detected, skipping"),e.call(this);let t=this.getAttribute("action")||"";if(a(t)||Array.from(this.elements).some(i=>(i==null?void 0:i.name)==="checkout")&&(console.log("SANDBOX-REDIRECT: Form has checkout input, intercepting"),a("/checkout")))return}catch{}return e.call(this)},addEventListener("submit",o=>{try{let t=o.target;if(console.log("SANDBOX-REDIRECT: Form submit event intercepted",t==null?void 0:t.action),b(t)){console.log("SANDBOX-REDIRECT: Kaching form detected in submit event, skipping");return}let n=(t==null?void 0:t.getAttribute("action"))||"",i=Array.from((t==null?void 0:t.elements)||[]);(d(n)||i.some(c=>(c==null?void 0:c.name)==="checkout"))&&(console.log("SANDBOX-REDIRECT: \u{1F4DD} Checkout form submitted, preventing default"),o.preventDefault(),o.stopPropagation(),h())}catch{}},!0),console.log("SANDBOX-REDIRECT: \u2705 Form submit interceptors installed")}{let e=location.href;setInterval(()=>{location.href!==e&&(console.log("SANDBOX-REDIRECT: URL change detected by watchdog",{from:e,to:location.href}),e=location.href,a(e))},250),console.log("SANDBOX-REDIRECT: \u2705 URL watchdog installed")}{let e=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(t,n,i,c,C){try{console.log("SANDBOX-REDIRECT: XHR.open intercepted",{method:t,url:n}),typeof n=="string"&&d(n)&&(console.log("SANDBOX-REDIRECT: \u{1F310} XHR to checkout URL detected"),a(n))}catch{}return e.call(this,t,n,!!i,c,C)},console.log("SANDBOX-REDIRECT: \u2705 XHR interceptor installed")}{let e=window.fetch.bind(window);window.fetch=function(t,n){try{let i=typeof t=="string"||t instanceof URL?String(t):t.url;console.log("SANDBOX-REDIRECT: fetch() intercepted",i),i&&d(i)&&(console.log("SANDBOX-REDIRECT: \u{1F310} fetch() to checkout URL detected"),a(i))}catch{}return e(t,n)},console.log("SANDBOX-REDIRECT: \u2705 fetch() interceptor installed")}let b=e=>{if(!e)return!1;let o=Array.from(e.elements).some(t=>{var i,c;let n=t;return((i=n.name)==null?void 0:i.includes("__kaching_bundles"))||((c=n.name)==null?void 0:c.includes("kaching"))||e.classList.contains("kaching-form")});return o&&console.log("SANDBOX-REDIRECT: Form identified as Kaching form"),o};{console.log("SANDBOX-REDIRECT: Setting up Kaching API proxy");let e={},o;(S=window.kachingCartApi)!=null&&S.updateTieredPromotionsBar&&(console.log("SANDBOX-REDIRECT: Existing kachingCartApi found, capturing original"),o=window.kachingCartApi.updateTieredPromotionsBar,Object.assign(e,window.kachingCartApi)),window.kachingCartApi=new Proxy(e,{get(t,n){return n==="updateTieredPromotionsBar"?async function(...i){console.log("SANDBOX-REDIRECT: \u{1F6D2} Kaching updateTieredPromotionsBar called",i),o&&(console.log("SANDBOX-REDIRECT: Calling original Kaching function"),await o.apply(this,i)),console.log("SANDBOX-REDIRECT: Starting Kaching checkout redirect with 10s timeout"),await Promise.all([new Promise(c=>setTimeout(c,1e4)),h()])}:t[n]},set(t,n,i){return n==="updateTieredPromotionsBar"&&(console.log("SANDBOX-REDIRECT: Kaching updateTieredPromotionsBar being set, capturing it"),o=i,l("Kaching updateTieredPromotionsBar captured")),t[n]=i,!0}}),console.log("SANDBOX-REDIRECT: \u2705 Kaching API proxy installed")}},P=()=>{console.log("SANDBOX-REDIRECT: init() called");let s=document.currentScript;if(!s){console.error("SANDBOX-REDIRECT: \u274C No currentScript found");return}let r=s.dataset.revleyStoreId,u=s.dataset.revleyCheckoutHost;console.log("SANDBOX-REDIRECT: Script data attributes",{storeId:r,host:u}),r&&u?L(r,u):console.error("SANDBOX-REDIRECT: \u274C Missing storeId or host",{storeId:r,host:u})};P();
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- var A=(l,d)=>{if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let p=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts(?:\/|$|\?|#)/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 a(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(c=>u===c||u.startsWith(c)||u.includes(c));document.cookie&&document.cookie.split(";").forEach(u=>{let c=u.trim();if(c){let[f,...T]=c.split("="),v=T.join("=");f&&v&&r(f)&&(i[f]=v)}});let s=`gid://shopify/Cart/${n.token}`,m=await(await fetch(`${d}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:l,cartId:s,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||!a(t)?!1:(b=!0,g(),!0)}if(window.__isCheckoutLike=a,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||a(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||[]);(a(e)||r.some(s=>s?.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,s,w){try{typeof e=="string"&&a(e)&&o(e)}catch{}return t.call(this,i,e,!!r,s,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&&a(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),await new Promise(s=>setTimeout(s,1e3*1e4)),await g()}:i[e]},set(i,e,r){return e==="updateTieredPromotionsBar"&&(n=r,_("Kaching updateTieredPromotionsBar captured")),i[e]=r,!0}})}},U=()=>{let l=document.currentScript;if(!l)return;let d=l.dataset.revleyStoreId,p=l.dataset.revleyCheckoutHost;d&&p&&A(d,p)};U();
1
+ var I=(a,s)=>{if(console.log("SANDBOX-REDIRECT: Initializing checkout intercept",{storeId:a,checkoutHost:s}),window.__checkoutInterceptInstalled){console.log("SANDBOX-REDIRECT: Already installed, skipping");return}window.__checkoutInterceptInstalled=!0,console.log("SANDBOX-REDIRECT: Installation complete");let l=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts(?:\/|$|\?|#)/i],S=!1,m=(...e)=>S?console.debug("[checkout-intercept]",...e):void 0,C=e=>e.replace(/\/+$/,""),T=e=>e.endsWith(".myshopify.com")||e===location.hostname;function _(e,n=location.origin){try{return e instanceof URL?e:new URL(String(e),n)}catch{return null}}function u(e){let n=_(e);if(!n)return console.log("SANDBOX-REDIRECT: isCheckoutLike - invalid URL",e),!1;if(!T(n.hostname))return console.log("SANDBOX-REDIRECT: isCheckoutLike - not Shopify host",n.hostname),!1;let o=C(n.pathname),t=l.some(i=>i.test(o));return t?(console.log("SANDBOX-REDIRECT: \u2705 Detected checkout-like URL:",String(n)),m("detected checkout-like URL:",String(n))):console.log("SANDBOX-REDIRECT: isCheckoutLike - path doesn't match patterns",o),t}async function p(){console.log("SANDBOX-REDIRECT: \u{1F680} jumpToCustomCheckout started"),console.log("SANDBOX-REDIRECT: Fetching /cart.js");let n=await(await fetch("/cart.js")).json();console.log("SANDBOX-REDIRECT: Cart data received",{token:n.token,itemCount:n.item_count,totalPrice:n.total_price});let o={},t=["_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_"],i=g=>t.some(d=>g===d||g.startsWith(d)||g.includes(d));document.cookie&&document.cookie.split(";").forEach(g=>{let d=g.trim();if(d){let[f,...A]=d.split("="),y=A.join("=");f&&y&&i(f)&&(o[f]=y)}}),console.log("SANDBOX-REDIRECT: Pixel cookies collected",{count:Object.keys(o).length});let c=`gid://shopify/Cart/${n.token}`;console.log("SANDBOX-REDIRECT: Sending checkout request to backend",{endpoint:`${s}/checkout`,cartId:c,storeId:a});let R=await(await fetch(`${s}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:a,cartId:c,cookies:o})})).text();if(console.log("SANDBOX-REDIRECT: Checkout URL received from backend",R),!R){console.error("SANDBOX-REDIRECT: \u274C No checkout ID received from backend");return}let E=_(R);if(!E){console.error("SANDBOX-REDIRECT: \u274C Invalid checkout URL received from backend:",R);return}console.log("SANDBOX-REDIRECT: \u2705 Redirecting to:",E.href),location.assign(E.href)}let h=!1;function r(e){return console.log("SANDBOX-REDIRECT: maybeRedirect called",{targetUrl:String(e),redirected:h}),h?(console.log("SANDBOX-REDIRECT: Already redirected, skipping"),!1):u(e)?(console.log("SANDBOX-REDIRECT: \u{1F3AF} Triggering redirect"),h=!0,p(),!0):(console.log("SANDBOX-REDIRECT: URL is not checkout-like, skipping"),!1)}if(window.__isCheckoutLike=u,window.__maybeRedirect=r,window.Shopify?.designMode){console.log("SANDBOX-REDIRECT: In Shopify design mode, interceptors disabled");return}console.log("SANDBOX-REDIRECT: Setting up interceptors");{let e=window.location,n=e.assign.bind(e),o=e.replace.bind(e);try{Object.defineProperty(e,"assign",{value:t=>{console.log("SANDBOX-REDIRECT: location.assign intercepted",t),r(t)||n(t)},writable:!0,configurable:!0}),Object.defineProperty(e,"replace",{value:t=>{console.log("SANDBOX-REDIRECT: location.replace intercepted",t),r(t)||o(t)},writable:!0,configurable:!0}),console.log("SANDBOX-REDIRECT: \u2705 location.assign/replace interceptors installed")}catch(t){console.error("SANDBOX-REDIRECT: \u274C Failed to override location methods:",t),m("Could not override location methods, relying on Service Worker:",t)}}{let e=window.open;window.open=function(n,o,t){return console.log("SANDBOX-REDIRECT: window.open intercepted",{url:n,target:o}),n&&r(n)?null:e.call(window,n,o,t)},console.log("SANDBOX-REDIRECT: \u2705 window.open interceptor installed")}{let e=history.pushState.bind(history),n=history.replaceState.bind(history);history.pushState=function(o,t,i){if(console.log("SANDBOX-REDIRECT: history.pushState intercepted",i),!(i!=null&&r(i)))return e(o,t,i)},history.replaceState=function(o,t,i){if(console.log("SANDBOX-REDIRECT: history.replaceState intercepted",i),!(i!=null&&r(i)))return n(o,t,i)},addEventListener("popstate",()=>{console.log("SANDBOX-REDIRECT: popstate event fired",location.href),r(location.href)},!0),console.log("SANDBOX-REDIRECT: \u2705 History API interceptors installed")}{let e=n=>n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0;addEventListener("click",n=>{let o=n;if(o.defaultPrevented||e(o))return;let t=n.target;for(;t&&t.nodeType===1&&t.tagName!=="A";)t=t.parentElement;let i=t;!i||!i.href||(console.log("SANDBOX-REDIRECT: Link click intercepted",i.href),u(i.href)&&(console.log("SANDBOX-REDIRECT: \u{1F517} Checkout link clicked, preventing default"),o.preventDefault(),o.stopPropagation(),p()))},!0),console.log("SANDBOX-REDIRECT: \u2705 Link click interceptor installed")}{let e=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{if(console.log("SANDBOX-REDIRECT: Form.submit() intercepted",this.action),D(this))return console.log("SANDBOX-REDIRECT: Kaching form detected, skipping"),e.call(this);let o=this.getAttribute("action")||"";if(r(o)||Array.from(this.elements).some(i=>i?.name==="checkout")&&(console.log("SANDBOX-REDIRECT: Form has checkout input, intercepting"),r("/checkout")))return}catch{}return e.call(this)},addEventListener("submit",n=>{try{let o=n.target;if(console.log("SANDBOX-REDIRECT: Form submit event intercepted",o?.action),D(o)){console.log("SANDBOX-REDIRECT: Kaching form detected in submit event, skipping");return}let t=o?.getAttribute("action")||"",i=Array.from(o?.elements||[]);(u(t)||i.some(c=>c?.name==="checkout"))&&(console.log("SANDBOX-REDIRECT: \u{1F4DD} Checkout form submitted, preventing default"),n.preventDefault(),n.stopPropagation(),p())}catch{}},!0),console.log("SANDBOX-REDIRECT: \u2705 Form submit interceptors installed")}{let e=location.href;setInterval(()=>{location.href!==e&&(console.log("SANDBOX-REDIRECT: URL change detected by watchdog",{from:e,to:location.href}),e=location.href,r(e))},250),console.log("SANDBOX-REDIRECT: \u2705 URL watchdog installed")}{let e=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(o,t,i,c,b){try{console.log("SANDBOX-REDIRECT: XHR.open intercepted",{method:o,url:t}),typeof t=="string"&&u(t)&&(console.log("SANDBOX-REDIRECT: \u{1F310} XHR to checkout URL detected"),r(t))}catch{}return e.call(this,o,t,!!i,c,b)},console.log("SANDBOX-REDIRECT: \u2705 XHR interceptor installed")}{let e=window.fetch.bind(window);window.fetch=function(o,t){try{let i=typeof o=="string"||o instanceof URL?String(o):o.url;console.log("SANDBOX-REDIRECT: fetch() intercepted",i),i&&u(i)&&(console.log("SANDBOX-REDIRECT: \u{1F310} fetch() to checkout URL detected"),r(i))}catch{}return e(o,t)},console.log("SANDBOX-REDIRECT: \u2705 fetch() interceptor installed")}let D=e=>{if(!e)return!1;let n=Array.from(e.elements).some(o=>{let t=o;return t.name?.includes("__kaching_bundles")||t.name?.includes("kaching")||e.classList.contains("kaching-form")});return n&&console.log("SANDBOX-REDIRECT: Form identified as Kaching form"),n};{console.log("SANDBOX-REDIRECT: Setting up Kaching API proxy");let e={},n;window.kachingCartApi?.updateTieredPromotionsBar&&(console.log("SANDBOX-REDIRECT: Existing kachingCartApi found, capturing original"),n=window.kachingCartApi.updateTieredPromotionsBar,Object.assign(e,window.kachingCartApi)),window.kachingCartApi=new Proxy(e,{get(o,t){return t==="updateTieredPromotionsBar"?async function(...i){console.log("SANDBOX-REDIRECT: \u{1F6D2} Kaching updateTieredPromotionsBar called",i),n&&(console.log("SANDBOX-REDIRECT: Calling original Kaching function"),await n.apply(this,i)),console.log("SANDBOX-REDIRECT: Starting Kaching checkout redirect with 10s timeout"),await Promise.all([new Promise(c=>setTimeout(c,1e4)),p()])}:o[t]},set(o,t,i){return t==="updateTieredPromotionsBar"&&(console.log("SANDBOX-REDIRECT: Kaching updateTieredPromotionsBar being set, capturing it"),n=i,m("Kaching updateTieredPromotionsBar captured")),o[t]=i,!0}}),console.log("SANDBOX-REDIRECT: \u2705 Kaching API proxy installed")}},k=()=>{console.log("SANDBOX-REDIRECT: init() called");let a=document.currentScript;if(!a){console.error("SANDBOX-REDIRECT: \u274C No currentScript found");return}let s=a.dataset.revleyStoreId,l=a.dataset.revleyCheckoutHost;console.log("SANDBOX-REDIRECT: Script data attributes",{storeId:s,host:l}),s&&l?I(s,l):console.error("SANDBOX-REDIRECT: \u274C Missing storeId or host",{storeId:s,host:l})};k();
@@ -1 +1 @@
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(?:\/|$|\?|#)/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),await new Promise(u=>setTimeout(u,1e3*1e4)),await 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);})();
1
+ "use strict";var SandboxCheckoutPkg=(()=>{var A=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var w=(s,r,u,h)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of X(r))!N.call(s,l)&&l!==u&&A(s,l,{get:()=>r[l],enumerable:!(h=B(r,l))||h.enumerable});return s};var v=s=>w(A({},"__esModule",{value:!0}),s);var U={};var L=(s,r)=>{var y,S;if(console.log("SANDBOX-REDIRECT: Initializing checkout intercept",{storeId:s,checkoutHost:r}),window.__checkoutInterceptInstalled){console.log("SANDBOX-REDIRECT: Already installed, skipping");return}window.__checkoutInterceptInstalled=!0,console.log("SANDBOX-REDIRECT: Installation complete");let u=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts(?:\/|$|\?|#)/i],h=!1,l=(...t)=>h?console.debug("[checkout-intercept]",...t):void 0,I=t=>t.replace(/\/+$/,""),k=t=>t.endsWith(".myshopify.com")||t===location.hostname;function D(t,o=location.origin){try{return t instanceof URL?t:new URL(String(t),o)}catch(e){return null}}function d(t){let o=D(t);if(!o)return console.log("SANDBOX-REDIRECT: isCheckoutLike - invalid URL",t),!1;if(!k(o.hostname))return console.log("SANDBOX-REDIRECT: isCheckoutLike - not Shopify host",o.hostname),!1;let e=I(o.pathname),n=u.some(i=>i.test(e));return n?(console.log("SANDBOX-REDIRECT: \u2705 Detected checkout-like URL:",String(o)),l("detected checkout-like URL:",String(o))):console.log("SANDBOX-REDIRECT: isCheckoutLike - path doesn't match patterns",e),n}async function m(){console.log("SANDBOX-REDIRECT: \u{1F680} jumpToCustomCheckout started"),console.log("SANDBOX-REDIRECT: Fetching /cart.js");let o=await(await fetch("/cart.js")).json();console.log("SANDBOX-REDIRECT: Cart data received",{token:o.token,itemCount:o.item_count,totalPrice:o.total_price});let 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_"],i=R=>n.some(g=>R===g||R.startsWith(g)||R.includes(g));document.cookie&&document.cookie.split(";").forEach(R=>{let g=R.trim();if(g){let[f,...O]=g.split("="),T=O.join("=");f&&T&&i(f)&&(e[f]=T)}}),console.log("SANDBOX-REDIRECT: Pixel cookies collected",{count:Object.keys(e).length});let c=`gid://shopify/Cart/${o.token}`;console.log("SANDBOX-REDIRECT: Sending checkout request to backend",{endpoint:`${r}/checkout`,cartId:c,storeId:s});let p=await(await fetch(`${r}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:s,cartId:c,cookies:e})})).text();if(console.log("SANDBOX-REDIRECT: Checkout URL received from backend",p),!p){console.error("SANDBOX-REDIRECT: \u274C No checkout ID received from backend");return}let _=D(p);if(!_){console.error("SANDBOX-REDIRECT: \u274C Invalid checkout URL received from backend:",p);return}console.log("SANDBOX-REDIRECT: \u2705 Redirecting to:",_.href),location.assign(_.href)}let E=!1;function a(t){return console.log("SANDBOX-REDIRECT: maybeRedirect called",{targetUrl:String(t),redirected:E}),E?(console.log("SANDBOX-REDIRECT: Already redirected, skipping"),!1):d(t)?(console.log("SANDBOX-REDIRECT: \u{1F3AF} Triggering redirect"),E=!0,m(),!0):(console.log("SANDBOX-REDIRECT: URL is not checkout-like, skipping"),!1)}if(window.__isCheckoutLike=d,window.__maybeRedirect=a,(y=window.Shopify)!=null&&y.designMode){console.log("SANDBOX-REDIRECT: In Shopify design mode, interceptors disabled");return}console.log("SANDBOX-REDIRECT: Setting up interceptors");{let t=window.location,o=t.assign.bind(t),e=t.replace.bind(t);try{Object.defineProperty(t,"assign",{value:n=>{console.log("SANDBOX-REDIRECT: location.assign intercepted",n),a(n)||o(n)},writable:!0,configurable:!0}),Object.defineProperty(t,"replace",{value:n=>{console.log("SANDBOX-REDIRECT: location.replace intercepted",n),a(n)||e(n)},writable:!0,configurable:!0}),console.log("SANDBOX-REDIRECT: \u2705 location.assign/replace interceptors installed")}catch(n){console.error("SANDBOX-REDIRECT: \u274C Failed to override location methods:",n),l("Could not override location methods, relying on Service Worker:",n)}}{let t=window.open;window.open=function(o,e,n){return console.log("SANDBOX-REDIRECT: window.open intercepted",{url:o,target:e}),o&&a(o)?null:t.call(window,o,e,n)},console.log("SANDBOX-REDIRECT: \u2705 window.open interceptor installed")}{let t=history.pushState.bind(history),o=history.replaceState.bind(history);history.pushState=function(e,n,i){if(console.log("SANDBOX-REDIRECT: history.pushState intercepted",i),!(i!=null&&a(i)))return t(e,n,i)},history.replaceState=function(e,n,i){if(console.log("SANDBOX-REDIRECT: history.replaceState intercepted",i),!(i!=null&&a(i)))return o(e,n,i)},addEventListener("popstate",()=>{console.log("SANDBOX-REDIRECT: popstate event fired",location.href),a(location.href)},!0),console.log("SANDBOX-REDIRECT: \u2705 History API interceptors installed")}{let t=o=>o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0;addEventListener("click",o=>{let e=o;if(e.defaultPrevented||t(e))return;let n=o.target;for(;n&&n.nodeType===1&&n.tagName!=="A";)n=n.parentElement;let i=n;!i||!i.href||(console.log("SANDBOX-REDIRECT: Link click intercepted",i.href),d(i.href)&&(console.log("SANDBOX-REDIRECT: \u{1F517} Checkout link clicked, preventing default"),e.preventDefault(),e.stopPropagation(),m()))},!0),console.log("SANDBOX-REDIRECT: \u2705 Link click interceptor installed")}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{if(console.log("SANDBOX-REDIRECT: Form.submit() intercepted",this.action),b(this))return console.log("SANDBOX-REDIRECT: Kaching form detected, skipping"),t.call(this);let e=this.getAttribute("action")||"";if(a(e)||Array.from(this.elements).some(i=>(i==null?void 0:i.name)==="checkout")&&(console.log("SANDBOX-REDIRECT: Form has checkout input, intercepting"),a("/checkout")))return}catch(e){}return t.call(this)},addEventListener("submit",o=>{try{let e=o.target;if(console.log("SANDBOX-REDIRECT: Form submit event intercepted",e==null?void 0:e.action),b(e)){console.log("SANDBOX-REDIRECT: Kaching form detected in submit event, skipping");return}let n=(e==null?void 0:e.getAttribute("action"))||"",i=Array.from((e==null?void 0:e.elements)||[]);(d(n)||i.some(c=>(c==null?void 0:c.name)==="checkout"))&&(console.log("SANDBOX-REDIRECT: \u{1F4DD} Checkout form submitted, preventing default"),o.preventDefault(),o.stopPropagation(),m())}catch(e){}},!0),console.log("SANDBOX-REDIRECT: \u2705 Form submit interceptors installed")}{let t=location.href;setInterval(()=>{location.href!==t&&(console.log("SANDBOX-REDIRECT: URL change detected by watchdog",{from:t,to:location.href}),t=location.href,a(t))},250),console.log("SANDBOX-REDIRECT: \u2705 URL watchdog installed")}{let t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(e,n,i,c,C){try{console.log("SANDBOX-REDIRECT: XHR.open intercepted",{method:e,url:n}),typeof n=="string"&&d(n)&&(console.log("SANDBOX-REDIRECT: \u{1F310} XHR to checkout URL detected"),a(n))}catch(p){}return t.call(this,e,n,!!i,c,C)},console.log("SANDBOX-REDIRECT: \u2705 XHR interceptor installed")}{let t=window.fetch.bind(window);window.fetch=function(e,n){try{let i=typeof e=="string"||e instanceof URL?String(e):e.url;console.log("SANDBOX-REDIRECT: fetch() intercepted",i),i&&d(i)&&(console.log("SANDBOX-REDIRECT: \u{1F310} fetch() to checkout URL detected"),a(i))}catch(i){}return t(e,n)},console.log("SANDBOX-REDIRECT: \u2705 fetch() interceptor installed")}let b=t=>{if(!t)return!1;let o=Array.from(t.elements).some(e=>{var i,c;let n=e;return((i=n.name)==null?void 0:i.includes("__kaching_bundles"))||((c=n.name)==null?void 0:c.includes("kaching"))||t.classList.contains("kaching-form")});return o&&console.log("SANDBOX-REDIRECT: Form identified as Kaching form"),o};{console.log("SANDBOX-REDIRECT: Setting up Kaching API proxy");let t={},o;(S=window.kachingCartApi)!=null&&S.updateTieredPromotionsBar&&(console.log("SANDBOX-REDIRECT: Existing kachingCartApi found, capturing original"),o=window.kachingCartApi.updateTieredPromotionsBar,Object.assign(t,window.kachingCartApi)),window.kachingCartApi=new Proxy(t,{get(e,n){return n==="updateTieredPromotionsBar"?async function(...i){console.log("SANDBOX-REDIRECT: \u{1F6D2} Kaching updateTieredPromotionsBar called",i),o&&(console.log("SANDBOX-REDIRECT: Calling original Kaching function"),await o.apply(this,i)),console.log("SANDBOX-REDIRECT: Starting Kaching checkout redirect with 10s timeout"),await Promise.all([new Promise(c=>setTimeout(c,1e4)),m()])}:e[n]},set(e,n,i){return n==="updateTieredPromotionsBar"&&(console.log("SANDBOX-REDIRECT: Kaching updateTieredPromotionsBar being set, capturing it"),o=i,l("Kaching updateTieredPromotionsBar captured")),e[n]=i,!0}}),console.log("SANDBOX-REDIRECT: \u2705 Kaching API proxy installed")}},P=()=>{console.log("SANDBOX-REDIRECT: init() called");let s=document.currentScript;if(!s){console.error("SANDBOX-REDIRECT: \u274C No currentScript found");return}let r=s.dataset.revleyStoreId,u=s.dataset.revleyCheckoutHost;console.log("SANDBOX-REDIRECT: Script data attributes",{storeId:r,host:u}),r&&u?L(r,u):console.error("SANDBOX-REDIRECT: \u274C Missing storeId or host",{storeId:r,host:u})};P();return v(U);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revley/sandbox-checkout-package",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "description": "Tiny TS package optimized for browsers with modern & legacy outputs",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.cjs",