Git Product home page Git Product logo

automerge-rs's Introduction

Automerge RS

Automerge logo

homepage main docs ci

This is a rust implementation of the Automerge file format and network protocol.

If you are looking for the origional automerge-rs project that can be used as a wasm backend to the javascript implementation, it can be found here.

Status

This project has 4 components:

  1. automerge - a rust implementation of the library. This project is the most mature and being used in a handful of small applications.
  2. automerge-wasm - a js/wasm interface to the underlying rust library. This api is generally mature and in use in a handful of projects as well.
  3. automerge-js - this is a javascript library using the wasm interface to export the same public api of the primary automerge project. Currently this project passes all of automerge's tests but has not been used in any real project or packaged as an NPM. Alpha testers welcome.
  4. automerge-c - this is a c library intended to be an ffi integration point for all other languages. It is currently a work in progress and not yet ready for any testing.

How?

The current iteration of automerge-rs is complicated to work with because it adopts the frontend/backend split architecture of the JS implementation. This architecture was necessary due to basic operations on the automerge opset being too slow to perform on the UI thread. Recently @orionz has been able to improve the performance to the point where the split is no longer necessary. This means we can adopt a much simpler mutable API.

The architecture is now built around the OpTree. This is a data structure which supports efficiently inserting new operations and realising values of existing operations. Most interactions with the OpTree are in the form of implementations of TreeQuery - a trait which can be used to traverse the optree and producing state of some kind. User facing operations are exposed on an Automerge object, under the covers these operations typically instantiate some TreeQuery and run it over the OpTree.

Development

Please feel free to open issues and pull requests.

Running CI

The steps CI will run are all defined in ./scripts/ci. Obviously CI will run everything when you submit a PR, but if you want to run everything locally before you push you can run ./scripts/ci/run to run everything.

Running the JS tests

You will need to have node, yarn, rust and wasm-pack installed.

To build and test the rust library:

  $ cd automerge
  $ cargo test

To build and test the wasm library:

  ## setup
  $ cd automerge-wasm
  $ yarn

  ## building or testing
  $ yarn build
  $ yarn test

  ## without this the js library wont automatically use changes
  $ yarn link

  ## cutting a release or doing benchmarking
  $ yarn release

To test the js library. This is where most of the tests reside.

  ## setup
  $ cd automerge-js
  $ yarn
  $ yarn link "automerge-wasm"

  ## testing
  $ yarn test

And finally, to build and test the C bindings with CMake:

## setup
$ cd automerge-c
$ mkdir -p build
$ cd build
$ cmake -S .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
## building and testing
$ cmake --build .

To add debugging symbols, replace Release with Debug. To build a shared library instead of a static one, replace OFF with ON.

The C bindings can be built and tested on any platform for which CMake is available but the steps for doing so vary across platforms and are too numerous to list here.

Benchmarking

The edit-trace folder has the main code for running the edit trace benchmarking.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.