gritzko/swarm

Text type status and improvements

Closed this issue · 6 comments

I noticed the Text type is missing from both Html5Client.js and NodeServer.js. Is there a particular reason for that or would you accept a pull request with that change?

Without a require for Text in NodeServer, in my environment (ES6+Babel+Webpack) the server-side code does not add the Text type to Syncable properly:

In server.js:

var Swarm = require('swarm')
Swarm.Text = require('swarm/lib/Text')
console.log('types are now:')
console.dir(_.keys(Swarm.Syncable.types))
// types are now:
// [ 'Syncable', 'Model', 'Set', 'Vector', 'Host' ]

and then later when receiving Text from a client:

error processing message [Error: type unknown: /Text#note] Error: type unknown: /Text#note

However, for some reason, this does work:

var Swarm = require('swarm/lib/NodeServer')
Swarm.Text = require('swarm/lib/Text')
console.log('types are now:')
console.dir(_.keys(Swarm.Syncable.types))
// types are now:
// [ 'Syncable', 'Model', 'Set', 'Vector', 'Host', 'Text' ]

The swarm package.json specifies lib/NodeServer.js as "main", so as I understand the code above should be equivalent. It might have something to do with my use of ES6 and Webpack.

That is because it is crap.
Text.js as it is is a demo only thing.
I have a decent implementation, but it will take time to release that one. Hopefully, with 0.4.
By the way, what is your use case?

By the way, what is your use case?

@gritzko I am building a prototype of a collaborative rich text editor, and I liked the relative simplicity of your CRDT-based causal trees approach in comparison to OT. I noted that Swarm included Text.js and was attempting to learn from it. I'm curious, in what ways do you consider the current Text.js to be crap?

@rocketraman It uses uncompressed base64 id strings, so it has x100 overhead compared to plain text. A "normal" value is below x10, x3 is really good. See IdArray.
It has no decent API, events are cryptic and so on.
It is just a minimal CT implementation, it was not intended to be practical.

@gritzko Ok given I'm creating a prototype I'm not super-concerned about the overhead. However, I'd love to see the better implementation you have. Does that implementation support rich text also? Are you open to helping us with a good rich text implementation, either as part of swarm open source or on a consulting basis? We'd probably be willing to contribute any source created as part of a consulting project back to Swarm.

You can always contact me privately at victor.grishchenko@gmail.com

I know this issue is closed, but I'd love some recommendations about how to use plain text. Is Text.js in better shape on the 0.4 branch? (I'm also getting the type unknown: /Text#note error).

FWIW I'm trying to integrate Swarm with CodeMirror.