# Third-party notices

## libheif-js 1.23.5

- Package: `libheif-js` 1.23.5, licensed `LGPL-3.0`.
- Copyright/author: Kiril Vatev (`vatev.1@gmail.com`); package metadata names Kiril Vatev as author. The full LGPLv3 supplement is in [LGPL-3.0.txt](LGPL-3.0.txt); the accompanying GPLv3 terms it incorporates are in [GPL-3.0.txt](GPL-3.0.txt).
- JavaScript wrapper source: https://github.com/catdad-experiments/libheif-js/tree/d8ec4bc3bc5bf8055975577bccbbc7e1d7313c2d (tag `1.23.5`). Published package: https://registry.npmjs.org/libheif-js/-/libheif-js-1.23.5.tgz.
- WASM build/release source: https://github.com/catdad-experiments/libheif-emscripten/tree/5c8968a44e9c68ae677e24790d77d001ed7fe7cc (tag `v1.23.5`). Its `.github/workflows/emscripten.yml` pins Emscripten to `3.1.61`; its `libheif` submodule pins the C/C++ source to `413e2a87e6a70b3eccc3a3adc5801179dd2d9e00`.
- Exact libheif source archive: https://github.com/strukturag/libheif/archive/413e2a87e6a70b3eccc3a3adc5801179dd2d9e00.tar.gz. Includes bindings (`post.js`), build scripts and license terms. The GPL text here is copied verbatim from that revision's `COPYING`.
- Included HEVC codec source: libde265 `1.0.15`, tag commit `17bb8d9fcea62db8cdeb0fc7ef8d15dbd19a22e4`, https://github.com/strukturag/libde265/releases/download/v1.0.15/libde265-1.0.15.tar.gz. It is LGPLv3; retain its copyright and license notices too. The pinned libheif build script downloads and statically links this version. Optional AOM, OpenJPEG, WebCodecs and uncompressed codecs are disabled in this build.

### Source-to-WASM build recipe

`bun install --frozen-lockfile` installs the published binary; it is **not** a source build. To build a modified replacement, use the following recipe in a separate build directory on Linux with Git, Bash, curl, tar, CMake, Make, autoconf, automake, libtool, Python 3 and Node.js available. The compiler is Emscripten `3.1.61`; the source and codec versions are pinned below. Upstream built on Ubuntu 22.04. No global npm installation is needed.

```sh
git clone --branch v1.23.5 https://github.com/catdad-experiments/libheif-emscripten.git
git -C libheif-emscripten checkout 5c8968a44e9c68ae677e24790d77d001ed7fe7cc
git -C libheif-emscripten submodule update --init --recursive

git clone --branch 3.1.61 https://github.com/emscripten-core/emsdk.git
./emsdk/emsdk install 3.1.61
./emsdk/emsdk activate 3.1.61
. ./emsdk/emsdk_env.sh
npm install --prefix build-tools --no-save --package-lock=false typescript@5.5.4 esbuild@0.19.5
export PATH="$PWD/build-tools/node_modules/.bin:$PATH"

mkdir build-wasm
cd build-wasm
ENABLE_LIBDE265=1 LIBDE265_VERSION=1.0.15 \
ENABLE_AOM=0 ENABLE_OPENJPEG=0 ENABLE_WEBCODECS=0 ENABLE_UNCOMPRESSED=0 \
USE_WASM=1 USE_UNSAFE_EVAL=0 USE_TYPESCRIPT=1 USE_ES6=0 STANDALONE=0 DEBUG=0 \
  ../libheif-emscripten/libheif/build-emscripten.sh ../libheif-emscripten/libheif
cd ..

mkdir replacement
./build-tools/node_modules/.bin/esbuild build-wasm/libheif.js \
  --target=es2019 --minify --outfile=replacement/libheif.js
cp build-wasm/libheif.wasm build-wasm/libheif.d.ts replacement/
```

Make source changes in `libheif-emscripten/libheif` before invoking `build-emscripten.sh`. To change libde265, unpack the pinned release into `build-wasm/libde265-1.0.15`, modify it before the build and retain that modified source. The script builds the static codec and libheif, then runs `emcc` with `post.js` to produce separate `libheif.js` and `libheif.wasm` files. The final esbuild step mirrors the ES2019/minification transform in the pinned wrapper's `scripts/install.js`; it does not bundle WASM. The upstream wrapper has no dependency lockfile, so this recipe pins its transform tool explicitly rather than claiming byte-identical glue output from an unpinned upstream install.

### Separate assets and replaceability

The application imports `libheif-wasm/libheif.js` and `libheif-wasm/libheif.wasm` as Vite URL assets from the dynamically loaded `heicDecoder` module. Only HEIC/HEIF inputs load the glue; the factory receives the standalone WASM bytes and its URL via `locateFile`. Vite emits distinct glue and WASM assets rather than the upstream `wasm-bundle` variant.

To use the source build above, copy `replacement/libheif.wasm` to this application's `node_modules/libheif-js/libheif-wasm/libheif.wasm` before `bun run build`. If the replacement changes the Emscripten ABI, also copy `replacement/libheif.js` to `node_modules/libheif-js/libheif-wasm/libheif.js`. A WASM-only replacement must preserve the existing glue ABI. Keep the loader wiring and check that the built glue and WASM remain separately addressable. Replacing a deployed hashed asset also requires updating its URL in the decoder chunk; rebuilding avoids that manual step.

Redistributions must retain the LGPL and GPL texts, copyright notices, the exact corresponding source (including modifications and linked codec source), build instructions and replacement instructions. Preserve recipients' ability to modify/relink the decoder, including reverse engineering for debugging those modifications. Do not describe the npm binary archive as corresponding C/C++ source. State the LGPL dependency and these obligations in the PR. Counsel sign-off remains required before production rollout.
