jupyter-server / pycrdt

CRDTs based on Yrs.
https://jupyter-server.github.io/pycrdt
MIT License
37 stars 9 forks source link

Expose functionality to manager Y.Doc updates without instantiating Y.Doc (diffUpdate, mergeUpdates, encodeStateVectorFromUpdate) #78

Closed kevinvalk closed 3 weeks ago

kevinvalk commented 6 months ago

Problem

I am working on a platform that has centralized storage for the YDoc. As the centralized server does not need to know anything about the YDoc there is really no point in instantiating a YDoc object and I could get away with only using the encodeStateVectorFromUpdate, diffUpdate, mergeUpdates methods (https://docs.yjs.dev/api/document-updates#example-syncing-clients-without-loading-the-y.doc).

Currently neither https://github.com/y-crdt/ypy nor this project expose those methods. I think it would be rather handy dandy if these basic buffer manipulation methods would be exposed. That way users can simply use those.

Proposed Solution

Expose the update API (in both v1 and v2) format https://github.com/yjs/yjs?tab=readme-ov-file#update-api that work directly on buffers(so mergeUpdates, encodeStateVectorFromUpdate, diffUpdate, convertUpdateFormatV1ToV2, convertUpdateFormatV2ToV1, mergeUpdatesV2, encodeStateVectorFromUpdateV2, diffUpdateV2),

Additional context

I have been following the "separation" between pycrdt and ypy and I do think that this issue may be more applicable to https://github.com/y-crdt/ypy than this project. Then again, ypy is somewhat unmaintained and I do wonder if this request indeed falls outside of the future of this project.

welcome[bot] commented 6 months ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

davidbrochart commented 6 months ago

Why not, but I can't commit if/when I will do it. It would be great if you could open a PR.