diff --git a/build/browser/Connectors/IwcConnector.js b/build/browser/Connectors/IwcConnector.js index de98d202..95aa51f5 100644 --- a/build/browser/Connectors/IwcConnector.js +++ b/build/browser/Connectors/IwcConnector.js @@ -2,7 +2,7 @@ var createIwcConnector; createIwcConnector = function(callback, initial_user_id) { - var IwcConnector, duiClient, get_HB_intent, init, iwcHandler, received_HB, send_get_HB_intent; + var IwcConnector, duiClient, init, iwcHandler, received_HB; iwcHandler = {}; duiClient = new DUIClient(); duiClient.connect(function(intent) { @@ -26,22 +26,31 @@ createIwcConnector = function(callback, initial_user_id) { this.iwcHandler = iwcHandler; send_ = (function(_this) { return function(o) { - return _this.send(o); + if (Object.getOwnPropertyNames(_this.initialized).length !== 0) { + return _this.send(o); + } }; })(this); this.execution_listener.push(send_); + this.initialized = {}; receiveHB = (function(_this) { return function(json) { - HB = json != null ? json.extras.HB : void 0; - return _this.engine.applyOpsCheckDouble(HB); + var him; + HB = json.extras.HB; + him = json.extras.user; + _this.engine.applyOpsCheckDouble(HB); + return _this.initialized[him] = true; }; })(this); iwcHandler["Yatta_push_HB_element"] = [receiveHB]; + this.sendIwcIntent("Yatta_get_HB_element", {}); receive_ = (function(_this) { return function(intent) { var o; o = intent.extras; - return _this.receive(o); + if (_this.initialized[o.uid.creator] != null) { + return _this.receive(o); + } }; })(this); this.iwcHandler["Yatta_new_operation"] = [receive_]; @@ -52,7 +61,8 @@ createIwcConnector = function(callback, initial_user_id) { return function() { var json; json = { - HB: _this.yatta.getHistoryBuffer()._encode() + HB: _this.yatta.getHistoryBuffer()._encode(), + user: _this.yatta.getUserId() }; return _this.sendIwcIntent("Yatta_push_HB_element", json); }; @@ -88,20 +98,8 @@ createIwcConnector = function(callback, initial_user_id) { return IwcConnector; })(); - get_HB_intent = { - action: "Yatta_get_HB_element", - component: "", - data: "", - dataType: "", - flags: ["PUBLISH_GLOBAL"], - extras: {} - }; - send_get_HB_intent = function() { - return duiClient.sendIntent(get_HB_intent); - }; init = function() { var proposed_user_id; - setTimeout(send_get_HB_intent, 1000); proposed_user_id = null; if (initial_user_id != null) { proposed_user_id = initial_user_id; @@ -110,7 +108,7 @@ createIwcConnector = function(callback, initial_user_id) { } return callback(IwcConnector, proposed_user_id); }; - setTimeout(init, 1000.); + setTimeout(init, 5000); return void 0; }; diff --git a/build/browser/Connectors/IwcConnector.min.js b/build/browser/Connectors/IwcConnector.min.js index 5b8cabd3..ab024b46 100644 --- a/build/browser/Connectors/IwcConnector.min.js +++ b/build/browser/Connectors/IwcConnector.min.js @@ -1 +1 @@ -!function t(n,e,r){function i(u,a){if(!e[u]){if(!n[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(o)return o(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=e[u]={exports:{}};n[u][0].call(s.exports,function(t){var e=n[u][1][t];return i(e?e:t)},s,s.exports,t,n,e,r)}return e[u].exports}for(var o="function"==typeof require&&require,u=0;ur;r++)n=t[r],o.push(n.getUserId()!==this.HB.getUserId()?n.getConnector().receive(e):void 0);return o}},e.prototype.receive=function(t){var e,n;return null==(e=this.unexecuted)[n=t.uid.creator]&&(e[n]=[]),this.unexecuted[t.uid.creator].push(t)},e.prototype.flushOne=function(t){var e;return(null!=(e=this.unexecuted[t])?e.length:void 0)>0?this.engine.applyOp(this.unexecuted[t].shift()):void 0},e.prototype.flushOneRandom=function(){return this.flushOne(n.random(0,t.length-1))},e.prototype.flushAll=function(){var t,e,n;n=this.unexecuted;for(t in n)e=n[t],this.engine.applyOps(e);return this.unexecuted={}},e}()}},{underscore:12}],3:[function(t,e){var n;n=function(){function t(t,e){this.HB=t,this.parser=e,this.unprocessed_ops=[]}return t.prototype.parseOperation=function(t){var e;if(e=this.parser[t.type],null!=e)return e(t);throw new Error("You forgot to specify a parser for type "+t.type+". The message is "+JSON.stringify(t)+".")},t.prototype.applyOpsBundle=function(t){var e,n,r,i,o,u,a,s;for(n=[],r=0,u=t.length;u>r;r++)e=t[r],n.push(this.parseOperation(e));for(i=0,a=n.length;a>i;i++)e=n[i],this.HB.addOperation(e);for(o=0,s=n.length;s>o;o++)e=n[o],e.execute()||this.unprocessed_ops.push(e);return this.tryUnprocessed()},t.prototype.applyOpsCheckDouble=function(t){var e,n,r,i;for(i=[],n=0,r=t.length;r>n;n++)e=t[n],i.push(null==this.HB.getOperation(e.uid)?this.applyOp(e):void 0);return i},t.prototype.applyOps=function(t){var e,n,r,i;for(i=[],n=0,r=t.length;r>n;n++)e=t[n],i.push(this.applyOp(e));return i},t.prototype.applyOp=function(t){var e;return e=this.parseOperation(t),this.HB.addToCounter(e),e.execute()?this.HB.addOperation(e):this.unprocessed_ops.push(e),this.tryUnprocessed()},t.prototype.tryUnprocessed=function(){var t,e,n,r,i,o,u;for(u=[];;){for(t=this.unprocessed_ops.length,n=[],o=this.unprocessed_ops,r=0,i=o.length;i>r;r++)e=o[r],e.execute()?this.HB.addOperation(e):n.push(e);if(this.unprocessed_ops=n,this.unprocessed_ops.length===t)break;u.push(void 0)}return u},t}(),e.exports=n},{}],4:[function(t,e){var n,r,i,o;o=t("../Types/JsonTypes"),r=t("../HistoryBuffer"),n=t("../Engine"),i=function(){function t(t,e){var i,u;this.HB=new r(t),u=o(this.HB),this.engine=new n(this.HB,u.parser),this.connector=new e(this.engine,this.HB,u.execution_listener,this),i=new u.types.JsonType(this.HB.getReservedUniqueIdentifier()),this.HB.addOperation(i).execute(),this.root_element=i}return t.prototype.getRootElement=function(){return this.root_element},t.prototype.getEngine=function(){return this.engine},t.prototype.getConnector=function(){return this.connector},t.prototype.getHistoryBuffer=function(){return this.HB},t.prototype.setMutableDefault=function(t){return this.root_element.setMutableDefault(t)},t.prototype.getUserId=function(){return this.HB.getUserId()},t.prototype.val=function(t,e,n){return this.root_element.val(t,e,n)},Object.defineProperty(t.prototype,"value",{get:function(){return this.root_element.value},set:function(t){var e,n,r;if(t.constructor==={}.constructor){r=[];for(e in t)n=t[e],r.push(this.val(e,n,"immutable"));return r}throw new Error("You must only set Object values!")}}),t}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=i),e.exports=i},{"../Engine":3,"../HistoryBuffer":6,"../Types/JsonTypes":8}],5:[function(t,e){var n,r,i,o;o=t("../Types/TextTypes"),r=t("../HistoryBuffer"),n=t("../Engine"),i=function(){function t(t,e){var i,u;this.HB=new r(t),u=o(this.HB),this.engine=new n(this.HB,u.parser),this.connector=new e(this.engine,this.HB,u.execution_listener),i=new u.types.Word(void 0),this.HB.addOperation(i).execute(),this.root_element=i}return t.prototype.getRootElement=function(){return this.root_element},t.prototype.getEngine=function(){return this.engine},t.prototype.getConnector=function(){return this.connector},t.prototype.getHistoryBuffer=function(){return this.HB},t.prototype.getUserId=function(){return this.HB.getUserId()},t.prototype.val=function(){return this.root_element.val()},t.prototype.insertText=function(t,e){return this.root_element.insertText(t,e)},t.prototype.deleteText=function(t,e){return this.root_element.deleteText(t,e)},t.prototype.replaceText=function(t){return this.root_element.replaceText(t)},t}(),e.exports=i},{"../Engine":3,"../HistoryBuffer":6,"../Types/TextTypes":10}],6:[function(t,e){var n;n=function(){function t(t){this.user_id=t,this.operation_counter={},this.buffer={},this.change_listeners=[]}return t.prototype.getUserId=function(){return this.user_id},t.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},t.prototype.getOperationCounter=function(){var t,e,n,r;e={},r=this.operation_counter;for(n in r)t=r[n],e[n]=t;return e},t.prototype._encode=function(t){var e,n,r,i,o,u,a,s,c,l;null==t&&(t={}),e=[],s=function(e,n){if(null==e||null==n)throw new Error("dah!");return null==t[e]||t[e]<=n},l=this.buffer;for(a in l){c=l[a];for(o in c)if(n=c[o],!isNaN(parseInt(o))&&s(a,o)){if(r=n._encode(),null!=n.next_cl){for(i=n.next_cl;null!=i.next_cl&&s(i.creator,i.op_number);)i=i.next_cl;r.next=i.getUid()}else if(null!=n.prev_cl){for(u=n.prev_cl;null!=u.prev_cl&&s(i.creator,i.op_number);)u=u.prev_cl;r.prev=u.getUid()}e.push(r)}}return e},t.prototype.getNextOperationIdentifier=function(t){var e;return null==t&&(t=this.user_id),null==this.operation_counter[t]&&(this.operation_counter[t]=0),e={creator:t,op_number:this.operation_counter[t]},this.operation_counter[t]++,e},t.prototype.getOperation=function(t){var e;if(t instanceof Object)return null!=(e=this.buffer[t.creator])?e[t.op_number]:void 0;if(null!=t)throw new Error("This type of uid is not defined!")},t.prototype.addOperation=function(t){if(null==this.buffer[t.creator]&&(this.buffer[t.creator]={}),null!=this.buffer[t.creator][t.op_number])throw new Error("You must not overwrite operations!");return this.buffer[t.creator][t.op_number]=t,t},t.prototype.addToCounter=function(t){return null==this.operation_counter[t.creator]&&(this.operation_counter[t.creator]=0),"number"==typeof t.op_number&&t.creator!==this.getUserId()?this.operation_counter[t.creator]++:void 0},t}(),e.exports=n},{}],7:[function(t,e){var n={}.hasOwnProperty,r=function(t,e){function r(){this.constructor=t}for(var i in e)n.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};e.exports=function(t){var e,n,i,o,u,a,s;return s={},a=[],u=function(){function e(e){null==e&&(e=t.getNextOperationIdentifier()),this.creator=e.creator,this.op_number=e.op_number}return e.prototype.on=function(t,e){var n;return null==this.event_listeners&&(this.event_listeners={}),null==(n=this.event_listeners)[t]&&(n[t]=[]),this.event_listeners[t].push(e)},e.prototype.callEvent=function(t,e){var n,r,i,o,u;if(null!=this.event_listeners[t]){for(o=this.event_listeners[t],u=[],r=0,i=o.length;i>r;r++)n=o[r],u.push(n.call(this,t,e));return u}},e.prototype.setParent=function(t){return this.parent=t},e.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},e.prototype.execute=function(){var t,e,n;for(this.is_executed=!0,e=0,n=a.length;n>e;e++)(t=a[e])(this._encode());return this},e.prototype.saveOperation=function(t,e){return null!=(null!=e?e.execute:void 0)?this[t]=e:null!=e?(null==this.unchecked&&(this.unchecked={}),this.unchecked[t]=e):void 0},e.prototype.validateSavedOperations=function(){var e,n,r,i,o,u;o={},i=this,u=this.unchecked;for(e in u)r=u[e],n=t.getOperation(r),n?this[e]=n:(o[e]=r,i=!1);return delete this.unchecked,i||(this.unchecked=o),i},e}(),e=function(t){function e(t,n){this.saveOperation("deletes",n),e.__super__.constructor.call(this,t)}return r(e,t),e.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},e.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),e.__super__.execute.apply(this,arguments),this):!1},e}(u),s.Delete=function(t){var n,r;return r=t.uid,n=t.deletes,new e(r,n)},o=function(t){function e(t,n,r,i){this.saveOperation("prev_cl",n),this.saveOperation("next_cl",r),null!=i?this.saveOperation("origin",i):this.saveOperation("origin",n),e.__super__.constructor.call(this,t)}return r(e,t),e.prototype.applyDelete=function(t){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(t)},e.prototype.isDeleted=function(){var t;return(null!=(t=this.deleted_by)?t.length:void 0)>0},e.prototype.getDistanceToOrigin=function(){var t,e;for(t=0,e=this.prev_cl;;){if(this.origin===e)break;if(t++,this===this.prev_cl)throw new Error("this should not happen ;) ");e=e.prev_cl}return t},e.prototype.update_sl=function(){var t;return t=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},e.prototype.execute=function(){var t,n,r,i,o;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(i=this.prev_cl)?i.validateSavedOperations():void 0)&&(null!=(o=this.next_cl)?o.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(t=0,r=this.prev_cl.next_cl,n=0;;){if(null==r&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),r===this.next_cl)break;if(r.getDistanceToOrigin()===n)r.creator0)for(;;){if(e=e.next_cl,e.isDeleted()||(t-=1),0===t)break;if(e instanceof l.Delimiter)throw new Error("position parameter exceeded the length of the document!")}return e},n}(l.Insert),u=function(e){function n(t,e,r,i,o,u,a){n.__super__.constructor.call(this,e,r,i,o,u,a),null!=t&&this.replace(t)}return i(n,e),n.prototype.replace=function(e){var n,r;return n=this.getLastOperation(),r=new a(e,this,void 0,n,n.next_cl),t.addOperation(r).execute()},n.prototype.val=function(){var t;if(t=this.getLastOperation(),t instanceof l.Delimiter)throw new Error("dtrn");return t.val()},n.prototype._encode=function(){var t;return t={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(t.prev=this.prev_cl.getUid(),t.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(t.origin=this.origin.getUid()),t},n}(r),c.ReplaceManager=function(t){var e,n,r,i,o,a,s;return n=t.content,s=t.uid,a=t.prev,i=t.next,o=t.origin,e=t.beginning,r=t.end,new u(n,s,e,r,a,i,o)},a=function(t){function e(t,n,r,i,o,u){if(this.saveOperation("content",t),this.saveOperation("parent",n),null==i||null==o||null==t)throw new Error("You must define content, prev, and next for Replaceable-types!");e.__super__.constructor.call(this,r,i,o,u)}return i(e,t),e.prototype.val=function(){return this.content},e.prototype.replace=function(t){return this.parent.replace(t)},e.prototype.execute=function(){var t;return this.validateSavedOperations()?("function"==typeof(t=this.content).setReplaceManager&&t.setReplaceManager(this.parent),e.__super__.execute.apply(this,arguments)):!1},e.prototype._encode=function(){var t;return t={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&&(t.origin=this.origin.getUid()),t},e}(l.Insert),c.Replaceable=function(t){var e,n,r,i,o,u;return e=t.content,i=t.ReplaceManager,u=t.uid,o=t.prev,n=t.next,r=t.origin,new a(e,i,u,o,n,r)},l.ListManager=r,l.MapManager=o,l.ReplaceManager=u,l.Replaceable=a,s}},{"./BasicTypes":7}],10:[function(t,e){var n,r={}.hasOwnProperty,i=function(t,e){function n(){this.constructor=t}for(var i in e)r.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};n=t("./StructuredTypes"),e.exports=function(t){var e,r,o,u,a,s;return a=n(t),s=a.types,u=a.parser,e=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return i(e,t),e}(s.Delete),u.TextDelete=u.Delete,r=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 i(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),u.TextInsert=function(t){var e,n,i,o,u;return e=t.content,u=t.uid,o=t.prev,n=t.next,i=t.origin,new r(e,u,o,n,i)},o=function(n){function o(t,e,n,r,i,u){o.__super__.constructor.call(this,t,e,n,r,i,u)}return i(o,n),o.prototype.insertText=function(e,n){var i,o,u,a,s,c;for(o=this.getOperationByPosition(e),c=[],a=0,s=n.length;s>a;a++)i=n[a],u=new r(i,void 0,o.prev_cl,o),c.push(t.addOperation(u).execute());return c},o.prototype.deleteText=function(n,r){var i,o,u,a,c;for(u=this.getOperationByPosition(n),c=[],o=a=0;r>=0?r>a:a>r;o=r>=0?++a:--a){for(i=t.addOperation(new e(void 0,u)).execute(),u=u.next_cl;u.isDeleted();){if(u instanceof s.Delimiter)throw new Error("You can't delete more than there is..");u=u.next_cl}c.push(i._encode())}return c},o.prototype.replaceText=function(e){var n;if(null!=this.replace_manager)return n=t.addOperation(new o(void 0)).execute(),n.insertText(0,e),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}(s.ListManager),u.Word=function(t){var e,n,r,i,u,a;return a=t.uid,e=t.beginning,n=t.end,u=t.prev,r=t.next,i=t.origin,new o(a,e,n,u,r,i)},s.TextInsert=r,s.TextDelete=e,s.Word=o,a}},{"./StructuredTypes":9}],11:[function(t,e,n){n.IwcConnector=t("./Connectors/IwcConnector"),n.TestConnector=t("./Connectors/TestConnector"),n.JsonYatta=t("./Frameworks/JsonYatta"),n.TextYatta=t("./Frameworks/TextYatta")},{"./Connectors/IwcConnector":1,"./Connectors/TestConnector":2,"./Frameworks/JsonYatta":4,"./Frameworks/TextYatta":5}],12:[function(t,e,n){(function(){var t=this,r=t._,i={},o=Array.prototype,u=Object.prototype,a=Function.prototype,s=o.push,c=o.slice,l=o.concat,p=u.toString,f=u.hasOwnProperty,h=o.forEach,d=o.map,v=o.reduce,_=o.reduceRight,g=o.filter,y=o.every,m=o.some,x=o.indexOf,b=o.lastIndexOf,w=Array.isArray,O=Object.keys,T=a.bind,U=function(t){return t instanceof U?t:this instanceof U?void(this._wrapped=t):new U(t)};"undefined"!=typeof n?("undefined"!=typeof e&&e.exports&&(n=e.exports=U),n._=U):t._=U,U.VERSION="1.6.0";var B=U.each=U.forEach=function(t,e,n){if(null==t)return t;if(h&&t.forEach===h)t.forEach(e,n);else if(t.length===+t.length){for(var r=0,o=t.length;o>r;r++)if(e.call(n,t[r],r,t)===i)return}else for(var u=U.keys(t),r=0,o=u.length;o>r;r++)if(e.call(n,t[u[r]],u[r],t)===i)return;return t};U.map=U.collect=function(t,e,n){var r=[];return null==t?r:d&&t.map===d?t.map(e,n):(B(t,function(t,i,o){r.push(e.call(n,t,i,o))}),r)};var I="Reduce of empty array with no initial value";U.reduce=U.foldl=U.inject=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),v&&t.reduce===v)return r&&(e=U.bind(e,r)),i?t.reduce(e,n):t.reduce(e);if(B(t,function(t,o,u){i?n=e.call(r,n,t,o,u):(n=t,i=!0)}),!i)throw new TypeError(I);return n},U.reduceRight=U.foldr=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),_&&t.reduceRight===_)return r&&(e=U.bind(e,r)),i?t.reduceRight(e,n):t.reduceRight(e);var o=t.length;if(o!==+o){var u=U.keys(t);o=u.length}if(B(t,function(a,s,c){s=u?u[--o]:--o,i?n=e.call(r,n,t[s],s,c):(n=t[s],i=!0)}),!i)throw new TypeError(I);return n},U.find=U.detect=function(t,e,n){var r;return j(t,function(t,i,o){return e.call(n,t,i,o)?(r=t,!0):void 0}),r},U.filter=U.select=function(t,e,n){var r=[];return null==t?r:g&&t.filter===g?t.filter(e,n):(B(t,function(t,i,o){e.call(n,t,i,o)&&r.push(t)}),r)},U.reject=function(t,e,n){return U.filter(t,function(t,r,i){return!e.call(n,t,r,i)},n)},U.every=U.all=function(t,e,n){e||(e=U.identity);var r=!0;return null==t?r:y&&t.every===y?t.every(e,n):(B(t,function(t,o,u){return(r=r&&e.call(n,t,o,u))?void 0:i}),!!r)};var j=U.some=U.any=function(t,e,n){e||(e=U.identity);var r=!1;return null==t?r:m&&t.some===m?t.some(e,n):(B(t,function(t,o,u){return r||(r=e.call(n,t,o,u))?i:void 0}),!!r)};U.contains=U.include=function(t,e){return null==t?!1:x&&t.indexOf===x?-1!=t.indexOf(e):j(t,function(t){return t===e})},U.invoke=function(t,e){var n=c.call(arguments,2),r=U.isFunction(e);return U.map(t,function(t){return(r?e:t[e]).apply(t,n)})},U.pluck=function(t,e){return U.map(t,U.property(e))},U.where=function(t,e){return U.filter(t,U.matches(e))},U.findWhere=function(t,e){return U.find(t,U.matches(e))},U.max=function(t,e,n){if(!e&&U.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.max.apply(Math,t);var r=-1/0,i=-1/0;return B(t,function(t,o,u){var a=e?e.call(n,t,o,u):t;a>i&&(r=t,i=a)}),r},U.min=function(t,e,n){if(!e&&U.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.min.apply(Math,t);var r=1/0,i=1/0;return B(t,function(t,o,u){var a=e?e.call(n,t,o,u):t;i>a&&(r=t,i=a)}),r},U.shuffle=function(t){var e,n=0,r=[];return B(t,function(t){e=U.random(n++),r[n-1]=r[e],r[e]=t}),r},U.sample=function(t,e,n){return null==e||n?(t.length!==+t.length&&(t=U.values(t)),t[U.random(t.length-1)]):U.shuffle(t).slice(0,Math.max(0,e))};var E=function(t){return null==t?U.identity:U.isFunction(t)?t:U.property(t)};U.sortBy=function(t,e,n){return e=E(e),U.pluck(U.map(t,function(t,r,i){return{value:t,index:r,criteria:e.call(n,t,r,i)}}).sort(function(t,e){var n=t.criteria,r=e.criteria;if(n!==r){if(n>r||void 0===n)return 1;if(r>n||void 0===r)return-1}return t.index-e.index}),"value")};var H=function(t){return function(e,n,r){var i={};return n=E(n),B(e,function(o,u){var a=n.call(r,o,u,e);t(i,a,o)}),i}};U.groupBy=H(function(t,e,n){U.has(t,e)?t[e].push(n):t[e]=[n]}),U.indexBy=H(function(t,e,n){t[e]=n}),U.countBy=H(function(t,e){U.has(t,e)?t[e]++:t[e]=1}),U.sortedIndex=function(t,e,n,r){n=E(n);for(var i=n.call(r,e),o=0,u=t.length;u>o;){var a=o+u>>>1;n.call(r,t[a])e?[]:c.call(t,0,e)},U.initial=function(t,e,n){return c.call(t,0,t.length-(null==e||n?1:e))},U.last=function(t,e,n){return null==t?void 0:null==e||n?t[t.length-1]:c.call(t,Math.max(t.length-e,0))},U.rest=U.tail=U.drop=function(t,e,n){return c.call(t,null==e||n?1:e)},U.compact=function(t){return U.filter(t,U.identity)};var k=function(t,e,n){return e&&U.every(t,U.isArray)?l.apply(n,t):(B(t,function(t){U.isArray(t)||U.isArguments(t)?e?s.apply(n,t):k(t,e,n):n.push(t)}),n)};U.flatten=function(t,e){return k(t,e,[])},U.without=function(t){return U.difference(t,c.call(arguments,1))},U.partition=function(t,e){var n=[],r=[];return B(t,function(t){(e(t)?n:r).push(t)}),[n,r]},U.uniq=U.unique=function(t,e,n,r){U.isFunction(e)&&(r=n,n=e,e=!1);var i=n?U.map(t,n,r):t,o=[],u=[];return B(i,function(n,r){(e?r&&u[u.length-1]===n:U.contains(u,n))||(u.push(n),o.push(t[r]))}),o},U.union=function(){return U.uniq(U.flatten(arguments,!0))},U.intersection=function(t){var e=c.call(arguments,1);return U.filter(U.uniq(t),function(t){return U.every(e,function(e){return U.contains(e,t)})})},U.difference=function(t){var e=l.apply(o,c.call(arguments,1));return U.filter(t,function(t){return!U.contains(e,t)})},U.zip=function(){for(var t=U.max(U.pluck(arguments,"length").concat(0)),e=new Array(t),n=0;t>n;n++)e[n]=U.pluck(arguments,""+n);return e},U.object=function(t,e){if(null==t)return{};for(var n={},r=0,i=t.length;i>r;r++)e?n[t[r]]=e[r]:n[t[r][0]]=t[r][1];return n},U.indexOf=function(t,e,n){if(null==t)return-1;var r=0,i=t.length;if(n){if("number"!=typeof n)return r=U.sortedIndex(t,e),t[r]===e?r:-1;r=0>n?Math.max(0,i+n):n}if(x&&t.indexOf===x)return t.indexOf(e,n);for(;i>r;r++)if(t[r]===e)return r;return-1},U.lastIndexOf=function(t,e,n){if(null==t)return-1;var r=null!=n;if(b&&t.lastIndexOf===b)return r?t.lastIndexOf(e,n):t.lastIndexOf(e);for(var i=r?n:t.length;i--;)if(t[i]===e)return i;return-1},U.range=function(t,e,n){arguments.length<=1&&(e=t||0,t=0),n=arguments[2]||1;for(var r=Math.max(Math.ceil((e-t)/n),0),i=0,o=new Array(r);r>i;)o[i++]=t,t+=n;return o};var D=function(){};U.bind=function(t,e){var n,r;if(T&&t.bind===T)return T.apply(t,c.call(arguments,1));if(!U.isFunction(t))throw new TypeError;return n=c.call(arguments,2),r=function(){if(!(this instanceof r))return t.apply(e,n.concat(c.call(arguments)));D.prototype=t.prototype;var i=new D;D.prototype=null;var o=t.apply(i,n.concat(c.call(arguments)));return Object(o)===o?o:i}},U.partial=function(t){var e=c.call(arguments,1);return function(){for(var n=0,r=e.slice(),i=0,o=r.length;o>i;i++)r[i]===U&&(r[i]=arguments[n++]);for(;n=l?(clearTimeout(u),u=null,a=c,o=t.apply(r,i),r=i=null):u||n.trailing===!1||(u=setTimeout(s,l)),o}},U.debounce=function(t,e,n){var r,i,o,u,a,s=function(){var c=U.now()-u;e>c?r=setTimeout(s,e-c):(r=null,n||(a=t.apply(o,i),o=i=null))};return function(){o=this,i=arguments,u=U.now();var c=n&&!r;return r||(r=setTimeout(s,e)),c&&(a=t.apply(o,i),o=i=null),a}},U.once=function(t){var e,n=!1;return function(){return n?e:(n=!0,e=t.apply(this,arguments),t=null,e)}},U.wrap=function(t,e){return U.partial(e,t)},U.compose=function(){var t=arguments;return function(){for(var e=arguments,n=t.length-1;n>=0;n--)e=[t[n].apply(this,e)];return e[0]}},U.after=function(t,e){return function(){return--t<1?e.apply(this,arguments):void 0}},U.keys=function(t){if(!U.isObject(t))return[];if(O)return O(t);var e=[];for(var n in t)U.has(t,n)&&e.push(n);return e},U.values=function(t){for(var e=U.keys(t),n=e.length,r=new Array(n),i=0;n>i;i++)r[i]=t[e[i]];return r},U.pairs=function(t){for(var e=U.keys(t),n=e.length,r=new Array(n),i=0;n>i;i++)r[i]=[e[i],t[e[i]]];return r},U.invert=function(t){for(var e={},n=U.keys(t),r=0,i=n.length;i>r;r++)e[t[n[r]]]=n[r];return e},U.functions=U.methods=function(t){var e=[];for(var n in t)U.isFunction(t[n])&&e.push(n);return e.sort()},U.extend=function(t){return B(c.call(arguments,1),function(e){if(e)for(var n in e)t[n]=e[n]}),t},U.pick=function(t){var e={},n=l.apply(o,c.call(arguments,1));return B(n,function(n){n in t&&(e[n]=t[n])}),e},U.omit=function(t){var e={},n=l.apply(o,c.call(arguments,1));for(var r in t)U.contains(n,r)||(e[r]=t[r]);return e},U.defaults=function(t){return B(c.call(arguments,1),function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t},U.clone=function(t){return U.isObject(t)?U.isArray(t)?t.slice():U.extend({},t):t},U.tap=function(t,e){return e(t),t};var M=function(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return t===e;t instanceof U&&(t=t._wrapped),e instanceof U&&(e=e._wrapped);var i=p.call(t);if(i!=p.call(e))return!1;switch(i){case"[object String]":return t==String(e);case"[object Number]":return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case"[object Date]":case"[object Boolean]":return+t==+e;case"[object RegExp]":return t.source==e.source&&t.global==e.global&&t.multiline==e.multiline&&t.ignoreCase==e.ignoreCase}if("object"!=typeof t||"object"!=typeof e)return!1;for(var o=n.length;o--;)if(n[o]==t)return r[o]==e;var u=t.constructor,a=e.constructor;if(u!==a&&!(U.isFunction(u)&&u instanceof u&&U.isFunction(a)&&a instanceof a)&&"constructor"in t&&"constructor"in e)return!1;n.push(t),r.push(e);var s=0,c=!0;if("[object Array]"==i){if(s=t.length,c=s==e.length)for(;s--&&(c=M(t[s],e[s],n,r)););}else{for(var l in t)if(U.has(t,l)&&(s++,!(c=U.has(e,l)&&M(t[l],e[l],n,r))))break;if(c){for(l in e)if(U.has(e,l)&&!s--)break;c=!s}}return n.pop(),r.pop(),c};U.isEqual=function(t,e){return M(t,e,[],[])},U.isEmpty=function(t){if(null==t)return!0;if(U.isArray(t)||U.isString(t))return 0===t.length;for(var e in t)if(U.has(t,e))return!1;return!0},U.isElement=function(t){return!(!t||1!==t.nodeType)},U.isArray=w||function(t){return"[object Array]"==p.call(t)},U.isObject=function(t){return t===Object(t)},B(["Arguments","Function","String","Number","Date","RegExp"],function(t){U["is"+t]=function(e){return p.call(e)=="[object "+t+"]"}}),U.isArguments(arguments)||(U.isArguments=function(t){return!(!t||!U.has(t,"callee"))}),"function"!=typeof/./&&(U.isFunction=function(t){return"function"==typeof t}),U.isFinite=function(t){return isFinite(t)&&!isNaN(parseFloat(t))},U.isNaN=function(t){return U.isNumber(t)&&t!=+t},U.isBoolean=function(t){return t===!0||t===!1||"[object Boolean]"==p.call(t)},U.isNull=function(t){return null===t},U.isUndefined=function(t){return void 0===t},U.has=function(t,e){return f.call(t,e)},U.noConflict=function(){return t._=r,this},U.identity=function(t){return t},U.constant=function(t){return function(){return t}},U.property=function(t){return function(e){return e[t]}},U.matches=function(t){return function(e){if(e===t)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0}},U.times=function(t,e,n){for(var r=Array(Math.max(0,t)),i=0;t>i;i++)r[i]=e.call(n,i);return r},U.random=function(t,e){return null==e&&(e=t,t=0),t+Math.floor(Math.random()*(e-t+1))},U.now=Date.now||function(){return(new Date).getTime()};var A={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};A.unescape=U.invert(A.escape);var R={escape:new RegExp("["+U.keys(A.escape).join("")+"]","g"),unescape:new RegExp("("+U.keys(A.unescape).join("|")+")","g")};U.each(["escape","unescape"],function(t){U[t]=function(e){return null==e?"":(""+e).replace(R[t],function(e){return A[t][e]})}}),U.result=function(t,e){if(null==t)return void 0;var n=t[e];return U.isFunction(n)?n.call(t):n},U.mixin=function(t){B(U.functions(t),function(e){var n=U[e]=t[e];U.prototype[e]=function(){var t=[this._wrapped];return s.apply(t,arguments),N.call(this,n.apply(U,t))}})};var S=0;U.uniqueId=function(t){var e=++S+"";return t?t+e:e},U.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var C=/(.)^/,Y={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},F=/\\|'|\r|\n|\t|\u2028|\u2029/g;U.template=function(t,e,n){var r;n=U.defaults({},n,U.templateSettings);var i=new RegExp([(n.escape||C).source,(n.interpolate||C).source,(n.evaluate||C).source].join("|")+"|$","g"),o=0,u="__p+='";t.replace(i,function(e,n,r,i,a){return u+=t.slice(o,a).replace(F,function(t){return"\\"+Y[t]}),n&&(u+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(u+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(u+="';\n"+i+"\n__p+='"),o=a+e.length,e}),u+="';\n",n.variable||(u="with(obj||{}){\n"+u+"}\n"),u="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+u+"return __p;\n";try{r=new Function(n.variable||"obj","_",u)}catch(a){throw a.source=u,a}if(e)return r(e,U);var s=function(t){return r.call(this,t,U)};return s.source="function("+(n.variable||"obj")+"){\n"+u+"}",s},U.chain=function(t){return U(t).chain()};var N=function(t){return this._chain?U(t).chain():t};U.mixin(U),B(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=o[t];U.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!=t&&"splice"!=t||0!==n.length||delete n[0],N.call(this,n)}}),B(["concat","join","slice"],function(t){var e=o[t];U.prototype[t]=function(){return N.call(this,e.apply(this._wrapped,arguments))}}),U.extend(U.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return U})}).call(this)},{}]},{},[11]); \ No newline at end of file +!function t(e,n,r){function i(u,a){if(!n[u]){if(!e[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=n[u]={exports:{}};e[u][0].call(c.exports,function(t){var n=e[u][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;ur;r++)n=t[r],o.push(n.getUserId()!==this.HB.getUserId()?n.getConnector().receive(e):void 0);return o}},e.prototype.receive=function(t){var e,n;return null==(e=this.unexecuted)[n=t.uid.creator]&&(e[n]=[]),this.unexecuted[t.uid.creator].push(t)},e.prototype.flushOne=function(t){var e;return(null!=(e=this.unexecuted[t])?e.length:void 0)>0?this.engine.applyOp(this.unexecuted[t].shift()):void 0},e.prototype.flushOneRandom=function(){return this.flushOne(n.random(0,t.length-1))},e.prototype.flushAll=function(){var t,e,n;n=this.unexecuted;for(t in n)e=n[t],this.engine.applyOps(e);return this.unexecuted={}},e}()}},{underscore:12}],3:[function(t,e){var n;n=function(){function t(t,e){this.HB=t,this.parser=e,this.unprocessed_ops=[]}return t.prototype.parseOperation=function(t){var e;if(e=this.parser[t.type],null!=e)return e(t);throw new Error("You forgot to specify a parser for type "+t.type+". The message is "+JSON.stringify(t)+".")},t.prototype.applyOpsBundle=function(t){var e,n,r,i,o,u,a,s;for(n=[],r=0,u=t.length;u>r;r++)e=t[r],n.push(this.parseOperation(e));for(i=0,a=n.length;a>i;i++)e=n[i],this.HB.addOperation(e);for(o=0,s=n.length;s>o;o++)e=n[o],e.execute()||this.unprocessed_ops.push(e);return this.tryUnprocessed()},t.prototype.applyOpsCheckDouble=function(t){var e,n,r,i;for(i=[],n=0,r=t.length;r>n;n++)e=t[n],i.push(null==this.HB.getOperation(e.uid)?this.applyOp(e):void 0);return i},t.prototype.applyOps=function(t){var e,n,r,i;for(i=[],n=0,r=t.length;r>n;n++)e=t[n],i.push(this.applyOp(e));return i},t.prototype.applyOp=function(t){var e;return e=this.parseOperation(t),this.HB.addToCounter(e),e.execute()?this.HB.addOperation(e):this.unprocessed_ops.push(e),this.tryUnprocessed()},t.prototype.tryUnprocessed=function(){var t,e,n,r,i,o,u;for(u=[];;){for(t=this.unprocessed_ops.length,n=[],o=this.unprocessed_ops,r=0,i=o.length;i>r;r++)e=o[r],e.execute()?this.HB.addOperation(e):n.push(e);if(this.unprocessed_ops=n,this.unprocessed_ops.length===t)break;u.push(void 0)}return u},t}(),e.exports=n},{}],4:[function(t,e){var n,r,i,o;o=t("../Types/JsonTypes"),r=t("../HistoryBuffer"),n=t("../Engine"),i=function(){function t(t,e){var i,u;this.HB=new r(t),u=o(this.HB),this.engine=new n(this.HB,u.parser),this.connector=new e(this.engine,this.HB,u.execution_listener,this),i=new u.types.JsonType(this.HB.getReservedUniqueIdentifier()),this.HB.addOperation(i).execute(),this.root_element=i}return t.prototype.getRootElement=function(){return this.root_element},t.prototype.getEngine=function(){return this.engine},t.prototype.getConnector=function(){return this.connector},t.prototype.getHistoryBuffer=function(){return this.HB},t.prototype.setMutableDefault=function(t){return this.root_element.setMutableDefault(t)},t.prototype.getUserId=function(){return this.HB.getUserId()},t.prototype.val=function(t,e,n){return this.root_element.val(t,e,n)},Object.defineProperty(t.prototype,"value",{get:function(){return this.root_element.value},set:function(t){var e,n,r;if(t.constructor==={}.constructor){r=[];for(e in t)n=t[e],r.push(this.val(e,n,"immutable"));return r}throw new Error("You must only set Object values!")}}),t}(),"undefined"!=typeof window&&null!==window&&(window.JsonYatta=i),e.exports=i},{"../Engine":3,"../HistoryBuffer":6,"../Types/JsonTypes":8}],5:[function(t,e){var n,r,i,o;o=t("../Types/TextTypes"),r=t("../HistoryBuffer"),n=t("../Engine"),i=function(){function t(t,e){var i,u;this.HB=new r(t),u=o(this.HB),this.engine=new n(this.HB,u.parser),this.connector=new e(this.engine,this.HB,u.execution_listener),i=new u.types.Word(void 0),this.HB.addOperation(i).execute(),this.root_element=i}return t.prototype.getRootElement=function(){return this.root_element},t.prototype.getEngine=function(){return this.engine},t.prototype.getConnector=function(){return this.connector},t.prototype.getHistoryBuffer=function(){return this.HB},t.prototype.getUserId=function(){return this.HB.getUserId()},t.prototype.val=function(){return this.root_element.val()},t.prototype.insertText=function(t,e){return this.root_element.insertText(t,e)},t.prototype.deleteText=function(t,e){return this.root_element.deleteText(t,e)},t.prototype.replaceText=function(t){return this.root_element.replaceText(t)},t}(),e.exports=i},{"../Engine":3,"../HistoryBuffer":6,"../Types/TextTypes":10}],6:[function(t,e){var n;n=function(){function t(t){this.user_id=t,this.operation_counter={},this.buffer={},this.change_listeners=[]}return t.prototype.getUserId=function(){return this.user_id},t.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},t.prototype.getOperationCounter=function(){var t,e,n,r;e={},r=this.operation_counter;for(n in r)t=r[n],e[n]=t;return e},t.prototype._encode=function(t){var e,n,r,i,o,u,a,s,c,l;null==t&&(t={}),e=[],s=function(e,n){if(null==e||null==n)throw new Error("dah!");return null==t[e]||t[e]<=n},l=this.buffer;for(a in l){c=l[a];for(o in c)if(n=c[o],!isNaN(parseInt(o))&&s(a,o)){if(r=n._encode(),null!=n.next_cl){for(i=n.next_cl;null!=i.next_cl&&s(i.creator,i.op_number);)i=i.next_cl;r.next=i.getUid()}else if(null!=n.prev_cl){for(u=n.prev_cl;null!=u.prev_cl&&s(i.creator,i.op_number);)u=u.prev_cl;r.prev=u.getUid()}e.push(r)}}return e},t.prototype.getNextOperationIdentifier=function(t){var e;return null==t&&(t=this.user_id),null==this.operation_counter[t]&&(this.operation_counter[t]=0),e={creator:t,op_number:this.operation_counter[t]},this.operation_counter[t]++,e},t.prototype.getOperation=function(t){var e;if(t instanceof Object)return null!=(e=this.buffer[t.creator])?e[t.op_number]:void 0;if(null!=t)throw new Error("This type of uid is not defined!")},t.prototype.addOperation=function(t){if(null==this.buffer[t.creator]&&(this.buffer[t.creator]={}),null!=this.buffer[t.creator][t.op_number])throw new Error("You must not overwrite operations!");return this.buffer[t.creator][t.op_number]=t,t},t.prototype.addToCounter=function(t){return null==this.operation_counter[t.creator]&&(this.operation_counter[t.creator]=0),"number"==typeof t.op_number&&t.creator!==this.getUserId()?this.operation_counter[t.creator]++:void 0},t}(),e.exports=n},{}],7:[function(t,e){var n={}.hasOwnProperty,r=function(t,e){function r(){this.constructor=t}for(var i in e)n.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};e.exports=function(t){var e,n,i,o,u,a,s;return s={},a=[],u=function(){function e(e){null==e&&(e=t.getNextOperationIdentifier()),this.creator=e.creator,this.op_number=e.op_number}return e.prototype.on=function(t,e){var n;return null==this.event_listeners&&(this.event_listeners={}),null==(n=this.event_listeners)[t]&&(n[t]=[]),this.event_listeners[t].push(e)},e.prototype.callEvent=function(t,e){var n,r,i,o,u;if(null!=this.event_listeners[t]){for(o=this.event_listeners[t],u=[],r=0,i=o.length;i>r;r++)n=o[r],u.push(n.call(this,t,e));return u}},e.prototype.setParent=function(t){return this.parent=t},e.prototype.getUid=function(){return{creator:this.creator,op_number:this.op_number}},e.prototype.execute=function(){var t,e,n;for(this.is_executed=!0,e=0,n=a.length;n>e;e++)(t=a[e])(this._encode());return this},e.prototype.saveOperation=function(t,e){return null!=(null!=e?e.execute:void 0)?this[t]=e:null!=e?(null==this.unchecked&&(this.unchecked={}),this.unchecked[t]=e):void 0},e.prototype.validateSavedOperations=function(){var e,n,r,i,o,u;o={},i=this,u=this.unchecked;for(e in u)r=u[e],n=t.getOperation(r),n?this[e]=n:(o[e]=r,i=!1);return delete this.unchecked,i||(this.unchecked=o),i},e}(),e=function(t){function e(t,n){this.saveOperation("deletes",n),e.__super__.constructor.call(this,t)}return r(e,t),e.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},e.prototype.execute=function(){return this.validateSavedOperations()?(this.deletes.applyDelete(this),e.__super__.execute.apply(this,arguments),this):!1},e}(u),s.Delete=function(t){var n,r;return r=t.uid,n=t.deletes,new e(r,n)},o=function(t){function e(t,n,r,i){this.saveOperation("prev_cl",n),this.saveOperation("next_cl",r),null!=i?this.saveOperation("origin",i):this.saveOperation("origin",n),e.__super__.constructor.call(this,t)}return r(e,t),e.prototype.applyDelete=function(t){return null==this.deleted_by&&(this.deleted_by=[]),this.deleted_by.push(t)},e.prototype.isDeleted=function(){var t;return(null!=(t=this.deleted_by)?t.length:void 0)>0},e.prototype.getDistanceToOrigin=function(){var t,e;for(t=0,e=this.prev_cl;;){if(this.origin===e)break;if(t++,this===this.prev_cl)throw new Error("this should not happen ;) ");e=e.prev_cl}return t},e.prototype.update_sl=function(){var t;return t=this.prev_cl,update("prev_cl","prev_sl"),update("next_cl","prev_sl")},e.prototype.execute=function(){var t,n,r,i,o;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(i=this.prev_cl)?i.validateSavedOperations():void 0)&&(null!=(o=this.next_cl)?o.validateSavedOperations():void 0)&&this.prev_cl.next_cl!==this){for(t=0,r=this.prev_cl.next_cl,n=0;;){if(null==r&&(console.log(JSON.stringify(this.prev_cl.getUid())),console.log(JSON.stringify(this.next_cl.getUid()))),r===this.next_cl)break;if(r.getDistanceToOrigin()===n)r.creator0)for(;;){if(e=e.next_cl,e.isDeleted()||(t-=1),0===t)break;if(e instanceof l.Delimiter)throw new Error("position parameter exceeded the length of the document!")}return e},n}(l.Insert),u=function(e){function n(t,e,r,i,o,u,a){n.__super__.constructor.call(this,e,r,i,o,u,a),null!=t&&this.replace(t)}return i(n,e),n.prototype.replace=function(e){var n,r;return n=this.getLastOperation(),r=new a(e,this,void 0,n,n.next_cl),t.addOperation(r).execute()},n.prototype.val=function(){var t;if(t=this.getLastOperation(),t instanceof l.Delimiter)throw new Error("dtrn");return t.val()},n.prototype._encode=function(){var t;return t={type:"ReplaceManager",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&null!=this.next_cl&&(t.prev=this.prev_cl.getUid(),t.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(t.origin=this.origin.getUid()),t},n}(r),c.ReplaceManager=function(t){var e,n,r,i,o,a,s;return n=t.content,s=t.uid,a=t.prev,i=t.next,o=t.origin,e=t.beginning,r=t.end,new u(n,s,e,r,a,i,o)},a=function(t){function e(t,n,r,i,o,u){if(this.saveOperation("content",t),this.saveOperation("parent",n),null==i||null==o||null==t)throw new Error("You must define content, prev, and next for Replaceable-types!");e.__super__.constructor.call(this,r,i,o,u)}return i(e,t),e.prototype.val=function(){return this.content},e.prototype.replace=function(t){return this.parent.replace(t)},e.prototype.execute=function(){var t;return this.validateSavedOperations()?("function"==typeof(t=this.content).setReplaceManager&&t.setReplaceManager(this.parent),e.__super__.execute.apply(this,arguments)):!1},e.prototype._encode=function(){var t;return t={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&&(t.origin=this.origin.getUid()),t},e}(l.Insert),c.Replaceable=function(t){var e,n,r,i,o,u;return e=t.content,i=t.ReplaceManager,u=t.uid,o=t.prev,n=t.next,r=t.origin,new a(e,i,u,o,n,r)},l.ListManager=r,l.MapManager=o,l.ReplaceManager=u,l.Replaceable=a,s}},{"./BasicTypes":7}],10:[function(t,e){var n,r={}.hasOwnProperty,i=function(t,e){function n(){this.constructor=t}for(var i in e)r.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};n=t("./StructuredTypes"),e.exports=function(t){var e,r,o,u,a,s;return a=n(t),s=a.types,u=a.parser,e=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return i(e,t),e}(s.Delete),u.TextDelete=u.Delete,r=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 i(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),u.TextInsert=function(t){var e,n,i,o,u;return e=t.content,u=t.uid,o=t.prev,n=t.next,i=t.origin,new r(e,u,o,n,i)},o=function(n){function o(t,e,n,r,i,u){o.__super__.constructor.call(this,t,e,n,r,i,u)}return i(o,n),o.prototype.insertText=function(e,n){var i,o,u,a,s,c;for(o=this.getOperationByPosition(e),c=[],a=0,s=n.length;s>a;a++)i=n[a],u=new r(i,void 0,o.prev_cl,o),c.push(t.addOperation(u).execute());return c},o.prototype.deleteText=function(n,r){var i,o,u,a,c;for(u=this.getOperationByPosition(n),c=[],o=a=0;r>=0?r>a:a>r;o=r>=0?++a:--a){for(i=t.addOperation(new e(void 0,u)).execute(),u=u.next_cl;u.isDeleted();){if(u instanceof s.Delimiter)throw new Error("You can't delete more than there is..");u=u.next_cl}c.push(i._encode())}return c},o.prototype.replaceText=function(e){var n;if(null!=this.replace_manager)return n=t.addOperation(new o(void 0)).execute(),n.insertText(0,e),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}(s.ListManager),u.Word=function(t){var e,n,r,i,u,a;return a=t.uid,e=t.beginning,n=t.end,u=t.prev,r=t.next,i=t.origin,new o(a,e,n,u,r,i)},s.TextInsert=r,s.TextDelete=e,s.Word=o,a}},{"./StructuredTypes":9}],11:[function(t,e,n){n.IwcConnector=t("./Connectors/IwcConnector"),n.TestConnector=t("./Connectors/TestConnector"),n.JsonYatta=t("./Frameworks/JsonYatta"),n.TextYatta=t("./Frameworks/TextYatta")},{"./Connectors/IwcConnector":1,"./Connectors/TestConnector":2,"./Frameworks/JsonYatta":4,"./Frameworks/TextYatta":5}],12:[function(t,e,n){(function(){var t=this,r=t._,i={},o=Array.prototype,u=Object.prototype,a=Function.prototype,s=o.push,c=o.slice,l=o.concat,p=u.toString,f=u.hasOwnProperty,h=o.forEach,d=o.map,v=o.reduce,_=o.reduceRight,g=o.filter,y=o.every,m=o.some,x=o.indexOf,b=o.lastIndexOf,w=Array.isArray,O=Object.keys,T=a.bind,U=function(t){return t instanceof U?t:this instanceof U?void(this._wrapped=t):new U(t)};"undefined"!=typeof n?("undefined"!=typeof e&&e.exports&&(n=e.exports=U),n._=U):t._=U,U.VERSION="1.6.0";var I=U.each=U.forEach=function(t,e,n){if(null==t)return t;if(h&&t.forEach===h)t.forEach(e,n);else if(t.length===+t.length){for(var r=0,o=t.length;o>r;r++)if(e.call(n,t[r],r,t)===i)return}else for(var u=U.keys(t),r=0,o=u.length;o>r;r++)if(e.call(n,t[u[r]],u[r],t)===i)return;return t};U.map=U.collect=function(t,e,n){var r=[];return null==t?r:d&&t.map===d?t.map(e,n):(I(t,function(t,i,o){r.push(e.call(n,t,i,o))}),r)};var B="Reduce of empty array with no initial value";U.reduce=U.foldl=U.inject=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),v&&t.reduce===v)return r&&(e=U.bind(e,r)),i?t.reduce(e,n):t.reduce(e);if(I(t,function(t,o,u){i?n=e.call(r,n,t,o,u):(n=t,i=!0)}),!i)throw new TypeError(B);return n},U.reduceRight=U.foldr=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),_&&t.reduceRight===_)return r&&(e=U.bind(e,r)),i?t.reduceRight(e,n):t.reduceRight(e);var o=t.length;if(o!==+o){var u=U.keys(t);o=u.length}if(I(t,function(a,s,c){s=u?u[--o]:--o,i?n=e.call(r,n,t[s],s,c):(n=t[s],i=!0)}),!i)throw new TypeError(B);return n},U.find=U.detect=function(t,e,n){var r;return j(t,function(t,i,o){return e.call(n,t,i,o)?(r=t,!0):void 0}),r},U.filter=U.select=function(t,e,n){var r=[];return null==t?r:g&&t.filter===g?t.filter(e,n):(I(t,function(t,i,o){e.call(n,t,i,o)&&r.push(t)}),r)},U.reject=function(t,e,n){return U.filter(t,function(t,r,i){return!e.call(n,t,r,i)},n)},U.every=U.all=function(t,e,n){e||(e=U.identity);var r=!0;return null==t?r:y&&t.every===y?t.every(e,n):(I(t,function(t,o,u){return(r=r&&e.call(n,t,o,u))?void 0:i}),!!r)};var j=U.some=U.any=function(t,e,n){e||(e=U.identity);var r=!1;return null==t?r:m&&t.some===m?t.some(e,n):(I(t,function(t,o,u){return r||(r=e.call(n,t,o,u))?i:void 0}),!!r)};U.contains=U.include=function(t,e){return null==t?!1:x&&t.indexOf===x?-1!=t.indexOf(e):j(t,function(t){return t===e})},U.invoke=function(t,e){var n=c.call(arguments,2),r=U.isFunction(e);return U.map(t,function(t){return(r?e:t[e]).apply(t,n)})},U.pluck=function(t,e){return U.map(t,U.property(e))},U.where=function(t,e){return U.filter(t,U.matches(e))},U.findWhere=function(t,e){return U.find(t,U.matches(e))},U.max=function(t,e,n){if(!e&&U.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.max.apply(Math,t);var r=-1/0,i=-1/0;return I(t,function(t,o,u){var a=e?e.call(n,t,o,u):t;a>i&&(r=t,i=a)}),r},U.min=function(t,e,n){if(!e&&U.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.min.apply(Math,t);var r=1/0,i=1/0;return I(t,function(t,o,u){var a=e?e.call(n,t,o,u):t;i>a&&(r=t,i=a)}),r},U.shuffle=function(t){var e,n=0,r=[];return I(t,function(t){e=U.random(n++),r[n-1]=r[e],r[e]=t}),r},U.sample=function(t,e,n){return null==e||n?(t.length!==+t.length&&(t=U.values(t)),t[U.random(t.length-1)]):U.shuffle(t).slice(0,Math.max(0,e))};var E=function(t){return null==t?U.identity:U.isFunction(t)?t:U.property(t)};U.sortBy=function(t,e,n){return e=E(e),U.pluck(U.map(t,function(t,r,i){return{value:t,index:r,criteria:e.call(n,t,r,i)}}).sort(function(t,e){var n=t.criteria,r=e.criteria;if(n!==r){if(n>r||void 0===n)return 1;if(r>n||void 0===r)return-1}return t.index-e.index}),"value")};var H=function(t){return function(e,n,r){var i={};return n=E(n),I(e,function(o,u){var a=n.call(r,o,u,e);t(i,a,o)}),i}};U.groupBy=H(function(t,e,n){U.has(t,e)?t[e].push(n):t[e]=[n]}),U.indexBy=H(function(t,e,n){t[e]=n}),U.countBy=H(function(t,e){U.has(t,e)?t[e]++:t[e]=1}),U.sortedIndex=function(t,e,n,r){n=E(n);for(var i=n.call(r,e),o=0,u=t.length;u>o;){var a=o+u>>>1;n.call(r,t[a])e?[]:c.call(t,0,e)},U.initial=function(t,e,n){return c.call(t,0,t.length-(null==e||n?1:e))},U.last=function(t,e,n){return null==t?void 0:null==e||n?t[t.length-1]:c.call(t,Math.max(t.length-e,0))},U.rest=U.tail=U.drop=function(t,e,n){return c.call(t,null==e||n?1:e)},U.compact=function(t){return U.filter(t,U.identity)};var k=function(t,e,n){return e&&U.every(t,U.isArray)?l.apply(n,t):(I(t,function(t){U.isArray(t)||U.isArguments(t)?e?s.apply(n,t):k(t,e,n):n.push(t)}),n)};U.flatten=function(t,e){return k(t,e,[])},U.without=function(t){return U.difference(t,c.call(arguments,1))},U.partition=function(t,e){var n=[],r=[];return I(t,function(t){(e(t)?n:r).push(t)}),[n,r]},U.uniq=U.unique=function(t,e,n,r){U.isFunction(e)&&(r=n,n=e,e=!1);var i=n?U.map(t,n,r):t,o=[],u=[];return I(i,function(n,r){(e?r&&u[u.length-1]===n:U.contains(u,n))||(u.push(n),o.push(t[r]))}),o},U.union=function(){return U.uniq(U.flatten(arguments,!0))},U.intersection=function(t){var e=c.call(arguments,1);return U.filter(U.uniq(t),function(t){return U.every(e,function(e){return U.contains(e,t)})})},U.difference=function(t){var e=l.apply(o,c.call(arguments,1));return U.filter(t,function(t){return!U.contains(e,t)})},U.zip=function(){for(var t=U.max(U.pluck(arguments,"length").concat(0)),e=new Array(t),n=0;t>n;n++)e[n]=U.pluck(arguments,""+n);return e},U.object=function(t,e){if(null==t)return{};for(var n={},r=0,i=t.length;i>r;r++)e?n[t[r]]=e[r]:n[t[r][0]]=t[r][1];return n},U.indexOf=function(t,e,n){if(null==t)return-1;var r=0,i=t.length;if(n){if("number"!=typeof n)return r=U.sortedIndex(t,e),t[r]===e?r:-1;r=0>n?Math.max(0,i+n):n}if(x&&t.indexOf===x)return t.indexOf(e,n);for(;i>r;r++)if(t[r]===e)return r;return-1},U.lastIndexOf=function(t,e,n){if(null==t)return-1;var r=null!=n;if(b&&t.lastIndexOf===b)return r?t.lastIndexOf(e,n):t.lastIndexOf(e);for(var i=r?n:t.length;i--;)if(t[i]===e)return i;return-1},U.range=function(t,e,n){arguments.length<=1&&(e=t||0,t=0),n=arguments[2]||1;for(var r=Math.max(Math.ceil((e-t)/n),0),i=0,o=new Array(r);r>i;)o[i++]=t,t+=n;return o};var D=function(){};U.bind=function(t,e){var n,r;if(T&&t.bind===T)return T.apply(t,c.call(arguments,1));if(!U.isFunction(t))throw new TypeError;return n=c.call(arguments,2),r=function(){if(!(this instanceof r))return t.apply(e,n.concat(c.call(arguments)));D.prototype=t.prototype;var i=new D;D.prototype=null;var o=t.apply(i,n.concat(c.call(arguments)));return Object(o)===o?o:i}},U.partial=function(t){var e=c.call(arguments,1);return function(){for(var n=0,r=e.slice(),i=0,o=r.length;o>i;i++)r[i]===U&&(r[i]=arguments[n++]);for(;n=l?(clearTimeout(u),u=null,a=c,o=t.apply(r,i),r=i=null):u||n.trailing===!1||(u=setTimeout(s,l)),o}},U.debounce=function(t,e,n){var r,i,o,u,a,s=function(){var c=U.now()-u;e>c?r=setTimeout(s,e-c):(r=null,n||(a=t.apply(o,i),o=i=null))};return function(){o=this,i=arguments,u=U.now();var c=n&&!r;return r||(r=setTimeout(s,e)),c&&(a=t.apply(o,i),o=i=null),a}},U.once=function(t){var e,n=!1;return function(){return n?e:(n=!0,e=t.apply(this,arguments),t=null,e)}},U.wrap=function(t,e){return U.partial(e,t)},U.compose=function(){var t=arguments;return function(){for(var e=arguments,n=t.length-1;n>=0;n--)e=[t[n].apply(this,e)];return e[0]}},U.after=function(t,e){return function(){return--t<1?e.apply(this,arguments):void 0}},U.keys=function(t){if(!U.isObject(t))return[];if(O)return O(t);var e=[];for(var n in t)U.has(t,n)&&e.push(n);return e},U.values=function(t){for(var e=U.keys(t),n=e.length,r=new Array(n),i=0;n>i;i++)r[i]=t[e[i]];return r},U.pairs=function(t){for(var e=U.keys(t),n=e.length,r=new Array(n),i=0;n>i;i++)r[i]=[e[i],t[e[i]]];return r},U.invert=function(t){for(var e={},n=U.keys(t),r=0,i=n.length;i>r;r++)e[t[n[r]]]=n[r];return e},U.functions=U.methods=function(t){var e=[];for(var n in t)U.isFunction(t[n])&&e.push(n);return e.sort()},U.extend=function(t){return I(c.call(arguments,1),function(e){if(e)for(var n in e)t[n]=e[n]}),t},U.pick=function(t){var e={},n=l.apply(o,c.call(arguments,1));return I(n,function(n){n in t&&(e[n]=t[n])}),e},U.omit=function(t){var e={},n=l.apply(o,c.call(arguments,1));for(var r in t)U.contains(n,r)||(e[r]=t[r]);return e},U.defaults=function(t){return I(c.call(arguments,1),function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t},U.clone=function(t){return U.isObject(t)?U.isArray(t)?t.slice():U.extend({},t):t},U.tap=function(t,e){return e(t),t};var M=function(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return t===e;t instanceof U&&(t=t._wrapped),e instanceof U&&(e=e._wrapped);var i=p.call(t);if(i!=p.call(e))return!1;switch(i){case"[object String]":return t==String(e);case"[object Number]":return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case"[object Date]":case"[object Boolean]":return+t==+e;case"[object RegExp]":return t.source==e.source&&t.global==e.global&&t.multiline==e.multiline&&t.ignoreCase==e.ignoreCase}if("object"!=typeof t||"object"!=typeof e)return!1;for(var o=n.length;o--;)if(n[o]==t)return r[o]==e;var u=t.constructor,a=e.constructor;if(u!==a&&!(U.isFunction(u)&&u instanceof u&&U.isFunction(a)&&a instanceof a)&&"constructor"in t&&"constructor"in e)return!1;n.push(t),r.push(e);var s=0,c=!0;if("[object Array]"==i){if(s=t.length,c=s==e.length)for(;s--&&(c=M(t[s],e[s],n,r)););}else{for(var l in t)if(U.has(t,l)&&(s++,!(c=U.has(e,l)&&M(t[l],e[l],n,r))))break;if(c){for(l in e)if(U.has(e,l)&&!s--)break;c=!s}}return n.pop(),r.pop(),c};U.isEqual=function(t,e){return M(t,e,[],[])},U.isEmpty=function(t){if(null==t)return!0;if(U.isArray(t)||U.isString(t))return 0===t.length;for(var e in t)if(U.has(t,e))return!1;return!0},U.isElement=function(t){return!(!t||1!==t.nodeType)},U.isArray=w||function(t){return"[object Array]"==p.call(t)},U.isObject=function(t){return t===Object(t)},I(["Arguments","Function","String","Number","Date","RegExp"],function(t){U["is"+t]=function(e){return p.call(e)=="[object "+t+"]"}}),U.isArguments(arguments)||(U.isArguments=function(t){return!(!t||!U.has(t,"callee"))}),"function"!=typeof/./&&(U.isFunction=function(t){return"function"==typeof t}),U.isFinite=function(t){return isFinite(t)&&!isNaN(parseFloat(t))},U.isNaN=function(t){return U.isNumber(t)&&t!=+t},U.isBoolean=function(t){return t===!0||t===!1||"[object Boolean]"==p.call(t)},U.isNull=function(t){return null===t},U.isUndefined=function(t){return void 0===t},U.has=function(t,e){return f.call(t,e)},U.noConflict=function(){return t._=r,this},U.identity=function(t){return t},U.constant=function(t){return function(){return t}},U.property=function(t){return function(e){return e[t]}},U.matches=function(t){return function(e){if(e===t)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0}},U.times=function(t,e,n){for(var r=Array(Math.max(0,t)),i=0;t>i;i++)r[i]=e.call(n,i);return r},U.random=function(t,e){return null==e&&(e=t,t=0),t+Math.floor(Math.random()*(e-t+1))},U.now=Date.now||function(){return(new Date).getTime()};var R={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};R.unescape=U.invert(R.escape);var A={escape:new RegExp("["+U.keys(R.escape).join("")+"]","g"),unescape:new RegExp("("+U.keys(R.unescape).join("|")+")","g")};U.each(["escape","unescape"],function(t){U[t]=function(e){return null==e?"":(""+e).replace(A[t],function(e){return R[t][e]})}}),U.result=function(t,e){if(null==t)return void 0;var n=t[e];return U.isFunction(n)?n.call(t):n},U.mixin=function(t){I(U.functions(t),function(e){var n=U[e]=t[e];U.prototype[e]=function(){var t=[this._wrapped];return s.apply(t,arguments),N.call(this,n.apply(U,t))}})};var C=0;U.uniqueId=function(t){var e=++C+"";return t?t+e:e},U.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var S=/(.)^/,Y={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},F=/\\|'|\r|\n|\t|\u2028|\u2029/g;U.template=function(t,e,n){var r;n=U.defaults({},n,U.templateSettings);var i=new RegExp([(n.escape||S).source,(n.interpolate||S).source,(n.evaluate||S).source].join("|")+"|$","g"),o=0,u="__p+='";t.replace(i,function(e,n,r,i,a){return u+=t.slice(o,a).replace(F,function(t){return"\\"+Y[t]}),n&&(u+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(u+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(u+="';\n"+i+"\n__p+='"),o=a+e.length,e}),u+="';\n",n.variable||(u="with(obj||{}){\n"+u+"}\n"),u="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+u+"return __p;\n";try{r=new Function(n.variable||"obj","_",u)}catch(a){throw a.source=u,a}if(e)return r(e,U);var s=function(t){return r.call(this,t,U)};return s.source="function("+(n.variable||"obj")+"){\n"+u+"}",s},U.chain=function(t){return U(t).chain()};var N=function(t){return this._chain?U(t).chain():t};U.mixin(U),I(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=o[t];U.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!=t&&"splice"!=t||0!==n.length||delete n[0],N.call(this,n)}}),I(["concat","join","slice"],function(t){var e=o[t];U.prototype[t]=function(){return N.call(this,e.apply(this._wrapped,arguments))}}),U.extend(U.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return U})}).call(this)},{}]},{},[11]); \ No newline at end of file diff --git a/build/node/Connectors/IwcConnector.js b/build/node/Connectors/IwcConnector.js index 646de143..6d72f697 100644 --- a/build/node/Connectors/IwcConnector.js +++ b/build/node/Connectors/IwcConnector.js @@ -1,2 +1,2 @@ -(function(){var t;t=function(t,n){var e,i,r,o,u,a,s;return 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)}):void 0}),i.initOK(),a=null,e=function(){function t(t,n,e,r){var o,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,this.iwcHandler=u,l=function(t){return function(n){return t.send(n)}}(this),this.execution_listener.push(l),o=function(t){return function(e){return n=null!=e?e.extras.HB:void 0,t.engine.applyOpsCheckDouble(n)}}(this),u.Yatta_push_HB_element=[o],s=function(t){return function(n){var e;return e=n.extras,t.receive(e)}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=a&&this.engine.applyOpsCheckDouble(a),c=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode()},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={action:"Yatta_get_HB_element",component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:{}},s=function(){return i.sendIntent(r)},o=function(){var i;return setTimeout(s,1e3),i=null,i=null!=n?n:Math.floor(1e6*Math.random()),t(e,i)},void setTimeout(o,1e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(window.createIwcConnector=t)}).call(this); +(function(){var t;t=function(t,e){var n,i,r,o,u;return o={},i=new DUIClient,i.connect(function(t){var e;return null!=(e=o[t.action])?e.map(function(e){return setTimeout(function(){return e(t)},0)}):void 0}),i.initOK(),u=null,n=function(){function t(t,e,n,r){var a,s,c,l;this.engine=t,this.HB=e,this.execution_listener=n,this.yatta=r,this.duiClient=i,this.iwcHandler=o,l=function(t){return function(e){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(e):void 0}}(this),this.execution_listener.push(l),this.initialized={},a=function(t){return function(n){var i;return e=n.extras.HB,i=n.extras.user,t.engine.applyOpsCheckDouble(e),t.initialized[i]=!0}}(this),o.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(e){var n;return n=e.extras,null!=t.initialized[n.uid.creator]?t.receive(n):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=u&&this.engine.applyOpsCheckDouble(u),c=function(t){return function(){var e;return e={HB:t.yatta.getHistoryBuffer()._encode(),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,e){var n;return n={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:e},this.duiClient.sendIntent(n)},t}(),r=function(){var i;return i=null,i=null!=e?e:Math.floor(1e6*Math.random()),t(n,i)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(window.createIwcConnector=t)}).call(this); //# sourceMappingURL=../Connectors/IwcConnector.js.map \ No newline at end of file diff --git a/build/node/Connectors/IwcConnector.js.map b/build/node/Connectors/IwcConnector.js.map index 7ef19189..4f5bfac3 100755 --- a/build/node/Connectors/IwcConnector.js.map +++ b/build/node/Connectors/IwcConnector.js.map @@ -1 +1 @@ -{"version":3,"file":"Connectors/IwcConnector.js","sources":["Connectors/IwcConnector.coffee"],"names":[],"mappings":"CAKA,WAAA,GAAA,EAAA,GAAqB,SAAC,EAAU,GAC9B,GAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,QAAA,MACA,EAAgB,GAAA,WAEhB,EAAU,QAAQ,SAAC,GACjB,GAAA,kCAA2B,IAAI,SAAC,SAC9B,YAAW,iBACT,GAAE,IACF,KAHJ,SAKF,EAAU,SAEV,EAAc,KAOR,EAAA,WAQS,QAAA,GAAE,EAAS,EAAK,EAAqB,GAChD,GAAA,GAAA,EAAA,EAAA,CADY,MAAC,OAAA,EAAQ,KAAC,GAAA,EAAI,KAAC,mBAAA,EAAoB,KAAC,MAAA,EAChD,KAAC,UAAY,EACb,KAAC,WAAa,EAEd,EAAQ,SAAA,SAAA,UAAC,SACP,GAAC,KAAK,KADA,MAER,KAAC,mBAAmB,KAAK,GAEzB,EAAY,SAAA,SAAA,UAAC,SACX,GAAA,MAAA,EAAK,EAAM,OAAO,GAAA,OAClB,EAAK,OAAO,oBAAoB,KAFtB,MAGZ,EAAW,uBAA4B,GAGvC,EAAW,SAAA,SAAA,UAAC,GACV,GAAA,SAAA,GAAI,EAAO,OACX,EAAC,QAAQ,KAFA,MAGX,KAAC,WAAW,qBAA0B,GAEnC,MAAA,GACD,KAAC,OAAO,oBAAoB,GAE9B,EAAoB,SAAA,SAAA,YAClB,GAAA,SAAA,IACE,GAAK,EAAC,MAAM,mBAAmB,WACjC,EAAC,cAAc,wBAAyB,KAHtB,MAIpB,KAAC,WAAW,sBAA2B,SA1BzC,GAAA,UAgCA,KAAM,SAAC,GACL,MAAG,GAAE,IAAI,UAAW,KAAC,GAAG,aAA6C,gBAA5B,GAAS,IAAI,UACpD,KAAC,cAAc,sBAAuB,GADxC,QAjCF,EAAA,UAwCA,QAAS,SAAC,GACR,MAAG,GAAE,IAAI,UAAa,KAAC,GAAG,YACxB,KAAC,OAAO,QAAQ,GADlB,QAzCF,EAAA,UAiDA,cAAe,SAAC,EAAa,GAC3B,GAAA,SAAA,IACE,OAAQ,EACR,UAAW,GACX,KAAM,GACN,SAAU,GACV,OAAQ,kBACR,OAAQ,GAEV,KAAC,UAAU,WAAW,SAE1B,GACE,OAAQ,uBACR,UAAW,GACX,KAAM,GACN,SAAU,GACV,OAAQ,kBACR,WAEF,EAAqB,iBACnB,GAAU,WAAW,IAEvB,EAAO,WACL,GAAA,SAAA,YAAW,EAAoB,KAC/B,EAAmB,KAEjB,EADC,MAAA,EACkB,EAGA,KAAK,MAAoB,IAAd,KAAK,UACrC,EAAS,EAAc,QAEzB,YAAW,EAAO,MAGpB,OAAO,QAAU,8CACjB,OAAQ,mBAAqB","sourcesContent":["\n#\n# @param {Function} callback The callback is called when the connector is initialized.\n# @param {String} initial_user_id Optional. You can set you own user_id (since the ids of duiclient are not always unique)\n#\ncreateIwcConnector = (callback, initial_user_id)->\n iwcHandler = {}\n duiClient = new DUIClient()\n #@duiClient = new iwc.Client()\n duiClient.connect (intent)->\n iwcHandler[intent.action]?.map (f)->\n setTimeout ()->\n f intent\n , 0\n\n duiClient.initOK()\n\n received_HB = null\n\n #\n # The Iwc Connector adds support for the Inter-Widget-Communication protocol that is used in the Role-SDK.\n # @see http://dbis.rwth-aachen.de/cms/projects/the-xmpp-experience#interwidget-communication\n # @see http://dbis.rwth-aachen.de/cms/projects/ROLE\n #\n class IwcConnector\n\n #\n # @param {Engine} engine The transformation engine\n # @param {HistoryBuffer} HB\n # @param {Array} 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 @duiClient = duiClient\n @iwcHandler = iwcHandler\n\n send_ = (o)=>\n @send o\n @execution_listener.push send_\n\n receiveHB = (json)=>\n HB = json?.extras.HB\n this.engine.applyOpsCheckDouble HB\n iwcHandler[\"Yatta_push_HB_element\"] = [receiveHB]\n\n\n receive_ = (intent)=>\n o = intent.extras\n @receive o\n @iwcHandler[\"Yatta_new_operation\"] = [receive_]\n\n if received_HB?\n @engine.applyOpsCheckDouble received_HB\n\n sendHistoryBuffer = ()=>\n json =\n HB : @yatta.getHistoryBuffer()._encode()\n @sendIwcIntent \"Yatta_push_HB_element\", json\n @iwcHandler[\"Yatta_get_HB_element\"] = [sendHistoryBuffer]\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 @sendIwcIntent \"Yatta_new_operation\", 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 #\n # Helper for sending iwc intents.\n # @param {String} action_name The name of the action that is going to be send.\n # @param {String} content The content that is atteched to the intent.\n #\n sendIwcIntent: (action_name, content)->\n intent =\n action: action_name\n component: \"\"\n data: \"\"\n dataType: \"\"\n flags: [\"PUBLISH_GLOBAL\"]\n extras: content\n\n @duiClient.sendIntent(intent)\n\n get_HB_intent =\n action: \"Yatta_get_HB_element\"\n component: \"\"\n data: \"\"\n dataType: \"\"\n flags: [\"PUBLISH_GLOBAL\"]\n extras: {}\n\n send_get_HB_intent = ()->\n duiClient.sendIntent(get_HB_intent)\n\n init = ()->\n setTimeout send_get_HB_intent, 1000\n proposed_user_id = null\n if initial_user_id?\n proposed_user_id = initial_user_id\n else\n # proposed_user_id = duiClient.getIwcClient()._componentName #TODO: This is stupid! why can't i use this?\n proposed_user_id = Math.floor(Math.random()*1000000)\n callback IwcConnector, proposed_user_id\n\n setTimeout init, (1000)\n\n undefined\nmodule.exports = createIwcConnector\nwindow?.createIwcConnector = createIwcConnector\n\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"file":"Connectors/IwcConnector.js","sources":["Connectors/IwcConnector.coffee"],"names":[],"mappings":"CAKA,WAAA,GAAA,EAAA,GAAqB,SAAC,EAAU,GAC9B,GAAA,GAAA,EAAA,EAAA,EAAA,QAAA,MACA,EAAgB,GAAA,WAEhB,EAAU,QAAQ,SAAC,GACjB,GAAA,kCAA2B,IAAI,SAAC,SAC9B,YAAW,iBACT,GAAE,IACF,KAHJ,SAKF,EAAU,SAEV,EAAc,KAOR,EAAA,WAQS,QAAA,GAAE,EAAS,EAAK,EAAqB,GAChD,GAAA,GAAA,EAAA,EAAA,CADY,MAAC,OAAA,EAAQ,KAAC,GAAA,EAAI,KAAC,mBAAA,EAAoB,KAAC,MAAA,EAChD,KAAC,UAAY,EACb,KAAC,WAAa,EAEd,EAAQ,SAAA,SAAA,UAAC,GACP,MAAwD,KAArD,OAAO,oBAAoB,EAAC,aAAa,OAC1C,EAAC,KAAK,GADR,SADM,MAGR,KAAC,mBAAmB,KAAK,GAEzB,KAAC,eACD,EAAY,SAAA,SAAA,UAAC,GACX,GAAA,SAAA,GAAK,EAAK,OAAO,GACjB,EAAM,EAAK,OAAO,KAClB,EAAK,OAAO,oBAAoB,GAChC,EAAC,YAAY,IAAO,IAJV,MAKZ,EAAW,uBAA4B,GAEvC,KAAC,cAAc,2BAEf,EAAW,SAAA,SAAA,UAAC,GACV,GAAA,EACA,OADA,GAAI,EAAO,OACR,MAAA,EAAA,YAAA,EAAA,IAAA,SACD,EAAC,QAAQ,GADX,SAFS,MAKX,KAAC,WAAW,qBAA0B,GAEnC,MAAA,GACD,KAAC,OAAO,oBAAoB,GAE9B,EAAoB,SAAA,SAAA,YAClB,GAAA,SAAA,IACE,GAAK,EAAC,MAAM,mBAAmB,UAC/B,KAAO,EAAC,MAAM,aAChB,EAAC,cAAc,wBAAyB,KAJtB,MAKpB,KAAC,WAAW,sBAA2B,SAlCzC,GAAA,UAwCA,KAAM,SAAC,GACL,MAAG,GAAE,IAAI,UAAW,KAAC,GAAG,aAA6C,gBAA5B,GAAS,IAAI,UACpD,KAAC,cAAc,sBAAuB,GADxC,QAzCF,EAAA,UAgDA,QAAS,SAAC,GACR,MAAG,GAAE,IAAI,UAAa,KAAC,GAAG,YACxB,KAAC,OAAO,QAAQ,GADlB,QAjDF,EAAA,UAyDA,cAAe,SAAC,EAAa,GAC3B,GAAA,SAAA,IACE,OAAQ,EACR,UAAW,GACX,KAAM,GACN,SAAU,GACV,OAAQ,kBACR,OAAQ,GAEV,KAAC,UAAU,WAAW,SAI1B,EAAO,WACL,GAAA,SAAA,GAAmB,KAEjB,EADC,MAAA,EACkB,EAGA,KAAK,MAAoB,IAAd,KAAK,UACrC,EAAS,EAAc,QAEzB,YAAW,EAAM,MAGnB,OAAO,QAAU,8CACjB,OAAQ,mBAAqB","sourcesContent":["\n#\n# @param {Function} callback The callback is called when the connector is initialized.\n# @param {String} initial_user_id Optional. You can set you own user_id (since the ids of duiclient are not always unique)\n#\ncreateIwcConnector = (callback, initial_user_id)->\n iwcHandler = {}\n duiClient = new DUIClient()\n #@duiClient = new iwc.Client()\n duiClient.connect (intent)->\n iwcHandler[intent.action]?.map (f)->\n setTimeout ()->\n f intent\n , 0\n\n duiClient.initOK()\n\n received_HB = null\n\n #\n # The Iwc Connector adds support for the Inter-Widget-Communication protocol that is used in the Role-SDK.\n # @see http://dbis.rwth-aachen.de/cms/projects/the-xmpp-experience#interwidget-communication\n # @see http://dbis.rwth-aachen.de/cms/projects/ROLE\n #\n class IwcConnector\n\n #\n # @param {Engine} engine The transformation engine\n # @param {HistoryBuffer} HB\n # @param {Array} 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 @duiClient = duiClient\n @iwcHandler = iwcHandler\n\n send_ = (o)=>\n if Object.getOwnPropertyNames(@initialized).length isnt 0\n @send o\n @execution_listener.push send_\n\n @initialized = {}\n receiveHB = (json)=>\n HB = json.extras.HB\n him = json.extras.user\n this.engine.applyOpsCheckDouble HB\n @initialized[him] = true\n iwcHandler[\"Yatta_push_HB_element\"] = [receiveHB]\n\n @sendIwcIntent \"Yatta_get_HB_element\", {}\n\n receive_ = (intent)=>\n o = intent.extras\n if @initialized[o.uid.creator]? # initialize first\n @receive o\n\n @iwcHandler[\"Yatta_new_operation\"] = [receive_]\n\n if received_HB?\n @engine.applyOpsCheckDouble received_HB\n\n sendHistoryBuffer = ()=>\n json =\n HB : @yatta.getHistoryBuffer()._encode()\n user : @yatta.getUserId()\n @sendIwcIntent \"Yatta_push_HB_element\", json\n @iwcHandler[\"Yatta_get_HB_element\"] = [sendHistoryBuffer]\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 @sendIwcIntent \"Yatta_new_operation\", 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 #\n # Helper for sending iwc intents.\n # @param {String} action_name The name of the action that is going to be send.\n # @param {String} content The content that is atteched to the intent.\n #\n sendIwcIntent: (action_name, content)->\n intent =\n action: action_name\n component: \"\"\n data: \"\"\n dataType: \"\"\n flags: [\"PUBLISH_GLOBAL\"]\n extras: content\n\n @duiClient.sendIntent(intent)\n\n\n\n init = ()->\n proposed_user_id = null\n if initial_user_id?\n proposed_user_id = initial_user_id\n else\n # proposed_user_id = duiClient.getIwcClient()._componentName #TODO: This is stupid! why can't i use this?\n proposed_user_id = Math.floor(Math.random()*1000000)\n callback IwcConnector, proposed_user_id\n\n setTimeout init, 5000\n\n undefined\nmodule.exports = createIwcConnector\nwindow?.createIwcConnector = createIwcConnector\n\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/examples/IwcJson/README.md b/examples/IwcJson/README.md index 3b049929..0b577505 100644 --- a/examples/IwcJson/README.md +++ b/examples/IwcJson/README.md @@ -54,123 +54,9 @@ A string property can be either mutable or immutable. yatta.val('mutable_string').insertText(2,"XXX"); // position, string yatta.val('mutable_string').deleteText(0,1); // position, deletion length console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true -``` -You can omit the mutable - parameter. In that case the default will be used. -Initially the default is 'mutable'. You can set it like this: - -```js - yatta.setMutableDefault('mutable'); - // or - yatta.setMutableDefault('immutable'); - - yatta.val('new_string', "string"); - console.log(yatta.val('new_string') === "string"); // true -``` - - -yatta is chainable: - - -```js - yatta.val('a', 4).val('b',5); - console.log(yatta.val('a') === 4); // true - console.log(yatta.val('b') === 5); // true -``` - - -You can alse set objects. - - -```js - yatta.val('object', {a : {b : "b"}, c : { d : 5 }}); - console.log(yatta.val('object').val('c').val('d') === 5); // true -``` - - -Lists are always immutable. - - -```js - yatta.val('list', [1,2,3]); - console.log(yatta.val('list')[2] === 3); // true -``` - - -But there is a much more convenient way! - - -```js - console.log(yatta.value.list[2] === 3) // true - yatta.value.list = [3,4,5] - console.log(yatta.val('list')[2] === 5) // true - yatta.value.object = {c : 4} - console.log(yatta.value.object.c === 4) // true -``` - - -The downside is that you are only allowed to overwrite existing properties. - - -```js - yatta.value.newProperty = "Awesome" - console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined. -``` - - -So, how do we create new properties? - - -```js - yatta.value = {newProperty : "Awesome"} - console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;) -``` - - -This is stupid! I don't want to overwrite all my existing properties! -Very well.. The solution is that we merge yatta.value with the new assignment. -For example: assuming we want to overwrite yatta.value with some object o. -Then these two rules apply: -* The result has all properties of o -* The result has all properties of yatta.value if they don't occur under the same property-name in o - - -```js - yatta.value = {newProperty : {Awesome : true }} - console.log(yatta.value.list[2] === 5) // true, old value list still exists. - console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten. -``` - - -Consider this case. - - -```js - yatta.value = {newProperty : { x : 4} } - console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined -``` - - -Did you notice that you always set immutable objects if you set properties like this? -Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val(). - -One last thing. You are only allowed to set properties like this `yatta.value = o`. -Yatta can't observe if you overwrite object references `yatta = "Awesome"`. - - -```js - w = yatta.value.newProperty - w = "Awesome" - console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome.. -``` - - -Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html) - - -```js }) } window.onload = init diff --git a/examples/IwcJson/index.js b/examples/IwcJson/index.js index e22a8d25..3d1dc693 100644 --- a/examples/IwcJson/index.js +++ b/examples/IwcJson/index.js @@ -42,89 +42,8 @@ function init(){ yatta.val('mutable_string').deleteText(0,1); // position, deletion length console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true - /** - You can omit the mutable - parameter. In that case the default will be used. - Initially the default is 'mutable'. You can set it like this: - */ - yatta.setMutableDefault('mutable'); - // or - yatta.setMutableDefault('immutable'); - yatta.val('new_string', "string"); - console.log(yatta.val('new_string') === "string"); // true - /** - yatta is chainable: - */ - yatta.val('a', 4).val('b',5); - console.log(yatta.val('a') === 4); // true - console.log(yatta.val('b') === 5); // true - - /** - You can alse set objects. - */ - yatta.val('object', {a : {b : "b"}, c : { d : 5 }}); - console.log(yatta.val('object').val('c').val('d') === 5); // true - - /** - Lists are always immutable. - */ - yatta.val('list', [1,2,3]); - console.log(yatta.val('list')[2] === 3); // true - - /** - But there is a much more convenient way! - */ - console.log(yatta.value.list[2] === 3) // true - yatta.value.list = [3,4,5] - console.log(yatta.val('list')[2] === 5) // true - yatta.value.object = {c : 4} - console.log(yatta.value.object.c === 4) // true - - /** - The downside is that you are only allowed to overwrite existing properties. - */ - yatta.value.newProperty = "Awesome" - console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined. - - /** - So, how do we create new properties? - */ - yatta.value = {newProperty : "Awesome"} - console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;) - - /** - This is stupid! I don't want to overwrite all my existing properties! - Very well.. The solution is that we merge yatta.value with the new assignment. - For example: assuming we want to overwrite yatta.value with some object o. - Then these two rules apply: - * The result has all properties of o - * The result has all properties of yatta.value if they don't occur under the same property-name in o - */ - yatta.value = {newProperty : {Awesome : true }} - console.log(yatta.value.list[2] === 5) // true, old value list still exists. - console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten. - - /** - Consider this case. - */ - yatta.value = {newProperty : { x : 4} } - console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined - - /** - Did you notice that you always set immutable objects if you set properties like this? - Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val(). - - One last thing. You are only allowed to set properties like this `yatta.value = o`. - Yatta can't observe if you overwrite object references `yatta = "Awesome"`. - */ - w = yatta.value.newProperty - w = "Awesome" - console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome.. - - /** - Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html) - */ }) } window.onload = init diff --git a/examples/Json/IwcJson.xml b/examples/Json/IwcJson.xml new file mode 100644 index 00000000..64b1e307 --- /dev/null +++ b/examples/Json/IwcJson.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + +

Collaborative Json Widget

+ ]]>
+
diff --git a/examples/Json/README.md b/examples/Json/README.md new file mode 100644 index 00000000..3b049929 --- /dev/null +++ b/examples/Json/README.md @@ -0,0 +1,177 @@ +## IWC + JSON Example +Here, I will give a short overview on how to use the IwcJson Framework in Role-SDK widgets. +First you have to include the following libraries in your widget file: +``` + + + + + + +``` +A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js) + + +```js +function init(){ + createIwcConnector(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. + + +```js + yatta = new JsonYatta(user_id, Connector); +``` + + +Add a integer-property like this + + +```js + yatta.val('x', 7); +``` + + +Get the value of property x like this + + +```js + console.log(yatta.val('x') === 7); // true +``` + + +A string property can be either mutable or immutable. + + +```js + yatta.val('mutable_string', "text", "mutable"); + yatta.val('immutable_string', "text", "immutable"); + + console.log(yatta.val('immutable_string') === "text"); // true + yatta.val('mutable_string').insertText(2,"XXX"); // position, string + yatta.val('mutable_string').deleteText(0,1); // position, deletion length + console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true +``` + + +You can omit the mutable - parameter. In that case the default will be used. +Initially the default is 'mutable'. You can set it like this: + + +```js + yatta.setMutableDefault('mutable'); + // or + yatta.setMutableDefault('immutable'); + + yatta.val('new_string', "string"); + console.log(yatta.val('new_string') === "string"); // true +``` + + +yatta is chainable: + + +```js + yatta.val('a', 4).val('b',5); + console.log(yatta.val('a') === 4); // true + console.log(yatta.val('b') === 5); // true +``` + + +You can alse set objects. + + +```js + yatta.val('object', {a : {b : "b"}, c : { d : 5 }}); + console.log(yatta.val('object').val('c').val('d') === 5); // true +``` + + +Lists are always immutable. + + +```js + yatta.val('list', [1,2,3]); + console.log(yatta.val('list')[2] === 3); // true +``` + + +But there is a much more convenient way! + + +```js + console.log(yatta.value.list[2] === 3) // true + yatta.value.list = [3,4,5] + console.log(yatta.val('list')[2] === 5) // true + yatta.value.object = {c : 4} + console.log(yatta.value.object.c === 4) // true +``` + + +The downside is that you are only allowed to overwrite existing properties. + + +```js + yatta.value.newProperty = "Awesome" + console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined. +``` + + +So, how do we create new properties? + + +```js + yatta.value = {newProperty : "Awesome"} + console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;) +``` + + +This is stupid! I don't want to overwrite all my existing properties! +Very well.. The solution is that we merge yatta.value with the new assignment. +For example: assuming we want to overwrite yatta.value with some object o. +Then these two rules apply: +* The result has all properties of o +* The result has all properties of yatta.value if they don't occur under the same property-name in o + + +```js + yatta.value = {newProperty : {Awesome : true }} + console.log(yatta.value.list[2] === 5) // true, old value list still exists. + console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten. +``` + + +Consider this case. + + +```js + yatta.value = {newProperty : { x : 4} } + console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined +``` + + +Did you notice that you always set immutable objects if you set properties like this? +Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val(). + +One last thing. You are only allowed to set properties like this `yatta.value = o`. +Yatta can't observe if you overwrite object references `yatta = "Awesome"`. + + +```js + w = yatta.value.newProperty + w = "Awesome" + console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome.. +``` + + +Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html) + + +```js + }) +} +window.onload = init +``` diff --git a/examples/Json/index.js b/examples/Json/index.js new file mode 100644 index 00000000..e22a8d25 --- /dev/null +++ b/examples/Json/index.js @@ -0,0 +1,130 @@ + +/** + ## IWC + JSON Example + Here, I will give a short overview on how to use the IwcJson Framework in Role-SDK widgets. + First you have to include the following libraries in your widget file: + ``` + + + + + + + ``` +A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js) + */ +function init(){ + createIwcConnector(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. + */ + yatta = new JsonYatta(user_id, Connector); + + /** + Add a integer-property like this + */ + yatta.val('x', 7); + + /** + Get the value of property x like this + */ + console.log(yatta.val('x') === 7); // true + + /** + A string property can be either mutable or immutable. + */ + yatta.val('mutable_string', "text", "mutable"); + yatta.val('immutable_string', "text", "immutable"); + + console.log(yatta.val('immutable_string') === "text"); // true + yatta.val('mutable_string').insertText(2,"XXX"); // position, string + yatta.val('mutable_string').deleteText(0,1); // position, deletion length + console.log(yatta.val('mutable_string').val() === "eXXXxt"); // true + + /** + You can omit the mutable - parameter. In that case the default will be used. + Initially the default is 'mutable'. You can set it like this: + */ + yatta.setMutableDefault('mutable'); + // or + yatta.setMutableDefault('immutable'); + + yatta.val('new_string', "string"); + console.log(yatta.val('new_string') === "string"); // true + + /** + yatta is chainable: + */ + yatta.val('a', 4).val('b',5); + console.log(yatta.val('a') === 4); // true + console.log(yatta.val('b') === 5); // true + + /** + You can alse set objects. + */ + yatta.val('object', {a : {b : "b"}, c : { d : 5 }}); + console.log(yatta.val('object').val('c').val('d') === 5); // true + + /** + Lists are always immutable. + */ + yatta.val('list', [1,2,3]); + console.log(yatta.val('list')[2] === 3); // true + + /** + But there is a much more convenient way! + */ + console.log(yatta.value.list[2] === 3) // true + yatta.value.list = [3,4,5] + console.log(yatta.val('list')[2] === 5) // true + yatta.value.object = {c : 4} + console.log(yatta.value.object.c === 4) // true + + /** + The downside is that you are only allowed to overwrite existing properties. + */ + yatta.value.newProperty = "Awesome" + console.log(yatta.value.newProperty !== "Awesome") // true, yatta.value.newProperty is undefined. + + /** + So, how do we create new properties? + */ + yatta.value = {newProperty : "Awesome"} + console.log(yatta.value.newProperty === "Awesome") // true, it's awesome ;) + + /** + This is stupid! I don't want to overwrite all my existing properties! + Very well.. The solution is that we merge yatta.value with the new assignment. + For example: assuming we want to overwrite yatta.value with some object o. + Then these two rules apply: + * The result has all properties of o + * The result has all properties of yatta.value if they don't occur under the same property-name in o + */ + yatta.value = {newProperty : {Awesome : true }} + console.log(yatta.value.list[2] === 5) // true, old value list still exists. + console.log(yatta.value.newProperty.Awesome === true) // true, newProperty is overwritten. + + /** + Consider this case. + */ + yatta.value = {newProperty : { x : 4} } + console.log(yatta.value.newProperty.Awesome == null) // true, newProperty was replaced, therefore it is now undefined + + /** + Did you notice that you always set immutable objects if you set properties like this? + Even if the default is 'mutable'. If you want to work with mutable objects you have to work with .val(). + + One last thing. You are only allowed to set properties like this `yatta.value = o`. + Yatta can't observe if you overwrite object references `yatta = "Awesome"`. + */ + w = yatta.value.newProperty + w = "Awesome" + console.log(yatta.value.newProperty !== "Awesome") // true, still not awesome.. + + /** + Please also read [JsonWrapper](https://rawgit.com/DadaMonad/Yatta/master/doc/class/JsonWrapper.html) + */ + }) +} +window.onload = init diff --git a/lib/.HistoryBuffer.coffee.kate-swp b/lib/.HistoryBuffer.coffee.kate-swp new file mode 100644 index 00000000..8b231b40 Binary files /dev/null and b/lib/.HistoryBuffer.coffee.kate-swp differ diff --git a/lib/Connectors/IwcConnector.coffee b/lib/Connectors/IwcConnector.coffee index 44b245a8..cc5734a1 100644 --- a/lib/Connectors/IwcConnector.coffee +++ b/lib/Connectors/IwcConnector.coffee @@ -35,18 +35,25 @@ createIwcConnector = (callback, initial_user_id)-> @iwcHandler = iwcHandler send_ = (o)=> - @send o + if Object.getOwnPropertyNames(@initialized).length isnt 0 + @send o @execution_listener.push send_ + @initialized = {} receiveHB = (json)=> - HB = json?.extras.HB + HB = json.extras.HB + him = json.extras.user this.engine.applyOpsCheckDouble HB + @initialized[him] = true iwcHandler["Yatta_push_HB_element"] = [receiveHB] + @sendIwcIntent "Yatta_get_HB_element", {} receive_ = (intent)=> o = intent.extras - @receive o + if @initialized[o.uid.creator]? # initialize first + @receive o + @iwcHandler["Yatta_new_operation"] = [receive_] if received_HB? @@ -55,6 +62,7 @@ createIwcConnector = (callback, initial_user_id)-> sendHistoryBuffer = ()=> json = HB : @yatta.getHistoryBuffer()._encode() + user : @yatta.getUserId() @sendIwcIntent "Yatta_push_HB_element", json @iwcHandler["Yatta_get_HB_element"] = [sendHistoryBuffer] @@ -90,19 +98,9 @@ createIwcConnector = (callback, initial_user_id)-> @duiClient.sendIntent(intent) - get_HB_intent = - action: "Yatta_get_HB_element" - component: "" - data: "" - dataType: "" - flags: ["PUBLISH_GLOBAL"] - extras: {} - send_get_HB_intent = ()-> - duiClient.sendIntent(get_HB_intent) init = ()-> - setTimeout send_get_HB_intent, 1000 proposed_user_id = null if initial_user_id? proposed_user_id = initial_user_id @@ -111,7 +109,7 @@ createIwcConnector = (callback, initial_user_id)-> proposed_user_id = Math.floor(Math.random()*1000000) callback IwcConnector, proposed_user_id - setTimeout init, (1000) + setTimeout init, 5000 undefined module.exports = createIwcConnector