@fungies/fungies-js 0.7.1 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Add `DOM_CHECKOUT_EVENTS` and dispatch `fungies:checkout:complete` / `fungies:checkout:close` document events when the checkout iframe posts `checkoutComplete` or `closeWindow`
8
+
9
+ ## 0.7.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Extend iframe payment permissions
14
+
3
15
  ## 0.0.7
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Fungies=(()=>{var t=Object.defineProperty,e=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,i=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(e,n,i)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,s=(t,e)=>{for(var n in e||(e={}))a.call(e,n)&&r(t,n,e[n]);if(i)for(var n of i(e))o.call(e,n)&&r(t,n,e[n]);return t},d=(t,e)=>{var n={};for(var r in t)a.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&i)for(var r of i(t))e.indexOf(r)<0&&o.call(t,r)&&(n[r]=t[r]);return n},l={};((e,n)=>{for(var i in n)t(e,i,{get:n[i],enumerable:!0})})(l,{Fungies:()=>F});var c=(t,e="log",n=!1,i={isEnabled:!0})=>{if(!i.isEnabled)return;window.console.debug=window.console.debug||window.console.log;const a=`[Fungies Debug]${t}`;"log"===e?console.debug(a):"warning"===e&&console.warn(a),n&&console.warn(t)};function u(t,e){const n=document.getElementsByClassName(t);for(let t=0;t<n.length;t++){const i=n[t];if("function"!=typeof e)throw new Error("each(className, function() {... requires the callback argument to be of type Function");e(i)}}function m(){u("fungies-loader",(t=>{var e;null==(e=null==t?void 0:t.parentNode)||e.removeChild(t)}))}function g(t){const e=t.getAttribute("data-fungies-checkout-url");e||c("Element has data-fungies-checkout-url attribute but no value","warning");const n=t.getAttribute("data-fungies-mode"),i="embed"===n||"overlay"===n?n:"overlay",a=t.getAttribute("data-fungies-frame-target")||void 0,o=t.getAttribute("data-fungies-discount-code")||void 0,r=t.getAttribute("data-fungies-customer-email")||void 0,d=t.getAttribute("data-fungies-quantity"),l=d?Number.parseInt(d,10):void 0,u=t.getAttribute("data-fungies-billing-email")||void 0,m=t.getAttribute("data-fungies-billing-first-name")||void 0,g=t.getAttribute("data-fungies-billing-last-name")||void 0,p=t.getAttribute("data-fungies-billing-country")||void 0,f=t.getAttribute("data-fungies-billing-state")||void 0,b=t.getAttribute("data-fungies-billing-city")||void 0,w=t.getAttribute("data-fungies-billing-zip-code")||void 0,v=u||m||g||p||f||b||w?s(s(s(s(s(s(s({},u&&{email:u}),m&&{firstName:m}),g&&{lastName:g}),p&&{country:p}),f&&{state:f}),b&&{city:b}),w&&{zipCode:w}):void 0;let h;const y=t.getAttribute("data-fungies-items");if(y)try{h=JSON.parse(y)}catch(t){c(`Invalid JSON in data-fungies-items: ${y}`,"warning")}let k;const x=t.getAttribute("data-fungies-custom-fields");if(x)try{k=JSON.parse(x)}catch(t){c(`Invalid JSON in data-fungies-custom-fields: ${x}`,"warning")}return s(s(s(s(s(s({checkoutUrl:e,settings:s({mode:i},a&&{frameTarget:a})},o&&{discountCode:o}),r&&{customerEmail:r}),v&&{billingData:v}),l&&{quantity:l}),h&&{items:h}),k&&{customFields:k})}var p="closeWindow",f="embed";var b=(t,e,n)=>{const i=new URL(e);var a;return i.searchParams.append("fngs-checkout-payload",(a=JSON.stringify(t),encodeURIComponent(encodeURIComponent(a)))),i.searchParams.append("fngs-display-mode",n),i.toString()},w=()=>{c("Checkout frame/window has been closed."),m(),u("fungies-frame",(t=>{var e;null==(e=t.parentNode)||e.removeChild(t)})),void 0===window.FungiesWindow||window.FungiesWindow.closed||window.FungiesWindow.close()},v=(t,e,n)=>{var i;const a=((t,e)=>{var n=t,{checkoutUrl:i}=n,a=d(n,["checkoutUrl"]);return b(a,i,e)})(t,e.mode);if(n||function(){m();const t=document.createElement("style");t.type="text/css",t.innerHTML="\t\t\t\t@-webkit-keyframes rotate {\t\t\t\t\t0% {\t\t\t\t\t\t-webkit-transform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\t100% {\t\t\t\t\t\t-webkit-transform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}\t\t\t\t@keyframes rotate {\t\t\t\t\tfrom {\t\t\t\t\t\ttransform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\tto {\t\t\t\t\t\ttransform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}";const e=document.getElementsByTagName("head")[0];e&&e.appendChild(t);const n=document.createElement("div");n.setAttribute("style","z-index:99998; display: block; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; right: 0px; bottom: 0px; margin: 0px; padding: 0px; background: rgba(0,0,0,0.38);"),n.setAttribute("class","fungies-loader");const i=document.createElement("main");i.setAttribute("style","align-items: center;display: flex;flex-direction: column;justify-content: center;left: 50%;margin: 0.5rem 0;position: absolute;text-align: center;top: 50%;transform: translate(-50%, -50%);width: 90%;");const a=document.createElement("div");a.setAttribute("style","border: 4px solid #f3f3f3;border-radius: 50%;border-top: 4px solid #ccc;width: 34px;height: 34px;-webkit-animation: rotate 1s ease-in-out infinite forwards;animation: rotate 1s ease-in-out infinite forwards;"),i.appendChild(a),n.appendChild(i);const o=()=>{const t=document.getElementsByTagName("body")[0];t&&t.appendChild(n)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",o):o()}(),window.FungiesFrame=document.createElement("iframe"),window.FungiesFrame.className="fungies-frame",window.FungiesFrame.name="fungies_frame",window.FungiesFrame.frameBorder="0",window.FungiesFrame.allowTransparency="true",window.FungiesFrame.allow="payment *",n){window.FungiesFrame.classList.add("fungies-frame-embed"),window.FungiesFrame.setAttribute("style","width: 100%; height: 100%;");const t=document.createElement("style");t.type="text/css",t.innerHTML=".fungies-frame-embed::-webkit-scrollbar { display: none !important; }",null==(i=null==document?void 0:document.getElementsByTagName("head")[0])||i.appendChild(t)}else window.FungiesFrame.classList.add("fungies-frame-overlay");if(n||(!function(){let t=!1;var e;return e=navigator.userAgent||navigator.vendor,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e.substr(0,4)))&&(t=!0),t}()?window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"):window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: scroll; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;")),window.FungiesFrame.src=a,(null==e?void 0:e.frameTarget)&&n){const t=document.getElementById(e.frameTarget);t&&t.appendChild(window.FungiesFrame)}else{const t=document.getElementsByTagName("body")[0];t&&t.appendChild(window.FungiesFrame)}},h=t=>{var e=t,{settings:n}=e,i=d(e,["settings"]);w();const a=()=>{c("Checkout.open() called"),v(i,n,(null==n?void 0:n.mode)===f)};"loading"!==document.readyState?a():document.addEventListener("DOMContentLoaded",a)},y=()=>{c("Scanning for checkout elements");const t=document.querySelectorAll("[data-fungies-checkout-url]:not([data-fungies-initialized])");for(const e of t){const t=g(e);e.addEventListener("click",(e=>{e.preventDefault(),h(t)})),e.setAttribute("data-fungies-initialized","true")}const e=document.querySelectorAll("[data-fungies-button]:not([data-fungies-initialized])");for(const t of e){const e=t.getAttribute("data-fungies-button");if(e)try{const n=new URL(e).pathname.split("/"),i=n.indexOf("checkout-element"),a=n.indexOf("overlay");if(-1===i&&-1===a){c(`Invalid URL in data-fungies-button: ${e}`,"warning");continue}const o={checkoutUrl:e,settings:{mode:"overlay"}};t.addEventListener("click",(t=>{t.preventDefault(),h(o)})),t.setAttribute("data-fungies-initialized","true")}catch(t){c(t,"error")}else c("Element has data-fungies-button attribute but no value","warning")}},k=t=>{const{data:e}=t;if(("string"==typeof e?e:"")===p)w()};var x,F={Checkout:{open:h,close:()=>{w()}},Initialize:(t,e={completedSetup:!1,options:null})=>{e.completedSetup?c("Cannot call Fungies.Initialize() more than once per page, the call was ignored.","warning"):("undefined"!=typeof window&&window.addEventListener("message",k,!1),!1!==t.enableDataAttributes&&(c("Initializing DOM support"),"loading"!==document.readyState?y():document.addEventListener("DOMContentLoaded",y),new MutationObserver((t=>{let e=!1;for(const n of t)if("childList"===n.type&&n.addedNodes.length>0)for(const t of n.addedNodes)if(t.nodeType===Node.ELEMENT_NODE&&t.querySelector("[data-fungies-checkout-url]:not([data-fungies-initialized]), [data-fungies-button]:not([data-fungies-initialized])")){e=!0;break}e&&y()})).observe(document.body,{childList:!0,subtree:!0})),((t,e)=>{s(s({},t),e)})(e,{completedSetup:!0,options:t}))},ScanDOM:y};if("undefined"!=typeof window&&(window.Fungies=F),"undefined"!=typeof document){const t=document.currentScript;if((null==t?void 0:t.hasAttribute("data-auto-init"))&&(F.Initialize({enableDataAttributes:!0}),null==t?void 0:t.hasAttribute("data-auto-display-checkout"))){const e=g(t);F.Checkout.open(e)}}return x=l,((i,o,r,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let d of n(o))a.call(i,d)||d===r||t(i,d,{get:()=>o[d],enumerable:!(s=e(o,d))||s.enumerable});return i})(t({},"__esModule",{value:!0}),x)})();
1
+ "use strict";var Fungies=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,r=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,s=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&r(e,n,t[n]);if(i)for(var n of i(t))a.call(t,n)&&r(e,n,t[n]);return e},d=(e,t)=>{var n={};for(var r in e)o.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&i)for(var r of i(e))t.indexOf(r)<0&&a.call(e,r)&&(n[r]=e[r]);return n},l={};((t,n)=>{for(var i in n)e(t,i,{get:n[i],enumerable:!0})})(l,{Fungies:()=>O});var c=(e,t="log",n=!1,i={isEnabled:!0})=>{if(!i.isEnabled)return;window.console.debug=window.console.debug||window.console.log;const o=`[Fungies Debug]${e}`;"log"===t?console.debug(o):"warning"===t&&console.warn(o),n&&console.warn(e)};function u(e,t){const n=document.getElementsByClassName(e);for(let e=0;e<n.length;e++){const i=n[e];if("function"!=typeof t)throw new Error("each(className, function() {... requires the callback argument to be of type Function");t(i)}}function m(){u("fungies-loader",(e=>{var t;null==(t=null==e?void 0:e.parentNode)||t.removeChild(e)}))}function g(e){const t=e.getAttribute("data-fungies-checkout-url");t||c("Element has data-fungies-checkout-url attribute but no value","warning");const n=e.getAttribute("data-fungies-mode"),i="embed"===n||"overlay"===n?n:"overlay",o=e.getAttribute("data-fungies-frame-target")||void 0,a=e.getAttribute("data-fungies-discount-code")||void 0,r=e.getAttribute("data-fungies-customer-email")||void 0,d=e.getAttribute("data-fungies-quantity"),l=d?Number.parseInt(d,10):void 0,u=e.getAttribute("data-fungies-billing-email")||void 0,m=e.getAttribute("data-fungies-billing-first-name")||void 0,g=e.getAttribute("data-fungies-billing-last-name")||void 0,p=e.getAttribute("data-fungies-billing-country")||void 0,f=e.getAttribute("data-fungies-billing-state")||void 0,b=e.getAttribute("data-fungies-billing-city")||void 0,w=e.getAttribute("data-fungies-billing-zip-code")||void 0,v=u||m||g||p||f||b||w?s(s(s(s(s(s(s({},u&&{email:u}),m&&{firstName:m}),g&&{lastName:g}),p&&{country:p}),f&&{state:f}),b&&{city:b}),w&&{zipCode:w}):void 0;let h;const y=e.getAttribute("data-fungies-items");if(y)try{h=JSON.parse(y)}catch(e){c(`Invalid JSON in data-fungies-items: ${y}`,"warning")}let k;const x=e.getAttribute("data-fungies-custom-fields");if(x)try{k=JSON.parse(x)}catch(e){c(`Invalid JSON in data-fungies-custom-fields: ${x}`,"warning")}return s(s(s(s(s(s({checkoutUrl:t,settings:s({mode:i},o&&{frameTarget:o})},a&&{discountCode:a}),r&&{customerEmail:r}),v&&{billingData:v}),l&&{quantity:l}),h&&{items:h}),k&&{customFields:k})}var p="closeWindow",f="checkoutComplete",b="fungies:checkout:complete",w="fungies:checkout:close",v="embed";var h=(e,t,n)=>{const i=new URL(t);var o;return i.searchParams.append("fngs-checkout-payload",(o=JSON.stringify(e),encodeURIComponent(encodeURIComponent(o)))),i.searchParams.append("fngs-display-mode",n),i.toString()},y=()=>{c("Checkout frame/window has been closed."),m(),u("fungies-frame",(e=>{var t;null==(t=e.parentNode)||t.removeChild(e)})),void 0===window.FungiesWindow||window.FungiesWindow.closed||window.FungiesWindow.close()},k=(e,t,n)=>{var i;const o=((e,t)=>{var n=e,{checkoutUrl:i}=n,o=d(n,["checkoutUrl"]);return h(o,i,t)})(e,t.mode);if(n||function(){m();const e=document.createElement("style");e.type="text/css",e.innerHTML="\t\t\t\t@-webkit-keyframes rotate {\t\t\t\t\t0% {\t\t\t\t\t\t-webkit-transform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\t100% {\t\t\t\t\t\t-webkit-transform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}\t\t\t\t@keyframes rotate {\t\t\t\t\tfrom {\t\t\t\t\t\ttransform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\tto {\t\t\t\t\t\ttransform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}";const t=document.getElementsByTagName("head")[0];t&&t.appendChild(e);const n=document.createElement("div");n.setAttribute("style","z-index:99998; display: block; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; right: 0px; bottom: 0px; margin: 0px; padding: 0px; background: rgba(0,0,0,0.38);"),n.setAttribute("class","fungies-loader");const i=document.createElement("main");i.setAttribute("style","align-items: center;display: flex;flex-direction: column;justify-content: center;left: 50%;margin: 0.5rem 0;position: absolute;text-align: center;top: 50%;transform: translate(-50%, -50%);width: 90%;");const o=document.createElement("div");o.setAttribute("style","border: 4px solid #f3f3f3;border-radius: 50%;border-top: 4px solid #ccc;width: 34px;height: 34px;-webkit-animation: rotate 1s ease-in-out infinite forwards;animation: rotate 1s ease-in-out infinite forwards;"),i.appendChild(o),n.appendChild(i);const a=()=>{const e=document.getElementsByTagName("body")[0];e&&e.appendChild(n)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",a):a()}(),window.FungiesFrame=document.createElement("iframe"),window.FungiesFrame.className="fungies-frame",window.FungiesFrame.name="fungies_frame",window.FungiesFrame.frameBorder="0",window.FungiesFrame.allowTransparency="true",window.FungiesFrame.allow="payment *",n){window.FungiesFrame.classList.add("fungies-frame-embed"),window.FungiesFrame.setAttribute("style","width: 100%; height: 100%;");const e=document.createElement("style");e.type="text/css",e.innerHTML=".fungies-frame-embed::-webkit-scrollbar { display: none !important; }",null==(i=null==document?void 0:document.getElementsByTagName("head")[0])||i.appendChild(e)}else window.FungiesFrame.classList.add("fungies-frame-overlay");if(n||(!function(){let e=!1;var t;return t=navigator.userAgent||navigator.vendor,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(t.substr(0,4)))&&(e=!0),e}()?window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"):window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: scroll; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;")),window.FungiesFrame.src=o,(null==t?void 0:t.frameTarget)&&n){const e=document.getElementById(t.frameTarget);e&&e.appendChild(window.FungiesFrame)}else{const e=document.getElementsByTagName("body")[0];e&&e.appendChild(window.FungiesFrame)}},x=e=>{var t=e,{settings:n}=t,i=d(t,["settings"]);y();const o=()=>{c("Checkout.open() called"),k(i,n,(null==n?void 0:n.mode)===v)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)},F=()=>{c("Scanning for checkout elements");const e=document.querySelectorAll("[data-fungies-checkout-url]:not([data-fungies-initialized])");for(const t of e){const e=g(t);t.addEventListener("click",(t=>{t.preventDefault(),x(e)})),t.setAttribute("data-fungies-initialized","true")}const t=document.querySelectorAll("[data-fungies-button]:not([data-fungies-initialized])");for(const e of t){const t=e.getAttribute("data-fungies-button");if(t)try{const n=new URL(t).pathname.split("/"),i=n.indexOf("checkout-element"),o=n.indexOf("overlay");if(-1===i&&-1===o){c(`Invalid URL in data-fungies-button: ${t}`,"warning");continue}const a={checkoutUrl:t,settings:{mode:"overlay"}};e.addEventListener("click",(e=>{e.preventDefault(),x(a)})),e.setAttribute("data-fungies-initialized","true")}catch(e){c(e,"error")}else c("Element has data-fungies-button attribute but no value","warning")}},E=e=>{const{data:t}=e;switch("string"==typeof t?t:""){case f:document.dispatchEvent(new CustomEvent(b));break;case p:y(),document.dispatchEvent(new CustomEvent(w))}};var A,O={Checkout:{open:x,close:()=>{y()}},Initialize:(e,t={completedSetup:!1,options:null})=>{t.completedSetup?c("Cannot call Fungies.Initialize() more than once per page, the call was ignored.","warning"):("undefined"!=typeof window&&window.addEventListener("message",E,!1),!1!==e.enableDataAttributes&&(c("Initializing DOM support"),"loading"!==document.readyState?F():document.addEventListener("DOMContentLoaded",F),new MutationObserver((e=>{let t=!1;for(const n of e)if("childList"===n.type&&n.addedNodes.length>0)for(const e of n.addedNodes)if(e.nodeType===Node.ELEMENT_NODE&&e.querySelector("[data-fungies-checkout-url]:not([data-fungies-initialized]), [data-fungies-button]:not([data-fungies-initialized])")){t=!0;break}t&&F()})).observe(document.body,{childList:!0,subtree:!0})),((e,t)=>{s(s({},e),t)})(t,{completedSetup:!0,options:e}))},ScanDOM:F};if("undefined"!=typeof window&&(window.Fungies=O),"undefined"!=typeof document){const e=document.currentScript;if((null==e?void 0:e.hasAttribute("data-auto-init"))&&(O.Initialize({enableDataAttributes:!0}),null==e?void 0:e.hasAttribute("data-auto-display-checkout"))){const t=g(e);O.Checkout.open(t)}}return A=l,((i,a,r,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let d of n(a))o.call(i,d)||d===r||e(i,d,{get:()=>a[d],enumerable:!(s=t(a,d))||s.enumerable});return i})(e({},"__esModule",{value:!0}),A)})();
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var t=Object.defineProperty,e=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,a=(e,n,i)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,o=(t,o)=>{for(var r in o||(o={}))n.call(o,r)&&a(t,r,o[r]);if(e)for(var r of e(o))i.call(o,r)&&a(t,r,o[r]);return t},r=(t,a)=>{var o={};for(var r in t)n.call(t,r)&&a.indexOf(r)<0&&(o[r]=t[r]);if(null!=t&&e)for(var r of e(t))a.indexOf(r)<0&&i.call(t,r)&&(o[r]=t[r]);return o},d=(t,e="log",n=!1,i={isEnabled:!0})=>{if(!i.isEnabled)return;window.console.debug=window.console.debug||window.console.log;const a=`[Fungies Debug]${t}`;"log"===e?console.debug(a):"warning"===e&&console.warn(a),n&&console.warn(t)};function s(t,e){const n=document.getElementsByClassName(t);for(let t=0;t<n.length;t++){const i=n[t];if("function"!=typeof e)throw new Error("each(className, function() {... requires the callback argument to be of type Function");e(i)}}function l(){s("fungies-loader",(t=>{var e;null==(e=null==t?void 0:t.parentNode)||e.removeChild(t)}))}function c(t){const e=t.getAttribute("data-fungies-checkout-url");e||d("Element has data-fungies-checkout-url attribute but no value","warning");const n=t.getAttribute("data-fungies-mode"),i="embed"===n||"overlay"===n?n:"overlay",a=t.getAttribute("data-fungies-frame-target")||void 0,r=t.getAttribute("data-fungies-discount-code")||void 0,s=t.getAttribute("data-fungies-customer-email")||void 0,l=t.getAttribute("data-fungies-quantity"),c=l?Number.parseInt(l,10):void 0,u=t.getAttribute("data-fungies-billing-email")||void 0,m=t.getAttribute("data-fungies-billing-first-name")||void 0,g=t.getAttribute("data-fungies-billing-last-name")||void 0,p=t.getAttribute("data-fungies-billing-country")||void 0,f=t.getAttribute("data-fungies-billing-state")||void 0,b=t.getAttribute("data-fungies-billing-city")||void 0,w=t.getAttribute("data-fungies-billing-zip-code")||void 0,h=u||m||g||p||f||b||w?o(o(o(o(o(o(o({},u&&{email:u}),m&&{firstName:m}),g&&{lastName:g}),p&&{country:p}),f&&{state:f}),b&&{city:b}),w&&{zipCode:w}):void 0;let v;const y=t.getAttribute("data-fungies-items");if(y)try{v=JSON.parse(y)}catch(t){d(`Invalid JSON in data-fungies-items: ${y}`,"warning")}let k;const x=t.getAttribute("data-fungies-custom-fields");if(x)try{k=JSON.parse(x)}catch(t){d(`Invalid JSON in data-fungies-custom-fields: ${x}`,"warning")}return o(o(o(o(o(o({checkoutUrl:e,settings:o({mode:i},a&&{frameTarget:a})},r&&{discountCode:r}),s&&{customerEmail:s}),h&&{billingData:h}),c&&{quantity:c}),v&&{items:v}),k&&{customFields:k})}var u="closeWindow",m="embed";var g=(t,e,n)=>{const i=new URL(e);var a;return i.searchParams.append("fngs-checkout-payload",(a=JSON.stringify(t),encodeURIComponent(encodeURIComponent(a)))),i.searchParams.append("fngs-display-mode",n),i.toString()},p=()=>{d("Checkout frame/window has been closed."),l(),s("fungies-frame",(t=>{var e;null==(e=t.parentNode)||e.removeChild(t)})),void 0===window.FungiesWindow||window.FungiesWindow.closed||window.FungiesWindow.close()},f=(t,e,n)=>{var i;const a=((t,e)=>{var n=t,{checkoutUrl:i}=n,a=r(n,["checkoutUrl"]);return g(a,i,e)})(t,e.mode);if(n||function(){l();const t=document.createElement("style");t.type="text/css",t.innerHTML="\t\t\t\t@-webkit-keyframes rotate {\t\t\t\t\t0% {\t\t\t\t\t\t-webkit-transform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\t100% {\t\t\t\t\t\t-webkit-transform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}\t\t\t\t@keyframes rotate {\t\t\t\t\tfrom {\t\t\t\t\t\ttransform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\tto {\t\t\t\t\t\ttransform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}";const e=document.getElementsByTagName("head")[0];e&&e.appendChild(t);const n=document.createElement("div");n.setAttribute("style","z-index:99998; display: block; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; right: 0px; bottom: 0px; margin: 0px; padding: 0px; background: rgba(0,0,0,0.38);"),n.setAttribute("class","fungies-loader");const i=document.createElement("main");i.setAttribute("style","align-items: center;display: flex;flex-direction: column;justify-content: center;left: 50%;margin: 0.5rem 0;position: absolute;text-align: center;top: 50%;transform: translate(-50%, -50%);width: 90%;");const a=document.createElement("div");a.setAttribute("style","border: 4px solid #f3f3f3;border-radius: 50%;border-top: 4px solid #ccc;width: 34px;height: 34px;-webkit-animation: rotate 1s ease-in-out infinite forwards;animation: rotate 1s ease-in-out infinite forwards;"),i.appendChild(a),n.appendChild(i);const o=()=>{const t=document.getElementsByTagName("body")[0];t&&t.appendChild(n)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",o):o()}(),window.FungiesFrame=document.createElement("iframe"),window.FungiesFrame.className="fungies-frame",window.FungiesFrame.name="fungies_frame",window.FungiesFrame.frameBorder="0",window.FungiesFrame.allowTransparency="true",window.FungiesFrame.allow="payment *",n){window.FungiesFrame.classList.add("fungies-frame-embed"),window.FungiesFrame.setAttribute("style","width: 100%; height: 100%;");const t=document.createElement("style");t.type="text/css",t.innerHTML=".fungies-frame-embed::-webkit-scrollbar { display: none !important; }",null==(i=null==document?void 0:document.getElementsByTagName("head")[0])||i.appendChild(t)}else window.FungiesFrame.classList.add("fungies-frame-overlay");if(n||(!function(){let t=!1;var e;return e=navigator.userAgent||navigator.vendor,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e.substr(0,4)))&&(t=!0),t}()?window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"):window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: scroll; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;")),window.FungiesFrame.src=a,(null==e?void 0:e.frameTarget)&&n){const t=document.getElementById(e.frameTarget);t&&t.appendChild(window.FungiesFrame)}else{const t=document.getElementsByTagName("body")[0];t&&t.appendChild(window.FungiesFrame)}},b=t=>{var e=t,{settings:n}=e,i=r(e,["settings"]);p();const a=()=>{d("Checkout.open() called"),f(i,n,(null==n?void 0:n.mode)===m)};"loading"!==document.readyState?a():document.addEventListener("DOMContentLoaded",a)},w=()=>{d("Scanning for checkout elements");const t=document.querySelectorAll("[data-fungies-checkout-url]:not([data-fungies-initialized])");for(const e of t){const t=c(e);e.addEventListener("click",(e=>{e.preventDefault(),b(t)})),e.setAttribute("data-fungies-initialized","true")}const e=document.querySelectorAll("[data-fungies-button]:not([data-fungies-initialized])");for(const t of e){const e=t.getAttribute("data-fungies-button");if(e)try{const n=new URL(e).pathname.split("/"),i=n.indexOf("checkout-element"),a=n.indexOf("overlay");if(-1===i&&-1===a){d(`Invalid URL in data-fungies-button: ${e}`,"warning");continue}const o={checkoutUrl:e,settings:{mode:"overlay"}};t.addEventListener("click",(t=>{t.preventDefault(),b(o)})),t.setAttribute("data-fungies-initialized","true")}catch(t){d(t,"error")}else d("Element has data-fungies-button attribute but no value","warning")}},h=t=>{const{data:e}=t;if(("string"==typeof e?e:"")===u)p()};var v={Checkout:{open:b,close:()=>{p()}},Initialize:(t,e={completedSetup:!1,options:null})=>{e.completedSetup?d("Cannot call Fungies.Initialize() more than once per page, the call was ignored.","warning"):("undefined"!=typeof window&&window.addEventListener("message",h,!1),!1!==t.enableDataAttributes&&(d("Initializing DOM support"),"loading"!==document.readyState?w():document.addEventListener("DOMContentLoaded",w),new MutationObserver((t=>{let e=!1;for(const n of t)if("childList"===n.type&&n.addedNodes.length>0)for(const t of n.addedNodes)if(t.nodeType===Node.ELEMENT_NODE&&t.querySelector("[data-fungies-checkout-url]:not([data-fungies-initialized]), [data-fungies-button]:not([data-fungies-initialized])")){e=!0;break}e&&w()})).observe(document.body,{childList:!0,subtree:!0})),((t,e)=>{o(o({},t),e)})(e,{completedSetup:!0,options:t}))},ScanDOM:w};if("undefined"!=typeof window&&(window.Fungies=v),"undefined"!=typeof document){const t=document.currentScript;if((null==t?void 0:t.hasAttribute("data-auto-init"))&&(v.Initialize({enableDataAttributes:!0}),null==t?void 0:t.hasAttribute("data-auto-display-checkout"))){const e=c(t);v.Checkout.open(e)}}export{v as Fungies};
1
+ var t=Object.defineProperty,e=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,o=(e,n,i)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,a=(t,a)=>{for(var r in a||(a={}))n.call(a,r)&&o(t,r,a[r]);if(e)for(var r of e(a))i.call(a,r)&&o(t,r,a[r]);return t},r=(t,o)=>{var a={};for(var r in t)n.call(t,r)&&o.indexOf(r)<0&&(a[r]=t[r]);if(null!=t&&e)for(var r of e(t))o.indexOf(r)<0&&i.call(t,r)&&(a[r]=t[r]);return a},s=(t,e="log",n=!1,i={isEnabled:!0})=>{if(!i.isEnabled)return;window.console.debug=window.console.debug||window.console.log;const o=`[Fungies Debug]${t}`;"log"===e?console.debug(o):"warning"===e&&console.warn(o),n&&console.warn(t)};function d(t,e){const n=document.getElementsByClassName(t);for(let t=0;t<n.length;t++){const i=n[t];if("function"!=typeof e)throw new Error("each(className, function() {... requires the callback argument to be of type Function");e(i)}}function l(){d("fungies-loader",(t=>{var e;null==(e=null==t?void 0:t.parentNode)||e.removeChild(t)}))}function c(t){const e=t.getAttribute("data-fungies-checkout-url");e||s("Element has data-fungies-checkout-url attribute but no value","warning");const n=t.getAttribute("data-fungies-mode"),i="embed"===n||"overlay"===n?n:"overlay",o=t.getAttribute("data-fungies-frame-target")||void 0,r=t.getAttribute("data-fungies-discount-code")||void 0,d=t.getAttribute("data-fungies-customer-email")||void 0,l=t.getAttribute("data-fungies-quantity"),c=l?Number.parseInt(l,10):void 0,u=t.getAttribute("data-fungies-billing-email")||void 0,m=t.getAttribute("data-fungies-billing-first-name")||void 0,g=t.getAttribute("data-fungies-billing-last-name")||void 0,p=t.getAttribute("data-fungies-billing-country")||void 0,f=t.getAttribute("data-fungies-billing-state")||void 0,b=t.getAttribute("data-fungies-billing-city")||void 0,w=t.getAttribute("data-fungies-billing-zip-code")||void 0,h=u||m||g||p||f||b||w?a(a(a(a(a(a(a({},u&&{email:u}),m&&{firstName:m}),g&&{lastName:g}),p&&{country:p}),f&&{state:f}),b&&{city:b}),w&&{zipCode:w}):void 0;let v;const y=t.getAttribute("data-fungies-items");if(y)try{v=JSON.parse(y)}catch(t){s(`Invalid JSON in data-fungies-items: ${y}`,"warning")}let k;const x=t.getAttribute("data-fungies-custom-fields");if(x)try{k=JSON.parse(x)}catch(t){s(`Invalid JSON in data-fungies-custom-fields: ${x}`,"warning")}return a(a(a(a(a(a({checkoutUrl:e,settings:a({mode:i},o&&{frameTarget:o})},r&&{discountCode:r}),d&&{customerEmail:d}),h&&{billingData:h}),c&&{quantity:c}),v&&{items:v}),k&&{customFields:k})}var u="closeWindow",m="checkoutComplete",g="fungies:checkout:complete",p="fungies:checkout:close",f="embed";var b=(t,e,n)=>{const i=new URL(e);var o;return i.searchParams.append("fngs-checkout-payload",(o=JSON.stringify(t),encodeURIComponent(encodeURIComponent(o)))),i.searchParams.append("fngs-display-mode",n),i.toString()},w=()=>{s("Checkout frame/window has been closed."),l(),d("fungies-frame",(t=>{var e;null==(e=t.parentNode)||e.removeChild(t)})),void 0===window.FungiesWindow||window.FungiesWindow.closed||window.FungiesWindow.close()},h=(t,e,n)=>{var i;const o=((t,e)=>{var n=t,{checkoutUrl:i}=n,o=r(n,["checkoutUrl"]);return b(o,i,e)})(t,e.mode);if(n||function(){l();const t=document.createElement("style");t.type="text/css",t.innerHTML="\t\t\t\t@-webkit-keyframes rotate {\t\t\t\t\t0% {\t\t\t\t\t\t-webkit-transform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\t100% {\t\t\t\t\t\t-webkit-transform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}\t\t\t\t@keyframes rotate {\t\t\t\t\tfrom {\t\t\t\t\t\ttransform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\tto {\t\t\t\t\t\ttransform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}";const e=document.getElementsByTagName("head")[0];e&&e.appendChild(t);const n=document.createElement("div");n.setAttribute("style","z-index:99998; display: block; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; right: 0px; bottom: 0px; margin: 0px; padding: 0px; background: rgba(0,0,0,0.38);"),n.setAttribute("class","fungies-loader");const i=document.createElement("main");i.setAttribute("style","align-items: center;display: flex;flex-direction: column;justify-content: center;left: 50%;margin: 0.5rem 0;position: absolute;text-align: center;top: 50%;transform: translate(-50%, -50%);width: 90%;");const o=document.createElement("div");o.setAttribute("style","border: 4px solid #f3f3f3;border-radius: 50%;border-top: 4px solid #ccc;width: 34px;height: 34px;-webkit-animation: rotate 1s ease-in-out infinite forwards;animation: rotate 1s ease-in-out infinite forwards;"),i.appendChild(o),n.appendChild(i);const a=()=>{const t=document.getElementsByTagName("body")[0];t&&t.appendChild(n)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",a):a()}(),window.FungiesFrame=document.createElement("iframe"),window.FungiesFrame.className="fungies-frame",window.FungiesFrame.name="fungies_frame",window.FungiesFrame.frameBorder="0",window.FungiesFrame.allowTransparency="true",window.FungiesFrame.allow="payment *",n){window.FungiesFrame.classList.add("fungies-frame-embed"),window.FungiesFrame.setAttribute("style","width: 100%; height: 100%;");const t=document.createElement("style");t.type="text/css",t.innerHTML=".fungies-frame-embed::-webkit-scrollbar { display: none !important; }",null==(i=null==document?void 0:document.getElementsByTagName("head")[0])||i.appendChild(t)}else window.FungiesFrame.classList.add("fungies-frame-overlay");if(n||(!function(){let t=!1;var e;return e=navigator.userAgent||navigator.vendor,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e.substr(0,4)))&&(t=!0),t}()?window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"):window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: scroll; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;")),window.FungiesFrame.src=o,(null==e?void 0:e.frameTarget)&&n){const t=document.getElementById(e.frameTarget);t&&t.appendChild(window.FungiesFrame)}else{const t=document.getElementsByTagName("body")[0];t&&t.appendChild(window.FungiesFrame)}},v=t=>{var e=t,{settings:n}=e,i=r(e,["settings"]);w();const o=()=>{s("Checkout.open() called"),h(i,n,(null==n?void 0:n.mode)===f)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)},y=()=>{s("Scanning for checkout elements");const t=document.querySelectorAll("[data-fungies-checkout-url]:not([data-fungies-initialized])");for(const e of t){const t=c(e);e.addEventListener("click",(e=>{e.preventDefault(),v(t)})),e.setAttribute("data-fungies-initialized","true")}const e=document.querySelectorAll("[data-fungies-button]:not([data-fungies-initialized])");for(const t of e){const e=t.getAttribute("data-fungies-button");if(e)try{const n=new URL(e).pathname.split("/"),i=n.indexOf("checkout-element"),o=n.indexOf("overlay");if(-1===i&&-1===o){s(`Invalid URL in data-fungies-button: ${e}`,"warning");continue}const a={checkoutUrl:e,settings:{mode:"overlay"}};t.addEventListener("click",(t=>{t.preventDefault(),v(a)})),t.setAttribute("data-fungies-initialized","true")}catch(t){s(t,"error")}else s("Element has data-fungies-button attribute but no value","warning")}},k=t=>{const{data:e}=t;switch("string"==typeof e?e:""){case m:document.dispatchEvent(new CustomEvent(g));break;case u:w(),document.dispatchEvent(new CustomEvent(p))}};var x={Checkout:{open:v,close:()=>{w()}},Initialize:(t,e={completedSetup:!1,options:null})=>{e.completedSetup?s("Cannot call Fungies.Initialize() more than once per page, the call was ignored.","warning"):("undefined"!=typeof window&&window.addEventListener("message",k,!1),!1!==t.enableDataAttributes&&(s("Initializing DOM support"),"loading"!==document.readyState?y():document.addEventListener("DOMContentLoaded",y),new MutationObserver((t=>{let e=!1;for(const n of t)if("childList"===n.type&&n.addedNodes.length>0)for(const t of n.addedNodes)if(t.nodeType===Node.ELEMENT_NODE&&t.querySelector("[data-fungies-checkout-url]:not([data-fungies-initialized]), [data-fungies-button]:not([data-fungies-initialized])")){e=!0;break}e&&y()})).observe(document.body,{childList:!0,subtree:!0})),((t,e)=>{a(a({},t),e)})(e,{completedSetup:!0,options:t}))},ScanDOM:y};if("undefined"!=typeof window&&(window.Fungies=x),"undefined"!=typeof document){const t=document.currentScript;if((null==t?void 0:t.hasAttribute("data-auto-init"))&&(x.Initialize({enableDataAttributes:!0}),null==t?void 0:t.hasAttribute("data-auto-display-checkout"))){const e=c(t);x.Checkout.open(e)}}export{x as Fungies};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungies/fungies-js",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
package/variables.env CHANGED
@@ -1 +1 @@
1
- CHANGED_PACKAGES=@fungies/fungies-js@0.7.1
1
+ CHANGED_PACKAGES=@fungies/fungies-js@0.7.2