lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit fc456f548fa782eb25f72b5da3d83d728fcb4514
parent 2c30f7d6421b01c6fefe53092873c74cf359e42e
Author: triesap <tyson@radroots.org>
Date:   Wed, 24 Dec 2025 21:05:06 +0000

wasm: export comment tag builder


- Import comment event type and tag encoder helper
- Add JSON parser for RadrootsComment payloads
- Expose comment_tags via wasm_bindgen js_name mapping
- Encode comment tags and serialize tag vectors to JSON

Diffstat:
Mevents-codec-wasm/src/lib.rs | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/events-codec-wasm/src/lib.rs b/events-codec-wasm/src/lib.rs @@ -1,9 +1,11 @@ #![cfg(target_arch = "wasm32")] #![forbid(unsafe_code)] +use radroots_events::comment::RadrootsComment; use radroots_events::follow::RadrootsFollow; use radroots_events::listing::RadrootsListing; use radroots_events::reaction::RadrootsReaction; +use radroots_events_codec::comment::encode::comment_build_tags; use radroots_events_codec::follow::encode::follow_build_tags; use radroots_events_codec::reaction::encode::reaction_build_tags; use radroots_events_codec::listing::tags::{ @@ -20,6 +22,10 @@ fn parse_listing(listing_json: &str) -> Result<RadrootsListing, JsValue> { serde_json::from_str(listing_json).map_err(err_js) } +fn parse_comment(comment_json: &str) -> Result<RadrootsComment, JsValue> { + serde_json::from_str(comment_json).map_err(err_js) +} + fn parse_follow(follow_json: &str) -> Result<RadrootsFollow, JsValue> { serde_json::from_str(follow_json).map_err(err_js) } @@ -46,6 +52,13 @@ pub fn listing_tags_full(listing_json: &str) -> Result<String, JsValue> { tags_to_json(tags) } +#[wasm_bindgen(js_name = comment_tags)] +pub fn comment_tags(comment_json: &str) -> Result<String, JsValue> { + let comment = parse_comment(comment_json)?; + let tags = comment_build_tags(&comment).map_err(err_js)?; + tags_to_json(tags) +} + #[wasm_bindgen(js_name = follow_tags)] pub fn follow_tags(follow_json: &str) -> Result<String, JsValue> { let follow = parse_follow(follow_json)?;