@featurepeek/snippet.js
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -1,1 +0,1 @@ | ||
function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var o=[],n=!0,r=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(n=(i=c.next()).done)&&(o.push(i.value),!t||o.length!==t);n=!0);}catch(e){r=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(r)throw a}}return o}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o<t;o++)n[o]=e[o];return n}!function(){function r(e,t){return o=t,e.x<o.x&&(t=t,(e=e).x+e.width<t.x);var o}function a(e,t){return o=t,e.y<o.y&&(t=t,(e=e).y+e.height<t.y);var o}function o(e,t){return e.width<=t.width?e:t}function n(e,t){return e.height<=t.height?e:t}function i(e,t){return e.y!==o(e,t).y?C(t,e):{x:e.x+e.width/2,y:e.y+e.height,height:t.y-(e.y+e.height)}}function c(e,t){return e.x!==n(e,t).x?j(t,e):{x:t.x+t.width,y:e.y+e.height/2,width:e.x-(t.x+t.width)}}function d(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}function s(e,t,o){var n=2<arguments.length&&void 0!==o?o:"red",r={blue:{hex:"#18a0fb",data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAIAAADZrBkAAAAAPklEQVR4AWOQWPAbH5oPQpjiIG2EEC20/ScCDJi2+XTTNp9UbfPgts0hRdt8uLa55DlyHhnahkZ00z8HkIEAA7TgNxFIMYsAAAAASUVORK5CYII="},red:{hex:"#f24822",data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAIAAADZrBkAAAAAHUlEQVR4AWP45KFEBhoobf+JALTXNqptVNuQyDgAD6SjH1sbDJwAAAAASUVORK5CYII="}};return["border: 1px solid","border-image: url(".concat(r[n].data,") 30 / 9px / 5px"),"box-shadow: 0 0 0 2px ".concat(r[n].hex),"display: flex","height: ".concat(Math.max(t.height-2,0),"px"),"justify-content: center","left: ".concat(e.pageXOffset+t.x,"px"),"pointer-events: none","position: absolute","top: ".concat(e.pageYOffset+t.y,"px"),"visibility: visible","width: ".concat(Math.max(t.width-2,0),"px"),"z-index: 99999999999999999"].join(";")}function l(e,t,o){var n=2<arguments.length&&void 0!==o?o:"red";if(i=e.document.getElementById(t))return i;var r=e.document.createElement("div"),a=e.document.createElement("code"),i=e.document.createElement("span");return r.id=t,a.style=["background: #ffffc2","font-size: 11px","left: 4px","line-height: 11px","margin: 0","max-width: calc(100% - 7px)","overflow: hidden","padding: 2px 4px","position: absolute","text-overflow: ellipsis","top: -18px","white-space: nowrap","word-wrap: normal"].join(";"),i.style=["background: ".concat("red"===n?"#fdeae6":"#e6f4ff"),"border-radius: 3px","bottom: -20px","color: ".concat("red"===n?"#f24822":"#18a0fb"),"font-family: -apple-system, 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif","font-size: 11px","line-height: 11px","margin: 0","padding: 2px 4px","position: absolute","text-align: center","white-space: nowrap"].join(";"),r.appendChild(a),r.appendChild(i),e.document.body.appendChild(r),e.document.getElementById(t)}function h(e,t){var o=e.document.getElementById(t);return o||((o=e.document.createElement("div")).id=t,e.document.body.appendChild(o),e.document.getElementById(t))}function p(e){return['<span style="color:#88137f">'.concat(e.tagName.toLowerCase(),"</span>"),e.id&&'<span style="color:#1a1aa6">#'.concat(e.id,"</span>"),e.className&&'<span style="color:#9a4500">.'.concat(e.className.replace(/ /g,"."),"</span>")].filter(Boolean).join("")}function y(t){var o=["align-items: center","border-width: 1px","font-size: 11px","line-height: 11px","margin: 0","padding: 0","pointer-events: none","position: absolute","visibility: visible","z-index: 9999999999999"],n=["background: #fdeae6","border-radius: 3px","color: #f24822","font-family: -apple-system, 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif","margin: 3px","padding: 2px 4px"];Object.keys(t).forEach(function(e){e=t[e];e.el.style=[].concat(o,_toConsumableArray(e.styles),["display: ".concat(1<e.distance?"flex":"none")]).join(";"),e.el.innerHTML='<span style="'.concat(n.join(";"),'">').concat(e.distance,"</span>")})}function f(e,t,o,n){var r=(s=o,i=n,Math.round(i.x>s.x+s.width?i.x-(s.x+s.width):s.x-(i.x+i.width))),a=(c=o,d=n,Math.round(d.y>c.y+c.height?d.y-(c.y+c.height):c.y-(d.y+d.height))),i=(l=n,{horz:{x:(s=o).x<l.x?s.x+s.width:l.x+l.width,y:s.y<l.y?s.y+s.height/2:l.y+l.height},vert:{x:s.x<l.x?s.x+s.width/2:s.x,y:s.y<l.y?s.y+s.height:l.y+l.height}}),c=e.pageXOffset+i.horz.x,d=e.pageYOffset+i.horz.y,s=a+o.height/2,l=e.pageXOffset+i.vert.x,e=e.pageYOffset+i.vert.y,i=o.width/2,i={horz:{el:t[0],distance:r,styles:["border-top-style: ".concat(o.y<n.y?"solid":"dashed"),"border-right-style: dashed","border-bottom-style: ".concat(o.y>n.y?"solid":"dashed"),"border-left-style: dashed","border-top-color: #f24822","border-right-color: ".concat(o.x<n.x?"#f24822":"transparent"),"border-bottom-color: #f24822","border-left-color: ".concat(o.x>n.x?"#f24822":"transparent"),"flex-direction: column","justify-content: flex-".concat(o.y<n.y?"start":"end"),"height: ".concat(s-2,"px"),"left: ".concat(c,"px"),"top: ".concat(d,"px"),"width: ".concat(r-2,"px")]},vert:{el:t[1],distance:a,styles:["border-top-style: dashed","border-right-style: solid","border-bottom-style: dashed","border-left-style: solid","border-top-color: ".concat(o.y>n.y?"#f24822":"transparent"),"border-right-color: ".concat(o.x>n.x?"#f24822":"transparent"),"border-bottom-color: ".concat(o.y<n.y?"#f24822":"transparent"),"border-left-color: ".concat(o.x<n.x?"#f24822":"transparent"),"justify-content: flex-".concat(o.x<n.x?"start":"end"),"height: ".concat(a-2,"px"),"left: ".concat(l,"px"),"top: ".concat(e,"px"),"width: ".concat(i-2,"px")]}};y(i)}function u(e,t,o,n){o={north:{el:t[0],distance:Math.round(n.y-o.y),styles:["border-left: 1px solid #f24822","height: ".concat(n.y-o.y,"px"),"left: ".concat(e.pageXOffset+n.x+n.width/2,"px"),"top: ".concat(e.pageYOffset+o.y-2,"px")]},south:{el:t[1],distance:Math.round(o.y+o.height-(n.y+n.height)),styles:["border-left: 1px solid #f24822","height: ".concat(o.y+o.height-(n.y+n.height),"px"),"left: ".concat(e.pageXOffset+n.x+n.width/2,"px"),"top: ".concat(e.pageYOffset+n.y+n.height+2,"px")]},east:{el:t[2],distance:Math.round(o.x+o.width-(n.x+n.width)),styles:["border-top: 1px solid #f24822","flex-direction: column","left: ".concat(e.pageXOffset+n.x+n.width+2,"px"),"top: ".concat(e.pageYOffset+n.y+n.height/2,"px"),"width: ".concat(o.x+o.width-(n.x+n.width),"px")]},west:{el:t[3],distance:Math.round(n.x-o.x),styles:["border-top: 1px solid #f24822","flex-direction: column","left: ".concat(e.pageXOffset+o.x,"px"),"top: ".concat(e.pageYOffset+n.y+n.height/2,"px"),"width: ".concat(n.x-o.x-2,"px")]}},y(o)}function x(e){e.forEach(function(e){e&&(e.style.visibility="hidden")})}function g(e){var t;e&&m&&(t=e.getBoundingClientRect(),m.style=s(window,t,"blue"),w.innerHTML=p(e),A.innerText="".concat(Math.round(t.width)," × ").concat(Math.round(t.height)),x([v,O,I,T,k]))}function b(e){var t,o,n;v&&(t=m.getBoundingClientRect(),o=e.getBoundingClientRect(),v.style=s(window,o,"red"),_.innerHTML=p(e),E.innerText="".concat(Math.round(o.width)," × ").concat(Math.round(o.height)),(r(n=t,e=o)||r(e,n))&&(a(n,e)||a(e,n))?(f(window,[O,I],t,o),x([T,k])):d(t,o)?u(window,[O,I,T,k],t,o):d(o,t)?u(window,[O,I,T,k],o,t):(N(t,o)?function(e,t,o,n){n=i(o,n),n={pos:{el:t,distance:Math.round(n.height),styles:["border-left: 1px solid #f24822","height: ".concat(n.height,"px"),"left: ".concat(e.pageXOffset+n.x,"px"),"top: ".concat(e.pageYOffset+n.y,"px")]}};y(n)}(window,O,t,o):a(o,t)?function(e,t,o,n){n=C(o,n),n={pos:{el:t,distance:Math.round(n.height),styles:["border-left: 1px solid #f24822","height: ".concat(n.height,"px"),"left: ".concat(e.pageXOffset+n.x,"px"),"top: ".concat(e.pageYOffset+n.y,"px")]}};y(n)}(window,O,t,o):r(o,t)?function(e,t,o,n){n=c(o,n),n={pos:{el:t,distance:Math.round(n.width),styles:["border-top: 1px solid #f24822","flex-direction: column","left: ".concat(e.pageXOffset+n.x,"px"),"top: ".concat(e.pageYOffset+n.y,"px"),"width: ".concat(n.width,"px")]}};y(n)}(window,O,t,o):B(t,o)&&function(e,t,o,n){n=j(o,n),n={pos:{el:t,distance:Math.round(n.width),styles:["border-top: 1px solid #f24822","flex-direction: column","left: ".concat(e.pageXOffset+n.x,"px"),"top: ".concat(e.pageYOffset+n.y,"px"),"width: ".concat(n.width,"px")]}};y(n)}(window,O,t,o),x([I,T,k])))}var m,w,A,v,_,E,O,I,T,k,S,M,L,N=a,B=r,C=function(e,t){return e.y!==o(e,t).y?i(t,e):{x:e.x+e.width/2,y:t.y+t.height,height:e.y-(t.y+t.height)}},j=function(e,t){return e.x!==n(e,t).x?c(t,e):{x:e.x+e.width,y:e.y+e.height/2,width:t.x-(e.x+e.width)}},R="_featurepeek_selection_box",H="_featurepeek_comparison_box",Y="_featurepeek_measure_1",D="_featurepeek_measure_2",X="_featurepeek_measure_3",U="_featurepeek_measure_4";try{var e=document.querySelector("script[data-repo][data-id]");if(!e)return;var z,t=document.location.hostname.split("--")[0].split("-")[2],F=e.dataset,V=F.repo,W=F.id,e=F.env,F=F.vcs,P="https://dashboard".concat("dev"===e?".dev":"",".featurepeek.com");t&&W&&V&&((z=document.createElement("iframe")).allow="display-capture",z.src="".concat(P,"/netlify/").concat(F||"github","/").concat(V,"/").concat(t,"/").concat(W),z.style=["display:block","border:0","position:fixed","left:0","bottom:0","width:52px","height:300px","z-index:9999999999"].join(";"),document.body.appendChild(z),window.addEventListener("message",function(e){var t;if(e.origin===P)switch(e.data){case"FULL_VIEWPORT":z.style.height="100vh",z.style.width="100vw";break;case"HALF_VIEWPORT":z.style.height="300px",z.style.width="240px";break;case"TINY_VIEWPORT":z.style.height="300px",z.style.width="52px";break;case"DESIGN_MODE_ON":document.designMode="on";break;case"DESIGN_MODE_OFF":document.designMode="off";break;case"BEGIN_SELECTION":!function(){document.body.style.cursor="crosshair";var e=_slicedToArray((m=l(window,R,"blue")).getElementsByTagName("code"),1);w=e[0],e=_slicedToArray(m.getElementsByTagName("span"),1),A=e[0],e=_slicedToArray((v=l(window,H,"red")).getElementsByTagName("code"),1),_=e[0],e=_slicedToArray(v.getElementsByTagName("span"),1),E=e[0],O=h(window,Y),I=h(window,D),T=h(window,X),k=h(window,U),M=function(e){m?(S?b:g)(e.target):document.body.removeEventListener("mouseover",M)},(L=function(e){e?(e.preventDefault(),e.stopPropagation(),g(e.target),S=!0):(e=document.querySelectorAll(":hover"))&&(e=e[e.length-1],g(e))})(),document.body.addEventListener("click",L),document.body.addEventListener("mouseover",M)}();break;case"END_SELECTION":S=!1,document.body.style.cursor="default",t=window,[R,H,Y,D,X,U].forEach(function(e){e=t.document.getElementById(e);e&&e.parentNode.removeChild(e)}),document.body.removeEventListener("mouseover",M),document.body.removeEventListener("click",L);break;case"LOCATION_HREF":e.source.postMessage({type:"LOCATION_HREF",value:document.location.href},e.origin)}}))}catch(e){}}(); | ||
function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var o=[],n=!0,r=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(n=(i=c.next()).done)&&(o.push(i.value),!t||o.length!==t);n=!0);}catch(e){r=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(r)throw a}}return o}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);o<t;o++)n[o]=e[o];return n}!function(){function r(e,t){return o=t,e.x<o.x&&(t=t,(e=e).x+e.width<t.x);var o}function a(e,t){return o=t,e.y<o.y&&(t=t,(e=e).y+e.height<t.y);var o}function o(e,t){return e.width<=t.width?e:t}function n(e,t){return e.height<=t.height?e:t}function i(e,t){return e.y!==o(e,t).y?C(t,e):{x:e.x+e.width/2,y:e.y+e.height,height:t.y-(e.y+e.height)}}function c(e,t){return e.x!==n(e,t).x?j(t,e):{x:t.x+t.width,y:e.y+e.height/2,width:e.x-(t.x+t.width)}}function d(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}function s(e,t,o){var n=2<arguments.length&&void 0!==o?o:"red",r={blue:{hex:"#18a0fb",data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAIAAADZrBkAAAAAPklEQVR4AWOQWPAbH5oPQpjiIG2EEC20/ScCDJi2+XTTNp9UbfPgts0hRdt8uLa55DlyHhnahkZ00z8HkIEAA7TgNxFIMYsAAAAASUVORK5CYII="},red:{hex:"#f24822",data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAIAAADZrBkAAAAAHUlEQVR4AWP45KFEBhoobf+JALTXNqptVNuQyDgAD6SjH1sbDJwAAAAASUVORK5CYII="}};return["border: 1px solid","border-image: url(".concat(r[n].data,") 30 / 9px / 5px"),"box-shadow: 0 0 0 2px ".concat(r[n].hex),"display: flex","height: ".concat(Math.max(t.height-2,0),"px"),"justify-content: center","left: ".concat(e.pageXOffset+t.x,"px"),"pointer-events: none","position: absolute","top: ".concat(e.pageYOffset+t.y,"px"),"visibility: visible","width: ".concat(Math.max(t.width-2,0),"px"),"z-index: 99999999999999999"].join(";")}function l(e,t,o){var n=2<arguments.length&&void 0!==o?o:"red";if(i=e.document.getElementById(t))return i;var r=e.document.createElement("div"),a=e.document.createElement("code"),i=e.document.createElement("span");return r.id=t,a.style=["background: #ffffc2","font-size: 11px","left: 4px","line-height: 11px","margin: 0","max-width: calc(100% - 7px)","overflow: hidden","padding: 2px 4px","position: absolute","text-overflow: ellipsis","top: -18px","white-space: nowrap","word-wrap: normal"].join(";"),i.style=["background: ".concat("red"===n?"#fdeae6":"#e6f4ff"),"border-radius: 3px","bottom: -20px","color: ".concat("red"===n?"#f24822":"#18a0fb"),"font-family: -apple-system, 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif","font-size: 11px","line-height: 11px","margin: 0","padding: 2px 4px","position: absolute","text-align: center","white-space: nowrap"].join(";"),r.appendChild(a),r.appendChild(i),e.document.body.appendChild(r),e.document.getElementById(t)}function p(e,t){var o=e.document.getElementById(t);return o||((o=e.document.createElement("div")).id=t,e.document.body.appendChild(o),e.document.getElementById(t))}function h(e){return['<span style="color:#88137f">'.concat(e.tagName.toLowerCase(),"</span>"),e.id&&'<span style="color:#1a1aa6">#'.concat(e.id,"</span>"),e.className&&'<span style="color:#9a4500">.'.concat(e.className.replace(/ /g,"."),"</span>")].filter(Boolean).join("")}function f(t){var o=["align-items: center","border-width: 1px","font-size: 11px","line-height: 11px","margin: 0","padding: 0","pointer-events: none","position: absolute","visibility: visible","z-index: 9999999999999"],n=["background: #fdeae6","border-radius: 3px","color: #f24822","font-family: -apple-system, 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif","margin: 3px","padding: 2px 4px"];Object.keys(t).forEach(function(e){e=t[e];e.el.style=[].concat(o,_toConsumableArray(e.styles),["display: ".concat(1<e.distance?"flex":"none")]).join(";"),e.el.innerHTML='<span style="'.concat(n.join(";"),'">').concat(e.distance,"</span>")})}function y(e,t,o,n){var r=(s=o,i=n,Math.round(i.x>s.x+s.width?i.x-(s.x+s.width):s.x-(i.x+i.width))),a=(c=o,d=n,Math.round(d.y>c.y+c.height?d.y-(c.y+c.height):c.y-(d.y+d.height))),i=(l=n,{horz:{x:(s=o).x<l.x?s.x+s.width:l.x+l.width,y:s.y<l.y?s.y+s.height/2:l.y+l.height},vert:{x:s.x<l.x?s.x+s.width/2:s.x,y:s.y<l.y?s.y+s.height:l.y+l.height}}),c=e.pageXOffset+i.horz.x,d=e.pageYOffset+i.horz.y,s=a+o.height/2,l=e.pageXOffset+i.vert.x,e=e.pageYOffset+i.vert.y,i=o.width/2,i={horz:{el:t[0],distance:r,styles:["border-top-style: ".concat(o.y<n.y?"solid":"dashed"),"border-right-style: dashed","border-bottom-style: ".concat(o.y>n.y?"solid":"dashed"),"border-left-style: dashed","border-top-color: #f24822","border-right-color: ".concat(o.x<n.x?"#f24822":"transparent"),"border-bottom-color: #f24822","border-left-color: ".concat(o.x>n.x?"#f24822":"transparent"),"flex-direction: column","justify-content: flex-".concat(o.y<n.y?"start":"end"),"height: ".concat(s-2,"px"),"left: ".concat(c,"px"),"top: ".concat(d,"px"),"width: ".concat(r-2,"px")]},vert:{el:t[1],distance:a,styles:["border-top-style: dashed","border-right-style: solid","border-bottom-style: dashed","border-left-style: solid","border-top-color: ".concat(o.y>n.y?"#f24822":"transparent"),"border-right-color: ".concat(o.x>n.x?"#f24822":"transparent"),"border-bottom-color: ".concat(o.y<n.y?"#f24822":"transparent"),"border-left-color: ".concat(o.x<n.x?"#f24822":"transparent"),"justify-content: flex-".concat(o.x<n.x?"start":"end"),"height: ".concat(a-2,"px"),"left: ".concat(l,"px"),"top: ".concat(e,"px"),"width: ".concat(i-2,"px")]}};f(i)}function u(e,t,o,n){o={north:{el:t[0],distance:Math.round(n.y-o.y),styles:["border-left: 1px solid #f24822","height: ".concat(n.y-o.y,"px"),"left: ".concat(e.pageXOffset+n.x+n.width/2,"px"),"top: ".concat(e.pageYOffset+o.y-2,"px")]},south:{el:t[1],distance:Math.round(o.y+o.height-(n.y+n.height)),styles:["border-left: 1px solid #f24822","height: ".concat(o.y+o.height-(n.y+n.height),"px"),"left: ".concat(e.pageXOffset+n.x+n.width/2,"px"),"top: ".concat(e.pageYOffset+n.y+n.height+2,"px")]},east:{el:t[2],distance:Math.round(o.x+o.width-(n.x+n.width)),styles:["border-top: 1px solid #f24822","flex-direction: column","left: ".concat(e.pageXOffset+n.x+n.width+2,"px"),"top: ".concat(e.pageYOffset+n.y+n.height/2,"px"),"width: ".concat(o.x+o.width-(n.x+n.width),"px")]},west:{el:t[3],distance:Math.round(n.x-o.x),styles:["border-top: 1px solid #f24822","flex-direction: column","left: ".concat(e.pageXOffset+o.x,"px"),"top: ".concat(e.pageYOffset+n.y+n.height/2,"px"),"width: ".concat(n.x-o.x-2,"px")]}},f(o)}function x(e){e.forEach(function(e){e&&(e.style.visibility="hidden")})}function g(e){var t;e&&m&&(t=e.getBoundingClientRect(),m.style=s(window,t,"blue"),w.innerHTML=h(e),A.innerText="".concat(Math.round(t.width)," × ").concat(Math.round(t.height)),x([v,O,I,T,k]))}function b(e){var t,o,n;v&&(t=m.getBoundingClientRect(),o=e.getBoundingClientRect(),v.style=s(window,o,"red"),_.innerHTML=h(e),E.innerText="".concat(Math.round(o.width)," × ").concat(Math.round(o.height)),(r(n=t,e=o)||r(e,n))&&(a(n,e)||a(e,n))?(y(window,[O,I],t,o),x([T,k])):d(t,o)?u(window,[O,I,T,k],t,o):d(o,t)?u(window,[O,I,T,k],o,t):(L(t,o)?function(e,t,o,n){n=i(o,n),n={pos:{el:t,distance:Math.round(n.height),styles:["border-left: 1px solid #f24822","height: ".concat(n.height,"px"),"left: ".concat(e.pageXOffset+n.x,"px"),"top: ".concat(e.pageYOffset+n.y,"px")]}};f(n)}(window,O,t,o):a(o,t)?function(e,t,o,n){n=C(o,n),n={pos:{el:t,distance:Math.round(n.height),styles:["border-left: 1px solid #f24822","height: ".concat(n.height,"px"),"left: ".concat(e.pageXOffset+n.x,"px"),"top: ".concat(e.pageYOffset+n.y,"px")]}};f(n)}(window,O,t,o):r(o,t)?function(e,t,o,n){n=c(o,n),n={pos:{el:t,distance:Math.round(n.width),styles:["border-top: 1px solid #f24822","flex-direction: column","left: ".concat(e.pageXOffset+n.x,"px"),"top: ".concat(e.pageYOffset+n.y,"px"),"width: ".concat(n.width,"px")]}};f(n)}(window,O,t,o):B(t,o)&&function(e,t,o,n){n=j(o,n),n={pos:{el:t,distance:Math.round(n.width),styles:["border-top: 1px solid #f24822","flex-direction: column","left: ".concat(e.pageXOffset+n.x,"px"),"top: ".concat(e.pageYOffset+n.y,"px"),"width: ".concat(n.width,"px")]}};f(n)}(window,O,t,o),x([I,T,k])))}var m,w,A,v,_,E,O,I,T,k,S,M,N,L=a,B=r,C=function(e,t){return e.y!==o(e,t).y?i(t,e):{x:e.x+e.width/2,y:t.y+t.height,height:e.y-(t.y+t.height)}},j=function(e,t){return e.x!==n(e,t).x?c(t,e):{x:e.x+e.width,y:e.y+e.height/2,width:t.x-(e.x+e.width)}},R="_featurepeek_selection_box",H="_featurepeek_comparison_box",F="_featurepeek_measure_1",P="_featurepeek_measure_2",Y="_featurepeek_measure_3",D="_featurepeek_measure_4";try{var e=document.querySelector("script[data-repo][data-id]");if(!e)return console.warn("FeaturePeek snippet: You are missing a script tag with data-repo and data-id attributes.");var t=e.dataset,U=t.repo,X=t.id,z=t.env,V=t.vcs;if(!/\//.test(U))return console.warn("FeaturePeek snippet: The value you set for `repo` does not contain a slash (/).");if(!/^[0-9a-f-]{36}$/i.test(X))return console.warn("FeaturePeek snippet: The value you set for `id` is not a UUID.");e=document.location.hostname;if(!/--/.test(e))return console.warn("FeaturePeek snippet: The hostname does not appear to be a Netlify deployment.");t=e.split("--")[0],t=/^deploy-preview-/.test(e)?t.split("-")[2]:t;if(!t)return console.warn("FeaturePeek snippet: Something went wrong. Are you using Netlify Deploy Previews?");var W="https://dashboard".concat("dev"===z?".dev":"",".featurepeek.com"),G=document.createElement("iframe");G.allow="display-capture",G.src="".concat(W,"/netlify/").concat(V||"github","/").concat(U,"/").concat(t,"/").concat(X),G.style=["display:block","border:0","position:fixed","left:0","bottom:0","width:52px","height:300px","z-index:9999999999"].join(";"),document.body.appendChild(G),window.addEventListener("message",function(e){var t;if(e.origin===W)switch(e.data){case"FULL_VIEWPORT":G.style.height="100vh",G.style.width="100vw";break;case"HALF_VIEWPORT":G.style.height="300px",G.style.width="240px";break;case"TINY_VIEWPORT":G.style.height="300px",G.style.width="52px";break;case"DESIGN_MODE_ON":document.designMode="on";break;case"DESIGN_MODE_OFF":document.designMode="off";break;case"BEGIN_SELECTION":!function(){document.body.style.cursor="crosshair";var e=_slicedToArray((m=l(window,R,"blue")).getElementsByTagName("code"),1);w=e[0],e=_slicedToArray(m.getElementsByTagName("span"),1),A=e[0],e=_slicedToArray((v=l(window,H,"red")).getElementsByTagName("code"),1),_=e[0],e=_slicedToArray(v.getElementsByTagName("span"),1),E=e[0],O=p(window,F),I=p(window,P),T=p(window,Y),k=p(window,D),M=function(e){m?(S?b:g)(e.target):document.body.removeEventListener("mouseover",M)},(N=function(e){e?(e.preventDefault(),e.stopPropagation(),g(e.target),S=!0):(e=document.querySelectorAll(":hover"))&&(e=e[e.length-1],g(e))})(),document.body.addEventListener("click",N),document.body.addEventListener("mouseover",M)}();break;case"END_SELECTION":S=!1,document.body.style.cursor="default",t=window,[R,H,F,P,Y,D].forEach(function(e){e=t.document.getElementById(e);e&&e.parentNode.removeChild(e)}),document.body.removeEventListener("mouseover",M),document.body.removeEventListener("click",N);break;case"LOCATION_HREF":e.source.postMessage({type:"LOCATION_HREF",value:document.location.href},e.origin)}})}catch(e){console.error("FeaturePeek snippet: ".concat(e))}}(); |
{ | ||
"name": "@featurepeek/snippet.js", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"main": "dist/loader.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/featurepeek/snippet.js", |
@@ -601,69 +601,98 @@ ;(() => { | ||
if (!scriptTag) { | ||
// eslint-disable-next-line no-console | ||
console.warn('FeaturePeek snippet: You are missing a script tag with data-repo and data-id attributes.') | ||
return | ||
} | ||
const { hostname } = document.location | ||
const branch = hostname.split('--')[0] | ||
const pr = branch.split('-')[2] | ||
const { repo, id, env, vcs } = scriptTag.dataset | ||
const url = `https://dashboard${env === 'dev' ? '.dev' : ''}.featurepeek.com` | ||
if (pr && id && repo) { | ||
const frame = document.createElement('iframe') | ||
frame.allow = 'display-capture' | ||
frame.src = `${url}/netlify/${vcs || 'github'}/${repo}/${pr}/${id}` | ||
frame.style = [ | ||
'display:block', | ||
'border:0', | ||
'position:fixed', | ||
'left:0', | ||
'bottom:0', | ||
'width:52px', | ||
'height:300px', | ||
'z-index:9999999999', | ||
].join(';') | ||
document.body.appendChild(frame) | ||
if (!/\//.test(repo)) { | ||
// eslint-disable-next-line no-console | ||
console.warn('FeaturePeek snippet: The value you set for `repo` does not contain a slash (/).') | ||
return | ||
} | ||
window.addEventListener('message', event => { | ||
if (event.origin !== url) { | ||
return | ||
} | ||
const message = event.data | ||
if (!/^[0-9a-f-]{36}$/i.test(id)) { | ||
// eslint-disable-next-line no-console | ||
console.warn('FeaturePeek snippet: The value you set for `id` is not a UUID.') | ||
return | ||
} | ||
switch (message) { | ||
case 'FULL_VIEWPORT': | ||
frame.style.height = '100vh' | ||
frame.style.width = '100vw' | ||
break | ||
case 'HALF_VIEWPORT': | ||
frame.style.height = '300px' | ||
frame.style.width = '240px' | ||
break | ||
case 'TINY_VIEWPORT': | ||
frame.style.height = '300px' | ||
frame.style.width = '52px' | ||
break | ||
case 'DESIGN_MODE_ON': | ||
document.designMode = 'on' | ||
break | ||
case 'DESIGN_MODE_OFF': | ||
document.designMode = 'off' | ||
break | ||
case 'BEGIN_SELECTION': | ||
beginSelection() | ||
break | ||
case 'END_SELECTION': | ||
endSelection() | ||
break | ||
case 'LOCATION_HREF': | ||
event.source.postMessage({ type: 'LOCATION_HREF', value: document.location.href }, event.origin) | ||
break | ||
default: | ||
break | ||
} | ||
}) | ||
const { hostname } = document.location | ||
if (!/--/.test(hostname)) { | ||
// eslint-disable-next-line no-console | ||
console.warn('FeaturePeek snippet: The hostname does not appear to be a Netlify deployment.') | ||
return | ||
} | ||
const subdomainPrefix = hostname.split('--')[0] | ||
// deploy can be either a PR number, a deployment identifier like 5fc7f1590bae700008b0deef, or a branch name | ||
const deploy = /^deploy-preview-/.test(hostname) ? subdomainPrefix.split('-')[2] : subdomainPrefix | ||
if (!deploy) { | ||
// eslint-disable-next-line no-console | ||
console.warn('FeaturePeek snippet: Something went wrong. Are you using Netlify Deploy Previews?') | ||
return | ||
} | ||
const url = `https://dashboard${env === 'dev' ? '.dev' : ''}.featurepeek.com` | ||
const frame = document.createElement('iframe') | ||
frame.allow = 'display-capture' | ||
frame.src = `${url}/netlify/${vcs || 'github'}/${repo}/${deploy}/${id}` | ||
frame.style = [ | ||
'display:block', | ||
'border:0', | ||
'position:fixed', | ||
'left:0', | ||
'bottom:0', | ||
'width:52px', | ||
'height:300px', | ||
'z-index:9999999999', | ||
].join(';') | ||
document.body.appendChild(frame) | ||
window.addEventListener('message', event => { | ||
if (event.origin !== url) { | ||
return | ||
} | ||
const message = event.data | ||
switch (message) { | ||
case 'FULL_VIEWPORT': | ||
frame.style.height = '100vh' | ||
frame.style.width = '100vw' | ||
break | ||
case 'HALF_VIEWPORT': | ||
frame.style.height = '300px' | ||
frame.style.width = '240px' | ||
break | ||
case 'TINY_VIEWPORT': | ||
frame.style.height = '300px' | ||
frame.style.width = '52px' | ||
break | ||
case 'DESIGN_MODE_ON': | ||
document.designMode = 'on' | ||
break | ||
case 'DESIGN_MODE_OFF': | ||
document.designMode = 'off' | ||
break | ||
case 'BEGIN_SELECTION': | ||
beginSelection() | ||
break | ||
case 'END_SELECTION': | ||
endSelection() | ||
break | ||
case 'LOCATION_HREF': | ||
event.source.postMessage({ type: 'LOCATION_HREF', value: document.location.href }, event.origin) | ||
break | ||
default: | ||
break | ||
} | ||
}) | ||
} catch (e) { | ||
// console.error(e) | ||
// eslint-disable-next-line no-console | ||
console.error(`FeaturePeek snippet: ${e}`) | ||
} | ||
})() |
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
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
139901
2441