Issue #4: Improved sync process. Only unsynced operations are sent now
This commit is contained in:
parent
ad5898a77a
commit
77739deda3
File diff suppressed because one or more lines are too long
1
build/browser/Connectors/IwcConnector.min.js
vendored
1
build/browser/Connectors/IwcConnector.min.js
vendored
@ -1 +0,0 @@
|
||||
!function t(n,e,r){function i(o,a){if(!e[o]){if(!n[o]){var s="function"==typeof require&&require;if(!a&&s)return s(o,!0);if(u)return u(o,!0);throw new Error("Cannot find module '"+o+"'")}var c=e[o]={exports:{}};n[o][0].call(c.exports,function(t){var e=n[o][1][t];return i(e?e:t)},c,c.exports,t,n,e,r)}return e[o].exports}for(var u="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(t,n){var e;e=function(t,n){var e,r,i,u,o,a;return a=null,null!=n&&(a=n.iwcHandler),u={},r=new DUIClient,r.connect(function(t){var n;return null!=(n=u[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),r.initOK(),o=null,e=function(){function t(t,n,e,i){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=i,this.duiClient=r,this.iwcHandler=u,l=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(e){var r;return n=e.extras.HB,r=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[r]=!0}}(this),u.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=o&&this.engine.applyOpsCheckDouble(o),c=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.setIwcHandler=function(t){return a=t},t}(),i=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(i,5e3)},n.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=e)},{}]},{},[1]);
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
!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 e.send("hey"),n.addConnection(e)}}(this)),i=function(n){return function(e){return n.send(e)}}(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;return this.connections[n.peer]=n,n.on("data",function(n){return function(e){var t,r,o,i,u;if("hey"===e)return console.log("Yatta: Connection received with init message (debug)");if(null!=e.HB)return n.engine.applyOpsCheckDouble(e.HB);if(null!=e.op)return n.engine.applyOp(e.op);if(null!=e.conns){for(i=e.conns,u=[],r=0,o=i.length;o>r;r++)t=i[r],u.push(n.connectToPeer(t));return u}throw new Error("Can't parse this operation")}}(this)),e=function(e){return function(){return n.send({HB:e.yatta.getHistoryBuffer()._encode()}),n.send({conns:e.getAllConnectionIds()})}}(this),setTimeout(e,1e3)},n.prototype.send=function(n){var e,t,r,o;if(n.uid.creator===this.HB.getUserId()&&"string"!=typeof n.uid.op_number){r=this.connections,o=[];for(t in r)e=r[t],o.push(e.send({op:n}));return o}},n.prototype.receive=function(n){return n.uid.creator!==this.HB.getUserId()?this.engine.applyOp(n):void 0},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
1
build/browser/Engine.min.js
vendored
1
build/browser/Engine.min.js
vendored
@ -1 +0,0 @@
|
||||
!function r(e,t,o){function p(s,i){if(!t[s]){if(!e[s]){var u="function"==typeof require&&require;if(!i&&u)return u(s,!0);if(n)return n(s,!0);throw new Error("Cannot find module '"+s+"'")}var h=t[s]={exports:{}};e[s][0].call(h.exports,function(r){var t=e[s][1][r];return p(t?t:r)},h,h.exports,r,e,t,o)}return t[s].exports}for(var n="function"==typeof require&&require,s=0;s<o.length;s++)p(o[s]);return p}({1:[function(r,e){var t;t=function(){function r(r,e){this.HB=r,this.parser=e,this.unprocessed_ops=[]}return r.prototype.parseOperation=function(r){var e;if(e=this.parser[r.type],null!=e)return e(r);throw new Error("You forgot to specify a parser for type "+r.type+". The message is "+JSON.stringify(r)+".")},r.prototype.applyOpsBundle=function(r){var e,t,o,p,n,s,i,u;for(t=[],o=0,s=r.length;s>o;o++)e=r[o],t.push(this.parseOperation(e));for(p=0,i=t.length;i>p;p++)e=t[p],this.HB.addOperation(e);for(n=0,u=t.length;u>n;n++)e=t[n],e.execute()||this.unprocessed_ops.push(e);return this.tryUnprocessed()},r.prototype.applyOpsCheckDouble=function(r){var e,t,o,p;for(p=[],t=0,o=r.length;o>t;t++)e=r[t],p.push(null==this.HB.getOperation(e.uid)?this.applyOp(e):void 0);return p},r.prototype.applyOps=function(r){var e,t,o,p;for(p=[],t=0,o=r.length;o>t;t++)e=r[t],p.push(this.applyOp(e));return p},r.prototype.applyOp=function(r){var e;return e=this.parseOperation(r),this.HB.addToCounter(e),e.execute()?this.HB.addOperation(e):this.unprocessed_ops.push(e),this.tryUnprocessed()},r.prototype.tryUnprocessed=function(){var r,e,t,o,p,n,s;for(s=[];;){for(r=this.unprocessed_ops.length,t=[],n=this.unprocessed_ops,o=0,p=n.length;p>o;o++)e=n[o],e.execute()?this.HB.addOperation(e):t.push(e);if(this.unprocessed_ops=t,this.unprocessed_ops.length===r)break;s.push(void 0)}return s},r}(),e.exports=t},{}]},{},[1]);
|
File diff suppressed because one or more lines are too long
1
build/browser/Frameworks/JsonYatta.min.js
vendored
1
build/browser/Frameworks/JsonYatta.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
build/browser/Frameworks/TextYatta.min.js
vendored
1
build/browser/Frameworks/TextYatta.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
build/browser/HistoryBuffer.min.js
vendored
1
build/browser/HistoryBuffer.min.js
vendored
@ -1 +0,0 @@
|
||||
!function r(e,t,n){function o(u,f){if(!t[u]){if(!e[u]){var p="function"==typeof require&&require;if(!f&&p)return p(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=t[u]={exports:{}};e[u][0].call(c.exports,function(r){var t=e[u][1][r];return o(t?t:r)},c,c.exports,r,e,t,n)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(r,e){var t;t=function(){function r(r){this.user_id=r,this.operation_counter={},this.buffer={},this.change_listeners=[]}return r.prototype.getUserId=function(){return this.user_id},r.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},r.prototype.getOperationCounter=function(){var r,e,t,n;e={},n=this.operation_counter;for(t in n)r=n[t],e[t]=r;return e},r.prototype._encode=function(r){var e,t,n,o,i,u,f,p,c,a;null==r&&(r={}),e=[],p=function(e,t){if(null==e||null==t)throw new Error("dah!");return null==r[e]||r[e]<=t},a=this.buffer;for(f in a){c=a[f];for(i in c)if(t=c[i],!isNaN(parseInt(i))&&p(f,i)){if(n=t._encode(),null!=t.next_cl){for(o=t.next_cl;null!=o.next_cl&&p(o.creator,o.op_number);)o=o.next_cl;n.next=o.getUid()}else if(null!=t.prev_cl){for(u=t.prev_cl;null!=u.prev_cl&&p(o.creator,o.op_number);)u=u.prev_cl;n.prev=u.getUid()}e.push(n)}}return e},r.prototype.getNextOperationIdentifier=function(r){var e;return null==r&&(r=this.user_id),null==this.operation_counter[r]&&(this.operation_counter[r]=0),e={creator:r,op_number:this.operation_counter[r]},this.operation_counter[r]++,e},r.prototype.getOperation=function(r){var e;if(r instanceof Object)return null!=(e=this.buffer[r.creator])?e[r.op_number]:void 0;if(null!=r)throw new Error("This type of uid is not defined!")},r.prototype.addOperation=function(r){if(null==this.buffer[r.creator]&&(this.buffer[r.creator]={}),null!=this.buffer[r.creator][r.op_number])throw new Error("You must not overwrite operations!");return this.buffer[r.creator][r.op_number]=r,r},r.prototype.addToCounter=function(r){return null==this.operation_counter[r.creator]&&(this.operation_counter[r.creator]=0),"number"==typeof r.op_number&&r.creator!==this.getUserId()?this.operation_counter[r.creator]++:void 0},r}(),e.exports=t},{}]},{},[1]);
|
142
build/browser/IwcConnector.js
Normal file
142
build/browser/IwcConnector.js
Normal file
File diff suppressed because one or more lines are too long
1
build/browser/IwcConnector.min.js
vendored
Normal file
1
build/browser/IwcConnector.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function t(n,e,r){function i(u,a){if(!e[u]){if(!n[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(o)return o(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=e[u]={exports:{}};n[u][0].call(c.exports,function(t){var e=n[u][1][t];return i(e?e:t)},c,c.exports,t,n,e,r)}return e[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)i(r[u]);return i}({1:[function(t,n){var e;e=function(t,n){var e,r,i,o,u,a;return a=null,null!=n&&(a=n.iwcHandler),o={},r=new DUIClient,r.connect(function(t){var n;return null!=(n=o[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),r.initOK(),u=null,e=function(){function t(t,n,e,i){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=i,this.duiClient=r,this.iwcHandler=o,l=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(e){var r;return n=e.extras.HB,r=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[r]=!0}}(this),o.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",this.HB.getOperationCounter()),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=u&&this.engine.applyOpsCheckDouble(u),c=function(t){return function(n){var e,r;return r=n.extras,console.log(r),e={HB:t.yatta.getHistoryBuffer()._encode(r),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",e)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.setIwcHandler=function(t){return a=t},t}(),i=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(i,5e3)},n.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=e)},{}]},{},[1]);
|
1571
build/browser/JsonYatta.js
Normal file
1571
build/browser/JsonYatta.js
Normal file
File diff suppressed because one or more lines are too long
1
build/browser/JsonYatta.min.js
vendored
Normal file
1
build/browser/JsonYatta.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
142
build/browser/PeerJsConnector.js
Normal file
142
build/browser/PeerJsConnector.js
Normal file
File diff suppressed because one or more lines are too long
1
build/browser/PeerJsConnector.min.js
vendored
Normal file
1
build/browser/PeerJsConnector.min.js
vendored
Normal file
@ -0,0 +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){return n.send(e)}}(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))()},n.prototype.send=function(n){var e,t,r,o;if(n.uid.creator===this.HB.getUserId()&&"string"!=typeof n.uid.op_number){r=this.connections,o=[];for(t in r)e=r[t],o.push(e.send({op:n}));return o}},n.prototype.receive=function(n){return n.uid.creator!==this.HB.getUserId()?this.engine.applyOp(n):void 0},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]);
|
1385
build/browser/TextYatta.js
Normal file
1385
build/browser/TextYatta.js
Normal file
File diff suppressed because one or more lines are too long
1
build/browser/TextYatta.min.js
vendored
Normal file
1
build/browser/TextYatta.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
build/browser/Types/BasicTypes.min.js
vendored
1
build/browser/Types/BasicTypes.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
build/browser/Types/JsonTypes.min.js
vendored
1
build/browser/Types/JsonTypes.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
build/browser/Types/StructuredTypes.min.js
vendored
1
build/browser/Types/StructuredTypes.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
build/browser/Types/TextTypes.min.js
vendored
1
build/browser/Types/TextTypes.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +0,0 @@
|
||||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
|
||||
|
||||
|
||||
},{}]},{},[1])
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL2Rtb25hZC9Ecm9wYm94L1lhdHRhIS9ub2RlX21vZHVsZXMvZ3VscC1icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvaG9tZS9kbW9uYWQvRHJvcGJveC9ZYXR0YSEvbGliL1R5cGVzL1htbFR5cGVzLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQ0FBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiKGZ1bmN0aW9uIGUodCxuLHIpe2Z1bmN0aW9uIHMobyx1KXtpZighbltvXSl7aWYoIXRbb10pe3ZhciBhPXR5cGVvZiByZXF1aXJlPT1cImZ1bmN0aW9uXCImJnJlcXVpcmU7aWYoIXUmJmEpcmV0dXJuIGEobywhMCk7aWYoaSlyZXR1cm4gaShvLCEwKTt0aHJvdyBuZXcgRXJyb3IoXCJDYW5ub3QgZmluZCBtb2R1bGUgJ1wiK28rXCInXCIpfXZhciBmPW5bb109e2V4cG9ydHM6e319O3Rbb11bMF0uY2FsbChmLmV4cG9ydHMsZnVuY3Rpb24oZSl7dmFyIG49dFtvXVsxXVtlXTtyZXR1cm4gcyhuP246ZSl9LGYsZi5leHBvcnRzLGUsdCxuLHIpfXJldHVybiBuW29dLmV4cG9ydHN9dmFyIGk9dHlwZW9mIHJlcXVpcmU9PVwiZnVuY3Rpb25cIiYmcmVxdWlyZTtmb3IodmFyIG89MDtvPHIubGVuZ3RoO28rKylzKHJbb10pO3JldHVybiBzfSkiLCJcblxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZGF0YTphcHBsaWNhdGlvbi9qc29uO2Jhc2U2NCxleUoyWlhKemFXOXVJam96TENKbWFXeGxJam9pTDJodmJXVXZaRzF2Ym1Ga0wwUnliM0JpYjNndldXRjBkR0VoTDJ4cFlpOVVlWEJsY3k5WWJXeFVlWEJsY3k1amIyWm1aV1VpTENKemIzVnlZMlZTYjI5MElqb2lJaXdpYzI5MWNtTmxjeUk2V3lJdmFHOXRaUzlrYlc5dVlXUXZSSEp2Y0dKdmVDOVpZWFIwWVNFdmJHbGlMMVI1Y0dWekwxaHRiRlI1Y0dWekxtTnZabVpsWlNKZExDSnVZVzFsY3lJNlcxMHNJbTFoY0hCcGJtZHpJam9pUVVFd1pFY2lMQ0p6YjNWeVkyVnpRMjl1ZEdWdWRDSTZXeUlpWFgwPSJdfQ==
|
1
build/browser/Types/XmlTypes.min.js
vendored
1
build/browser/Types/XmlTypes.min.js
vendored
@ -1 +0,0 @@
|
||||
!function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);throw new Error("Cannot find module '"+i+"'")}var a=n[i]={exports:{}};e[i][0].call(a.exports,function(r){var n=e[i][1][r];return o(n?n:r)},a,a.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(){},{}]},{},[1]);
|
File diff suppressed because one or more lines are too long
4
build/browser/index.min.js
vendored
4
build/browser/index.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
(function(){var t;t=function(t,n){var e,i,r,u,o,a;return a=null,null!=n&&(a=n.iwcHandler),u={},i=new DUIClient,i.connect(function(t){var n;return null!=(n=u[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),i.initOK(),o=null,e=function(){function t(t,n,e,r){var a,s,l,c;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,this.iwcHandler=u,c=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(c),this.initialized={},a=function(t){return function(e){var i;return n=e.extras.HB,i=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[i]=!0}}(this),u.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=o&&this.engine.applyOpsCheckDouble(o),l=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[l]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.setIwcHandler=function(t){return a=t},t}(),r=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=t)}).call(this);
|
||||
(function(){var t;t=function(t,n){var e,i,r,o,u,a;return a=null,null!=n&&(a=n.iwcHandler),o={},i=new DUIClient,i.connect(function(t){var n;return null!=(n=o[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),i.initOK(),u=null,e=function(){function t(t,n,e,r){var a,s,l,c;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,this.iwcHandler=o,c=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(c),this.initialized={},a=function(t){return function(e){var i;return n=e.extras.HB,i=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[i]=!0}}(this),o.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",this.HB.getOperationCounter()),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=u&&this.engine.applyOpsCheckDouble(u),l=function(t){return function(n){var e,i;return i=n.extras,console.log(i),e={HB:t.yatta.getHistoryBuffer()._encode(i),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",e)}}(this),this.iwcHandler.Yatta_get_HB_element=[l]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.setIwcHandler=function(t){return a=t},t}(),r=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=t)}).call(this);
|
||||
//# sourceMappingURL=../Connectors/IwcConnector.js.map
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
(function(){var n;n=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,o,r){var i;this.engine=n,this.HB=e,this.execution_listener=o,this.yatta=r,this.peer=t,this.connections={},this.peer.on("connection",function(n){return function(e){return e.send("hey"),n.addConnection(e)}}(this)),i=function(n){return function(e){return n.send(e)}}(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;return this.connections[n.peer]=n,n.on("data",function(n){return function(e){var t,o,r,i,u;if("hey"===e)return console.log("Yatta: Connection received with init message (debug)");if(null!=e.HB)return n.engine.applyOpsCheckDouble(e.HB);if(null!=e.op)return n.engine.applyOp(e.op);if(null!=e.conns){for(i=e.conns,u=[],o=0,r=i.length;r>o;o++)t=i[o],u.push(n.connectToPeer(t));return u}throw new Error("Can't parse this operation")}}(this)),e=function(e){return function(){return n.send({HB:e.yatta.getHistoryBuffer()._encode()}),n.send({conns:e.getAllConnectionIds()})}}(this),setTimeout(e,1e3)},n.prototype.send=function(n){var e,t,o,r;if(n.uid.creator===this.HB.getUserId()&&"string"!=typeof n.uid.op_number){o=this.connections,r=[];for(t in o)e=o[t],r.push(e.send({op:n}));return r}},n.prototype.receive=function(n){return n.uid.creator!==this.HB.getUserId()?this.engine.applyOp(n):void 0},n}(),t.on("open",function(t){return e(n,t)})},module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=n)}).call(this);
|
||||
(function(){var n;n=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,o,r){var i;this.engine=n,this.HB=t,this.execution_listener=o,this.yatta=r,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){return n.send(t)}}(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,o;return this.connections[n.peer]=n,e=!1,t=!1,n.on("data",function(o){return function(r){var i,s,u,c,a;if("empty_message"===r);else{if(null!=r.HB)return e=!0,o.engine.applyOpsCheckDouble(r.HB),n.send({conns:o.getAllConnectionIds()});if(null!=r.op)return o.engine.applyOp(r.op);if(null!=r.conns){for(c=r.conns,a=[],s=0,u=c.length;u>s;s++)i=c[s],a.push(o.connectToPeer(i));return a}if(null==r.state_vector)throw new Error("Can't parse this operation");if(!t)return n.send({HB:o.yatta.getHistoryBuffer()._encode(r.state_vector)}),t=!0}}}(this)),(o=function(t){return function(){return n.send({state_vector:t.HB.getOperationCounter()}),e?void 0:setTimeout(o,100)}}(this))()},n.prototype.send=function(n){var t,e,o,r;if(n.uid.creator===this.HB.getUserId()&&"string"!=typeof n.uid.op_number){o=this.connections,r=[];for(e in o)t=o[e],r.push(t.send({op:n}));return r}},n.prototype.receive=function(n){return n.uid.creator!==this.HB.getUserId()?this.engine.applyOp(n):void 0},n}(),e.on("open",function(e){return t(n,e)})},module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=n)}).call(this);
|
||||
//# sourceMappingURL=../Connectors/PeerJsConnector.js.map
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
(function(){var r;r=function(){function r(r){this.user_id=r,this.operation_counter={},this.buffer={},this.change_listeners=[]}return r.prototype.getUserId=function(){return this.user_id},r.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},r.prototype.getOperationCounter=function(){var r,t,e,o;t={},o=this.operation_counter;for(e in o)r=o[e],t[e]=r;return t},r.prototype._encode=function(r){var t,e,o,n,i,u,c,p,f,l;null==r&&(r={}),t=[],p=function(t,e){if(null==t||null==e)throw new Error("dah!");return null==r[t]||r[t]<=e},l=this.buffer;for(c in l){f=l[c];for(i in f)if(e=f[i],!isNaN(parseInt(i))&&p(c,i)){if(o=e._encode(),null!=e.next_cl){for(n=e.next_cl;null!=n.next_cl&&p(n.creator,n.op_number);)n=n.next_cl;o.next=n.getUid()}else if(null!=e.prev_cl){for(u=e.prev_cl;null!=u.prev_cl&&p(n.creator,n.op_number);)u=u.prev_cl;o.prev=u.getUid()}t.push(o)}}return t},r.prototype.getNextOperationIdentifier=function(r){var t;return null==r&&(r=this.user_id),null==this.operation_counter[r]&&(this.operation_counter[r]=0),t={creator:r,op_number:this.operation_counter[r]},this.operation_counter[r]++,t},r.prototype.getOperation=function(r){var t;if(r instanceof Object)return null!=(t=this.buffer[r.creator])?t[r.op_number]:void 0;if(null!=r)throw new Error("This type of uid is not defined!")},r.prototype.addOperation=function(r){if(null==this.buffer[r.creator]&&(this.buffer[r.creator]={}),null!=this.buffer[r.creator][r.op_number])throw new Error("You must not overwrite operations!");return this.buffer[r.creator][r.op_number]=r,r},r.prototype.addToCounter=function(r){return null==this.operation_counter[r.creator]&&(this.operation_counter[r.creator]=0),"number"==typeof r.op_number&&r.creator!==this.getUserId()?this.operation_counter[r.creator]++:void 0},r}(),module.exports=r}).call(this);
|
||||
(function(){var r;r=function(){function r(r){this.user_id=r,this.operation_counter={},this.buffer={},this.change_listeners=[]}return r.prototype.getUserId=function(){return this.user_id},r.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},r.prototype.getOperationCounter=function(){var r,t,e,o;t={},o=this.operation_counter;for(e in o)r=o[e],t[e]=r;return t},r.prototype._encode=function(r){var t,e,o,n,i,u,c,p,a,f;null==r&&(r={}),t=[],p=function(t,e){if(null==t||null==e)throw new Error("dah!");return null==r[t]||r[t]<=e},f=this.buffer;for(c in f){a=f[c];for(i in a)if(e=a[i],!isNaN(parseInt(i))&&p(c,i)){if(o=e._encode(),null!=e.next_cl){for(n=e.next_cl;null!=n.next_cl&&p(n.creator,n.op_number);)n=n.next_cl;o.next=n.getUid()}else if(null!=e.prev_cl){for(u=e.prev_cl;null!=u.prev_cl&&p(u.creator,u.op_number);)u=u.prev_cl;o.prev=u.getUid()}t.push(o)}}return t},r.prototype.getNextOperationIdentifier=function(r){var t;return null==r&&(r=this.user_id),null==this.operation_counter[r]&&(this.operation_counter[r]=0),t={creator:r,op_number:this.operation_counter[r]},this.operation_counter[r]++,t},r.prototype.getOperation=function(r){var t;if(r instanceof Object)return null!=(t=this.buffer[r.creator])?t[r.op_number]:void 0;if(null!=r)throw new Error("This type of uid is not defined!")},r.prototype.addOperation=function(r){if(null==this.buffer[r.creator]&&(this.buffer[r.creator]={}),null!=this.buffer[r.creator][r.op_number])throw new Error("You must not overwrite operations!");return this.buffer[r.creator][r.op_number]=r,r},r.prototype.addToCounter=function(r){var t;if(null==this.operation_counter[r.creator]&&(this.operation_counter[r.creator]=0),"number"==typeof r.op_number&&r.creator!==this.getUserId()&&r.op_number===this.operation_counter[r.creator]){for(this.operation_counter[r.creator]++,t=[];null!=this.getOperation({creator:r.creator,op_number:this.operation_counter[r.creator]});)t.push(this.operation_counter[r.creator]++);return t}},r}(),module.exports=r}).call(this);
|
||||
//# sourceMappingURL=HistoryBuffer.js.map
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
{"version":3,"file":"Types/XmlTypes.js","sources":["Types/XmlTypes.coffee"],"names":[],"mappings":"CA0H8B","sourcesContent":[""],"sourceRoot":"/source/"}
|
||||
{"version":3,"file":"Types/XmlTypes.js","sources":["Types/XmlTypes.coffee"],"names":[],"mappings":"CA4GgC","sourcesContent":[""],"sourceRoot":"/source/"}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -22,7 +22,7 @@ gulp.task 'build', ['lint', 'browser']
|
||||
files =
|
||||
lib : ['./lib/**/*.coffee']
|
||||
build : ['./build/**']
|
||||
browser : ['./lib/**/*.coffee', './lib/Connectors/**/*', './lib/Frameworks/**/*', './lib/index.coffee']
|
||||
browser : ['./lib/Connectors/**/*', './lib/Frameworks/**/*', './lib/index.coffee']
|
||||
test : ['./test/**/*_test.coffee']
|
||||
gulp : ['./gulpfile.coffee']
|
||||
examples : ['./examples/**/*.js']
|
||||
|
@ -53,7 +53,7 @@ createIwcConnector = (callback, options)->
|
||||
@initialized[him] = true
|
||||
iwcHandler["Yatta_push_HB_element"] = [receiveHB]
|
||||
|
||||
@sendIwcIntent "Yatta_get_HB_element", {}
|
||||
@sendIwcIntent "Yatta_get_HB_element", @HB.getOperationCounter()
|
||||
|
||||
receive_ = (intent)=>
|
||||
o = intent.extras
|
||||
@ -65,9 +65,11 @@ createIwcConnector = (callback, options)->
|
||||
if received_HB?
|
||||
@engine.applyOpsCheckDouble received_HB
|
||||
|
||||
sendHistoryBuffer = ()=>
|
||||
sendHistoryBuffer = (intent)=>
|
||||
state_vector = intent.extras
|
||||
console.log state_vector
|
||||
json =
|
||||
HB : @yatta.getHistoryBuffer()._encode()
|
||||
HB : @yatta.getHistoryBuffer()._encode(state_vector)
|
||||
user : @yatta.getUserId()
|
||||
@sendIwcIntent "Yatta_push_HB_element", json
|
||||
@iwcHandler["Yatta_get_HB_element"] = [sendHistoryBuffer]
|
||||
|
@ -35,7 +35,6 @@ createPeerJsConnector = ()->
|
||||
@connections = {}
|
||||
|
||||
@peer.on 'connection', (conn)=>
|
||||
conn.send "hey" # is never send. But without it it won't work either..
|
||||
@addConnection conn
|
||||
|
||||
send_ = (o)=>
|
||||
@ -50,29 +49,47 @@ createPeerJsConnector = ()->
|
||||
for conn_id of @connections
|
||||
conn_id
|
||||
|
||||
#
|
||||
# What this method does:
|
||||
# * Send state vector
|
||||
# * Receive HB -> apply them
|
||||
# * Send connections
|
||||
# * Receive Connections -> Connect to unknow connections
|
||||
#
|
||||
addConnection: (conn)->
|
||||
@connections[conn.peer] = conn
|
||||
|
||||
initialized_me = false
|
||||
initialized_him = false
|
||||
conn.on 'data', (data)=>
|
||||
if data is "hey"
|
||||
console.log "Yatta: Connection received with init message (debug)" # I can remove this hey stuff when this happens.
|
||||
if data is "empty_message"
|
||||
# nop
|
||||
else if data.HB?
|
||||
initialized_me = true
|
||||
@engine.applyOpsCheckDouble data.HB
|
||||
conn.send
|
||||
conns: @getAllConnectionIds()
|
||||
else if data.op?
|
||||
@engine.applyOp data.op
|
||||
else if data.conns?
|
||||
for conn_id in data.conns
|
||||
@connectToPeer conn_id
|
||||
else if data.state_vector?
|
||||
if not initialized_him
|
||||
# make sure, that it is sent only once
|
||||
conn.send
|
||||
HB: @yatta.getHistoryBuffer()._encode(data.state_vector)
|
||||
initialized_him = true
|
||||
else
|
||||
throw new Error "Can't parse this operation"
|
||||
|
||||
sendHB = ()=>
|
||||
sendStateVector = ()=>
|
||||
conn.send
|
||||
HB: @yatta.getHistoryBuffer()._encode()
|
||||
conn.send
|
||||
conns: @getAllConnectionIds()
|
||||
|
||||
setTimeout sendHB, 1000
|
||||
state_vector: @HB.getOperationCounter()
|
||||
if not initialized_me
|
||||
# Because of a bug in PeerJs,
|
||||
# we never know if state vector was actually sent
|
||||
setTimeout sendStateVector, 100
|
||||
sendStateVector()
|
||||
|
||||
#
|
||||
# This function is called whenever an operation was executed.
|
||||
|
@ -44,7 +44,7 @@ class HistoryBuffer
|
||||
|
||||
#
|
||||
# Encode this operation in such a way that it can be parsed by remote peers.
|
||||
#
|
||||
# TODO: Make this more efficient!
|
||||
_encode: (state_vector={})->
|
||||
json = []
|
||||
unknown = (user, o_number)->
|
||||
@ -55,15 +55,18 @@ class HistoryBuffer
|
||||
for u_name,user of @buffer
|
||||
for o_number,o of user
|
||||
if (not isNaN(parseInt(o_number))) and unknown(u_name, o_number)
|
||||
# its necessary to send it, and not known in state_vector
|
||||
o_json = o._encode()
|
||||
if o.next_cl?
|
||||
# search for the next _known_ operation. (When state_vector is {} then this is the Delimiter)
|
||||
o_next = o.next_cl
|
||||
while o_next.next_cl? and unknown(o_next.creator, o_next.op_number)
|
||||
o_next = o_next.next_cl
|
||||
o_json.next = o_next.getUid()
|
||||
else if o.prev_cl?
|
||||
# same as the above with prev.
|
||||
o_prev = o.prev_cl
|
||||
while o_prev.prev_cl? and unknown(o_next.creator, o_next.op_number)
|
||||
while o_prev.prev_cl? and unknown(o_prev.creator, o_prev.op_number)
|
||||
o_prev = o_prev.prev_cl
|
||||
o_json.prev = o_prev.getUid()
|
||||
json.push o_json
|
||||
@ -114,7 +117,14 @@ class HistoryBuffer
|
||||
if not @operation_counter[o.creator]?
|
||||
@operation_counter[o.creator] = 0
|
||||
if typeof o.op_number is 'number' and o.creator isnt @getUserId()
|
||||
@operation_counter[o.creator]++
|
||||
# TODO: fix this issue better.
|
||||
# Operations should income in order
|
||||
# Then you don't have to do this..
|
||||
if o.op_number is @operation_counter[o.creator]
|
||||
@operation_counter[o.creator]++
|
||||
while @getOperation({creator:o.creator, op_number: @operation_counter[o.creator]})?
|
||||
@operation_counter[o.creator]++
|
||||
|
||||
#if @operation_counter[o.creator] isnt (o.op_number + 1)
|
||||
#console.log (@operation_counter[o.creator] - (o.op_number + 1))
|
||||
#console.log o
|
||||
|
@ -117,8 +117,16 @@ module.exports = class Test
|
||||
choices[choice](user_num)
|
||||
|
||||
flushAll: ()->
|
||||
for user,user_number in @users
|
||||
user.getConnector().flushAll()
|
||||
if @users.length <= 1
|
||||
for user,user_number in @users
|
||||
user.getConnector().flushAll()
|
||||
else
|
||||
for user,user_number in @users[1..]
|
||||
user.getConnector().flushAll()
|
||||
ops = @users[1].getHistoryBuffer()._encode @users[0].HB.getOperationCounter()
|
||||
@users[0].getEngine().applyOpsCheckDouble ops
|
||||
|
||||
|
||||
|
||||
compareAll: (test_number)->
|
||||
@flushAll()
|
||||
|
Loading…
x
Reference in New Issue
Block a user