@applitools/snippets 2.1.4 → 2.1.8

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,24 @@
4
4
  ## Unreleased
5
5
 
6
6
 
7
+ ## 2.1.8 - 2021/12/16
8
+
9
+ - fix `addPageMarker` to handle different pixel densities
10
+ - change shape and size of marker added by `addPageMarker`
11
+
12
+ ## 2.1.7 - 2021/9/9
13
+
14
+ - fix `getShadowRoot` to follow convention for arguments
15
+
16
+ ## 2.1.6 - 2021/9/6
17
+
18
+ - return array instead of object from `addElementIds`
19
+
20
+ ## 2.1.5 - 2021/9/6
21
+
22
+ - add `getShadowRoot` snippet
23
+ - replace `setElementMarkers` with `addElementIds` snippet, which will return a selector mapping
24
+
7
25
  ## 2.1.4 - 2021/8/4
8
26
 
9
27
  - add `isEqualElements` snippet
@@ -1,7 +1,8 @@
1
1
  {
2
- "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=document.createElement(\"div\"),r=document.createElement(\"div\");e.appendChild(r),document.body.appendChild(e),e.setAttribute(\"data-applitools-marker\",\"\"),e.style.setProperty(\"position\",\"fixed\",\"important\"),e.style.setProperty(\"top\",\"0\",\"important\"),e.style.setProperty(\"left\",\"0\",\"important\"),e.style.setProperty(\"width\",\"3px\",\"important\"),e.style.setProperty(\"height\",\"9px\",\"important\"),e.style.setProperty(\"box-sizing\",\"content-box\",\"important\"),e.style.setProperty(\"border\",\"1px solid rgb(127,127,127)\",\"important\"),e.style.setProperty(\"background\",\"rgb(0,0,0)\",\"important\"),e.style.setProperty(\"z-index\",\"999999999\",\"important\"),r.style.setProperty(\"width\",\"3px\",\"important\"),r.style.setProperty(\"height\",\"3px\",\"important\"),r.style.setProperty(\"margin\",\"3px 0\",\"important\"),r.style.setProperty(\"background\",\"rgb(255,255,255)\",\"important\");var o={value:\"none\",important:!0},n=t([document.documentElement,{transform:o,\"-webkit-transform\":o}]),i=t([document.body,{transform:o,\"-webkit-transform\":o}]);return document.documentElement.setAttribute(\"data-applitools-original-transforms\",JSON.stringify(n)),document.body.setAttribute(\"data-applitools-original-transforms\",JSON.stringify(i)),{offset:1*window.devicePixelRatio,size:3*window.devicePixelRatio,mask:[0,1,0]}}}();\nreturn s(arg)}",
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=Math.max(1,window.innerWidth/screen.availWidth),n=document.createElement(\"div\");n.setAttribute(\"data-applitools-marker\",\"\"),n.style.setProperty(\"position\",\"fixed\",\"important\"),n.style.setProperty(\"top\",\"0\",\"important\"),n.style.setProperty(\"left\",\"0\",\"important\"),n.style.setProperty(\"box-sizing\",\"content-box\",\"important\"),n.style.setProperty(\"padding\",\"1px\",\"important\"),n.style.setProperty(\"z-index\",\"2147483647\",\"important\"),e.forEach((function(t){var e=document.createElement(\"div\");e.style.setProperty(\"display\",\"block\",\"important\"),e.style.setProperty(\"float\",\"left\",\"important\"),e.style.setProperty(\"width\",o+\"px\",\"important\"),e.style.setProperty(\"height\",\"1px\",\"important\"),e.style.setProperty(\"background\",r[t],\"important\"),n.appendChild(e)}));var i={value:\"none\",important:!0},a=t([document.documentElement,{transform:i,\"-webkit-transform\":i}]),s=t([document.body,{transform:i,\"-webkit-transform\":i}]);return document.documentElement.setAttribute(\"data-applitools-original-transforms\",JSON.stringify(a)),document.body.setAttribute(\"data-applitools-original-transforms\",JSON.stringify(s)),document.body.appendChild(n),{mask:e,size:o,offset:1}}}();\nreturn s(arg)}",
3
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)}",
4
- "cleanupElementMarkers": "function(arg){var s=function(){\"use strict\";return function(t){t[0].forEach((function(t){return t.removeAttribute(\"data-applitools-marker\")}))}}();\nreturn s(arg)}",
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)}",
5
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)}",
6
7
  "focusElement": "function(arg){var s=function(){\"use strict\";return function(n){var r=(void 0===n?[]:n)[0];r&&r.focus()}}();\nreturn s(arg)}",
7
8
  "getChildFramesInfo": "function(arg){var s=function(){\"use strict\";return function(){var r=document.querySelectorAll(\"frame, iframe\");return Array.prototype.map.call(r,(function(r){return[r,!r.contentDocument,r.src]}))}}();\nreturn s(arg)}",
@@ -18,13 +19,13 @@
18
19
  "getElementTranslateOffset": "function(arg){var s=function(){\"use strict\";var r=function(r){var t=void 0===r?[]:r,e=t[0],n=t[1];return(void 0===n?[]:n).reduce((function(r,t){return r[t]={value:e.style.getPropertyValue(t),important:Boolean(e.style.getPropertyPriority(t))},r}),{})};return function(t){var e=(void 0===t?[]:t)[0],n=void 0===e?document.scrollingElement||document.documentElement:e,o=r([n,[\"transform\",\"-webkit-transform\"]]),u=Object.keys(o).reduce((function(r,t){var e=o[t].value;if(e){var n=e.match(/^translate\\s*\\(\\s*(\\-?[\\d, \\.]+)px\\s*(,\\s*(-?[\\d, \\.]+)px)?\\s*\\)/);if(n){var u=n[1],s=void 0!==n[3]?n[3]:0;r.push({x:Math.round(-parseFloat(u)),y:Math.round(-parseFloat(s))})}else r.push({x:0,y:0})}return r}),[]);if(!u.every((function(r){return u[0].x===r.x||u[0].y===r.y})))throw new Error(\"Got different css positions!\");return u[0]||{x:0,y:0}}}();\nreturn s(arg)}",
19
20
  "getElementXpath": "function(arg){var s=function(){\"use strict\";return function(r){var e=(void 0===r?[]:r)[0],t=\"\",n=e.ownerDocument;if(!n)return t;for(var a=e;a!==n;){var o=Array.prototype.filter.call(a.parentNode.childNodes,(function(r){return r.tagName===a.tagName})).indexOf(a);t=\"/\"+a.tagName+\"[\"+(o+1)+\"]\"+t,a=a.parentNode}return t}}();\nreturn s(arg)}",
20
21
  "getPixelRatio": "function(arg){var s=function(){\"use strict\";return function(){return window.devicePixelRatio}}();\nreturn s(arg)}",
22
+ "getShadowRoot": "function(arg){var s=function(){\"use strict\";return function(t){return(void 0===t?[]:t)[0].shadowRoot}}();\nreturn s(arg)}",
21
23
  "getUserAgent": "function(arg){var s=function(){\"use strict\";return function(){return window.navigator.userAgent}}();\nreturn s(arg)}",
22
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),{width:e,height:t}}}();\nreturn s(arg)}",
23
25
  "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)}",
24
26
  "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)}",
25
27
  "scrollTo": "function(arg){var s=function(){\"use strict\";return function(o){var l=void 0===o?[]:o,r=l[0],c=l[1];return(r=r||document.documentElement).scrollTo?r.scrollTo(c.x,c.y):(r.scrollLeft=c.x,r.scrollTop=c.y),{x:r.scrollLeft,y:r.scrollTop}}}();\nreturn s(arg)}",
26
28
  "setElementAttributes": "function(arg){var s=function(){\"use strict\";return function(t){var e=void 0===t?[]:t,r=e[0],u=e[1];return Object.keys(u).reduce((function(t,e){return t[e]=r.getAttribute(e),r.setAttribute(e,u[e]),t}),{})}}();\nreturn s(arg)}",
27
- "setElementMarkers": "function(arg){var s=function(){\"use strict\";return function(t){var r=t[0],a=t[1];r.forEach((function(t,r){var e=t.getAttribute(\"data-applitools-marker\");t.setAttribute(\"data-applitools-marker\",e?e+\" \"+a[r]:a[r])}))}}();\nreturn s(arg)}",
28
29
  "setElementStyleProperties": "function(arg){var s=function(){\"use strict\";return function(t){var r=void 0===t?[]:t,e=r[0],o=r[1],n=Object.keys(o).sort(),i=n.reduce((function(t,r){return t[r]={value:e.style.getPropertyValue(r),important:Boolean(e.style.getPropertyPriority(r))},t}),{});return n.forEach((function(t){e.style.setProperty(t,\"string\"!=typeof o[t]&&o[t]?o[t].value:o[t],o[t]&&o[t].important?\"important\":\"\")})),i}}();\nreturn s(arg)}",
29
30
  "translateTo": "function(arg){var s=function(){\"use strict\";var t=function(t){var r=void 0===t?[]:t,e=r[0],n=r[1],o=Object.keys(n).sort(),a=o.reduce((function(t,r){return t[r]={value:e.style.getPropertyValue(r),important:Boolean(e.style.getPropertyPriority(r))},t}),{});return o.forEach((function(t){e.style.setProperty(t,\"string\"!=typeof n[t]&&n[t]?n[t].value:n[t],n[t]&&n[t].important?\"important\":\"\")})),a};return function(r){var e=void 0===r?[]:r,n=e[0],o=e[1];n=n||document.documentElement;var a=\"translate(\"+-o.x+\"px, \"+-o.y+\"px)\";return t([n,{transform:{value:a},\"-webkit-transform\":{value:a}}]),o}}();\nreturn s(arg)}"
30
31
  }
package/dist/index.js CHANGED
@@ -1,13 +1,17 @@
1
+ exports.addElementIds=function(arg){
2
+ 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+'"]'}))}))}}();
3
+ return s(arg)
4
+ }
1
5
  exports.addPageMarker=function(arg){
2
- 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=document.createElement("div"),r=document.createElement("div");e.appendChild(r),document.body.appendChild(e),e.setAttribute("data-applitools-marker",""),e.style.setProperty("position","fixed","important"),e.style.setProperty("top","0","important"),e.style.setProperty("left","0","important"),e.style.setProperty("width","3px","important"),e.style.setProperty("height","9px","important"),e.style.setProperty("box-sizing","content-box","important"),e.style.setProperty("border","1px solid rgb(127,127,127)","important"),e.style.setProperty("background","rgb(0,0,0)","important"),e.style.setProperty("z-index","999999999","important"),r.style.setProperty("width","3px","important"),r.style.setProperty("height","3px","important"),r.style.setProperty("margin","3px 0","important"),r.style.setProperty("background","rgb(255,255,255)","important");var o={value:"none",important:!0},n=t([document.documentElement,{transform:o,"-webkit-transform":o}]),i=t([document.body,{transform:o,"-webkit-transform":o}]);return document.documentElement.setAttribute("data-applitools-original-transforms",JSON.stringify(n)),document.body.setAttribute("data-applitools-original-transforms",JSON.stringify(i)),{offset:1*window.devicePixelRatio,size:3*window.devicePixelRatio,mask:[0,1,0]}}}();
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=Math.max(1,window.innerWidth/screen.availWidth),n=document.createElement("div");n.setAttribute("data-applitools-marker",""),n.style.setProperty("position","fixed","important"),n.style.setProperty("top","0","important"),n.style.setProperty("left","0","important"),n.style.setProperty("box-sizing","content-box","important"),n.style.setProperty("padding","1px","important"),n.style.setProperty("z-index","2147483647","important"),e.forEach((function(t){var e=document.createElement("div");e.style.setProperty("display","block","important"),e.style.setProperty("float","left","important"),e.style.setProperty("width",o+"px","important"),e.style.setProperty("height","1px","important"),e.style.setProperty("background",r[t],"important"),n.appendChild(e)}));var i={value:"none",important:!0},a=t([document.documentElement,{transform:i,"-webkit-transform":i}]),s=t([document.body,{transform:i,"-webkit-transform":i}]);return document.documentElement.setAttribute("data-applitools-original-transforms",JSON.stringify(a)),document.body.setAttribute("data-applitools-original-transforms",JSON.stringify(s)),document.body.appendChild(n),{mask:e,size:o,offset:1}}}();
3
7
  return s(arg)
4
8
  }
5
9
  exports.blurElement=function(arg){
6
10
  var s=function(){"use strict";return function(t){var n=(void 0===t?[]:t)[0]||document.activeElement;return n&&n.blur(),n}}();
7
11
  return s(arg)
8
12
  }
9
- exports.cleanupElementMarkers=function(arg){
10
- var s=function(){"use strict";return function(t){t[0].forEach((function(t){return t.removeAttribute("data-applitools-marker")}))}}();
13
+ exports.cleanupElementIds=function(arg){
14
+ 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")}))}}();
11
15
  return s(arg)
12
16
  }
13
17
  exports.cleanupPageMarker=function(arg){
@@ -74,6 +78,10 @@ exports.getPixelRatio=function(arg){
74
78
  var s=function(){"use strict";return function(){return window.devicePixelRatio}}();
75
79
  return s(arg)
76
80
  }
81
+ exports.getShadowRoot=function(arg){
82
+ var s=function(){"use strict";return function(t){return(void 0===t?[]:t)[0].shadowRoot}}();
83
+ return s(arg)
84
+ }
77
85
  exports.getUserAgent=function(arg){
78
86
  var s=function(){"use strict";return function(){return window.navigator.userAgent}}();
79
87
  return s(arg)
@@ -98,10 +106,6 @@ exports.setElementAttributes=function(arg){
98
106
  var s=function(){"use strict";return function(t){var e=void 0===t?[]:t,r=e[0],u=e[1];return Object.keys(u).reduce((function(t,e){return t[e]=r.getAttribute(e),r.setAttribute(e,u[e]),t}),{})}}();
99
107
  return s(arg)
100
108
  }
101
- exports.setElementMarkers=function(arg){
102
- var s=function(){"use strict";return function(t){var r=t[0],a=t[1];r.forEach((function(t,r){var e=t.getAttribute("data-applitools-marker");t.setAttribute("data-applitools-marker",e?e+" "+a[r]:a[r])}))}}();
103
- return s(arg)
104
- }
105
109
  exports.setElementStyleProperties=function(arg){
106
110
  var s=function(){"use strict";return function(t){var r=void 0===t?[]:t,e=r[0],o=r[1],n=Object.keys(o).sort(),i=n.reduce((function(t,r){return t[r]={value:e.style.getPropertyValue(r),important:Boolean(e.style.getPropertyPriority(r))},t}),{});return n.forEach((function(t){e.style.setProperty(t,"string"!=typeof o[t]&&o[t]?o[t].value:o[t],o[t]&&o[t].important?"important":"")})),i}}();
107
111
  return s(arg)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/snippets",
3
- "version": "2.1.4",
3
+ "version": "2.1.8",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "main": "./dist/index.js",
6
6
  "files": [
@@ -24,6 +24,11 @@
24
24
  "pre-push": "yarn bongo lint"
25
25
  }
26
26
  },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/applitools/eyes.sdk.javascript1.git",
30
+ "directory": "packages/snippets"
31
+ },
27
32
  "dependencies": {},
28
33
  "devDependencies": {
29
34
  "@applitools/sdk-release-kit": "^0.3.3",
@@ -39,7 +44,7 @@
39
44
  "glob": "^7.1.6",
40
45
  "husky": "^4.3.7",
41
46
  "mocha": "^8.1.3",
42
- "playwright": "1.8.0",
47
+ "playwright": "1.16.3",
43
48
  "prettier": "1.19.0",
44
49
  "rollup": "^2.26.11",
45
50
  "rollup-plugin-terser": "^7.0.2",