@napi-rs/canvas 0.1.58 → 0.1.60

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 (3) hide show
  1. package/README.md +1 -1
  2. package/load-image.js +10 -5
  3. package/package.json +13 -13
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%2Fm130-hotpink)
4
+ ![Skia Version](https://img.shields.io/badge/Skia-chrome%2Fm131-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
 
package/load-image.js CHANGED
@@ -19,7 +19,8 @@ module.exports = async function loadImage(source, options = {}) {
19
19
  // load readable stream as image
20
20
  if (source instanceof Readable) return createImage(await consumeStream(source), options.alt)
21
21
  // construct a Uint8Array if the source is ArrayBuffer or SharedArrayBuffer
22
- if (source instanceof ArrayBuffer || source instanceof SharedArrayBuffer) return createImage(Uint8Array.from(source), options.alt)
22
+ if (source instanceof ArrayBuffer || source instanceof SharedArrayBuffer)
23
+ return createImage(new Uint8Array(source), options.alt)
23
24
  // construct a buffer if the source is buffer-like
24
25
  if (isBufferLike(source)) return createImage(Buffer.from(source), options.alt)
25
26
  // if the source is Image instance, copy the image src to new image
@@ -67,7 +68,13 @@ function makeRequest(url, resolve, reject, redirectCount, requestOptions) {
67
68
  try {
68
69
  const shouldRedirect = REDIRECT_STATUSES.has(res.statusCode) && typeof res.headers.location === 'string'
69
70
  if (shouldRedirect && redirectCount > 0)
70
- return makeRequest(new URL(res.headers.location, url.origin), resolve, reject, redirectCount - 1, requestOptions)
71
+ return makeRequest(
72
+ new URL(res.headers.location, url.origin),
73
+ resolve,
74
+ reject,
75
+ redirectCount - 1,
76
+ requestOptions,
77
+ )
71
78
  if (typeof res.statusCode === 'number' && (res.statusCode < 200 || res.statusCode >= 300)) {
72
79
  return reject(new Error(`remote source rejected with status code ${res.statusCode}`))
73
80
  }
@@ -102,9 +109,7 @@ function createImage(src, alt) {
102
109
  }
103
110
 
104
111
  function isBufferLike(src) {
105
- return (
106
- (src && src.type === 'Buffer') || Array.isArray(src)
107
- )
112
+ return (src && src.type === 'Buffer') || Array.isArray(src)
108
113
  }
109
114
 
110
115
  async function exists(path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/canvas",
3
- "version": "0.1.58",
3
+ "version": "0.1.60",
4
4
  "description": "Canvas for Node.js with skia backend",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -89,8 +89,8 @@
89
89
  "husky": "^9.0.10",
90
90
  "lint-staged": "^15.2.1",
91
91
  "lodash": "^4.17.21",
92
- "npm-run-all2": "^6.1.2",
93
- "oxlint": "^0.9.0",
92
+ "npm-run-all2": "^7.0.0",
93
+ "oxlint": "^0.11.0",
94
94
  "pinst": "^3.0.0",
95
95
  "png.js": "^0.2.1",
96
96
  "prettier": "^3.2.5",
@@ -135,16 +135,16 @@
135
135
  "singleQuote": true,
136
136
  "arrowParens": "always"
137
137
  },
138
- "packageManager": "yarn@4.5.0",
138
+ "packageManager": "yarn@4.5.1",
139
139
  "optionalDependencies": {
140
- "@napi-rs/canvas-win32-x64-msvc": "0.1.58",
141
- "@napi-rs/canvas-darwin-x64": "0.1.58",
142
- "@napi-rs/canvas-linux-x64-gnu": "0.1.58",
143
- "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.58",
144
- "@napi-rs/canvas-linux-x64-musl": "0.1.58",
145
- "@napi-rs/canvas-linux-arm64-gnu": "0.1.58",
146
- "@napi-rs/canvas-linux-arm64-musl": "0.1.58",
147
- "@napi-rs/canvas-darwin-arm64": "0.1.58",
148
- "@napi-rs/canvas-android-arm64": "0.1.58"
140
+ "@napi-rs/canvas-win32-x64-msvc": "0.1.60",
141
+ "@napi-rs/canvas-darwin-x64": "0.1.60",
142
+ "@napi-rs/canvas-linux-x64-gnu": "0.1.60",
143
+ "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.60",
144
+ "@napi-rs/canvas-linux-x64-musl": "0.1.60",
145
+ "@napi-rs/canvas-linux-arm64-gnu": "0.1.60",
146
+ "@napi-rs/canvas-linux-arm64-musl": "0.1.60",
147
+ "@napi-rs/canvas-darwin-arm64": "0.1.60",
148
+ "@napi-rs/canvas-android-arm64": "0.1.60"
149
149
  }
150
150
  }