Comparing version 2.11.2 to 3.0.0-rc1b
@@ -14,2 +14,5 @@ const Canvas = require('./lib/canvas') | ||
bindings.setDOMMatrix(DOMMatrix) | ||
bindings.setParseFont(parseFont) | ||
function createCanvas (width, height, type) { | ||
@@ -16,0 +19,0 @@ return new Canvas(width, height, type) |
@@ -7,2 +7,12 @@ 'use strict' | ||
Object.defineProperty(bindings.Canvas.prototype, Symbol.toStringTag, { | ||
value: 'HTMLCanvasElement', | ||
configurable: true | ||
}) | ||
Object.defineProperty(bindings.Image.prototype, Symbol.toStringTag, { | ||
value: 'HTMLImageElement', | ||
configurable: true | ||
}) | ||
bindings.ImageData.prototype.toString = function () { | ||
@@ -12,4 +22,24 @@ return '[object ImageData]' | ||
Object.defineProperty(bindings.ImageData.prototype, Symbol.toStringTag, { | ||
value: 'ImageData', | ||
configurable: true | ||
}) | ||
bindings.CanvasGradient.prototype.toString = function () { | ||
return '[object CanvasGradient]' | ||
} | ||
Object.defineProperty(bindings.CanvasGradient.prototype, Symbol.toStringTag, { | ||
value: 'CanvasGradient', | ||
configurable: true | ||
}) | ||
Object.defineProperty(bindings.CanvasPattern.prototype, Symbol.toStringTag, { | ||
value: 'CanvasPattern', | ||
configurable: true | ||
}) | ||
Object.defineProperty(bindings.CanvasRenderingContext2d.prototype, Symbol.toStringTag, { | ||
value: 'CanvasRenderingContext2d', | ||
configurable: true | ||
}) |
@@ -10,6 +10,3 @@ 'use strict' | ||
const bindings = require('./bindings') | ||
const parseFont = require('./parse-font') | ||
const { DOMMatrix } = require('./DOMMatrix') | ||
bindings.CanvasRenderingContext2dInit(DOMMatrix, parseFont) | ||
module.exports = bindings.CanvasRenderingContext2d |
@@ -10,5 +10,3 @@ 'use strict' | ||
const bindings = require('./bindings') | ||
const { DOMMatrix } = require('./DOMMatrix') | ||
bindings.CanvasPatternInit(DOMMatrix) | ||
module.exports = bindings.CanvasPattern | ||
@@ -15,0 +13,0 @@ |
{ | ||
"name": "canvas", | ||
"description": "Canvas graphics API backed by Cairo", | ||
"version": "2.11.2", | ||
"version": "3.0.0-rc1b", | ||
"author": "TJ Holowaychuk <tj@learnboost.com>", | ||
"main": "index.js", | ||
"browser": "browser.js", | ||
"types": "index.d.ts", | ||
"contributors": [ | ||
@@ -34,23 +35,17 @@ "Nathan Rajlich <nathan@tootallnate.net>", | ||
"test-wpt": "mocha test/wpt/generated/*.js", | ||
"install": "node-pre-gyp install --fallback-to-build --update-binary", | ||
"dtslint": "dtslint types" | ||
"install": "prebuild-install -r napi || node-gyp rebuild", | ||
"tsd": "tsd" | ||
}, | ||
"binary": { | ||
"module_name": "canvas", | ||
"module_path": "build/Release", | ||
"host": "https://github.com/Automattic/node-canvas/releases/download/", | ||
"remote_path": "v{version}", | ||
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{libc}-{arch}.tar.gz" | ||
}, | ||
"files": [ | ||
"binding.gyp", | ||
"browser.js", | ||
"index.d.ts", | ||
"index.js", | ||
"lib/", | ||
"src/", | ||
"util/", | ||
"types/index.d.ts" | ||
"util/" | ||
], | ||
"types": "types/index.d.ts", | ||
"dependencies": { | ||
"@mapbox/node-pre-gyp": "^1.0.0", | ||
"nan": "^2.17.0", | ||
"node-addon-api": "^7.0.0", | ||
"prebuild-install": "^7.1.1", | ||
"simple-get": "^3.0.3" | ||
@@ -61,3 +56,2 @@ }, | ||
"assert-rejects": "^1.0.0", | ||
"dtslint": "^4.0.7", | ||
"express": "^4.16.3", | ||
@@ -68,8 +62,9 @@ "js-yaml": "^4.1.0", | ||
"standard": "^12.0.1", | ||
"tsd": "^0.29.0", | ||
"typescript": "^4.2.2" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
"node": "^18.12.0 || >= 20.9.0" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -14,6 +14,11 @@ # node-canvas | ||
By default, binaries for macOS, Linux and Windows will be downloaded. If you want to build from source, use `npm install --build-from-source` and see the **Compiling** section below. | ||
By default, pre-built binaries will be downloaded if you're on one of the following platforms: | ||
- macOS x86/64 (*not* Apple silicon) | ||
- Linux x86/64 (glibc only) | ||
- Windows x86/64 | ||
The minimum version of Node.js required is **6.0.0**. | ||
If you want to build from source, use `npm install --build-from-source` and see the **Compiling** section below. | ||
The minimum version of Node.js required is **18.12.0**. | ||
### Compiling | ||
@@ -27,3 +32,3 @@ | ||
----- | ----- | ||
OS X | Using [Homebrew](https://brew.sh/):<br/>`brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman` | ||
macOS | Using [Homebrew](https://brew.sh/):<br/>`brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman` | ||
Ubuntu | `sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev` | ||
@@ -83,3 +88,5 @@ Fedora | `sudo yum install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel` | ||
* [registerFont()](#registerfont) | ||
* [deregisterAllFonts()](#deregisterAllFonts) | ||
### Non-standard APIs | ||
@@ -176,2 +183,31 @@ | ||
### deregisterAllFonts() | ||
> ```ts | ||
> deregisterAllFonts() => void | ||
> ``` | ||
Use `deregisterAllFonts` to unregister all fonts that have been previously registered. This method is useful when you want to remove all registered fonts, such as when using the canvas in tests | ||
```ts | ||
const { registerFont, createCanvas, deregisterAllFonts } = require('canvas') | ||
describe('text rendering', () => { | ||
afterEach(() => { | ||
deregisterAllFonts(); | ||
}) | ||
it('should render text with Comic Sans', () => { | ||
registerFont('comicsans.ttf', { family: 'Comic Sans' }) | ||
const canvas = createCanvas(500, 500) | ||
const ctx = canvas.getContext('2d') | ||
ctx.font = '12px "Comic Sans"' | ||
ctx.fillText('Everyone loves this font :)', 250, 10) | ||
// assertScreenshot() | ||
}) | ||
}) | ||
``` | ||
### Image#src | ||
@@ -178,0 +214,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
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
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1643
637
0
2
359707
57
1
1
+ Addednode-addon-api@^7.0.0
+ Addedprebuild-install@^7.1.1
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexpand-template@2.0.3(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedini@1.3.8(transitive)
+ Addedmimic-response@3.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addednapi-build-utils@1.0.2(transitive)
+ Addednode-abi@3.67.0(transitive)
+ Addednode-addon-api@7.1.1(transitive)
+ Addedprebuild-install@7.1.2(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedsimple-get@4.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
- Removed@mapbox/node-pre-gyp@^1.0.0
- Removednan@^2.17.0
- Removed@mapbox/node-pre-gyp@1.0.11(transitive)
- Removedabbrev@1.1.1(transitive)
- Removedagent-base@6.0.2(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedaproba@2.0.0(transitive)
- Removedare-we-there-yet@2.0.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedchownr@2.0.0(transitive)
- Removedcolor-support@1.1.3(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedconsole-control-strings@1.1.0(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddelegates@1.0.0(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedfs-minipass@2.1.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedgauge@3.0.2(transitive)
- Removedglob@7.2.3(transitive)
- Removedhas-unicode@2.0.1(transitive)
- Removedhttps-proxy-agent@5.0.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedmake-dir@3.1.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminipass@3.3.65.0.0(transitive)
- Removedminizlib@2.1.2(transitive)
- Removedmkdirp@1.0.4(transitive)
- Removedms@2.1.3(transitive)
- Removednan@2.20.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removednopt@5.0.0(transitive)
- Removednpmlog@5.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedrimraf@3.0.2(transitive)
- Removedsemver@6.3.1(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedtar@6.2.1(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedwide-align@1.1.5(transitive)
- Removedyallist@4.0.0(transitive)