Comparing version 2.4.1 to 2.5.0
@@ -8,3 +8,3 @@ /* globals document, ImageData */ | ||
exports.createCanvas = function (width, height) { | ||
return Object.assign(document.createElement('canvas'), { width, height }) | ||
return Object.assign(document.createElement('canvas'), { width: width, height: height }) | ||
} | ||
@@ -22,5 +22,5 @@ | ||
exports.loadImage = function (src) { | ||
return new Promise((resolve, reject) => { | ||
const image = document.createElement('img') | ||
exports.loadImage = function (src, options) { | ||
return new Promise(function (resolve, reject) { | ||
const image = Object.assign(document.createElement('img'), options) | ||
@@ -32,4 +32,4 @@ function cleanup () { | ||
image.onload = () => { cleanup(); resolve(image) } | ||
image.onerror = () => { cleanup(); reject(new Error(`Failed to load the image "${src}"`)) } | ||
image.onload = function () { cleanup(); resolve(image) } | ||
image.onerror = function () { cleanup(); reject(new Error('Failed to load the image "' + src + '"')) } | ||
@@ -36,0 +36,0 @@ image.src = src |
@@ -14,2 +14,10 @@ # Changelog | ||
2.5.0 | ||
================== | ||
### Added | ||
* Support redirects when fetching images (using [simple-get](https://github.com/feross/simple-get)) (#1398) | ||
* Support Node.js v12 | ||
### Fixed | ||
* Fix object literal & arrow function syntax usage for IE. | ||
2.4.1 | ||
@@ -16,0 +24,0 @@ ================== |
@@ -15,6 +15,7 @@ 'use strict'; | ||
const Image = module.exports = bindings.Image | ||
const http = require("http") | ||
const https = require("https") | ||
const util = require('util') | ||
// Lazily loaded simple-get | ||
let get; | ||
const {GetSource, SetSource} = bindings; | ||
@@ -50,13 +51,13 @@ | ||
const type = /^\s*https:\/\//.test(val) ? https : http | ||
type.get(val, res => { | ||
if (res.statusCode !== 200) { | ||
if (!get) get = require('simple-get'); | ||
get.concat(val, (err, res, data) => { | ||
if (err) return onerror(err) | ||
if (res.statusCode < 200 || res.statusCode >= 300) { | ||
return onerror(new Error(`Server responded with ${res.statusCode}`)) | ||
} | ||
const buffers = [] | ||
res.on('data', buffer => buffers.push(buffer)) | ||
res.on('end', () => { | ||
setSource(this, Buffer.concat(buffers)); | ||
}) | ||
}).on('error', onerror) | ||
setSource(this, data) | ||
}) | ||
} else { // local file path assumed | ||
@@ -63,0 +64,0 @@ setSource(this, val); |
@@ -17,6 +17,6 @@ 'use strict' | ||
// https://drafts.csswg.org/css-fonts-3/#font-prop | ||
const weightRe = new RegExp(`(${weights}) +`, 'i') | ||
const styleRe = new RegExp(`(${styles}) +`, 'i') | ||
const variantRe = new RegExp(`(${variants}) +`, 'i') | ||
const stretchRe = new RegExp(`(${stretches}) +`, 'i') | ||
const weightRe = new RegExp('(' + weights + ') +', 'i') | ||
const styleRe = new RegExp('(' + styles + ') +', 'i') | ||
const variantRe = new RegExp('(' + variants + ') +', 'i') | ||
const stretchRe = new RegExp('(' + stretches + ') +', 'i') | ||
const sizeFamilyRe = new RegExp( | ||
@@ -23,0 +23,0 @@ '([\\d\\.]+)(' + units + ') *' |
{ | ||
"name": "canvas", | ||
"description": "Canvas graphics API backed by Cairo", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"author": "TJ Holowaychuk <tj@learnboost.com>", | ||
@@ -51,4 +51,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"nan": "^2.12.1", | ||
"node-pre-gyp": "^0.11.0" | ||
"nan": "^2.13.2", | ||
"node-pre-gyp": "^0.11.0", | ||
"simple-get": "^3.0.3" | ||
}, | ||
@@ -55,0 +56,0 @@ "devDependencies": { |
@@ -297,3 +297,3 @@ // TypeScript Version: 3.0 | ||
*/ | ||
export function loadImage(src: string|Buffer): Promise<Image> | ||
export function loadImage(src: string|Buffer, options?: any): Promise<Image> | ||
@@ -300,0 +300,0 @@ /** |
@@ -14,3 +14,4 @@ var query = process.argv[2] | ||
'/usr/lib/arm-linux-gnueabihf', | ||
'/usr/lib/arm-linux-gnueabi' | ||
'/usr/lib/arm-linux-gnueabi', | ||
'/usr/lib/aarch64-linux-gnu' | ||
] | ||
@@ -17,0 +18,0 @@ |
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
360622
2
3
1348
+ Addedsimple-get@^3.0.3
+ Addeddecompress-response@4.2.1(transitive)
+ Addedmimic-response@2.1.0(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@3.1.1(transitive)
Updatednan@^2.13.2