Skip to content

Commit

Permalink
ci: remove node 14.x
Browse files Browse the repository at this point in the history
  • Loading branch information
nieyuyao committed Apr 10, 2024
1 parent cc21d56 commit b41cbb4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 16 deletions.
27 changes: 23 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ name: CI

on:
push:
branches: [ "main" ]
branches:
- main
- tags
pull_request:
branches: [ "main" ]
branches: ['main']

jobs:
build:
runs-on: ubuntu-latest
environment: release

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -40,4 +43,20 @@ jobs:
run: npm run build:cjs --if-present

- name: test
run: npm run test
run: npm run test

- name: echo
env:
NODE_AUTH_TOKEN: ${{ vars.NPM_TOKEN }}
run: echo $NODE_AUTH_TOKEN

release:
if: ${{ startsWith(github.ref, 'refs/tags') && startsWith(github.ref_name, 'v') }}
runs-on: ubuntu-latest
needs: [build]
environment: release
steps:
- name: release
run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ vars.NPM_PUBLISH_TOKEN }}
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ console.log(version) // 1.3.2

#### encodeRGB

Encodes rgb bitmap an outputs webp.
Encodes rgb bitmap an returns WebP Uint8Array. The `width` and `height` parameters of the bitmap should be provided.

`function encodeRGB(rgb: Uint8Array, width: number, height: number, quality?: number): Promise<Nullable<Uint8Array>>`

Expand Down Expand Up @@ -59,7 +59,7 @@ a.remove()

#### encodeRGBA

Encodes rgba bitmap an outputs webp.
Encodes rgba bitmap an returns WebP Uint8Array.

`function encodeRGBA(rgba: Uint8Array, width: number, height: number, quality?: number): Promise<Nullable<Uint8Array>>`

Expand All @@ -76,7 +76,7 @@ const webpData = await encodeRGBA(imgData.data, canvas.width, canvas.height)

#### encode

A more advanced API is based on the WebPConfig. <b>Only the lossless and quality parameters are supported now !!!</b>.
A more advanced API is based on the WebPConfig. <b>Only the lossless and quality parameters are supported now !!!</b>. You can generate low-quality webp with this function.

`function encodeRGBA(data: Uint8Array, width: number, height: number, hasAlpha: boolean,config: Partial<WebPConfig>): Promise<Nullable<Uint8Array>>`

Expand All @@ -90,7 +90,7 @@ Lossless encoding (0=lossy(default), 1=lossless).

- WebPConfig.quality: number

Between 0 and 100.
Between 0 and 100. Default value is 100.

##### Example

Expand All @@ -105,17 +105,19 @@ const webpData = await encode(imgData.data, canvas.width, canvas.height, true, {

#### encodeAnimation

Encodes frame data an outputs animated webp.
Returns animated WebP like `GIF`.

`function encodeAnimation(width: number, height: number, hasAlpha: boolean, frames: WebPAnimationFrame[]): Promise<Nullable<Uint8Array>>`

- hasAlpha: boolean

Whether to include alpha chanel.

The WebPAnimationFrame has follow properties:

- WebPAnimationFrame.data: Uint8Array

Frame data.
Frame bitmap.

- WebPAnimationFrame.duration: number

Expand Down Expand Up @@ -206,6 +208,24 @@ fr.readAsArrayBuffer(file)
...
```

#### WebPDecodedImageData

The object have the following properties:

- WebPDecodedImageData.width: number

The image width in pixels.

- WebPDecodedImageData.height: number

The image height in pixels.

- WebPDecodedImageData.data: Uint8Array

Raw data in pixels.

> Note: It looks like an `ImageData` object, but it is not. There is actually no `ImageData` in node.
## Playing Examples

```shell
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webp.wasm",
"version": "0.0.1",
"name": "wasm-webp",
"version": "0.0.1-beta.1",
"description": "",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand All @@ -10,9 +10,11 @@
"webp",
"wasm",
"libwebp",
"webp-animation",
"animation",
"encode",
"decode"
"decode",
"WebAssembly",
"canvas"
],
"files": [
"dist"
Expand All @@ -28,8 +30,7 @@
"build-wasm:cjs": "bash ./build.sh",
"build:esm": "npm run build-wasm:esm && tsc -m ES6 --outDir ./dist/esm && cp -r src/*.d.ts dist",
"build:cjs": "npm run build-wasm:cjs && tsc -m commonjs --outDir ./dist/cjs && cp -r src/*.d.ts dist",
"test": "node --experimental-wasm-modules --experimental-vm-modules ./node_modules/jest/bin/jest.js",
"publish": ""
"test": "node --experimental-wasm-modules --experimental-vm-modules ./node_modules/jest/bin/jest.js"
},
"author": "nieyuyao",
"license": "MIT",
Expand Down

0 comments on commit b41cbb4

Please sign in to comment.