doc(wasm): add JS/TS integration guide + link from README (#226)#232
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Second slice of #226 (after the KPM rustdoc slice, #231). #226 stays open — remaining slices below.
The gap
The npm package
@webarkit/webarkitlib-wasmshipped 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:init→init_wasm→ optionalinit_panic_hook)exportsmap (@webarkit/webarkitlib-wasmvs/simd) + a runtime SIMD probeWasmARHandle(square/barcode),WasmKpmHandle(NFT detection),WasmNFTHandle(AR2 tracking){ pose, page, error }and{ found, matrix, error, cont_num })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, theKpmDetectResult/NFTTrackingResultserde shapes).README wiring
Linked from the README's WASM section using an absolute GitHub URL — only
README.mdis published to the npm package (notdocs/), so npm readers can still click through. The root README is whatbuild-dualcopies topkg/README.md; that generated copy refreshes on the nextnpm run build.Remaining for #226
types.rsC-port struct fields (116) +ar2/tracking.rs+icp.rs(146) — mechanical field docs#![warn(missing_docs)]+ the ~43 pre-existing broken intra-doc linksDocs-only change (Markdown); no code touched.
🤖 Generated with Claude Code