Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ env:

jobs:
# Whether the change is more than documentation. A pull request that only
# changes Markdown files and the pictures under docs/ skips the jobs that
# build and run the code; the lint job still checks the documents' figures and
# copies. A push to main runs everything.
# changes Markdown files, other than the npm package's README, and the
# pictures under docs/ skips the jobs that build and run the code; the lint
# job still checks the documents' figures and copies. A push to main runs
# everything.
changes:
name: what changed
runs-on: ubuntu-latest
Expand All @@ -42,8 +43,11 @@ jobs:
echo "code=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Everything that is not a Markdown file or a picture of docs/.
other=$(git diff --name-only "$BASE...$HEAD" | grep -v -E '(\.md$|^docs/images/)' || true)
# Everything that is not a Markdown file or a picture of docs/, and
# the npm package's README, which ships in the package and which
# its build checks (decision D76).
other=$(git diff --name-only "$BASE...$HEAD" |
awk '/^crates\/emberwave-web\/npm\// || !/(\.md$|^docs\/images\/)/')
if [ -n "$other" ]; then
echo "code=true" >> "$GITHUB_OUTPUT"
echo "changed beyond the documentation:"
Expand Down Expand Up @@ -138,6 +142,12 @@ jobs:
# broken one would otherwise show only once it is published.
- run: scripts/build_web.sh
- run: node scripts/check_web.mjs
# The same module as an npm package, ready to publish but not published
# (decision D76): what it would ship, and that it installs from its
# archive and instantiates as a page's dependency. The build above
# leaves cargo nothing to do.
- run: scripts/build_npm.sh
- run: scripts/check_npm.sh

build-test:
needs: changes
Expand Down
21 changes: 21 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ The player also decodes a stream packet by packet, as a client of a live stream

CI builds the module as Pages does and instantiates it in Node (`scripts/check_web.mjs`), so that a module whose glue does not load fails a pull request rather than the published page. The check also encodes two of the demo's pictures and splits a frame with `packet_ends`.

The same module is also built as an npm package for other pages, with TypeScript declarations (`scripts/build_npm.sh`, decision D76). It is ready to publish and not published. CI checks it as a page's project would take it: packed, installed from the archive, imported by its name, and then put through the same check.

## C API

`crates/emberwave-ffi` is the decoder and the GPU encoder for C programs. It builds a shared library (and, for releases, a static one) with the functions of `include/emberwave.h`, which cbindgen generates from `src/lib.rs`; `tests/header.rs` fails when the committed header falls behind the source. [`crates/emberwave-ffi/README.md`](crates/emberwave-ffi/README.md) is the guide for C programmers. The objects are those of the Rust API:
Expand Down Expand Up @@ -1937,3 +1939,22 @@ The last frame's detail, always, gains everything on a still picture and loses u

**Consequence.** The checklist item "stable C and Rust APIs" in the README can close when the library's name carries its version and the split has landed, or earlier, if the maintainer decides to ship 1.0 with option 1's plain statement instead; the data above is what that choice would weigh. No code moves with this entry.

### 2026-11-24 — D76: The browser player as an npm package

**Context.** The README's checklist for 1.0.0 lists packages, and the browser had none. D74 left it to the web build: a page other than the player's own took the module by building emberwave, or by copying `web/pkg/` from a build, which has no TypeScript declarations. npm is where a web project looks for such a module. Publishing there, as on crates.io (D74), is the maintainer's call: a version once published cannot be published again, even after it is unpublished, and the first publish takes the name.

**Decision.** The module is built as an npm package, ready to publish, and not published.
- `scripts/build_npm.sh` builds the crate as `scripts/build_web.sh` does and runs wasm-bindgen with the pages' target, `--target web`, this time with TypeScript declarations, into `target/npm/emberwave-web/`. It adds a `package.json`, the package's README (`crates/emberwave-web/npm/README.md`, with examples that use the module's real API) and copies of `LICENSE` and `THIRD_PARTY_NOTICES.md` made at build time, so `scripts/check_license_copies.sh` has no new copy to keep equal. `emberwave_web_bg.wasm.d.ts`, which declares the wasm's raw exports for importing the wasm directly, does not ship.
- `package.json`: the crate's version, which is the workspace's; `"type": "module"`; `main`, `module` and `types` on the glue and its declarations; `exports` with `.` (declarations, then the glue), the wasm file, for a page whose bundler needs the file's URL to pass to `init`, and `package.json`; `files` naming the six files that ship beside it; `"sideEffects": false`, as the glue only defines its exports when imported; MIT, the repository with the crate's directory, keywords. It has no dependencies. In 0.19.0 the archive is 200.4 kB, 659.6 kB unpacked, of which the wasm is 551.8 kB.
- The pages' target, so that the package is the module the pages test, and a page uses it as `web/main.js` uses `web/pkg/`: `init()` fetches the wasm from beside the module, or takes the file or its URL, so the wasm needs no bundler's help; a page without a bundler maps the package's name to the glue with an import map. Not chosen: `--target bundler`, whose module imports the wasm as an ES module and needs a bundler that supports that (webpack's async WebAssembly, a plugin for Vite), and wasm-pack, which writes a `package.json` too but is one more tool to install and pin for what wasm-bindgen and a few lines of shell do.
- The paths of the source files, which panic messages name and which on a personal machine lie under the user's home directory (16 of them in the first build here), are remapped: the home directory to `/home`, cargo's sources to `/cargo`, the repository to `/emberwave`, so that a package built on the maintainer's machine says nothing about it. `build_npm.sh` fails if the wasm still names the home directory, cargo's sources, the repository or the target directory. `scripts/build_web.sh` builds with the same flags, so that the pages' wasm and the package's are the same bytes and cargo builds them once; the pages' panic messages name the remapped paths where they named the CI runner's.
- `scripts/check_npm.sh` prints what `npm pack --dry-run` lists, packs the package, installs the archive into a scratch project offline, as a page's project would take it, and runs `scripts/check_web.mjs` on that project. Given a project, the check finds the package's files through its `exports`, checks that they are exactly those of `files`, that `type` is `module`, that every path of `main`, `module`, `types` and `exports`, under every condition, is one of them, that `exports` gives the declarations first and the same as `types`, and that they declare the module's exports; it then imports the package by its name from a module in the project, through Node's ES module resolution, and puts it through the checks of the pages' module. CI's wasm job runs both scripts after the pages' build, when cargo has nothing left to build; the check took about a second on an Apple M3 Max. CI does not take the package's README for documentation, though it is Markdown: a pull request that changes it alone runs the jobs that build the code, as for any other change.

**The name, which the maintainer confirms before the first publish.** Proposed: `emberwave-web`, without a scope. It is the crate's name, it sits beside `emberwave-core` and `emberwave-cli` on crates.io, it is the shortest to install, and it needs only the maintainer's npm account. On 2026-11-24 the registry had no package `emberwave-web` or `emberwave`, and no scope `@with-developer` ("Scope not found"). Not chosen, and the maintainer's to prefer: `@with-developer/emberwave-web`, which ties the name to the GitHub organisation and under which no one else can publish, but needs an npm organisation `with-developer` made first, and a first publish with `--access public`. The name is `NAME` in `scripts/build_npm.sh` and the package's README's examples, which the script checks agree; the READMEs and this entry name it too.

**Not done.** Nothing is published: no npm account, organisation or token was made, and no name is held on the registry. `npm publish --dry-run`, without a login, is as far as it went. The release workflow does not publish to npm. Not tried here: a bundler building a page with the package, and a TypeScript compiler on the declarations (the check reads them as text); the module in a browser is what the player's page shows.

**Consequence.**
- A release can publish the package after the maintainer's approval, which holds for one version, as for the crates (`CONTRIBUTING.md`): `scripts/build_npm.sh`, `scripts/check_npm.sh`, `npm publish target/npm/emberwave-web`. npm's Trusted Publishing from the release workflow would publish without a long-lived token; it is not set up.
- The package's API is the module's: a change to `Player`, `Demo`, `Bench` or `packet_ends` changes it. The package carries emberwave's version, but the 1.0 promise is for the C and Rust APIs; whether it covers this one is open.
- To revert, remove the two scripts, the package's README, the two CI steps, the README's exception in CI's documentation filter, the project argument of `scripts/check_web.mjs` and the remapped paths of `scripts/build_web.sh`; nothing outside the repository changed.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to emberwave. The format follows [Keep a Changelog](https://

## [Unreleased]

### Added
- The browser player's module as an npm package, ready to publish and not published (decision D76): `scripts/build_npm.sh` builds it into `target/npm/emberwave-web`, with TypeScript declarations and a README for web pages, and `scripts/check_npm.sh`, which CI runs, installs its archive into a scratch project and checks it there. The name proposed for npm is `emberwave-web`; the maintainer confirms it before the first publish. The package and the pages' module are built with the source paths that panic messages name remapped, so that the wasm names no directory of the machine that built it.

### Changed
- **A change for Rust users of the GPU decoder and encoder**: they are the crate `emberwave-wgpu` now, `emberwave_wgpu::Decoder` where it was `emberwave_core::gpu::Decoder`, with the same names, and `emberwave_wgpu::wgpu` where it was `emberwave_core::wgpu`. `emberwave-core` has no `gpu` feature and no wgpu in its dependencies or its API, so that its version need not follow wgpu's (decision D75). The C API, the CLI and the browser player do not change. `emberwave-wgpu` is not on crates.io yet.

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ On Linux with a Vulkan loader from 1.3.284 to 1.4.344 (Debian 13, Ubuntu 25.04 t

After a deliberate change to what the encoder writes, `scripts/gen_encoder_vectors.sh` makes its vectors again (macOS), and `scripts/gen_encoder_weights.py` writes its weight table, which is generated rather than written by hand. After a change to the C API, `EMBERWAVE_BLESS=1 cargo test -p emberwave-ffi --test header` writes `crates/emberwave-ffi/include/emberwave.h` anew; commit it with the change. `scripts/check_c_example.sh` needs CMake and a C compiler, and `cargo build -p emberwave-ffi -p emberwave-cli` first. `scripts/build_xcframework.sh` builds the XCFramework for iOS and macOS on a Mac with Xcode, after `rustup target add aarch64-apple-ios aarch64-apple-ios-sim`; `scripts/build_xcframework.sh macos-arm64` builds the Mac's library alone, which needs no extra target. `scripts/check_xcframework.sh target/debug/emberwave-cli` then checks what was built, the iOS Simulator's library in a simulator, which needs an iOS Simulator runtime (Xcode > Settings > Components).

`scripts/build_web.sh` builds the browser player into `web/` (it needs `rustup target add wasm32-unknown-unknown` and `cargo install wasm-bindgen-cli` at the version of the `wasm-bindgen` crate in `Cargo.lock`), and `node scripts/check_web.mjs` then checks that the module instantiates, as CI does; serve `web/` with any static file server, for example `python3 -m http.server -d web 8000`, and open it in a browser with WebGPU. `scripts/verify_4k.sh` is the 4K acceptance check, and [`BENCHMARKS.md`](BENCHMARKS.md) explains the benchmark scripts. Two leak checks run on request, both on the 4K stream of `scripts/gen_bench_data.sh`: `cargo test --release -p emberwave-wgpu --test gpu -- --ignored` counts the GPU resources over 1000 frames, and `scripts/soak.sh` watches the memory of `emberwave-cli` over as many. The README is in English, `README.md`, and in Korean, `README.ko.md` (decision D50): change both together. Write the Korean as Korean prose rather than a sentence-by-sentence translation of the English: the same facts, numbers and links, in sentences built the Korean way. `scripts/bench.sh` rewrites the summary of the benchmarks in each. `scripts/readme_figures.py` draws the READMEs' banner and charts into `docs/images/`, and CI checks that the files are what it draws. Their numbers are copied from `BENCHMARKS.md`, as are those of the READMEs' highlights and of the figures' alt texts: when a benchmark run changes them, change them in the script and in both READMEs and run the script again. `scripts/quality_figure.py` makes the READMEs' picture of the quality, `docs/images/quality.png`, and the first table of [Picture quality](BENCHMARKS.md#picture-quality), by hand: it needs the frame, which the repository does not have, numpy, Pillow and a release build of `emberwave-cli`. The HEVC table there comes from a scratch program that was not kept. The quality numbers are also copied into both READMEs' paragraph and alt text and into decision D49: change them together.
`scripts/build_web.sh` builds the browser player into `web/` (it needs `rustup target add wasm32-unknown-unknown` and `cargo install wasm-bindgen-cli` at the version of the `wasm-bindgen` crate in `Cargo.lock`), and `node scripts/check_web.mjs` then checks that the module instantiates, as CI does; serve `web/` with any static file server, for example `python3 -m http.server -d web 8000`, and open it in a browser with WebGPU. `scripts/build_npm.sh` builds the same module as an npm package into `target/npm/emberwave-web` (it also needs Node), and `scripts/check_npm.sh` lists what the package would ship, installs its archive into a scratch project and runs `check_web.mjs` on it there, as CI does (decision D76). `scripts/verify_4k.sh` is the 4K acceptance check, and [`BENCHMARKS.md`](BENCHMARKS.md) explains the benchmark scripts. Two leak checks run on request, both on the 4K stream of `scripts/gen_bench_data.sh`: `cargo test --release -p emberwave-wgpu --test gpu -- --ignored` counts the GPU resources over 1000 frames, and `scripts/soak.sh` watches the memory of `emberwave-cli` over as many. The README is in English, `README.md`, and in Korean, `README.ko.md` (decision D50): change both together. Write the Korean as Korean prose rather than a sentence-by-sentence translation of the English: the same facts, numbers and links, in sentences built the Korean way. `scripts/bench.sh` rewrites the summary of the benchmarks in each. `scripts/readme_figures.py` draws the READMEs' banner and charts into `docs/images/`, and CI checks that the files are what it draws. Their numbers are copied from `BENCHMARKS.md`, as are those of the READMEs' highlights and of the figures' alt texts: when a benchmark run changes them, change them in the script and in both READMEs and run the script again. `scripts/quality_figure.py` makes the READMEs' picture of the quality, `docs/images/quality.png`, and the first table of [Picture quality](BENCHMARKS.md#picture-quality), by hand: it needs the frame, which the repository does not have, numpy, Pillow and a release build of `emberwave-cli`. The HEVC table there comes from a scratch program that was not kept. The quality numbers are also copied into both READMEs' paragraph and alt text and into decision D49: change them together.

## Test vectors and acceptance bars

Expand All @@ -73,7 +73,7 @@ After a deliberate change to what the encoder writes, `scripts/gen_encoder_vecto
- **No "fix later" comments.** Open an issue instead.
- **New dependencies** need a reason in the pull request.
- **The C API's structs.** A struct the C API takes or fills in through a pointer starts with `struct_size` (decision D69). A member is added at the end, only, and its zero is its default; the struct's `FIRST_SIZE` stays the size it had before. The calls read and write a struct through `read_struct` and `write_struct`, never by dereferencing the pointer.
- **A release** changes the version in `Cargo.toml` and `EMBERWAVE_VERSION_MAJOR`, `_MINOR`, `_PATCH` and `EMBERWAVE_VERSION` in `crates/emberwave-ffi/src/lib.rs` together, as the build fails otherwise, and regenerates the header. Once its tag's release is out, `cargo publish -p emberwave-core` and then `cargo publish -p emberwave-cli` put the two crates on crates.io; `emberwave-ffi` and `emberwave-web` are not published. Since D75 `emberwave-cli` depends on `emberwave-wgpu`, which is `publish = false` until the maintainer takes its name on crates.io: until then neither crate is published (publish `emberwave-core` alone and the cli cannot follow), and then the order is core, wgpu, cli, with `emberwave-wgpu` added to `scripts/check_license_copies.sh`. The first release after the split is a minor version, as `emberwave_core::gpu` and the `gpu` feature are gone. The release workflow packages the C library with `scripts/package_ffi.sh`, which gives the shared library the versioned name it carries (D75); at the 1.0.0 release the `.so.0` and `.0.dylib` that `crates/emberwave-ffi/README.md` names become `.so.1` and `.1.dylib`. `LICENSE` and `THIRD_PARTY_NOTICES.md` are copied into both crates, and `scripts/check_license_copies.sh` (a step of the lint job) checks that they are the root's, so a change to either goes into the copies too.
- **A release** changes the version in `Cargo.toml` and `EMBERWAVE_VERSION_MAJOR`, `_MINOR`, `_PATCH` and `EMBERWAVE_VERSION` in `crates/emberwave-ffi/src/lib.rs` together, as the build fails otherwise, and regenerates the header. Once its tag's release is out, `cargo publish -p emberwave-core` and then `cargo publish -p emberwave-cli` put the two crates on crates.io; the crates `emberwave-ffi` and `emberwave-web` are not published. The browser player's npm package (D76) is not published yet. Once the maintainer approves, for one version at a time as for the crates, it would be published from the tag: `scripts/build_npm.sh`, `scripts/check_npm.sh`, then `npm publish target/npm/emberwave-web` by the maintainer's own npm login. The first publish takes the package's name on npm, which the maintainer confirms before it (`NAME` in `build_npm.sh` and the package's README). Since D75 `emberwave-cli` depends on `emberwave-wgpu`, which is `publish = false` until the maintainer takes its name on crates.io: until then neither crate is published (publish `emberwave-core` alone and the cli cannot follow), and then the order is core, wgpu, cli, with `emberwave-wgpu` added to `scripts/check_license_copies.sh`. The first release after the split is a minor version, as `emberwave_core::gpu` and the `gpu` feature are gone. The release workflow packages the C library with `scripts/package_ffi.sh`, which gives the shared library the versioned name it carries (D75); at the 1.0.0 release the `.so.0` and `.0.dylib` that `crates/emberwave-ffi/README.md` names become `.so.1` and `.1.dylib`. `LICENSE` and `THIRD_PARTY_NOTICES.md` are copied into both crates, and `scripts/check_license_copies.sh` (a step of the lint job) checks that they are the root's, so a change to either goes into the copies too.

## Commits and pull requests

Expand Down
Loading
Loading