These don't have the ability to preserve the semantics of the reference
based transaction model and so can make use of the nicer auto
transaction model.
This removes the requirement for `&mut self`s on some of the immutable
methods on `Automerge` which can be quite inconvenient.
I've reimplemented the main functions on `Automerge` that manipulate
state to create a transaction for their op for ease of use but not
performance. I've updated the edit trace to run in a single
transaction, like on a page load.
Wasm API still needs working on at the moment to expose this properly.
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.
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.
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.