import * as automerge from "https://deno.land/x/automerge@2.2.2/next.ts";
The next API
This module contains new features we are working on which are backwards incompatible with the current API of Automerge. This module will become the API of the next major version of Automerge
Differences from stable
In the stable API text objects are represented using the Text class.
This means you must decide up front whether your string data might need
concurrent merges in the future and if you change your mind you have to
figure out how to migrate your data. In the unstable API the Text
class is
gone and all string
s are represented using the text CRDT, allowing for
concurrent changes. Modifying a string is done using the splice
function. You can still access the old behaviour of strings which do not
support merging behaviour via the RawString class.
This leads to the following differences from stable
:
- There is no
unstable.Text
class, all strings are text objects - Reading strings in an
unstable
document is the same as reading any other javascript string - To modify strings in an
unstable
document use splice - The AutomergeValue type does not include the Text class but the RawString class is included in the ScalarValue type
CHANGELOG
- Rename this module to
next
to reflect our increased confidence in it and stability commitment to it - Introduce this module to expose the new API which has no
Text
class
Classes
The most basic CRDT: an integer value that can be changed only by incrementing and decrementing. Since addition of integers is commutative, the value trivially converges. | |
c Int | |
c Uint |
Functions
Apply changes received from another document | |
Get the block marker at the given index | |
Update the contents of an automerge document | |
Make a change to the document as it was at a particular point in history | |
Make a full writable copy of an automerge document | |
Decode some binary data into a SyncState | |
Function for use in change which deletes values from a list at a given index | |
f diff | Create a set of patches representing the change from one set of heads to another |
f dump | |
Make a change to a document which does not modify the document | |
encode a SyncState into binary to send over the network | |
f free | Explicity free the memory backing a document. Note that this is note
necessary in environments which support
|
f from | Create an automerge document from a POJO |
Generate a sync message to send to the peer represented by | |
Get the actor ID associated with the document | |
Get all the changes in a document | |
Get the changes which are in | |
Get the conflicts associated with a property | |
Returns a cursor for the given position in a string. | |
Returns the current index of the cursor. | |
Get the hashes of the heads of this document | |
Get the binary representation of the last change which was made to this doc | |
Get any changes in | |
Return the object ID of an arbitrary javascript value | |
f init | Create a new automerge document |
Create a new, blank SyncState | |
Function for use in change which inserts values into a list at a given index | |
Delete the block marker at the given index | |
f load | Load an automerge document from a compressed document produce by save |
Load changes produced by saveIncremental, or partial changes | |
f mark | |
Merge | |
Update a document and our sync state on receiving a sync message | |
f save | Export the contents of a document to a compressed format |
Create binary save data to be appended to a save file or fed into loadIncremental | |
Return the text + block markers at a given path | |
Modify a string | |
Insert a new block marker at the given index | |
f toJS | |
Update the block marker at the given index | |
Update the spans at the given path | |
Update the value of a string | |
f view | Make an immutable view of an automerge document as at |
Type Aliases
Options passed to loadIncremental, applyChanges, and receiveSyncMessage | |
The type returned from changeAt | |
Function which is called by change when making changes to a | |
Options passed to change, and emptyChange | |
T Doc | An automerge document. |
T Mark | |
Callback which is called by various methods in this library to notify the user of what changes have been made. | |
T Prop | |
T Span | |
An opaque type tracking the state of sync with a remote peer |