Commit graph

41 commits

Author SHA1 Message Date
Zixuan Chen
edb0ef75f6
chore: Update VSCode settings and dependencies (#299) 2024-03-30 06:53:22 +08:00
Leon Zhao
a47cf06712
Refactor fuzzing test (#271)
* feat: new fuzz test

* test: add arbtest

* fix: remove PROPTEST_FACTOR
2024-03-08 16:40:06 +08:00
Zixuan Chen
08847d6639
refactor: rename client_id in idspan to peer (#287)
* refactor: rename client_id in idspan to peer

* fix: type err
2024-03-02 19:10:33 +08:00
Leon Zhao
dcbdd55195
feat: remove deleted set in tree state and optimize api (#259)
Co-authored-by: Zixuan Chen <me@zxch3n.com>
2024-01-30 09:54:54 +08:00
Zixuan Chen
9e57ccbc00
Fix avoid rich text apply diff err when time travel (#256)
* fix: avoid enter invalid richtext state

* fix: only include the style when the doc contains both style start and style end

* fix: iter_range err in richtext state

* fix: richtext state iter range

* fix: iter range err

* fix: iter range

* chore: rm log

* fix: iter range

* fix: get affected range

* fix: return err if given checkout target is invalid
2024-01-21 19:51:27 +08:00
Zixuan Chen
1295ac6d61
(wasm) Extract VersionVector class and fix inconsistent PeerID repr (#249)
* refactor(wasm): extract VersionVector class and fix inconsistent PeerID in wasm

* fix: example type err

* fix: binding err

* fix: peer id repr should be consistent

* test: update tests
2024-01-18 13:28:28 +08:00
Leon Zhao
692c5e3436
feat: group ops (#243) 2024-01-12 16:47:44 +08:00
Zixuan Chen
b8cf4dc4c3
Refine the new encoding schema (#244)
* perf: refine the new encoding schema

* chore: rm auto derived fromprimitive and toprimitive from encode mode
2024-01-11 22:49:18 +08:00
Zixuan Chen
bc27a47531
feat: stabilizing encoding (#219)
This PR implements a new encode schema that is more extendible and more compact. It’s also simpler and takes less binary size and maintaining effort. It is inspired by the [Automerge Encoding Format](https://automerge.org/automerge-binary-format-spec/).

The main motivation is the extensibility. When we integrate a new CRDT algorithm, we don’t want to make a breaking change to the encoding or keep multiple versions of the encoding schema in the code, as it will make our WASM size much larger. We need a stable and extendible encoding schema for our v1.0 version.

This PR also exposes the ops that compose the current container state. For example, now you can make a query about which operation a certain character quickly. This behavior is required in the new snapshot encoding, so it’s included in this PR.

# Encoding Schema

## Header

The header has 22 bytes.

- (0-4 bytes) Magic Bytes: The encoding starts with `loro` as magic bytes.
- (4-20 bytes) Checksum: MD5 checksum of the encoded data, including the header starting from 20th bytes. The checksum is encoded as a 16-byte array. The `checksum` and `magic bytes` fields are trimmed when calculating the checksum.
- (20-21 bytes) Encoding Method (2 bytes, big endian): Multiple encoding methods are available for a specific encoding version.

## Encode Mode: Updates

In this approach, only ops, specifically their historical record, are encoded, while document states are excluded.

Like Automerge's format, we employ columnar encoding for operations and changes.

Previously, operations were ordered by their Operation ID (OpId) before columnar encoding. However, sorting operations based on their respective containers initially enhance compression potential.

## Encode Mode: Snapshot

This mode simultaneously captures document state and historical data. Upon importing a snapshot into a new document, initialization occurs directly from the snapshot, bypassing the need for CRDT-based recalculations.

Unlike previous snapshot encoding methods, the current binary output in snapshot mode is compatible with the updates mode. This enhances the efficiency of importing snapshots into non-empty documents, where initialization via snapshot is infeasible. 

Additionally, when feasible, we leverage the sequence of operations to construct state snapshots. In CRDTs, deducing the specific ops constituting the current container state is feasible. These ops are tagged in relation to the container, facilitating direct state reconstruction from them. This approach, pioneered by Automerge, significantly improves compression efficiency.
2024-01-02 17:03:24 +08:00
Leon zhao
acafc76aff
Feat: diff calc bring back & tree new event and value (#149)
* feat: new tree state

* fix: emit meta event

* fix: semantic tree event

* fix: diff calc bring_back

* chore: clear comments

* fix: merge

* fix: tree snapshot

* fix: filter empty bring back

* feat: tree add external diff

* fix: imported changes were not mergeable (#147)

* fix: imported changes were not mergeable
now the small encoding size is supported in example

* fix: stupid err in richtext checkout

* fix: rle oplog encode err
- support pending changes
- start counters were wrong

* fix: utf16 query err (#151)

* fix: tree movable node lamport

* fix: merge

* perf: bring back

* doc: add deep value meta doc

* refactor: bring back only when record diff

---------

Co-authored-by: Zixuan Chen <remch183@outlook.com>
2023-11-05 15:53:33 +08:00
Zixuan Chen
7a19b49acb
Add richtext example using Quill (#145)
* feat: richtext example init

* fix: pass richtext event delta consistency check

* chore: debug history
2023-11-03 16:59:27 +08:00
Zixuan Chen
95e6130d93
Fix: richtext event (#138)
Support rich text event. Now it will emit the delta event correctly in the Quill Delta format.
2023-11-01 20:02:05 +08:00
Zixuan Chen
734b832c00
Fix checkout event (#126)
* tests: add checkout err tests

* fix: checkout event err when create child
2023-10-30 14:16:50 +08:00
Zixuan Chen
d942e3d7a2
Feat: Peritext-like rich text support (#123)
* feat: richtext wip

* feat: add insert to style range map wip

* feat: richtext state

* fix: fix style state inserting and style map

* fix: tiny vec merge err

* fix: comment err

* refactor: use new generic-btree & refine impl

* feat: fugue tracker

* feat: tracker

* feat: tracker

* fix: fix a few err in impl

* feat: init richtext content state

* feat: refactor arena

* feat: extract anchor_type info out of style flag

* refactor: state apply op more efficiently
we can now reuse the repr in state and op

* fix: new clippy errors

* refactor: use state chunk as delta item

* refactor: use two op to insert style start and style end

* feat: diff calc

* feat: handler

* fix: tracker checkout err

* fix: pass basic richtext handler tests

* fix: pass handler basic marking tests

* fix: pass all peritext criteria

* feat: snapshot encoding for richtext init

* refactor: replace Text with Richtext

* refacotr: rm text code

* fix: richtext checkout err

* refactor: diff of text and map

* refactor: del span

* refactor: event

* fix: fuzz err

* fix: pass all tests

* fix: fuzz err

* fix: list child cache err

* chore: rm debug code

* fix: encode enhanced err

* fix: encode enchanced

* fix: fix several richtext issue

* fix: richtext anchor err

* chore: rm debug code

* fix: richtext fuzz err

* feat: speedup text snapshot decode

* perf: optimize snapshot encoding

* perf: speed up decode & insert

* fix: fugue span merge err

* perf: speedup delete & id cursor map

* fix: fugue merge err

* chore: update utils

* perf: speedup text insert / del

* fix: cursor cache

* perf: reduce conversion by introducing InsertText

* perf: speed up by refined cursor cache

* chore: update gbtree dep

* refactor(wasm): use quill delta format

* chore: fix warnings
2023-10-29 14:02:13 +08:00
leeeon233
f1adc7d15d chore: use columnar 0.3.2 2023-09-11 14:54:54 +08:00
Zixuan Chen
72cc8c6ed5
fix: map version checkout err (#101) 2023-08-04 22:41:02 +08:00
Zixuan Chen
c105ff2220
Feat: checkout to target version & use unicode index by default (#98)
* feat: checkout to frontiers

* feat: record timestamp

* fix: use unicode len by default for text
now "你好" has length of 2 instead of 6

* chore: rm dbg!
2023-08-04 10:45:23 +08:00
Zixuan Chen
abec22cd22 fix: text sync issues 2023-07-12 12:30:36 +08:00
Zixuan Chen
508ca4b5c6 refactor: use a new version of txn 2023-07-10 12:06:11 +08:00
Zixuan Chen
abd3e38253 chore: bk 2023-07-02 23:24:17 +08:00
Zixuan Chen
c50294ac22 feat: use text tracker diff 2023-06-29 16:09:42 +08:00
Zixuan Chen
490a54d559 feat: expose from loro crate 2023-03-21 11:09:12 +08:00
leeeon233
9544e27be4 feat: add delta compose 2023-03-01 14:12:05 +08:00
leeeon233
5b6f864479 feat: init nodejs bindgen 2023-02-16 11:22:50 +08:00
Zixuan Chen
9748779f08
Bench: report (#49) 2022-12-27 14:18:46 +08:00
Zixuan Chen
594b60dafb
Perf store cache in parent node (#36)
* refactor: make internal and leaf use same type of cache

* refactor: add cache update

* test : add normalization to arb test

* test: fuzz

* fix: internal insert bug

* fix: missing utf16

* test: fix test sub overflow

* feat: use heapless for binary heap

* refactor: refine warning

* test: reduce test time

* perf: reduce computation when finding pos

* bench: fix ignore parse time in benching

* feat: make it compile in new sig (should be merged)

* fix: type err

* fix: fix type err

* fix: cache when merge & borrow

* refactor: simplify code

* fix: cumulated tree trait bug

* fix: a few fatal bugs (still buggy)

* fix: global tree trait

* refactor: rm an unused fn

* fix: insert at cursor bug

* fix: in cursor insert cache may be invalid

strip the checker there

* chore: remove needless check

* refactor: add inline to methods

* test: remove cfg=mem for mem example

* fix: type err
2022-12-06 16:34:46 +08:00
Zixuan Chen
7a6e50931d chore: replace justfile with deno task 2022-11-21 12:50:15 +08:00
Zixuan Chen
8f7a5a08e0 refactor: fix warning and remove dead codes 2022-11-18 21:16:29 +08:00
Zixuan Chen
1ca3f0e774 refactor: rename feature fuzzing to test_utils 2022-11-14 10:49:42 +08:00
Zixuan Chen
743e2b597b chore: fix all warnings 2022-11-11 22:44:18 +08:00
Zixuan Chen
9d48e5df88 refactor: fix type error 2022-10-31 12:33:44 +08:00
Zixuan Chen
e0a472fd1a feat: basic wasm interface 2022-10-31 12:22:07 +08:00
Zixuan Chen
16e3d6f3cb chore: bk 2022-10-28 17:19:58 +08:00
Zixuan Chen
906aebfa8a fix: a few common ancestors bugs
still buggy
2022-10-26 23:31:34 +08:00
Zixuan Chen
d28fa407ea chore: update config 2022-10-26 23:31:34 +08:00
Zixuan Chen
5ca3a42a0b test: add fuzz and fix a few iter bugs 2022-10-26 23:31:34 +08:00
Zixuan Chen
3ec2aed1a6 refactor: less unsafe in loro-core 2022-10-26 23:31:34 +08:00
Zixuan Chen
bd1b0a2215 feat: init content map 2022-10-26 23:31:34 +08:00
Zixuan Chen
c8a83fe676 fix: post delete handler 2022-08-16 16:46:03 +08:00
Zixuan Chen
590a6e8ee6 refactor: reset snapshot 2022-07-25 13:00:22 +08:00
Zixuan Chen
42cc347be4 chore: setup justfile 2022-07-21 00:39:19 +08:00