changed examples, added listener methods

This commit is contained in:
Kevin Jahns
2014-08-19 21:09:23 +02:00
parent 9a1b0b7ced
commit 92e23b7007
50 changed files with 1229 additions and 526 deletions

View File

@@ -1,2 +1,2 @@
(function(){var t;t=function(t,n){var e,i,r,u,o,a;return null!=n&&(a=n.iwcHandler),u={},i=new DUIClient,i.connect(function(t){var n;return null!=(n=u[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),i.initOK(),o=null,e=function(){function t(t,n,e,r){var a,s,c,l;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,this.iwcHandler=u,l=function(t){return function(n){return 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),u.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=o&&this.engine.applyOpsCheckDouble(o),c=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[c]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t}(),r=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=t)}).call(this);
(function(){var t;t=function(t,n){var e,i,r,u,o,a;return a=null,null!=n&&(a=n.iwcHandler),u={},i=new DUIClient,i.connect(function(t){var n;return null!=(n=u[t.action])&&n.map(function(n){return setTimeout(function(){return n(t)},0)}),null!=a?a(t):void 0}),i.initOK(),o=null,e=function(){function t(t,n,e,r){var a,s,l,c;this.engine=t,this.HB=n,this.execution_listener=e,this.yatta=r,this.duiClient=i,this.iwcHandler=u,c=function(t){return function(n){return 0!==Object.getOwnPropertyNames(t.initialized).length?t.send(n):void 0}}(this),this.execution_listener.push(c),this.initialized={},a=function(t){return function(e){var i;return n=e.extras.HB,i=e.extras.user,t.engine.applyOpsCheckDouble(n),t.initialized[i]=!0}}(this),u.Yatta_push_HB_element=[a],this.sendIwcIntent("Yatta_get_HB_element",{}),s=function(t){return function(n){var e;return e=n.extras,null!=t.initialized[e.uid.creator]?t.receive(e):void 0}}(this),this.iwcHandler.Yatta_new_operation=[s],null!=o&&this.engine.applyOpsCheckDouble(o),l=function(t){return function(){var n;return n={HB:t.yatta.getHistoryBuffer()._encode(),user:t.yatta.getUserId()},t.sendIwcIntent("Yatta_push_HB_element",n)}}(this),this.iwcHandler.Yatta_get_HB_element=[l]}return t.prototype.send=function(t){return t.uid.creator===this.HB.getUserId()&&"string"!=typeof t.uid.op_number?this.sendIwcIntent("Yatta_new_operation",t):void 0},t.prototype.receive=function(t){return t.uid.creator!==this.HB.getUserId()?this.engine.applyOp(t):void 0},t.prototype.sendIwcIntent=function(t,n){var e;return e=null,arguments.length>=2?(t=arguments[0],n=arguments[1],e={action:t,component:"",data:"",dataType:"",flags:["PUBLISH_GLOBAL"],extras:n}):e=arguments[0],this.duiClient.sendIntent(e)},t.prototype.setIwcHandler=function(t){return a=t},t}(),r=function(){var n;return n=Math.floor(1e6*Math.random()),t(e,n)},void setTimeout(r,5e3)},module.exports=t,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.createIwcConnector=t)}).call(this);
//# sourceMappingURL=../Connectors/IwcConnector.js.map

File diff suppressed because one or more lines are too long

View File

@@ -29,7 +29,7 @@ class JsonYatta
#
# @result JsonType
#
getRootElement: ()->
getSharedObject: ()->
@root_element
#

View File

@@ -1,2 +1,2 @@
(function(){var t,e,n,o;o=require("../Types/JsonTypes"),e=require("../HistoryBuffer"),t=require("../Engine"),n=function(){function n(n,r){var i,s;this.HB=new e(n),s=o(this.HB),this.types=s.types,this.engine=new t(this.HB,s.parser),this.connector=new r(this.engine,this.HB,s.execution_listener,this),i=new this.types.JsonType(this.HB.getReservedUniqueIdentifier()),this.HB.addOperation(i).execute(),this.root_element=i}return n.prototype.getRootElement=function(){return this.root_element},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.setMutableDefault=function(t){return this.root_element.setMutableDefault(t)},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.toJson=function(){return this.root_element.toJson()},n.prototype.val=function(t,e,n){return this.root_element.val(t,e,n)},Object.defineProperty(n.prototype,"value",{get:function(){return this.root_element.value},set:function(t){var e,n,o;if(t.constructor==={}.constructor){o=[];for(e in t)n=t[e],o.push(this.val(e,n,"immutable"));return o}throw new Error("You must only set Object values!")}}),n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.JsonYatta=n)}).call(this);
(function(){var t,e,n,o;o=require("../Types/JsonTypes"),e=require("../HistoryBuffer"),t=require("../Engine"),n=function(){function n(n,r){var i,s;this.HB=new e(n),s=o(this.HB),this.types=s.types,this.engine=new t(this.HB,s.parser),this.connector=new r(this.engine,this.HB,s.execution_listener,this),i=new this.types.JsonType(this.HB.getReservedUniqueIdentifier()),this.HB.addOperation(i).execute(),this.root_element=i}return n.prototype.getSharedObject=function(){return this.root_element},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.setMutableDefault=function(t){return this.root_element.setMutableDefault(t)},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.toJson=function(){return this.root_element.toJson()},n.prototype.val=function(t,e,n){return this.root_element.val(t,e,n)},n.prototype.on=function(){var t;return(t=this.root_element).on.apply(t,arguments)},Object.defineProperty(n.prototype,"value",{get:function(){return this.root_element.value},set:function(t){var e,n,o;if(t.constructor==={}.constructor){o=[];for(e in t)n=t[e],o.push(this.val(e,n,"immutable"));return o}throw new Error("You must only set Object values!")}}),n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.JsonYatta=n)}).call(this);
//# sourceMappingURL=../Frameworks/JsonYatta.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"Frameworks/JsonYatta.js","sources":["Frameworks/JsonYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aASX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAe,EAAyB,KAAC,IACzC,KAAC,MAAQ,EAAa,MACtB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAa,QACvC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAa,mBAAoB,MAE1E,EAAiB,GAAA,MAAC,MAAM,SAAS,KAAC,GAAG,+BACrC,KAAC,GAAG,aAAa,GAAY,UAC7B,KAAC,aAAe,QATlB,GAAA,UAcA,eAAgB,iBACd,MAAC,cAfH,EAAA,UAoBA,UAAW,iBACT,MAAC,QArBH,EAAA,UA0BA,aAAc,iBACZ,MAAC,WA3BH,EAAA,UAgCA,iBAAkB,iBAChB,MAAC,IAjCH,EAAA,UAsCA,kBAAmB,SAAC,SAClB,MAAC,aAAa,kBAAkB,IAvClC,EAAA,UA8CA,UAAW,iBACT,MAAC,GAAG,aA/CN,EAAA,UAoDA,OAAS,iBACP,MAAC,aAAa,UArDhB,EAAA,UA0DA,IAAM,SAAC,EAAM,EAAS,SACpB,MAAC,aAAa,IAAI,EAAM,EAAS,IAKnC,OAAO,eAAe,EAAU,UAAW,SACzC,IAAM,iBAAG,MAAC,aAAa,OACvB,IAAM,SAAC,GACL,GAAA,GAAA,EAAA,CAAA,IAAG,EAAE,iBAAkB,YAAvB,CACE,SAAA,IAAA,UACE,EAAA,KAAA,KAAC,IAAI,EAAQ,EAAO,uBAEtB,KAAU,IAAA,OAAM,4CAExB,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","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 type_manager = json_types_uninitialized @HB\n @types = type_manager.types\n @engine = new Engine @HB, type_manager.parser\n @connector = new Connector @engine, @HB, type_manager.execution_listener, @\n\n first_word = new @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.toJson\n #\n toJson : ()->\n @root_element.toJson()\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!\"\n\nmodule.exports = JsonYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.JsonYatta = JsonYatta\n"],"sourceRoot":"/source/"}
{"version":3,"file":"Frameworks/JsonYatta.js","sources":["Frameworks/JsonYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aASX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAe,EAAyB,KAAC,IACzC,KAAC,MAAQ,EAAa,MACtB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAa,QACvC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAa,mBAAoB,MAE1E,EAAiB,GAAA,MAAC,MAAM,SAAS,KAAC,GAAG,+BACrC,KAAC,GAAG,aAAa,GAAY,UAC7B,KAAC,aAAe,QATlB,GAAA,UAcA,gBAAiB,iBACf,MAAC,cAfH,EAAA,UAoBA,UAAW,iBACT,MAAC,QArBH,EAAA,UA0BA,aAAc,iBACZ,MAAC,WA3BH,EAAA,UAgCA,iBAAkB,iBAChB,MAAC,IAjCH,EAAA,UAsCA,kBAAmB,SAAC,SAClB,MAAC,aAAa,kBAAkB,IAvClC,EAAA,UA8CA,UAAW,iBACT,MAAC,GAAG,aA/CN,EAAA,UAoDA,OAAS,iBACP,MAAC,aAAa,UArDhB,EAAA,UA0DA,IAAM,SAAC,EAAM,EAAS,SACpB,MAAC,aAAa,IAAI,EAAM,EAAS,IA3DnC,EAAA,UA6DA,GAAI,WACF,GAAA,UAAA,EAAA,KAAC,cAAa,GAAd,MAAA,EAAiB,YAKnB,OAAO,eAAe,EAAU,UAAW,SACzC,IAAM,iBAAG,MAAC,aAAa,OACvB,IAAM,SAAC,GACL,GAAA,GAAA,EAAA,CAAA,IAAG,EAAE,iBAAkB,YAAvB,CACE,SAAA,IAAA,UACE,EAAA,KAAA,KAAC,IAAI,EAAQ,EAAO,uBAEtB,KAAU,IAAA,OAAM,4CAExB,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","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 type_manager = json_types_uninitialized @HB\n @types = type_manager.types\n @engine = new Engine @HB, type_manager.parser\n @connector = new Connector @engine, @HB, type_manager.execution_listener, @\n\n first_word = new @types.JsonType @HB.getReservedUniqueIdentifier()\n @HB.addOperation(first_word).execute()\n @root_element = first_word\n\n #\n # @result JsonType\n #\n getSharedObject: ()->\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.toJson\n #\n toJson : ()->\n @root_element.toJson()\n\n #\n # @see JsonType.val\n #\n val : (name, content, mutable)->\n @root_element.val(name, content, mutable)\n\n on: ()->\n @root_element.on arguments...\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!\"\n\nmodule.exports = JsonYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.JsonYatta = JsonYatta\n"],"sourceRoot":"/source/"}

View File

@@ -25,7 +25,7 @@ class TextYatta
#
# @result Word
#
getRootElement: ()->
getSharedObject: ()->
@root_element
#

View File

@@ -1,2 +1,2 @@
(function(){var e,t,n,o;o=require("../Types/TextTypes"),t=require("../HistoryBuffer"),e=require("../Engine"),n=function(){function n(n,r){var i,s,p,u,c,a,d,h;this.HB=new t(n),c=o(this.HB),this.types=c.types,this.engine=new e(this.HB,c.parser),this.connector=new r(this.engine,this.HB,c.execution_listener,this),s=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_beginning"},void 0,void 0)),p=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_end"},s,void 0)),s.next_cl=p,s.execute(),p.execute(),u=new this.types.Word({creator:"_",op_number:"_"},s,p),this.HB.addOperation(u).execute(),h={creator:"_",op_number:"RM"},a={creator:"_",op_number:"_RM_beginning"},d={creator:"_",op_number:"_RM_end"},i=this.HB.addOperation(new this.types.Delimiter(a,void 0,d)).execute(),p=this.HB.addOperation(new this.types.Delimiter(d,i,void 0)).execute(),this.root_element=this.HB.addOperation(new this.types.ReplaceManager(void 0,h,i,p)).execute(),this.root_element.replace(u,{creator:"_",op_number:"Replaceable"})}return n.prototype.getRootElement=function(){return this.root_element.val()},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.val=function(){return this.getRootElement().val()},n.prototype.insertText=function(e,t){return this.getRootElement().insertText(e,t)},n.prototype.deleteText=function(e,t){return this.getRootElement().deleteText(e,t)},n.prototype.bind=function(e){return this.getRootElement().bind(e)},n.prototype.replaceText=function(e){return this.getRootElement().replaceText(e)},n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.TextYatta=n)}).call(this);
(function(){var e,t,n,r;r=require("../Types/TextTypes"),t=require("../HistoryBuffer"),e=require("../Engine"),n=function(){function n(n,i){var o,p,s,u,c,a,d,h;this.HB=new t(n),c=r(this.HB),this.types=c.types,this.engine=new e(this.HB,c.parser),this.connector=new i(this.engine,this.HB,c.execution_listener,this),p=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_beginning"},void 0,void 0)),s=this.HB.addOperation(new this.types.Delimiter({creator:"_",op_number:"_end"},p,void 0)),p.next_cl=s,p.execute(),s.execute(),u=new this.types.Word({creator:"_",op_number:"_"},p,s),this.HB.addOperation(u).execute(),h={creator:"_",op_number:"RM"},a={creator:"_",op_number:"_RM_beginning"},d={creator:"_",op_number:"_RM_end"},o=this.HB.addOperation(new this.types.Delimiter(a,void 0,d)).execute(),s=this.HB.addOperation(new this.types.Delimiter(d,o,void 0)).execute(),this.root_element=this.HB.addOperation(new this.types.ReplaceManager(void 0,h,o,s)).execute(),this.root_element.replace(u,{creator:"_",op_number:"Replaceable"})}return n.prototype.getSharedObject=function(){return this.root_element.val()},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.val=function(){return this.getSharedObject().val()},n.prototype.insertText=function(e,t){return this.getSharedObject().insertText(e,t)},n.prototype.deleteText=function(e,t){return this.getSharedObject().deleteText(e,t)},n.prototype.bind=function(e){return this.getSharedObject().bind(e)},n.prototype.replaceText=function(e){return this.getSharedObject().replaceText(e)},n.prototype.on=function(){var e;return(e=this.root_element).on.apply(e,arguments)},n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.TextYatta=n)}).call(this);
//# sourceMappingURL=../Frameworks/TextYatta.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"Frameworks/TextYatta.js","sources":["Frameworks/TextYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aAKX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAa,EAAyB,KAAC,IACvC,KAAC,MAAQ,EAAW,MACpB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAW,QACrC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAW,mBAAoB,MAExE,EAAY,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,WAAW,QAAS,IAAK,UAAW,cAAgB,OAAW,SACvG,EAAY,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,WAAW,QAAS,IAAK,UAAW,QAAgB,EAAW,SACvG,EAAU,QAAU,EACpB,EAAU,UACV,EAAI,UACJ,EAAiB,GAAA,MAAC,MAAM,MAAM,QAAS,IAAK,UAAW,KAAM,EAAW,GACxE,KAAC,GAAG,aAAa,GAAY,UAE7B,GAAU,QAAS,IAAK,UAAW,MACnC,GAAY,QAAS,IAAK,UAAW,iBACrC,GAAY,QAAS,IAAK,UAAW,WACrC,EAAM,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,UAAU,EAAS,OAAW,IAAS,UACzE,EAAM,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,UAAU,EAAS,EAAK,SAAW,UACrE,KAAC,aAAe,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,eAAe,OAAW,EAAO,EAAK,IAAK,UACvF,KAAC,aAAa,QAAQ,GAAc,QAAS,IAAK,UAAW,sBArB/D,GAAA,UA2BA,eAAgB,iBACd,MAAC,aAAa,OA5BhB,EAAA,UAiCA,UAAW,iBACT,MAAC,QAlCH,EAAA,UAuCA,aAAc,iBACZ,MAAC,WAxCH,EAAA,UA6CA,iBAAkB,iBAChB,MAAC,IA9CH,EAAA,UAqDA,UAAW,iBACT,MAAC,GAAG,aAtDN,EAAA,UA2DA,IAAK,iBACH,MAAC,iBAAiB,OA5DpB,EAAA,UAiEA,WAAY,SAAC,EAAK,SAChB,MAAC,iBAAiB,WAAW,EAAK,IAlEpC,EAAA,UAuEA,WAAY,SAAC,EAAK,SAChB,MAAC,iBAAiB,WAAW,EAAK,IAxEpC,EAAA,UA6EA,KAAM,SAAC,SACL,MAAC,iBAAiB,KAAK,IA9EzB,EAAA,UAmFA,YAAa,SAAC,SACZ,MAAC,iBAAiB,YAAY,SAGlC,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","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 @types = text_types.types\n @engine = new Engine @HB, text_types.parser\n @connector = new Connector @engine, @HB, text_types.execution_listener, @\n\n beginning = @HB.addOperation new @types.Delimiter {creator: '_', op_number: '_beginning'} , undefined, undefined\n end = @HB.addOperation new @types.Delimiter {creator: '_', op_number: '_end'} , beginning, undefined\n beginning.next_cl = end\n beginning.execute()\n end.execute()\n first_word = new @types.Word {creator: '_', op_number: '_'}, beginning, end\n @HB.addOperation(first_word).execute()\n\n uid_r = { creator: '_', op_number: \"RM\" }\n uid_beg = { creator: '_', op_number: \"_RM_beginning\" }\n uid_end = { creator: '_', op_number: \"_RM_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 @root_element = @HB.addOperation(new @types.ReplaceManager undefined, uid_r, beg, end).execute()\n @root_element.replace first_word, { creator: '_', op_number: 'Replaceable'}\n\n\n #\n # @result Word\n #\n getRootElement: ()->\n @root_element.val()\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 @getRootElement().val()\n\n #\n # @see Word.insertText\n #\n insertText: (pos, content)->\n @getRootElement().insertText pos, content\n\n #\n # @see Word.deleteText\n #\n deleteText: (pos, length)->\n @getRootElement().deleteText pos, length\n\n #\n # @see Word.bind\n #\n bind: (textarea)->\n @getRootElement().bind textarea\n\n #\n # @see Word.replaceText\n #\n replaceText: (text)->\n @getRootElement().replaceText text\n\n\nmodule.exports = TextYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.TextYatta = TextYatta\n"],"sourceRoot":"/source/"}
{"version":3,"file":"Frameworks/TextYatta.js","sources":["Frameworks/TextYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aAKX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAa,EAAyB,KAAC,IACvC,KAAC,MAAQ,EAAW,MACpB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAW,QACrC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAW,mBAAoB,MAExE,EAAY,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,WAAW,QAAS,IAAK,UAAW,cAAgB,OAAW,SACvG,EAAY,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,WAAW,QAAS,IAAK,UAAW,QAAgB,EAAW,SACvG,EAAU,QAAU,EACpB,EAAU,UACV,EAAI,UACJ,EAAiB,GAAA,MAAC,MAAM,MAAM,QAAS,IAAK,UAAW,KAAM,EAAW,GACxE,KAAC,GAAG,aAAa,GAAY,UAE7B,GAAU,QAAS,IAAK,UAAW,MACnC,GAAY,QAAS,IAAK,UAAW,iBACrC,GAAY,QAAS,IAAK,UAAW,WACrC,EAAM,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,UAAU,EAAS,OAAW,IAAS,UACzE,EAAM,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,UAAU,EAAS,EAAK,SAAW,UACrE,KAAC,aAAe,KAAC,GAAG,aAAiB,GAAA,MAAC,MAAM,eAAe,OAAW,EAAO,EAAK,IAAK,UACvF,KAAC,aAAa,QAAQ,GAAc,QAAS,IAAK,UAAW,sBArB/D,GAAA,UA2BA,gBAAiB,iBACf,MAAC,aAAa,OA5BhB,EAAA,UAiCA,UAAW,iBACT,MAAC,QAlCH,EAAA,UAuCA,aAAc,iBACZ,MAAC,WAxCH,EAAA,UA6CA,iBAAkB,iBAChB,MAAC,IA9CH,EAAA,UAqDA,UAAW,iBACT,MAAC,GAAG,aAtDN,EAAA,UA2DA,IAAK,iBACH,MAAC,kBAAkB,OA5DrB,EAAA,UAiEA,WAAY,SAAC,EAAK,SAChB,MAAC,kBAAkB,WAAW,EAAK,IAlErC,EAAA,UAuEA,WAAY,SAAC,EAAK,SAChB,MAAC,kBAAkB,WAAW,EAAK,IAxErC,EAAA,UA6EA,KAAM,SAAC,SACL,MAAC,kBAAkB,KAAK,IA9E1B,EAAA,UAmFA,YAAa,SAAC,SACZ,MAAC,kBAAkB,YAAY,IApFjC,EAAA,UAsFA,GAAI,WACF,GAAA,UAAA,EAAA,KAAC,cAAa,GAAd,MAAA,EAAiB,iBAGrB,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","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 @types = text_types.types\n @engine = new Engine @HB, text_types.parser\n @connector = new Connector @engine, @HB, text_types.execution_listener, @\n\n beginning = @HB.addOperation new @types.Delimiter {creator: '_', op_number: '_beginning'} , undefined, undefined\n end = @HB.addOperation new @types.Delimiter {creator: '_', op_number: '_end'} , beginning, undefined\n beginning.next_cl = end\n beginning.execute()\n end.execute()\n first_word = new @types.Word {creator: '_', op_number: '_'}, beginning, end\n @HB.addOperation(first_word).execute()\n\n uid_r = { creator: '_', op_number: \"RM\" }\n uid_beg = { creator: '_', op_number: \"_RM_beginning\" }\n uid_end = { creator: '_', op_number: \"_RM_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 @root_element = @HB.addOperation(new @types.ReplaceManager undefined, uid_r, beg, end).execute()\n @root_element.replace first_word, { creator: '_', op_number: 'Replaceable'}\n\n\n #\n # @result Word\n #\n getSharedObject: ()->\n @root_element.val()\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 @getSharedObject().val()\n\n #\n # @see Word.insertText\n #\n insertText: (pos, content)->\n @getSharedObject().insertText pos, content\n\n #\n # @see Word.deleteText\n #\n deleteText: (pos, length)->\n @getSharedObject().deleteText pos, length\n\n #\n # @see Word.bind\n #\n bind: (textarea)->\n @getSharedObject().bind textarea\n\n #\n # @see Word.replaceText\n #\n replaceText: (text)->\n @getSharedObject().replaceText text\n\n on: ()->\n @root_element.on arguments...\n\n\nmodule.exports = TextYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.TextYatta = TextYatta\n"],"sourceRoot":"/source/"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,2 @@
(function(){var e,t={}.hasOwnProperty,n=function(e,n){function r(){this.constructor=e}for(var i in n)t.call(n,i)&&(e[i]=n[i]);return r.prototype=n.prototype,e.prototype=new r,e.__super__=n.prototype,e};e=require("./StructuredTypes"),module.exports=function(t){var r,i,o,l,s,u;return s=e(t),u=s.types,l=s.parser,r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return n(t,e),t}(u.Delete),l.TextDelete=l.Delete,i=function(e){function t(e,n,r,i,o){if(this.content=e,null==r||null==i)throw new Error("You must define prev, and next for TextInsert-types!");t.__super__.constructor.call(this,n,r,i,o)}return n(t,e),t.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},t.prototype.val=function(){return this.isDeleted()?"":this.content},t.prototype._encode=function(){var e;return e={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&&(e.origin=this.origin.getUid()),e},t}(u.Insert),l.TextInsert=function(e){var t,n,r,o,l;return t=e.content,l=e.uid,o=e.prev,n=e.next,r=e.origin,new i(t,l,o,n,r)},o=function(e){function o(e,t,n,r,i,l){o.__super__.constructor.call(this,e,t,n,r,i,l)}return n(o,e),o.prototype.insertText=function(e,n){var r,o,l,s,u,a;for(o=this.getOperationByPosition(e),a=[],s=0,u=n.length;u>s;s++)r=n[s],l=new i(r,void 0,o.prev_cl,o),a.push(t.addOperation(l).execute());return a},o.prototype.deleteText=function(e,n){var i,o,l,s,a;for(s=this.getOperationByPosition(e),o=[],l=a=0;(n>=0?n>a:a>n)&&!(s instanceof u.Delimiter);l=n>=0?++a:--a){for(i=t.addOperation(new r(void 0,s)).execute(),s=s.next_cl;!(s instanceof u.Delimiter)&&s.isDeleted();)s=s.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 e,t;return e=function(){var e,n,r,i;for(r=this.toArray(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(null!=t.val?t.val():"");return i}.call(this),e.join("")},o.prototype.setReplaceManager=function(e){return this.saveOperation("replace_manager",e),this.validateSavedOperations},o.prototype.bind=function(e){var t;return t=this,e.value=this.val(),this.on("insert",function(n,r){var i,o,l,s;return l=r.getPosition(),i=function(e){return l>=e?e:e+=1},o=i(e.selectionStart),s=i(e.selectionEnd),e.value=t.val(),e.setSelectionRange(o,s)}),this.on("delete",function(n,r){var i,o,l,s;return l=r.getPosition(),i=function(e){return l>e?e:e-=1},o=i(e.selectionStart),s=i(e.selectionEnd),e.value=t.val(),e.setSelectionRange(o,s)}),e.onkeypress=function(n){var r,i,o,l;return r=null,r=null!=n.key?32===n.charCode?" ":13===n.keyCode?"\n":n.key:String.fromCharCode(n.keyCode),r.length>0?(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),t.deleteText(l,i),t.insertText(l,r),o=l+r.length,e.setSelectionRange(o,o),n.preventDefault()):n.preventDefault()},e.onpaste=function(e){return e.preventDefault()},e.oncut=function(e){return e.preventDefault()},e.onkeydown=function(n){var r,i,o,l,s;if(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),null!=n.keyCode&&8===n.keyCode){if(i>0)t.deleteText(l,i),e.setSelectionRange(l,l);else if(null!=n.ctrlKey&&n.ctrlKey){for(s=e.value,o=l,r=0,l>0&&(o--,r++);o>0&&" "!==s[o]&&"\n"!==s[o];)o--,r++;t.deleteText(o,l-o),e.setSelectionRange(o,o)}else t.deleteText(l-1,1);return n.preventDefault()}return null!=n.keyCode&&46===n.keyCode?(i>0?(t.deleteText(l,i),e.setSelectionRange(l,l)):(t.deleteText(l,1),e.setSelectionRange(l,l)),n.preventDefault()):void 0}},o.prototype._encode=function(){var e;return e={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(e.prev=this.prev_cl.getUid()),null!=this.next_cl&&(e.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},o}(u.ListManager),l.Word=function(e){var t,n,r,i,l,s;return s=e.uid,t=e.beginning,n=e.end,l=e.prev,r=e.next,i=e.origin,new o(s,t,n,l,r,i)},u.TextInsert=i,u.TextDelete=r,u.Word=o,s}}).call(this);
(function(){var e,t={}.hasOwnProperty,n=function(e,n){function r(){this.constructor=e}for(var i in n)t.call(n,i)&&(e[i]=n[i]);return r.prototype=n.prototype,e.prototype=new r,e.__super__=n.prototype,e};e=require("./StructuredTypes"),module.exports=function(t){var r,i,o,l,u,s;return u=e(t),s=u.types,l=u.parser,r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return n(t,e),t}(s.Delete),l.TextDelete=l.Delete,i=function(e){function t(e,n,r,i,o){if(this.content=e,null==r||null==i)throw new Error("You must define prev, and next for TextInsert-types!");t.__super__.constructor.call(this,n,r,i,o)}return n(t,e),t.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},t.prototype.val=function(){return this.isDeleted()?"":this.content},t.prototype._encode=function(){var e;return e={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&&(e.origin=this.origin.getUid()),e},t}(s.Insert),l.TextInsert=function(e){var t,n,r,o,l;return t=e.content,l=e.uid,o=e.prev,n=e.next,r=e.origin,new i(t,l,o,n,r)},o=function(e){function o(e,t,n,r,i,l){o.__super__.constructor.call(this,e,t,n,r,i,l)}return n(o,e),o.prototype.insertText=function(e,n){var r,o,l,u,s,a;for(o=this.getOperationByPosition(e),a=[],u=0,s=n.length;s>u;u++)r=n[u],l=new i(r,void 0,o.prev_cl,o),a.push(t.addOperation(l).execute());return a},o.prototype.deleteText=function(e,n){var i,o,l,u,a;for(u=this.getOperationByPosition(e),o=[],l=a=0;(n>=0?n>a:a>n)&&!(u instanceof s.Delimiter);l=n>=0?++a:--a){for(i=t.addOperation(new r(void 0,u)).execute(),u=u.next_cl;!(u instanceof s.Delimiter)&&u.isDeleted();)u=u.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 e,t;return e=function(){var e,n,r,i;for(r=this.toArray(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(null!=t.val?t.val():"");return i}.call(this),e.join("")},o.prototype.setReplaceManager=function(e){return this.saveOperation("replace_manager",e),this.validateSavedOperations(),this.on(["insert","delete"],function(e){return function(){var t;return null!=(t=e.replace_manager)?t.callEvent("change"):void 0}}(this))},o.prototype.bind=function(e){var t;return t=this,e.value=this.val(),this.on("insert",function(n,r){var i,o,l,u;return l=r.getPosition(),i=function(e){return l>=e?e:e+=1},o=i(e.selectionStart),u=i(e.selectionEnd),e.value=t.val(),e.setSelectionRange(o,u)}),this.on("delete",function(n,r){var i,o,l,u;return l=r.getPosition(),i=function(e){return l>e?e:e-=1},o=i(e.selectionStart),u=i(e.selectionEnd),e.value=t.val(),e.setSelectionRange(o,u)}),e.onkeypress=function(n){var r,i,o,l;return r=null,r=null!=n.key?32===n.charCode?" ":13===n.keyCode?"\n":n.key:String.fromCharCode(n.keyCode),r.length>0?(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),t.deleteText(l,i),t.insertText(l,r),o=l+r.length,e.setSelectionRange(o,o),n.preventDefault()):n.preventDefault()},e.onpaste=function(e){return e.preventDefault()},e.oncut=function(e){return e.preventDefault()},e.onkeydown=function(n){var r,i,o,l,u;if(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),null!=n.keyCode&&8===n.keyCode){if(i>0)t.deleteText(l,i),e.setSelectionRange(l,l);else if(null!=n.ctrlKey&&n.ctrlKey){for(u=e.value,o=l,r=0,l>0&&(o--,r++);o>0&&" "!==u[o]&&"\n"!==u[o];)o--,r++;t.deleteText(o,l-o),e.setSelectionRange(o,o)}else t.deleteText(l-1,1);return n.preventDefault()}return null!=n.keyCode&&46===n.keyCode?(i>0?(t.deleteText(l,i),e.setSelectionRange(l,l)):(t.deleteText(l,1),e.setSelectionRange(l,l)),n.preventDefault()):void 0}},o.prototype._encode=function(){var e;return e={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(e.prev=this.prev_cl.getUid()),null!=this.next_cl&&(e.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},o}(s.ListManager),l.Word=function(e){var t,n,r,i,l,u;return u=e.uid,t=e.beginning,n=e.end,l=e.prev,r=e.next,i=e.origin,new o(u,t,n,l,r,i)},s.TextInsert=i,s.TextDelete=r,s.Word=o,u}}).call(this);
//# sourceMappingURL=../Types/TextTypes.js.map

File diff suppressed because one or more lines are too long