lib

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

commit 2c30f7d6421b01c6fefe53092873c74cf359e42e
parent 4efa93fdcc0eb493d548499bc08c865d3169b5d1
Author: triesap <tyson@radroots.org>
Date:   Wed, 24 Dec 2025 21:01:48 +0000

wasm: export reaction tag builder


- Import reaction event type and tag encoder helpers
- Add JSON parser for RadrootsReaction payloads
- Expose reaction_tags via wasm_bindgen js_name mapping
- Encode reaction 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 @@ -3,7 +3,9 @@ use radroots_events::follow::RadrootsFollow; use radroots_events::listing::RadrootsListing; +use radroots_events::reaction::RadrootsReaction; use radroots_events_codec::follow::encode::follow_build_tags; +use radroots_events_codec::reaction::encode::reaction_build_tags; use radroots_events_codec::listing::tags::{ listing_tags as listing_tags_impl, listing_tags_full as listing_tags_full_impl, @@ -22,6 +24,10 @@ fn parse_follow(follow_json: &str) -> Result<RadrootsFollow, JsValue> { serde_json::from_str(follow_json).map_err(err_js) } +fn parse_reaction(reaction_json: &str) -> Result<RadrootsReaction, JsValue> { + serde_json::from_str(reaction_json).map_err(err_js) +} + fn tags_to_json(tags: Vec<Vec<String>>) -> Result<String, JsValue> { serde_json::to_string(&tags).map_err(err_js) } @@ -46,3 +52,10 @@ pub fn follow_tags(follow_json: &str) -> Result<String, JsValue> { let tags = follow_build_tags(&follow).map_err(err_js)?; tags_to_json(tags) } + +#[wasm_bindgen(js_name = reaction_tags)] +pub fn reaction_tags(reaction_json: &str) -> Result<String, JsValue> { + let reaction = parse_reaction(reaction_json)?; + let tags = reaction_build_tags(&reaction).map_err(err_js)?; + tags_to_json(tags) +}