@applitools/snippets 2.1.12 → 2.1.13

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
@@ -4,6 +4,12 @@
4
4
  ## Unreleased
5
5
 
6
6
 
7
+ ## 2.1.13 - 2022/2/15
8
+
9
+ - add `getViewportScale` snippet
10
+ - remove auto scaling from `getViewportSize` and `addPageMarker`
11
+ - marker mask and size have to be passed as arguments in `addPageMarker`
12
+
7
13
  ## 2.1.12 - 2021/12/22
8
14
 
9
15
  - round fractional values in `getViewportSize`
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "addElementIds": "function(arg){var s=function(){\"use strict\";return function(t){var o=t[0],e=t[1];return o.map((function(t,o){var r=[t];if(t.getRootNode)for(var a=t.getRootNode();a!==document;a=a.host.getRootNode())r.push(a.host);var n=e[o];return r.map((function(t){var o=t.getAttribute(\"data-applitools-selector\"),e=o?o+\" \"+n:n;return t.setAttribute(\"data-applitools-selector\",e),'[data-applitools-selector~=\"'+n+'\"]'}))}))}}();\nreturn s(arg)}",
3
- "addPageMarker": "function(arg){var s=function(){\"use strict\";var t=function(t){var e=void 0===t?[]:t,r=e[0],o=e[1],n=Object.keys(o).sort(),i=n.reduce((function(t,e){return t[e]={value:r.style.getPropertyValue(e),important:Boolean(r.style.getPropertyPriority(e))},t}),{});return n.forEach((function(t){r.style.setProperty(t,\"string\"!=typeof o[t]&&o[t]?o[t].value:o[t],o[t]&&o[t].important?\"important\":\"\")})),i};return function(){var e=[1,0,1,1,0,1,1,0,1,0,1,0,1,1,0,1,0,0,1,1,1],r={1:\"rgb(0, 0, 0)\",0:\"rgb(255, 255, 255)\"},o=visualViewport?visualViewport.scale:1,n=o>=1?1:2,i=n,a=document.createElement(\"div\");a.setAttribute(\"data-applitools-marker\",\"\"),a.style.setProperty(\"position\",\"fixed\",\"important\"),a.style.setProperty(\"top\",\"0\",\"important\"),a.style.setProperty(\"left\",\"0\",\"important\"),a.style.setProperty(\"box-sizing\",\"content-box\",\"important\"),a.style.setProperty(\"padding\",i/o+\"px\",\"important\"),a.style.setProperty(\"background\",\"rgb(128, 128, 128)\",\"important\"),a.style.setProperty(\"z-index\",\"2147483647\",\"important\");for(var s,p=0;p<e.length;p+=s){for(s=1;e[p]===e[p+s];)++s;var l=e[p],y=document.createElement(\"div\");y.style.setProperty(\"display\",\"block\",\"important\"),y.style.setProperty(\"float\",\"left\",\"important\"),y.style.setProperty(\"width\",s*(n/o)+\"px\",\"important\"),y.style.setProperty(\"height\",n/o+\"px\",\"important\"),y.style.setProperty(\"background\",r[l],\"important\"),a.appendChild(y)}var m={value:\"none\",important:!0},d=t([document.documentElement,{transform:m,\"-webkit-transform\":m}]),u=t([document.body,{transform:m,\"-webkit-transform\":m}]);return document.documentElement.setAttribute(\"data-applitools-original-transforms\",JSON.stringify(d)),document.body.setAttribute(\"data-applitools-original-transforms\",JSON.stringify(u)),document.body.appendChild(a),{mask:e,size:n,offset:i}}}();\nreturn s(arg)}",
3
+ "addPageMarker": "function(arg){var s=function(){\"use strict\";var t=function(t){var e=void 0===t?[]:t,r=e[0],o=e[1],n=Object.keys(o).sort(),i=n.reduce((function(t,e){return t[e]={value:r.style.getPropertyValue(e),important:Boolean(r.style.getPropertyPriority(e))},t}),{});return n.forEach((function(t){r.style.setProperty(t,\"string\"!=typeof o[t]&&o[t]?o[t].value:o[t],o[t]&&o[t].important?\"important\":\"\")})),i};return function(e){var r=e[0],o=r.mask,n=r.size,i=void 0===n?1:n,a={1:\"rgb(0, 0, 0)\",0:\"rgb(255, 255, 255)\"},s=i,p=document.createElement(\"div\");p.setAttribute(\"data-applitools-marker\",\"\"),p.style.setProperty(\"position\",\"fixed\",\"important\"),p.style.setProperty(\"top\",\"0\",\"important\"),p.style.setProperty(\"left\",\"0\",\"important\"),p.style.setProperty(\"box-sizing\",\"content-box\",\"important\"),p.style.setProperty(\"padding\",s+\"px\",\"important\"),p.style.setProperty(\"background\",\"rgb(128, 128, 128)\",\"important\"),p.style.setProperty(\"z-index\",\"2147483647\",\"important\");for(var l,y=0;y<o.length;y+=l){for(l=1;o[y]===o[y+l];)++l;var m=o[y],d=document.createElement(\"div\");d.style.setProperty(\"display\",\"block\",\"important\"),d.style.setProperty(\"float\",\"left\",\"important\"),d.style.setProperty(\"width\",l*i+\"px\",\"important\"),d.style.setProperty(\"height\",i+\"px\",\"important\"),d.style.setProperty(\"background\",a[m],\"important\"),p.appendChild(d)}var u={value:\"none\",important:!0},c=t([document.documentElement,{transform:u,\"-webkit-transform\":u}]),f=t([document.body,{transform:u,\"-webkit-transform\":u}]);return document.documentElement.setAttribute(\"data-applitools-original-transforms\",JSON.stringify(c)),document.body.setAttribute(\"data-applitools-original-transforms\",JSON.stringify(f)),document.body.appendChild(p),{mask:o,size:i,offset:s}}}();\nreturn s(arg)}",
4
4
  "blurElement": "function(arg){var s=function(){\"use strict\";return function(t){var n=(void 0===t?[]:t)[0]||document.activeElement;return n&&n.blur(),n}}();\nreturn s(arg)}",
5
5
  "cleanupElementIds": "function(arg){var s=function(){\"use strict\";return function(t){t[0].forEach((function(t){if(t.removeAttribute(\"data-applitools-selector\"),t.getRootNode)for(var o=t.getRootNode();o!==document;o=o.host.getRootNode())o.host.removeAttribute(\"data-applitools-selector\")}))}}();\nreturn s(arg)}",
6
6
  "cleanupPageMarker": "function(arg){var s=function(){\"use strict\";var t=function(t){var e=void 0===t?[]:t,r=e[0],o=e[1],n=Object.keys(o).sort(),a=n.reduce((function(t,e){return t[e]={value:r.style.getPropertyValue(e),important:Boolean(r.style.getPropertyPriority(e))},t}),{});return n.forEach((function(t){r.style.setProperty(t,\"string\"!=typeof o[t]&&o[t]?o[t].value:o[t],o[t]&&o[t].important?\"important\":\"\")})),a};return function(){var e=document.querySelector(\"[data-applitools-marker]\");e&&document.body.removeChild(e);var r=document.documentElement.getAttribute(\"data-applitools-original-transforms\"),o=document.body.getAttribute(\"data-applitools-original-transforms\");r&&t([document.documentElement,JSON.parse(r)]),o&&t([document.body,JSON.parse(o)])}}();\nreturn s(arg)}",
@@ -21,7 +21,8 @@
21
21
  "getPixelRatio": "function(arg){var s=function(){\"use strict\";return function(){return window.devicePixelRatio}}();\nreturn s(arg)}",
22
22
  "getShadowRoot": "function(arg){var s=function(){\"use strict\";return function(t){return(void 0===t?[]:t)[0].shadowRoot}}();\nreturn s(arg)}",
23
23
  "getUserAgent": "function(arg){var s=function(){\"use strict\";return function(){return window.navigator.userAgent}}();\nreturn s(arg)}",
24
- "getViewportSize": "function(arg){var s=function(){\"use strict\";return function(){var e=0,t=0;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),window.visualViewport&&(e=Math.round(e*window.visualViewport.scale),t=Math.round(t*window.visualViewport.scale)),{width:e,height:t}}}();\nreturn s(arg)}",
24
+ "getViewportScale": "function(arg){var s=function(){\"use strict\";return function(){return window.visualViewport&&window.visualViewport.scale}}();\nreturn s(arg)}",
25
+ "getViewportSize": "function(arg){var s=function(){\"use strict\";return function(){var e=0,t=0;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),{width:e,height:t}}}();\nreturn s(arg)}",
25
26
  "isElementScrollable": "function(arg){var s=function(){\"use strict\";return function(t){var i=(void 0===t?[]:t)[0];return i.scrollWidth>i.clientWidth||i.scrollHeight>i.clientHeight}}();\nreturn s(arg)}",
26
27
  "isEqualElements": "function(arg){var s=function(){\"use strict\";return function(r){var n=void 0===r?[]:r;return n[0]===n[1]}}();\nreturn s(arg)}",
27
28
  "scrollTo": "function(arg){var s=function(){\"use strict\";var t=function(t){var r=void 0===t?[]:t,o=r[0],e=r[1],l=Object.keys(e).sort(),n=l.reduce((function(t,r){return t[r]={value:o.style.getPropertyValue(r),important:Boolean(o.style.getPropertyPriority(r))},t}),{});return l.forEach((function(t){o.style.setProperty(t,\"string\"!=typeof e[t]&&e[t]?e[t].value:e[t],e[t]&&e[t].important?\"important\":\"\")})),n};return function(r){var o=void 0===r?[]:r,e=o[0],l=o[1];e=e||document.documentElement;var n=t([e,{\"scroll-behavior\":{value:\"auto\",important:!0}}]);return e.scrollTo?e.scrollTo(l.x,l.y):(e.scrollLeft=l.x,e.scrollTop=l.y),t([e,n]),{x:e.scrollLeft,y:e.scrollTop}}}();\nreturn s(arg)}",
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var s=function(){"use strict";return function(t){var o=t[0],e=t[1];return o.map(
3
3
  return s(arg)
4
4
  }
5
5
  exports.addPageMarker=function(arg){
6
- var s=function(){"use strict";var t=function(t){var e=void 0===t?[]:t,r=e[0],o=e[1],n=Object.keys(o).sort(),i=n.reduce((function(t,e){return t[e]={value:r.style.getPropertyValue(e),important:Boolean(r.style.getPropertyPriority(e))},t}),{});return n.forEach((function(t){r.style.setProperty(t,"string"!=typeof o[t]&&o[t]?o[t].value:o[t],o[t]&&o[t].important?"important":"")})),i};return function(){var e=[1,0,1,1,0,1,1,0,1,0,1,0,1,1,0,1,0,0,1,1,1],r={1:"rgb(0, 0, 0)",0:"rgb(255, 255, 255)"},o=visualViewport?visualViewport.scale:1,n=o>=1?1:2,i=n,a=document.createElement("div");a.setAttribute("data-applitools-marker",""),a.style.setProperty("position","fixed","important"),a.style.setProperty("top","0","important"),a.style.setProperty("left","0","important"),a.style.setProperty("box-sizing","content-box","important"),a.style.setProperty("padding",i/o+"px","important"),a.style.setProperty("background","rgb(128, 128, 128)","important"),a.style.setProperty("z-index","2147483647","important");for(var s,p=0;p<e.length;p+=s){for(s=1;e[p]===e[p+s];)++s;var l=e[p],y=document.createElement("div");y.style.setProperty("display","block","important"),y.style.setProperty("float","left","important"),y.style.setProperty("width",s*(n/o)+"px","important"),y.style.setProperty("height",n/o+"px","important"),y.style.setProperty("background",r[l],"important"),a.appendChild(y)}var m={value:"none",important:!0},d=t([document.documentElement,{transform:m,"-webkit-transform":m}]),u=t([document.body,{transform:m,"-webkit-transform":m}]);return document.documentElement.setAttribute("data-applitools-original-transforms",JSON.stringify(d)),document.body.setAttribute("data-applitools-original-transforms",JSON.stringify(u)),document.body.appendChild(a),{mask:e,size:n,offset:i}}}();
6
+ var s=function(){"use strict";var t=function(t){var e=void 0===t?[]:t,r=e[0],o=e[1],n=Object.keys(o).sort(),i=n.reduce((function(t,e){return t[e]={value:r.style.getPropertyValue(e),important:Boolean(r.style.getPropertyPriority(e))},t}),{});return n.forEach((function(t){r.style.setProperty(t,"string"!=typeof o[t]&&o[t]?o[t].value:o[t],o[t]&&o[t].important?"important":"")})),i};return function(e){var r=e[0],o=r.mask,n=r.size,i=void 0===n?1:n,a={1:"rgb(0, 0, 0)",0:"rgb(255, 255, 255)"},s=i,p=document.createElement("div");p.setAttribute("data-applitools-marker",""),p.style.setProperty("position","fixed","important"),p.style.setProperty("top","0","important"),p.style.setProperty("left","0","important"),p.style.setProperty("box-sizing","content-box","important"),p.style.setProperty("padding",s+"px","important"),p.style.setProperty("background","rgb(128, 128, 128)","important"),p.style.setProperty("z-index","2147483647","important");for(var l,y=0;y<o.length;y+=l){for(l=1;o[y]===o[y+l];)++l;var m=o[y],d=document.createElement("div");d.style.setProperty("display","block","important"),d.style.setProperty("float","left","important"),d.style.setProperty("width",l*i+"px","important"),d.style.setProperty("height",i+"px","important"),d.style.setProperty("background",a[m],"important"),p.appendChild(d)}var u={value:"none",important:!0},c=t([document.documentElement,{transform:u,"-webkit-transform":u}]),f=t([document.body,{transform:u,"-webkit-transform":u}]);return document.documentElement.setAttribute("data-applitools-original-transforms",JSON.stringify(c)),document.body.setAttribute("data-applitools-original-transforms",JSON.stringify(f)),document.body.appendChild(p),{mask:o,size:i,offset:s}}}();
7
7
  return s(arg)
8
8
  }
9
9
  exports.blurElement=function(arg){
@@ -86,8 +86,12 @@ exports.getUserAgent=function(arg){
86
86
  var s=function(){"use strict";return function(){return window.navigator.userAgent}}();
87
87
  return s(arg)
88
88
  }
89
+ exports.getViewportScale=function(arg){
90
+ var s=function(){"use strict";return function(){return window.visualViewport&&window.visualViewport.scale}}();
91
+ return s(arg)
92
+ }
89
93
  exports.getViewportSize=function(arg){
90
- var s=function(){"use strict";return function(){var e=0,t=0;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),window.visualViewport&&(e=Math.round(e*window.visualViewport.scale),t=Math.round(t*window.visualViewport.scale)),{width:e,height:t}}}();
94
+ var s=function(){"use strict";return function(){var e=0,t=0;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),{width:e,height:t}}}();
91
95
  return s(arg)
92
96
  }
93
97
  exports.isElementScrollable=function(arg){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/snippets",
3
- "version": "2.1.12",
3
+ "version": "2.1.13",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "main": "./dist/index.js",
6
6
  "files": [