This change will make the internal operations more accessible to the application code.
* feat: add exportJsonInIdSpan and make peer compression optional
- Introduced `export_json_updates_without_peer_compression` method to allow exporting JSON updates without compressing peer IDs, making it easier for application code to process.
- Updated existing `export_json_updates` method to accept a `with_peer_compression` parameter, defaulting to true.
- Refactored related code in various files to accommodate the new functionality, ensuring backward compatibility.
* fix: slice err & add tests
* chore: changeset
* fix: tree should use jitter 0 by default
Otherwise, there may be inconsistency between the event and the actual data. But this will increase the cost when the index property is not used.
* chore: add changeset
* chore: fix warning
* refactor: enable tree move by default
* docs: update related docs
* perf: use a priority-queue-based search for updating text
It tends to produce diffs with more continuous edits,
which is more efficient when we need to apply them to CRDTs
* fix: use better text diff calc
* refactor: add text update options struct
* chore: update text.update comments
* chore: fix warnings
* fix: rm a dumb optimization
- (js) Refactor subscription mechanism to return unsubscribe function
- (rust) Implement must-use struct for subscriptions in Rust
- Enhance API ergonomics for JavaScript-like environments
- Improve resource cleanup and prevent potential memory leaks
* refactor: Loro import function should return LoroEncodeError
- Change return type
- Add support for handling potential errors:
- Invalid or non-existent frontiers
- Exporting old snapshot format from trimmed snapshot doc
- Improve compatibility with trimmed docs
* fix: add tests and fix a few places that need to return err
* feat: add old parent in tree diff
* chore: enable ci
* feat: add old_index to tree diff
* fix: new fractional index config
* fix: cargo fix
* fix: add FractionalIndexNotEnabled error
* fix: move config to tree state
* fix: error string
---------
Co-authored-by: Zixuan Chen <remch183@outlook.com>
* feat: add diff algorithm
* feat: implement DiffHook
* feat: add rust/typescript API
* feat: use u8 to enable SIMD
* feat: add SIMD support
* test: add a failed test case
* revert: change to unicode index
* fix: text event index correctness when using utf8 or unicode
* fix: use unicode index
* fix: apply delta
* fix: remove splice_unicode
---------
Co-authored-by: Zixuan Chen <remch183@outlook.com>
* fix: should transform checkout event
* chore: update fuzz dep
* chore: add pos to error info
* fix: clear undo/redo stack when checkingout
* test: update fuzz dep
* test: a new failed test case
* fix: tree transform
* chore: fuzz
* chore: add log
* chore: add more logs
* fix: compose err
* chore: fuzz test dep
* test: a failed tree case
* fix: undo tree event
* fix: do not compare tree position in fuzz
* fix: fuzz rev
* test: a failed tree case
* fix: add tree compose
* chore: add comment
* chore: fuzz
* fix: test
* fix: tree transform
* fix: tree transform index
* fix: sort tree index
* chore: fuzz
* fix: undo/redo remote change effect compose
* bk
* fix: tree undo redo (#385)
* fix: event hint none
* chore: fuzz version
* ci: fuzz
* bk: weird err
* fix: type err
* fix: fractional index between
* fix: wasm counter feature
* test: a new failed case
* fix: recursively create child nodes
* fix: filter empty event
* bk
* bk
* fix: tree undo redo remap
* chore: clean
* bk
* fix: tree need remap first
* fix: tree undo effect
* fix: tree diff calc
* fix: tree fuzz check eq func
* fix: remove EventHint None
* chore: cargo fix
* fix: tree uncreate
* fix: fuzz tree assert only structure
* refactor: rename methods
* fix: movable tree apply delta
* fix: another movable list issue
* chore: fuzz only check 1 actor's history
---------
Co-authored-by: Leon Zhao <leeeon233@gmail.com>
* bk: add move op content
* bk: add inner_movable_list diff and related stuff
* perf: high perf state
* fix: update old list item cache
* fix: should use id in del
* feat: two kinds of len for movable list state
* bk: add op index to movable list
* bk: make basic handler test pass
* refactor: add move_from to list event
* fix: make all existing tests pass
* bk: list move event hint into event
* bk: convert inner event into user event
Co-authored-by: Leon <leeeon233@gmail.com>
* fix: convert issue when inserting new value
* feat: add op group for movable list
* feat: diff calc
* feat: add mov support to tracker
* fix: when applying diff, state should be force update
* feat: encoded op
* feat: snapshot encode
* fix: pass basic sync
* fix: snapshot encode/decode
* fix: warnings
* feat: expose mov list to loro crate
* test: fuzz movable list
* test: fix fuzz integration
* fix: movable list basic move sync
* fix: movable list events
* fix: movable event err
* fix: register child container on movable list
* fix: should not return child index if the value is already overwritten
* fix: local event err in movable list
* fix: get elem at pos
* refactor: extract mut op that could break invariants
* fix: event err
* fix: child container to elem err
* fix: bringback event issue
* fix: event err
* fix: event emit
* fix: id to cursor iter issue
* chore: fix a few warnings
* fix: warnings
* fix: fix move in tracker
* test: add consistency check
* test: fix tracker
* refactor: simplify event conversion in docstate
* refactor: refine move event
* refactor: simplify the maintain of parent child links
* fix: revive err
* fix: warnings
* fix: it's possible that pos change but cannot find the respective list item
* fix: elem may be dropped after snapshot
* fix: warnings
* fix: richtext time travel issue
* fix: move op used wrong delete id on tracker
* fix: handle events created by concurrent moves correctly
* fix: event hint error, used op index for list event
* fix: move_from flag err
* fix: id to cursor get err
* test: add mov fuzz target
* fix: the pos of inserting new container
* fix: used wrong event hint index
* fix: del event hint
* fix: warnings
* fix: internal diff to event err
* fix: event's move flag error
This "move" flag does not actually mean that the insertion
is caused by the move op.
就算是 move 造成的它不一定就能是 true
它得是下游真的能在“前一个版本的 array 里找到“,才能是 true
* fix: remove redundant elements from the movable list
The Movable List is currently flawed; an element may not exist on the movable list state, yet there are operations that revive its corresponding list item. In such cases, the diff calculation does not send back the corresponding element state (this occurs when tracing back, which fuzz testing currently does not cover. It might only be exposed by randomly switching to a version and then checking for consistency; otherwise, as long as all elements are in memory, this problem does not arise).
Moreover, there is no need to store elements in the state that do not have a corresponding list item. They will be deleted during the Snapshot, and relying on "them still being in the state" is incorrect behavior. Such adjustments also eliminate the need to maintain the `pending_elements` field.
By allowing the opgroup to record the mapping from pos id to state id, we can ensure that the events sent to the movable list state will include the corresponding state.
Movable List 现在是有错的,elem 可能不存在 movable list state 上,但是又有操作把它对应的 list item 复活了,此时 diff calc 不会把对应 element 状态发送回来(往前回溯的时候会出现,fuzz 现在没覆盖到。得有随意切换一个版本然后 check consistency 才可能会暴露;否则现在大家 elements 都在内存,就没这个问题)
而且我们没有必要在状态中存储没有对应 list item 的 element。在 Snapshot 的时候它们都会被删掉,如果依赖了“它们还会在 state 内”就是错误的行为。这样的调整也让我们不需要去维护 pending_elements 这个 field 了
通过让 opgroup 记录了 pos id → state id 的映射,可以保证发给 movable list state 的事件中会带上对应的 state
* test: make fuzzer stricter
* test: test expectation error
* refactor: rename stable pos to cursor
* tests: chore list bench init
* test: add bench
* bench: add mov & set bench
* feat(wasm): movable list js api
* fix: make movablelist able to attach even if it's already attached & refine the type of subscribe
* fix: remove the loro doc param in .unsub
* refactor: refine ts types and export setContainer api
* chore: fix warnings
* chore: rm debug logs
* perf: reduce mem usage of opgroup
* bench: add list criterion bench
---------
Co-authored-by: Leon <leeeon233@gmail.com>
* feat: delta rope support init
* perf: use generic-btree v0.9.0
* refactor: improve readability and maintainability
* fix: fix several issues about composing
* fix: a few more issue about composing deletions
* test: rich text
* fix: cover more edge cases
* refactor: use deltarope for list event
* refactor: replace text delta with DeltaRope
* fix: list fuzz err
* fix: safety issue on insert_many
* chore: refine impl of text delta
* refactor: use Replace instead of insert+del in DeltaItem (#330)
* refactor: use Replace instead of insert+del in DeltaItem
* fix: each deltaitem should have non-zero rle_len
Updated generic-btree dependency to version 0.10.3 and refactored DeltaItem and DeltaRope implementations in loro-delta. Refine compose impl
* fix: update generic-btree to fix the update leaf issue
* chore: lockfile
* chore: clippy fix
* refactor: make composing easier to understand
* refactor: simplify the impl of composing
This PR includes a BREAKING CHANGE.
It enables you to create containers before attaching them to the document, making the API more intuitive and straightforward.
A container can be either attached to a document or detached. When it's detached, its history/state does not persist. You can attach a container to a document by inserting it into an attached container. Once a container is attached, its state, along with all of its descendants's states, will be recreated in the document. After attaching, the container and its descendants, will each have their corresponding "attached" version of themselves?
When a detached container x is attached to a document, you can use x.getAttached() to obtain the corresponding attached container.
* refactor: use rich text style config
* chore: rm log
* feat: support config text style in wasm
* feat: overlapped styles
* chore: add warning style key cannot contain ':'
* test: refine test case for richtext
* test: refine test
* refactor: rm txn.abort and related undo behavior
* perf: simplify richtext state when there is not styles
* perf: reduce text cost when there is no style
* chore: refine logs
* perf: remove cid in states to reduce mem overhead
* refactor: reduce mem overhead by using a compacter mapvalue
* refactor: rm the box inside richtext state