Commit graph

972 commits

Author SHA1 Message Date
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
ef89520d7c more tests for wasm 2022-01-03 14:59:46 -05: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
Alex Good
dc8140cb0b fmt 🙄 2022-01-01 20:17:38 +00: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
de5332af05 Run the js_test in CI
We add a script for running the js tests in `scripts/ci/js_tests`. This
script can also be run locally. We move the `automerge-js` package to
below the `automerge-wasm` crate as it is specifically testing the wasm
interface. We also add an action to the github actions workflow for CI
to run the js tests.
2021-12-30 17:30:38 -05:00
Orion Henry
6932bdff08 package.json can run on windows now 2021-12-29 14:16:15 -05:00
Alex Good
7087cbdf69 Add CI to README 2021-12-24 10:18:16 -08:00
Alex Good
e98eca3a08 Add github action 2021-12-24 10:18:16 -08:00
Alex Good
4e043e06c2 Add script to run all the CI steps 2021-12-24 10:18:16 -08: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
Alex Good
05a7d24f77 Add script to run tests 2021-12-24 10:18:16 -08:00
Alex Good
216b4eed82 Add deny.toml and a script for calling cargo deny
In order to get cargo deny to pass we also update a few dependencies and
add licenses
2021-12-24 10:18:16 -08:00
Orion Henry
9d0caab6b6 import the uuid tests 2021-12-22 15:36:57 -05:00
Orion Henry
4c90b5f822 get js text tests working 2021-12-22 15:08:31 -05:00
Andrew Jeffery
7f115964f1 Unwrap text set in benchmark 2021-12-22 10:35:42 +00: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
8eb147333c use value_at() in the js wrapper 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
Alex Good
e435957125 Update README with details of the new implementation 2021-12-19 17:12:56 -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
b7eae836d5 Merge branch 'experiment' of github.com:automerge/automerge-rs into experiment 2021-12-19 14:20:55 -05:00
Orion Henry
1f0989cbb0 break op set into one per object 2021-12-19 14:18:02 -05:00
Andrew Jeffery
e6b806b458
Add criterion benchmarks for Rust (#248) 2021-12-19 14:59:40 +00: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
fc89a26302 first pass for sync in js/wasm 2021-12-18 00:22:20 -05:00
Orion Henry
25eeb256e0 remove cargo.lock from project 2021-12-17 21:19:33 -05:00
Orion Henry
503ee1ca19 Merge branch 'experiment' of github.com:automerge/automerge-rs into experiment 2021-12-17 21:15:05 -05:00
Orion Henry
1739a7e7b1 encode/decode sync in wasm 2021-12-17 21:14:16 -05:00
Andrew Jeffery
ed6975d7ee Make a rust workspace 2021-12-17 23:41:34 +00:00
Andrew Jeffery
a0f9612be9 Fixup readme and add makefile 2021-12-17 23:37:21 +00:00
Andrew Jeffery
c5f6ffc4cd Fix wasm build 2021-12-17 23:36:38 +00: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
Andrew Jeffery
a2191e2643 Add nix config 2021-12-17 11:48:14 +00: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