@acuityai/acuityai
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -1,1 +0,1 @@ | ||
import t from"url-join";import{env as e}from"process";import o from"event-lite";const n=new class extends o{};var a,r,c;a=window,r="message",c=function(t){try{var e=JSON.parse(t.data),o=e.message?JSON.parse(e.message):e;if(0===String(o.msg).indexOf("seek-to-"))return n.emit(o.msg,o.data);switch(o.msg){case"redirect-to":return n.emit("redirect-to",o);case"add-to-cart":return n.emit("add-to-cart",o);case"close-ad-popup":return n.emit("close-ad-popup",o);case"open-product":return n.emit("open-product",o);case"close-product":return n.emit("close-product");case"close":return n.emit("close");case"open-standalonecart":return n.emit("open-standalonecart");default:return n.emit(o.msg,o.data)}}catch(t){}},a.addEventListener?a.addEventListener(r,c):a.attachEvent&&a.attachEvent("on"+r,c);const{REACT_APP_URL:i,NODE_ENV:s}=e;let d,p;function u(t){return document.getElementById("acuity-cart-iframe").style.display="block",d=t.data.id,n.emit("notify:product-open",{id:d}),e={msg:"open-product",data:t.data},void document.getElementById("acuity-cart-iframe").contentWindow.postMessage(e,"*");var e}function l({company:t}){if(p)return;const e=document.createElement("div");e.innerHTML=`\n <iframe id="acuity-cart-iframe" src="${function(t){if("production"!==s)return i;switch(t){case"proactiv":return"https://shoppable.proactiv.com";case"santaluzia":return"https://www.santaluziamouldings.com/shoppable";case"Coach":return"https://www.coach.com/shop_content.html";case"myft":return"https://www.myft.com.br/shoppable";case"lancaperfume":return"https://www.lancaperfume.com.br/_secure/shoppble";default:return i}}(t)}?type=cart&company=${t}" frameborder="0"></iframe>\n <style>\n #acuity-cart-iframe {\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99999;\n height: 100%;\n width: 100%;\n display: none;\n }\n </style>\n `,document.body.appendChild(e),p=e}n.on("open-product",u),n.on("close-product",(function(){document.getElementById("acuity-cart-iframe").style.display="none",n.emit("notify:product-closed",{id:d})})),n.on("add-to-cart",(function({product:t}){if(!t.id)return;if("examples.acuityai.com"!==window.location.host)return;const e=new XMLHttpRequest;e.open("POST",`${window.location.protocol}//${window.location.host}/cart/add`,!0),e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.onreadystatechange=function(){if(this.readyState===XMLHttpRequest.DONE&&200===this.status){if(console.log("product added to cart!"),"examples.acuityai.com"!==window.location.host)return;const t=document.querySelectorAll(".site-header__cart-count span")[0];t.innerText=Number(t.innerText)+1}},e.send(`id=${t.id}`)}));const m=window.acuityaiLayer||{};export default m;function y({name:t,productId:e}){u({data:{asset:t,product:{id:e},client:window.company}})}function f(t,e){t.contentWindow.postMessage(JSON.stringify(e),"*")}function w(t,e,o){t.addEventListener?t.addEventListener(e,o):t.attachEvent&&t.attachEvent("on"+e,o)}let h;window.acuityaiLayer=m;m.onClickProduct=y,m.openCart=()=>null,m.start=function({selector:e,company:o,asset:a,video:r,disableAutoPause:c}){const i=document.querySelector(e),s=document.createElement("iframe");window.company=o,s.style.border=0,s.style.backgroundColor="rgba(0,0,0,0)",s.height=128,s.width=300,s.src=t("https://app.acuityai.com","app",o,a,"productpanel"),function({company:e,asset:o}){const a=document.createElement("iframe"),r=document.querySelector("body");a.style.display="none",a.style.position="fixed",a.style.top=0,a.style.right=0,a.style.border=0,a.style.zIndex=99999,a.style.width="460px",a.style.height="100%",a.style.backgroundColor="rgba(0,0,0,0)",a.src=t("https://app.acuityai.com","app",e,"shoppingcart"),r.appendChild(a),m._$cart=a,w(window,"message",(t=>{if("https://app.acuityai.com"===t.origin){const e=JSON.parse(t.data);"cart-close"===e.type?a.style.display="none":"redirect-to"===e.type?window.location.href=e.data.location:"cart-update"===e.type&&n.emit("cart-total",e.data.total)}})),m.openCart=()=>{a.style.display="block",setTimeout((()=>{f(m._$cart,{type:"toggle-cart"})}),100)},n.on("add-to-cart",(()=>{setTimeout((()=>{f(m._$cart,{type:"update-session-cart"})}),1e3)})),setTimeout((()=>{f(m._$cart,{type:"start-cart"})}),1e3)}({company:o,asset:a}),i.appendChild(s),w(window,"message",(t=>{if("https://app.acuityai.com"===t.origin){const e=JSON.parse(t.data);"open-product"==e.type&&y(e)}})),function(t,e){t.addEventListener("progress",(o=>{f(e,{type:"video-progress",duration:t.duration,currentTime:t.currentTime})})),t.addEventListener("seeked",(o=>{f(e,{type:"video-progress",duration:t.duration,currentTime:t.currentTime})}))}(r,s),l({company:window.company});const d=(p=r,()=>{h=!p.paused,p.pause()});var p;const u=(t=>()=>{h&&t.play(),m._$cart&&f(m._$cart,{type:"update-cart"})})(r);c||(n.on("notify:product-open",d),n.on("notify:product-closed",u)),m.destroy=()=>{s.parentElement.removeChild(s),n.off("notify:product-open",d),n.off("notify:product-closed",u)}},m.events=n,m.destroy=()=>null; | ||
import t from"url-join";import{env as e}from"process";import n from"event-lite";const o=new class extends n{};var a,r,c;a=window,r="message",c=function(t){try{var e=JSON.parse(t.data),n=e.message?JSON.parse(e.message):e;if(0===String(n.msg).indexOf("seek-to-"))return o.emit(n.msg,n.data);switch(n.msg){case"redirect-to":return o.emit("redirect-to",n);case"add-to-cart":return o.emit("add-to-cart",n);case"close-ad-popup":return o.emit("close-ad-popup",n);case"open-product":return o.emit("open-product",n);case"close-product":return o.emit("close-product");case"close":return o.emit("close");case"open-standalonecart":return o.emit("open-standalonecart");default:return o.emit(n.msg,n.data)}}catch(t){}},a.addEventListener?a.addEventListener(r,c):a.attachEvent&&a.attachEvent("on"+r,c);const{REACT_APP_URL:i,NODE_ENV:s}=e;let d,p;function u(t){return document.getElementById("acuity-cart-iframe").style.display="block",d=t.data.id,o.emit("notify:product-open",{id:d}),e={msg:"open-product",data:t.data},void document.getElementById("acuity-cart-iframe").contentWindow.postMessage(e,"*");var e}function l({company:t}){if(p)return;const e=document.createElement("div");e.innerHTML=`\n <iframe id="acuity-cart-iframe" src="${function(t){if("production"!==s)return i;switch(t){case"proactiv":return"https://shoppable.proactiv.com";case"santaluzia":return"https://www.santaluziamouldings.com/shoppable";case"Coach":return"https://www.coach.com/shop_content.html";case"myft":return"https://www.myft.com.br/shoppable";case"lancaperfume":return"https://www.lancaperfume.com.br/_secure/shoppble";default:return i}}(t)}?type=cart&company=${t}" frameborder="0"></iframe>\n <style>\n #acuity-cart-iframe {\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99999;\n height: 100%;\n width: 100%;\n display: none;\n }\n </style>\n `,document.body.appendChild(e),p=e}o.on("open-product",u),o.on("close-product",(function(){document.getElementById("acuity-cart-iframe").style.display="none",o.emit("notify:product-closed",{id:d})})),o.on("add-to-cart",(function({product:t}){if(!t.id)return;if("examples.acuityai.com"!==window.location.host)return;const e=new XMLHttpRequest;e.open("POST",`${window.location.protocol}//${window.location.host}/cart/add`,!0),e.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),e.onreadystatechange=function(){if(this.readyState===XMLHttpRequest.DONE&&200===this.status){if(console.log("product added to cart!"),"examples.acuityai.com"!==window.location.host)return;const t=document.querySelectorAll(".site-header__cart-count span")[0];t.innerText=Number(t.innerText)+1}},e.send(`id=${t.id}`)}));const m=window.acuityaiLayer||{};export default m;function y({name:t,productId:e}){u({data:{asset:t,product:{id:e},client:window.company}})}function f(t,e){t.contentWindow.postMessage(JSON.stringify(e),"*")}function h(t,e,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent&&t.attachEvent("on"+e,n)}let g;window.acuityaiLayer=m;const w=()=>{o.emit("openProduct")},v=()=>{o.emit("closeProduct")};m.onClickProduct=y,m.toggleCart=()=>null,m.start=function({selector:e,company:n,asset:a,video:r,cartButtonSelector:c}){const i=document.querySelector(e),s=document.createElement("iframe");window.company=n,s.style.border=0,s.style.backgroundColor="rgba(0,0,0,0)",s.height=128,s.width=300,s.src=t("https://app.acuityai.com","app",n,a,"productpanel"),function({company:e,asset:n}){const a=document.createElement("iframe"),r=document.querySelector("body");a.style.display="none",a.style.position="fixed",a.style.top=0,a.style.right=0,a.style.border=0,a.style.zIndex=99999,a.style.width="460px",a.style.height="100%",a.style.backgroundColor="rgba(0,0,0,0)",a.src=t("https://app.acuityai.com","app",e,"shoppingcart"),r.appendChild(a),m._$cart=a,h(window,"message",(t=>{if("https://app.acuityai.com"===t.origin){const e=JSON.parse(t.data);"cart-close"===e.type?a.style.display="none":"redirect-to"===e.type?window.location.href=e.data.location:"cart-update"===e.type&&o.emit("cartTotal",e.data.total)}})),m.openCart=()=>{a.style.display="block",setTimeout((()=>{f(m._$cart,{type:"toggle-cart"})}),100)},o.on("add-to-cart",(()=>{setTimeout((()=>{f(m._$cart,{type:"update-session-cart"})}),1e3)})),setTimeout((()=>{f(m._$cart,{type:"start-cart"})}),1e3)}({company:n,asset:a}),i.appendChild(s);const d=function(t){const e=document.querySelector(t),n=document.createElement("div");if(!e)return;n.innerHTML='<style>\n/* Acuity */\n.acuityai-open-cart.has-products::after {\n content: attr(data-total);\n position: absolute;\n width: 14px;\n height: 14px;\n background-color: rgb(183, 7, 46);\n color: #FFFFFF;\n font-size: 10px;\n line-height: 12px;\n border-radius: 14px;\n display: flex;\n justify-content: center;\n align-items: center;\n top: 0;\n right: 0;\n font-family: \'Open Sans\';\n text-indent: 2px;\n}\n\n.acuityai-open-cart.more-than-9-products.has-products::after {\n font-size: 8px;\n}\n\n.acuityai-open-cart {\n height: 40px;\n width: 40px;\n background-color: #FFFFFF;\n border-radius: 30px;\n display: flex;\n position: relative;\n justify-content: center;\n align-items: center;\n box-shadow: 0 0 2px rgba(0,0,0,.5);\n}\n\n.acuityai-open-cart:active {\n transform: scale(.95);\n}\n\n.acuityai-open-cart > * {\n cursor: pointer;\n}\n</style>\n<svg width="22px" height="20px" viewBox="0 0 22 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Components" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n <g id="header-bar" transform="translate(-328.000000, -20.000000)" fill="#3D4246" fill-rule="nonzero">\n <g id="cart" transform="translate(311.000000, 8.000000)">\n <path d="M17.8138789,13.6277578 C17.3662455,13.6277578 17,13.2615123 17,12.8138789 C17,12.3662455 17.3662455,12 17.8138789,12 L20.7574395,12 C21.123685,12 21.4492366,12.2441637 21.5441732,12.5968605 L24.8674801,24.6151231 L33.9286813,24.6151231 L36.9400332,17.6971523 L26.9021774,17.6971523 C26.454544,17.6971523 26.0882985,17.3309068 26.0882985,16.8832734 C26.0882985,16.43564 26.454544,16.0693945 26.9021774,16.0693945 L38.1879011,16.0693945 C38.45921,16.0693945 38.7169224,16.2050251 38.8661495,16.43564 C39.0153765,16.666255 39.0425218,16.9511126 38.9339887,17.208825 L35.2172909,25.7545535 C35.0816604,26.0529598 34.7968028,26.2428809 34.4712512,26.2428809 L24.257071,26.2428809 C23.8908255,26.2428809 23.5652739,25.9987172 23.4703373,25.6460204 L20.1469825,13.6277578 L17.8138789,13.6277578 Z M23.483886,31.9671785 C22.4665374,31.9671785 21.6391098,31.139703 21.6391098,30.1223544 C21.6391098,29.1050057 22.4665374,28.277626 23.483886,28.277626 C24.5012346,28.277626 25.3286622,29.1050536 25.3286622,30.1224022 C25.3286622,31.1397509 24.5012346,31.9671785 23.483886,31.9671785 Z M35.0138691,31.9671785 C34.0507631,31.9671785 33.2504329,31.2075422 33.1826415,30.2444362 C33.1148023,29.2406841 33.8744386,28.3454173 34.8917873,28.2775781 C35.9091359,28.2097389 36.7908061,28.9829239 36.8586453,29.9867238 C36.8857906,30.4885999 36.7365635,30.9633785 36.4110119,31.329624 C36.0854604,31.7094661 35.637827,31.9264845 35.1494996,31.9671785 C35.1088057,31.9671785 35.054563,31.9671785 35.0138691,31.9671785 Z" id="Combined-Shape"></path>\n </g>\n </g>\n </g>\n</svg>',n.classList.add("acuityai-open-cart"),n.addEventListener("click",(()=>{m.toggleCart()}));const a=t=>{n.classList.add("has-products"),t>9?(n.classList.add("more-than-9-products"),n.dataset.total="+9"):n.dataset.total=t};return o.on("cartTotal",a),e.appendChild(n),()=>{e&&(e.removeChild(n),o.off("cartTotal",a))}}(c);h(window,"message",(t=>{if("https://app.acuityai.com"===t.origin){const e=JSON.parse(t.data);"open-product"==e.type&&y(e)}})),l({company:window.company});const p=(t=>({duration:e,currentTime:n})=>{f(t,{type:"video-progress",duration:e,currentTime:n})})(s);let C,x,L;var b;o.on("progress",p),o.on("notify:product-open",w),o.on("notify:product-closed",v),r&&(b=r,C=()=>{g=!b.paused,b.pause()},x=(t=>()=>{g&&t.play(),m._$cart&&f(m._$cart,{type:"update-cart"})})(r),L=function(t,e){const n=n=>{f(e,{type:"video-progress",duration:t.duration,currentTime:t.currentTime})};t.addEventListener("progress",n);const o=n=>{f(e,{type:"video-progress",duration:t.duration,currentTime:t.currentTime})};return t.addEventListener("seeked",o),()=>{t.removeEventListener("progress",n),t.removeEventListener("seeked",o)}}(r,s),o.on("notify:product-open",C),o.on("notify:product-closed",x)),m.destroy=()=>{s.parentElement.removeChild(s),u&&o.off("notify:product-open",C),_closeProduct&&o.off("notify:product-closed",x),L&&L(),o.off("notify:product-open",w),o.off("notify:product-closed",v),o.off("progress",p),d()}},m.events=o,m.destroy=()=>null,m.setProgress=t=>o.emit("progress",t); |
{ | ||
"name": "@acuityai/acuityai", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "The acuityai SDK is library that uses https://acuityai.com com for implement shoppable in video element by utilizing our easy interface.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12251
1