Commit graph

1358 commits

Author SHA1 Message Date
Leon Zhao
e111c519e3
refactor: setting parent only in state (#245)
* refactor: set parent in state
2024-01-12 16:46:31 +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
5f1353791d
Remove txn abort and reduce mem usage (#240)
* 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
2024-01-08 17:29:11 +08:00
Zixuan Chen
e2cf29f3a8
Fix time travel issue (#241)
* fix: time travel issue

* docs: refine comment

* fix: fix start vv in diff_calc apply change
2024-01-08 17:02:32 +08:00
Zixuan Chen
08390cb0de
chore: loro-crdt v0.8.0 2024-01-05 16:11:09 +08:00
Zixuan Chen
a30abf7af1
chore: upgrade debug-log to fix type issue 2024-01-05 16:07:47 +08:00
Zixuan Chen
aaec64a503
Update debug-log (#236)
* chore: use new version of debug-log

* fix: rm group_end
2024-01-05 12:12:04 +08:00
Zixuan Chen
92305f8917
chore: add checks for tracker (#238) 2024-01-05 12:10:50 +08:00
Leon Zhao
76e3f97ff9
feat: use string as peer type in wasm (#234) 2024-01-05 12:06:13 +08:00
Zixuan Chen
bf3b442e97
Fix time travel issue in Tracker (#235)
This pull request fixes an issue in the Tracker module where only the target span was forwarded during forwarding instead of forwarding all content from vv to the target opid. This resulted in errors in current_vv. The issue is resolved by updating the forward function in the Tracker module to include the entire range of content to be forwarded.

It also fixed the inconsistent issue in richtext between style anchors and style ranges.

---------

Co-authored-by: leeeon233 <leeeon233@gmail.com>
2024-01-05 12:05:39 +08:00
Zixuan Chen
00f158c0df
Update loro_value! macro and add binary support (#231)
* docs: update loro_value! doc

* fix: type errors
2024-01-04 22:58:21 +08:00
Zixuan Chen
13a3078408
Refactor container states and add consistency checks (#237)
* refactor: make container states can get their ids

* test: add utils to test consistency between the current states and diff calc

* test: add state diff calc consistency check
2024-01-03 21:57:31 +08:00
Zixuan Chen
8be7cf0412
fix: tracker delete err when the update is partially included (#232) 2024-01-02 20:11:36 +08:00
Zixuan Chen
a6be7d2ea6
refactor: make InternalString an internal struct (#233) 2024-01-02 20:11:22 +08:00
Leon zhao
a4c30f7a4b
test: add richtext fuzz (#224)
This PR adds fuzz for richtext, adding new tests covering checkout, event, and time machine
2024-01-02 17:13: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
Zixuan Chen
727b5c2518
Add benchmark utils that simulate drawing workflow (#229)
* chore: add benchmark utils that simulate drawing workflow

* chore: use markdown as table default style

* chore: init sheet simulating
2023-12-28 18:00:34 +08:00
Zixuan Chen
6a2d0f8fef
test: fix fuzz test config 2023-12-26 18:09:55 +08:00
Zixuan Chen
9477717e3e
chore: bump loro-crdt versions to v0.7.1 2023-12-26 18:01:14 +08:00
Leon zhao
012abe97c3
fix: richtext undo item merge error (#227) 2023-12-26 11:06:27 +08:00
Zixuan Chen
612745aa8c
Fix issue with richtext's applyDelta() behavior (#226)
* fix: [LORO-371] The behavior of richtext's `applyDelta()` is not entirely correct #225

* test: add corresponding test

Fixes #225
2023-12-21 11:40:39 +08:00
Zixuan Chen
c2877e8468
chore: bump version 2023-12-14 10:38:54 +08:00
Leon zhao
442f2561a1
Remove prelim feature (#215)
* chore: remove prelim temporarily
2023-12-13 10:25:00 +08:00
Zixuan Chen
546cadf26c
refactor(wasm): invoke setPanicHook when starting 2023-12-08 16:58:41 +08:00
Zixuan Chen
ce36f8adbd
chore: bump version 2023-12-07 15:27:22 +08:00
Zixuan Chen
699c2c73a5
Fix partial inclusion bug in Tracker (#214)
* fix: partial inclusion bug in Tracker

* fix: rm redundant logs
2023-12-07 15:25:33 +08:00
Zixuan Chen
33d06d5cd8
chore: add a few assert msg #210 2023-12-07 14:23:16 +08:00
Zixuan Chen
b689f5b1cd
chore: bump version 2023-12-06 23:39:55 +08:00
Zixuan Chen
ab64881029
fix: text tracker error #211 (#212)
* fix: text tracker error #211

* chore: rm only

* fix: refine
2023-12-06 23:36:21 +08:00
Zixuan Chen
3c735390e9
chore: put tasks into package.json when possible 2023-12-05 17:42:25 +08:00
Zixuan Chen
4112a28607
chore: bump loro-crdt 2023-12-05 14:53:01 +08:00
Zixuan Chen
14c66edcd4
fix: use Object.getPrototypeOf instead of __proto__ 2023-12-05 14:51:31 +08:00
Zixuan Chen
aa87a96286
chore: bump loro-crdt js 2023-12-05 14:31:06 +08:00
Zixuan Chen
d9d28ada61
fix: refine isContainer & getType 2023-12-05 14:28:39 +08:00
Zixuan Chen
acdcb14367
docs: update release steps 2023-12-05 13:59:16 +08:00
Zixuan Chen
bbf8acd767
chore: bump version 2023-12-05 13:58:00 +08:00
Zixuan Chen
6753c2fb7a
chore: refine build script 2023-12-05 13:57:24 +08:00
Zixuan Chen
7a6b0bd259
chore: update access 2023-12-05 13:40:06 +08:00
Zixuan Chen
e4814aa627
chore: init changesets 2023-12-05 13:38:09 +08:00
Zixuan Chen
f4c6b6dce7
refactor: rm compact bytes (#206) 2023-12-05 11:58:09 +08:00
Zixuan Chen
53a7196c52
fix: [LORO-337] Marking should have no effect when the target key value pair exists #204 (#209) 2023-12-05 11:57:58 +08:00
Leon zhao
47fea50dda
Refactor: use ValueOrContainer for diff event (#202)
* feat: use resolved diff as event

* feat: wasm ValueOrContainer event

* fix: cargo fix

* fix: avoid state clone

* chore: add resolve event bench

* test: add handler in event test

* refactor: use resolved as external diff

* chore: cargo fix

* fix: typescript loro value type

* fix: use Arc::new_cyclic

* refactor: bring back sub container
2023-12-05 11:57:41 +08:00
Zixuan Chen
bf1a792933
refactor: only need shared ref on loro doc now (#203) 2023-12-03 14:54:45 +08:00
Zixuan Chen
e342dfc98a
chore: wasm-snip init 2023-11-29 15:07:39 +08:00
Zixuan Chen
ced4f4d5a5
feat: expose subscription to rust api (#200) 2023-11-29 14:39:07 +08:00
Zixuan Chen
cccb4f3957
perf(wasm): reduce wasm size (#198) 2023-11-29 13:59:39 +08:00
Zixuan Chen
208c673b2d
refactor: list now use the same tracker as text (#197)
Resolve #122
2023-11-29 10:45:00 +08:00
Zixuan Chen
fddcf7a321
chore: publish v0.2.2 with refined doc 2023-11-28 23:23:07 +08:00
Zixuan Chen
cd8be80a6f
docs: refine rust api doc 2023-11-28 23:20:57 +08:00
Zixuan Chen
1eae5ea495
chore: bump loro rust to v0.2.1 2023-11-28 22:22:09 +08:00