feat(wasm): per-container and range deep reads with container ids - #1086
Open
zxch3n wants to merge 1 commit into
Open
feat(wasm): per-container and range deep reads with container ids#1086zxch3n wants to merge 1 commit into
zxch3n wants to merge 1 commit into
Conversation
- Fix getDeepValueWithID() cid field: emit the bare ContainerID string
(the same as container.id) instead of the Debug-style
'idx:N, id:cid:...' composite. Potentially breaking for consumers that
parsed the old form; restores parity with the pure-TS runtime.
- Add getDeepValueWithID() on LoroMap/LoroList/LoroMovableList/LoroTree
({ cid, value } node) and LoroText ({ cid, value: string }).
- Add getRangeDeepValueWithID(start, end) and getRangeValue(start, end)
on LoroList/LoroMovableList for one-call deep reads of a slice;
bounds are clamped, empty or inverted ranges return [].
- Detached containers return a readable error instead of trapping.
MovableListHandler::get_deep_value_with_id now returns LoroResult
instead of unwrapping on detached handlers.
Wasm size (dev build, with debug info): +158 KB (+0.16%).
zxch3n
force-pushed
the
feat/wasm-container-bulk-read
branch
from
September 4, 2026 04:15
5375041 to
e48b247
Compare
This was referenced Sep 4, 2026
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.
Stack: 3/6 — merge order: #1093 → #1085 → #1086 → #1087 → #1090 → #1091
Summary
Stacked on #1085 (merge that first; GitHub will retarget this to
mainautomatically).1.
cidformat fix (potentially breaking)LoroDoc.getDeepValueWithID()emitted the nodecidas a Debug-style composite:idx:85, id:cid:92@2311024965712536503:Map(internal container index + id). It now emits the bareContainerIDstring —cid:92@2311024965712536503:Map/cid:root-map:Map— exactly what the container'sidproperty returns. No in-repo consumer parsed the old form (verified withrg); the pure-TS runtime inloro-jsalready emittedcontainer.id, so this restores wasm/JS-runtime parity. The change is called out in the changeset.2. Per-container
getDeepValueWithID()LoroMap/LoroList/LoroMovableList/LoroTreenow exposegetDeepValueWithID()returning the same{ cid, value }node shape as the doc-level API;LoroTextreturns{ cid, value: string }. One WASM call reads a whole subtree.3. Range deep reads
LoroList.getRangeDeepValueWithID(start, end)/LoroMovableList.getRangeDeepValueWithID(start, end)return the deep-with-id nodes for items[start, end)in one call;getRangeValue(start, end)returns plain deep values without ids. Negative bounds clamp to 0, overflows clamp to the length, empty or inverted ranges return[].Detached containers throw a readable error (
MisuseDetachedContainer) instead of trapping — this required changingMovableListHandler::get_deep_value_with_idfrom an unwrap-on-detached toLoroResult(no other callers).Tests
loro-internal(cid == container.id for root/nested, text/tree node shapes, slice clamping/empty/inverted, detached errors).cargo test -p loro-internalandcargo test -p loropass.tests/deep_value.test.ts(11 tests). Full wasm suite: 27 files / 360 tests pass;tsc --noEmitclean.typescript_custom_sectioninterfaces; new exportedValueWithContainerIDtype.Wasm binary size
Dev build with debug info: 99,697,095 → 99,855,123 B (+158 KB, +0.16%).