Skip to content

doc(wasm): add JS/TS integration guide + link from README (#226)#232

Merged
kalwalt merged 1 commit into
devfrom
doc/wasm-js-guide-226
Jul 20, 2026
Merged

doc(wasm): add JS/TS integration guide + link from README (#226)#232
kalwalt merged 1 commit into
devfrom
doc/wasm-js-guide-226

Conversation

@kalwalt

@kalwalt kalwalt commented Jul 17, 2026

Copy link
Copy Markdown
Member

Second slice of #226 (after the KPM rustdoc slice, #231). #226 stays open — remaining slices below.

The gap

The npm package @webarkit/webarkitlib-wasm shipped with no consumer usage guide — the README just said "See npm for API documentation and usage examples," and npm just points back at the README. Circular. There was nowhere that actually showed how to call the WASM API from JS.

What this adds

A full walkthrough at docs/wasm-js-integration.md:

  • Load + initialize (initinit_wasm → optional init_panic_hook)
  • Standard vs SIMD engines via the package exports map (@webarkit/webarkitlib-wasm vs /simd) + a runtime SIMD probe
  • The three handles: WasmARHandle (square/barcode), WasmKpmHandle (NFT detection), WasmNFTHandle (AR2 tracking)
  • The NFT detect-then-track loop with the real serialized return shapes ({ pose, page, error } and { found, matrix, error, cont_num })
  • The 3×4 row-major pose-matrix layout, TypeScript usage, memory management (free()), and common pitfalls (RGBA length, load-before-detect, single-marker-per-handle, …)

Every snippet is checked against the actual crates/wasm/src/lib.rs (constructor signatures, byte-length guards, the KpmDetectResult / NFTTrackingResult serde shapes).

README wiring

Linked from the README's WASM section using an absolute GitHub URL — only README.md is published to the npm package (not docs/), so npm readers can still click through. The root README is what build-dual copies to pkg/README.md; that generated copy refreshes on the next npm run build.

Remaining for #226

  • types.rs C-port struct fields (116) + ar2/tracking.rs + icp.rs (146) — mechanical field docs
  • Crate-wide #![warn(missing_docs)] + the ~43 pre-existing broken intra-doc links

Docs-only change (Markdown); no code touched.

🤖 Generated with Claude Code

The npm package (@webarkit/webarkitlib-wasm) shipped with no consumer-facing
usage guide — the README only said "see npm for API docs". Add a full
walkthrough at docs/wasm-js-integration.md covering:

- loading + initializing the module (init / init_wasm / init_panic_hook)
- the standard vs SIMD engines (the package `exports` map) + a runtime probe
- the three handles: WasmARHandle (square markers), WasmKpmHandle (NFT
  detection), WasmNFTHandle (AR2 tracking)
- the NFT detect-then-track loop with the real serialized shapes
  ({ pose, page, error } and { found, matrix, error, cont_num })
- the 3x4 row-major pose-matrix layout, TypeScript usage, memory management
  (free()), and common pitfalls (RGBA length, load-before-detect, etc.)

All snippets are checked against the actual crates/wasm/src/lib.rs API.

Link from the README's WASM section using an absolute GitHub URL so it also
works for consumers reading the README on npmjs.com (only README.md is
published to the package, not docs/). The root README is the source copied
to pkg/README.md by build-dual at build time; pkg/README.md refreshes on the
next `npm run build`.

Second slice of the #226 documentation pass (after the KPM rustdoc slice in
#231).

Refs #226

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kalwalt kalwalt self-assigned this Jul 19, 2026
@kalwalt kalwalt added documentation Improvements or additions to documentation enhancement New feature or request wasm labels Jul 19, 2026
@kalwalt kalwalt added this to the Stabilization & DX milestone Jul 19, 2026
@kalwalt
kalwalt merged commit 198b531 into dev Jul 20, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant