Expose inner LoroDoc reference from loro-wasm::LoroDoc for extension crates

Open Beginner friendly
#942 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust, wasm

Research direction

Start at the loro-wasm::LoroDoc definition and inspect how its private doc field wraps the underlying LoroDocInner. Add the requested public accessor and verify that an extension crate can use it to call operations such as get_tree(), subscribe_root(), and commit() on the shared document.

Written by the indexing model from the issue text.

Description

I'm building a #[wasm_bindgen] extension crate that needs to operate on the same LoroDoc as the JS frontend. Currently, loro-wasm::LoroDoc.doc is private, so I can't accept a &LoroDoc in my Rust crate and access the underlying LoroDocInner for operations like get_tree(), subscribe_root(), commit(), etc.

Request: Could you add a public accessor on the wasm LoroDoc struct? Something like:

impl LoroDoc {
pub fn doc(&self) -> &LoroDocInner {
&self.doc
}
}

This would allow extension crates to depend on loro-wasm via git and build into a single WASM module that shares the same LoroDoc instance with JS — no dual-doc bridging needed.

Without this, the only options are forking loro-wasm or maintaining two separate LoroDoc instances (one in JS, one in WASM) with a sync bridge, which adds memory overhead and complexity.

Dominant language
Rust
Stars
6.1k
Forks
178
Avg merge
1d 22h
Merged PRs (30d)
22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from loro-dev/loro

All issues in loro-dev/loro

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.