Provide a decoder for JBIG2 images based on the pdfium library.
Run:
node build.js --compile --output my_output_dirThis builds the Docker image using Docker's layer cache, then writes jbig2.js, jbig2.wasm and jbig2_nowasm_fallback.js to my_output_dir.
jbig2.wasm contains a build_info custom section with a JSON object describing the build: the pdfium revision (pdfium), the revision of this repository (repo, suffixed with -dirty if there were local changes), the Emscripten version (emscripten) and the compile flags (flags). It can be read with:
const module = await WebAssembly.compile(bytes);
const [section] = WebAssembly.Module.customSections(module, "build_info");
const buildInfo = JSON.parse(new TextDecoder().decode(section));To update pdfium, change the commit hash in Dockerfile and run:
node build.js --compile --output my_output_dirUse node build.js --create to build only the Docker image.
Pushing a version tag (e.g. v1.2.3) runs the Release workflow: it builds the decoder and opens a pull request in pdf.js updating external/jbig2/, titled "Update JBIG2 decoder to version 1.2.3":
git tag v1.2.3
git push origin v1.2.3The workflow refuses to replace a decoder in pdf.js that was built from a revision which isn't an ancestor of the tagged one, so that retrying an old tag can't revert a newer release.
The workflow runs in the release environment, which must provide the CLIENT_ID and APP_PRIVATE_KEY secrets of a GitHub App installed on mozilla/pdf.js with read and write access to contents and pull requests.
The code is released under Apache-2.0.