resoved issue #7, empty value when addProperty fires on late join
This commit is contained in:
parent
93a04c8e23
commit
12e8768c31
@ -1 +1 @@
|
||||
!function n(t,e,r){function o(u,s){if(!e[u]){if(!t[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var a=e[u]={exports:{}};t[u][0].call(a.exports,function(n){var e=t[u][1][n];return o(e?e:n)},a,a.exports,n,t,e,r)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(n,t){var e;e=function(){var n,t,e;return e=null,2===arguments.length?(e=new Peer(arguments[0]),t=arguments[1]):(e=new Peer(arguments[0],arguments[1]),t=arguments[2]),n=function(){function n(n,t,r,o){var i;this.engine=n,this.HB=t,this.execution_listener=r,this.yatta=o,this.peer=e,this.connections={},this.peer.on("connection",function(n){return function(t){return n.addConnection(t)}}(this)),i=function(n){return function(t){var e,r,o,i;if(t.creator===n.HB.getUserId()&&"string"!=typeof t.uid.op_number&&t.uid.sync){o=n.connections,i=[];for(r in o)e=o[r],i.push(e.send({op:t}));return i}}}(this),this.execution_listener.push(i)}return n.prototype.connectToPeer=function(n){return null==this.connections[n]&&n!==this.yatta.getUserId()?this.addConnection(e.connect(n)):void 0},n.prototype.getAllConnectionIds=function(){var n,t;t=[];for(n in this.connections)t.push(n);return t},n.prototype.addConnection=function(n){var t,e,r;return this.connections[n.peer]=n,e=!1,t=!1,n.on("data",function(r){return function(o){var i,u,s,c,a;if("empty_message"===o);else{if(null!=o.HB)return e=!0,r.engine.applyOpsCheckDouble(o.HB,o.state_vector),n.send({conns:r.getAllConnectionIds()});if(null!=o.op)return r.engine.applyOp(o.op);if(null!=o.conns){for(c=o.conns,a=[],u=0,s=c.length;s>u;u++)i=c[u],a.push(r.connectToPeer(i));return a}if(null==o.state_vector)throw new Error("Can't parse this operation");if(!t)return n.send({HB:r.yatta.getHistoryBuffer()._encode(o.state_vector),state_vector:r.yatta.HB.getOperationCounter()}),t=!0}}}(this)),r=function(t){return function(){return n.send({state_vector:t.HB.getOperationCounter()}),e?void 0:setTimeout(r,100)}}(this),r()},n}(),e.on("open",function(e){return t(n,e)})},t.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=e)},{}]},{},[1]);
|
||||
!function n(e,t,r){function o(u,s){if(!t[u]){if(!e[u]){var c="function"==typeof require&&require;if(!s&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var f=t[u]={exports:{}};e[u][0].call(f.exports,function(n){var t=e[u][1][n];return o(t?t:n)},f,f.exports,n,e,t,r)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(n,e){var t;t=function(){var n,e,t;return t=null,2===arguments.length?(t=new Peer(arguments[0]),e=arguments[1]):(t=new Peer(arguments[0],arguments[1]),e=arguments[2]),n=function(){function n(n,e,r,o){var i;this.engine=n,this.HB=e,this.execution_listener=r,this.yatta=o,this.peer=t,this.connections={},this.peer.on("connection",function(n){return function(e){return n.addConnection(e)}}(this)),i=function(n){return function(e){var t,r,o,i;if(e.uid.creator===n.HB.getUserId()&&"string"!=typeof e.uid.op_number){o=n.connections,i=[];for(r in o)t=o[r],i.push(t.send({op:e}));return i}}}(this),this.execution_listener.push(i)}return n.prototype.connectToPeer=function(n){return null==this.connections[n]&&n!==this.yatta.getUserId()?this.addConnection(t.connect(n)):void 0},n.prototype.getAllConnectionIds=function(){var n,e;e=[];for(n in this.connections)e.push(n);return e},n.prototype.addConnection=function(n){var e,t,r;return this.connections[n.peer]=n,t=!1,e=!1,n.on("data",function(r){return function(o){var i,u,s,c,f;if("empty_message"===o);else{if(null!=o.HB)return t=!0,r.engine.applyOpsCheckDouble(o.HB),n.send({conns:r.getAllConnectionIds()});if(null!=o.op)return r.engine.applyOp(o.op);if(null!=o.conns){for(c=o.conns,f=[],u=0,s=c.length;s>u;u++)i=c[u],f.push(r.connectToPeer(i));return f}if(null==o.state_vector)throw new Error("Can't parse this operation");if(!e)return n.send({HB:r.yatta.getHistoryBuffer()._encode(o.state_vector)}),e=!0}}}(this)),r=function(e){return function(){return n.send({state_vector:e.HB.getOperationCounter()}),t?void 0:setTimeout(r,100)}}(this),r()},n}(),t.on("open",function(t){return e(n,t)})},e.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=t)},{}]},{},[1]);
|
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -258,7 +258,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -302,7 +302,7 @@ data from the received intent.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -335,7 +335,7 @@ JsonFramework was initialized (Depending on the HistoryBuffer implementation).</
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -466,7 +466,7 @@ if (x.type === "JsonType") {
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -139,7 +139,7 @@ console.log(w.newProperty == "Awesome") # true!</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -222,7 +222,7 @@ on how to do that with urls.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -356,7 +356,7 @@ JsonFramework was initialized (Depending on the HistoryBuffer implementation).</
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -415,7 +415,7 @@ yatta.bind(textbox);</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -38,7 +38,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -70,7 +70,7 @@ But I would become really motivated if you gave me some feedback :) (<a href="ht
|
||||
<ul>
|
||||
<li>XML support</li>
|
||||
</ul>
|
||||
<h2 id="support">Support</h2><p>Please report any issues to the <a href="https://github.com/DadaMonad/Yatta/issues">Github issue page</a>!</p><h2 id="license">License</h2><p>Yatta! is licensed under the <a href="./LICENSE.txt">MIT License</a>.</p><a href="mailto:kevin.jahns@rwth-aachen.de">kevin.jahns@rwth-aachen.de</a>
|
||||
<h2 id="support">Support</h2><p>Please report any issues to the <a href="https://github.com/DadaMonad/Yatta/issues">Github issue page</a>!</p><h2 id="license">License</h2><p>Yatta! is licensed under the <a href="./LICENSE.txt">MIT License</a>.</p><a href="mailto:kevin.jahns@rwth-aachen.de">kevin.jahns@rwth-aachen.de</a>
|
||||
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ But I would become really motivated if you gave me some feedback :) (<a href="ht
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -100,7 +100,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -158,7 +158,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -48,7 +48,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -60,7 +60,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -60,7 +60,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -48,7 +48,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -37,7 +37,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id='footer'>
|
||||
September 26, 14 10:55:56 by
|
||||
September 26, 14 11:52:44 by
|
||||
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
||||
Codo
|
||||
</a>
|
||||
|
@ -40,6 +40,25 @@ Y.createPeerJsConnector("unique_id", {key: 'h7nlefbgavh1tt9'}, function(Connecto
|
||||
it will be instantly shared with all the other collaborators.
|
||||
*/
|
||||
yatta = new Y.JsonFramework(user_id, Connector);
|
||||
yatta.val('w','w');
|
||||
console.log(yatta.getUserId());
|
||||
|
||||
function show(o){
|
||||
if (o.type === "JsonType"){
|
||||
return JSON.stringify(o.toJson());
|
||||
} else if (o.type === "WordType") {
|
||||
return o.val();
|
||||
} else if (o.constructor === {}.constructor) { // It's an Object
|
||||
return JSON.stringify(o);
|
||||
} else { // It's a primitive data type (E.g. string, int)
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
function addProperty(event_name, property_name, op){
|
||||
// op is the operation that changed the objects value. In addProperty it is most likely to be a 'Replaceable' (see doc).
|
||||
console.log("Property '" + property_name + "' was created by '"+op.creator+"'!");
|
||||
console.log("Value: " + show(this.val(property_name))); // 'this' is the object on which the property was created.
|
||||
};
|
||||
yatta.on('addProperty', addProperty);
|
||||
|
||||
});
|
||||
|
@ -16,7 +16,7 @@ run = require 'gulp-run'
|
||||
ljs = require 'gulp-ljs'
|
||||
|
||||
|
||||
gulp.task 'default', ['build', 'test', 'literate', 'lib', 'codo']
|
||||
gulp.task 'default', ['lint', 'browser', 'test', 'literate', 'lib', 'codo']
|
||||
gulp.task 'build', ['lint', 'browser']
|
||||
|
||||
files =
|
||||
@ -104,7 +104,7 @@ gulp.task 'upload', [], ()->
|
||||
run('scp -r ./build ./examples jahns@manet.informatik.rwth-aachen.de:/home/jahns/public_html/collaborative_preview/').exec()
|
||||
|
||||
gulp.task 'codo', [], ()->
|
||||
command = 'codo -o "./doc" --name "Yatta!" --readme "README.md" --undocumented false --private true --title "Yatta! API" ./lib - LICENSE.txt ./extras/*'
|
||||
command = 'codo -o "./doc" --name "Yatta!" --readme "README.md" --undocumented false --private true --title "Yatta! API" ./lib - LICENSE.txt '
|
||||
run(command).exec()
|
||||
|
||||
gulp.task 'clean', ->
|
||||
|
@ -321,8 +321,8 @@ module.exports = (HB)->
|
||||
#
|
||||
# @private
|
||||
# Include this operation in the associative lists.
|
||||
#
|
||||
execute: ()->
|
||||
# @param fire_event {boolean} Whether to fire the insert-event.
|
||||
execute: (fire_event = true)->
|
||||
if not @validateSavedOperations()
|
||||
return false
|
||||
else
|
||||
@ -374,7 +374,7 @@ module.exports = (HB)->
|
||||
@next_cl.prev_cl = @
|
||||
|
||||
parent = @prev_cl?.getParent()
|
||||
if parent?
|
||||
if parent? and fire_event
|
||||
@setParent parent
|
||||
@parent.callEvent "insert", @
|
||||
super # notify the execution_listeners
|
||||
|
@ -257,8 +257,7 @@ module.exports = (HB)->
|
||||
repl_manager.parent.callEvent 'change', property_name, op
|
||||
# Call this, when the first element is inserted. Then delete the listener.
|
||||
addPropertyListener = (event, op)->
|
||||
if op.next_cl instanceof types.Delimiter and op.prev_cl instanceof types.Delimiter
|
||||
repl_manager.parent.callEvent 'addProperty', property_name, op
|
||||
repl_manager.parent.callEvent 'addProperty', property_name, op
|
||||
repl_manager.deleteListener 'addProperty', addPropertyListener
|
||||
@on 'insert', addPropertyListener
|
||||
super parent
|
||||
@ -356,7 +355,10 @@ module.exports = (HB)->
|
||||
return false
|
||||
else
|
||||
@content?.setReplaceManager?(@parent)
|
||||
ins_result = super()
|
||||
# only fire 'insert-event' (which will result in addProperty and change events),
|
||||
# when content is added. In case of Json, empty content means that this is not the last update,
|
||||
# since content is deleted when 'applyDelete' was exectuted.
|
||||
ins_result = super(@content?) # @content? whether to fire or not
|
||||
if ins_result
|
||||
if @next_cl.type is "Delimiter" and @prev_cl.type isnt "Delimiter"
|
||||
@prev_cl.applyDelete()
|
||||
|
@ -54,6 +54,7 @@
|
||||
"gulp-uglify": "^0.3.1",
|
||||
"mocha": "^1.21.4",
|
||||
"sinon": "^1.10.2",
|
||||
"sinon-chai": "^2.5.0"
|
||||
"sinon-chai": "^2.5.0",
|
||||
"codo": "^2.0.9"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user