Ywasm
This project is a wrapper around Yrs and targets Web Assembly bindings.
It's a library used on collaborative document editing using Conflict-free Replicated Data Types.
This enables to provide a shared document editing experience on a client devices without explicit requirement for hosting a single server - CRDTs can resolve potential update conflicts on their own with no central authority - as well as provide first-class offline editing capabilities, where document replicas are modified without having connection to each other, and then synchronize automatically once such connection is enabled.
Example
import * as Y from 'ywasm';
const doc = new Y.YDoc()
const text = doc.getText('name')
text.insert(0, 'hello world', { bold: true })
const remoteDoc = new Y.YDoc()
const remoteText = remoteDoc.getText('name')
const remoteSV = Y.encodeStateVector(remoteDoc)
const update = Y.encodeStateAsUpdate(doc, remoteSV)
Y.applyUpdate(remoteDoc, update)
const str = remoteText.toString()
console.log(str)