Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating to libheif v1.18.0 #26

Merged
merged 6 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12, 14, 16, 18, 20]
node-version: [14, 16, 18, 20]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand All @@ -33,10 +33,10 @@ jobs:
needs: test
steps:
- uses: actions/checkout@v4
- name: Use Node.js 14
uses: actions/setup-node@v3
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm install
- run: npm run fetch
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libheif-js",
"version": "1.17.1",
"version": "1.18.0",
"description": "Emscripten distribution of libheif for Node.JS and the browser",
"main": "index.js",
"scripts": {
Expand Down
23 changes: 21 additions & 2 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const gunzip = require('gunzip-maybe');

const esbuild = require('esbuild');

const version = 'v1.17.1';
const version = 'v1.18.0';

const base = `https://github.com/catdad-experiments/libheif-emscripten/releases/download/${version}`;
const tarball = `${base}/libheif.tar.gz`;
Expand Down Expand Up @@ -37,13 +37,31 @@ const autoReadStream = async stream => {
await fs.remove(path.resolve(root, 'libheif'));
await fs.remove(path.resolve(root, 'libheif-wasm'));

// libheif started using optional chaining, which is not
// supported in older versions of node, but we'd like to
// support them here, so transform to a target from before
// https://esbuild.github.io/content-types/#javascript
const target = 'es2019';

for await (const entry of (await getStream(tarball)).pipe(gunzip()).pipe(tar.extract())) {
const basedir = entry.header.name.split('/')[0];

if (entry.header.type === 'file' && ['libheif', 'libheif-wasm'].includes(basedir)) {
const outfile = path.resolve(root, entry.header.name);
console.log(` writing "${outfile}"`);
await fs.outputFile(outfile, await autoReadStream(entry));

let file = await autoReadStream(entry);

if (path.extname(outfile) === '.js') {
const result = await esbuild.transform(file, {
target,
minify: true
});

file = result.code;
}

await fs.outputFile(outfile, file);
} else {
await autoReadStream(entry);
}
Expand All @@ -53,6 +71,7 @@ const autoReadStream = async stream => {
entryPoints: [path.resolve(root, 'scripts/bundle.js')],
bundle: true,
minify: true,
target,
external: ['fs', 'path', 'require'],
loader: {
'.wasm': 'binary'
Expand Down
2 changes: 1 addition & 1 deletion test/libheif.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function runTests(libheif) {
it('is the correct version', () => {
expect(libheif).to.have.property('heif_get_version')
.and.to.be.a('function');
expect(libheif.heif_get_version()).to.equal('1.17.1')
expect(libheif.heif_get_version()).to.equal('1.18.0')
.and.to.equal(pkg.version);
});

Expand Down