Skip to content

Commit

Permalink
Merge branch 'master' into RangeError
Browse files Browse the repository at this point in the history
  • Loading branch information
piranna authored Jul 6, 2023
2 parents fcba4d1 + adf73ee commit 4a4ff63
Show file tree
Hide file tree
Showing 95 changed files with 28,088 additions and 3,202 deletions.
11 changes: 2 additions & 9 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<!---
Having trouble installing node-canvas? Please make sure you have read
the installation instructions located here before asking for help:
https://github.com/Automattic/node-canvas#installation
Still having problems, found a bug or want a feature? Fill out the form below.
-->

<!--- Provide a general summary of the issue in the Title above -->

## Issue or Feature
- [ ] If this is an issue with installation, I have read the [troubleshooting guide](https://github.com/Automattic/node-canvas/issues/1511).

<!--- Provide info about the bug or feature. -->

## Steps to Reproduce
Expand Down
36 changes: 19 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ on:
pull_request:
paths-ignore:
- ".github/workflows/prebuild.yaml"


jobs:
jobs:
Linux:
name: Test on Linux
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]
node: [10, 12, 14, 16, 18, 20]
steps:
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
sudo apt update
Expand All @@ -31,21 +30,23 @@ jobs:

Windows:
name: Test on Windows
runs-on: windows-latest
runs-on: windows-2019
strategy:
matrix:
node: [10, 12, 14]
node: [10, 12, 14, 16, 18, 20]
steps:
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
Invoke-WebRequest "http://ftp.gnome.org/pub/GNOME/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip" -OutFile "gtk.zip"
Invoke-WebRequest "https://ftp-osl.osuosl.org/pub/gnome/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip" -OutFile "gtk.zip"
Expand-Archive gtk.zip -DestinationPath "C:\GTK"
Invoke-WebRequest "https://downloads.sourceforge.net/project/libjpeg-turbo/2.0.4/libjpeg-turbo-2.0.4-vc64.exe" -OutFile "libjpeg.exe" -UserAgent NativeHost
.\libjpeg.exe /S
npm install -g node-gyp@8
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
- name: Install
run: npm install --build-from-source
- name: Test
Expand All @@ -56,29 +57,30 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
node: [10, 12, 14]
node: [10, 12, 14, 16, 18, 20]
steps:
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
brew update
brew install python3 || : # python doesn't need to be linked
brew install pkg-config cairo pango libpng jpeg giflib librsvg
- name: Install
run: npm install --build-from-source
- name: Test
run: npm test
run: npm test

Lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 12
- uses: actions/checkout@v2
node-version: 14
- uses: actions/checkout@v3
- name: Install
run: npm install --ignore-scripts
- name: Lint
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/prebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
Linux:
strategy:
matrix:
node: [8, 9, 10, 11, 12, 13, 14]
node: [8, 9, 10, 11, 12, 13, 14, 16, 18, 20]
canvas_tag: [] # e.g. "v2.6.1"
name: ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, Linux
runs-on: ubuntu-latest
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
macOS:
strategy:
matrix:
node: [8, 9, 10, 11, 12, 13, 14]
node: [8, 9, 10, 11, 12, 13, 14, 16, 18, 20]
canvas_tag: [] # e.g. "v2.6.1"
name: ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, macOS
runs-on: macos-latest
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
Win:
strategy:
matrix:
node: [8, 9, 10, 11, 12, 13, 14]
node: [8, 9, 10, 11, 12, 13, 14, 16, 18, 20]
canvas_tag: [] # e.g. "v2.6.1"
name: ${{ matrix.canvas_tag}}, Node.js ${{ matrix.node }}, Windows
runs-on: windows-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ package-lock.json
*.swp
*.un~
npm-debug.log

.idea
115 changes: 114 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,123 @@ project adheres to [Semantic Versioning](http://semver.org/).
(Unreleased)
==================
### Changed
* Defer the initialization of the `op` variable to the `default` switch case to avoid a compiler warning. (#2229)
* Use a `default` switch case with a null statement if some enum values aren't suppsed to be handled, this avoids a compiler warning. (#2229)
* Migrate from librsvg's deprecated `rsvg_handle_get_dimensions()` and `rsvg_handle_render_cairo()` functions to the new `rsvg_handle_get_intrinsic_size_in_pixels()` and `rsvg_handle_render_document()` respectively. (#2229)
* Avoid calling virtual methods in constructors/destructors to avoid bypassing virtual dispatch. (#2229)
* Remove unused private field `backend` in the `Backend` class. (#2229)
* Add Node.js v20 to CI. (#2237)
### Added
* Added support for `inverse()` and `invertSelf()` to `DOMMatrix` (#1648)
* Added string tags to support class detection
### Fixed
* Fix a case of use-after-free. (#2229)
* Fix usage of garbage value by filling the allocated memory entirely with zeros if it's not modified. (#2229)
* Fix a potential memory leak. (#2229)

2.11.2
==================
### Fixed
* Building on Windows in CI (and maybe other Windows configurations?) (#2216)

2.11.1
==================
### Fixed
* Add missing property `canvas` to the `CanvasRenderingContext2D` type
* Fixed glyph positions getting rounded, resulting text having a slight `letter-spacing` effect
* Fixed `ctx.font` not being restored correctly after `ctx.restore()` (#1946)

2.11.0
==================
### Fixed
* Replace triple-slash directive in types with own types to avoid polluting TS modules with globals ([#1656](https://github.com/Automattic/node-canvas/issues/1656))

2.10.2
==================
### Fixed
* Fix `Assertion failed: (object->InternalFieldCount() > 0), function Unwrap, file nan_object_wrap.h, line 32.` ([#2025](https://github.com/Automattic/node-canvas/issues/2025))
* `textBaseline` and `textAlign` were not saved/restored by `save()`/`restore()`. ([#1936](https://github.com/Automattic/node-canvas/issues/2029))
* Update nan to v2.17.0 to ensure Node.js v18+ support.
### Changed
* Improve performance and memory usage of `save()`/`restore()`.
* `save()`/`restore()` no longer have a maximum depth (previously 64 states).

2.10.1
==================
### Fixed
* Fix `actualBoundingBoxLeft` and `actualBoundingBoxRight` when `textAlign='center'` or `'right'` ([#1909](https://github.com/Automattic/node-canvas/issues/1909))
* Fix `rgba(r,g,b,0)` with alpha to 0 should parse as transparent, not opaque. ([#2110](https://github.com/Automattic/node-canvas/pull/2110))

2.10.0
==================
### Added
* Export `pangoVersion`
* [`ctx.roundRect()`](https://developer.chrome.com/blog/canvas2d/#round-rect)
### Fixed
* `rgba(r,g,b)` with no alpha should parse as opaque, not transparent. ([#2029](https://github.com/Automattic/node-canvas/issues/2029))
* Typo in `PngConfig.filters` types. ([#2072](https://github.com/Automattic/node-canvas/issues/2072))
* `createPattern()` always used "repeat" mode; now supports "repeat-x" and "repeat-y". ([#2066](https://github.com/Automattic/node-canvas/issues/2066))
* Crashes and hangs when using non-finite values in `context.arc()`. ([#2055](https://github.com/Automattic/node-canvas/issues/2055))
* Incorrect `context.arc()` geometry logic for full ellipses. ([#1808](https://github.com/Automattic/node-canvas/issues/1808), ([#1736](https://github.com/Automattic/node-canvas/issues/1736)))
* Added missing `deregisterAllFonts` to the Typescript declaration file ([#2096](https://github.com/Automattic/node-canvas/pull/2096))
* Add `User-Agent` header when requesting remote images ([#2099](https://github.com/Automattic/node-canvas/issues/2099))

2.9.3
==================
### Fixed
* Wrong fonts used when calling `registerFont` multiple times with the same family name ([#2041](https://github.com/Automattic/node-canvas/issues/2041))

2.9.2
==================
### Fixed
* All exports now work when Canvas is used in ES Modules (ESM). ([#2047](https://github.com/Automattic/node-canvas/pull/2047))
* `npm rebuild` will now re-fetch prebuilt binaries to avoid `NODE_MODULE_VERSION` mismatch errors. ([#1982](https://github.com/Automattic/node-canvas/pull/1982))

2.9.1
==================
### Fixed
* Stringify CanvasGradient, CanvasPattern and ImageData like browsers do. (#1639, #1646)
* Add missing include for `toupper`.
* Throw an error instead of crashing the process if `getImageData` or `putImageData` is called on a PDF or SVG canvas (#1853)
* Compatibility with Typescript 4.6
* Near-perfect font matching on Linux (#1572)
* Fix multi-byte font path support on Windows.
* Allow rebuild of this library

2.9.0
==================
### Changed
* Refactor functions to classes.
* Changed `DOMPoint()` constructor to check for parameter nullability.
* Changed `DOMMatrix.js` to use string literals for non-special cases.
* Remove semicolons from Dommatrix.js.
* Update nan to v2.15.0 to ensure Node.js v14+ support.
* Clean up inf/nan macros and slightly speed up argument checking.
### Added
* Added `deregisterAllFonts` method to free up memory and reduce font conflicts.
### Fixed
* Support Apple M1 Homebrew install that puts canvas install library files in `/opt/homebrew/lib`

2.8.0
==================
### Changed
* Upgrade dtslint
* Upgrade node-pre-gyp to 1.0.0. Note that if you are using special node-pre-gyp
features like `node_pre_gyp_accessKeyId`, you may need to make changes to your
installation procedure. See https://github.com/mapbox/node-pre-gyp/blob/master/CHANGELOG.md#100.
* Add Node.js v16 to CI.
* The C++ class method `nBytes()` now returns a size_t. (Because this is a C++
method only, this is not considered a breaking change.)
### Added
* Add support for `inverse()` and `invertSelf()` to `DOMMatrix` (#1648)
* Add support for `context.getTransform()` ([#1769](https://github.com/Automattic/node-canvas/pull/1769))
* Add support for `context.setTransform(dommatrix)` ([#1769](https://github.com/Automattic/node-canvas/pull/1769))
### Fixed
* Fix `actualBoundingBoxLeft` and `actualBoundingBoxRight` returned by `measureText` to be the ink rect ([#1776](https://github.com/Automattic/node-canvas/pull/1776), fixes [#1703](https://github.com/Automattic/node-canvas/issues/1703)).
* Fix Pango logging "expect ugly output" on Windows (#1643)
* Fix benchmark for createPNGStream (#1672)
* Fix dangling reference in BackendOperationNotAvailable exception (#1740)
* Fix always-false comparison warning in Canvas.cc.
* Fix Node.js crash when throwing from an onload or onerror handler.

2.7.0
==================
Expand All @@ -24,6 +136,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
* Speed up `fillStyle=` and `strokeStyle=`
### Added
* Export `rsvgVersion`.
* CanvasPattern’s `setTransform` method is no longer missing
### Fixed
* Fix BMP issues. (#1497)
* Update typings to support jpg and addPage on NodeCanvasRenderingContext2D (#1509)
Expand Down
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For detailed installation information, see the [wiki](https://github.com/Automat

OS | Command
----- | -----
OS X | Using [Homebrew](https://brew.sh/):<br/>`brew install pkg-config cairo pango libpng jpeg giflib librsvg`
OS X | 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`
Fedora | `sudo yum install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel`
Solaris | `pkgin install cairo pango pkg-config xproto renderproto kbproto xextproto`
Expand Down Expand Up @@ -91,7 +91,7 @@ This project is an implementation of the Web Canvas API and implements that API
* [CanvasRenderingContext2D#patternQuality](#canvasrenderingcontext2dpatternquality)
* [CanvasRenderingContext2D#quality](#canvasrenderingcontext2dquality)
* [CanvasRenderingContext2D#textDrawingMode](#canvasrenderingcontext2dtextdrawingmode)
* [CanvasRenderingContext2D#globalCompositeOperator = 'saturate'](#canvasrenderingcontext2dglobalcompositeoperator--saturate)
* [CanvasRenderingContext2D#globalCompositeOperation = 'saturate'](#canvasrenderingcontext2dglobalcompositeoperation--saturate)
* [CanvasRenderingContext2D#antialias](#canvasrenderingcontext2dantialias)

### createCanvas()
Expand Down
42 changes: 27 additions & 15 deletions benchmarks/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* milliseconds to complete.
*/

var createCanvas = require('../').createCanvas
var canvas = createCanvas(200, 200)
var largeCanvas = createCanvas(1000, 1000)
var ctx = canvas.getContext('2d')
const { createCanvas } = require('../')
const canvas = createCanvas(200, 200)
const largeCanvas = createCanvas(1000, 1000)
const ctx = canvas.getContext('2d')

var initialTimes = 10
var minDurationMs = 2000
const initialTimes = 10
const minDurationMs = 2000

var queue = []
var running = false
const queue = []
let running = false

function bm (label, fn) {
queue.push({ label: label, fn: fn })
Expand All @@ -28,11 +28,11 @@ function next () {

function run (benchmark, n, start) {
running = true
var originalN = n
var fn = benchmark.fn
const originalN = n
const fn = benchmark.fn

if (fn.length) { // async
var pending = n
let pending = n

while (n--) {
fn(function () {
Expand All @@ -46,12 +46,12 @@ function run (benchmark, n, start) {
}

function done (benchmark, times, start, isAsync) {
var duration = Date.now() - start
const duration = Date.now() - start

if (duration < minDurationMs) {
run(benchmark, times * 2, Date.now())
} else {
var opsSec = times / duration * 1000
const opsSec = times / duration * 1000
if (isAsync) {
console.log(' - \x1b[33m%s\x1b[0m %s ops/sec (%s times, async)', benchmark.label, opsSec.toLocaleString(), times)
} else {
Expand All @@ -64,6 +64,18 @@ function done (benchmark, times, start, isAsync) {

// node-canvas

bm('save/restore', function () {
for (let i = 0; i < 1000; i++) {
const max = i & 15
for (let j = 0; j < max; ++j) {
ctx.save()
}
for (let j = 0; j < max; ++j) {
ctx.restore()
}
}
})

bm('fillStyle= name', function () {
for (let i = 0; i < 10000; i++) {
ctx.fillStyle = '#fefefe'
Expand Down Expand Up @@ -97,7 +109,7 @@ bm('strokeRect()', function () {
})

bm('linear gradients', function () {
var lingrad = ctx.createLinearGradient(0, 50, 0, 95)
const lingrad = ctx.createLinearGradient(0, 50, 0, 95)
lingrad.addColorStop(0.5, '#000')
lingrad.addColorStop(1, 'rgba(0,0,0,0)')
ctx.fillStyle = lingrad
Expand Down Expand Up @@ -157,7 +169,7 @@ bm('getImageData(0,0,100,100)', function () {
})

bm('PNGStream 200x200', function (done) {
var stream = canvas.createPNGStream()
const stream = canvas.createPNGStream()
stream.on('data', function (chunk) {
// whatever
})
Expand Down
Loading

0 comments on commit 4a4ff63

Please sign in to comment.