From 88a1ca875f9d177eec055d05c8fbfd015ee4f669 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Tue, 5 May 2026 13:08:57 -0700 Subject: [PATCH 1/4] docs: Update wasm-bindgen version, fix links, etc --- packages/c2pa-wasm/README.md | 35 +++++++++++++++++++++++++---------- packages/c2pa-web/README.md | 16 +++++++++++----- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/packages/c2pa-wasm/README.md b/packages/c2pa-wasm/README.md index 672278e..d1189e3 100644 --- a/packages/c2pa-wasm/README.md +++ b/packages/c2pa-wasm/README.md @@ -12,15 +12,23 @@ npm install @contentauth/c2pa-wasm ### Prerequisites -Ensure the repo-wide prerequisites ([Node.js](https://nodejs.org/) v22+, [NX](https://nx.dev/getting-started/intro), and [pnpm](https://pnpm.io/)) are installed. See the [top-level README](https://github.com/contentauth/c2pa-js#prerequisites) for details. +Ensure the repo-wide prerequisites are installed.: -Then, all of the following prerequisites must be installed before `c2pa-wasm` can be built: +- ([Node.js](https://nodejs.org/) v22+ +- [NX](https://nx.dev/getting-started/intro) +- [pnpm](https://pnpm.io/)) -#### Rust +See the [c2pa-js README](../../README.md#prerequisites) for details. + +Then, install all of the following prerequisites: -[Installation instructions](https://www.rust-lang.org/tools/install) +- [Rust](#rust) +- [wasm-bindgen-cli](#wasm-bindgen-cli) +- [wasm-pack](#wasm-pack) + +#### Rust -Minimum supported Rust version: **1.88.0**. +The minimum supported Rust version is **1.88.0**. To install Rust via [rustup](https://rustup.rs/): @@ -28,7 +36,9 @@ To install Rust via [rustup](https://rustup.rs/): curl https://sh.rustup.rs -sSf | sh ``` -Additionally, the `wasm32-unknown-unknown` target must be installed: +For more information, see [Install Rust](https://www.rust-lang.org/tools/install). + +Additionally, you must install the `wasm32-unknown-unknown` target: ```sh rustup target add wasm32-unknown-unknown @@ -36,22 +46,27 @@ rustup target add wasm32-unknown-unknown #### wasm-bindgen-cli -[Documentation](https://wasm-bindgen.github.io/wasm-bindgen/reference/cli) +The `wasm-bindgen-cli` provides options to tweak JavaScript generated by `wasm-bingen`. + +For more information, see the [wasm-bindgen-cli documentation](https://wasm-bindgen.github.io/wasm-bindgen/reference/cli). ```sh -cargo install wasm-bindgen-cli@0.2.114 +cargo install wasm-bindgen-cli@0.2.120 ``` -> **Important:** The version of `wasm-bindgen-cli` **must** match the version of the `wasm-bindgen` dependency in [`Cargo.toml`](./Cargo.toml). A version mismatch will cause build failures with errors like _"rust Wasm file schema version: X.X.X, this binary schema version: Y.Y.Y"_. If you encounter this, check `Cargo.toml` for the correct version and reinstall the CLI accordingly. +> [!IMPORTANT] +> The version of `wasm-bindgen-cli` **must** match the version of the `wasm-bindgen` dependency in [`Cargo.toml`](./Cargo.toml). A version mismatch will cause build failures with errors like _"rust Wasm file schema version: X.X.X, this binary schema version: Y.Y.Y"_. If you encounter this, check `Cargo.toml` for the correct version and reinstall the CLI accordingly. #### wasm-pack -[Documentation](https://rustwasm.github.io/docs/wasm-pack/) +Wasm-pack is a tool for building and working with Rust-generated WebAssembly that interoperates with JavaScript. ```sh cargo install wasm-pack@0.13.1 ``` +For more information, see the [wasm-pack documentation](https://rustwasm.github.io/docs/wasm-pack/). + ### Building To build the library: diff --git a/packages/c2pa-web/README.md b/packages/c2pa-web/README.md index b9172bd..a52e5a9 100644 --- a/packages/c2pa-web/README.md +++ b/packages/c2pa-web/README.md @@ -12,7 +12,7 @@ npm install @contentauth/c2pa-web ## Importing the library -There are two ways to import the library, due to [specific requirements](https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Loading_and_running) for handling Wasm modules: +Due to [specific requirements](https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Loading_and_running) for handling Wasm modules, there are two ways to import the library: - Using a separate Wasm binary, which provides better performance. - Using an inline Wasm binary, which is more convenient. @@ -22,7 +22,7 @@ There are two ways to import the library, due to [specific requirements](https:/ The recommended way to import the library is to fetch the Wasm binary over the network at runtime. This requires that the Wasm binary be hosted separately. -With Vite: +Use a solution appropriate to your tooling; for example, using Vite: ```typescript import { createC2pa } from '@contentauth/c2pa-web'; @@ -32,7 +32,7 @@ import wasmSrc from '@contentauth/c2pa-web/resources/c2pa.wasm?url'; const c2pa = createC2pa({ wasmSrc }); ``` -Use a solution appropriate to your tooling. Alternatively, you can request the binary from a CDN: +Alternatively, you can request the binary from a CDN: ```typescript import { createC2pa } from '@contentauth/c2pa-web'; @@ -288,9 +288,15 @@ For the full list, see the [API reference](https://contentauth.github.io/c2pa-js ### Prerequisites -Ensure the repo-wide prerequisites ([Node.js](https://nodejs.org/) v22+, [NX](https://nx.dev/getting-started/intro), and [pnpm](https://pnpm.io/)) are installed. See the [top-level README](https://github.com/contentauth/c2pa-js#prerequisites) for details. +Ensure the repo-wide prerequisites are installed.: -[`c2pa-wasm`'s prerequisites](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-wasm#prerequisites) must also be installed. +- ([Node.js](https://nodejs.org/) v22+ +- [NX](https://nx.dev/getting-started/intro) +- [pnpm](https://pnpm.io/)) + +See the [c2pa-js README](../../README.md#prerequisites) for details. + +Then, install [the additional prerequisites for `c2pa-wasm`](../c2pa-wasm/README.md#prerequisites). ### Building From 249bad09718519c343f1c7f944df01980db3c004 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Tue, 5 May 2026 13:22:01 -0700 Subject: [PATCH 2/4] docs: Copy edits and clean up --- README.md | 91 ++++++++++++++++++------------------- packages/c2pa-web/README.md | 2 +- 2 files changed, 44 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 6e01c65..ea619d5 100644 --- a/README.md +++ b/README.md @@ -1,105 +1,100 @@ # c2pa-js > [!NOTE] -> Looking for the old `c2pa-js` repo? It's available [here](https://github.com/contentauth/c2pa-js-legacy) as `c2pa-js-legacy`. Those packages are now deprecated and implementors wishing to interact with C2PA metadata on the web should use the libraries in this repo instead. +> The old `c2pa-js` repository is now in [c2pa-js-legacy](https://github.com/contentauth/c2pa-js-legacy) and is deprecated. If you need to work with C2PA metadata in the browser, use the libraries in this repository instead. -A collection of libraries and tools that enable interaction with [C2PA metadata](https://c2pa.org/) in JavaScript. Part of the [Content Authenticity Initiative](https://contentauthenticity.org/). +JavaScript libraries and tools for working with [C2PA metadata](https://c2pa.org/). This repository is part of the [Content Authenticity Initiative](https://contentauthenticity.org/). -## Using This Monorepo +## Using this monorepo -This monorepo is managed by [NX](https://nx.dev/getting-started/intro) and [pnpm](https://pnpm.io/). +This monorepo uses [Nx](https://nx.dev/getting-started/intro) and [pnpm](https://pnpm.io/). ### Prerequisites -The following must be installed before working with this monorepo: +Install the following before you work in this repository. #### Node.js -Node.js **v22 or later** is required (earlier versions may fail with build errors related to unknown file extensions). +Node.js **v22 or later** is required. Older versions may fail to build because of unrecognized file extensions. -If you use [nvm](https://github.com/nvm-sh/nvm), you can install the required version with: +If you use [nvm](https://github.com/nvm-sh/nvm), install a supported v22 release (for example, `nvm install 22` or `nvm install 22.22.0`). -```sh -nvm install -nvm install 22.22.0 -``` - -#### pnpm and NX +#### pnpm and Nx -Install pnpm and NX. +Install `pnpm` and the Nx CLI globally: ```sh npm install -g pnpm npm install -g nx ``` -#### Rust Toolchain (for building `c2pa-wasm`) +#### Rust toolchain for building `c2pa-wasm` -If you plan to build from source (rather than only consuming published packages), the Rust toolchain and additional prerequisites are required. See [`c2pa-wasm`'s prerequisites](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-wasm#prerequisites) for full details. +To build from source instead of using published packages only, you need the Rust toolchain and other prerequisites. See [Prerequisites in `packages/c2pa-wasm/README.md`](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-wasm#prerequisites). -### Recommended Setup Order +### Recommended setup order -1. Install Node.js, pnpm, and NX (see above). -2. Install the Rust toolchain and `c2pa-wasm` prerequisites (see [`packages/c2pa-wasm/README.md`](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-wasm#prerequisites)). -3. Run `pnpm install` from the repo root to install the project's dependencies. +1. Install Node.js, `pnpm`, and the Nx CLI (see the previous sections). +2. Install the Rust toolchain and `c2pa-wasm` prerequisites ([`packages/c2pa-wasm/README.md`](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-wasm#prerequisites)). +3. From the repository root, run `pnpm install` to install dependencies. -### Running Commands with Nx +### Running commands with Nx -Commands are run in the following format: `nx [target] [project]`, e.g.: +Run tasks as `nx `. For example: ```sh -nx build c2pa-web # This will build c2pa-web and all of its dependencies -nx test c2pa-web # This will build and run the tests defined in the c2pa-web package -nx lint c2pa-web # This will run ESLint on the c2pa-web package -nx lint c2pa-web --fix # This will run ESLint on the c2pa-web package and fix any errors +nx build c2pa-web # Builds c2pa-web and its dependencies +nx test c2pa-web # Builds and runs tests for c2pa-web +nx lint c2pa-web # Runs ESLint on c2pa-web +nx lint c2pa-web --fix # Runs ESLint and applies fixes ``` -### Committing Changes for Release +### Committing changes for a release -If your changes should be part of a release, you will need to create and commit a changeset. +Include a changeset when your change should ship in a release. -To create a new changeset, from the root repo directory, run: +From the repository root: ```sh pnpm changeset ``` -Follow the prompts to bump the version numbers of affected packages as appropriate. This will generate a new changeset markdown file in the `.changeset` directory, which should then be committed as part of your PR. +Follow the prompts to bump affected packages. The command adds a Markdown file under `.changeset/`; commit that file with your pull request. -Once the PR is merge into `main`, the changeset bot will create a release PR, which will then be reviewed, merged, and result in a new release being published. +After the pull request merges to `main`, the changeset bot opens a release pull request. When that pull request merges, a new release is published. -## Packages +## Directory layout -Please see the individual package directories for more detailed information. +See each package directory for full details. -### `packages/` +### packages -Published libraries intended for production use. +The `/packages` directory contains libraries published for production use. -#### [c2pa-web](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-web) +#### c2pa-web -The SDK for interacting with [C2PA metadata](https://c2pa.org/) on the web. +SDK for [C2PA](https://c2pa.org/) metadata in the browser. Source: [`packages/c2pa-web`](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-web). -#### [c2pa-wasm](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-wasm) +#### c2pa-wasm -The WebAssembly wrapper for [c2pa-rs](https://github.com/contentauth/c2pa-rs) that powers c2pa-web, built with [wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen). While these bindings can be used directly, most users will prefer the convenience of c2pa-web. +WebAssembly bindings for [`c2pa-rs`](https://github.com/contentauth/c2pa-rs), built with [`wasm-bindgen`](https://github.com/wasm-bindgen/wasm-bindgen). They power `c2pa-web`; most applications should use `c2pa-web` instead of calling the bindings directly. Source: [`packages/c2pa-wasm`](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-wasm). -#### [c2pa-types](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-types) +#### c2pa-types -Exports TypeScript types autogenerated from [c2pa-rs](https://github.com/contentauth/c2pa-rs) structs, used by c2pa-web. +TypeScript types generated from `c2pa-rs` structs for use by `c2pa-web`. Source: [`packages/c2pa-types`](https://github.com/contentauth/c2pa-js/tree/main/packages/c2pa-types). -### `tools/` +### tools -Other tools that provide utilities for local development. +The `/tools` directory contains utilities for local development. -#### [testbed](https://github.com/contentauth/c2pa-js/tree/main/tools/testbed) +#### testbed -A minimal website that can be used to view c2pa-web output and as a sandbox for local development. +Minimal site for inspecting `c2pa-web` output and experimenting locally. Source: [`tools/testbed`](https://github.com/contentauth/c2pa-js/tree/main/tools/testbed). -#### [nx-wasm-bindgen](https://github.com/contentauth/c2pa-js/tree/main/tools/nx-wasm-bindgen) +#### nx-wasm-bindgen -A custom [NX executor](https://nx.dev/concepts/executors-and-configurations) that contains the logic for building c2pa-wasm using [wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen). +Custom [Nx executor](https://nx.dev/concepts/executors-and-configurations) that builds `c2pa-wasm` with `wasm-bindgen`. Source: [`tools/nx-wasm-bindgen`](https://github.com/contentauth/c2pa-js/tree/main/tools/nx-wasm-bindgen). ## License -This project is licensed under the terms of the [MIT license](https://github.com/contentauth/c2pa-js-v2/blob/main/LICENSE). +This project is licensed under the [MIT license](https://github.com/contentauth/c2pa-js/blob/main/LICENSE). diff --git a/packages/c2pa-web/README.md b/packages/c2pa-web/README.md index a52e5a9..ff3efcf 100644 --- a/packages/c2pa-web/README.md +++ b/packages/c2pa-web/README.md @@ -288,7 +288,7 @@ For the full list, see the [API reference](https://contentauth.github.io/c2pa-js ### Prerequisites -Ensure the repo-wide prerequisites are installed.: +Ensure the repo-wide prerequisites are installed: - ([Node.js](https://nodejs.org/) v22+ - [NX](https://nx.dev/getting-started/intro) From c41ca68ba5cd6fc66a0c93a32d54747ddc4fa161 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Tue, 5 May 2026 14:52:28 -0700 Subject: [PATCH 3/4] More clean up --- packages/c2pa-types/README.md | 8 +++++++- packages/c2pa-wasm/README.md | 2 +- packages/c2pa-web/README.md | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/c2pa-types/README.md b/packages/c2pa-types/README.md index 43cb077..c68965e 100644 --- a/packages/c2pa-types/README.md +++ b/packages/c2pa-types/README.md @@ -4,7 +4,13 @@ Exports TypeScript types autogenerated from [c2pa-rs](https://github.com/content ### Building -Ensure the repo-wide prerequisites ([Node.js](https://nodejs.org/) v22+, [NX](https://nx.dev/getting-started/intro), and [pnpm](https://pnpm.io/)) are installed. See the [top-level README](https://github.com/contentauth/c2pa-js#prerequisites) for details. +Ensure the repo-wide prerequisites are installed: + +- [Node.js](https://nodejs.org/) v22+ +- [NX](https://nx.dev/getting-started/intro) +- [pnpm](https://pnpm.io/) + +See the [c2pa-js README](../../README.md#prerequisites) for details. To build the types: diff --git a/packages/c2pa-wasm/README.md b/packages/c2pa-wasm/README.md index d1189e3..4893e88 100644 --- a/packages/c2pa-wasm/README.md +++ b/packages/c2pa-wasm/README.md @@ -55,7 +55,7 @@ cargo install wasm-bindgen-cli@0.2.120 ``` > [!IMPORTANT] -> The version of `wasm-bindgen-cli` **must** match the version of the `wasm-bindgen` dependency in [`Cargo.toml`](./Cargo.toml). A version mismatch will cause build failures with errors like _"rust Wasm file schema version: X.X.X, this binary schema version: Y.Y.Y"_. If you encounter this, check `Cargo.toml` for the correct version and reinstall the CLI accordingly. +> The version of `wasm-bindgen-cli` **must** match the version of the `wasm-bindgen` dependency in [`Cargo.toml`](https://github.com/contentauth/c2pa-js/blob/main/packages/c2pa-wasm/Cargo.toml). A version mismatch will cause build failures with errors like _"rust Wasm file schema version: X.X.X, this binary schema version: Y.Y.Y"_. If you encounter this, check `Cargo.toml` for the correct version and reinstall the CLI accordingly. #### wasm-pack diff --git a/packages/c2pa-web/README.md b/packages/c2pa-web/README.md index ff3efcf..ebc520e 100644 --- a/packages/c2pa-web/README.md +++ b/packages/c2pa-web/README.md @@ -290,9 +290,9 @@ For the full list, see the [API reference](https://contentauth.github.io/c2pa-js Ensure the repo-wide prerequisites are installed: -- ([Node.js](https://nodejs.org/) v22+ +- [Node.js](https://nodejs.org/) v22+ - [NX](https://nx.dev/getting-started/intro) -- [pnpm](https://pnpm.io/)) +- [pnpm](https://pnpm.io/) See the [c2pa-js README](../../README.md#prerequisites) for details. From ebad96e827a76ab439ab37aa7b874c261cc1bf8b Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Tue, 5 May 2026 15:09:05 -0700 Subject: [PATCH 4/4] clean up c2pa-types readme --- packages/c2pa-types/README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/c2pa-types/README.md b/packages/c2pa-types/README.md index c68965e..b42299b 100644 --- a/packages/c2pa-types/README.md +++ b/packages/c2pa-types/README.md @@ -1,8 +1,8 @@ # c2pa-types -Exports TypeScript types autogenerated from [c2pa-rs](https://github.com/contentauth/c2pa-rs) structs, used by c2pa-web. +Exports TypeScript types used by c2pa-web that are auto-generated from [c2pa-rs](https://github.com/contentauth/c2pa-rs) structs. -### Building +## Prerequisites Ensure the repo-wide prerequisites are installed: @@ -12,6 +12,8 @@ Ensure the repo-wide prerequisites are installed: See the [c2pa-js README](../../README.md#prerequisites) for details. +## Building + To build the types: ```sh @@ -21,6 +23,6 @@ nx build c2pa-types The types are built as follows: 1. Specific structs ([example](https://github.com/contentauth/c2pa-rs/blob/main/sdk/src/manifest.rs#L55)) from c2pa-rs are annotated with the `schemars::JsonSchema` attribute. -2. JSON schema files are generated by calling `schemars::schema_for` and saved to the `schemas/` directory -3. Schema files are read by `json-schema-to-typescript` and used to generate TypeScript types, saved to the `types/` directory -4. Types are "gathered" and exported from the `index.d.ts` file +2. JSON schema files are generated by calling `schemars::schema_for` and saved to the `schemas/` directory. +3. Schema files are read by `json-schema-to-typescript` and used to generate TypeScript types, saved to the `types/` directory. +4. Types are "gathered" and exported from the `index.d.ts` file.