Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Nigel Gilbert
    @micrology
    PRSM, a collaborative system mapping tool, has users' cursors with separate colours. You'll find the code for this at https://github.com/micrology/prsm/blob/master/js/prsm.js, line 3697 onwards. I hope it helps.
    1 reply
    YarnBall
    @yarnball
    Hi all, can someone point me to a current/good example of how to setup persistence on a server? I cant seem to find a recent oen
    Joshua Fontany
    @joshuafontany
    Hi. Is there anything in the Yjs libraries that would allow me to generate a quill-delta-diff of two texts? I need it for my wiki-(editor)-binding.
    Namit Chadha
    @nc
    @yarnball have you seen? https://github.com/yjs/y-redis
    Stefan de Konink
    @skinkie

    I am completely new to Yjs (and to npm etc.) I notice when I try to install y-array and y-text those have dependency issues. Could not resolve dependency: peer yjs@">= 12.3.1 < 13.0.0" from y-array@10.1.4

    Is this a known issue?

    Namit Chadha
    @nc
    @skinkie i think you just install 'yjs', does that not work?
    YarnBall
    @yarnball
    @nc I have seen that before, but I didnt know redis could/should be used as storage
    I was thinking more like something SQL right? This will be for large strings? Or is that not generally how it is used
    Will Heslam
    @willheslam

    Hello everyone :)
    I've had some trouble getting the subdocs example code to work
    https://docs.yjs.dev/api/subdocuments

    and I suspect it's due to this line:

    It is up to the providers to sync subdocuments.

    as I'm trying to manually sync the two root docs using
    Y.applyUpdateV2(rootDoc2, Y.encodeStateAsUpdateV2(rootDoc1))

    I'm assuming then that I need to use a fully fledged provider that can sync subdocuments properly.
    Looking at the provider list, there doesn't seem to be anything useful for local testing - some kind of in-memory provider (beyond the manual application of updates as in my example above). Is this something that exists, and what have people used instead?
    Would I have to implement it myself, similar to the code at the bottom of the subdocs docs page?
    e.g. doc.on('subdocs', ...
    Am I barking up the wrong tree here and overcomplicating it for myself?

    1 reply
    kapil verma
    @kapv89

    Hi all, can someone point me to a current/good example of how to setup persistence on a server? I cant seem to find a recent oen

    @yarnball you can check out this repo - https://github.com/kapv89/yjs-scalable-ws-backend

    dalperin
    @dalperin:matrix.org
    [m]
    Hey all, I don't know if this will be helpful to anyone else but I've open sourced my version of y-websocket with subdocument support. I'll update the example server implementation to make use of the subdoc protocol I added later on but for now a working version is here: https://github.com/DAlperin/y-websocket/blob/master/src/y-websocket.js
    1 reply
    Chance
    @chanced

    i'm curious if the benefits of the current way of encoding/decoding data (lib0) are significant enough to warrant the added cost in complexity and resistance to adoption in other languages?

    For example, readVarUint:

    numbers < 2^7 is stored in one bytlength
    numbers < 2^14 is stored in two bylength

    That pretty much eliminates using the standard buffer.readUInt8, for example, right?

    so in order for me to safety read the messageType, for example, I have to instantiate a decoder?
    Chance
    @chanced
    why not just work with buffers, utilizing the standard methods? with something like https://github.com/feross/buffer for the browser?

    i'm trying to understand the reasoning and whether or not a port to go would be feasible.

    uint8 would be a bad example.

    Kevin Jahns
    @dmonad

    There are few libraries that do variable-length encoding. buffer.readUint8 still uses 8 bytes for each integer. Furthermore, lib0/encoding also supports other types of efficient encoding and includes a library for RLE encoding. Node libraries are super bloated and have thousands of dependencies from questionable sources. And another thing: lib0 is much more performant than any other alternative. In some cases, lib0 is 1000x faster than alternatives.

    If you are interested in writing a Go binding for Yjs, then I recommend to have a look at the yjs/y-crdt project that already includes some language bindings to other languages. I recommend to join the next Y Community meeting if you have any questions.

    Chance
    @chanced
    @dmonad thats fair, thank you for the response
    Chance
    @chanced
    gotta say, you've done awesome work with yjs man.
    Kevin Jahns
    @dmonad
    Thanks @chanced
    Philip Aarseth
    @philipaarseth
    What is the best approach to clearing a yMap? seems there is no .clear() function so is looping through really the only alternative?
    wanuj
    @wanuj
    @dmonad is it possible for you to export some functions from Item.js , specially redoItem, followRedone, findIndexCleanStart, splitItem. I tried importing them directly from src/internals but i realised I cant make it work since you have placed lots of instanceof Item checks on these functions. The item instances are different for a doc created from the.mjs file and providers and y-prosemirror depend on that mjs file as well, so creating Doc from 'internals.js' does not work. I have re-included the functions thatredoItem and followRedone depend on to fork out just the undomanager. And I dont want to fork yjs repo completely. So if you could export them, that would be great.
    Kevin Jahns
    @dmonad
    @wanuj Exporting them means that I'd need to keep compatibility in future releases - and I can't guarantee that. Maybe you can import yjs/src/index instead (use a patch override in your module bundler)?
    @philipaarseth That is correct.
    Nigel Gilbert
    @micrology

    if I specify an origin for a Y.doc.transact, e.g.

    const ydoc = new Y.Doc();
    const ymap = ydoc.getMap('mymap');
    ydoc.transact(() => {ymap.set('foo', 'bar')}, 'myOrigin')

    and, using a WebSocket provider, use ymap.observe(event) on another client, the value of event.transaction.origin is not the expected myOrigin, but WebsocketProvider {....}. How can I get the origin I provided to ydoc.transact to appear in the second client as the origin of the transaction?

    Joshua Fontany
    @joshuafontany
    The origin of the incoming transaction would the the WebSocket provider on that side of the connection.
    Blake Miner
    @compwiz737:matrix.org
    [m]
    Is it possible for a Y.js node to be more authoritative, perhaps like a central server in some regard? More specifically, if Node A wants to send updates to Node B for document D, can Node B tell Node A to undo some of his changes to document D? The use case is an authoritative node that works to perform data validation on the document. Other nodes might place more trust in an authoritative node for this purpose.
    Blake Miner
    @compwiz737:matrix.org
    [m]
    Blake Miner
    @compwiz737:matrix.org
    [m]
    Now that I think about this more, this appears to be a fundamental limitation right now. One-way sync, read-only sync... it feels like fine-grained permissions / authorization, as well.
    Martin Ellern Bilgrau
    @ellern
    I'm trying to set up a SignalR connector - I've found a Typescript version inside the Ycs repo - but can't figure out how to get it transpiled to JS so I can use it in my non-typescript webpack config. I have no experience with React, so I'm a bit lost here. Any advise?
    Kevin Jahns
    @dmonad

    Hi @micrology, if the update message from the first client is received by the second client, then the y-websocket provider will apply the message to the document. Hence, the origin is the provider. The transaction-origin concept only works locally. It is useful to determine where a change comes from so you can filter specific changes depending on where they come from (e.g. when implementing a 2-way binding).

    @compwiz737:matrix.org you could implement something like this using the y-websocket server and an undo-manager (track and revert the changes that you want to undo). The authorative y-websocket server could also just filter messages if a client has only read-only access to a document.

    @ellern you could look up how to install a typescript extension to webpack (maybe a babel plugin, but other people probably have better advice as I'm also not using webpack).

    Martin Ellern Bilgrau
    @ellern
    @dmonad yeah, I thought of that, but it might be easier just to get the ts transpiled with the correct settings and import it into my webpack build
    Nigel Gilbert
    @micrology
    Hi @dmonad Yes, I concluded that the origin is always the provider and cannot be reassigned. But I am still keen to label a transaction with the client that originated it. I note that the transaction object has a meta field, which is a map, but it doesn't seem to be possible for a client to set the map (am I right?). Can you think of any other way of labelling a transaction with the originating client, such that the originating client Id would be visible to peers that observe the transaction?
    wanuj
    @wanuj
    Has anyone achieved a proper way of doing history restore? Could be collection/project wise or just one document. Any insights would be helpful.
    Dan Steingart
    @dansteingart
    hi all: is there an example of how to use y on nodejs to broadcast to clients from the server
    I want to run a script on a server, and then have the output of that script display in a connect browser. TIA
    4 replies
    Kevin Jahns
    @dmonad

    Hi @dmonad Yes, I concluded that the origin is always the provider and cannot be reassigned. But I am still keen to label a transaction with the client that originated it. I note that the transaction object has a meta field, which is a map, but it doesn't seem to be possible for a client to set the map (am I right?). Can you think of any other way of labelling a transaction with the originating client, such that the originating client Id would be visible to peers that observe the transaction?

    That's not possible unformutately, as changes from multiple clients are often bundled. Then you could use something like the versioning approach that allows you to store which user created which content.

    2 replies
    Adrián Martínez Pérez
    @geralt1_gitlab
    Hi, I am using y-websocket to handle collaboration with yjs, and sometimes two different users are connected to two different rooms created with the same ID. Any idea what could happen here? Thanks.
    Kevin Jahns
    @dmonad
    @geralt1_gitlab You can open a ticket on discuss.yjs.dev
    1 reply
    Dan Steingart
    @dansteingart
    has anyone made an updated ace binding? thanks.
    Vinicius Zaramella
    @vzaramel
    Hi guys, Is there a way of get the initial update sync in chunks instead of a single update? Or split a update in smaller chunks?
    The reason I am asking is that I am implementing a persistence provider to work with Cloudflare Workers Durable Object, but their storage only accepts a max of 32Kb per value in the kv store.
    Kevin Jahns
    @dmonad
    @vzaramel No that's impossible unfortunately, you need to split messages yourself (by implementing your own protocol to chunk messages and merge them together at some point)
    Vitali Lovich
    @vlovich
    Hi. I'm trying to use y-websocket with Cloudflare Workers DO acting as the server. Normally I obtain a WebSocket in Workers by issuing a fetch with an upgrade. Is that something I can bridge into y-websocket or do I have to do everything custom? I'm assuming the latter - do I just build on top of y-protocols instead?
    Vitali Lovich
    @vlovich
    Oh I see @vzaramel might be doing something similar
    Kevin Jahns
    @dmonad
    @vlovich I would just build on y-protocols. But you can implement your own instead - it is not very complicated.
    @dansteingart Sorry for the late answer. To my knowledge, there is no Ace binding that works with the latest Yjs.
    atng
    @atng

    Hello everyone :)
    I've just started with yjs and have found it amazing! I'm particularly interested in the subdocuments feature, but i'm facing some issues with the example in the docs (https://docs.yjs.dev/api/subdocuments) - it doesn't seem to be working right.

    Here's what the docs say

    A new feature that was introduced in Yjs@13.4.0 is that all documents are given a GUID. The documents are identified with GUIDs and used as a room-name to sync documents. This allows you to duplicate data in the document structure.

    Here's some sample code:

    const rootDoc = new Y.Doc();const doc = new Y.Doc(); doc.getMap().set("data", "some initial data");
    rootDoc.getMap().set("file.txt", doc);
    const copy = new Y.Doc({ guid: doc.guid });
    rootDoc.getMap().set("copy.txt", copy);
    console.log(copy.getMap().get("data"));
    console.log(doc.getMap().get("data"));

    Here's the output:

    undefined
    some initial data

    Shouldn't the output be the same? Or did I miss something here? Any help is appreciated! Thank you.

    Kevin Jahns
    @dmonad
    @atng You probably didn't assign a provider. Yjs documents need providers to sync, otherwise they don't know about each other..
    atng
    @atng
    @kev Oh right! I've tried it with y-websocket - I'm assuming that we need to hookup the updates with a custom provider that updates all the subdocs with the same guid on update?
    atng
    @atng
    @dmonad ^ oops tagged the wrong person there. Thank you!