Skip to content

Commit

Permalink
feat: upgrade Rust toolchain (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 5, 2024
1 parent 6fe6e21 commit 6ce93d8
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 226 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -31,10 +31,10 @@ serde_json = "1"
thiserror = "1"

[target.'cfg(not(target_os = "linux"))'.dependencies]
mimalloc-rust = "0.2"
mimalloc = "0.1"

[target.'cfg(all(target_os = "linux", not(all(target_env = "musl", target_arch = "aarch64"))))'.dependencies]
mimalloc-rust = { version = "0.2", features = ["local-dynamic-tls"] }
[target.'cfg(target_os = "linux")'.dependencies]
mimalloc = { version = "0.1", features = ["local_dynamic_tls"] }

[build-dependencies]
cc = "1"
Expand Down
16 changes: 2 additions & 14 deletions README-zh.md
Expand Up @@ -23,18 +23,6 @@ npm install @napi-rs/canvas

# 支持的系统和 Node.js 版本

| | node10 | node12 | node14 | node16 | node18 |
| --------------------- | ------ | ------ | ------ | ------ | ------ |
| Windows x64 ||||| ------ |
| macOS x64 ||||| ------ |
| macOS arm64 (m chips) ||||| ------ |
| Linux x64 gnu ||||| ------ |
| Linux x64 musl ||||| ------ |
| Linux arm64 gnu ||||| ------ |
| Linux arm64 musl ||||| ------ |
| Linux arm gnueabihf ||||| ------ |
| Linux arm64 android ||||| ------ |

## 系统要求

### `arm64`
Expand All @@ -54,8 +42,8 @@ npm install @napi-rs/canvas
# 用法

```js
const { promises } = require('fs')
const { join } = require('path')
const { promises } = require('node:fs')
const { join } = require('node:path')
const { createCanvas } = require('@napi-rs/canvas')

const canvas = createCanvas(300, 320)
Expand Down
16 changes: 2 additions & 14 deletions README.md
Expand Up @@ -23,18 +23,6 @@ npm install @napi-rs/canvas

# Support matrix

| | node10 | node12 | node14 | node16 | node18 |
| --------------------- | ------ | ------ | ------ | ------ | ------ |
| Windows x64 ||||||
| macOS x64 ||||||
| macOS arm64 (m chips) ||||||
| Linux x64 gnu ||||||
| Linux x64 musl ||||||
| Linux arm64 gnu ||||||
| Linux arm64 musl ||||||
| Linux arm gnueabihf ||||||
| Linux arm64 android ||||||

## System requirement

### `arm64`
Expand Down Expand Up @@ -62,8 +50,8 @@ You can simply attach a lambda layer by getting an ARN from [Canvas-Lambda-Layer
# Usage

```js
const { promises } = require('fs')
const { join } = require('path')
const { promises } = require('node:fs')
const { join } = require('node:path')
const { createCanvas, loadImage } = require('@napi-rs/canvas')

const canvas = createCanvas(300, 320)
Expand Down
32 changes: 16 additions & 16 deletions package.json
Expand Up @@ -67,39 +67,39 @@
"@jimp/custom": "^0.22.10",
"@jimp/jpeg": "^0.22.10",
"@jimp/png": "^0.22.10",
"@napi-rs/cli": "^2.16.4",
"@napi-rs/cli": "^2.18.0",
"@octokit/rest": "^20.0.2",
"@swc-node/register": "^1.6.8",
"@swc/core": "^1.3.95",
"@swc-node/register": "^1.8.0",
"@swc/core": "^1.4.0",
"@taplo/cli": "^0.7.0",
"@types/lodash": "^4.14.200",
"@types/node": "^20.8.10",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.16",
"@types/semver": "^7",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"ava": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"ava": "^6.1.1",
"benny": "^3.7.1",
"canvas": "^2.11.2",
"canvaskit-wasm": "^0.39.1",
"colorette": "^2.0.20",
"conventional-changelog-cli": "^4.1.0",
"echarts": "^5.4.3",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-sonarjs": "^0.23.0",
"husky": "^9.0.0",
"lint-staged": "^15.0.2",
"husky": "^9.0.10",
"lint-staged": "^15.2.1",
"lodash": "^4.17.21",
"npm-run-all2": "^6.0.0",
"npm-run-all2": "^6.1.2",
"pinst": "^3.0.0",
"png.js": "^0.2.1",
"prettier": "^3.0.3",
"prettier": "^3.2.5",
"pretty-bytes": "^6.1.1",
"semver": "^7.5.4",
"skia-canvas": "^1.0.1",
"table": "^6.8.1",
"typescript": "^5.2.2"
"typescript": "^5.3.3"
},
"lint-staged": {
"*.@(js|ts|tsx|yml|yaml|md|json|html)": [
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-08-09"
channel = "nightly-2024-02-04"
profile = "default"
4 changes: 3 additions & 1 deletion src/image.rs
Expand Up @@ -246,7 +246,9 @@ impl Image {
} else {
None
}
} else if let Some(kind) = infer::get(&data) && kind.matcher_type() == infer::MatcherType::Image {
} else if let Some(kind) = infer::get(&data)
&& kind.matcher_type() == infer::MatcherType::Image
{
Some(Bitmap::from_buffer(data.as_ptr() as *mut u8, length))
} else if self.is_svg_image(data_ref, length) {
self.is_svg = true;
Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Expand Up @@ -26,12 +26,8 @@ use sk::{ColorSpace, SkiaDataRef};

use avif::AvifConfig;

#[cfg(all(
not(all(target_os = "linux", target_env = "musl", target_arch = "aarch64")),
not(debug_assertions)
))]
#[global_allocator]
static ALLOC: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc;
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;

mod avif;
mod ctx;
Expand Down
4 changes: 2 additions & 2 deletions src/state.rs
Expand Up @@ -45,9 +45,9 @@ impl Default for Context2dRenderingState {
shadow_blur: 0f32,
shadow_color: RGBA::new(0, 0, 0, 255),
shadow_color_string: "#000000".to_owned(),
/// 0.0 ~ 1.0
// 0.0 ~ 1.0
global_alpha: 1.0,
/// A float specifying the amount of the line dash offset. The default value is 0.0.
// A float specifying the amount of the line dash offset. The default value is 0.0.
line_dash_offset: 0.0,
image_smoothing_enabled: true,
image_smoothing_quality: FilterQuality::default(),
Expand Down

0 comments on commit 6ce93d8

Please sign in to comment.