Skip to content

Commit

Permalink
Merge pull request #26 from catdad-experiments/libheif-v1.18.0
Browse files Browse the repository at this point in the history
updating to libheif v1.18.0
  • Loading branch information
catdad authored Jul 28, 2024
2 parents d583276 + 5373d25 commit e86e853
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
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

0 comments on commit e86e853

Please sign in to comment.