testcafe-browser-tools
Advanced tools
Comparing version 1.4.0 to 1.4.1-git.201708181130
@@ -28,2 +28,9 @@ 'use strict'; | ||
'chrome-canary': { | ||
nameRe: /chrome\s*canary/i, | ||
cmd: '--no-first-run --new-window', | ||
macOpenCmdTemplate: 'open -n -a "{{{path}}}" --args {{{pageUrl}}} {{{cmd}}}', | ||
linuxBinaries: ['google-chrome-canary'] | ||
}, | ||
'chrome': { | ||
@@ -33,3 +40,3 @@ nameRe: /chrome/i, | ||
macOpenCmdTemplate: 'open -n -a "{{{path}}}" --args {{{pageUrl}}} {{{cmd}}}', | ||
linuxBinaries: ['google-chrome', 'google-chrome-stable', 'google-chrome-canary'] | ||
linuxBinaries: ['google-chrome', 'google-chrome-stable', 'google-chrome-unstable'] | ||
}, | ||
@@ -36,0 +43,0 @@ |
'use strict'; | ||
var _Promise = require('babel-runtime/core-js/promise').default; | ||
var _regeneratorRuntime = require('babel-runtime/regenerator').default; | ||
@@ -13,11 +15,11 @@ | ||
var _utilsEnsureDirectory = require('../utils/ensure-directory'); | ||
var _fs = require('fs'); | ||
var _utilsEnsureDirectory2 = _interopRequireDefault(_utilsEnsureDirectory); | ||
var _fs2 = _interopRequireDefault(_fs); | ||
var _utilsExec = require('../utils/exec'); | ||
var _pngjs = require('pngjs'); | ||
var _binaries = require('../binaries'); | ||
var _utilsEnsureDirectory = require('../utils/ensure-directory'); | ||
var _binaries2 = _interopRequireDefault(_binaries); | ||
var _utilsEnsureDirectory2 = _interopRequireDefault(_utilsEnsureDirectory); | ||
@@ -27,2 +29,73 @@ var DEFAULT_THUMBNAIL_WIDTH = 240; | ||
function cubicInterpolation(t, t2, t3, f) { | ||
var C = [0 - 1 * t + 2 * t2 - 1 * t3, 2 + 0 * t - 5 * t2 + 3 * t3, 0 + 1 * t + 4 * t2 - 3 * t3, 0 + 0 * t - 1 * t2 + 1 * t3]; | ||
return 0.5 * (C[0] * f[0] + C[1] * f[1] + C[2] * f[2] + C[3] * f[3]); | ||
} | ||
function getSubpixel(img, y, x, channel) { | ||
if (y >= img.height || x >= img.width || y < 0 || x < 0) return 0; | ||
return img.data[y * img.width * 4 + x * 4 + channel]; | ||
} | ||
function setSubpixel(img, y, x, channel, color) { | ||
if (y >= img.height || x >= img.width || y < 0 || x < 0) return; | ||
if (color > 255) color = 255;else if (color < 0) color = 0; | ||
img.data[y * img.width * 4 + x * 4 + channel] = color; | ||
} | ||
function scale(src, width, height) { | ||
var dst = new _pngjs.PNG({ width: width, height: height }); | ||
var cx = src.width / width; | ||
var cy = src.height / height; | ||
var interpolated = [0, 0, 0, 0]; | ||
for (var i = 0; i < height; ++i) { | ||
var targetY = cy * i; | ||
var sourceY = Math.floor(targetY); | ||
var dy = targetY - sourceY; | ||
var dy2 = dy * dy; | ||
var dy3 = dy2 * dy; | ||
for (var j = 0; j < width; ++j) { | ||
var targetX = cx * j; | ||
var sourceX = Math.floor(targetX); | ||
var dx = targetX - sourceX; | ||
var dx2 = dx * dx; | ||
var dx3 = dx2 * dx; | ||
for (var k = 0; k < 3; ++k) { | ||
for (var ii = 0, interpolY = sourceY - 1; ii < 4; ++ii, ++interpolY) { | ||
var pixels = [getSubpixel(src, interpolY, sourceX - 1, k), getSubpixel(src, interpolY, sourceX, k), getSubpixel(src, interpolY, sourceX + 1, k), getSubpixel(src, interpolY, sourceX + 2, k)]; | ||
interpolated[ii] = cubicInterpolation(dx, dx2, dx3, pixels); | ||
} | ||
setSubpixel(dst, i, j, k, cubicInterpolation(dy, dy2, dy3, interpolated)); | ||
} | ||
setSubpixel(dst, i, j, 3, 255); | ||
} | ||
} | ||
return dst; | ||
} | ||
function generate(src, dst, width, height) { | ||
return new _Promise(function (resolve) { | ||
_fs2.default.createReadStream(src).pipe(new _pngjs.PNG()).on('parsed', function () { | ||
var dstImage = scale(this, width, height); | ||
dstImage.pack().pipe(_fs2.default.createWriteStream(dst)).on('end', resolve); | ||
}); | ||
}); | ||
} | ||
function getThumbnailPath(imagePath) { | ||
@@ -67,3 +140,3 @@ var imageName = _path2.default.basename(imagePath); | ||
context$2$0.next = 4; | ||
return _regeneratorRuntime.awrap(_utilsExec.execFile(_binaries2.default.generateThumbnail, [sourcePath, thumbnailPath, width, height])); | ||
return _regeneratorRuntime.awrap(generate(sourcePath, thumbnailPath, width, height)); | ||
@@ -70,0 +143,0 @@ case 4: |
{ | ||
"name": "testcafe-browser-tools", | ||
"version": "1.4.0", | ||
"version": "1.4.1-git.201708181130", | ||
"description": "An utility library for performing platform-dependent actions on browsers.", | ||
@@ -24,2 +24,3 @@ "homepage": "https://github.com/DevExpress/testcafe-browser-tools", | ||
"pinkie": "^2.0.1", | ||
"pngjs": "^3.3.0", | ||
"read-file-relative": "^1.2.0", | ||
@@ -26,0 +27,0 @@ "which-promise": "^1.0.0" |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1595848
1594
10
1
4
+ Addedpngjs@^3.3.0
+ Addedpngjs@3.4.0(transitive)