Files
ruvnet__ruflo/v3/@claude-flow/watermark/scripts/build-wasm.sh
rUv fa13ee4ad6 feat(watermark): add browser/Deno ESM entry (@claude-flow/watermark 0.2.0) (#3041)
Adds a `@claude-flow/watermark/web` ESM entry (wasm-pack `--target web`) so the
package works in browsers, Deno, and bundlers — not just Node. Instantiate once
with `await init()` (auto-fetches the wasm in a browser; accepts bytes/URL/
Response), then the same ergonomic API (Watermarker, detect, detectSelfSync,
detectExact) as the Node build.

- package.json: conditional exports (`.` = Node CJS/ESM, `./web` = browser ESM,
  `./package.json` re-exported); web/ marked ESM via a nested package.json.
- build:wasm now builds both nodejs and web targets.
- Added test/smoke-web.mjs; `npm test` runs Node + web. Both verified, plus a
  fresh dual-entry tarball install (node z=64.7, web z=64.7).

Bumps to 0.2.0 (new capability, backward-compatible). No removal tooling.


Claude-Session: https://claude.ai/code/session_01VYDa3Hah5VJLS2ceEuTLKz
2026-08-15 19:18:24 -04:00

32 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Regenerate the WASM bindings from the ruflo-watermark Rust crate: the Node
# (CommonJS) build in ./wasm and the browser/Deno (ESM) build in ./web.
#
# Requires: rustup + wasm32-unknown-unknown target + wasm-pack.
# rustup target add wasm32-unknown-unknown
# cargo install wasm-pack
#
# RUSTFLAGS is cleared for the wasm target because a machine-global
# `-C link-arg=-fuse-ld=mold` (if present) is rejected by wasm's rust-lld.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
crate="$here/../../crates/ruflo-watermark"
build() { # <target> <out-dir>
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS="" RUSTFLAGS="" \
wasm-pack build --release --target "$1" \
--out-dir "$crate/$2" --out-name ruflo_watermark \
"$crate" -- --features wasm
}
files=(ruflo_watermark.js ruflo_watermark_bg.wasm ruflo_watermark.d.ts ruflo_watermark_bg.wasm.d.ts)
build nodejs pkg-nodejs
for f in "${files[@]}"; do cp "$crate/pkg-nodejs/$f" "$here/wasm/"; done
build web pkg-web
for f in "${files[@]}"; do cp "$crate/pkg-web/$f" "$here/web/"; done
echo "Rebuilt wasm/ (nodejs) and web/ (browser) from $crate"