Skip to content

Commit

Permalink
feat: upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 7, 2024
1 parent 2eaff51 commit be496e2
Show file tree
Hide file tree
Showing 21 changed files with 5,546 additions and 5,467 deletions.
169 changes: 89 additions & 80 deletions .github/workflows/CI.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ output-exif.*
!output-exif.image.webp
nasa-small.*
output-overlay-png.png
output-debian.jpeg
874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.4.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.1.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.4.cjs
yarnPath: .yarn/releases/yarn-4.1.0.cjs
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ resolver = "2"
[profile.release]
lto = 'fat'
codegen-units = 1
strip = 'symbols'
6 changes: 3 additions & 3 deletions bench/bench.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promises as fs } from 'fs'
import { cpus } from 'os'
import { hrtime } from 'process'
import { promises as fs } from 'node:fs'
import { cpus } from 'node:os'
import { hrtime } from 'node:process'

import { from, timer, lastValueFrom, Subject } from 'rxjs'
import { mergeMap, takeUntil } from 'rxjs/operators'
Expand Down
2 changes: 1 addition & 1 deletion example.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync } from 'fs'
import { readFileSync, writeFileSync } from 'node:fs'

import {
losslessCompressPng,
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
"website"
],
"devDependencies": {
"@napi-rs/cli": "^2.16.3",
"@taplo/cli": "^0.5.2",
"@types/node": "^20.7.0",
"@napi-rs/cli": "^2.18.0",
"@taplo/cli": "^0.7.0",
"@types/node": "^20.11.16",
"@types/sharp": "^0.31.1",
"ava": "^5.3.1",
"ava": "^6.1.1",
"blurhash": "^2.0.5",
"chalk": "^5.3.0",
"electron": "^26.2.2",
"lerna": "^7.3.0",
"electron": "^28.2.1",
"lerna": "^8.1.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.3",
"prettier": "^3.2.5",
"rxjs": "^7.8.1",
"sharp": "^0.32.6",
"typescript": "^5.2.2"
"sharp": "^0.33.2",
"typescript": "^5.3.3"
},
"scripts": {
"artifacts": "lerna run artifacts",
Expand Down Expand Up @@ -70,6 +70,6 @@
"pre-commit": "lint-staged && cargo fmt --all"
}
},
"packageManager": "yarn@3.6.4",
"packageManager": "yarn@4.1.0",
"repository": "git@github.com:Brooooooklyn/Image.git"
}
17 changes: 11 additions & 6 deletions packages/binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ oxipng_libdeflater = ["oxipng/zopfli", "oxipng/parallel"]
with_simd = ["mozjpeg-sys/nasm_simd_parallel_build"]

[dependencies]
fast_image_resize = "2"
fast_image_resize = "3"
imagequant = "4.0.0"
image = { version = "0.24", default-features = false, features = [
"jpeg",
Expand All @@ -35,11 +35,10 @@ image = { version = "0.24", default-features = false, features = [
"openexr",
] }
jpeg-decoder = "0.3"
libavif = { version = "0.11", default-features = false, features = [
libavif = { version = "0.12", default-features = false, features = [
"codec-aom",
] }
libc = "0.2"
libwebp-sys = { version = "0.9", features = ["avx2", "sse41", "neon"] }
lodepng = "3"
napi = { version = "2", default-features = false, features = ["napi3"] }
napi-derive = { version = "2", default-features = false, features = [
Expand All @@ -51,16 +50,22 @@ once_cell = "1"
png = "0.17"
rexif = "0.7"
rgb = "0.8"
resvg = "0.36"
svgtypes = "0.12"
resvg = "0.39"
svgtypes = "0.14"

[dependencies.oxipng]
default-features = false
version = "8"
version = "9"

[dependencies.mozjpeg-sys]
default-features = false
version = "2"

[target.'cfg(not(all(target_os = "macos", target_arch = "x86_64")))'.dependencies]
libwebp-sys = { version = "0.9", default-features = false, features = ["std", "parallel", "avx2", "sse41", "neon"] }

[target.'cfg(all(target_os = "macos", target_arch = "x86_64"))'.dependencies]
libwebp-sys = { version = "0.9", default-features = false, features = ["std", "parallel"] }

[build-dependencies]
napi-build = "2"
43 changes: 43 additions & 0 deletions packages/binding/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,49 @@ switch (platform) {
loadError = e
}
break
case 'riscv64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'image.linux-riscv64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./image.linux-riscv64-musl.node')
} else {
nativeBinding = require('@napi-rs/image-linux-riscv64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'image.linux-riscv64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./image.linux-riscv64-gnu.node')
} else {
nativeBinding = require('@napi-rs/image-linux-riscv64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 's390x':
localFileExisted = existsSync(
join(__dirname, 'image.linux-s390x-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./image.linux-s390x-gnu.node')
} else {
nativeBinding = require('@napi-rs/image-linux-s390x-gnu')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`)
}
Expand Down
3 changes: 0 additions & 3 deletions packages/binding/npm/android-arm-eabi/README.md

This file was deleted.

37 changes: 0 additions & 37 deletions packages/binding/npm/android-arm-eabi/package.json

This file was deleted.

5 changes: 2 additions & 3 deletions packages/binding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-musl",
"x86_64-unknown-freebsd",
"i686-pc-windows-msvc",
"armv7-linux-androideabi"
"i686-pc-windows-msvc"
]
}
},
Expand All @@ -62,6 +61,6 @@
},
"repository": "git@github.com:Brooooooklyn/Image.git",
"devDependencies": {
"@napi-rs/cli": "^2.16.2"
"@napi-rs/cli": "^2.18.0"
}
}
4 changes: 2 additions & 2 deletions packages/binding/src/avif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ pub(crate) fn encode_avif_inner(
) -> Result<AvifData<'static>> {
let mut encoder = libavif::Encoder::new();
let config: Config = config.unwrap_or_default().into();
encoder.set_quantizer((63.0 * (1.0 - config.quality as f32 / 100.0)) as u8);
encoder.set_quantizer_alpha((63.0 * (1.0 - config.alpha_quality as f32 / 100.0)) as u8);
encoder.set_quality((63.0 * (1.0 - config.quality as f32 / 100.0)) as u8);
encoder.set_alpha_quality((63.0 * (1.0 - config.alpha_quality as f32 / 100.0)) as u8);
encoder.set_speed(config.speed);
encoder.set_max_threads(config.threads);
let (width, height) = input_image.dimensions();
Expand Down
6 changes: 3 additions & 3 deletions packages/binding/src/png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ fn to_oxipng_options(opt: &PNGLosslessOptions) -> oxipng::Options {
.strip
.map(|s| {
if s {
oxipng::Headers::All
oxipng::StripChunks::All
} else {
oxipng::Headers::None
oxipng::StripChunks::None
}
})
.unwrap_or(oxipng::Headers::All),
.unwrap_or(oxipng::StripChunks::Safe),
#[cfg(target_arch = "arm")]
deflate: oxipng::Deflaters::Libdeflater { compression: 12 },
..Default::default()
Expand Down
15 changes: 10 additions & 5 deletions packages/binding/src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use napi::{bindgen_prelude::*, JsBuffer};
use napi_derive::napi;
use resvg::{
tiny_skia,
usvg::fontdb::Database,
usvg::{self, Options, TreeParsing, TreeTextToPath},
usvg::{self, fontdb::Database, Options},
};

use crate::{
Expand Down Expand Up @@ -646,7 +645,9 @@ impl Task for EncodeTask {
let len = avif_data.len();
let data_ptr = avif_data.as_slice().as_ptr();
unsafe {
env.create_buffer_with_borrowed_data(data_ptr, len, avif_data, |data, _env| drop(data))
env.create_buffer_with_borrowed_data(data_ptr.cast_mut(), len, avif_data, |data, _env| {
drop(data)
})
}
.map(|b| b.into_raw())
}
Expand Down Expand Up @@ -683,7 +684,7 @@ impl Transformer {
Either::B(b) => usvg::Tree::from_data(b.as_ref(), &options),
}
.map_err(|err| Error::from_reason(format!("{err}")))?;
tree.convert_text(&FONT_DB);
tree.postprocess(Default::default(), &FONT_DB);
let mut size = tree.size.to_int_size();
let min_svg_size = 1000;
while size.width() < min_svg_size || size.height() < min_svg_size {
Expand All @@ -700,7 +701,11 @@ impl Transformer {
let color = tiny_skia::Color::from_rgba8(bg.red, bg.green, bg.blue, bg.alpha);
pix_map.fill(color);
}
resvg::Tree::from_usvg(&tree).render(tiny_skia::Transform::identity(), &mut pix_map.as_mut());
resvg::render(
&tree,
tiny_skia::Transform::identity(),
&mut pix_map.as_mut(),
);

let width = pix_map.width();
let height = pix_map.height();
Expand Down
10 changes: 5 additions & 5 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"version": "0.0.0",
"type": "module",
"dependencies": {
"@napi-rs/canvas": "^0.1.41",
"@napi-rs/image": "^1.6.1",
"@napi-rs/canvas": "^0.1.45",
"@napi-rs/image": "^1.7.0",
"chalk": "^5.3.0",
"next": "canary",
"next-mdx-remote": "^4.4.1",
"nextra": "^2.10.0",
"nextra-theme-docs": "^2.10.0",
"nextra": "^2.13.3",
"nextra-theme-docs": "^2.13.3",
"node-fetch": "^3.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sharp": "^0.32.4"
"sharp": "^0.33.2"
},
"scripts": {
"build": "node generate-img.js && next build",
Expand Down
2 changes: 1 addition & 1 deletion website/public/img/example.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync } from 'fs'
import { readFileSync, writeFileSync } from 'node:fs'

import {
losslessCompressPng,
Expand Down
Binary file modified website/public/img/output-debian.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit be496e2

Please sign in to comment.