The assert_doc and assert_obj macros in automerge/tests::helpers are
useful for writing tests for any application working with automerge
documents. Typically however, you only want these utilities in tests so
rather than packaging them in the main `automerge` crate move them to a
new crate (in the spirit of `tokio_test`)
The logic for `clone` which was updated to support cloning a viewed
document inadverantly left the heads of the cloned document state in
place, which meant that cloned documents could not be `change`d. Set
state.heads to undefined when cloning to allow changing them.
Sometimes you need a cheap copy of a document at a given set of heads
just so you can see what has changed. Cloning the document to do this is
quite expensive when you don't need a writable copy. Add automerge.view
to allow a cheap read only copy of a document at a given set of heads
and add an additional heads argument to clone for when you do want a
writable copy.
The cmake CI seemed to reference a few nonexistent targets for docs and
tests. Remove the doc generation step and point the test CI script at
the generated test program.
Vite apps which use SharedWorker of WebWorker require additional
configuration to get WebAssembly imports to work effectively, add these
to the example.
Continuing our theme of treating all languages equally, move
wrappers/javascript to javascrpit. Automerge libraries for new languages
should be built at this top level if possible.
After some discussion with PVH I realise that the repo structure in the
last reorg was very rust-centric. In an attempt to put each language on
a level footing move the rust code and project files into ./rust
Fixes#433. `getObjectId` was previously throwing an error if passed
something which was not an object. In the process of fixing this I
simplified the logic of `getObjectId` by modifying automerge-wasm to not
set the OBJECT_ID hidden property on objects which are not maps, lists,
or text - it was previously setting this property on anything which was
a JS object, including `Date` and `Uint8Array`.
Whilst we only have one wrapper library, we anticipate more.
Furthermore, the naming of the `wrappers` directory makes it clear what
the role of the JS codebase is.
For larger rust projects it's common to put all rust code in a directory
called `crates`. This helps in general by reducing the number of
directories in the top level but it's particularly helpful for us
because some directories _do not_ contain Rust code. In particular
`automerge-js`. Move rust code into `/crates` to make the repo easier
to navigate.
With the `OpObserver` moving to the transaction rather than being passed
in to the `Transaction::commit` method we have needed to add a way to
get the observer back out of the transaction (via
`Transaction::observer` and `AutoCommit::observer`). This `Observer`
type is then used to handle patch generation logic. However, there are
cases where we might not want an `OpObserver` and in these cases we can
execute various things fast - so we need to have something like an
`Option<OpObserver>`. In order to track the presence or otherwise of the
observer at the type level introduce
`automerge::transaction::observation`, which is a type level `Option`.
This allows us to efficiently choose the right code paths whilst
maintaining correct types for `Transaction::observer` and
`AutoCommit::observer`
This dependency was added in a PR which is no longer relevant as we've
switched to depending directly on `@automerge/automerge-wasm` and
testing by running a local NPM registry.