simple editing working
This commit is contained in:
parent
eb541fd473
commit
2a10fe45fa
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
!function n(e,t,r){function o(u,c){if(!t[u]){if(!e[u]){var s="function"==typeof require&&require;if(!c&&s)return s(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(n){var e,t;return t=new Peer({key:"h7nlefbgavh1tt9"}),e=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 this.addConnection(t.connect(n))},n.prototype.addConnection=function(n){var e;return this.connections.push(n),n.on("data",function(n){return function(e){if("hey"!==e){if(null!=e.HB)return n.engine.applyOpsCheckDouble(e.HB);if(null!=e.op)return n.engine.applyOp(e.op);throw new Error("Can't parse this operation")}}}(this)),e=function(e){return function(){return n.send({HB:e.yatta.getHistoryBuffer()._encode()})}}(this),setTimeout(e,1e3)},n.prototype.send=function(n){var e,t,r,o,i;if(n.uid.creator===this.HB.getUserId()&&"string"!=typeof n.uid.op_number){for(o=this.connections,i=[],t=0,r=o.length;r>t;t++)e=o[t],i.push(e.send({op:n}));return i}},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 n(e,t)})},e.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=t)},{}]},{},[1]);
|
||||
!function n(e,t,o){function r(u,c){if(!t[u]){if(!e[u]){var s="function"==typeof require&&require;if(!c&&s)return s(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 r(t?t:n)},f,f.exports,n,e,t,o)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}({1:[function(n,e){var t;t=function(n){var e,t;return t=new Peer({key:"h7nlefbgavh1tt9"}),e=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(console.log("conns received"),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 n(e,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
2
build/browser/Frameworks/JsonYatta.min.js
vendored
2
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
2
build/browser/Frameworks/TextYatta.min.js
vendored
2
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/IwcConnector.min.js
vendored
Normal file
1
build/browser/IwcConnector.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function t(n,e,i){function r(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 r(e?e:t)},c,c.exports,t,n,e,i)}return e[u].exports}for(var o="function"==typeof require&&require,u=0;u<i.length;u++)r(i[u]);return r}({1:[function(t,n){var e;e=function(t,n){var e,i,r,o,u;return 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)}):void 0}),i.initOK(),u=null,e=function(){function t(t,n,e,r){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,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 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",{}),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(){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={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n},this.duiClient.sendIntent(e)},t}(),r=function(){var i;return i=null,i=null!=n?n:Math.floor(1e6*Math.random()),t(e,i)},void setTimeout(r,5e3)},n.exports=e,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=e)},{}]},{},[1]);
|
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
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,o){function r(u,c){if(!t[u]){if(!e[u]){var s="function"==typeof require&&require;if(!c&&s)return s(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 r(t?t:n)},f,f.exports,n,e,t,o)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}({1:[function(n,e){var t;t=function(n){var e,t;return t=new Peer({key:"h7nlefbgavh1tt9"}),e=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(console.log("conns received"),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 n(e,t)})},e.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=t)},{}]},{},[1]);
|
1
build/browser/TestConnector.min.js
vendored
Normal file
1
build/browser/TestConnector.min.js
vendored
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
2
build/browser/Types/BasicTypes.min.js
vendored
2
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
2
build/browser/Types/JsonTypes.min.js
vendored
2
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
2
build/browser/Types/StructuredTypes.min.js
vendored
2
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
2
build/browser/Types/TextTypes.min.js
vendored
2
build/browser/Types/TextTypes.min.js
vendored
File diff suppressed because one or more lines are too long
@ -2,4 +2,5 @@
|
||||
|
||||
|
||||
|
||||
},{}]},{},[1])
|
||||
},{}]},{},[1])
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL2Rtb25hZC9Ecm9wYm94L1lhdHRhIS9ub2RlX21vZHVsZXMvZ3VscC1icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvaG9tZS9kbW9uYWQvRHJvcGJveC9ZYXR0YSEvbGliL1R5cGVzL1htbFR5cGVzLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQ0FBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiKGZ1bmN0aW9uIGUodCxuLHIpe2Z1bmN0aW9uIHMobyx1KXtpZighbltvXSl7aWYoIXRbb10pe3ZhciBhPXR5cGVvZiByZXF1aXJlPT1cImZ1bmN0aW9uXCImJnJlcXVpcmU7aWYoIXUmJmEpcmV0dXJuIGEobywhMCk7aWYoaSlyZXR1cm4gaShvLCEwKTt0aHJvdyBuZXcgRXJyb3IoXCJDYW5ub3QgZmluZCBtb2R1bGUgJ1wiK28rXCInXCIpfXZhciBmPW5bb109e2V4cG9ydHM6e319O3Rbb11bMF0uY2FsbChmLmV4cG9ydHMsZnVuY3Rpb24oZSl7dmFyIG49dFtvXVsxXVtlXTtyZXR1cm4gcyhuP246ZSl9LGYsZi5leHBvcnRzLGUsdCxuLHIpfXJldHVybiBuW29dLmV4cG9ydHN9dmFyIGk9dHlwZW9mIHJlcXVpcmU9PVwiZnVuY3Rpb25cIiYmcmVxdWlyZTtmb3IodmFyIG89MDtvPHIubGVuZ3RoO28rKylzKHJbb10pO3JldHVybiBzfSkiLCJcblxuLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZGF0YTphcHBsaWNhdGlvbi9qc29uO2Jhc2U2NCxleUoyWlhKemFXOXVJam96TENKbWFXeGxJam9pTDJodmJXVXZaRzF2Ym1Ga0wwUnliM0JpYjNndldXRjBkR0VoTDJ4cFlpOVVlWEJsY3k5WWJXeFVlWEJsY3k1amIyWm1aV1VpTENKemIzVnlZMlZTYjI5MElqb2lJaXdpYzI5MWNtTmxjeUk2V3lJdmFHOXRaUzlrYlc5dVlXUXZSSEp2Y0dKdmVDOVpZWFIwWVNFdmJHbGlMMVI1Y0dWekwxaHRiRlI1Y0dWekxtTnZabVpsWlNKZExDSnVZVzFsY3lJNlcxMHNJbTFoY0hCcGJtZHpJam9pUVVGNVkwY2lMQ0p6YjNWeVkyVnpRMjl1ZEdWdWRDSTZXeUlpWFgwPSJdfQ==
|
||||
|
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
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
(function(){var n;n=function(n){var t,e;return e=new Peer({key:"h7nlefbgavh1tt9"}),t=function(){function n(n,t,o,i){var r;this.engine=n,this.HB=t,this.execution_listener=o,this.yatta=i,this.peer=e,this.connections=[],this.peer.on("connection",function(n){return function(t){return t.send("hey"),n.addConnection(t)}}(this)),r=function(n){return function(t){return n.send(t)}}(this),this.execution_listener.push(r)}return n.prototype.connectToPeer=function(n){return this.addConnection(e.connect(n))},n.prototype.addConnection=function(n){var t;return this.connections.push(n),n.on("data",function(n){return function(t){if("hey"!==t){if(null!=t.HB)return n.engine.applyOpsCheckDouble(t.HB);if(null!=t.op)return n.engine.applyOp(t.op);throw new Error("Can't parse this operation")}}}(this)),t=function(t){return function(){return n.send({HB:t.yatta.getHistoryBuffer()._encode()})}}(this),setTimeout(t,1e3)},n.prototype.send=function(n){var t,e,o,i,r;if(n.uid.creator===this.HB.getUserId()&&"string"!=typeof n.uid.op_number){for(i=this.connections,r=[],e=0,o=i.length;o>e;e++)t=i[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 n(t,e)})},module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=n)}).call(this);
|
||||
(function(){var n;n=function(n){var e,t;return t=new Peer({key:"h7nlefbgavh1tt9"}),e=function(){function n(n,e,o,i){var r;this.engine=n,this.HB=e,this.execution_listener=o,this.yatta=i,this.peer=t,this.connections={},this.peer.on("connection",function(n){return function(e){return e.send("hey"),n.addConnection(e)}}(this)),r=function(n){return function(e){return n.send(e)}}(this),this.execution_listener.push(r)}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,i,r,c;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(console.log("conns received"),r=e.conns,c=[],o=0,i=r.length;i>o;o++)t=r[o],c.push(n.connectToPeer(t));return c}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,i;if(n.uid.creator===this.HB.getUserId()&&"string"!=typeof n.uid.op_number){o=this.connections,i=[];for(t in o)e=o[t],i.push(e.send({op:n}));return i}},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 n(e,t)})},module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createPeerJsConnector=n)}).call(this);
|
||||
//# sourceMappingURL=../Connectors/PeerJsConnector.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"Connectors/PeerJsConnector.js","sources":["Connectors/PeerJsConnector.coffee"],"names":[],"mappings":"CAIA,WAAA,GAAA,EAAA,GAAwB,SAAC,GAEvB,GAAA,GAAA,QAAA,GAAW,GAAA,OAAM,IAAK,oBAKhB,EAAA,WAQS,QAAA,GAAE,EAAS,EAAK,EAAqB,GAEhD,GAAA,EAFY,MAAC,OAAA,EAAQ,KAAC,GAAA,EAAI,KAAC,mBAAA,EAAoB,KAAC,MAAA,EAEhD,KAAC,KAAO,EACR,KAAC,eAED,KAAC,KAAK,GAAG,aAAc,SAAA,SAAA,UAAC,SACtB,GAAK,KAAK,OACV,EAAC,cAAc,KAFM,OAOvB,EAAQ,SAAA,SAAA,UAAC,SACP,GAAC,KAAK,KADA,MAER,KAAC,mBAAmB,KAAK,SAd3B,GAAA,UAgBA,cAAe,SAAC,SACd,MAAC,cAAc,EAAK,QAAQ,KAjB9B,EAAA,UAmBA,cAAe,SAAC,GACd,GAAA,SAAA,MAAC,YAAY,KAAK,GAElB,EAAK,GAAG,OAAQ,SAAA,SAAA,UAAC,GACf,GAAW,QAAR,EACE,CAAA,GAAG,MAAA,EAAA,SACN,GAAC,OAAO,oBAAoB,EAAK,GAC9B,IAAG,MAAA,EAAA,SACN,GAAC,OAAO,QAAQ,EAAK,GAErB,MAAU,IAAA,OAAM,iCAPJ,OAShB,EAAS,SAAA,SAAA,kBACP,GAAK,MACH,GAAI,EAAC,MAAM,mBAAmB,cAFzB,MAGT,WAAW,EAAQ,MAlCrB,EAAA,UAwCA,KAAM,SAAC,GACL,GAAA,GAAA,EAAA,EAAA,EAAA,CAAA,IAAG,EAAE,IAAI,UAAW,KAAC,GAAG,aAA6C,gBAA5B,GAAS,IAAI,UAAtD,KACE,EAAA,KAAA,YAAA,KAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,WACE,EAAA,KAAA,EAAK,MACH,GAAI,gBA5CZ,EAAA,UAkDA,QAAS,SAAC,GACR,MAAG,GAAE,IAAI,UAAa,KAAC,GAAG,YACxB,KAAC,OAAO,QAAQ,GADlB,aAGJ,EAAK,GAAG,OAAQ,SAAC,SACf,GAAS,EAAiB,MAG9B,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,sBAAwB","sourcesContent":["\n#\n# @param {Function} callback The callback is called when the connector is initialized.\n#\ncreatePeerJsConnector = (callback)->\n\n peer = new Peer {key: 'h7nlefbgavh1tt9'}\n\n #\n # @see http://peerjs.com\n #\n class PeerJsConnector\n\n #\n # @param {Engine} engine The transformation engine\n # @param {HistoryBuffer} HB\n # @param {Array<Function>} execution_listener You must ensure that whenever an operation is executed, every function in this Array is called.\n # @param {Yatta} yatta The Yatta framework.\n #\n constructor: (@engine, @HB, @execution_listener, @yatta)->\n\n @peer = peer\n @connections = []\n\n @peer.on 'connection', (conn)=>\n conn.send \"hey\"\n @addConnection conn\n\n\n\n\n send_ = (o)=>\n @send o\n @execution_listener.push send_\n\n connectToPeer: (id)->\n @addConnection peer.connect id\n\n addConnection: (conn)->\n @connections.push conn\n\n conn.on 'data', (data)=>\n if data is \"hey\"\n else if data.HB?\n @engine.applyOpsCheckDouble data.HB\n else if data.op?\n @engine.applyOp data.op\n else\n throw new Error \"Can't parse this operation\"\n\n sendHB = ()=>\n conn.send\n HB: @yatta.getHistoryBuffer()._encode()\n setTimeout sendHB, 1000\n\n #\n # This function is called whenever an operation was executed.\n # @param {Operation} o The operation that was executed.\n #\n send: (o)->\n if o.uid.creator is @HB.getUserId() and (typeof o.uid.op_number isnt \"string\")\n for conn in @connections\n conn.send\n op: o\n\n #\n # This function is called whenever an operation was received from another peer.\n # @param {Operation} o The operation that was received.\n #\n receive: (o)->\n if o.uid.creator isnt @HB.getUserId()\n @engine.applyOp o\n\n peer.on 'open', (id)->\n callback PeerJsConnector, id\n\n\nmodule.exports = createPeerJsConnector\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.createPeerJsConnector = createPeerJsConnector\n\n"],"sourceRoot":"/source/"}
|
||||
{"version":3,"file":"Connectors/PeerJsConnector.js","sources":["Connectors/PeerJsConnector.coffee"],"names":[],"mappings":"CAIA,WAAA,GAAA,EAAA,GAAwB,SAAC,GAEvB,GAAA,GAAA,QAAA,GAAW,GAAA,OAAM,IAAK,oBAKhB,EAAA,WAQS,QAAA,GAAE,EAAS,EAAK,EAAqB,GAEhD,GAAA,EAFY,MAAC,OAAA,EAAQ,KAAC,GAAA,EAAI,KAAC,mBAAA,EAAoB,KAAC,MAAA,EAEhD,KAAC,KAAO,EACR,KAAC,eAED,KAAC,KAAK,GAAG,aAAc,SAAA,SAAA,UAAC,SACtB,GAAK,KAAK,OACV,EAAC,cAAc,KAFM,OAIvB,EAAQ,SAAA,SAAA,UAAC,SACP,GAAC,KAAK,KADA,MAER,KAAC,mBAAmB,KAAK,SAX3B,GAAA,UAaA,cAAe,SAAC,GACd,MAAO,OAAA,KAAA,YAAA,IAAsB,IAAQ,KAAC,MAAM,YAC1C,KAAC,cAAc,EAAK,QAAQ,IAD9B,QAdF,EAAA,UAiBA,oBAAqB,WACnB,GAAA,GAAA,CAAA,UAAA,IAAA,MAAA,YACE,EAAA,KAAA,aAnBJ,EAAA,UAqBA,cAAe,SAAC,GACd,GAAA,SAAA,MAAC,YAAY,EAAK,MAAQ,EAE1B,EAAK,GAAG,OAAQ,SAAA,SAAA,UAAC,GACf,GAAA,GAAA,EAAA,EAAA,EAAA,CAAA,IAAW,QAAR,QACD,SAAQ,IAAI,uDACT,IAAG,MAAA,EAAA,SACN,GAAC,OAAO,oBAAoB,EAAK,GAC9B,IAAG,MAAA,EAAA,SACN,GAAC,OAAO,QAAQ,EAAK,GAClB,IAAG,MAAA,EAAA,MAAH,KACH,QAAQ,IAAI,kBACZ,EAAA,EAAA,MAAA,KAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,WACE,EAAA,KAAA,EAAC,cAAc,aAEjB,KAAU,IAAA,OAAM,gCAZJ,OAchB,EAAS,SAAA,SAAA,kBACP,GAAK,MACH,GAAI,EAAC,MAAM,mBAAmB,YAChC,EAAK,MACH,MAAO,EAAC,0BAJH,MAMT,WAAW,EAAQ,MA5CrB,EAAA,UAkDA,KAAM,SAAC,GACL,GAAA,GAAA,EAAA,EAAA,CAAA,IAAG,EAAE,IAAI,UAAW,KAAC,GAAG,aAA6C,gBAA5B,GAAS,IAAI,UAAtD,CACE,EAAA,KAAA,YAAA,SAAA,IAAA,UACE,EAAA,KAAA,EAAK,MACH,GAAI,gBAtDZ,EAAA,UA4DA,QAAS,SAAC,GACR,MAAG,GAAE,IAAI,UAAa,KAAC,GAAG,YACxB,KAAC,OAAO,QAAQ,GADlB,aAGJ,EAAK,GAAG,OAAQ,SAAC,SACf,GAAS,EAAiB,MAG9B,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,sBAAwB","sourcesContent":["\n#\n# @param {Function} callback The callback is called when the connector is initialized.\n#\ncreatePeerJsConnector = (callback)->\n\n peer = new Peer {key: 'h7nlefbgavh1tt9'}\n\n #\n # @see http://peerjs.com\n #\n class PeerJsConnector\n\n #\n # @param {Engine} engine The transformation engine\n # @param {HistoryBuffer} HB\n # @param {Array<Function>} execution_listener You must ensure that whenever an operation is executed, every function in this Array is called.\n # @param {Yatta} yatta The Yatta framework.\n #\n constructor: (@engine, @HB, @execution_listener, @yatta)->\n\n @peer = peer\n @connections = {}\n\n @peer.on 'connection', (conn)=>\n conn.send \"hey\" # is never send. But without it it won't work either..\n @addConnection conn\n\n send_ = (o)=>\n @send o\n @execution_listener.push send_\n\n connectToPeer: (id)->\n if not @connections[id]? and id isnt @yatta.getUserId()\n @addConnection peer.connect id\n\n getAllConnectionIds: ()->\n for conn_id of @connections\n conn_id\n\n addConnection: (conn)->\n @connections[conn.peer] = conn\n\n conn.on 'data', (data)=>\n if data is \"hey\"\n console.log \"Yatta: Connection received with init message (debug)\" # I can remove this hey stuff when this happens.\n else if data.HB?\n @engine.applyOpsCheckDouble data.HB\n else if data.op?\n @engine.applyOp data.op\n else if data.conns?\n console.log \"conns received\"\n for conn_id in data.conns\n @connectToPeer conn_id\n else\n throw new Error \"Can't parse this operation\"\n\n sendHB = ()=>\n conn.send\n HB: @yatta.getHistoryBuffer()._encode()\n conn.send\n conns: @getAllConnectionIds()\n\n setTimeout sendHB, 1000\n\n #\n # This function is called whenever an operation was executed.\n # @param {Operation} o The operation that was executed.\n #\n send: (o)->\n if o.uid.creator is @HB.getUserId() and (typeof o.uid.op_number isnt \"string\")\n for conn_id,conn of @connections\n conn.send\n op: o\n\n #\n # This function is called whenever an operation was received from another peer.\n # @param {Operation} o The operation that was received.\n #\n receive: (o)->\n if o.uid.creator isnt @HB.getUserId()\n @engine.applyOp o\n\n peer.on 'open', (id)->\n callback PeerJsConnector, id\n\n\nmodule.exports = createPeerJsConnector\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.createPeerJsConnector = createPeerJsConnector\n\n"],"sourceRoot":"/source/"}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
(function(){var e,t={}.hasOwnProperty,n=function(e,n){function i(){this.constructor=e}for(var r in n)t.call(n,r)&&(e[r]=n[r]);return i.prototype=n.prototype,e.prototype=new i,e.__super__=n.prototype,e};e=require("./BasicTypes"),module.exports=function(t){var i,r,a,o,p,s,u,c;return s=e(t),c=s.types,u=s.parser,a=function(e){function r(e){this.map={},r.__super__.constructor.call(this,e)}return n(r,e),r.prototype.val=function(e,n){var a,o,p,s,u;if(null!=n)return null==this.map[e]&&t.addOperation(new i(void 0,this,e)).execute(),this.map[e].replace(n),this;if(null!=e)return o=null!=(s=this.map[e])?s.val():void 0,o instanceof c.ImmutableObject?o.val():o;p={},u=this.map;for(e in u)a=u[e],o=a.val(),(o instanceof c.ImmutableObject||o instanceof r)&&(o=o.val()),p[e]=o;return p},r}(c.Operation),i=function(e){function i(e,t,n){this.name=n,this.saveOperation("map_manager",t),i.__super__.constructor.call(this,e)}return n(i,e),i.prototype.execute=function(){var e,n,r,a,p;return this.validateSavedOperations()?(p=this.map_manager.getUid(),p.op_number="_"+p.op_number+"_RM_"+this.name,null==t.getOperation(p)&&(r=this.map_manager.getUid(),r.op_number="_"+r.op_number+"_RM_"+this.name+"_beginning",a=this.map_manager.getUid(),a.op_number="_"+a.op_number+"_RM_"+this.name+"_end",e=t.addOperation(new c.Delimiter(r,void 0,a)).execute(),n=t.addOperation(new c.Delimiter(a,e,void 0)).execute(),this.map_manager.map[this.name]=t.addOperation(new o(void 0,p,e,n)).execute()),i.__super__.execute.apply(this,arguments)):!1},i.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},i}(c.Operation),u.AddName=function(e){var t,n,r;return t=e.map_manager,r=e.uid,n=e.name,new i(r,t,n)},r=function(e){function i(e,n,r,a,o,p){null!=n&&null!=r?(this.saveOperation("beginning",n),this.saveOperation("end",r)):(this.beginning=t.addOperation(new c.Delimiter(void 0,void 0,void 0)),this.end=t.addOperation(new c.Delimiter(void 0,this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),i.__super__.constructor.call(this,e,a,o,p)}return n(i,e),i.prototype.getLastOperation=function(){return this.end.prev_cl},i.prototype.getFirstOperation=function(){return this.beginning.next_cl},i.prototype.toArray=function(){var e,t;for(e=this.beginning.next_cl,t=[];e!==this.end;)t.push(e),e=e.next_cl;return t},i.prototype.getOperationByPosition=function(e){var t;if(t=this.beginning.next_cl,e>0)for(;;){if(t=t.next_cl,t.isDeleted()||(e-=1),0===e)break;if(t instanceof c.Delimiter)throw new Error("position parameter exceeded the length of the document!")}return t},i}(c.Insert),o=function(e){function i(e,t,n,r,a,o,p){i.__super__.constructor.call(this,t,n,r,a,o,p),null!=e&&this.replace(e)}return n(i,e),i.prototype.replace=function(e){var n,i;return n=this.getLastOperation(),i=new p(e,this,void 0,n,n.next_cl),t.addOperation(i).execute()},i.prototype.val=function(){var e;if(e=this.getLastOperation(),e instanceof c.Delimiter)throw new Error("dtrn");return e.val()},i.prototype._encode=function(){var e;return e={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(e.prev=this.prev_cl.getUid(),e.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},i}(r),u.ReplaceManager=function(e){var t,n,i,r,a,p,s;return n=e.content,s=e.uid,p=e.prev,r=e.next,a=e.origin,t=e.beginning,i=e.end,new o(n,s,t,i,p,r,a)},p=function(e){function t(e,n,i,r,a,o){if(this.saveOperation("content",e),this.saveOperation("parent",n),null==r||null==a||null==e)throw new Error("You must define content, prev, and next for Replaceable-types!");t.__super__.constructor.call(this,i,r,a,o)}return n(t,e),t.prototype.val=function(){return this.content},t.prototype.replace=function(e){return this.parent.replace(e)},t.prototype.execute=function(){var e;return this.validateSavedOperations()?("function"==typeof(e=this.content).setReplaceManager&&e.setReplaceManager(this.parent),t.__super__.execute.apply(this,arguments)):!1},t.prototype._encode=function(){var e;return e={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},t}(c.Insert),u.Replaceable=function(e){var t,n,i,r,a,o;return t=e.content,r=e.ReplaceManager,o=e.uid,a=e.prev,n=e.next,i=e.origin,new p(t,r,o,a,n,i)},c.ListManager=r,c.MapManager=a,c.ReplaceManager=o,c.Replaceable=p,s}}).call(this);
|
||||
(function(){var e,t={}.hasOwnProperty,n=function(e,n){function i(){this.constructor=e}for(var r in n)t.call(n,r)&&(e[r]=n[r]);return i.prototype=n.prototype,e.prototype=new i,e.__super__=n.prototype,e};e=require("./BasicTypes"),module.exports=function(t){var i,r,a,o,p,s,u,c;return s=e(t),c=s.types,u=s.parser,a=function(e){function r(e){this.map={},r.__super__.constructor.call(this,e)}return n(r,e),r.prototype.val=function(e,n){var a,o,p,s,u;if(null!=n)return null==this.map[e]&&t.addOperation(new i(void 0,this,e)).execute(),this.map[e].replace(n),this;if(null!=e)return o=null!=(s=this.map[e])?s.val():void 0,o instanceof c.ImmutableObject?o.val():o;p={},u=this.map;for(e in u)a=u[e],o=a.val(),(o instanceof c.ImmutableObject||o instanceof r)&&(o=o.val()),p[e]=o;return p},r}(c.Operation),i=function(e){function i(e,t,n){this.name=n,this.saveOperation("map_manager",t),i.__super__.constructor.call(this,e)}return n(i,e),i.prototype.execute=function(){var e,n,r,a,p;return this.validateSavedOperations()?(p=this.map_manager.getUid(),p.op_number="_"+p.op_number+"_RM_"+this.name,null==t.getOperation(p)&&(r=this.map_manager.getUid(),r.op_number="_"+r.op_number+"_RM_"+this.name+"_beginning",a=this.map_manager.getUid(),a.op_number="_"+a.op_number+"_RM_"+this.name+"_end",e=t.addOperation(new c.Delimiter(r,void 0,a)).execute(),n=t.addOperation(new c.Delimiter(a,e,void 0)).execute(),this.map_manager.map[this.name]=t.addOperation(new o(void 0,p,e,n)).execute()),i.__super__.execute.apply(this,arguments)):!1},i.prototype._encode=function(){return{type:"AddName",uid:this.getUid(),map_manager:this.map_manager.getUid(),name:this.name}},i}(c.Operation),u.AddName=function(e){var t,n,r;return t=e.map_manager,r=e.uid,n=e.name,new i(r,t,n)},r=function(e){function i(e,n,r,a,o,p){null!=n&&null!=r?(this.saveOperation("beginning",n),this.saveOperation("end",r)):(this.beginning=t.addOperation(new c.Delimiter(void 0,void 0,void 0)),this.end=t.addOperation(new c.Delimiter(void 0,this.beginning,void 0)),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute()),i.__super__.constructor.call(this,e,a,o,p)}return n(i,e),i.prototype.execute=function(){return this.validateSavedOperations()?(this.beginning.setParent(this),this.end.setParent(this),i.__super__.execute.apply(this,arguments)):!1},i.prototype.getLastOperation=function(){return this.end.prev_cl},i.prototype.getFirstOperation=function(){return this.beginning.next_cl},i.prototype.toArray=function(){var e,t;for(e=this.beginning.next_cl,t=[];e!==this.end;)t.push(e),e=e.next_cl;return t},i.prototype.getOperationByPosition=function(e){var t;if(t=this.beginning.next_cl,e>0)for(;;){if(t=t.next_cl,t.isDeleted()||(e-=1),0===e)break;if(t instanceof c.Delimiter){console.log("position parameter exceeded the length of the document!"),t=null;break}}return t},i}(c.Insert),o=function(e){function i(e,t,n,r,a,o,p){i.__super__.constructor.call(this,t,n,r,a,o,p),null!=e&&this.replace(e)}return n(i,e),i.prototype.replace=function(e){var n,i;return n=this.getLastOperation(),i=new p(e,this,void 0,n,n.next_cl),t.addOperation(i).execute()},i.prototype.val=function(){var e;if(e=this.getLastOperation(),e instanceof c.Delimiter)throw new Error("dtrn");return e.val()},i.prototype._encode=function(){var e;return e={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(e.prev=this.prev_cl.getUid(),e.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},i}(r),u.ReplaceManager=function(e){var t,n,i,r,a,p,s;return n=e.content,s=e.uid,p=e.prev,r=e.next,a=e.origin,t=e.beginning,i=e.end,new o(n,s,t,i,p,r,a)},p=function(e){function t(e,n,i,r,a,o){if(this.saveOperation("content",e),this.saveOperation("parent",n),null==r||null==a||null==e)throw new Error("You must define content, prev, and next for Replaceable-types!");t.__super__.constructor.call(this,i,r,a,o)}return n(t,e),t.prototype.val=function(){return this.content},t.prototype.replace=function(e){return this.parent.replace(e)},t.prototype.execute=function(){var e;return this.validateSavedOperations()?("function"==typeof(e=this.content).setReplaceManager&&e.setReplaceManager(this.parent),t.__super__.execute.apply(this,arguments)):!1},t.prototype._encode=function(){var e;return e={type:"Replaceable",content:this.content.getUid(),ReplaceManager:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),uid:this.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},t}(c.Insert),u.Replaceable=function(e){var t,n,i,r,a,o;return t=e.content,r=e.ReplaceManager,o=e.uid,a=e.prev,n=e.next,i=e.origin,new p(t,r,o,a,n,i)},c.ListManager=r,c.MapManager=a,c.ReplaceManager=o,c.Replaceable=p,s}}).call(this);
|
||||
//# sourceMappingURL=../Types/StructuredTypes.js.map
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
(function(){var t,e={}.hasOwnProperty,n=function(t,n){function r(){this.constructor=t}for(var i in n)e.call(n,i)&&(t[i]=n[i]);return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t};t=require("./StructuredTypes"),module.exports=function(e){var r,i,o,s,u,c;return u=t(e),c=u.types,s=u.parser,r=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return n(e,t),e}(c.Delete),s.TextDelete=s.Delete,i=function(t){function e(t,n,r,i,o){if(this.content=t,null==r||null==i)throw new Error("You must define prev, and next for TextInsert-types!");e.__super__.constructor.call(this,n,r,i,o)}return n(e,t),e.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},e.prototype.val=function(){return this.isDeleted()?"":this.content},e.prototype._encode=function(){var t;return t={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(t.origin=this.origin.getUid()),t},e}(c.Insert),s.TextInsert=function(t){var e,n,r,o,s;return e=t.content,s=t.uid,o=t.prev,n=t.next,r=t.origin,new i(e,s,o,n,r)},o=function(t){function o(t,e,n,r,i,s){o.__super__.constructor.call(this,t,e,n,r,i,s)}return n(o,t),o.prototype.insertText=function(t,n){var r,o,s,u,c,p;for(o=this.getOperationByPosition(t),p=[],u=0,c=n.length;c>u;u++)r=n[u],s=new i(r,void 0,o.prev_cl,o),p.push(e.addOperation(s).execute());return p},o.prototype.deleteText=function(t,n){var i,o,s,u,p;for(s=this.getOperationByPosition(t),p=[],o=u=0;n>=0?n>u:u>n;o=n>=0?++u:--u){for(i=e.addOperation(new r(void 0,s)).execute(),s=s.next_cl;s.isDeleted();){if(s instanceof c.Delimiter)throw new Error("You can't delete more than there is..");s=s.next_cl}p.push(i._encode())}return p},o.prototype.replaceText=function(t){var n;if(null!=this.replace_manager)return n=e.addOperation(new o(void 0)).execute(),n.insertText(0,t),this.replace_manager.replace(n);throw new Error("This type is currently not maintained by a ReplaceManager!")},o.prototype.val=function(){var t,e;return t=function(){var t,n,r,i;for(r=this.toArray(),i=[],t=0,n=r.length;n>t;t++)e=r[t],i.push(null!=e.val?e.val():"");return i}.call(this),t.join("")},o.prototype.setReplaceManager=function(t){return this.saveOperation("replace_manager",t),this.validateSavedOperations},o.prototype._encode=function(){var t;return t={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(t.prev=this.prev_cl.getUid()),null!=this.next_cl&&(t.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(t.origin=this.origin.getUid()),t},o}(c.ListManager),s.Word=function(t){var e,n,r,i,s,u;return u=t.uid,e=t.beginning,n=t.end,s=t.prev,r=t.next,i=t.origin,new o(u,e,n,s,r,i)},c.TextInsert=i,c.TextDelete=r,c.Word=o,u}}).call(this);
|
||||
(function(){var t,e={}.hasOwnProperty,n=function(t,n){function r(){this.constructor=t}for(var i in n)e.call(n,i)&&(t[i]=n[i]);return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t};t=require("./StructuredTypes"),module.exports=function(e){var r,i,o,l,u,s;return u=t(e),s=u.types,l=u.parser,r=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return n(e,t),e}(s.Delete),l.TextDelete=l.Delete,i=function(t){function e(t,n,r,i,o){if(this.content=t,null==r||null==i)throw new Error("You must define prev, and next for TextInsert-types!");e.__super__.constructor.call(this,n,r,i,o)}return n(e,t),e.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},e.prototype.val=function(){return this.isDeleted()?"":this.content},e.prototype._encode=function(){var t;return t={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(t.origin=this.origin.getUid()),t},e}(s.Insert),l.TextInsert=function(t){var e,n,r,o,l;return e=t.content,l=t.uid,o=t.prev,n=t.next,r=t.origin,new i(e,l,o,n,r)},o=function(t){function o(t,e,n,r,i,l){o.__super__.constructor.call(this,t,e,n,r,i,l)}return n(o,t),o.prototype.insertText=function(t,n){var r,o,l,u,s,a;for(o=this.getOperationByPosition(t),a=[],u=0,s=n.length;s>u;u++)r=n[u],l=new i(r,void 0,o.prev_cl,o),a.push(e.addOperation(l).execute());return a},o.prototype.deleteText=function(t,n){var i,o,l,u,a,c;for(u=this.getOperationByPosition(t),o=[],c=[],l=a=0;n>=0?n>a:a>n;l=n>=0?++a:--a){for(i=e.addOperation(new r(void 0,u)).execute(),u=u.next_cl;u.isDeleted()&&!(u instanceof s.Delimiter);){if(u instanceof s.Delimiter)throw new Error("You can't delete more than there is..");u=u.next_cl}if(o.push(i._encode()),u instanceof s.Delimiter)break;c.push(void 0)}return c},o.prototype.replaceText=function(t){var n;if(null!=this.replace_manager)return n=e.addOperation(new o(void 0)).execute(),n.insertText(0,t),this.replace_manager.replace(n);throw new Error("This type is currently not maintained by a ReplaceManager!")},o.prototype.val=function(){var t,e;return t=function(){var t,n,r,i;for(r=this.toArray(),i=[],t=0,n=r.length;n>t;t++)e=r[t],i.push(null!=e.val?e.val():"");return i}.call(this),t.join("")},o.prototype.setReplaceManager=function(t){return this.saveOperation("replace_manager",t),this.validateSavedOperations},o.prototype.bind=function(t){var n,r,i,o;return o=this,t.value=this.val(),r=null,n=null,this.on("insert",function(i,l){var u,s,a,c;return l.creator!==e.getUserId()?(a=l.getPosition(),u=function(t){return a>=t?t:t+=1},s=u(t.selectionStart),c=u(t.selectionEnd),null!=r&&(n+=1,r=u(r)),t.value=o.val(),t.setSelectionRange(s,c)):void 0}),this.on("delete",function(i,l){var u,s,a,c;return l.creator!==e.getUserId()?(a=l.getPosition(),u=function(t){return a>=t?t:t-=1},s=u(t.selectionStart),c=u(t.selectionEnd),null!=r&&(n-=1,r=u(r)),t.value=o.val(),t.setSelectionRange(s,c)):void 0}),i=function(){var e,i,l,u;return null!=r?(l=t.value.length-n,e=Math.min(t.selectionStart,t.selectionEnd),0>l?(i=Math.min(e,r),o.deleteText(i,Math.abs(l))):l>0&&(u=t.value.substring(r,r+l),o.insertText(r,u)),r=null,n=null):void 0},t.onkeydown=function(){var e;return null!=r&&i(),e=Math.abs(t.selectionEnd-t.selectionStart),r=Math.min(t.selectionStart,t.selectionEnd),o.deleteText(r,e),n=t.value.length-e},t.onkeyup=function(){return i()}},o.prototype._encode=function(){var t;return t={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(t.prev=this.prev_cl.getUid()),null!=this.next_cl&&(t.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(t.origin=this.origin.getUid()),t},o}(s.ListManager),l.Word=function(t){var e,n,r,i,l,u;return u=t.uid,e=t.beginning,n=t.end,l=t.prev,r=t.next,i=t.origin,new o(u,e,n,l,r,i)},s.TextInsert=i,s.TextDelete=r,s.Word=o,u}}).call(this);
|
||||
//# sourceMappingURL=../Types/TextTypes.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -10,5 +10,10 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1> Yatta PeerJs Demo </h1>
|
||||
<p> Open this link in other browsers: <a id="peer_link" target="_blank">Drop me </a> </p>
|
||||
|
||||
<textarea style="width:80%;" rows=40 id="textfield"></textarea>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -13,6 +13,8 @@ A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file
|
||||
|
||||
|
||||
```js
|
||||
var yatta;
|
||||
|
||||
function init(){
|
||||
Y.createPeerJsConnector(function(Connector, user_id){
|
||||
```
|
||||
@ -23,9 +25,29 @@ it will be instantly shared with all the other collaborators.
|
||||
|
||||
|
||||
```js
|
||||
Y.yatta = new JsonYatta(user_id, Connector);
|
||||
yatta = new Y.JsonYatta(user_id, Connector);
|
||||
|
||||
var url = window.location.href;
|
||||
var peer_id = location.search
|
||||
var url = url.substring(0,-peer_id.length);
|
||||
peer_id = peer_id.substring(1);
|
||||
document.getElementById("peer_link").setAttribute("href",url+"?"+user_id);
|
||||
|
||||
var textbox = document.getElementById("textfield");
|
||||
if (peer_id.length > 0) {
|
||||
yatta.connector.connectToPeer(peer_id);
|
||||
function f() {
|
||||
if (yatta.val('x') == null) {
|
||||
setTimeout(f, 500);
|
||||
} else {
|
||||
yatta.val('x').bind(textbox);
|
||||
}
|
||||
}
|
||||
f();
|
||||
} else {
|
||||
yatta.val('x', "");
|
||||
yatta.val('x').bind(textbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
window.onload = init
|
||||
|
@ -13,15 +13,37 @@
|
||||
```
|
||||
A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js)
|
||||
*/
|
||||
var yatta;
|
||||
|
||||
function init(){
|
||||
Y.createPeerJsConnector(function(Connector, user_id){
|
||||
/**
|
||||
yatta is the shared json object. If you change something on this object,
|
||||
it will be instantly shared with all the other collaborators.
|
||||
*/
|
||||
Y.yatta = new JsonYatta(user_id, Connector);
|
||||
yatta = new Y.JsonYatta(user_id, Connector);
|
||||
|
||||
var url = window.location.href;
|
||||
var peer_id = location.search
|
||||
var url = url.substring(0,-peer_id.length);
|
||||
peer_id = peer_id.substring(1);
|
||||
document.getElementById("peer_link").setAttribute("href",url+"?"+user_id);
|
||||
|
||||
var textbox = document.getElementById("textfield");
|
||||
if (peer_id.length > 0) {
|
||||
yatta.connector.connectToPeer(peer_id);
|
||||
function f() {
|
||||
if (yatta.val('x') == null) {
|
||||
setTimeout(f, 500);
|
||||
} else {
|
||||
yatta.val('x').bind(textbox);
|
||||
}
|
||||
}
|
||||
f();
|
||||
} else {
|
||||
yatta.val('x', "");
|
||||
yatta.val('x').bind(textbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
window.onload = init
|
||||
|
@ -16,13 +16,13 @@ run = require 'gulp-run'
|
||||
ljs = require 'gulp-ljs'
|
||||
|
||||
|
||||
gulp.task 'default', ['build', 'test', 'literate']
|
||||
gulp.task 'build', ['lint', 'lib', 'browser']
|
||||
gulp.task 'default', ['build', 'test', 'literate', 'lib']
|
||||
gulp.task 'build', ['lint', 'browser']
|
||||
|
||||
files =
|
||||
lib : ['./lib/**/*.coffee']
|
||||
build : ['./build/**']
|
||||
browser : ['./lib/**/*.coffee']
|
||||
browser : ['./lib/**/*.coffee', './lib/Connectors/**/*', './lib/Frameworks/**/*', './lib/index.coffee']
|
||||
test : ['./test/**/*.coffee']
|
||||
gulp : ['./gulpfile.coffee']
|
||||
examples : ['./examples/**/*.js']
|
||||
@ -46,7 +46,7 @@ gulp.task 'browser', ->
|
||||
.pipe browserify
|
||||
transform: ['coffeeify']
|
||||
extensions: ['.coffee']
|
||||
debug : false
|
||||
debug : true
|
||||
.pipe rename
|
||||
extname: ".js"
|
||||
.pipe gulp.dest './build/browser'
|
||||
@ -92,8 +92,8 @@ gulp.task 'literate', ->
|
||||
.pipe gulp.dest 'examples/'
|
||||
.pipe gulpif '!**/', git.add({args : "-A"})
|
||||
|
||||
gulp.task 'upload', ()->
|
||||
run('scp -r ./build ./examples jahns@manet.informatik.rwth-aachen.de:/home/jahns/public_html/role-widgets/collaborative_preview/').exec()
|
||||
gulp.task 'upload', [], ()->
|
||||
run('scp -r ./build ./examples jahns@manet.informatik.rwth-aachen.de:/home/jahns/public_html/collaborative_preview/').exec()
|
||||
|
||||
gulp.task 'clean', ->
|
||||
gulp.src './build/{browser,test,node}/*.{js,map}', { read: false }
|
||||
|
@ -112,6 +112,8 @@ createIwcConnector = (callback, initial_user_id)->
|
||||
setTimeout init, 5000
|
||||
|
||||
undefined
|
||||
|
||||
|
||||
module.exports = createIwcConnector
|
||||
if window?
|
||||
if not window.Y?
|
||||
|
@ -20,37 +20,47 @@ createPeerJsConnector = (callback)->
|
||||
constructor: (@engine, @HB, @execution_listener, @yatta)->
|
||||
|
||||
@peer = peer
|
||||
@connections = []
|
||||
@connections = {}
|
||||
|
||||
@peer.on 'connection', (conn)=>
|
||||
conn.send "hey"
|
||||
conn.send "hey" # is never send. But without it it won't work either..
|
||||
@addConnection conn
|
||||
|
||||
|
||||
|
||||
|
||||
send_ = (o)=>
|
||||
@send o
|
||||
@execution_listener.push send_
|
||||
|
||||
connectToPeer: (id)->
|
||||
@addConnection peer.connect id
|
||||
if not @connections[id]? and id isnt @yatta.getUserId()
|
||||
@addConnection peer.connect id
|
||||
|
||||
getAllConnectionIds: ()->
|
||||
for conn_id of @connections
|
||||
conn_id
|
||||
|
||||
addConnection: (conn)->
|
||||
@connections.push conn
|
||||
@connections[conn.peer] = conn
|
||||
|
||||
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.
|
||||
else if data.HB?
|
||||
@engine.applyOpsCheckDouble data.HB
|
||||
else if data.op?
|
||||
@engine.applyOp data.op
|
||||
else if data.conns?
|
||||
console.log "conns received"
|
||||
for conn_id in data.conns
|
||||
@connectToPeer conn_id
|
||||
else
|
||||
throw new Error "Can't parse this operation"
|
||||
|
||||
sendHB = ()=>
|
||||
conn.send
|
||||
HB: @yatta.getHistoryBuffer()._encode()
|
||||
conn.send
|
||||
conns: @getAllConnectionIds()
|
||||
|
||||
setTimeout sendHB, 1000
|
||||
|
||||
#
|
||||
@ -59,7 +69,7 @@ createPeerJsConnector = (callback)->
|
||||
#
|
||||
send: (o)->
|
||||
if o.uid.creator is @HB.getUserId() and (typeof o.uid.op_number isnt "string")
|
||||
for conn in @connections
|
||||
for conn_id,conn of @connections
|
||||
conn.send
|
||||
op: o
|
||||
|
||||
|
@ -42,7 +42,7 @@ module.exports = (HB)->
|
||||
# TODO: Do something with timeouts. You don't want this to fire for every operation (e.g. insert).
|
||||
#
|
||||
callEvent: (event, args)->
|
||||
if @event_listeners[event]?
|
||||
if @event_listeners?[event]?
|
||||
for f in @event_listeners[event]
|
||||
f.call @, event, args
|
||||
|
||||
@ -52,6 +52,12 @@ module.exports = (HB)->
|
||||
setParent: (o)->
|
||||
@parent = o
|
||||
|
||||
#
|
||||
# Get the parent of this operation.
|
||||
#
|
||||
getParent: ()->
|
||||
@parent
|
||||
|
||||
#
|
||||
# Computes a unique identifier (uid) that identifies this operation.
|
||||
#
|
||||
@ -158,7 +164,6 @@ module.exports = (HB)->
|
||||
if @validateSavedOperations()
|
||||
@deletes.applyDelete @
|
||||
super
|
||||
@
|
||||
else
|
||||
false
|
||||
|
||||
@ -205,6 +210,9 @@ module.exports = (HB)->
|
||||
applyDelete: (o)->
|
||||
@deleted_by ?= []
|
||||
@deleted_by.push o
|
||||
if @parent? and @deleted_by.length is 1
|
||||
# call iff wasn't deleted earlyer
|
||||
@parent.callEvent "delete", @
|
||||
|
||||
#
|
||||
# If isDeleted() is true this operation won't be maintained in the sl
|
||||
@ -307,9 +315,24 @@ module.exports = (HB)->
|
||||
@next_cl = @prev_cl.next_cl
|
||||
@prev_cl.next_cl = @
|
||||
@next_cl.prev_cl = @
|
||||
parent = @prev_cl?.getParent()
|
||||
if parent?
|
||||
@setParent parent
|
||||
@parent.callEvent "insert", @
|
||||
super # notify the execution_listeners
|
||||
|
||||
|
||||
#
|
||||
# Compute the position of this operation.
|
||||
#
|
||||
getPosition: ()->
|
||||
position = 0
|
||||
prev = @prev_cl
|
||||
while true
|
||||
if prev instanceof Delimiter
|
||||
break
|
||||
position++
|
||||
prev = prev.prev_cl
|
||||
position
|
||||
#
|
||||
# Defines an object that is cannot be changed. You can use this to set an immutable string, or a number.
|
||||
#
|
||||
|
@ -122,6 +122,13 @@ module.exports = (HB)->
|
||||
@end.execute()
|
||||
super uid, prev, next, origin
|
||||
|
||||
execute: ()->
|
||||
if @validateSavedOperations()
|
||||
@beginning.setParent @
|
||||
@end.setParent @
|
||||
super
|
||||
else
|
||||
false
|
||||
|
||||
# Get the element previous to the delemiter at the end
|
||||
getLastOperation: ()->
|
||||
@ -154,7 +161,9 @@ module.exports = (HB)->
|
||||
if position is 0
|
||||
break
|
||||
if o instanceof types.Delimiter
|
||||
throw new Error "position parameter exceeded the length of the document!"
|
||||
console.log "position parameter exceeded the length of the document!"
|
||||
o = null
|
||||
break
|
||||
o
|
||||
|
||||
#
|
||||
|
@ -97,14 +97,18 @@ module.exports = (HB)->
|
||||
deleteText: (position, length)->
|
||||
o = @getOperationByPosition position
|
||||
|
||||
delete_ops = []
|
||||
for i in [0...length]
|
||||
d = HB.addOperation(new TextDelete undefined, o).execute()
|
||||
o = o.next_cl
|
||||
while o.isDeleted()
|
||||
while o.isDeleted() and not (o instanceof types.Delimiter)
|
||||
if o instanceof types.Delimiter
|
||||
throw new Error "You can't delete more than there is.."
|
||||
o = o.next_cl
|
||||
d._encode()
|
||||
delete_ops.push d._encode()
|
||||
if o instanceof types.Delimiter
|
||||
break
|
||||
|
||||
|
||||
#
|
||||
# Replace the content of this word with another one. Concurrent replacements are not merged!
|
||||
@ -141,6 +145,82 @@ module.exports = (HB)->
|
||||
@validateSavedOperations
|
||||
|
||||
#
|
||||
# Bind this Word to a textfield.
|
||||
# TODO:
|
||||
# insert_pressing+mouse new position
|
||||
# concurrent pressing (two user pressing stuff)
|
||||
bind: (textfield)->
|
||||
word = @
|
||||
textfield.value = @val()
|
||||
position_start = null
|
||||
document_length = null
|
||||
|
||||
@on "insert", (event, op)->
|
||||
if op.creator isnt HB.getUserId()
|
||||
o_pos = op.getPosition()
|
||||
fix = (cursor)->
|
||||
if cursor <= o_pos
|
||||
cursor
|
||||
else
|
||||
cursor += 1
|
||||
cursor
|
||||
left = fix textfield.selectionStart
|
||||
right = fix textfield.selectionEnd
|
||||
if position_start?
|
||||
document_length += 1
|
||||
position_start = fix position_start
|
||||
|
||||
textfield.value = word.val()
|
||||
textfield.setSelectionRange left, right
|
||||
|
||||
|
||||
@on "delete", (event, op)->
|
||||
if op.creator isnt HB.getUserId()
|
||||
o_pos = op.getPosition()
|
||||
fix = (cursor)->
|
||||
if cursor <= o_pos
|
||||
cursor
|
||||
else
|
||||
cursor -= 1
|
||||
cursor
|
||||
left = fix textfield.selectionStart
|
||||
right = fix textfield.selectionEnd
|
||||
if position_start?
|
||||
document_length -= 1
|
||||
position_start = fix position_start
|
||||
|
||||
textfield.value = word.val()
|
||||
textfield.setSelectionRange left, right
|
||||
|
||||
|
||||
update_yatta = ()->
|
||||
if position_start?
|
||||
document_length_diff = textfield.value.length - document_length
|
||||
current_position = Math.min textfield.selectionStart, textfield.selectionEnd
|
||||
if document_length_diff < 0 # deletion
|
||||
deletion_position = Math.min current_position, position_start
|
||||
word.deleteText deletion_position, Math.abs document_length_diff
|
||||
else if document_length_diff > 0 # insertion
|
||||
text_insert = textfield.value.substring position_start, (position_start + document_length_diff)
|
||||
word.insertText position_start, text_insert
|
||||
|
||||
position_start = null
|
||||
document_length = null
|
||||
|
||||
textfield.onkeydown = (event)->
|
||||
#console.log "down"
|
||||
if position_start?
|
||||
update_yatta()
|
||||
|
||||
selection_range = Math.abs(textfield.selectionEnd - textfield.selectionStart)
|
||||
position_start = Math.min(textfield.selectionStart, textfield.selectionEnd)
|
||||
word.deleteText position_start, selection_range
|
||||
document_length = textfield.value.length - selection_range
|
||||
|
||||
textfield.onkeyup = (event)->
|
||||
#console.log "up"
|
||||
update_yatta()
|
||||
#
|
||||
# Encode this operation in such a way that it can be parsed by remote peers.
|
||||
#
|
||||
_encode: ()->
|
||||
|
Loading…
x
Reference in New Issue
Block a user