REBUILDING AND REPLACING THE OPTIONAL PHOTOGRAPH DECODER This page supplies source for the library and the complete small worker that links it. The page adapter uses the worker through postMessage. The browser worker is an independent same-origin file under /photo-decoder/; its content hash is a cache filename, not an integrity/signature check. There is no requirement to rebuild the rest of the notebook to replace this file in a local installation. The library portions may be modified, and reverse engineering to debug those modifications is permitted. You may use the supplied integration source to recombine/relink the application with modified libraries and use that worker. Other third-party license terms remain in effect. This does not grant access to private notebook records or authorize changes to Leifolas's hosted service. 1. GET AND VERIFY THE SOURCES Download each source archive linked by index.html, source-manifest.json and SHA256SUMS to one directory, preserving the sources/ subdirectory. From that directory use "shasum -a 256 -c SHA256SUMS" (macOS) or "sha256sum -c SHA256SUMS" (Linux). Extract the archives. No upstream source code has been changed here. The Emscripten archive omits only test/ to keep the optional download smaller; all runtime code, headers, build scripts and retained notices are included. The pin chain is: libheif-js tag 1.23.5 (d8ec4bc3bc5bf8055975577bccbbc7e1d7313c2d) scripts/install.js -> libheif-emscripten release v1.23.5 libheif-emscripten tag v1.23.5 (5c8968a44e9c68ae677e24790d77d001ed7fe7cc) libheif submodule -> 413e2a87e6a70b3eccc3a3adc5801179dd2d9e00 libheif CMakeLists.txt -> version 1.23.5 build-emscripten.sh -> libde265 release 1.0.15 .github/workflows/emscripten.yml -> Emscripten 3.1.61, Ubuntu 22.04, Node 24, TypeScript 5, USE_WASM=1 USE_UNSAFE_EVAL=0 USE_TYPESCRIPT=1 The unmodified npm package entry used by Leifolas has SHA-256: 095194187be00d3e36335b8ad7f5552d70655e5e2159486d7d36cd4daa47bba9 libheif-js/libheif-wasm/libheif-bundle.mjs 2. REBUILD THE LIBRARY (OPTIONAL WHEN ONLY CHANGING THE WORKER) Use a Linux build environment with the general-purpose tools required by the upstream scripts: CMake, make, autotools, pkg-config, Python, Node 24, TypeScript 5, and Emscripten SDK 3.1.61. Emscripten's separate LLVM/compiler tools are not part of the browser decoder. Setup instructions for the pinned toolchain: https://emscripten.org/docs/getting_started/downloads.html https://github.com/emscripten-core/emsdk Activate Emscripten 3.1.61 and source its emsdk_env.sh. The local Emscripten archive includes the corresponding runtime/source. The complete upstream build workflow is in libheif-emscripten-v1.23.5/.github/workflows/emscripten.yml. It applies the above environment switches to libheif/scripts/run-ci.sh. For a direct out-of-tree build, from the extracted libheif source: mkdir build-wasm cp /path/to/sources/libde265-1.0.15.tar.gz build-wasm/ cd build-wasm USE_WASM=1 USE_UNSAFE_EVAL=0 USE_TYPESCRIPT=1 ../build-emscripten.sh .. The build script uses the supplied libde265 archive when present. For a modified libde265, edit its source/build inputs as needed before rebuilding. The defaults build the libde265 HEVC decoder; AOM, WebCodecs, OpenJPEG and the uncompressed codec are disabled. The resulting files are libheif.js, libheif.wasm and libheif.d.ts. Keep USE_UNSAFE_EVAL=0: the hosted worker policy permits WebAssembly compilation, not JavaScript eval/new Function. To produce the ESM bundle used by the integration, use the supplied libheif-js source's scripts/install.js. Arrange the rebuilt files in a libheif-wasm/ directory (libheif.js, libheif.wasm, libheif.d.ts and the libheif COPYING text as LICENSE), then create a tar.gz containing that directory. In the extracted libheif-js source: npm install --ignore-scripts node scripts/install.js /absolute/path/to/rebuilt-libheif.tar.gz The installer accepts the local archive instead of fetching a release and emits libheif-wasm/libheif-bundle.mjs. This includes the compiled Wasm and JavaScript bindings. The package source contains scripts/bundle.js and all bundle settings. Upstream's source tag uses dependency ranges without a lockfile; these instructions provide a functional source rebuild, not a promise of a byte-for-byte identical upstream release. 3. RECOMBINE WITH THE SUPPLIED APPLICATION WORKER Create an empty working directory and save these files there, with an integration/ subdirectory as shown in the notice page: integration/notebook-heic.worker.ts integration/notebook-photos.ts integration/libheif.d.ts The worker is complete and has one runtime import: the libheif-js ESM bundle. The adapter and declarations explain its calling contract. With a Node version supported by esbuild, in this empty working directory: npm init -y npm install --ignore-scripts --save-exact libheif-js@1.23.5 esbuild@0.28.2 For a changed library, replace node_modules/libheif-js/libheif-wasm/libheif-bundle.mjs with the newly rebuilt ESM bundle from step 2. Then bundle the worker: npx esbuild integration/notebook-heic.worker.ts --bundle --format=esm --platform=browser --target=es2022 --minify --outfile=notebook-heic.worker.js The site's normal build uses Vite's worker bundler; this separate esbuild command produces a functionally equivalent replaceable module without the rest of the site source. Preserve this notice and the library notices with redistributed decoder copies and provide corresponding source for changes. 4. USE OR DEBUG A REPLACEMENT In an installation you control, replace the current /photo-decoder/notebook-heic.worker-.js with your output while retaining that filename, or update the page adapter's worker URL to your new filename. Reload with the browser cache disabled. The worker must be served as JavaScript from the same origin. The worker response's Content-Security-Policy must allow WebAssembly compilation (script-src 'self' 'wasm-unsafe-eval') and any applicable Worker policy must permit same-origin workers. No JavaScript unsafe-eval is needed. Keep origin and cross-origin isolation headers appropriate for your installation. Browser developer tools' local response overrides can also replace the downloaded worker when debugging your own session. Worker request: one ArrayBuffer containing the selected HEIC/HEIF file, sent with postMessage Worker success response: { width: number, height: number, pixels: ArrayBuffer } pixels contains RGBA bytes, width * height * 4 bytes; each output dimension is at most 2048, with the aspect ratio retained. Worker failure response: { error: true } The supplied adapter sends at most 10 MiB, validates the response, and terminates the worker on completion, error, or its 30-second deadline. The worker selects the primary still image, rejects dimensions above 64 million pixels, and resizes before transferring RGBA output. A replacement that preserves this interface can be used by the same application. All image decoding happens in the browser; none of these source or test steps needs access to notebook contents. Source availability is maintained alongside each distributed decoder release. When upgrading the decoder or changing the worker, update the source archives, manifest, integration snapshots, and notices together.