Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@percy/agent

Package Overview
Dependencies
Maintainers
6
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@percy/agent - npm Package Compare versions

Comparing version 0.28.0 to 0.28.1

2

.oclif.manifest.json

@@ -1,1 +0,1 @@

{"version":"0.28.0","commands":{"exec":{"id":"exec","description":"Start and stop Percy around a supplied command.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy exec -- echo \"percy is running around this echo command\"","$ percy exec -- bash -c \"echo foo && echo bar\""],"flags":{"allowed-hostname":{"name":"allowed-hostname","type":"option","char":"h","description":"Allowable hostname(s) to capture assets from"},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"[default: 125] Asset discovery network idle timeout (in milliseconds)"},"cache-responses":{"name":"cache-responses","type":"boolean","description":"[default: true] Caches successful network responses in asset discovery","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port"},"config":{"name":"config","type":"option","char":"c","description":"Path to percy config file"}},"args":[]},"finalize":{"id":"finalize","description":"Finalize a build. Commonly used for parallelized builds, especially when the number of parallelized processes is unknown.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy finalize --all\n[percy] Finalized parallel build."],"flags":{"all":{"name":"all","type":"boolean","char":"a","required":true,"allowNo":false}},"args":[]},"health-check":{"id":"health-check","description":"Determines if the Percy Agent process is currently running","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"examples":["$ percy healthcheck","$ percy healthcheck --port 6884"],"flags":{"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port","default":5338}},"args":[]},"percy-command":{"id":"percy-command","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"snapshot":{"id":"snapshot","description":"Snapshot a directory containing a pre-built static website.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy snapshot _site/","$ percy snapshot _site/ --base-url \"/blog/\"","$ percy snapshot _site/ --ignore-files \"/blog/drafts/**\""],"flags":{"snapshot-files":{"name":"snapshot-files","type":"option","char":"s","description":"[default: **/*.html,**/*.htm] Glob or comma-seperated string of globs for matching the files and directories to snapshot."},"ignore-files":{"name":"ignore-files","type":"option","char":"i","description":"[default: ] Glob or comma-seperated string of globs for matching the files and directories to ignore."},"base-url":{"name":"base-url","type":"option","char":"b","description":"[default: /] If your static files will be hosted in a subdirectory, instead of the webserver's root path, set that subdirectory with this flag."},"dry-run":{"name":"dry-run","type":"boolean","char":"d","description":"Print the list of paths to snapshot without creating a new build","allowNo":false},"allowed-hostname":{"name":"allowed-hostname","type":"option","char":"h","description":"Allowable hostname(s) to capture assets from"},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"[default: 125] Asset discovery network idle timeout (in milliseconds)"},"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port"},"config":{"name":"config","type":"option","char":"c","description":"Path to percy config file"}},"args":[{"name":"snapshotDirectory","description":"[default: .] A path to the directory you would like to snapshot"}]},"start":{"id":"start","description":"Starts the percy process.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy start\ninfo: percy has started on port 5338."],"flags":{"detached":{"name":"detached","type":"boolean","char":"d","description":"start as a detached process","allowNo":false},"allowed-hostname":{"name":"allowed-hostname","type":"option","char":"h","description":"Allowable hostname(s) to capture assets from"},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"[default: 125] Asset discovery network idle timeout (in milliseconds)"},"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port"},"config":{"name":"config","type":"option","char":"c","description":"Path to percy config file"}},"args":[]},"stop":{"id":"stop","description":"Stops the percy process.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy stop\ninfo: percy has stopped."],"flags":{"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port"}},"args":[]},"upload":{"id":"upload","description":"Upload a directory containing static snapshot images.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy upload _images/","$ percy upload _images/ --files **/*.png"],"flags":{"files":{"name":"files","type":"option","char":"f","description":"[default: **/*.png,**/*.jpg,**/*.jpeg] Glob or comma-seperated string of globs for matching the files and directories to snapshot."},"ignore":{"name":"ignore","type":"option","char":"i","description":"[default: ] Glob or comma-seperated string of globs for matching the files and directories to ignore."},"dry-run":{"name":"dry-run","type":"boolean","char":"d","description":"Print the list of images to upload without uploading them","allowNo":false},"config":{"name":"config","type":"option","char":"c","description":"Path to percy config file"}},"args":[{"name":"uploadDirectory","description":"[default: .] A path to the directory containing static snapshot images"}]}}}
{"version":"0.28.1","commands":{"exec":{"id":"exec","description":"Start and stop Percy around a supplied command.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy exec -- echo \"percy is running around this echo command\"","$ percy exec -- bash -c \"echo foo && echo bar\""],"flags":{"allowed-hostname":{"name":"allowed-hostname","type":"option","char":"h","description":"Allowable hostname(s) to capture assets from"},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"[default: 125] Asset discovery network idle timeout (in milliseconds)"},"cache-responses":{"name":"cache-responses","type":"boolean","description":"[default: true] Caches successful network responses in asset discovery","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port"},"config":{"name":"config","type":"option","char":"c","description":"Path to percy config file"}},"args":[]},"finalize":{"id":"finalize","description":"Finalize a build. Commonly used for parallelized builds, especially when the number of parallelized processes is unknown.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy finalize --all\n[percy] Finalized parallel build."],"flags":{"all":{"name":"all","type":"boolean","char":"a","required":true,"allowNo":false}},"args":[]},"health-check":{"id":"health-check","description":"Determines if the Percy Agent process is currently running","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"examples":["$ percy healthcheck","$ percy healthcheck --port 6884"],"flags":{"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port","default":5338}},"args":[]},"percy-command":{"id":"percy-command","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"snapshot":{"id":"snapshot","description":"Snapshot a directory containing a pre-built static website.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy snapshot _site/","$ percy snapshot _site/ --base-url \"/blog/\"","$ percy snapshot _site/ --ignore-files \"/blog/drafts/**\""],"flags":{"snapshot-files":{"name":"snapshot-files","type":"option","char":"s","description":"[default: **/*.html,**/*.htm] Glob or comma-seperated string of globs for matching the files and directories to snapshot."},"ignore-files":{"name":"ignore-files","type":"option","char":"i","description":"[default: ] Glob or comma-seperated string of globs for matching the files and directories to ignore."},"base-url":{"name":"base-url","type":"option","char":"b","description":"[default: /] If your static files will be hosted in a subdirectory, instead of the webserver's root path, set that subdirectory with this flag."},"dry-run":{"name":"dry-run","type":"boolean","char":"d","description":"Print the list of paths to snapshot without creating a new build","allowNo":false},"allowed-hostname":{"name":"allowed-hostname","type":"option","char":"h","description":"Allowable hostname(s) to capture assets from"},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"[default: 125] Asset discovery network idle timeout (in milliseconds)"},"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port"},"config":{"name":"config","type":"option","char":"c","description":"Path to percy config file"}},"args":[{"name":"snapshotDirectory","description":"[default: .] A path to the directory you would like to snapshot"}]},"start":{"id":"start","description":"Starts the percy process.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy start\ninfo: percy has started on port 5338."],"flags":{"detached":{"name":"detached","type":"boolean","char":"d","description":"start as a detached process","allowNo":false},"allowed-hostname":{"name":"allowed-hostname","type":"option","char":"h","description":"Allowable hostname(s) to capture assets from"},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"[default: 125] Asset discovery network idle timeout (in milliseconds)"},"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port"},"config":{"name":"config","type":"option","char":"c","description":"Path to percy config file"}},"args":[]},"stop":{"id":"stop","description":"Stops the percy process.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy stop\ninfo: percy has stopped."],"flags":{"port":{"name":"port","type":"option","char":"p","description":"[default: 5338] Port"}},"args":[]},"upload":{"id":"upload","description":"Upload a directory containing static snapshot images.","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy upload _images/","$ percy upload _images/ --files **/*.png"],"flags":{"files":{"name":"files","type":"option","char":"f","description":"[default: **/*.png,**/*.jpg,**/*.jpeg] Glob or comma-seperated string of globs for matching the files and directories to snapshot."},"ignore":{"name":"ignore","type":"option","char":"i","description":"[default: ] Glob or comma-seperated string of globs for matching the files and directories to ignore."},"dry-run":{"name":"dry-run","type":"boolean","char":"d","description":"Print the list of images to upload without uploading them","allowNo":false},"config":{"name":"config","type":"option","char":"c","description":"Path to percy config file"}},"args":[{"name":"uploadDirectory","description":"[default: .] A path to the directory containing static snapshot images"}]}}}

@@ -165,2 +165,4 @@ "use strict";

}
// Remove any lazy loading attributes, since they hang asset discovery
cloned.removeAttribute('loading');
}

@@ -167,0 +169,0 @@ }

@@ -1,1 +0,1 @@

window.PercyAgent=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r=5338;function i(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||a(e)||function(){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 o(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=a(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return c=e.done,e},e:function(e){s=!0,o=e},f:function(){try{c||null==n.return||n.return()}finally{if(s)throw o}}}}function a(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var u=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,"originalDOM",void 0),l(this,"clonedDOM",void 0),l(this,"options",void 0),l(this,"defaultDoctype","<!DOCTYPE html>"),this.originalDOM=t,this.options=n||{},this.clonedDOM=this.cloneDOM()}var t,n,r;return t=e,(n=[{key:"snapshotString",value:function(){var e=this.clonedDOM,t=this.getDoctype();if(this.options.domTransformation)try{e=this.options.domTransformation(e)}catch(e){console.error("Could not transform the dom: ",e.toString())}return t+e.outerHTML}},{key:"getDoctype",value:function(){return this.clonedDOM.doctype?this.doctypeToString(this.clonedDOM.doctype):this.defaultDoctype}},{key:"doctypeToString",value:function(e){var t=e.publicId?' PUBLIC "'.concat(e.publicId,'" '):"",n=e.systemId?' SYSTEM "'.concat(e.systemId,'" '):"";return"<!DOCTYPE ".concat(e.name)+t+n+">"}},{key:"cloneDOM",value:function(){this.mutateOriginalDOM();var e=this.originalDOM.cloneNode(!0);return e=this.stabilizeDOM(e)}},{key:"stabilizeDOM",value:function(e){return this.serializeInputElements(e),this.serializeFrameElements(e),this.options.enableJavaScript||(this.serializeCSSOM(e),this.serializeCanvasElements(e)),e.documentElement}},{key:"serializeInputElements",value:function(e){var t=this.originalDOM.querySelectorAll("input, textarea, select");Array.from(t).forEach(function(t){var n=t.getAttribute("data-percy-element-id"),r='[data-percy-element-id="'.concat(n,'"]'),i=e.querySelector(r);switch(t.type){case"checkbox":case"radio":t.checked&&i.setAttribute("checked","");break;case"select-one":-1!==t.selectedIndex&&i.options[t.selectedIndex].setAttribute("selected","true");break;case"select-multiple":var o=Array.from(t.selectedOptions),a=Array.from(i.options);o.length&&o.forEach(function(e){a.find(function(t){return e.text===t.text}).setAttribute("selected","true")});break;case"textarea":i.innerHTML=t.value;break;default:i.setAttribute("value",t.value)}})}},{key:"serializeFrameElements",value:function(t){var n,r=this.options.enableJavaScript,i=o(this.originalDOM.querySelectorAll("iframe"));try{for(i.s();!(n=i.n()).done;){var a=n.value,c=a.getAttribute("data-percy-element-id"),s=t.querySelector('[data-percy-element-id="'.concat(c,'"]')),l=!(a.srcdoc||a.src&&"javascript"!==a.src.split(":")[0]);if(t.head.contains(s))s.remove();else if(a.contentDocument){if(r&&l)continue;if(!l&&!a.contentWindow.performance.timing.loadEventEnd)continue;var u=new e(a.contentDocument,this.options);s.setAttribute("srcdoc",u.snapshotString()),s.removeAttribute("src")}else!r&&l&&s.remove()}}catch(e){i.e(e)}finally{i.f()}}},{key:"serializeCSSOM",value:function(e){Array.from(this.originalDOM.styleSheets).forEach(function(t){if(i=t.href,o=t.ownerNode,a=o.innerText&&o.innerText.trim(),c=!!a&&a.length>0,!i&&!c&&t.cssRules){var n=e.createElement("style"),r=Array.from(t.cssRules).reduce(function(e,t){return e+t.cssText},"");n.type="text/css",n.setAttribute("data-percy-cssom-serialized","true"),n.innerHTML=r,e.head.appendChild(n)}var i,o,a,c})}},{key:"serializeCanvasElements",value:function(e){var t,n=o(this.originalDOM.querySelectorAll("canvas"));try{for(n.s();!(t=n.n()).done;){var r=t.value,i=e.createElement("img"),a=r.getAttribute("data-percy-element-id"),c=e.querySelector("[data-percy-element-id=".concat(a,"]"));i.setAttribute("style","max-width: 100%"),i.classList.add("percy-canvas-image"),i.src=r.toDataURL(),i.setAttribute("data-percy-canvas-serialized","true"),c.parentElement.insertBefore(i,c),c.remove()}}catch(e){n.e(e)}finally{n.f()}}},{key:"mutateOriginalDOM",value:function(){var e=this.originalDOM.querySelectorAll("input, textarea, select"),t=this.originalDOM.querySelectorAll("iframe"),n=this.originalDOM.querySelectorAll("canvas");[].concat(i(e),i(t),i(n)).forEach(function(e){e.getAttribute("data-percy-element-id")||e.setAttribute("data-percy-element-id","_".concat(Math.random().toString(36).substr(2,9)))})}}])&&s(t.prototype,n),r&&s(t,r),e}();function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),h(this,"xhr",void 0),h(this,"agentHost",void 0),h(this,"agentConnected",!1),this.agentHost=t,this.xhr=new n||new XMLHttpRequest,this.healthCheck()}var t,n,r;return t=e,(n=[{key:"post",value:function(e,t){this.agentConnected?(this.xhr.open("post","".concat(this.agentHost).concat(e),!1),this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(JSON.stringify(t))):console.warn("percy agent not started.")}},{key:"healthCheck",value:function(){var e=this;try{this.xhr.open("get","".concat(this.agentHost).concat("/percy/healthcheck"),!1),this.xhr.onload=function(){200===e.xhr.status&&(e.agentConnected=!0)},this.xhr.send()}catch(e){this.agentConnected=!1}}}])&&f(t.prototype,n),r&&f(t,r),e}();function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach(function(t){v(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var b=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),v(this,"clientInfo",void 0),v(this,"environmentInfo",void 0),v(this,"xhr",void 0),v(this,"handleAgentCommunication",void 0),v(this,"port",void 0),v(this,"domTransformation",void 0),v(this,"client",null),this.clientInfo=t.clientInfo||null,this.environmentInfo=t.environmentInfo||null,this.handleAgentCommunication=!1!==t.handleAgentCommunication,this.domTransformation=t.domTransformation||null,this.port=t.port||r,this.handleAgentCommunication&&(this.xhr=t.xhr||XMLHttpRequest,this.client=new d("http://localhost:".concat(this.port),this.xhr))}var t,n,i;return t=e,(n=[{key:"snapshot",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.document||document,r=this.domSnapshot(n,t);return this.handleAgentCommunication&&this.client&&this.client.post("/percy/snapshot",{name:e,url:n.URL,percyCSS:t.percyCSS,enableJavaScript:t.enableJavaScript||t.enableJavascript,widths:t.widths,minHeight:t.minHeight||t.minimumHeight,clientInfo:this.clientInfo,environmentInfo:this.environmentInfo,domSnapshot:r}),r}},{key:"domSnapshot",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new u(e,y({},t,{domTransformation:this.domTransformation}));return n.snapshotString()}}])&&m(t.prototype,n),i&&m(t,i),e}();t.default=b}]).default;
window.PercyAgent=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r=5338;function i(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||a(e)||function(){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 o(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=a(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return c=e.done,e},e:function(e){s=!0,o=e},f:function(){try{c||null==n.return||n.return()}finally{if(s)throw o}}}}function a(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var u=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,"originalDOM",void 0),l(this,"clonedDOM",void 0),l(this,"options",void 0),l(this,"defaultDoctype","<!DOCTYPE html>"),this.originalDOM=t,this.options=n||{},this.clonedDOM=this.cloneDOM()}var t,n,r;return t=e,(n=[{key:"snapshotString",value:function(){var e=this.clonedDOM,t=this.getDoctype();if(this.options.domTransformation)try{e=this.options.domTransformation(e)}catch(e){console.error("Could not transform the dom: ",e.toString())}return t+e.outerHTML}},{key:"getDoctype",value:function(){return this.clonedDOM.doctype?this.doctypeToString(this.clonedDOM.doctype):this.defaultDoctype}},{key:"doctypeToString",value:function(e){var t=e.publicId?' PUBLIC "'.concat(e.publicId,'" '):"",n=e.systemId?' SYSTEM "'.concat(e.systemId,'" '):"";return"<!DOCTYPE ".concat(e.name)+t+n+">"}},{key:"cloneDOM",value:function(){this.mutateOriginalDOM();var e=this.originalDOM.cloneNode(!0);return e=this.stabilizeDOM(e)}},{key:"stabilizeDOM",value:function(e){return this.serializeInputElements(e),this.serializeFrameElements(e),this.options.enableJavaScript||(this.serializeCSSOM(e),this.serializeCanvasElements(e)),e.documentElement}},{key:"serializeInputElements",value:function(e){var t=this.originalDOM.querySelectorAll("input, textarea, select");Array.from(t).forEach(function(t){var n=t.getAttribute("data-percy-element-id"),r='[data-percy-element-id="'.concat(n,'"]'),i=e.querySelector(r);switch(t.type){case"checkbox":case"radio":t.checked&&i.setAttribute("checked","");break;case"select-one":-1!==t.selectedIndex&&i.options[t.selectedIndex].setAttribute("selected","true");break;case"select-multiple":var o=Array.from(t.selectedOptions),a=Array.from(i.options);o.length&&o.forEach(function(e){a.find(function(t){return e.text===t.text}).setAttribute("selected","true")});break;case"textarea":i.innerHTML=t.value;break;default:i.setAttribute("value",t.value)}})}},{key:"serializeFrameElements",value:function(t){var n,r=this.options.enableJavaScript,i=o(this.originalDOM.querySelectorAll("iframe"));try{for(i.s();!(n=i.n()).done;){var a=n.value,c=a.getAttribute("data-percy-element-id"),s=t.querySelector('[data-percy-element-id="'.concat(c,'"]')),l=!(a.srcdoc||a.src&&"javascript"!==a.src.split(":")[0]);if(t.head.contains(s))s.remove();else if(a.contentDocument){if(r&&l)continue;if(!l&&!a.contentWindow.performance.timing.loadEventEnd)continue;var u=new e(a.contentDocument,this.options);s.setAttribute("srcdoc",u.snapshotString()),s.removeAttribute("src")}else!r&&l&&s.remove();s.removeAttribute("loading")}}catch(e){i.e(e)}finally{i.f()}}},{key:"serializeCSSOM",value:function(e){Array.from(this.originalDOM.styleSheets).forEach(function(t){if(i=t.href,o=t.ownerNode,a=o.innerText&&o.innerText.trim(),c=!!a&&a.length>0,!i&&!c&&t.cssRules){var n=e.createElement("style"),r=Array.from(t.cssRules).reduce(function(e,t){return e+t.cssText},"");n.type="text/css",n.setAttribute("data-percy-cssom-serialized","true"),n.innerHTML=r,e.head.appendChild(n)}var i,o,a,c})}},{key:"serializeCanvasElements",value:function(e){var t,n=o(this.originalDOM.querySelectorAll("canvas"));try{for(n.s();!(t=n.n()).done;){var r=t.value,i=e.createElement("img"),a=r.getAttribute("data-percy-element-id"),c=e.querySelector("[data-percy-element-id=".concat(a,"]"));i.setAttribute("style","max-width: 100%"),i.classList.add("percy-canvas-image"),i.src=r.toDataURL(),i.setAttribute("data-percy-canvas-serialized","true"),c.parentElement.insertBefore(i,c),c.remove()}}catch(e){n.e(e)}finally{n.f()}}},{key:"mutateOriginalDOM",value:function(){var e=this.originalDOM.querySelectorAll("input, textarea, select"),t=this.originalDOM.querySelectorAll("iframe"),n=this.originalDOM.querySelectorAll("canvas");[].concat(i(e),i(t),i(n)).forEach(function(e){e.getAttribute("data-percy-element-id")||e.setAttribute("data-percy-element-id","_".concat(Math.random().toString(36).substr(2,9)))})}}])&&s(t.prototype,n),r&&s(t,r),e}();function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),h(this,"xhr",void 0),h(this,"agentHost",void 0),h(this,"agentConnected",!1),this.agentHost=t,this.xhr=new n||new XMLHttpRequest,this.healthCheck()}var t,n,r;return t=e,(n=[{key:"post",value:function(e,t){this.agentConnected?(this.xhr.open("post","".concat(this.agentHost).concat(e),!1),this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(JSON.stringify(t))):console.warn("percy agent not started.")}},{key:"healthCheck",value:function(){var e=this;try{this.xhr.open("get","".concat(this.agentHost).concat("/percy/healthcheck"),!1),this.xhr.onload=function(){200===e.xhr.status&&(e.agentConnected=!0)},this.xhr.send()}catch(e){this.agentConnected=!1}}}])&&f(t.prototype,n),r&&f(t,r),e}();function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach(function(t){v(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var b=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),v(this,"clientInfo",void 0),v(this,"environmentInfo",void 0),v(this,"xhr",void 0),v(this,"handleAgentCommunication",void 0),v(this,"port",void 0),v(this,"domTransformation",void 0),v(this,"client",null),this.clientInfo=t.clientInfo||null,this.environmentInfo=t.environmentInfo||null,this.handleAgentCommunication=!1!==t.handleAgentCommunication,this.domTransformation=t.domTransformation||null,this.port=t.port||r,this.handleAgentCommunication&&(this.xhr=t.xhr||XMLHttpRequest,this.client=new d("http://localhost:".concat(this.port),this.xhr))}var t,n,i;return t=e,(n=[{key:"snapshot",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.document||document,r=this.domSnapshot(n,t);return this.handleAgentCommunication&&this.client&&this.client.post("/percy/snapshot",{name:e,url:n.URL,percyCSS:t.percyCSS,enableJavaScript:t.enableJavaScript||t.enableJavascript,widths:t.widths,minHeight:t.minHeight||t.minimumHeight,clientInfo:this.clientInfo,environmentInfo:this.environmentInfo,domSnapshot:r}),r}},{key:"domSnapshot",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new u(e,y({},t,{domTransformation:this.domTransformation}));return n.snapshotString()}}])&&m(t.prototype,n),i&&m(t,i),e}();t.default=b}]).default;
{
"name": "@percy/agent",
"description": "An agent process for integrating with Percy.",
"version": "0.28.0",
"version": "0.28.1",
"author": "Perceptual Inc",

@@ -6,0 +6,0 @@ "bin": {

@@ -24,3 +24,3 @@ @percy/agent

$ percy (-v|--version|version)
@percy/agent/0.28.0 darwin-x64 node-v12.18.0
@percy/agent/0.28.1 linux-x64 node-v12.18.3
$ percy --help [COMMAND]

@@ -64,3 +64,3 @@ USAGE

_See code: [dist/commands/exec.ts](https://github.com/percy/percy-agent/blob/v0.28.0/dist/commands/exec.ts)_
_See code: [dist/commands/exec.ts](https://github.com/percy/percy-agent/blob/v0.28.1/dist/commands/exec.ts)_

@@ -83,3 +83,3 @@ ## `percy finalize`

_See code: [dist/commands/finalize.ts](https://github.com/percy/percy-agent/blob/v0.28.0/dist/commands/finalize.ts)_
_See code: [dist/commands/finalize.ts](https://github.com/percy/percy-agent/blob/v0.28.1/dist/commands/finalize.ts)_

@@ -141,3 +141,3 @@ ## `percy help [COMMAND]`

_See code: [dist/commands/snapshot.ts](https://github.com/percy/percy-agent/blob/v0.28.0/dist/commands/snapshot.ts)_
_See code: [dist/commands/snapshot.ts](https://github.com/percy/percy-agent/blob/v0.28.1/dist/commands/snapshot.ts)_

@@ -164,3 +164,3 @@ ## `percy start`

_See code: [dist/commands/start.ts](https://github.com/percy/percy-agent/blob/v0.28.0/dist/commands/start.ts)_
_See code: [dist/commands/start.ts](https://github.com/percy/percy-agent/blob/v0.28.1/dist/commands/start.ts)_

@@ -183,3 +183,3 @@ ## `percy stop`

_See code: [dist/commands/stop.ts](https://github.com/percy/percy-agent/blob/v0.28.0/dist/commands/stop.ts)_
_See code: [dist/commands/stop.ts](https://github.com/percy/percy-agent/blob/v0.28.1/dist/commands/stop.ts)_

@@ -212,3 +212,3 @@ ## `percy upload [UPLOADDIRECTORY]`

_See code: [dist/commands/upload.ts](https://github.com/percy/percy-agent/blob/v0.28.0/dist/commands/upload.ts)_
_See code: [dist/commands/upload.ts](https://github.com/percy/percy-agent/blob/v0.28.1/dist/commands/upload.ts)_
<!-- commandsstop -->
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc