Socket
Socket
Sign inDemoInstall

canvas

Package Overview
Dependencies
Maintainers
8
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas - npm Package Compare versions

Comparing version 2.11.2 to 3.0.0-rc1b

index.d.ts

3

index.js

@@ -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
})

3

lib/context2d.js

@@ -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

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