Skip to content

A specific version of ot-json0 is hardcoded as the basic type #284

Open
@houshuang

Description

@houshuang

There's currently a bunch of experiments going on around adding presence to ot-json0. One of the things I've come across is that ShareDB currently has a hard dependency on the ot-json0 NPM package, meaning that if we want to replace it with another implementation, we need to also fork the ShareDB package, which is unfortunate.

Here's the code that errors out:

      if (types.map[message.type] !== types.defaultType) {
        err = new ShareDBError(4020, 'Invalid default type');
        return this.emit('error', err);

(lib/client/connection.js:198)

We can either remove that (I did, and it worked), or instead of this line in lib/types.js:

exports.defaultType = require('ot-json0').type;

we might think about letting the user (optionally) supply a default type when configuring ShareDB?

Currently I've just been looking at replacing the base ot-json0 implementation with a type that is almost identical, just with added presence. However, I don't actually know enough about the requirements for a defaultType - does there have to be one? Does it just need to "exist" or to implement a certain interface (beyond the general OT interface)? Could I specify "ot-text" as a default type?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions