commit
7959bdf5ac
@ -3,7 +3,7 @@
|
||||
|
||||
[](https://travis-ci.org/y-js/yjs)
|
||||
|
||||
Yjs is a framework for optimistic concurrency control and automatic conflict resolution on arbitrary data types. The framework implements a new OT-like concurrency algorithm and provides similar functionality as [ShareJs] and [OpenCoweb]. Yjs was designed to handle concurrent actions on arbitrary complex data types like Text, Json, and XML. You can find some applications for this framework [here](http://y-js.org/examples/).
|
||||
Yjs is a framework for optimistic concurrency control and automatic conflict resolution on arbitrary data types. The framework implements a new OT-like concurrency algorithm and provides similar functionality as [ShareJs] and [OpenCoweb]. Yjs was designed to handle concurrent actions on arbitrary complex data types like Text, Json, and XML. You can find a tutorial and some applications for this framework on our [homepage](http://y-js.org/).
|
||||
|
||||
You can create your own shared data types easily. Therefore, you can take matters into your own hand by defining the meaning of the shared types and ensure that it is valid, while Yjs ensures data consistency (everyone will eventually end up with the same data).
|
||||
You can use existing types in your custom data type as well. Learn in [this wiki page](https://github.com/y-js/yjs/wiki/Custom-Types) how to craft your own custom data types. We already provide data types for
|
||||
@ -132,7 +132,7 @@ I created this framework during my bachelor thesis at the chair of computer scie
|
||||
## License
|
||||
Yjs is licensed under the [MIT License](./LICENSE.txt).
|
||||
|
||||
<kevin.jahns@rwth-aachen.de>
|
||||
<yjs@dbis.rwth-aachen.de>
|
||||
|
||||
[ShareJs]: https://github.com/share/ShareJS
|
||||
[OpenCoweb]: https://github.com/opencoweb/coweb
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"homepage": "https://github.com/DadaMonad/yjs",
|
||||
"authors": [
|
||||
"Kevin Jahns <kevin.jahns@rwth-aachen.de>"
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -38,10 +38,12 @@ module.exports = {
|
||||
this.connections = {};
|
||||
this.current_sync_target = null;
|
||||
this.sent_hb_to_all_users = false;
|
||||
this.is_initialized = true;
|
||||
return this.connections_listeners = [];
|
||||
return this.is_initialized = true;
|
||||
},
|
||||
onUserEvent: function(f) {
|
||||
if (this.connections_listeners == null) {
|
||||
this.connections_listeners = [];
|
||||
}
|
||||
return this.connections_listeners.push(f);
|
||||
},
|
||||
isRoleMaster: function() {
|
||||
@ -72,16 +74,18 @@ module.exports = {
|
||||
var f, i, len, ref, results;
|
||||
delete this.connections[user];
|
||||
this.findNewSyncTarget();
|
||||
ref = this.connections_listeners;
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
f = ref[i];
|
||||
results.push(f({
|
||||
action: "userLeft",
|
||||
user: user
|
||||
}));
|
||||
if (this.connections_listeners != null) {
|
||||
ref = this.connections_listeners;
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
f = ref[i];
|
||||
results.push(f({
|
||||
action: "userLeft",
|
||||
user: user
|
||||
}));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return results;
|
||||
},
|
||||
userJoined: function(user, role) {
|
||||
var base, f, i, len, ref, results;
|
||||
@ -99,17 +103,19 @@ module.exports = {
|
||||
this.performSyncWithMaster(user);
|
||||
}
|
||||
}
|
||||
ref = this.connections_listeners;
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
f = ref[i];
|
||||
results.push(f({
|
||||
action: "userJoined",
|
||||
user: user,
|
||||
role: role
|
||||
}));
|
||||
if (this.connections_listeners != null) {
|
||||
ref = this.connections_listeners;
|
||||
results = [];
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
f = ref[i];
|
||||
results.push(f({
|
||||
action: "userJoined",
|
||||
user: user,
|
||||
role: role
|
||||
}));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return results;
|
||||
},
|
||||
whenSynced: function(args) {
|
||||
if (args.constructore === Function) {
|
||||
|
@ -1,6 +1,4 @@
|
||||
var Y, bindToChildren;
|
||||
|
||||
Y = require('./y');
|
||||
var bindToChildren;
|
||||
|
||||
bindToChildren = function(that) {
|
||||
var attr, i, j, ref;
|
||||
@ -52,7 +50,7 @@ Polymer("y-object", {
|
||||
}
|
||||
},
|
||||
valChanged: function() {
|
||||
if ((this.val != null) && this.val.type === "Object") {
|
||||
if ((this.val != null) && this.val._name === "Object") {
|
||||
return bindToChildren(this);
|
||||
}
|
||||
},
|
||||
@ -68,11 +66,11 @@ Polymer("y-property", {
|
||||
ready: function() {
|
||||
if ((this.val != null) && (this.name != null)) {
|
||||
if (this.val.constructor === Object) {
|
||||
this.val = this.parentElement.val(this.name, this.val).val(this.name);
|
||||
this.val = this.parentElement.val(this.name, new Y.Object(this.val)).val(this.name);
|
||||
} else if (typeof this.val === "string") {
|
||||
this.parentElement.val(this.name, this.val);
|
||||
}
|
||||
if (this.val.type === "Object") {
|
||||
if (this.val._name === "Object") {
|
||||
return bindToChildren(this);
|
||||
}
|
||||
}
|
||||
@ -81,8 +79,8 @@ Polymer("y-property", {
|
||||
var ref;
|
||||
if ((this.val != null) && (this.name != null)) {
|
||||
if (this.val.constructor === Object) {
|
||||
return this.val = this.parentElement.val.val(this.name, this.val).val(this.name);
|
||||
} else if (this.val.type === "Object") {
|
||||
return this.val = this.parentElement.val.val(this.name, new Y.Object(this.val)).val(this.name);
|
||||
} else if (this.val._name === "Object") {
|
||||
return bindToChildren(this);
|
||||
} else if ((((ref = this.parentElement.val) != null ? ref.val : void 0) != null) && this.val !== this.parentElement.val.val(this.name)) {
|
||||
return this.parentElement.val.val(this.name, this.val);
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,15 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8 />
|
||||
<title>Y Example</title>
|
||||
<script src="../../../webcomponentsjs/webcomponents.min.js"></script>
|
||||
<link rel="import" href="../../../polymer/polymer.html">
|
||||
|
||||
<link rel="import" href="y-test.html">
|
||||
</head>
|
||||
<body>
|
||||
<y-test></y-test>
|
||||
<p> This example tests a few things like Late Join, the synchronization process while editing, and if the Connector and Yjs work together as Polymer elements. you can use this example as a starting point for your own Polymer project too. </p>
|
||||
</body>
|
||||
</html>
|
@ -1,55 +0,0 @@
|
||||
<link rel="import" href="../../build/browser/y-object.html">
|
||||
<link rel="import" href="../../../y-webrtc/build/browser/y-webrtc.html">
|
||||
<link rel="import" href="../../../paper-slider/paper-slider.html">
|
||||
|
||||
<polymer-element name="y-test" attributes="y connector stuff">
|
||||
<template>
|
||||
<h1 id="text" contentEditable> Check this out !</h1>
|
||||
<y-webrtc id="connector" connector={{connector}} room="testy-webrtc-polymer" debug="true"></y-webrtc>
|
||||
<y-object connector={{connector}} val={{y}}>
|
||||
<y-property name="slider" val={{slider}}>
|
||||
</y-property>
|
||||
<y-property name="stuff" val={{stuff}}>
|
||||
<y-property id="otherstuff" name="otherstuff" val={{otherstuff}}>
|
||||
</y-property>
|
||||
</y-property>
|
||||
</y-object>
|
||||
<y-object val={{otherstuff}}>
|
||||
<y-property name="nostuff" val={{nostuff}}>
|
||||
</y-property>
|
||||
</y-object>
|
||||
<paper-slider min="0" max="200" immediateValue={{slider}}></paper-slider>
|
||||
</template>
|
||||
<script>
|
||||
Polymer({
|
||||
ready: function(){
|
||||
window.y_stuff_property = this.$.otherstuff;
|
||||
this.y.val("slider",50)
|
||||
var that = this;
|
||||
this.connector.whenSynced(function(){
|
||||
if(that.y.val("text") == null){
|
||||
that.y.val("text","stuff","mutable");
|
||||
}
|
||||
that.y.val("text").bind(that.$.text,that.shadowRoot)
|
||||
})
|
||||
|
||||
// Everything is initialized. Lets test stuff!
|
||||
window.y_test = this;
|
||||
window.y_test.y.val("stuff",{otherstuff:{nostuff:"this is no stuff"}})
|
||||
setTimeout(function(){
|
||||
var res = y_test.y.val("stuff");
|
||||
if(!(y_test.nostuff === "this is no stuff")){
|
||||
console.log("Deep inherit doesn't work!")
|
||||
}
|
||||
window.y_stuff_property.val = {nostuff: "this is also no stuff"};
|
||||
setTimeout(function(){
|
||||
if(!(y_test.nostuff === "this is also no stuff")){
|
||||
console.log("Element val overwrite doesn't work")
|
||||
}
|
||||
console.log("Everything is fine :)");
|
||||
},500)
|
||||
},500);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</polymer-element>
|
@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8 />
|
||||
<title>Y Example</title>
|
||||
<script src="../../build/browser/y.js"></script>
|
||||
<script src="../../../y-webrtc/build/browser/y-webrtc.js"></script>
|
||||
<script src="./index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 contentEditable> yjs Tutorial</h1>
|
||||
<p> Collaborative Json editing with <a href="https://github.com/rwth-acis/yjs/">yjs</a>
|
||||
and WebRTC Connector. </p>
|
||||
|
||||
<textarea style="width:80%;" rows=40 id="textfield"></textarea>
|
||||
|
||||
<p> <a href="https://github.com/rwth-acis/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
@ -1,27 +0,0 @@
|
||||
|
||||
|
||||
connector = new Y.WebRTC("testy", {debug: true});
|
||||
|
||||
connector.debug = true
|
||||
|
||||
y = new Y(connector);
|
||||
|
||||
window.onload = function(){
|
||||
var textbox = document.getElementById("textfield");
|
||||
y.observe(function(events){
|
||||
for(var i=0; i<events.length; i++){
|
||||
var event = events[i];
|
||||
if(event.name === "textfield" && event.type !== "delete"){
|
||||
y.val("textfield").bind(textbox);
|
||||
y.val("headline").bind(document.querySelector("h1"))
|
||||
}
|
||||
}
|
||||
});
|
||||
connector.whenSynced(function(){
|
||||
if(y.val("textfield") == null){
|
||||
y.val("headline","headline", "mutable");
|
||||
y.val("textfield","stuff", "mutable")
|
||||
}
|
||||
})
|
||||
|
||||
};
|
@ -1,3 +1,5 @@
|
||||
<script src="../../build/browser/y.js"></script>
|
||||
<script src="../../../y-text/build/browser/y-text.js"></script>
|
||||
<link rel="import" href="../../build/browser/y-object.html">
|
||||
<link rel="import" href="../../../y-xmpp/build/browser/y-xmpp.html">
|
||||
<link rel="import" href="../../../paper-slider/paper-slider.html">
|
||||
@ -28,7 +30,7 @@
|
||||
var that = this;
|
||||
this.connector.whenSynced(function(){
|
||||
if(that.y.val("text") == null){
|
||||
that.y.val("text","stuff","mutable");
|
||||
that.y.val("text",new Y.Text("stuff"));
|
||||
}
|
||||
that.y.val("text").bind(that.$.text,that.shadowRoot)
|
||||
})
|
||||
@ -52,4 +54,4 @@
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</polymer-element>
|
||||
</polymer-element>
|
||||
|
@ -4,6 +4,7 @@
|
||||
<meta charset=utf-8 />
|
||||
<title>Y Example</title>
|
||||
<script src="../../build/browser/y.js"></script>
|
||||
<script src="../../../y-text/build/browser/y-text.js"></script>
|
||||
<script src="../../../y-xmpp/y-xmpp.js"></script>
|
||||
<script src="./index.js"></script>
|
||||
</head>
|
||||
@ -14,7 +15,7 @@ and XMPP Connector. </p>
|
||||
|
||||
<textarea style="width:80%;" rows=40 id="textfield"></textarea>
|
||||
|
||||
<p> <a href="https://github.com/rwth-acis/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types.
|
||||
<p> <a href="https://github.com/y-js/yjs/">yjs</a> is a Framework for Real-Time collaboration on arbitrary data types.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -18,9 +18,9 @@ window.onload = function(){
|
||||
});
|
||||
connector.whenSynced(function(){
|
||||
if(y.val("textfield") == null){
|
||||
y.val("headline","headline", "mutable");
|
||||
y.val("textfield","stuff", "mutable")
|
||||
y.val("headline", new Y.Text("headline"));
|
||||
y.val("textfield",new Y.Text("stuff"))
|
||||
}
|
||||
})
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -70,11 +70,12 @@ module.exports =
|
||||
userLeft: (user)->
|
||||
delete @connections[user]
|
||||
@findNewSyncTarget()
|
||||
for f in @connections_listeners
|
||||
f {
|
||||
action: "userLeft"
|
||||
user: user
|
||||
}
|
||||
if @connections_listeners?
|
||||
for f in @connections_listeners
|
||||
f {
|
||||
action: "userLeft"
|
||||
user: user
|
||||
}
|
||||
|
||||
|
||||
userJoined: (user, role)->
|
||||
@ -91,12 +92,13 @@ module.exports =
|
||||
# TODO: What if there are two masters? Prevent sending everything two times!
|
||||
@performSyncWithMaster user
|
||||
|
||||
for f in @connections_listeners
|
||||
f {
|
||||
action: "userJoined"
|
||||
user: user
|
||||
role: role
|
||||
}
|
||||
if @connections_listeners?
|
||||
for f in @connections_listeners
|
||||
f {
|
||||
action: "userJoined"
|
||||
user: user
|
||||
role: role
|
||||
}
|
||||
|
||||
#
|
||||
# Execute a function _when_ we are connected. If not connected, wait until connected.
|
||||
|
@ -38,7 +38,7 @@ class YObject
|
||||
# @overload val(name)
|
||||
# Get value of a property.
|
||||
# @param {String} name Name of the object property.
|
||||
# @return [Object Type||String|Object] Depending on the value of the property. If mutable it will return a Operation-type object, if immutable it will return String/Object.
|
||||
# @return [*] Depends on the value of the property.
|
||||
#
|
||||
# @overload val(name, content)
|
||||
# Set a new property.
|
||||
@ -72,11 +72,3 @@ if window?
|
||||
|
||||
if module?
|
||||
module.exports = YObject
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
|
||||
Y = require './y'
|
||||
|
||||
bindToChildren = (that)->
|
||||
for i in [0...that.children.length]
|
||||
attr = that.children.item(i)
|
||||
@ -25,7 +23,7 @@ Polymer "y-object",
|
||||
bindToChildren @
|
||||
|
||||
valChanged: ()->
|
||||
if @val? and @val.type is "Object"
|
||||
if @val? and @val._name is "Object"
|
||||
bindToChildren @
|
||||
|
||||
connectorChanged: ()->
|
||||
@ -37,23 +35,21 @@ Polymer "y-property",
|
||||
ready: ()->
|
||||
if @val? and @name?
|
||||
if @val.constructor is Object
|
||||
@val = @parentElement.val(@name,@val).val(@name)
|
||||
# TODO: please use instanceof instead of .type,
|
||||
@val = @parentElement.val(@name,new Y.Object(@val)).val(@name)
|
||||
# TODO: please use instanceof instead of ._name,
|
||||
# since it is more safe (consider someone putting a custom Object type here)
|
||||
else if typeof @val is "string"
|
||||
@parentElement.val(@name,@val)
|
||||
if @val.type is "Object"
|
||||
if @val._name is "Object"
|
||||
bindToChildren @
|
||||
|
||||
valChanged: ()->
|
||||
if @val? and @name?
|
||||
if @val.constructor is Object
|
||||
@val = @parentElement.val.val(@name,@val).val(@name)
|
||||
# TODO: please use instanceof instead of .type,
|
||||
@val = @parentElement.val.val(@name, new Y.Object(@val)).val(@name)
|
||||
# TODO: please use instanceof instead of ._name,
|
||||
# since it is more safe (consider someone putting a custom Object type here)
|
||||
else if @val.type is "Object"
|
||||
else if @val._name is "Object"
|
||||
bindToChildren @
|
||||
else if @parentElement.val?.val? and @val isnt @parentElement.val.val(@name)
|
||||
@parentElement.val.val @name, @val
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yjs",
|
||||
"version": "0.4.1",
|
||||
"version": "0.5.0",
|
||||
"description": "A Framework that enables Real-Time Collaboration on arbitrary data structures.",
|
||||
"main": "./build/node/y.js",
|
||||
"scripts": {
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user