New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webdriver-image-comparison

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webdriver-image-comparison - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

30

build/methods/images.js

@@ -267,3 +267,5 @@ "use strict";

rawMisMatchPercentage = data.rawMisMatchPercentage;
reportMisMatchPercentage = imageCompareOptions.rawMisMatchPercentage ? rawMisMatchPercentage : data.misMatchPercentage;
reportMisMatchPercentage = imageCompareOptions.rawMisMatchPercentage
? rawMisMatchPercentage
: Number(data.rawMisMatchPercentage.toFixed(3));
if (!(rawMisMatchPercentage > imageCompareOptions.saveAboveTolerance || logLevel === options_interface_1.LogLevel.debug)) return [3, 6];

@@ -402,28 +404,2 @@ isDifference = rawMisMatchPercentage > imageCompareOptions.saveAboveTolerance;

}
function createDeviceBezelCorners(_a) {
var ctx = _a.ctx, x = _a.x, y = _a.y, width = _a.width, height = _a.height, radius = _a.radius;
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
function createNotch(_a) {
var ctx = _a.ctx, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
var radius = Math.round((height > width ? width : height) / 2);
createDeviceBezelCorners({
ctx: ctx,
x: x,
y: y,
width: width,
height: height,
radius: radius,
});
}
//# sourceMappingURL=images.js.map

147

build/resemble/resemble.js
var naiveFallback = function () {
if (typeof self === "object" && self) {
if (typeof self === 'object' && self) {
return self;
}
if (typeof window === "object" && window) {
if (typeof window === 'object' && window) {
return window;
}
throw new Error("Unable to resolve global `this`");
throw new Error('Unable to resolve global `this`');
};
var getGlobalThis = function () {
if (typeof globalThis === "object" && globalThis) {
if (typeof globalThis === 'object' && globalThis) {
return globalThis;
}
try {
Object.defineProperty(Object.prototype, "__global__", {
Object.defineProperty(Object.prototype, '__global__', {
get: function () {
return this;
},
configurable: true
configurable: true,
});

@@ -37,10 +37,10 @@ }

var globalPolyfill = getGlobalThis();
return typeof globalPolyfill.process !== "undefined" && globalPolyfill.process.versions && globalPolyfill.process.versions.node;
return typeof globalPolyfill.process !== 'undefined' && globalPolyfill.process.versions && globalPolyfill.process.versions.node;
};
(function (root, factory) {
"use strict";
if (typeof define === "function" && define.amd) {
'use strict';
if (typeof define === 'function' && define.amd) {
define([], factory);
}
else if (typeof module === "object" && module.exports) {
else if (typeof module === 'object' && module.exports) {
module.exports = factory();

@@ -52,3 +52,3 @@ }

})(this, function () {
"use strict";
'use strict';
var Img;

@@ -58,3 +58,3 @@ var Canvas;

if (isNode()) {
Canvas = require("canvas");
Canvas = require('canvas');
Img = Canvas.Image;

@@ -70,3 +70,3 @@ loadNodeCanvasImage = Canvas.loadImage;

}
var cnvs = document.createElement("canvas");
var cnvs = document.createElement('canvas');
cnvs.width = width;

@@ -84,3 +84,3 @@ cnvs.height = height;

blue: 255,
alpha: 255
alpha: 255,
};

@@ -119,3 +119,3 @@ var targetPix = { r: 0, g: 0, b: 0, a: 0 };

px[offset + 3] = d2.a;
}
},
};

@@ -138,3 +138,3 @@ var errorPixel = errorPixelTransform.flat;

minBrightness: 16,
maxBrightness: 240
maxBrightness: 240,
};

@@ -200,3 +200,3 @@ var ignoreAntialiasing = false;

for (i = 0; i < len; i++) {
if (typeof updateCallbackArray[i] === "function") {
if (typeof updateCallbackArray[i] === 'function') {
updateCallbackArray[i](data);

@@ -264,4 +264,4 @@ }

var imageData;
hiddenCanvas.getContext("2d").drawImage(hiddenImage, 0, 0, width, height);
imageData = hiddenCanvas.getContext("2d").getImageData(0, 0, width, height);
hiddenCanvas.getContext('2d').drawImage(hiddenImage, 0, 0, width, height);
imageData = hiddenCanvas.getContext('2d').getImageData(0, 0, width, height);
images.push(imageData);

@@ -274,12 +274,12 @@ callback(imageData, width, height);

if (!hiddenImage.setAttribute) {
hiddenImage.setAttribute = function setAttribute() {
};
hiddenImage.setAttribute = function setAttribute() { };
}
if (useCrossOrigin) {
hiddenImage.setAttribute("crossorigin", "anonymous");
hiddenImage.setAttribute('crossorigin', 'anonymous');
}
hiddenImage.onerror = function (err) {
hiddenImage.onerror = function (event) {
hiddenImage.onload = null;
hiddenImage.onerror = null;
images.push({ error: err ? err + "" : "Image load error." });
var error = event ? event + '' : 'Unknown error';
images.push({ error: "Failed to load image '".concat(fileDataForImage, "'. ").concat(error) });
callback();

@@ -292,3 +292,3 @@ };

};
if (typeof fileDataForImage === "string") {
if (typeof fileDataForImage === 'string') {
hiddenImage.src = fileDataForImage;

@@ -299,9 +299,9 @@ if (!isNode() && hiddenImage.complete && hiddenImage.naturalWidth > 0) {

}
else if (typeof fileDataForImage.data !== "undefined" &&
typeof fileDataForImage.width === "number" &&
typeof fileDataForImage.height === "number") {
else if (typeof fileDataForImage.data !== 'undefined' &&
typeof fileDataForImage.width === 'number' &&
typeof fileDataForImage.height === 'number') {
images.push(fileDataForImage);
callback(fileDataForImage, fileDataForImage.width, fileDataForImage.height);
}
else if (typeof Buffer !== "undefined" && fileDataForImage instanceof Buffer) {
else if (typeof Buffer !== 'undefined' && fileDataForImage instanceof Buffer) {
loadNodeCanvasImage(fileDataForImage)

@@ -315,3 +315,3 @@ .then(function (image) {

images.push({
error: err ? err + "" : "Image load error."
error: err ? err + '' : 'Image load error.',
});

@@ -331,6 +331,6 @@ callback();

var absDiff = Math.abs(a - b);
if (typeof a === "undefined") {
if (typeof a === 'undefined') {
return false;
}
if (typeof b === "undefined") {
if (typeof b === 'undefined') {
return false;

@@ -347,4 +347,4 @@ }

function isPixelBrightnessSimilar(d1, d2) {
var alpha = isColorSimilar(d1.a, d2.a, "alpha");
var brightness = isColorSimilar(d1.brightness, d2.brightness, "minBrightness");
var alpha = isColorSimilar(d1.a, d2.a, 'alpha');
var brightness = isColorSimilar(d1.brightness, d2.brightness, 'minBrightness');
return brightness && alpha;

@@ -362,6 +362,6 @@ }

function isRGBSimilar(d1, d2) {
var red = isColorSimilar(d1.r, d2.r, "red");
var green = isColorSimilar(d1.g, d2.g, "green");
var blue = isColorSimilar(d1.b, d2.b, "blue");
var alpha = isColorSimilar(d1.a, d2.a, "alpha");
var red = isColorSimilar(d1.r, d2.r, 'red');
var green = isColorSimilar(d1.g, d2.g, 'green');
var blue = isColorSimilar(d1.b, d2.b, 'blue');
var alpha = isColorSimilar(d1.a, d2.a, 'alpha');
return red && green && blue && alpha;

@@ -442,3 +442,3 @@ }

function copyPixel(px, offset, pix) {
if (errorType === "diffOnly") {
if (errorType === 'diffOnly') {
return;

@@ -452,3 +452,3 @@ }

function copyGrayScalePixel(px, offset, pix) {
if (errorType === "diffOnly") {
if (errorType === 'diffOnly') {
return;

@@ -486,3 +486,3 @@ }

hiddenCanvas = createCanvas(width, height);
context = hiddenCanvas.getContext("2d");
context = hiddenCanvas.getContext('2d');
imgd = context.createImageData(width, height);

@@ -496,3 +496,3 @@ pix = imgd.data;

bottom: 0,
right: 0
right: 0,
};

@@ -552,3 +552,4 @@ var updateBounds = function (x, y) {

addBrightnessInfo(pixel2),
isAntialiased(pixel1, data1, 1, verticalPos, horizontalPos, width) || isAntialiased(pixel2, data2, 2, verticalPos, horizontalPos, width))) {
isAntialiased(pixel1, data1, 1, verticalPos, horizontalPos, width) ||
isAntialiased(pixel2, data2, 2, verticalPos, horizontalPos, width))) {
if (isPixelBrightnessSimilar(pixel1, pixel2) || !isWithinComparedArea) {

@@ -587,3 +588,3 @@ if (!compareOnly) {

if (compareOnly) {
throw Error("No diff image available - ran in compareOnly mode");
throw Error('No diff image available - ran in compareOnly mode');
}

@@ -595,3 +596,3 @@ var barHeight = 0;

context.putImageData(imgd, 0, barHeight);
return hiddenCanvas.toDataURL("image/png");
return hiddenCanvas.toDataURL('image/png');
};

@@ -616,3 +617,3 @@ if (!compareOnly && hiddenCanvas.toBuffer) {

var textPadding = 2;
context.font = "12px sans-serif";
context.font = '12px sans-serif';
var textWidth = context.measureText(text).width + textPadding * 2;

@@ -624,9 +625,9 @@ var barHeight = 22;

hiddenCanvas.height += barHeight;
context.fillStyle = "#666";
context.fillStyle = '#666';
context.fillRect(0, 0, hiddenCanvas.width, barHeight - 4);
context.fillStyle = "#fff";
context.fillStyle = '#fff';
context.fillRect(0, barHeight - 4, hiddenCanvas.width, 4);
context.fillStyle = "#fff";
context.textBaseline = "top";
context.font = "12px sans-serif";
context.fillStyle = '#fff';
context.textBaseline = 'top';
context.font = '12px sans-serif';
context.fillText(text, textPadding, 1);

@@ -640,3 +641,3 @@ return barHeight;

c = createCanvas(w, h);
context = c.getContext("2d");
context = c.getContext('2d');
context.putImageData(img, 0, 0);

@@ -660,3 +661,3 @@ return context.getImageData(0, 0, w, h);

}
if (options.errorPixel && typeof options.errorPixel === "function") {
if (options.errorPixel && typeof options.errorPixel === 'function') {
errorPixel = options.errorPixel;

@@ -711,3 +712,3 @@ }

width: images[0].width - images[1].width,
height: images[0].height - images[1].height
height: images[0].height - images[1].height,
};

@@ -724,3 +725,3 @@ analyseImages(normalise(images[0], width, height), normalise(images[1], width, height), width, height);

var secondFileData;
var hasMethod = typeof param === "function";
var hasMethod = typeof param === 'function';
if (!hasMethod) {

@@ -835,3 +836,11 @@ secondFileData = param;

return getCompareApi(wrapper);
}
},
setupCustomTolerance: function (customSettings) {
for (var property in tolerance) {
if (!customSettings.hasOwnProperty(property)) {
continue;
}
tolerance[property] = customSettings[property];
}
},
};

@@ -853,3 +862,3 @@ return self;

return rootSelf;
}
},
};

@@ -862,22 +871,23 @@ return rootSelf;

}
function applyIgnore(api, ignore) {
function applyIgnore(api, ignore, customTolerance) {
switch (ignore) {
case "nothing":
case 'nothing':
api.ignoreNothing();
break;
case "less":
case 'less':
api.ignoreLess();
break;
case "antialiasing":
case 'antialiasing':
api.ignoreAntialiasing();
break;
case "colors":
case 'colors':
api.ignoreColors();
break;
case "alpha":
case 'alpha':
api.ignoreAlpha();
break;
default:
throw new Error("Invalid ignore: " + ignore);
throw new Error('Invalid ignore: ' + ignore);
}
api.setupCustomTolerance(customTolerance);
}

@@ -887,3 +897,3 @@ resemble.compare = function (image1, image2, options, cb) {

var opt;
if (typeof options === "function") {
if (typeof options === 'function') {
callback = options;

@@ -908,8 +918,9 @@ opt = {};

}
if (typeof opt.ignore === "string") {
applyIgnore(compare, opt.ignore);
var toleranceSettings = opt.tolerance || {};
if (typeof opt.ignore === 'string') {
applyIgnore(compare, opt.ignore, toleranceSettings);
}
else if (opt.ignore && opt.ignore.forEach) {
opt.ignore.forEach(function (v) {
applyIgnore(compare, v);
applyIgnore(compare, v, toleranceSettings);
});

@@ -916,0 +927,0 @@ }

{
"name": "webdriver-image-comparison",
"version": "1.0.1",
"version": "1.0.2",
"description": "An image compare module that can be used for different NodeJS Test automation frameworks that support the webdriver protocol",

@@ -5,0 +5,0 @@ "main": "./build/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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