Expand description
WASM ABI over packdiff-dto — the comment engine the generated HTML page
calls into. Every model mutation and export the browser performs goes
through here; the page’s JavaScript is only a view layer.
ABI (no wasm-bindgen, empty import object, works from file://):
- Strings cross the boundary as
(ptr: u32, len: u32)UTF-8 buffers. JS allocates inputs withpd_alloc, writes, calls, then frees them withpd_free. - Every API function returns a packed
u64=(ptr << 32) | lennaming a fresh UTF-8 buffer the CALLER must free withpd_freeafter copying. - Every returned buffer is a single-key union document (§ house style):
{ "Ok": <result> }on success or{ "Error": { "message": "…" } }on failure. TheOkpayload is a document object for mutations and a plain string for exports/keys.
Purity: the module has no clock and no entropy — comment ids and RFC 3339 timestamps come in from JS as part of the comment JSON.
Functions§
- pd_
alloc - Allocate
lenbytes for the caller to write an input buffer into. - pd_
delete_ comment - Delete a comment by id (the id arrives as a plain UTF-8 string, not JSON). Returns the updated document; deleting a missing id is not an error.
- pd_
export_ csv - pd_
export_ json - pd_
export_ markdown - pd_free
- Free a buffer previously returned by
pd_allocor by any API function. - pd_
markdown_ html - Render markdown to safe HTML (the subset in
packdiff_dto::markdown). The input is the raw markdown text — a plain UTF-8 string, not JSON — andOkcarries the HTML string. Never fails on any input. - pd_
merge - Merge an imported document into the current one (union by id, newer
updated_atwins). Returns the merged document. - pd_
new_ document meta={"repo": "...", "base": {"name","sha"}, "head": {"name","sha"}}. Returns a fresh empty review document.- pd_
parse_ document - Parse, validate, and normalize a stored document (the load path).
- pd_
range_ diff - Diff a contiguous commit sub-range from the page’s embedded snapshots.
snapshotsis aRangeSnapshotsJSON;paramsis{"from": <boundary index>, "to": <boundary index>, "context": N}withfrom < to(commitkalone isfrom = k - 1, to = k).Okcarries theFileDiffarray — the same shape the build-time parser emits. - pd_
storage_ key metaas inpd_new_document; returns the localStorage key string.- pd_
upsert_ comment - Insert or replace (by id) one comment. Returns the updated document.