Commit graph

298 commits

Author SHA1 Message Date
Orion Henry
e679c4f6a0 v0 wip 2022-01-31 14:02:23 -05:00
Orion Henry
9ff0c60ccb add cra example code 2022-01-28 18:05:33 -05:00
Orion Henry
7b3db2f15a clippy lint 2022-01-20 14:17:11 -08:00
Orion Henry
54fec3e438 lamport compare was backward on actorids and so was value resolution 2022-01-20 14:17:11 -08:00
Andrew Jeffery
0388c46480 Remove unused is_empty function on optrees 2022-01-19 15:16:02 -08:00
Andrew Jeffery
429426a693 Fix removal and rollback
Credit to @orionz
2022-01-19 15:16:02 -08:00
Andrew Jeffery
2015428452 Detect object type before getting length 2022-01-19 15:16:02 -08:00
Andrew Jeffery
812c7df3a7 Add length tests to props tests 2022-01-19 15:16:02 -08:00
Andrew Jeffery
5867c8d131 Fixup CI 2022-01-19 15:11:04 -08:00
Andrew Jeffery
0ccf36fe49 Add test and doc update for setting scalarvalues 2022-01-19 15:11:04 -08:00
Orion Henry
8b2f0238f3 create sub op tree at a time when we know the type 2022-01-18 09:11:46 -08:00
Orion Henry
acbf394290 cleanup some dead code 2022-01-14 06:27:42 -08:00
Orion Henry
b30a2b9cc1 give Counter its own type 2022-01-14 06:27:42 -08:00
Orion Henry
d50062b769 move values into the counter type - remove need for vis_window 2022-01-14 06:27:42 -08:00
Orion Henry
e59d24f68b return values are sorted - add counter del test 2022-01-14 06:27:42 -08:00
Orion Henry
fdab61e213 derive default 2022-01-09 08:05:00 -08:00
Orion Henry
45ee5ddbd9 add import/export 2022-01-09 08:05:00 -08:00
Orion Henry
d2a7cc5f75 get sync tests working 2022-01-09 08:05:00 -08:00
Alex Good
1f0a1e4071 Correctly sort actor IDs when encoding changes
This is a port of a fix previously merged into `main`.

The javascript implementation of automerge sorts actor IDs
lexicographically when encoding changes. We were sorting actor IDs in
the order the appear in the change we're encoding. This meant that the
index that we assigned to operations in the encoded change was different
to that which the javascript implementation assigns, resulting in
mismatched head errors as the hashes we created did not match the
javascript implementation.

This change fixes the issue by sorting actor IDs lexicographically. We
make a pass over the operations in the change before encoding to collect
the actor IDs and sort them. This means we no longer need to pass a
mutable `Vec<ActorId>` to the various encode functions, which cleans
things up a little.
2022-01-04 15:28:03 -08:00
Orion Henry
96a8357e36 add hasher for exid 2022-01-03 14:59:34 -05:00
Orion Henry
4c4484b897 fix bug in wasm 2022-01-03 12:58:08 -05:00
Orion Henry
3046cbab35
Replace the OpID API with an object ID
Rather than returning an OpID for every mutation, we now return an
`Option<ObjId>`. This is `Some` only when a `make*` operation was
applied. This `ObjID` is an opaque type which can be used with any
document.
2022-01-01 20:15:02 +00:00
Alex Good
fa936b5a28 Add script to run clippy 2021-12-24 10:18:16 -08:00
Alex Good
001c9befcc Add script to run cargo fmt 2021-12-24 10:18:16 -08:00
Orion Henry
e275334e72 remove dead code and pubs we don't need 2021-12-21 12:23:55 -05:00
Orion Henry
780298b72c docs, tests, code cleanup 2021-12-21 09:23:34 -08:00
Orion Henry
265ce823da implement all the query_at(), add tests, was, cut dead code 2021-12-21 09:23:34 -08:00
Alex Good
6a63d30a56 Add some rust tests
This commit adds a bunch of testing infrastructure as well as most of
the tests from the `legacy_tests.js` file in the js codebase that seem
applicable to this codebase.
2021-12-20 17:54:40 -08:00
Alex Good
f22be2ade7 Make Automerge::visualise succinct, include succ
This abbreviates actor IDs so that object IDs are more readable and also
includes successor operation IDs in the op tables
2021-12-20 09:28:07 -08:00
Alex Good
4181f503aa UPdate Automerge::visualise to work with OpSet
The OpSet has multiple OpTrees in it so we update the visualisation
logic to show an op tree graph for each object in the OpSet.
2021-12-20 09:28:07 -08:00
Alex Good
48e01a6333 Add Automerge::visualise for debugging the optree
The OpTree is a reasonably complicated data structure. This change adds
a method on the OpTree which is then exposed through
`Automerge::visualise` which prints the structure of the OpTree in
graphviz format. Each node in the tree is printed as a simple table of
operations with outgoing edges to tables representing the children of
the node. This is behind a compile time flag (optree-visualisation)
because it's probably not useful except when debugging.
2021-12-20 09:28:07 -08:00
Orion Henry
a305f77de3 Merge branch 'noop' into experiment 2021-12-19 20:08:46 -05:00
Orion Henry
70bd0aee53 simplify index.replace 2021-12-19 19:58:43 -05:00
Orion Henry
1f0989cbb0 break op set into one per object 2021-12-19 14:18:02 -05:00
Alex Good
962340805c
automerge::set - don't generate ops for noops
Repeatedly setting the same value for a particular (obj, key)
combination now no longer generates an operation. To allow this we
modify the return value of `automerge::set` so that it may return an
`Option<OpId>` instead of an `OpId`.

Signed-off-by: Alex Good <alex@memoryandthought.me>
2021-12-18 15:57:03 +00:00
Orion Henry
1739a7e7b1 encode/decode sync in wasm 2021-12-17 21:14:16 -05:00
Orion Henry
9c237c7f00 remove expanded_op and internal_op_type 2021-12-17 12:39:26 -05:00
Orion Henry
702117b996 move change_hash out of legacy, removing diff 2021-12-17 12:13:43 -05:00
Orion Henry
90244236c3 move important items out of legacy 2021-12-17 11:33:05 -05:00
Orion Henry
6b517b9894 move things we need out of legacy 2021-12-17 11:04:35 -05:00
Orion Henry
b2f339e714 update packages - get legacy tests passing 2021-12-17 10:36:02 -05:00
Orion Henry
4c83416abf cheers to andrew who found a faster B value on the tree 2021-12-17 10:19:15 -05:00
Orion Henry
0ac2407815 cargo fmt 2021-12-17 09:52:57 -05:00
Orion Henry
db3a43c5b6 import protocol into legacy 2021-12-16 20:39:08 -05:00
Andrew Jeffery
0c417f02b2 Improve ergonomics of the main API 2021-12-16 05:46:01 -08:00
Andrew Jeffery
1bd54d5489 Optimise last function on op_tree
Rather than iterating through the children we can just skip straight to
the last. The last element is always in a leaf so we also don't need to
care about intermediate values.
2021-12-16 09:45:12 +00:00
Orion Henry
26ccaf63cc readme and new tests 2021-12-15 19:07:39 -05:00
Orion Henry
0c284992cd stub out text_at 2021-12-13 10:52:06 -05:00
Orion Henry
850db4a35b objid vs opid was not useful as an external type 2021-12-13 10:45:43 -05:00
Orion Henry
0c96d504bc getting ready for at(clock) api 2021-12-13 10:28:49 -05:00