Skip to content

Commit

Permalink
chore: bump up all non-major dependencies (#110)
Browse files Browse the repository at this point in the history
* chore: bump up all non-major dependencies

* Update napi

* fix armv7 build

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: LongYinan <[email protected]>
  • Loading branch information
renovate[bot] and Brooooooklyn authored Sep 21, 2024
1 parent f1eee17 commit 2ac81dd
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 254 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ jobs:
setup: |
sudo apt-get update
sudo apt-get install meson gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
build: CC="arm-linux-gnueabihf-gcc" yarn workspace @napi-rs/image build --target armv7-unknown-linux-gnueabihf --features oxipng_libdeflater --use-napi-cross
build: |
export CC="arm-linux-gnueabihf-gcc"
export CARGO_CFG_TARGET_FEATURE="neon"
yarn workspace @napi-rs/image build --target armv7-unknown-linux-gnueabihf --features oxipng_libdeflater --use-napi-cross
- host: ubuntu-latest
target: aarch64-linux-android
build: |
Expand Down
324 changes: 162 additions & 162 deletions .yarn/releases/yarn-4.4.1.cjs → .yarn/releases/yarn-4.5.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-4.4.1.cjs
yarnPath: .yarn/releases/yarn-4.5.0.cjs
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
"pre-commit": "lint-staged && cargo fmt --all"
}
},
"packageManager": "yarn@4.4.1",
"packageManager": "yarn@4.5.0",
"repository": "[email protected]:Brooooooklyn/Image.git"
}
4 changes: 2 additions & 2 deletions packages/binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ svgtypes = "0.15"
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"] }
libwebp-sys = { version = "0.10", 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"] }
libwebp-sys = { version = "0.10", default-features = false, features = ["std", "parallel"] }

[build-dependencies]
napi-build = "2"
14 changes: 7 additions & 7 deletions packages/binding/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class Transformer {
constructor(input: Buffer)
constructor(input: Uint8Array)
/** Support CSS3 color, e.g. rgba(255, 255, 255, .8) */
static fromSvg(input: string | Uint8Array, background?: string | undefined | null): Transformer
static fromRgbaPixels(input: Uint8Array | Uint8ClampedArray, width: number, height: number): Transformer
Expand Down Expand Up @@ -72,7 +72,7 @@ export declare class Transformer {
/** Crop a cut-out of this image delimited by the bounding rectangle. */
crop(x: number, y: number, width: number, height: number): this
/** Overlay an image at a given coordinate (x, y) */
overlay(onTop: Buffer, x: number, y: number): this
overlay(onTop: Uint8Array, x: number, y: number): this
/** Return this image's pixels as a native endian byte slice. */
rawPixels(signal?: AbortSignal | undefined | null): Promise<Buffer>
/** Return this image's pixels as a native endian byte slice. */
Expand Down Expand Up @@ -178,9 +178,9 @@ export declare enum CompressionType {
Best = 2
}

export declare function compressJpeg(input: Buffer, options?: JpegCompressOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
export declare function compressJpeg(input: Uint8Array, options?: JpegCompressOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>

export declare function compressJpegSync(input: Buffer, options?: JpegCompressOptions | undefined | null): Buffer
export declare function compressJpegSync(input: Uint8Array, options?: JpegCompressOptions | undefined | null): Buffer

export declare enum FastResizeFilter {
/**
Expand Down Expand Up @@ -283,7 +283,7 @@ export declare enum JsColorType {
Rgba32F = 9
}

export declare function losslessCompressPng(input: Buffer, options?: PNGLosslessOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
export declare function losslessCompressPng(input: Uint8Array, options?: PNGLosslessOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>

export declare function losslessCompressPngSync(input: Buffer, options?: PNGLosslessOptions | undefined | null): Buffer

Expand Down Expand Up @@ -358,9 +358,9 @@ export interface PNGLosslessOptions {
strip?: boolean
}

export declare function pngQuantize(input: Buffer, options?: PngQuantOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>
export declare function pngQuantize(input: Uint8Array, options?: PngQuantOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>

export declare function pngQuantizeSync(input: Buffer, options?: PngQuantOptions | undefined | null): Buffer
export declare function pngQuantizeSync(input: Uint8Array, options?: PngQuantOptions | undefined | null): Buffer

export interface PngQuantOptions {
/** default is 70 */
Expand Down
1 change: 1 addition & 0 deletions packages/binding/src/avif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct AvifConfig {
}

#[napi]
#[derive(Clone, Copy)]
/// https://en.wikipedia.org/wiki/Chroma_subsampling#Types_of_sampling_and_subsampling
/// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_concepts
pub enum ChromaSubsampling {
Expand Down
5 changes: 3 additions & 2 deletions packages/binding/src/fast_resize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use napi::bindgen_prelude::*;
use napi_derive::napi;

#[napi]
#[derive(Default)]
#[derive(Default, Clone, Copy)]
pub enum FastResizeFilter {
/// Each pixel of source image contributes to one pixel of the
/// destination image with identical weights. For upscaling is equivalent
/// of `Nearest` resize algorithm.
/// of `Nearest` resize algorithm.
Box,
/// Bilinear filter calculate the output pixel value using linear
/// interpolation on all pixels that may contribute to the output value.
Expand Down Expand Up @@ -49,6 +49,7 @@ impl From<FastResizeFilter> for FilterType {
}

#[napi]
#[derive(Clone, Copy)]
pub enum ResizeFit {
/// (default) Preserving aspect ratio
/// ensure the image covers both provided dimensions by cropping/clipping to fit.
Expand Down
33 changes: 16 additions & 17 deletions packages/binding/src/jpeg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::io::Cursor;

use napi::{bindgen_prelude::*, JsBuffer};
use napi::bindgen_prelude::*;
use napi_derive::napi;

#[napi(object)]
Expand All @@ -16,14 +16,14 @@ pub struct JpegCompressOptions {
#[napi]
pub fn compress_jpeg_sync(
env: Env,
input: Buffer,
input: &[u8],
options: Option<JpegCompressOptions>,
) -> Result<JsBuffer> {
) -> Result<BufferSlice> {
let options = options.unwrap_or_default();
let quality = options.quality.unwrap_or(100);
if quality != 100 {
let img = image::load_from_memory_with_format(input.as_ref(), image::ImageFormat::Jpeg)
.map_err(|err| {
let img =
image::load_from_memory_with_format(input, image::ImageFormat::Jpeg).map_err(|err| {
Error::new(
Status::InvalidArg,
format!("Load input jpeg image failed {err}"),
Expand All @@ -37,14 +37,13 @@ pub fn compress_jpeg_sync(
format!("Encode image from input jpeg failed {err}"),
)
})?;
return env
.create_buffer_with_data(dest.into_inner())
.map(|b| b.into_raw());
return BufferSlice::from_data(&env, dest.into_inner());
}
let (buf, outsize, de_c_info, compress_c_info) =
unsafe { moz_jpeg_compress(input.as_ref(), &options) }?;
unsafe { moz_jpeg_compress(input, &options) }?;
unsafe {
env.create_buffer_with_borrowed_data(
BufferSlice::from_external(
&env,
buf,
outsize,
(de_c_info, compress_c_info, buf),
Expand All @@ -55,7 +54,6 @@ pub fn compress_jpeg_sync(
},
)
}
.map(|v| v.into_raw())
}

/// # Safety
Expand Down Expand Up @@ -156,7 +154,7 @@ unsafe impl Send for ThreadsafeMozjpegCompressOutput {}

pub struct CompressJpegTask {
options: JpegCompressOptions,
input: Buffer,
input: Uint8Array,
}

pub enum JpegOptimizeOutput {
Expand All @@ -167,7 +165,7 @@ pub enum JpegOptimizeOutput {
#[napi]
impl Task for CompressJpegTask {
type Output = JpegOptimizeOutput;
type JsValue = JsBuffer;
type JsValue = Buffer;

fn compute(&mut self) -> Result<Self::Output> {
let quality = self.options.quality.unwrap_or(100);
Expand Down Expand Up @@ -212,7 +210,8 @@ impl Task for CompressJpegTask {
compress_c_info,
} = *moz_jpeg_output;
unsafe {
env.create_buffer_with_borrowed_data(
BufferSlice::from_external(
&env,
buf,
len,
(de_c_info, compress_c_info, buf),
Expand All @@ -224,15 +223,15 @@ impl Task for CompressJpegTask {
)
}
}
JpegOptimizeOutput::Lossy(buf) => env.create_buffer_with_data(buf),
JpegOptimizeOutput::Lossy(buf) => BufferSlice::from_data(&env, buf),
}
.map(|v| v.into_raw())
.and_then(|slice| slice.into_buffer(&env))
}
}

#[napi]
pub fn compress_jpeg(
input: Buffer,
input: Uint8Array,
options: Option<JpegCompressOptions>,
signal: Option<AbortSignal>,
) -> AsyncTask<CompressJpegTask> {
Expand Down
25 changes: 10 additions & 15 deletions packages/binding/src/png.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use napi::{bindgen_prelude::*, JsBuffer, JsBufferValue, Ref};
use napi::bindgen_prelude::*;
use napi_derive::napi;
use rgb::FromSlice;

#[napi]
#[derive(Default)]
#[derive(Default, Copy, Clone)]
pub enum CompressionType {
/// Default compression level
#[default]
Expand All @@ -25,7 +25,7 @@ impl From<CompressionType> for image::codecs::png::CompressionType {
}

#[napi]
#[derive(Default)]
#[derive(Default, Clone, Copy)]
pub enum FilterType {
/// No processing done, best used for low bit depth greyscale or data with a
/// low color count
Expand Down Expand Up @@ -183,7 +183,7 @@ pub fn lossless_compress_png_sync(
}

pub struct LosslessPngTask {
input: Ref<JsBufferValue>,
input: Uint8Array,
options: PNGLosslessOptions,
}

Expand All @@ -200,22 +200,17 @@ impl Task for LosslessPngTask {
fn resolve(&mut self, _env: Env, output: Self::Output) -> Result<Self::JsValue> {
Ok(output.into())
}

fn finally(&mut self, env: Env) -> Result<()> {
self.input.unref(env)?;
Ok(())
}
}

#[napi]
pub fn lossless_compress_png(
input: JsBuffer,
input: Uint8Array,
options: Option<PNGLosslessOptions>,
signal: Option<AbortSignal>,
) -> Result<AsyncTask<LosslessPngTask>> {
Ok(AsyncTask::with_optional_signal(
LosslessPngTask {
input: input.into_ref()?,
input,
options: options.unwrap_or_default(),
},
signal,
Expand All @@ -239,8 +234,8 @@ pub struct PngQuantOptions {
}

#[napi]
pub fn png_quantize_sync(input: Buffer, options: Option<PngQuantOptions>) -> Result<Buffer> {
let output = png_quantize_inner(input.as_ref(), &options.unwrap_or_default())?;
pub fn png_quantize_sync(input: &[u8], options: Option<PngQuantOptions>) -> Result<Buffer> {
let output = png_quantize_inner(input, &options.unwrap_or_default())?;
Ok(output.into())
}

Expand Down Expand Up @@ -301,7 +296,7 @@ fn png_quantize_inner(input: &[u8], options: &PngQuantOptions) -> Result<Vec<u8>
}

pub struct PngQuantTask {
input: Buffer,
input: Uint8Array,
options: PngQuantOptions,
}

Expand All @@ -321,7 +316,7 @@ impl Task for PngQuantTask {

#[napi]
pub fn png_quantize(
input: Buffer,
input: Uint8Array,
options: Option<PngQuantOptions>,
signal: Option<AbortSignal>,
) -> AsyncTask<PngQuantTask> {
Expand Down
Loading

0 comments on commit 2ac81dd

Please sign in to comment.