@acuityai/acuityai
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,1 +0,1 @@ | ||
import t from"url-join";import e from"event-lite";import{env as n}from"process";var o,r=t;function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=a(e),c=a(r);function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var d,u,p=new(function(t){var e,n;function o(){return t.apply(this,arguments)||this}return n=t,(e=o).prototype=Object.create(n.prototype),e.prototype.constructor=e,s(e,n),o}(i.default));u=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 p.emit(n.msg,n.data);switch(n.msg){case"redirect-to":return p.emit("redirect-to",n);case"add-to-cart":return p.emit("add-to-cart",n);case"close-ad-popup":return p.emit("close-ad-popup",n);case"open-product":return p.emit("open-product",n);case"close-product":return p.emit("close-product");case"close":return p.emit("close");case"open-standalonecart":return p.emit("open-standalonecart");default:return p.emit(n.msg,n.data)}}catch(t){}},(d=window).addEventListener?d.addEventListener("message",u):d.attachEvent&&d.attachEvent("onmessage",u);var l,f,m=n,y=m.REACT_APP_URL,h=m.NODE_ENV;function g(t){return document.getElementById("acuity-cart-iframe").style.display="block",p.emit("notify:product-open",{id:l=t.data.id}),e={msg:"open-product",data:t.data},void document.getElementById("acuity-cart-iframe").contentWindow.postMessage(e,"*");var e}p.on("open-product",g),p.on("close-product",(function(){document.getElementById("acuity-cart-iframe").style.display="none",p.emit("notify:product-closed",{id:l})})),p.on("add-to-cart",(function(t){var e=t.product;if(e.id&&"examples.acuityai.com"===window.location.host){var n=new XMLHttpRequest;n.open("POST",window.location.protocol+"//"+window.location.host+"/cart/add",!0),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.onreadystatechange=function(){if(this.readyState===XMLHttpRequest.DONE&&200===this.status){if(console.log("product added to cart!"),"examples.acuityai.com"!==window.location.host)return;var t=document.querySelectorAll(".site-header__cart-count span")[0];t.innerText=Number(t.innerText)+1}},n.send("id="+e.id)}}));var w,v=window.acuityaiLayer||{};function C(t){g({data:{asset:t.name,product:{id:t.productId},client:window.company}})}function x(t,e){t.contentWindow.postMessage(JSON.stringify(e),"*")}function b(t,e,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent&&t.attachEvent("on"+e,n)}window.acuityaiLayer=v;var L=function(){return p.emit("openProduct")},E=function(){return p.emit("closeProduct")};v.setProgress=function(t){return v.events.emit("progress",t)},v.onClickProduct=C,v.toggleCart=function(){return null},v.start=function(t){var e=t.company,n=t.asset,o=t.video,r=t.cartButtonSelector,a=document.querySelector(t.selector),i=document.createElement("iframe");window.company=e,i.style.border=0,i.style.backgroundColor="rgba(0,0,0,0)",i.height=128,i.width=300,i.src=c.default("https://app.acuityai.com","app",e,n,"productpanel"),function(t){var e=t.company,n=document.createElement("iframe"),o=document.querySelector("body");n.style.display="none",n.style.position="fixed",n.style.top=0,n.style.right=0,n.style.border=0,n.style.zIndex=99999,n.style.width="460px",n.style.height="100%",n.style.backgroundColor="rgba(0,0,0,0)",n.src=c.default("https://app.acuityai.com","app",e,"shoppingcart"),o.appendChild(n),v._$cart=n,b(window,"message",(function(t){if("https://app.acuityai.com"===t.origin){var e=JSON.parse(t.data);"cart-close"===e.type?n.style.display="none":"redirect-to"===e.type?fetch("https://examples.acuityai.com/cart/clear.js",{method:"POST",json:!0,body:{}}).finally((function(){window.location.href=e.data.location})):"cart-update"===e.type&&p.emit("cartTotal",e.data.total)}})),v.toggleCart=function(){n.style.display="block",setTimeout((function(){x(v._$cart,{type:"toggle-cart"})}),100)},p.on("add-to-cart",(function(){setTimeout((function(){x(v._$cart,{type:"update-session-cart"})}),1e3)})),setTimeout((function(){x(v._$cart,{type:"start-cart"})}),1e3)}({company:e,asset:n});var s=function(t){var e=document.createElement("div");e.classList.add("acuityai-open-cart"),e.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>',e.addEventListener("click",(function(){v.toggleCart()})),p.on("cartTotal",(function(t){e.classList.add("has-products"),t>9?(e.classList.add("more-than-9-products"),e.dataset.total="+9"):e.dataset.total=t}));var n=document.querySelector(t);return n&&n.appendChild(e),function(){n.removeChild(e)}}(r);a.appendChild(i),b(window,"message",(function(t){if("https://app.acuityai.com"===t.origin){var e=JSON.parse(t.data);"open-product"==e.type&&C(e)}})),function(t){var e=window.company;if(!f){var n=document.createElement("div");n.innerHTML='\n <iframe id="acuity-cart-iframe" src="'+function(t){if("production"!==h)return y;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 y}}(e)+"?type=cart&company="+e+'" 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(n),f=n}}(),p.on("notify:product-open",L),p.on("notify:product-closed",E);var d,u,l,m,g=function(t){return function(e){x(t,{type:"video-progress",duration:e.duration,currentTime:e.currentTime})}}(i);p.on("progress",g),o&&(l=function(t,e){var n=function(n){x(e,{type:"video-progress",duration:t.duration,currentTime:t.currentTime})};t.addEventListener("progress",n);var o=function(n){x(e,{type:"video-progress",duration:t.duration,currentTime:t.currentTime})};return t.addEventListener("seeked",o),function(){t.removeEventListener("progress",n),t.removeEventListener("seeked",o)}}(o,i),m=o,d=function(){w=!m.paused,m.pause()},u=function(t){return function(){w&&t.play(),v._$cart&&x(v._$cart,{type:"update-cart"})}}(o),p.on("notify:product-open",d),p.on("notify:product-closed",u)),v.destroy=function(){i.parentElement.removeChild(i),d&&p.off("notify:product-open",d),u&&p.off("notify:product-closed",u),l&&l(),p.off("notify:product-open",L),p.off("notify:product-closed",E),p.off("progress",g),s()}},v.events=p,v.destroy=function(){return null},o=v;export default o; | ||
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{REACT_APP_URL:m}=e,y=window.acuityaiLayer||{};function f({name:t,productId:e}){u({data:{asset:t,product:{id:e},client:window.company}})}function w(t,e){t.contentWindow.postMessage(JSON.stringify(e),"*")}function h(t,e,o){t.addEventListener?t.addEventListener(e,o):t.attachEvent&&t.attachEvent("on"+e,o)}let g;window.acuityaiLayer=y;y.onClickProduct=f,y.openCart=()=>null,y.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(m,"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(m,"app",e,"shoppingcart"),r.appendChild(a),y._$cart=a,h(window,"message",(t=>{if(t.origin===m){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)}})),y.openCart=()=>{a.style.display="block",setTimeout((()=>{w(y._$cart,{type:"toggle-cart"})}),100)},n.on("add-to-cart",(()=>{setTimeout((()=>{w(y._$cart,{type:"update-session-cart"})}),1e3)})),setTimeout((()=>{w(y._$cart,{type:"start-cart"})}),1e3)}({company:o,asset:a}),i.appendChild(s),h(window,"message",(t=>{if(t.origin===m){const e=JSON.parse(t.data);"open-product"==e.type&&f(e)}})),function(t,e){t.addEventListener("progress",(o=>{w(e,{type:"video-progress",duration:t.duration,currentTime:t.currentTime})})),t.addEventListener("seeked",(o=>{w(e,{type:"video-progress",duration:t.duration,currentTime:t.currentTime})}))}(r,s),l({company:window.company});const d=(p=r,()=>{g=!p.paused,p.pause()});var p;const u=(t=>()=>{g&&t.play(),y._$cart&&w(y._$cart,{type:"update-cart"})})(r);c||(n.on("notify:product-open",d),n.on("notify:product-closed",u)),y.destroy=()=>{s.parentElement.removeChild(s),n.off("notify:product-open",d),n.off("notify:product-closed",u)}},y.events=n,y.destroy=()=>null; |
{ | ||
"name": "@acuityai/acuityai", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"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", |
Network access
Supply chain riskThis module accesses the network.
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
0
1
8265