diff --git a/build/browser/Connectors/IwcConnector.js b/build/browser/Connectors/IwcConnector.js index 08ba95b8..81dea56f 100644 --- a/build/browser/Connectors/IwcConnector.js +++ b/build/browser/Connectors/IwcConnector.js @@ -1,17 +1,25 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;or;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.types=u.types,this.engine=new n(this.HB,u.parser),this.connector=new e(this.engine,this.HB,u.execution_listener,this),i=new this.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.toJson=function(){return this.root_element.toJson()},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}(),e.exports=i,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.JsonYatta=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,a,s,c,l,p,f;this.HB=new r(t),c=o(this.HB),this.types=c.types,this.engine=new n(this.HB,c.parser),this.connector=new e(this.engine,this.HB,c.execution_listener,this),u=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_beginning"},void 0,void 0)),a=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_end"},u,void 0)),u.next_cl=a,u.execute(),a.execute(),s=new this.types.Word({creator:"_",op_number:"_"},u,a),this.HB.addOperation(s).execute(),f={creator:"_",op_number:"RM"},l={creator:"_",op_number:"_RM_beginning"},p={creator:"_",op_number:"_RM_end"},i=this.HB.addOperation(new this.types.Delimiter(l,void 0,p)).execute(),a=this.HB.addOperation(new this.types.Delimiter(p,i,void 0)).execute(),this.root_element=this.HB.addOperation(new this.types.ReplaceManager(void 0,f,i,a)).execute(),this.root_element.replace(s,{creator:"_",op_number:"Replaceable"})}return t.prototype.getRootElement=function(){return this.root_element.val()},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.getRootElement().val()},t.prototype.insertText=function(t,e){return this.getRootElement().insertText(t,e)},t.prototype.deleteText=function(t,e){return this.getRootElement().deleteText(t,e)},t.prototype.bind=function(t){return this.getRootElement().bind(t)},t.prototype.replaceText=function(t){return this.getRootElement().replaceText(t)},t}(),e.exports=i,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.TextYatta=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,a;if(null!=(null!=(o=this.event_listeners)?o[t]:void 0)){for(u=this.event_listeners[t],a=[],r=0,i=u.length;i>r;r++)n=u[r],a.push(n.call(this,t,e));return a}},e.prototype.setParent=function(t){return this.parent=t},e.prototype.getParent=function(){return this.parent},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)):!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),null!=this.parent&&1===this.deleted_by.length?this.parent.callEvent("delete",this):void 0},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,u,a;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(o=this.prev_cl)?o.validateSavedOperations():void 0)&&(null!=(u=this.next_cl)?u.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||e.isDeleted())&&!(e instanceof l.Delimiter)){for(;e.isDeleted()&&!(e instanceof l.Delimiter);)e=e.next_cl;for(;;){if(e instanceof l.Delimiter)break;if(0>=t&&!e.isDeleted())break;e=e.next_cl,e.isDeleted()||(t-=1)}}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,n){var r,i;return r=this.getLastOperation(),i=new a(e,this,n,r,r.next_cl),t.addOperation(i).execute()},n.prototype.val=function(){var t;return t=this.getLastOperation(),"function"==typeof t.val?t.val():void 0},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(a=this.getOperationByPosition(n),o=[],u=c=0;(r>=0?r>c:c>r)&&!(a instanceof s.Delimiter);u=r>=0?++c:--c){for(i=t.addOperation(new e(void 0,a)).execute(),a=a.next_cl;!(a instanceof s.Delimiter)&&a.isDeleted();)a=a.next_cl;o.push(i._encode())}return o},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.bind=function(t){var e;return e=this,t.value=this.val(),this.on("insert",function(n,r){var i,o,u,a;return u=r.getPosition(),i=function(t){return u>=t?t:t+=1},o=i(t.selectionStart),a=i(t.selectionEnd),t.value=e.val(),t.setSelectionRange(o,a)}),this.on("delete",function(n,r){var i,o,u,a;return u=r.getPosition(),i=function(t){return u>t?t:t-=1},o=i(t.selectionStart),a=i(t.selectionEnd),t.value=e.val(),t.setSelectionRange(o,a)}),t.onkeypress=function(n){var r,i,o,u;return r=null,r=null!=n.key?32===n.charCode?" ":13===n.keyCode?"\n":n.key:String.fromCharCode(n.keyCode),r.length>0?(u=Math.min(t.selectionStart,t.selectionEnd),i=Math.abs(t.selectionEnd-t.selectionStart),e.deleteText(u,i),e.insertText(u,r),o=u+r.length,t.setSelectionRange(o,o),n.preventDefault()):n.preventDefault()},t.onpaste=function(t){return t.preventDefault()},t.oncut=function(t){return t.preventDefault()},t.onkeydown=function(n){var r,i,o,u,a;if(u=Math.min(t.selectionStart,t.selectionEnd),i=Math.abs(t.selectionEnd-t.selectionStart),null!=n.keyCode&&8===n.keyCode){if(i>0)e.deleteText(u,i),t.setSelectionRange(u,u);else if(null!=n.ctrlKey&&n.ctrlKey){for(a=t.value,o=u,r=0,u>0&&(o--,r++);o>0&&" "!==a[o]&&"\n"!==a[o];)o--,r++;e.deleteText(o,u-o),t.setSelectionRange(o,o)}else e.deleteText(u-1,1);return n.preventDefault()}return null!=n.keyCode&&46===n.keyCode?(i>0?(e.deleteText(u,i),t.setSelectionRange(u,u)):(e.deleteText(u,1),t.setSelectionRange(u,u)),n.preventDefault()):void 0}},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 D="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(D);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(D);return n},U.find=U.detect=function(t,e,n){var r;return I(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 I=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):I(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 k=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=k(function(t,e,n){U.has(t,e)?t[e].push(n):t[e]=[n]}),U.indexBy=k(function(t,e,n){t[e]=n}),U.countBy=k(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])r;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.types=u.types,this.engine=new n(this.HB,u.parser),this.connector=new e(this.engine,this.HB,u.execution_listener,this),i=new this.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.toJson=function(){return this.root_element.toJson()},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}(),e.exports=i,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.JsonYatta=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,a,s,c,l,p,f;this.HB=new r(t),c=o(this.HB),this.types=c.types,this.engine=new n(this.HB,c.parser),this.connector=new e(this.engine,this.HB,c.execution_listener,this),u=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_beginning"},void 0,void 0)),a=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_end"},u,void 0)),u.next_cl=a,u.execute(),a.execute(),s=new this.types.Word({creator:"_",op_number:"_"},u,a),this.HB.addOperation(s).execute(),f={creator:"_",op_number:"RM"},l={creator:"_",op_number:"_RM_beginning"},p={creator:"_",op_number:"_RM_end"},i=this.HB.addOperation(new this.types.Delimiter(l,void 0,p)).execute(),a=this.HB.addOperation(new this.types.Delimiter(p,i,void 0)).execute(),this.root_element=this.HB.addOperation(new this.types.ReplaceManager(void 0,f,i,a)).execute(),this.root_element.replace(s,{creator:"_",op_number:"Replaceable"})}return t.prototype.getRootElement=function(){return this.root_element.val()},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.getRootElement().val()},t.prototype.insertText=function(t,e){return this.getRootElement().insertText(t,e)},t.prototype.deleteText=function(t,e){return this.getRootElement().deleteText(t,e)},t.prototype.bind=function(t){return this.getRootElement().bind(t)},t.prototype.replaceText=function(t){return this.getRootElement().replaceText(t)},t}(),e.exports=i,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.TextYatta=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,a;if(null!=(null!=(o=this.event_listeners)?o[t]:void 0)){for(u=this.event_listeners[t],a=[],r=0,i=u.length;i>r;r++)n=u[r],a.push(n.call(this,t,e));return a}},e.prototype.setParent=function(t){return this.parent=t},e.prototype.getParent=function(){return this.parent},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)):!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),null!=this.parent&&1===this.deleted_by.length?this.parent.callEvent("delete",this):void 0},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,u,a;if(null!=this.is_executed)return this;if(this.validateSavedOperations()){if((null!=(o=this.prev_cl)?o.validateSavedOperations():void 0)&&(null!=(u=this.next_cl)?u.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||e.isDeleted())&&!(e instanceof l.Delimiter)){for(;e.isDeleted()&&!(e instanceof l.Delimiter);)e=e.next_cl;for(;;){if(e instanceof l.Delimiter)break;if(0>=t&&!e.isDeleted())break;e=e.next_cl,e.isDeleted()||(t-=1)}}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,n){var r,i;return r=this.getLastOperation(),i=new a(e,this,n,r,r.next_cl),t.addOperation(i).execute()},n.prototype.val=function(){var t;return t=this.getLastOperation(),"function"==typeof t.val?t.val():void 0},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(a=this.getOperationByPosition(n),o=[],u=c=0;(r>=0?r>c:c>r)&&!(a instanceof s.Delimiter);u=r>=0?++c:--c){for(i=t.addOperation(new e(void 0,a)).execute(),a=a.next_cl;!(a instanceof s.Delimiter)&&a.isDeleted();)a=a.next_cl;o.push(i._encode())}return o},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.bind=function(t){var e;return e=this,t.value=this.val(),this.on("insert",function(n,r){var i,o,u,a;return u=r.getPosition(),i=function(t){return u>=t?t:t+=1},o=i(t.selectionStart),a=i(t.selectionEnd),t.value=e.val(),t.setSelectionRange(o,a)}),this.on("delete",function(n,r){var i,o,u,a;return u=r.getPosition(),i=function(t){return u>t?t:t-=1},o=i(t.selectionStart),a=i(t.selectionEnd),t.value=e.val(),t.setSelectionRange(o,a)}),t.onkeypress=function(n){var r,i,o,u;return r=null,r=null!=n.key?32===n.charCode?" ":13===n.keyCode?"\n":n.key:String.fromCharCode(n.keyCode),r.length>0?(u=Math.min(t.selectionStart,t.selectionEnd),i=Math.abs(t.selectionEnd-t.selectionStart),e.deleteText(u,i),e.insertText(u,r),o=u+r.length,t.setSelectionRange(o,o),n.preventDefault()):n.preventDefault()},t.onpaste=function(t){return t.preventDefault()},t.oncut=function(t){return t.preventDefault()},t.onkeydown=function(n){var r,i,o,u,a;if(u=Math.min(t.selectionStart,t.selectionEnd),i=Math.abs(t.selectionEnd-t.selectionStart),null!=n.keyCode&&8===n.keyCode){if(i>0)e.deleteText(u,i),t.setSelectionRange(u,u);else if(null!=n.ctrlKey&&n.ctrlKey){for(a=t.value,o=u,r=0,u>0&&(o--,r++);o>0&&" "!==a[o]&&"\n"!==a[o];)o--,r++;e.deleteText(o,u-o),t.setSelectionRange(o,o)}else e.deleteText(u-1,1);return n.preventDefault()}return null!=n.keyCode&&46===n.keyCode?(i>0?(e.deleteText(u,i),t.setSelectionRange(u,u)):(e.deleteText(u,1),t.setSelectionRange(u,u)),n.preventDefault()):void 0}},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 D="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(D);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(D);return n},U.find=U.detect=function(t,e,n){var r;return I(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 I=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):I(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 k=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=k(function(t,e,n){U.has(t,e)?t[e].push(n):t[e]=[n]}),U.indexBy=k(function(t,e,n){t[e]=n}),U.countBy=k(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 j=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):j(t,e,n):n.push(t)}),n)};U.flatten=function(t,e){return j(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 H=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)));H.prototype=t.prototype;var i=new H;H.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 R=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=R(t[s],e[s],n,r)););}else{for(var l in t)if(U.has(t,l)&&(s++,!(c=U.has(e,l)&&R(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 R(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 M={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};M.unescape=U.invert(M.escape);var S={escape:new RegExp("["+U.keys(M.escape).join("")+"]","g"),unescape:new RegExp("("+U.keys(M.unescape).join("|")+")","g")};U.each(["escape","unescape"],function(t){U[t]=function(e){return null==e?"":(""+e).replace(S[t],function(e){return M[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),F.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 A=/(.)^/,Y={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},P=/\\|'|\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||A).source,(n.interpolate||A).source,(n.evaluate||A).source].join("|")+"|$","g"),o=0,u="__p+='";t.replace(i,function(e,n,r,i,a){return u+=t.slice(o,a).replace(P,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 F=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],F.call(this,n)}}),B(["concat","join","slice"],function(t){var e=o[t];U.prototype[t]=function(){return F.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.coffee.map b/build/node/Connectors/IwcConnector.coffee.map deleted file mode 100755 index 14552ec9..00000000 --- a/build/node/Connectors/IwcConnector.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Connectors/IwcConnector.coffee","names":[],"mappings":"","sources":["Connectors/IwcConnector.coffee"],"sourcesContent":["\n#\n# @param {Function} callback The callback is called when the connector is initialized.\n#\ncreateIwcConnector = (callback)->\n iwcHandler = {}\n duiClient = new DUIClient()\n #@duiClient = new iwc.Client()\n duiClient.connect (intent)->\n #console.log \"intent received iwc: #{JSON.stringify(intent)}\"\n #console.log \"#{JSON.stringify(@iwcHandler)}\"\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 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 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 extras: {}\n\n init = ()->\n duiClient.sendIntent(get_HB_intent)\n\n is_initialized = false\n receiveHB = (json)->\n proposed_user_id = duiClient.getIwcClient()._componentName\n received_HB = json?.extras.HB\n if not is_initialized\n is_initialized = true\n callback IwcConnector, proposed_user_id\n iwcHandler[\"Yatta_push_HB_element\"] = [receiveHB]\n setTimeout receiveHB, 0\n\n setTimeout init, (Math.random()*0)\n\n undefined\nmodule.exports = createIwcConnector\nwindow?.createConnector = createIwcConnector\n\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Connectors/IwcConnector.js b/build/node/Connectors/IwcConnector.js index 9de10d68..b9cd2af0 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;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)},module.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=t)}).call(this); +(function(){var t;t=function(t,n){var e,i,r,o,u,a;return null!=n&&(a=n.iwcHandler),o={},i=new DUIClient,i.connect(function(t){var n;return null!=(n=o[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),i.initOK(),u=null,e=function(){function t(t,n,e,r){var a,s,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 n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=t)}).call(this); //# sourceMappingURL=../Connectors/IwcConnector.js.map \ No newline at end of file diff --git a/build/node/Connectors/IwcConnector.js.map b/build/node/Connectors/IwcConnector.js.map index 81977b9b..5bbb761b 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,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,MAKnB,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,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\n\n\nmodule.exports = createIwcConnector\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.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,EAAA,QAAG,OAAA,IACY,EAAkB,EAA9B,YACH,KACA,EAAgB,GAAA,WAEhB,EAAU,QAAQ,SAAC,GACjB,GAAA,EAIA,iCAJ2B,IAAI,SAAC,SAC9B,YAAW,iBACT,GAAE,IACF,KACD,MAAA,EACD,EAAe,GADjB,SAGF,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,WAEL,GAAA,SAAA,GAAmB,KAAK,MAAoB,IAAd,KAAK,UACnC,EAAS,EAAc,QAEzB,YAAW,EAAM,MAKnB,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,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, options)->\n if options?\n {iwcHandler: userIwcHandler} = options\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 if userIwcHandler?\n userIwcHandler intent\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 = 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\n\n\nmodule.exports = createIwcConnector\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.createIwcConnector = createIwcConnector\n\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Connectors/TestConnector.coffee.map b/build/node/Connectors/TestConnector.coffee.map deleted file mode 100755 index ce39556d..00000000 --- a/build/node/Connectors/TestConnector.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Connectors/TestConnector.coffee","names":[],"mappings":"","sources":["Connectors/TestConnector.coffee"],"sourcesContent":["\n_ = require \"underscore\"\n\nmodule.exports = (user_list)->\n\n #\n # A trivial Connector that simulates network delay.\n #\n class TestConnector\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)->\n send_ = (o)=>\n @send o\n @execution_listener.push send_\n\n @applied_operations = []\n appliedOperationsListener = (o)=>\n @applied_operations.push o\n @execution_listener.push appliedOperationsListener\n if not (user_list?.length is 0)\n @engine.applyOps user_list[0].getHistoryBuffer()._encode()\n\n @unexecuted = {}\n\n #\n # This engine applied operations in a specific order.\n # Get the ops in the right order.\n #\n getOpsInExecutionOrder: ()->\n @applied_operations\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 user in user_list\n if user.getUserId() isnt @HB.getUserId()\n user.getConnector().receive(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 @unexecuted[o.uid.creator] ?= []\n @unexecuted[o.uid.creator].push o\n\n #\n # Flush one operation from the line of a specific user.\n #\n flushOne: (user)->\n if @unexecuted[user]?.length > 0\n @engine.applyOp @unexecuted[user].shift()\n\n #\n # Flush one operation on a random line.\n #\n flushOneRandom: ()->\n @flushOne (_.random 0, (user_list.length-1))\n\n #\n # Flush all operations on every line.\n #\n flushAll: ()->\n for n,ops of @unexecuted\n @engine.applyOps ops\n @unexecuted = {}\n\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Frameworks/JsonYatta.coffee.map b/build/node/Frameworks/JsonYatta.coffee.map deleted file mode 100755 index f0dfa358..00000000 --- a/build/node/Frameworks/JsonYatta.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Frameworks/JsonYatta.coffee","names":[],"mappings":"","sources":["Frameworks/JsonYatta.coffee"],"sourcesContent":["\njson_types_uninitialized = require \"../Types/JsonTypes\"\nHistoryBuffer = require \"../HistoryBuffer\"\nEngine = require \"../Engine\"\n\n#\n# Framework for Json data-structures.\n# Known values that are supported:\n# * String\n# * Integer\n# * Array\n#\nclass JsonYatta\n\n #\n # @param {String} user_id Unique id of the peer.\n # @param {Connector} Connector the connector class.\n #\n constructor: (user_id, Connector)->\n @HB = new HistoryBuffer user_id\n json_types = json_types_uninitialized @HB\n @engine = new Engine @HB, json_types.parser\n @connector = new Connector @engine, @HB, json_types.execution_listener, @\n\n first_word = new json_types.types.JsonType @HB.getReservedUniqueIdentifier()\n @HB.addOperation(first_word).execute()\n @root_element = first_word\n\n #\n # @result JsonType\n #\n getRootElement: ()->\n @root_element\n\n #\n # @see Engine\n #\n getEngine: ()->\n @engine\n\n #\n # Get the initialized connector.\n #\n getConnector: ()->\n @connector\n\n #\n # @see HistoryBuffer\n #\n getHistoryBuffer: ()->\n @HB\n\n #\n # @see JsonType.setMutableDefault\n #\n setMutableDefault: (mutable)->\n @root_element.setMutableDefault(mutable)\n\n #\n # Get the UserId from the HistoryBuffer object.\n # In most cases this will be the same as the user_id value with which\n # JsonYatta was initialized (Depending on the HistoryBuffer implementation).\n #\n getUserId: ()->\n @HB.getUserId()\n\n #\n # @see JsonType.val\n #\n val : (name, content, mutable)->\n @root_element.val(name, content, mutable)\n\n #\n # @see JsonType.value\n #\n Object.defineProperty JsonYatta.prototype, 'value',\n get : -> @root_element.value\n set : (o)->\n if o.constructor is {}.constructor\n for o_name,o_obj of o\n @val(o_name, o_obj, 'immutable')\n else\n throw new Error \"You must only set Object values!\"\nwindow?.JsonYatta = JsonYatta\nmodule.exports = JsonYatta\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Frameworks/TextYatta.coffee.map b/build/node/Frameworks/TextYatta.coffee.map deleted file mode 100755 index fd3403d8..00000000 --- a/build/node/Frameworks/TextYatta.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Frameworks/TextYatta.coffee","names":[],"mappings":"","sources":["Frameworks/TextYatta.coffee"],"sourcesContent":["\ntext_types_uninitialized = require \"../Types/TextTypes\"\nHistoryBuffer = require \"../HistoryBuffer\"\nEngine = require \"../Engine\"\n\n#\n# Framework for Text Datastructures.\n#\nclass TextYatta\n\n #\n # @param {String} user_id Uniqe user id that defines this peer.\n # @param {Connector} Connector The connector defines how you connect to the other peers.\n #\n constructor: (user_id, Connector)->\n @HB = new HistoryBuffer user_id\n text_types = text_types_uninitialized @HB\n @engine = new Engine @HB, text_types.parser\n @connector = new Connector @engine, @HB, text_types.execution_listener\n\n first_word = new text_types.types.Word undefined\n @HB.addOperation(first_word).execute()\n @root_element = first_word\n\n #\n # @result Word\n #\n getRootElement: ()->\n @root_element\n\n #\n # @see Engine\n #\n getEngine: ()->\n @engine\n\n #\n # Get the initialized connector.\n #\n getConnector: ()->\n @connector\n\n #\n # @see HistoryBuffer\n #\n getHistoryBuffer: ()->\n @HB\n\n #\n # Get the UserId from the HistoryBuffer object.\n # In most cases this will be the same as the user_id value with which\n # JsonYatta was initialized (Depending on the HistoryBuffer implementation).\n #\n getUserId: ()->\n @HB.getUserId()\n\n #\n # @see JsonType.val\n #\n val: ()->\n @root_element.val()\n\n #\n # @see Word.insertText\n #\n insertText: (pos, content)->\n @root_element.insertText pos, content\n\n #\n # @see Word.deleteText\n #\n deleteText: (pos, length)->\n @root_element.deleteText pos, length\n\n #\n # @see Word.replaceText\n #\n replaceText: (text)->\n @root_element.replaceText text\n\n\nmodule.exports = TextYatta\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Types/BasicTypes.coffee.map b/build/node/Types/BasicTypes.coffee.map deleted file mode 100755 index 1ae7af8c..00000000 --- a/build/node/Types/BasicTypes.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Types/BasicTypes.coffee","names":[],"mappings":"","sources":["Types/BasicTypes.coffee"],"sourcesContent":["module.exports = (HB)->\n # @see Engine.parse\n parser = {}\n execution_listener = []\n\n #\n # A generic interface to operations.\n #\n # An operation has the following methods:\n # _encode: encodes an operation (needed only if instance of this operation is sent).\n # execute: execute the effects of this operations. Good examples are Insert-type and AddName-type\n # val: in the case that the operation holds a value\n #\n # Furthermore an encodable operation has a parser.\n #\n class Operation\n\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @see HistoryBuffer.getNextOperationIdentifier\n #\n constructor: (uid)->\n if not uid?\n uid = HB.getNextOperationIdentifier()\n {\n 'creator': @creator\n 'op_number' : @op_number\n } = uid\n\n #\n # Add an event listener. It depends on the operation which events are supported.\n # @param {String} event Name of the event.\n # @param {Function} f f is executed in case the event fires.\n #\n on: (event, f)->\n @event_listeners ?= {}\n @event_listeners[event] ?= []\n @event_listeners[event].push f\n\n #\n # Fire an event.\n # TODO: Do something with timeouts. You don't want this to fire for every operation (e.g. insert).\n #\n callEvent: (event, args)->\n if @event_listeners[event]?\n for f in @event_listeners[event]\n f.call @, event, args\n\n #\n # Set the parent of this operation.\n #\n setParent: (o)->\n @parent = o\n\n #\n # Computes a unique identifier (uid) that identifies this operation.\n #\n getUid: ()->\n { 'creator': @creator, 'op_number': @op_number }\n\n #\n # @private\n # Notify the all the listeners.\n #\n execute: ()->\n @is_executed = true\n for l in execution_listener\n l @_encode()\n @\n\n #\n # @private\n # Operations may depend on other operations (linked lists, etc.).\n # The saveOperation and validateSavedOperations methods provide\n # an easy way to refer to these operations via an uid or object reference.\n #\n # For example: We can create a new Delete operation that deletes the operation $o like this\n # - var d = new Delete(uid, $o); or\n # - var d = new Delete(uid, $o.getUid());\n # Either way we want to access $o via d.deletes. In the second case validateSavedOperations must be called first.\n #\n # @overload saveOperation(name, op_uid)\n # @param {String} name The name of the operation. After validating (with validateSavedOperations) the instantiated operation will be accessible via this[name].\n # @param {Object} op_uid A uid that refers to an operation\n # @overload saveOperation(name, op)\n # @param {String} name The name of the operation. After calling this function op is accessible via this[name].\n # @param {Operation} op An Operation object\n #\n saveOperation: (name, op)->\n\n #\n # Every instance of $Operation must have an $execute function.\n # We use duck-typing to check if op is instantiated since there\n # could exist multiple classes of $Operation\n #\n if op?.execute?\n # is instantiated\n @[name] = op\n else if op?\n # not initialized. Do it when calling $validateSavedOperations()\n @unchecked ?= {}\n @unchecked[name] = op\n\n #\n # @private\n # After calling this function all not instantiated operations will be accessible.\n # @see Operation.saveOperation\n #\n # @return [Boolean] Whether it was possible to instantiate all operations.\n #\n validateSavedOperations: ()->\n uninstantiated = {}\n success = @\n for name, op_uid of @unchecked\n op = HB.getOperation op_uid\n if op\n @[name] = op\n else\n uninstantiated[name] = op_uid\n success = false\n delete @unchecked\n if not success\n @unchecked = uninstantiated\n success\n\n\n\n #\n # A simple Delete-type operation that deletes an Insert-type operation.\n #\n class Delete extends Operation\n\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @param {Object} deletes UID or reference of the operation that this to be deleted.\n #\n constructor: (uid, deletes)->\n @saveOperation 'deletes', deletes\n super uid\n\n #\n # @private\n # Convert all relevant information of this operation to the json-format.\n # This result can be sent to other clients.\n #\n _encode: ()->\n {\n 'type': \"Delete\"\n 'uid': @getUid()\n 'deletes': @deletes.getUid()\n }\n\n #\n # @private\n # Apply the deletion.\n #\n execute: ()->\n if @validateSavedOperations()\n @deletes.applyDelete @\n super\n @\n else\n false\n\n #\n # Define how to parse Delete operations.\n #\n parser['Delete'] = (o)->\n {\n 'uid' : uid\n 'deletes': deletes_uid\n } = o\n new Delete uid, deletes_uid\n\n #\n # A simple insert-type operation.\n #\n # An insert operation is always positioned between two other insert operations.\n # Internally this is realized as associative lists, whereby each insert operation has a predecessor and a successor.\n # For the sake of efficiency we maintain two lists:\n # - The short-list (abbrev. sl) maintains only the operations that are not deleted\n # - The complete-list (abbrev. cl) maintains all operations\n #\n class Insert extends Operation\n\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @param {Operation} prev_cl The predecessor of this operation in the complete-list (cl)\n # @param {Operation} next_cl The successor of this operation in the complete-list (cl)\n #\n # @see HistoryBuffer.getNextOperationIdentifier\n #\n constructor: (uid, prev_cl, next_cl, origin)->\n @saveOperation 'prev_cl', prev_cl\n @saveOperation 'next_cl', next_cl\n if origin?\n @saveOperation 'origin', origin\n else\n @saveOperation 'origin', prev_cl\n super uid\n\n #\n # @private\n #\n applyDelete: (o)->\n @deleted_by ?= []\n @deleted_by.push o\n\n #\n # If isDeleted() is true this operation won't be maintained in the sl\n #\n isDeleted: ()->\n @deleted_by?.length > 0\n\n #\n # @private\n # The amount of positions that $this operation was moved to the right.\n #\n getDistanceToOrigin: ()->\n d = 0\n o = @prev_cl\n while true\n if @origin is o\n break\n d++\n #TODO: delete this\n if @ is @prev_cl\n throw new Error \"this should not happen ;) \"\n o = o.prev_cl\n d\n\n #\n # @private\n # Update the short list\n # TODO (Unused)\n update_sl: ()->\n o = @prev_cl\n update: (dest_cl,dest_sl)->\n while true\n if o.isDeleted()\n o = o[dest_cl]\n else\n @[dest_sl] = o\n\n break\n update \"prev_cl\", \"prev_sl\"\n update \"next_cl\", \"prev_sl\"\n\n\n\n #\n # @private\n # Include this operation in the associative lists.\n #\n execute: ()->\n if @is_executed?\n return @\n if not @validateSavedOperations()\n return false\n else\n if @prev_cl?.validateSavedOperations() and @next_cl?.validateSavedOperations() and @prev_cl.next_cl isnt @\n distance_to_origin = 0\n o = @prev_cl.next_cl\n i = 0\n # $this has to find a unique position between origin and the next known character\n # case 1: $origin equals $o.origin: the $creator parameter decides if left or right\n # let $OL= [o1,o2,o3,o4], whereby $this is to be inserted between o1 and o4\n # o2,o3 and o4 origin is 1 (the position of o2)\n # there is the case that $this.creator < o2.creator, but o3.creator < $this.creator\n # then o2 knows o3. Since on another client $OL could be [o1,o3,o4] the problem is complex\n # therefore $this would be always to the right of o3\n # case 2: $origin < $o.origin\n # if current $this insert_position > $o origin: $this ins\n # else $insert_position will not change (maybe we encounter case 1 later, then this will be to the right of $o)\n # case 3: $origin > $o.origin\n # $this insert_position is to the left of $o (forever!)\n while true\n if not o?\n # TODO: Debugging\n console.log JSON.stringify @prev_cl.getUid()\n console.log JSON.stringify @next_cl.getUid()\n if o isnt @next_cl\n # $o happened concurrently\n if o.getDistanceToOrigin() is i\n # case 1\n if o.creator < @creator\n @prev_cl = o\n distance_to_origin = i + 1\n else\n # nop\n else if o.getDistanceToOrigin() < i\n # case 2\n if i - distance_to_origin <= o.getDistanceToOrigin()\n @prev_cl = o\n distance_to_origin = i + 1\n else\n #nop\n else\n # case 3\n break\n i++\n o = o.next_cl\n else\n # $this knows that $o exists,\n break\n # now reconnect everything\n @next_cl = @prev_cl.next_cl\n @prev_cl.next_cl = @\n @next_cl.prev_cl = @\n super # notify the execution_listeners\n @\n\n #\n # Defines an object that is cannot be changed. You can use this to set an immutable string, or a number.\n #\n class ImmutableObject extends Insert\n\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @param {Object} content\n #\n constructor: (uid, @content, prev, next, origin)->\n super uid, prev, next, origin\n\n #\n # @return [String] The content of this operation.\n #\n val : ()->\n @content\n\n #\n # Encode this operation in such a way that it can be parsed by remote peers.\n #\n _encode: ()->\n json = {\n 'type': \"ImmutableObject\"\n 'uid' : @getUid()\n 'content' : @content\n }\n if @prev_cl?\n json['prev'] = @prev_cl.getUid()\n if @next_cl?\n json['next'] = @next_cl.getUid()\n if @origin? and @origin isnt @prev_cl\n json[\"origin\"] = @origin.getUid()\n json\n\n parser['ImmutableObject'] = (json)->\n {\n 'uid' : uid\n 'content' : content\n 'prev': prev\n 'next': next\n 'origin' : origin\n } = json\n new ImmutableObject uid, content, prev, next, origin\n\n #\n # A delimiter is placed at the end and at the beginning of the associative lists.\n # This is necessary in order to have a beginning and an end even if the content\n # of the Engine is empty.\n #\n class Delimiter extends Operation\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @param {Operation} prev_cl The predecessor of this operation in the complete-list (cl)\n # @param {Operation} next_cl The successor of this operation in the complete-list (cl)\n #\n # @see HistoryBuffer.getNextOperationIdentifier\n #\n constructor: (uid, prev_cl, next_cl, origin)->\n @saveOperation 'prev_cl', prev_cl\n @saveOperation 'next_cl', next_cl\n @saveOperation 'origin', prev_cl\n super uid\n\n #\n # If isDeleted() is true this operation won't be maintained in the sl\n #\n isDeleted: ()->\n false\n\n #\n # @private\n #\n execute: ()->\n if @unchecked?['next_cl']?\n super\n else if @unchecked?['prev_cl']\n if @validateSavedOperations()\n if @prev_cl.next_cl?\n throw new Error \"Probably duplicated operations\"\n @prev_cl.next_cl = @\n delete @prev_cl.unchecked.next_cl\n super\n else\n false\n else if @prev_cl? and not @prev_cl.next_cl?\n delete @prev_cl.unchecked.next_cl\n @prev_cl.next_cl = @\n else if @prev_cl? or @next_cl?\n super\n else\n throw new Error \"Delimiter is unsufficient defined!\"\n\n #\n # @private\n #\n _encode: ()->\n {\n 'type' : \"Delimiter\"\n 'uid' : @getUid()\n 'prev' : @prev_cl?.getUid()\n 'next' : @next_cl?.getUid()\n }\n\n parser['Delimiter'] = (json)->\n {\n 'uid' : uid\n 'prev' : prev\n 'next' : next\n } = json\n new Delimiter uid, prev, next\n\n # This is what this module exports after initializing it with the HistoryBuffer\n {\n 'types' :\n 'Delete' : Delete\n 'Insert' : Insert\n 'Delimiter': Delimiter\n 'Operation': Operation\n 'ImmutableObject' : ImmutableObject\n 'parser' : parser\n 'execution_listener' : execution_listener\n }\n\n\n\n\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Types/JsonTypes.coffee.map b/build/node/Types/JsonTypes.coffee.map deleted file mode 100755 index 97662532..00000000 --- a/build/node/Types/JsonTypes.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Types/JsonTypes.coffee","names":[],"mappings":"","sources":["Types/JsonTypes.coffee"],"sourcesContent":["text_types_uninitialized = require \"./TextTypes\"\n\nmodule.exports = (HB)->\n text_types = text_types_uninitialized HB\n types = text_types.types\n parser = text_types.parser\n\n createJsonWrapper = (_jsonType)->\n\n #\n # A JsonWrapper was intended to be a convenient wrapper for the JsonType.\n # But it can make things more difficult than they are.\n # @see JsonType\n #\n # @example create a JsonWrapper\n # # You get a JsonWrapper from a JsonType by calling\n # w = yatta.value\n #\n # It creates Javascripts -getter and -setter methods for each property that JsonType maintains.\n # @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty\n #\n # @example Getter Example\n # # you can access the x property of yatta by calling\n # w.x\n # # instead of\n # yatta.val('x')\n #\n # @note You can only overwrite existing values! Setting a new property won't have any effect!\n #\n # @example Setter Example\n # # you can set an existing x property of yatta by calling\n # w.x = \"text\"\n # # instead of\n # yatta.val('x', \"text\")\n #\n # In order to set a new property you have to overwrite an existing property.\n # Therefore the JsonWrapper supports a special feature that should make things more convenient\n # (we can argue about that, use the JsonType if you don't like it ;).\n # If you overwrite an object property of the JsonWrapper with a new object, it will result in a merged version of the objects.\n # Let w.p the property that is to be overwritten and o the new value. E.g. w.p = o\n # * The result has all properties of o\n # * The result has all properties of w.p if they don't occur under the same property-name in o.\n #\n # @example Conflict Example\n # yatta.value = {a : \"string\"}\n # w = yatta.value\n # console.log(w) # {a : \"string\"}\n # w.a = {a : {b : \"string\"}}\n # console.log(w) # {a : {b : \"String\"}}\n # w.a = {a : {c : 4}}\n # console.log(w) # {a : {b : \"String\", c : 4}}\n #\n # @example Common Pitfalls\n # w = yatta.value\n # # Setting a new property\n # w.newProperty = \"Awesome\"\n # console.log(w.newProperty == \"Awesome\") # false, w.newProperty is undefined\n # # overwrite the w object\n # w = {newProperty : \"Awesome\"}\n # console.log(w.newProperty == \"Awesome\") # true!, but ..\n # console.log(yatta.value.newProperty == \"Awesome\") # false, you are only allowed to set properties!\n # # The solution\n # yatta.value = {newProperty : \"Awesome\"}\n # console.log(w.newProperty == \"Awesome\") # true!\n #\n class JsonWrapper\n\n #\n # @param {JsonType} jsonType Instance of the JsonType that this class wrappes.\n #\n constructor: (jsonType)->\n for name, obj of jsonType.map\n do (name, obj)->\n Object.defineProperty JsonWrapper.prototype, name,\n get : ->\n x = obj.val()\n if x instanceof JsonType\n createJsonWrapper x\n else if x instanceof types.ImmutableObject\n x.val()\n else\n x\n set : (o)->\n if o.constructor is {}.constructor\n overwrite = jsonType.val(name)\n for o_name,o_obj of o\n overwrite.val(o_name, o_obj, 'immutable')\n else\n jsonType.val(name, o, 'immutable')\n enumerable: true\n configurable: false\n new JsonWrapper _jsonType\n\n #\n # Manages Object-like values.\n #\n class JsonType extends types.MapManager\n\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @param {Object} initial_value Create this operation with an initial value.\n # @param {String|Boolean} Whether the initial_value should be created as mutable. (Optional - see setMutableDefault)\n #\n constructor: (uid, initial_value, mutable)->\n super uid\n if initial_value?\n if typeof initial_value isnt \"object\"\n throw new Error \"The initial value of JsonTypes must be of type Object! (current type: #{typeof initial_value})\"\n for name,o of initial_value\n @val name, o, mutable\n\n #\n # Whether the default is 'mutable' (true) or 'immutable' (false)\n #\n mutable_default:\n true\n\n #\n # Set if the default is 'mutable' or 'immutable'\n # @param {String|Boolean} mutable Set either 'mutable' / true or 'immutable' / false\n setMutableDefault: (mutable)->\n if mutable is true or mutable is 'mutable'\n JsonType.prototype.mutable_default = true\n else if mutable is false or mutable is 'immutable'\n JsonType.prototype.mutable_default = false\n else\n throw new Error 'Set mutable either \"mutable\" or \"immutable\"!'\n 'OK'\n\n #\n # @overload val()\n # Get this as a Json object.\n # @return [Json]\n #\n # @overload val(name)\n # Get value of a property.\n # @param {String} name Name of the object property.\n # @return [JsonType|Word|String|Object] Depending on the value of the property. If mutable it will return a Operation-type object, if immutable it will return String/Object.\n #\n # @overload val(name, content)\n # Set a new property.\n # @param {String} name Name of the object property.\n # @param {Object|String} content Content of the object property.\n # @return [JsonType] This object. (supports chaining)\n #\n val: (name, content, mutable)->\n if typeof name is 'object'\n # Special case. First argument is an object. Then the second arg is mutable.\n # Keep that in mind when reading the following..\n for o_name,o of name\n @val(o_name,o,content)\n @\n else if name? and content?\n if mutable?\n if mutable is true or mutable is 'mutable'\n mutable = true\n else\n mutable = false\n else\n mutable = @mutable_default\n if typeof content is 'function'\n @ # Just do nothing\n else if ((not mutable) or typeof content is 'number') and content.constructor isnt Object\n obj = HB.addOperation(new types.ImmutableObject undefined, content).execute()\n super name, obj\n else\n if typeof content is 'string'\n word = HB.addOperation(new types.Word undefined).execute()\n word.insertText 0, content\n super name, word\n else if content.constructor is Object\n json = HB.addOperation(new JsonType undefined, content, mutable).execute()\n super name, json\n else\n throw new Error \"You must not set #{typeof content}-types in collaborative Json-objects!\"\n else\n super name, content\n\n Object.defineProperty JsonType.prototype, 'value',\n get : -> createJsonWrapper @\n set : (o)->\n if o.constructor is {}.constructor\n for o_name,o_obj of o\n @val(o_name, o_obj, 'immutable')\n else\n throw new Error \"You must only set Object values!\"\n\n #\n # @private\n #\n _encode: ()->\n {\n 'type' : \"JsonType\"\n 'uid' : @getUid()\n }\n\n parser['JsonType'] = (json)->\n {\n 'uid' : uid\n } = json\n new JsonType uid\n\n\n\n\n types['JsonType'] = JsonType\n\n text_types\n\n\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Types/StructuredTypes.coffee.map b/build/node/Types/StructuredTypes.coffee.map deleted file mode 100755 index ecb02e1c..00000000 --- a/build/node/Types/StructuredTypes.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Types/StructuredTypes.coffee","names":[],"mappings":"","sources":["Types/StructuredTypes.coffee"],"sourcesContent":["basic_types_uninitialized = require \"./BasicTypes\"\n\nmodule.exports = (HB)->\n basic_types = basic_types_uninitialized HB\n types = basic_types.types\n parser = basic_types.parser\n\n #\n # Manages map like objects. E.g. Json-Type and XML attributes.\n #\n class MapManager extends types.Operation\n\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n #\n constructor: (uid)->\n @map = {}\n super uid\n\n #\n # @see JsonTypes.val\n #\n val: (name, content)->\n if content?\n if not @map[name]?\n HB.addOperation(new AddName undefined, @, name).execute()\n @map[name].replace content\n @\n else if name?\n obj = @map[name]?.val()\n if obj instanceof types.ImmutableObject\n obj.val()\n else\n obj\n else\n result = {}\n for name,o of @map\n obj = o.val()\n if obj instanceof types.ImmutableObject or obj instanceof MapManager\n obj = obj.val()\n result[name] = obj\n result\n\n #\n # When a new property in a map manager is created, then the uids of the inserted Operations\n # must be unique (think about concurrent operations). Therefore only an AddName operation is allowed to\n # add a property in a MapManager. If two AddName operations on the same MapManager name happen concurrently\n # only one will AddName operation will be executed.\n #\n class AddName extends types.Operation\n\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @param {Object} map_manager Uid or reference to the MapManager.\n # @param {String} name Name of the property that will be added.\n #\n constructor: (uid, map_manager, @name)->\n @saveOperation 'map_manager', map_manager\n super uid\n\n #\n # If map_manager doesn't have the property name, then add it.\n # The ReplaceManager that is being written on the property is unique\n # in such a way that if AddName is executed (from another peer) it will\n # always have the same result (ReplaceManager, and its beginning and end are the same)\n #\n execute: ()->\n if not @validateSavedOperations()\n return false\n else\n uid_r = @map_manager.getUid()\n uid_r.op_number = \"_#{uid_r.op_number}_RM_#{@name}\"\n if not HB.getOperation(uid_r)?\n uid_beg = @map_manager.getUid()\n uid_beg.op_number = \"_#{uid_beg.op_number}_RM_#{@name}_beginning\"\n uid_end = @map_manager.getUid()\n uid_end.op_number = \"_#{uid_end.op_number}_RM_#{@name}_end\"\n beg = HB.addOperation(new types.Delimiter uid_beg, undefined, uid_end).execute()\n end = HB.addOperation(new types.Delimiter uid_end, beg, undefined).execute()\n #beg.execute()\n @map_manager.map[@name] = HB.addOperation(new ReplaceManager undefined, uid_r, beg, end).execute()\n super\n\n #\n # Encode this operation in such a way that it can be parsed by remote peers.\n #\n _encode: ()->\n {\n 'type' : \"AddName\"\n 'uid' : @getUid()\n 'map_manager' : @map_manager.getUid()\n 'name' : @name\n }\n\n parser['AddName'] = (json)->\n {\n 'map_manager' : map_manager\n 'uid' : uid\n 'name' : name\n } = json\n new AddName uid, map_manager, name\n\n #\n # Manages a list of Insert-type operations.\n #\n class ListManager extends types.Insert\n\n #\n # A ListManager maintains a non-empty list that has a beginning and an end (both Delimiters!)\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @param {Delimiter} beginning Reference or Object.\n # @param {Delimiter} end Reference or Object.\n constructor: (uid, beginning, end, prev, next, origin)->\n if beginning? and end?\n @saveOperation 'beginning', beginning\n @saveOperation 'end', end\n else\n @beginning = HB.addOperation new types.Delimiter undefined, undefined, undefined\n @end = HB.addOperation new types.Delimiter undefined, @beginning, undefined\n @beginning.next_cl = @end\n @beginning.execute()\n @end.execute()\n super uid, prev, next, origin\n\n\n # Get the element previous to the delemiter at the end\n getLastOperation: ()->\n @end.prev_cl\n\n # similar to the above\n getFirstOperation: ()->\n @beginning.next_cl\n\n # Transforms the the list to an array\n # Doesn't return left-right delimiter.\n toArray: ()->\n o = @beginning.next_cl\n result = []\n while o isnt @end\n result.push o\n o = o.next_cl\n result\n\n #\n # Retrieves the x-th not deleted element.\n #\n getOperationByPosition: (position)->\n o = @beginning.next_cl\n if position > 0\n while true\n o = o.next_cl\n if not o.isDeleted()\n position -= 1\n if position is 0\n break\n if o instanceof types.Delimiter\n throw new Error \"position parameter exceeded the length of the document!\"\n o\n\n #\n # Adds support for replace. The ReplaceManager manages Replaceable operations.\n # Each Replaceable holds a value that is now replaceable.\n #\n # The Word-type has implemented support for replace\n # @see Word\n #\n class ReplaceManager extends ListManager\n #\n # @param {Operation} initial_content Initialize this with a Replaceable that holds the initial_content.\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n # @param {Delimiter} beginning Reference or Object.\n # @param {Delimiter} end Reference or Object.\n constructor: (initial_content, uid, beginning, end, prev, next, origin)->\n super uid, beginning, end, prev, next, origin\n if initial_content?\n @replace initial_content\n\n #\n # Replace the existing word with a new word.\n #\n replace: (content)->\n o = @getLastOperation()\n op = new Replaceable content, @, undefined, o, o.next_cl\n HB.addOperation(op).execute()\n\n #\n # Get the value of this Word\n # @return {String}\n #\n val: ()->\n o = @getLastOperation()\n if o instanceof types.Delimiter\n throw new Error \"dtrn\"\n o.val()\n\n #\n # Encode this operation in such a way that it can be parsed by remote peers.\n #\n _encode: ()->\n json =\n {\n 'type': \"ReplaceManager\"\n 'uid' : @getUid()\n 'beginning' : @beginning.getUid()\n 'end' : @end.getUid()\n }\n if @prev_cl? and @next_cl?\n json['prev'] = @prev_cl.getUid()\n json['next'] = @next_cl.getUid()\n if @origin? and @origin isnt @prev_cl\n json[\"origin\"] = @origin.getUid()\n json\n\n parser[\"ReplaceManager\"] = (json)->\n {\n 'content' : content\n 'uid' : uid\n 'prev': prev\n 'next': next\n 'origin' : origin\n 'beginning' : beginning\n 'end' : end\n } = json\n new ReplaceManager content, uid, beginning, end, prev, next, origin\n\n\n #\n # The ReplaceManager manages Replaceables.\n # @see ReplaceManager\n #\n class Replaceable extends types.Insert\n\n #\n # @param {Operation} content The value that this Replaceable holds.\n # @param {ReplaceManager} parent Used to replace this Replaceable with another one.\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n #\n constructor: (content, parent, uid, prev, next, origin)->\n @saveOperation 'content', content\n @saveOperation 'parent', parent\n if not (prev? and next? and content?)\n throw new Error \"You must define content, prev, and next for Replaceable-types!\"\n super uid, prev, next, origin\n\n #\n # Return the content that this operation holds.\n #\n val: ()->\n @content\n\n #\n # Replace the content of this replaceable with new content.\n #\n replace: (content)->\n @parent.replace content\n\n #\n # If possible set the replace manager in the content.\n # @see Word.setReplaceManager\n #\n execute: ()->\n if not @validateSavedOperations()\n return false\n else\n @content.setReplaceManager?(@parent)\n super\n @\n\n #\n # Encode this operation in such a way that it can be parsed by remote peers.\n #\n _encode: ()->\n json =\n {\n 'type': \"Replaceable\"\n 'content': @content.getUid()\n 'ReplaceManager' : @parent.getUid()\n 'prev': @prev_cl.getUid()\n 'next': @next_cl.getUid()\n 'uid' : @getUid()\n }\n if @origin? and @origin isnt @prev_cl\n json[\"origin\"] = @origin.getUid()\n json\n\n parser[\"Replaceable\"] = (json)->\n {\n 'content' : content\n 'ReplaceManager' : parent\n 'uid' : uid\n 'prev': prev\n 'next': next\n 'origin' : origin\n } = json\n new Replaceable content, parent, uid, prev, next, origin\n\n\n\n types['ListManager'] = ListManager\n types['MapManager'] = MapManager\n types['ReplaceManager'] = ReplaceManager\n types['Replaceable'] = Replaceable\n\n basic_types\n\n\n\n\n\n\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Types/TextTypes.coffee.map b/build/node/Types/TextTypes.coffee.map deleted file mode 100755 index c69357e8..00000000 --- a/build/node/Types/TextTypes.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Types/TextTypes.coffee","names":[],"mappings":"","sources":["Types/TextTypes.coffee"],"sourcesContent":["structured_types_uninitialized = require \"./StructuredTypes\"\n\nmodule.exports = (HB)->\n structured_types = structured_types_uninitialized HB\n types = structured_types.types\n parser = structured_types.parser\n\n #\n # At the moment TextDelete type equals the Delete type in BasicTypes.\n # @see BasicTypes.Delete\n #\n class TextDelete extends types.Delete\n parser[\"TextDelete\"] = parser[\"Delete\"]\n\n #\n # Extends the basic Insert type to an operation that holds a text value\n #\n class TextInsert extends types.Insert\n #\n # @param {String} content The content of this Insert-type Operation. Usually you restrict the length of content to size 1\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n #\n constructor: (@content, uid, prev, next, origin)->\n if not (prev? and next?)\n throw new Error \"You must define prev, and next for TextInsert-types!\"\n super uid, prev, next, origin\n #\n # Retrieve the effective length of the $content of this operation.\n #\n getLength: ()->\n if @isDeleted()\n 0\n else\n @content.length\n\n #\n # The result will be concatenated with the results from the other insert operations\n # in order to retrieve the content of the engine.\n # @see HistoryBuffer.toExecutedArray\n #\n val: (current_position)->\n if @isDeleted()\n \"\"\n else\n @content\n\n #\n # Convert all relevant information of this operation to the json-format.\n # This result can be send to other clients.\n #\n _encode: ()->\n json =\n {\n 'type': \"TextInsert\"\n 'content': @content\n 'uid' : @getUid()\n 'prev': @prev_cl.getUid()\n 'next': @next_cl.getUid()\n }\n if @origin? and @origin isnt @prev_cl\n json[\"origin\"] = @origin.getUid()\n json\n\n parser[\"TextInsert\"] = (json)->\n {\n 'content' : content\n 'uid' : uid\n 'prev': prev\n 'next': next\n 'origin' : origin\n } = json\n new TextInsert content, uid, prev, next, origin\n\n #\n # Handles a Text-like data structures with support for insertText/deleteText at a word-position.\n #\n class Word extends types.ListManager\n\n #\n # @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.\n #\n constructor: (uid, beginning, end, prev, next, origin)->\n super uid, beginning, end, prev, next, origin\n\n #\n # Inserts a string into the word\n #\n insertText: (position, content)->\n o = @getOperationByPosition position\n for c in content\n op = new TextInsert c, undefined, o.prev_cl, o\n HB.addOperation(op).execute()\n\n #\n # Deletes a part of the word.\n #\n deleteText: (position, length)->\n o = @getOperationByPosition position\n\n for i in [0...length]\n d = HB.addOperation(new TextDelete undefined, o).execute()\n o = o.next_cl\n while o.isDeleted()\n if o instanceof types.Delimiter\n throw new Error \"You can't delete more than there is..\"\n o = o.next_cl\n d._encode()\n\n #\n # Replace the content of this word with another one. Concurrent replacements are not merged!\n # Only one of the replacements will be used.\n #\n # Can only be used if the ReplaceManager was set!\n # @see Word.setReplaceManager\n #\n replaceText: (text)->\n if @replace_manager?\n word = HB.addOperation(new Word undefined).execute()\n word.insertText 0, text\n @replace_manager.replace(word)\n else\n throw new Error \"This type is currently not maintained by a ReplaceManager!\"\n\n #\n # @returns [Json] A Json object.\n #\n val: ()->\n c = for o in @toArray()\n if o.val?\n o.val()\n else\n \"\"\n c.join('')\n\n #\n # In most cases you would embed a Word in a Replaceable, wich is handled by the ReplaceManager in order\n # to provide replace functionality.\n #\n setReplaceManager: (op)->\n @saveOperation 'replace_manager', op\n @validateSavedOperations\n\n #\n # Encode this operation in such a way that it can be parsed by remote peers.\n #\n _encode: ()->\n json = {\n 'type': \"Word\"\n 'uid' : @getUid()\n 'beginning' : @beginning.getUid()\n 'end' : @end.getUid()\n }\n if @prev_cl?\n json['prev'] = @prev_cl.getUid()\n if @next_cl?\n json['next'] = @next_cl.getUid()\n if @origin? and @origin isnt @prev_cl\n json[\"origin\"] = @origin.getUid()\n json\n\n parser['Word'] = (json)->\n {\n 'uid' : uid\n 'beginning' : beginning\n 'end' : end\n 'prev': prev\n 'next': next\n 'origin' : origin\n } = json\n new Word uid, beginning, end, prev, next, origin\n\n types['TextInsert'] = TextInsert\n types['TextDelete'] = TextDelete\n types['Word'] = Word\n structured_types\n\n\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/node/Types/XmlTypes.coffee.map b/build/node/Types/XmlTypes.coffee.map deleted file mode 100755 index 006520eb..00000000 --- a/build/node/Types/XmlTypes.coffee.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Types/XmlTypes.coffee","names":[],"mappings":"","sources":["Types/XmlTypes.coffee"],"sourcesContent":[""],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/build/test/JsonYatta_test.js b/build/test/JsonYatta_test.js index eaf22513..f7b0a1f8 100644 --- a/build/test/JsonYatta_test.js +++ b/build/test/JsonYatta_test.js @@ -1,17 +1,25 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 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 } + gulp.src './build/{browser,test,node}/**/*.{js,map}', { read: false } .pipe ignore '*.html' .pipe rimraf() diff --git a/lib/Connectors/IwcConnector.coffee b/lib/Connectors/IwcConnector.coffee index 7bdcaec2..4fdb0ed2 100644 --- a/lib/Connectors/IwcConnector.coffee +++ b/lib/Connectors/IwcConnector.coffee @@ -3,7 +3,9 @@ # @param {Function} callback The callback is called when the connector is initialized. # @param {String} initial_user_id Optional. You can set you own user_id (since the ids of duiclient are not always unique) # -createIwcConnector = (callback, initial_user_id)-> +createIwcConnector = (callback, options)-> + if options? + {iwcHandler: userIwcHandler} = options iwcHandler = {} duiClient = new DUIClient() #@duiClient = new iwc.Client() @@ -12,6 +14,8 @@ createIwcConnector = (callback, initial_user_id)-> setTimeout ()-> f intent , 0 + if userIwcHandler? + userIwcHandler intent duiClient.initOK() @@ -101,12 +105,8 @@ createIwcConnector = (callback, initial_user_id)-> init = ()-> - proposed_user_id = null - if initial_user_id? - proposed_user_id = initial_user_id - else - # proposed_user_id = duiClient.getIwcClient()._componentName #TODO: This is stupid! why can't i use this? - proposed_user_id = Math.floor(Math.random()*1000000) + # proposed_user_id = duiClient.getIwcClient()._componentName #TODO: This is stupid! why can't i use this? + proposed_user_id = Math.floor(Math.random()*1000000) callback IwcConnector, proposed_user_id setTimeout init, 5000