Skip to content

Commit e86e853

Browse files
authored
Merge pull request #26 from catdad-experiments/libheif-v1.18.0
updating to libheif v1.18.0
2 parents d583276 + 5373d25 commit e86e853

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
node-version: [12, 14, 16, 18, 20]
17+
node-version: [14, 16, 18, 20]
1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424
- run: npm install
@@ -33,10 +33,10 @@ jobs:
3333
needs: test
3434
steps:
3535
- uses: actions/checkout@v4
36-
- name: Use Node.js 14
37-
uses: actions/setup-node@v3
36+
- name: Use Node.js 18
37+
uses: actions/setup-node@v4
3838
with:
39-
node-version: 14
39+
node-version: 18
4040
registry-url: https://registry.npmjs.org/
4141
- run: npm install
4242
- run: npm run fetch

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "libheif-js",
3-
"version": "1.17.1",
3+
"version": "1.18.0",
44
"description": "Emscripten distribution of libheif for Node.JS and the browser",
55
"main": "index.js",
66
"scripts": {

scripts/install.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const gunzip = require('gunzip-maybe');
88

99
const esbuild = require('esbuild');
1010

11-
const version = 'v1.17.1';
11+
const version = 'v1.18.0';
1212

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

40+
// libheif started using optional chaining, which is not
41+
// supported in older versions of node, but we'd like to
42+
// support them here, so transform to a target from before
43+
// https://esbuild.github.io/content-types/#javascript
44+
const target = 'es2019';
45+
4046
for await (const entry of (await getStream(tarball)).pipe(gunzip()).pipe(tar.extract())) {
4147
const basedir = entry.header.name.split('/')[0];
4248

4349
if (entry.header.type === 'file' && ['libheif', 'libheif-wasm'].includes(basedir)) {
4450
const outfile = path.resolve(root, entry.header.name);
4551
console.log(` writing "${outfile}"`);
46-
await fs.outputFile(outfile, await autoReadStream(entry));
52+
53+
let file = await autoReadStream(entry);
54+
55+
if (path.extname(outfile) === '.js') {
56+
const result = await esbuild.transform(file, {
57+
target,
58+
minify: true
59+
});
60+
61+
file = result.code;
62+
}
63+
64+
await fs.outputFile(outfile, file);
4765
} else {
4866
await autoReadStream(entry);
4967
}
@@ -53,6 +71,7 @@ const autoReadStream = async stream => {
5371
entryPoints: [path.resolve(root, 'scripts/bundle.js')],
5472
bundle: true,
5573
minify: true,
74+
target,
5675
external: ['fs', 'path', 'require'],
5776
loader: {
5877
'.wasm': 'binary'

test/libheif.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function runTests(libheif) {
8787
it('is the correct version', () => {
8888
expect(libheif).to.have.property('heif_get_version')
8989
.and.to.be.a('function');
90-
expect(libheif.heif_get_version()).to.equal('1.17.1')
90+
expect(libheif.heif_get_version()).to.equal('1.18.0')
9191
.and.to.equal(pkg.version);
9292
});
9393

0 commit comments

Comments
 (0)