59 个版本

0.19.2 2024 年 7 月 17 日
0.18.8 2024 年 5 月 10 日
0.18.2 2024 年 3 月 27 日
0.17.2 2023 年 12 月 7 日
0.1.0 2021 年 10 月 14 日

#78WebAssembly

Download history 44/week @ 2024-04-24 795/week @ 2024-05-01 149/week @ 2024-05-08 1/week @ 2024-05-15 1/week @ 2024-06-26 252/week @ 2024-07-03 27/week @ 2024-07-10 182/week @ 2024-07-17 367/week @ 2024-07-24 77/week @ 2024-07-31

626 次每月下载

MIT 许可证

1.5MB
32K SLoC

Ywasm

此项目是围绕 Yrs 的包装,并针对 Web Assembly 绑定。

它是一个用于协同文档编辑的库,使用无冲突副本数据类型。这使得在客户端设备上提供共享的文档编辑体验,而无需显式托管单个服务器 - CRDT 可以在没有中央权威的情况下自行解决潜在更新冲突 - 同时还提供一流的离线编辑功能,文档副本在彼此没有连接的情况下进行修改,并在连接启用后自动同步。

文档

示例

import * as Y from 'ywasm';

const doc = new Y.YDoc()
const text = doc.getText('name')

// append text to our collaborative document
text.insert(0, 'hello world', { bold: true })

// simulate update with remote peer
const remoteDoc = new Y.YDoc()
const remoteText = remoteDoc.getText('name')

// in order to exchange data with other documents
// we first need to create a state vector
const remoteSV = Y.encodeStateVector(remoteDoc)
// now compute a differential update based on remote document's state vector
const update = Y.encodeStateAsUpdate(doc, remoteSV)
// both update and state vector are serializable, we can pass them over the wire
// now apply update to a remote document
Y.applyUpdate(remoteDoc, update)

const str = remoteText.toString()
console.log(str)

依赖项

~8–12MB
~203K SLoC