@napi-rs/canvas 0.1.44 → 0.1.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +13 -16
  2. package/package.json +38 -36
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # `skr canvas`
2
2
 
3
3
  ![CI](https://github.com/Brooooooklyn/canvas/workflows/CI/badge.svg)
4
- ![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm116-hotpink)
4
+ ![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm122-hotpink)
5
5
  [![install size](https://packagephobia.com/badge?p=@napi-rs/canvas)](https://packagephobia.com/result?p=@napi-rs/canvas)
6
6
  [![Downloads](https://img.shields.io/npm/dm/@napi-rs/canvas.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/canvas?minimal=true)
7
7
 
@@ -23,18 +23,6 @@ npm install @napi-rs/canvas
23
23
 
24
24
  # Support matrix
25
25
 
26
- | | node10 | node12 | node14 | node16 | node18 |
27
- | --------------------- | ------ | ------ | ------ | ------ | ------ |
28
- | Windows x64 | ✓ | ✓ | ✓ | ✓ | ✓ |
29
- | macOS x64 | ✓ | ✓ | ✓ | ✓ | ✓ |
30
- | macOS arm64 (m chips) | ✓ | ✓ | ✓ | ✓ | ✓ |
31
- | Linux x64 gnu | ✓ | ✓ | ✓ | ✓ | ✓ |
32
- | Linux x64 musl | ✓ | ✓ | ✓ | ✓ | ✓ |
33
- | Linux arm64 gnu | ✓ | ✓ | ✓ | ✓ | ✓ |
34
- | Linux arm64 musl | ✓ | ✓ | ✓ | ✓ | ✓ |
35
- | Linux arm gnueabihf | ✓ | ✓ | ✓ | ✓ | ✓ |
36
- | Linux arm64 android | ✓ | ✓ | ✓ | ✓ | ✓ |
37
-
38
26
  ## System requirement
39
27
 
40
28
  ### `arm64`
@@ -62,9 +50,9 @@ You can simply attach a lambda layer by getting an ARN from [Canvas-Lambda-Layer
62
50
  # Usage
63
51
 
64
52
  ```js
65
- const { promises } = require('fs')
66
- const { join } = require('path')
67
- const { createCanvas } = require('@napi-rs/canvas')
53
+ const { promises } = require('node:fs')
54
+ const { join } = require('node:path')
55
+ const { createCanvas, loadImage } = require('@napi-rs/canvas')
68
56
 
69
57
  const canvas = createCanvas(300, 320)
70
58
  const ctx = canvas.getContext('2d')
@@ -88,6 +76,15 @@ ctx.closePath()
88
76
  ctx.stroke()
89
77
 
90
78
  async function main() {
79
+ // load images from disk or from a URL
80
+ const catImage = await loadImage('path/to/cat.png')
81
+ const dogImage = await loadImage('https://example.com/path/to/dog.jpg')
82
+
83
+ ctx.drawImage(catImage, 0, 0, catImage.width, catImage.height)
84
+
85
+ ctx.drawImage(dogImage, canvas.width / 2, canvas.height / 2, dogImage.width, dogImage.height)
86
+
87
+ // export canvas as image
91
88
  const pngData = await canvas.encode('png') // JPEG, AVIF and WebP are also supported
92
89
  // encoding in libuv thread pool, non-blocking
93
90
  await promises.writeFile(join(__dirname, 'simple.png'), pngData)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/canvas",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "Canvas for Node.js with skia backend",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/Brooooooklyn/canvas.git",
@@ -63,41 +63,43 @@
63
63
  "version": "napi version && conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
64
64
  },
65
65
  "devDependencies": {
66
- "@jimp/core": "^0.22.8",
67
- "@jimp/custom": "^0.22.8",
68
- "@jimp/jpeg": "^0.22.8",
69
- "@jimp/png": "^0.22.8",
70
- "@napi-rs/cli": "^2.16.2",
71
- "@octokit/rest": "^20.0.1",
72
- "@swc-node/register": "^1.6.6",
73
- "@swc/core": "^1.3.71",
74
- "@taplo/cli": "^0.5.2",
75
- "@types/lodash": "^4.14.196",
76
- "@types/node": "^20.4.5",
77
- "@typescript-eslint/eslint-plugin": "^6.2.0",
78
- "@typescript-eslint/parser": "^6.2.0",
79
- "ava": "^5.3.1",
66
+ "@jimp/core": "^0.22.10",
67
+ "@jimp/custom": "^0.22.10",
68
+ "@jimp/jpeg": "^0.22.10",
69
+ "@jimp/png": "^0.22.10",
70
+ "@napi-rs/cli": "^2.18.0",
71
+ "@octokit/rest": "^20.0.2",
72
+ "@swc-node/register": "^1.8.0",
73
+ "@swc/core": "^1.4.0",
74
+ "@taplo/cli": "^0.7.0",
75
+ "@types/lodash": "^4.14.202",
76
+ "@types/node": "^20.11.16",
77
+ "@types/semver": "^7",
78
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
79
+ "@typescript-eslint/parser": "^6.20.0",
80
+ "ava": "^6.1.1",
80
81
  "benny": "^3.7.1",
81
82
  "canvas": "^2.11.2",
82
- "canvaskit-wasm": "^0.38.2",
83
+ "canvaskit-wasm": "^0.39.1",
83
84
  "colorette": "^2.0.20",
84
- "conventional-changelog-cli": "^3.0.0",
85
+ "conventional-changelog-cli": "^4.1.0",
85
86
  "echarts": "^5.4.3",
86
- "eslint": "^8.45.0",
87
- "eslint-config-prettier": "^9.0.0",
88
- "eslint-plugin-import": "^2.27.5",
89
- "eslint-plugin-sonarjs": "^0.20.0",
90
- "husky": "^8.0.3",
91
- "lint-staged": "^14.0.0",
87
+ "eslint": "^8.56.0",
88
+ "eslint-config-prettier": "^9.1.0",
89
+ "eslint-plugin-import": "^2.29.1",
90
+ "eslint-plugin-sonarjs": "^0.23.0",
91
+ "husky": "^9.0.10",
92
+ "lint-staged": "^15.2.1",
92
93
  "lodash": "^4.17.21",
93
- "npm-run-all": "^4.1.5",
94
+ "npm-run-all2": "^6.1.2",
94
95
  "pinst": "^3.0.0",
95
96
  "png.js": "^0.2.1",
96
- "prettier": "^3.0.0",
97
+ "prettier": "^3.2.5",
97
98
  "pretty-bytes": "^6.1.1",
99
+ "semver": "^7.5.4",
98
100
  "skia-canvas": "^1.0.1",
99
101
  "table": "^6.8.1",
100
- "typescript": "^5.1.6"
102
+ "typescript": "^5.3.3"
101
103
  },
102
104
  "lint-staged": {
103
105
  "*.@(js|ts|tsx|yml|yaml|md|json|html)": [
@@ -133,16 +135,16 @@
133
135
  "singleQuote": true,
134
136
  "arrowParens": "always"
135
137
  },
136
- "packageManager": "yarn@3.6.2",
138
+ "packageManager": "yarn@4.1.0",
137
139
  "optionalDependencies": {
138
- "@napi-rs/canvas-win32-x64-msvc": "0.1.44",
139
- "@napi-rs/canvas-darwin-x64": "0.1.44",
140
- "@napi-rs/canvas-linux-x64-gnu": "0.1.44",
141
- "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.44",
142
- "@napi-rs/canvas-linux-x64-musl": "0.1.44",
143
- "@napi-rs/canvas-linux-arm64-gnu": "0.1.44",
144
- "@napi-rs/canvas-linux-arm64-musl": "0.1.44",
145
- "@napi-rs/canvas-darwin-arm64": "0.1.44",
146
- "@napi-rs/canvas-android-arm64": "0.1.44"
140
+ "@napi-rs/canvas-win32-x64-msvc": "0.1.45",
141
+ "@napi-rs/canvas-darwin-x64": "0.1.45",
142
+ "@napi-rs/canvas-linux-x64-gnu": "0.1.45",
143
+ "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.45",
144
+ "@napi-rs/canvas-linux-x64-musl": "0.1.45",
145
+ "@napi-rs/canvas-linux-arm64-gnu": "0.1.45",
146
+ "@napi-rs/canvas-linux-arm64-musl": "0.1.45",
147
+ "@napi-rs/canvas-darwin-arm64": "0.1.45",
148
+ "@napi-rs/canvas-android-arm64": "0.1.45"
147
149
  }
148
150
  }