feat: add cmx-icc WASM/npm bindings crate#24
Merged
Merged
Conversation
- Add `cmx-icc` workspace crate with `wasm-bindgen` bindings:
- `WasmDisplayProfile` builder with preset constructors (sRGB, Display P3, Adobe RGB)
and flat setters for matrix columns, TRC (gamma and parametric), white point,
chromatic adaptation, and profile metadata
- `WasmProfile` for parsing existing ICC profiles from bytes and re-serializing
- `WasmRenderingIntent` enum bridging Rust and JS representations
- Add 12 `wasm-bindgen-test` integration tests (headless Node.js)
- Expose `Profile::rendering_intent()` publicly in `src/profile.rs`
- Add `[workspace.package]` for lock-step versioning between `cmx` and `cmx-icc`
- Add `cmx-icc/README.md` generated by `cargo rdme` for npm package page
- Add `xtask publish-npm` and `xtask publish-crate` commands replacing manual publish steps
- Update CLAUDE.md release process to document xtask-based publish workflow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use `#[wasm_bindgen(js_name = "...")]` so JS/TS consumers see clean names: - `WasmRenderingIntent` → `RenderingIntent` - `WasmProfile` → `Profile` - `WasmDisplayProfile` → `DisplayProfile` Rust type names are unchanged, so the test suite and internal code are unaffected. Update doc comment examples and API tables in lib.rs to reflect the JS-facing names, and regenerate README.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add introductory context to the crate doc comment explaining that CMX is built on the Rust Colorimetry library and uses spectral representations of light for physically accurate color modelling. Regenerate README.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new workspace crate (cmx-icc) that exposes CMX ICC profile functionality to JavaScript via wasm-bindgen, plus cargo xtask publish commands to standardize crates.io and npm releases with lock-step workspace versioning.
Changes:
- Introduce
cmx-iccWASM/npm bindings with exportedProfile,DisplayProfile, andRenderingIntent, plus Node-basedwasm-bindgen-testcoverage. - Add
cargo xtask publish-npmandcargo xtask publish-crateworkflows and document the new release process. - Add
Profile::rendering_intent()to the core crate and move version/metadata to[workspace.package].
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
xtask/src/main.rs |
Adds publish-npm and publish-crate subcommands plus helpers for workspace-root execution. |
src/profile.rs |
Exposes Profile::rendering_intent() accessor used by WASM bindings. |
cmx-icc/src/lib.rs |
Implements wasm-bindgen API surface for parsing/serializing and building display profiles. |
cmx-icc/tests/bindings.rs |
Adds Node integration tests for presets, round-trips, errors, and builder validation. |
cmx-icc/Cargo.toml |
Defines the new WASM bindings crate and dependencies. |
cmx-icc/README.md |
Generated README content for the npm package page. |
Cargo.toml |
Adds cmx-icc to workspace and centralizes package metadata/version in [workspace.package]. |
Cargo.lock |
Locks new deps pulled in by the WASM crate and tests. |
CLAUDE.md |
Updates documented release workflow to use xtask publishing commands. |
.gitignore |
Ignores the cmx-icc/pkg wasm-pack output directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add language specifier to bare fenced code block (MD040) - Add spaces around table separator pipes (MD060) - Wrap long lines to stay within 120 characters (MD013) - Remove trailing spaces from list items (MD009) - Fix space inside code span `sig ` → `sig` (MD038) README.md fixes applied via src/lib.rs + cargo rdme regeneration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add top-level heading (MD041) - Fix table separator pipe spacing (MD060) Regenerate cmx-icc/README.md via cargo rdme. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- cmx-icc/src/lib.rs: replace .expect() with proper JsError propagation
in set_{red,green,blue}_trc_parametric — invalid param counts now throw
a JS error instead of panicking the WASM instance
- cmx-icc/src/lib.rs: fix intra-doc links to use Rust paths instead of
JS method names (WasmProfile::from_bytes, ::to_bytes,
WasmDisplayProfile::set_profile_description_mluc,
::set_red_trc_parametric) so rustdoc --deny warnings passes
- xtask/src/main.rs: add --all-features/--all-targets to publish-crate
test, clippy, and doc invocations so feature-gated code is exercised
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
harbik
commented
Apr 24, 2026
Owner
Author
harbik
left a comment
There was a problem hiding this comment.
All six issues from the review have been addressed in commit d9d3517:
.expect()panics in parametric TRC setters (3 comments): replaced with anOption<JsError>capture pattern so invalid parameter counts return a JS error instead of crashing the WASM instance.- Intra-doc links using JS names (2 comments): updated to Rust paths (
WasmProfile::from_bytes,WasmProfile::to_bytes,WasmDisplayProfile::set_profile_description_mluc,WasmDisplayProfile::set_red_trc_parametric) sorustdoc --deny warningspasses. - Missing
--all-features/--all-targetsin publish-crate (1 comment): test, clippy, and doc invocations now match thecheckcommand coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cmx-iccworkspace crate exposing ICC profile functionality to JavaScript viawasm-bindgen, published to npm ascmx-iccProfile,DisplayProfile,RenderingIntent) viajs_name— noWasmprefix visible to npm consumerscargo xtask publish-npmandcargo xtask publish-cratecommands, replacing any manual publish stepscmxcrate andcmx-iccnpm package via[workspace.package]What's included
cmx-icc/src/lib.rs— three exported classes:DisplayProfile— preset constructors (srgb,displayP3,adobeRgb) and a flat mutable builder API for custom matrix display profiles (matrix columns, TRC gamma/parametric, white point, chromatic adaptation, metadata)Profile— parse any ICC profile from aUint8Arrayand round-trip serialize it backRenderingIntent— enum bridging Rust and JS representationscmx-icc/tests/bindings.rs— 12wasm-bindgen-testintegration tests (headless Node.js):xtask— two new subcommands:cargo xtask publish-npm [--dry-run]— regenerates README, builds WASM, publishes to npmcargo xtask publish-crate [--dry-run]— runs full check suite, then publishes to crates.ioCLAUDE.md— release process updated to document the xtask-based publish workflowTest plan
cargo test --all-featurespassescargo clippy --all-targets --all-features -- -D warningscleanwasm-pack test cmx-icc --noderuns all 12 bindings testscargo xtask publish-npm --dry-runshows correctpackage.jsoncargo xtask publish-crate --dry-runcompletes all checks🤖 Generated with Claude Code