Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 13, 2024
1 parent 0effb1b commit 4b91b2a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 47 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ jobs:
fail-fast: false
matrix:
node:
- '18'
- '20'
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -413,10 +412,7 @@ jobs:
with:
image: node:${{ matrix.node }}-slim
options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build'
run: |
set -e
yarn test
ls -la
run: yarn test
test-linux-arm-gnueabihf-binding:
name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
needs:
Expand Down Expand Up @@ -453,10 +449,7 @@ jobs:
with:
image: node:${{ matrix.node }}-bullseye-slim
options: '--platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build'
run: |
set -e
yarn test
ls -la
run: yarn test
test-wasi-on-nodejs:
name: Test wasi on Node.js
runs-on: macos-14
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ resolver = "2"
[profile.release]
lto = 'fat'
codegen-units = 1
strip = 'symbols'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"website"
],
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.36",
"@napi-rs/cli": "^3.0.0-alpha.38",
"@taplo/cli": "^0.7.0",
"@types/node": "^20.11.16",
"@types/sharp": "^0.31.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ libwebp-sys = { version = "0.9", default-features = false, features = ["std", "p
libwebp-sys = { version = "0.9", default-features = false, features = ["std", "parallel"] }

[target.'cfg(target_family = "wasm")'.dependencies]
libavif = { git="https://github.com/Brooooooklyn/libavif-rs.git", rev = "4e108c4", version = "0.12", default-features = false, features = [
libavif = { git="https://github.com/njaard/libavif-rs.git", rev = "678bd68", version = "0.12", default-features = false, features = [
"codec-rav1e",
] }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
libavif = { git="https://github.com/Brooooooklyn/libavif-rs.git", rev = "4e108c4", version = "0.12", default-features = false, features = [
libavif = { git="https://github.com/njaard/libavif-rs.git", rev = "678bd68", version = "0.12", default-features = false, features = [
"codec-aom",
] }

Expand Down
16 changes: 2 additions & 14 deletions packages/binding/__test__/transformer.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ test('should be able to get exif from jpg', async (t) => {
})

test('should be able to encode into webp', async (t) => {
if (process.env.NAPI_RS_FORCE_WASI) {
t.pass()
return
}
const decoder = new Transformer(PNG)
await t.notThrowsAsync(() => decoder.webp(75))
})
Expand All @@ -58,23 +54,15 @@ test('should be able to decode from avif', async (t) => {
})

test('should be able to decode from webp', async (t) => {
if (process.env.NAPI_RS_FORCE_WASI) {
t.pass()
return
}
const decoder = new Transformer(PNG)
const WEBP = await decoder.webpLossless()
const WEBP = await decoder.webp()
const webpDecoder = new Transformer(WEBP)
await t.notThrowsAsync(() => webpDecoder.png())
})

test('should be able to create transformer from raw rgba pixels', async (t) => {
if (process.env.NAPI_RS_FORCE_WASI) {
t.pass()
return
}
const pixels = decode('LEHV6nWB2yk8pyo0adR*.7kCMdnj', 32, 32)
await t.notThrowsAsync(() => Transformer.fromRgbaPixels(pixels, 32, 32).webpLossless())
await t.notThrowsAsync(() => Transformer.fromRgbaPixels(pixels, 32, 32).webp())
})

test('should be able to create transformer from SVG', async (t) => {
Expand Down
10 changes: 7 additions & 3 deletions packages/binding/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,18 @@ switch (platform) {
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
try {
nativeBinding = require('./image.wasi.cjs')
} catch {
// ignore
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
console.error(err)
}
}
if (!nativeBinding) {
try {
nativeBinding = require('@napi-rs/image-wasm32-wasi')
} catch (err) {
console.error(err)
if (process.env.NAPI_RS_FORCE_WASI) {
console.error(err)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/binding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"repository": "git@github.com:Brooooooklyn/Image.git",
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.36",
"@napi-rs/cli": "^3.0.0-alpha.38",
"@napi-rs/wasm-runtime": "^0.1.1"
}
}
35 changes: 18 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -540,27 +540,26 @@ __metadata:
languageName: node
linkType: hard

"@napi-rs/cli@npm:^3.0.0-alpha.36":
version: 3.0.0-alpha.36
resolution: "@napi-rs/cli@npm:3.0.0-alpha.36"
"@napi-rs/cli@npm:^3.0.0-alpha.38":
version: 3.0.0-alpha.38
resolution: "@napi-rs/cli@npm:3.0.0-alpha.38"
dependencies:
"@napi-rs/cross-toolchain": "npm:^0.0.14"
"@octokit/rest": "npm:^20.0.2"
"@tybys/wasm-util": "npm:0.8.1"
clipanion: "npm:^3.2.1"
colorette: "npm:^2.0.20"
debug: "npm:^4.3.4"
emnapi: "npm:0.45.0"
inquirer: "npm:^9.2.12"
emnapi: "npm:1.0.0"
inquirer: "npm:^9.2.13"
js-yaml: "npm:^4.1.0"
lodash-es: "npm:^4.17.21"
semver: "npm:^7.5.4"
toml: "npm:^3.0.0"
typanion: "npm:^3.14.0"
peerDependencies:
"@emnapi/runtime": ^0.45.0
"@tybys/wasm-util": ^0.8.0
emnapi: ^0.45.0
"@emnapi/runtime": ^1.0.0
emnapi: ^1.0.0
peerDependenciesMeta:
"@emnapi/runtime":
optional: true
Expand All @@ -571,7 +570,7 @@ __metadata:
bin:
napi: dist/cli.js
napi-raw: cli.mjs
checksum: 10c0/cbcd0fee9ac93d71e5a56a8a82bd6ffa75e1f51816bf38edee94b88bda611eb281e8f2eb8c415145da1c15d9c56c49f9d65f6d23a92bbf7d4f16d5fff780ad79
checksum: 10c0/f0f4ed480bd2d0c627bc0f1de43bc4b9c5c589c62c78df092ec53b0a4ffa6e4080bca76302e38c1f46099dd6ab9753f9ede3023fc2af3646a6f1fcd375973ed7
languageName: node
linkType: hard

Expand Down Expand Up @@ -616,7 +615,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@napi-rs/image@workspace:packages/binding"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.36"
"@napi-rs/cli": "npm:^3.0.0-alpha.38"
"@napi-rs/wasm-runtime": "npm:^0.1.1"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -4206,15 +4205,17 @@ __metadata:
languageName: node
linkType: hard

"emnapi@npm:0.45.0":
version: 0.45.0
resolution: "emnapi@npm:0.45.0"
"emnapi@npm:1.0.0":
version: 1.0.0
resolution: "emnapi@npm:1.0.0"
dependencies:
node-gyp: "npm:latest"
peerDependencies:
node-addon-api: ">= 6.1.0"
peerDependenciesMeta:
node-addon-api:
optional: true
checksum: 10c0/076411fc611c0e3f1c08a9260babbeac8094474d8a4174e6b9f27dc5ba569b51fd42c2513d17d4056680a680a575fb8c81f18259d7208327b53195bf3f58483b
checksum: 10c0/cd927b47189e313858f68147368685054bd63ad28d371caab821a308d32d571ae7e390f322dfd35c513f33eb8550330a28a4bc65c5c1ed01ba47250a186f0ba1
languageName: node
linkType: hard

Expand Down Expand Up @@ -5699,7 +5700,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "image@workspace:."
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.36"
"@napi-rs/cli": "npm:^3.0.0-alpha.38"
"@taplo/cli": "npm:^0.7.0"
"@types/node": "npm:^20.11.16"
"@types/sharp": "npm:^0.31.1"
Expand Down Expand Up @@ -5828,7 +5829,7 @@ __metadata:
languageName: node
linkType: hard

"inquirer@npm:^9.2.12":
"inquirer@npm:^9.2.13":
version: 9.2.14
resolution: "inquirer@npm:9.2.14"
dependencies:
Expand Down Expand Up @@ -8304,7 +8305,7 @@ __metadata:
languageName: node
linkType: hard

"node-gyp@npm:^10.0.0":
"node-gyp@npm:^10.0.0, node-gyp@npm:latest":
version: 10.0.1
resolution: "node-gyp@npm:10.0.1"
dependencies:
Expand Down

0 comments on commit 4b91b2a

Please sign in to comment.