@revley/sandbox-checkout-package 0.1.997 → 0.1.999

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 R=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var A=(l,a,g,_)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of U(a))!x.call(l,c)&&c!==g&&R(l,c,{get:()=>a[c],enumerable:!(_=E(a,c))||_.enumerable});return l};var I=l=>A(R({},"__esModule",{value:!0}),l);var T={};module.exports=I(T);window.initRevleyCheckout=(l,a)=>{var v;if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let g=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],_=!1,c=(...t)=>_?console.debug("[checkout-intercept]",...t):void 0,k=t=>t.replace(/\/+$/,""),L=t=>t.endsWith(".myshopify.com")||t===location.hostname;function P(t,n=location.origin){try{return t instanceof URL?t:new URL(String(t),n)}catch{return null}}function d(t){let n=P(t);if(!n||!L(n.hostname))return!1;let i=k(n.pathname),e=g.some(r=>r.test(i));return e&&c("detected checkout-like URL:",String(n)),e}async function m(){let n=await(await fetch("/cart.js")).json(),i=n.discount_codes||[],e=(n.items||[]).map(o=>({variantId:o==null?void 0:o.variant_id,quantity:(o==null?void 0:o.quantity)||0,sellingPlanAllocation:(o==null?void 0:o.selling_plan_allocation)||null})).filter(o=>!!o.variantId&&o.quantity>0),r={},u=["_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_"],f=o=>u.some(p=>o===p||o.startsWith(p)||o.includes(p));document.cookie&&document.cookie.split(";").forEach(o=>{let p=o.trim();if(p){let[b,...S]=p.split("="),w=S.join("=");b&&w&&f(b)&&(r[b]=w)}});let h=await(await fetch(`${a}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({discountCodes:i,variants:e,storeId:l,cookies:r})})).text();if(console.log("checkoutUrl",h),h)location.assign(h);else{console.error("No checkout ID received from backend");return}}let y=!1;function s(t){return y||!d(t)?!1:(y=!0,m(),!0)}if(window.__isCheckoutLike=d,window.__maybeRedirect=s,!((v=window.Shopify)!=null&&v.designMode)){{let t=window.location,n=t.assign.bind(t),i=t.replace.bind(t);try{Object.defineProperty(t,"assign",{value:e=>{s(e)||n(e)},writable:!0,configurable:!0}),Object.defineProperty(t,"replace",{value:e=>{s(e)||i(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(n,i,e){return n&&s(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&&s(r)))return t(i,e,r)},history.replaceState=function(i,e,r){if(!(r!=null&&s(r)))return n(i,e,r)},addEventListener("popstate",()=>void s(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||d(r.href)&&(i.preventDefault(),i.stopPropagation(),m())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{let i=this.getAttribute("action")||"";if(s(i)||Array.from(this.elements).some(r=>(r==null?void 0:r.name)==="checkout")&&s("/checkout"))return}catch{}return t.call(this)},addEventListener("submit",n=>{try{let i=n.target,e=(i==null?void 0:i.getAttribute("action"))||"",r=Array.from((i==null?void 0:i.elements)||[]);(d(e)||r.some(u=>(u==null?void 0:u.name)==="checkout"))&&(n.preventDefault(),n.stopPropagation(),m())}catch{}},!0)}{let t=location.href;setInterval(()=>{location.href!==t&&(t=location.href,s(t))},250)}{let t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(i,e,r,u,f){try{typeof e=="string"&&d(e)&&s(e)}catch{}return t.call(this,i,e,!!r,u,f)}}{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&&d(r)&&s(r)}catch{}return t(i,e)}}}};
1
+ "use strict";var R=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var A=(l,a,g,_)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of U(a))!x.call(l,c)&&c!==g&&R(l,c,{get:()=>a[c],enumerable:!(_=E(a,c))||_.enumerable});return l};var I=l=>A(R({},"__esModule",{value:!0}),l);var T={};module.exports=I(T);window.initRevleyCheckout=(l,a)=>{var v;if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let g=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],_=!1,c=(...t)=>_?console.debug("[checkout-intercept]",...t):void 0,k=t=>t.replace(/\/+$/,""),L=t=>t.endsWith(".myshopify.com")||t===location.hostname;function P(t,n=location.origin){try{return t instanceof URL?t:new URL(String(t),n)}catch{return null}}function p(t){let n=P(t);if(!n||!L(n.hostname))return!1;let i=k(n.pathname),e=g.some(r=>r.test(i));return e&&c("detected checkout-like URL:",String(n)),e}async function m(){let n=await(await fetch("/cart.js")).json(),i=n.discount_codes||[],e=(n.items||[]).map(o=>({variantId:o==null?void 0:o.variant_id,quantity:(o==null?void 0:o.quantity)||0,sellingPlanAllocation:(o==null?void 0:o.selling_plan_allocation)||null})).filter(o=>!!o.variantId&&o.quantity>0),r={},u=["_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_"],f=o=>u.some(d=>o===d||o.startsWith(d)||o.includes(d));document.cookie&&document.cookie.split(";").forEach(o=>{let d=o.trim();if(d){let[b,...S]=d.split("="),w=S.join("=");b&&w&&f(b)&&(r[b]=w)}});let h=await(await fetch(`${a}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variants:e,storeId:l,cookies:r})})).text();if(console.log("checkoutUrl",h),h)location.assign(h);else{console.error("No checkout ID received from backend");return}}let y=!1;function s(t){return y||!p(t)?!1:(y=!0,m(),!0)}if(window.__isCheckoutLike=p,window.__maybeRedirect=s,!((v=window.Shopify)!=null&&v.designMode)){{let t=window.location,n=t.assign.bind(t),i=t.replace.bind(t);try{Object.defineProperty(t,"assign",{value:e=>{s(e)||n(e)},writable:!0,configurable:!0}),Object.defineProperty(t,"replace",{value:e=>{s(e)||i(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(n,i,e){return n&&s(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&&s(r)))return t(i,e,r)},history.replaceState=function(i,e,r){if(!(r!=null&&s(r)))return n(i,e,r)},addEventListener("popstate",()=>void s(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||p(r.href)&&(i.preventDefault(),i.stopPropagation(),m())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{let i=this.getAttribute("action")||"";if(s(i)||Array.from(this.elements).some(r=>(r==null?void 0:r.name)==="checkout")&&s("/checkout"))return}catch{}return t.call(this)},addEventListener("submit",n=>{try{let i=n.target,e=(i==null?void 0:i.getAttribute("action"))||"",r=Array.from((i==null?void 0:i.elements)||[]);(p(e)||r.some(u=>(u==null?void 0:u.name)==="checkout"))&&(n.preventDefault(),n.stopPropagation(),m())}catch{}},!0)}{let t=location.href;setInterval(()=>{location.href!==t&&(t=location.href,s(t))},250)}{let t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(i,e,r,u,f){try{typeof e=="string"&&p(e)&&s(e)}catch{}return t.call(this,i,e,!!r,u,f)}}{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&&p(r)&&s(r)}catch{}return t(i,e)}}}};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- window.initRevleyCheckout=(h,b)=>{if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let y=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],v=!1,g=(...t)=>v?console.debug("[checkout-intercept]",...t):void 0,w=t=>t.replace(/\/+$/,""),R=t=>t.endsWith(".myshopify.com")||t===location.hostname;function k(t,n=location.origin){try{return t instanceof URL?t:new URL(String(t),n)}catch{return null}}function a(t){let n=k(t);if(!n||!R(n.hostname))return!1;let i=w(n.pathname),e=y.some(r=>r.test(i));return e&&g("detected checkout-like URL:",String(n)),e}async function u(){let n=await(await fetch("/cart.js")).json(),i=n.discount_codes||[],e=(n.items||[]).map(s=>({variantId:s?.variant_id,quantity:s?.quantity||0,sellingPlanAllocation:s?.selling_plan_allocation||null})).filter(s=>!!s.variantId&&s.quantity>0),r={},l=["_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_"],d=s=>l.some(c=>s===c||s.startsWith(c)||s.includes(c));document.cookie&&document.cookie.split(";").forEach(s=>{let c=s.trim();if(c){let[_,...L]=c.split("="),f=L.join("=");_&&f&&d(_)&&(r[_]=f)}});let p=await(await fetch(`${b}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({discountCodes:i,variants:e,storeId:h,cookies:r})})).text();if(console.log("checkoutUrl",p),p)location.assign(p);else{console.error("No checkout ID received from backend");return}}let m=!1;function o(t){return m||!a(t)?!1:(m=!0,u(),!0)}if(window.__isCheckoutLike=a,window.__maybeRedirect=o,!window.Shopify?.designMode){{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){g("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(),u())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{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,e=i?.getAttribute("action")||"",r=Array.from(i?.elements||[]);(a(e)||r.some(l=>l?.name==="checkout"))&&(n.preventDefault(),n.stopPropagation(),u())}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,d){try{typeof e=="string"&&a(e)&&o(e)}catch{}return t.call(this,i,e,!!r,l,d)}}{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)}}}};
1
+ window.initRevleyCheckout=(h,b)=>{if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let y=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],v=!1,g=(...t)=>v?console.debug("[checkout-intercept]",...t):void 0,w=t=>t.replace(/\/+$/,""),R=t=>t.endsWith(".myshopify.com")||t===location.hostname;function k(t,n=location.origin){try{return t instanceof URL?t:new URL(String(t),n)}catch{return null}}function a(t){let n=k(t);if(!n||!R(n.hostname))return!1;let i=w(n.pathname),e=y.some(r=>r.test(i));return e&&g("detected checkout-like URL:",String(n)),e}async function u(){let n=await(await fetch("/cart.js")).json(),i=n.discount_codes||[],e=(n.items||[]).map(s=>({variantId:s?.variant_id,quantity:s?.quantity||0,sellingPlanAllocation:s?.selling_plan_allocation||null})).filter(s=>!!s.variantId&&s.quantity>0),r={},l=["_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_"],p=s=>l.some(c=>s===c||s.startsWith(c)||s.includes(c));document.cookie&&document.cookie.split(";").forEach(s=>{let c=s.trim();if(c){let[_,...L]=c.split("="),f=L.join("=");_&&f&&p(_)&&(r[_]=f)}});let d=await(await fetch(`${b}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variants:e,storeId:h,cookies:r})})).text();if(console.log("checkoutUrl",d),d)location.assign(d);else{console.error("No checkout ID received from backend");return}}let m=!1;function o(t){return m||!a(t)?!1:(m=!0,u(),!0)}if(window.__isCheckoutLike=a,window.__maybeRedirect=o,!window.Shopify?.designMode){{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){g("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(),u())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{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,e=i?.getAttribute("action")||"",r=Array.from(i?.elements||[]);(a(e)||r.some(l=>l?.name==="checkout"))&&(n.preventDefault(),n.stopPropagation(),u())}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,p){try{typeof e=="string"&&a(e)&&o(e)}catch{}return t.call(this,i,e,!!r,l,p)}}{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)}}}};
@@ -1 +1 @@
1
- "use strict";var SandboxCheckoutPkg=(()=>{var R=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var I=(l,a,g,_)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of x(a))!A.call(l,c)&&c!==g&&R(l,c,{get:()=>a[c],enumerable:!(_=U(a,c))||_.enumerable});return l};var T=l=>I(R({},"__esModule",{value:!0}),l);var C={};window.initRevleyCheckout=(l,a)=>{var v;if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let g=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],_=!1,c=(...t)=>_?console.debug("[checkout-intercept]",...t):void 0,k=t=>t.replace(/\/+$/,""),L=t=>t.endsWith(".myshopify.com")||t===location.hostname;function P(t,i=location.origin){try{return t instanceof URL?t:new URL(String(t),i)}catch(e){return null}}function d(t){let i=P(t);if(!i||!L(i.hostname))return!1;let e=k(i.pathname),n=g.some(r=>r.test(e));return n&&c("detected checkout-like URL:",String(i)),n}async function m(){let i=await(await fetch("/cart.js")).json(),e=i.discount_codes||[],n=(i.items||[]).map(o=>({variantId:o==null?void 0:o.variant_id,quantity:(o==null?void 0:o.quantity)||0,sellingPlanAllocation:(o==null?void 0:o.selling_plan_allocation)||null})).filter(o=>!!o.variantId&&o.quantity>0),r={},u=["_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_"],f=o=>u.some(p=>o===p||o.startsWith(p)||o.includes(p));document.cookie&&document.cookie.split(";").forEach(o=>{let p=o.trim();if(p){let[b,...E]=p.split("="),w=E.join("=");b&&w&&f(b)&&(r[b]=w)}});let h=await(await fetch(`${a}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({discountCodes:e,variants:n,storeId:l,cookies:r})})).text();if(console.log("checkoutUrl",h),h)location.assign(h);else{console.error("No checkout ID received from backend");return}}let y=!1;function s(t){return y||!d(t)?!1:(y=!0,m(),!0)}if(window.__isCheckoutLike=d,window.__maybeRedirect=s,!((v=window.Shopify)!=null&&v.designMode)){{let t=window.location,i=t.assign.bind(t),e=t.replace.bind(t);try{Object.defineProperty(t,"assign",{value:n=>{s(n)||i(n)},writable:!0,configurable:!0}),Object.defineProperty(t,"replace",{value:n=>{s(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&&s(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&&s(r)))return t(e,n,r)},history.replaceState=function(e,n,r){if(!(r!=null&&s(r)))return i(e,n,r)},addEventListener("popstate",()=>void s(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(),m())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{let e=this.getAttribute("action")||"";if(s(e)||Array.from(this.elements).some(r=>(r==null?void 0:r.name)==="checkout")&&s("/checkout"))return}catch(e){}return t.call(this)},addEventListener("submit",i=>{try{let e=i.target,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(),m())}catch(e){}},!0)}{let t=location.href;setInterval(()=>{location.href!==t&&(t=location.href,s(t))},250)}{let t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(e,n,r,u,f){try{typeof n=="string"&&d(n)&&s(n)}catch(S){}return t.call(this,e,n,!!r,u,f)}}{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)&&s(r)}catch(r){}return t(e,n)}}}};return T(C);})();
1
+ "use strict";var SandboxCheckoutPkg=(()=>{var R=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var I=(l,a,g,_)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of x(a))!A.call(l,c)&&c!==g&&R(l,c,{get:()=>a[c],enumerable:!(_=U(a,c))||_.enumerable});return l};var T=l=>I(R({},"__esModule",{value:!0}),l);var H={};window.initRevleyCheckout=(l,a)=>{var v;if(window.__checkoutInterceptInstalled)return;window.__checkoutInterceptInstalled=!0;let g=[/^\/(?:cart\/)?checkout(?:[?#]|$)/i,/^\/checkouts\/[a-z0-9]{32}(?:[\/?#]|$)/i],_=!1,c=(...t)=>_?console.debug("[checkout-intercept]",...t):void 0,k=t=>t.replace(/\/+$/,""),L=t=>t.endsWith(".myshopify.com")||t===location.hostname;function P(t,i=location.origin){try{return t instanceof URL?t:new URL(String(t),i)}catch(e){return null}}function p(t){let i=P(t);if(!i||!L(i.hostname))return!1;let e=k(i.pathname),n=g.some(r=>r.test(e));return n&&c("detected checkout-like URL:",String(i)),n}async function m(){let i=await(await fetch("/cart.js")).json(),e=i.discount_codes||[],n=(i.items||[]).map(o=>({variantId:o==null?void 0:o.variant_id,quantity:(o==null?void 0:o.quantity)||0,sellingPlanAllocation:(o==null?void 0:o.selling_plan_allocation)||null})).filter(o=>!!o.variantId&&o.quantity>0),r={},u=["_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_"],f=o=>u.some(d=>o===d||o.startsWith(d)||o.includes(d));document.cookie&&document.cookie.split(";").forEach(o=>{let d=o.trim();if(d){let[b,...E]=d.split("="),w=E.join("=");b&&w&&f(b)&&(r[b]=w)}});let h=await(await fetch(`${a}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variants:n,storeId:l,cookies:r})})).text();if(console.log("checkoutUrl",h),h)location.assign(h);else{console.error("No checkout ID received from backend");return}}let y=!1;function s(t){return y||!p(t)?!1:(y=!0,m(),!0)}if(window.__isCheckoutLike=p,window.__maybeRedirect=s,!((v=window.Shopify)!=null&&v.designMode)){{let t=window.location,i=t.assign.bind(t),e=t.replace.bind(t);try{Object.defineProperty(t,"assign",{value:n=>{s(n)||i(n)},writable:!0,configurable:!0}),Object.defineProperty(t,"replace",{value:n=>{s(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&&s(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&&s(r)))return t(e,n,r)},history.replaceState=function(e,n,r){if(!(r!=null&&s(r)))return i(e,n,r)},addEventListener("popstate",()=>void s(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||p(r.href)&&(e.preventDefault(),e.stopPropagation(),m())},!0)}{let t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){try{let e=this.getAttribute("action")||"";if(s(e)||Array.from(this.elements).some(r=>(r==null?void 0:r.name)==="checkout")&&s("/checkout"))return}catch(e){}return t.call(this)},addEventListener("submit",i=>{try{let e=i.target,n=(e==null?void 0:e.getAttribute("action"))||"",r=Array.from((e==null?void 0:e.elements)||[]);(p(n)||r.some(u=>(u==null?void 0:u.name)==="checkout"))&&(i.preventDefault(),i.stopPropagation(),m())}catch(e){}},!0)}{let t=location.href;setInterval(()=>{location.href!==t&&(t=location.href,s(t))},250)}{let t=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(e,n,r,u,f){try{typeof n=="string"&&p(n)&&s(n)}catch(S){}return t.call(this,e,n,!!r,u,f)}}{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&&p(r)&&s(r)}catch(r){}return t(e,n)}}}};return T(H);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revley/sandbox-checkout-package",
3
- "version": "0.1.997",
3
+ "version": "0.1.999",
4
4
  "description": "Tiny TS package optimized for browsers with modern & legacy outputs",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.cjs",