Commit graph

1358 commits

Author SHA1 Message Date
Zixuan Chen
a32b75ad3b
fix(js): allow convert from undefined to LoroValue (#323) 2024-04-18 09:47:00 +08:00
Zixuan Chen
2fc44206fb
Fix rich text cursor pos (#324)
* test: add text cursor test

* fix: should return event index
2024-04-18 09:46:50 +08:00
github-actions[bot]
e8352ad38d
chore: version packages (#321)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-17 15:15:17 +08:00
Zixuan Chen
598d97e013
chore: prerelease 2024-04-17 15:11:07 +08:00
Zixuan Chen
01b45598d8
refactor: parse uint8array to binary (#320)
and refine Awareness type in ts
2024-04-17 15:09:03 +08:00
Zixuan Chen
27566ed13a
docs: update how to publish new npm pkgs 2024-04-14 22:21:58 +08:00
github-actions[bot]
d51c566326
chore: version packages (#319)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-14 22:15:07 +08:00
Zixuan Chen
8f8d0989ca
ci: fix release-wasm 2024-04-14 22:04:59 +08:00
Zixuan Chen
a1fc2e3db6
ci: add release 2024-04-14 21:55:35 +08:00
Zixuan Chen
37311a52c8
feat: awareness (#318)
* feat: awareness

* refactor: new api wrapper for js & fix consistency

* chore: rm redundant file

* refactor: expose it to the rust crate
2024-04-14 20:44:20 +08:00
Zixuan Chen
08253f9d87
chore(ci): fix deno type conflict 2024-04-12 18:21:49 +08:00
Zixuan Chen
df8bf029a6
chore: experimentally publish to jsr 2024-04-12 17:33:28 +08:00
Zixuan Chen
8752c229f9
chore(js): bump version 2024-04-10 12:30:21 +08:00
Zixuan Chen
1918cd7ac3
refactor: rename stable pos to cursor (#317) 2024-04-10 12:26:12 +08:00
Zixuan Chen
454b4088a6
chore(rs): bump versions of rust crates 2024-04-09 16:23:48 +08:00
Zixuan Chen
095e93b327
chore(wasm): bump version 2024-04-09 16:10:28 +08:00
Zixuan Chen
aca14fda10
fix(ts): types 2024-04-09 16:05:30 +08:00
Zixuan Chen
81ae2abacc
Cursors (#290)
This PR introduces support for retrieving and querying cursors.

## Motivation

Using "index" to denote cursor positions can be unstable, as positions may shift with document edits. To reliably represent a position or range within a document, it is more effective to leverage the unique ID of each item/character in a List CRDT or Text CRDT.

## Updating Cursors

Loro optimizes State metadata by not storing the IDs of deleted elements. This approach, while efficient, complicates tracking cursor positions since they rely on these IDs for precise locations within the document. The solution recalculates position by replaying relevant history to update stable positions accurately. To minimize the performance impact of history replay, the system updates cursor info to reference only the IDs of currently present elements, thereby reducing the need for replay.

Each position has a "Side" information, indicating the actual cursor position is on the left, right, or directly in the center of the target ID.

Note: In JavaScript, the offset returned when querying a Stable Position is based on the UTF-16 index.

# Example

```ts
const loro = new Loro();
const list = loro.getList("list");
list.insert(0, "a");
const pos0 = list.getStablePos(0);
list.insert(1, "b");
{
  const ans = loro.queryStablePos(pos0!);
  expect(ans.offset).toEqual(0);
  expect(ans.side).toEqual(0);
  expect(ans.update).toBeUndefined();
}
list.insert(0, "c");
{
  const ans = loro.queryStablePos(pos0!);
  expect(ans.offset).toEqual(1);
  expect(ans.side).toEqual(0);
  expect(ans.update).toBeUndefined();
}
list.delete(1, 1);
{
  const ans = loro.queryStablePos(pos0!);
  expect(ans.offset).toEqual(1);
  expect(ans.side).toEqual(-1);
  expect(ans.update).toBeDefined();
}
```
2024-04-09 16:01:37 +08:00
Zixuan Chen
205fa94653
chore: bump loro-crdt 2024-04-05 02:25:25 +08:00
Zixuan Chen
9365cc049c
refactor(ts): make method types better (#315)
* refactor(ts): make method types better

* docs: add missing docs omitted by skip_typescript
2024-04-05 01:43:36 +08:00
Zixuan Chen
a215d88c03
refactor: add concrete type for each different container (#313) 2024-04-03 19:24:48 +08:00
Zixuan Chen
7561448323
refactor: replace "local" and "fromCheckout" in event with "triggeredBy" (#312)
* refactor: replace "local" and "fromCheckout" in event with "triggeredBy"

* refactor: simplify the name to `by`
2024-04-03 17:56:01 +08:00
Zixuan Chen
fc20f1f7d0
chore: add coverage report cli (#311)
* chore: add coverage report cli

* chore: ignore trace-*
2024-04-02 22:27:45 +08:00
Zixuan Chen
756d7a9404
fix: type error caused by merging 2024-04-01 17:42:02 +08:00
Leon Zhao
51890ff8d8
fix: decode iter return result by updating columnar to 0.3.4 (#309) 2024-04-01 17:29:07 +08:00
Zixuan Chen
3da28459b0
feat: decode import blob meta (#307)
* feat: decode import blob meta

* chore: rm logs
2024-04-01 17:25:43 +08:00
Zixuan Chen
3c124f454b
feat: access value/container by path (#308)
* feat: access elem by path

* fix: parse tree node index by str

* fix: reuse treeid try_from

* chore: rename methods on lib.rs

---------

Co-authored-by: Leon Zhao <leeeon233@gmail.com>
2024-04-01 17:25:12 +08:00
Zixuan Chen
c788ff1727
docs: clarify that peer id should be convertable to a u64 (#306)
#305
2024-04-01 10:06:13 +08:00
Zixuan Chen
25b0f8096e
docs: refine wasm docs (#304) 2024-04-01 09:03:32 +08:00
Zixuan Chen
1015ee33a7
chore: bump loro-crdt 2024-03-31 02:12:06 +08:00
Zixuan Chen
367975e1ac
fix: type error 2024-03-31 02:10:49 +08:00
Zixuan Chen
c3d5e92407
refactor: rm isAttached type on containers (#303) 2024-03-31 02:06:57 +08:00
Zixuan Chen
a8c059d96b
fix: type mismatch and add type info for whether a container is attached (#302) 2024-03-31 01:12:08 +08:00
Zixuan Chen
3fe9cc1969
fix: avoid bundler change the classname (#301) 2024-03-31 01:11:55 +08:00
Zixuan Chen
422e442012
chore: bump loro-crdt to 0.13.0 2024-03-30 11:44:18 +08:00
Zixuan Chen
9ecc0a90b1
refactor!: Add prelim support, making creating sub container easier (#300)
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.
2024-03-30 11:38:24 +08:00
Zixuan Chen
edb0ef75f6
chore: Update VSCode settings and dependencies (#299) 2024-03-30 06:53:22 +08:00
Zixuan Chen
e58e4e3fdd
chore: bump loro-crdt to v0.12.0 2024-03-27 23:53:34 +08:00
Zixuan Chen
673e36a7ba
feat: add getParent for each handler (#297)
* feat: add getParent for each handler

* fix: type err
2024-03-27 18:43:48 +08:00
Zixuan Chen
9a673acfde
feat: add getOrCreate on map (#296) 2024-03-27 17:52:53 +08:00
Zixuan Chen
c8b8694908
refactor: extract common methods on handlers (#295)
Co-authored-by: Leon <leeeon233@gmail.com>
2024-03-25 11:58:51 +08:00
Leon Zhao
83d4950a4e
fix: empty diff emits event (#292) 2024-03-14 20:46:18 +08:00
Zixuan Chen
f7fe0d4b26
test: reduce overall test time by splitting the fuzz 10s (#291) 2024-03-12 21:10:30 +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
1233b8df82
refactor: replace debug-log with tracing (#285)
* refactor: replace debug-log with tracing

* chore: fix setDebug in wasm

* chore: rm useless comments
2024-03-04 20:06:24 +08:00
Zixuan Chen
7e07e4dad4
perf: reduce mem usage in fugue span (#283) 2024-03-04 12:02:49 +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
Zixuan Chen
a5fce60883
perf: avoid a few clones in wasm (#288) 2024-03-02 16:26:34 +08:00
Leon Zhao
1db510104e
fix: delete list event hint assert (#289) 2024-03-02 16:25:57 +08:00
Leon Zhao
da782c7659
fix: tree child container index (#284) 2024-03-02 16:21:31 +08:00