added dui parameter

This commit is contained in:
Kevin Jahns 2014-08-19 15:57:48 +02:00
parent e9783c8a25
commit c40fe0e0b7
19 changed files with 80 additions and 77 deletions

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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<Function>} execution_listener You must ensure that whenever an operation is executed, every function in this Array is called.\n # @param {Yatta} yatta The Yatta framework.\n #\n constructor: (@engine, @HB, @execution_listener, @yatta)->\n @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/"}

View File

@ -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

File diff suppressed because one or more lines are too long

View File

@ -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<Function>} execution_listener You must ensure that whenever an operation is executed, every function in this Array is called.\n # @param {Yatta} yatta The Yatta framework.\n #\n constructor: (@engine, @HB, @execution_listener)->\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/"}

View File

@ -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/"}

View File

@ -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/"}

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 +0,0 @@
{"version":3,"file":"Types/XmlTypes.coffee","names":[],"mappings":"","sources":["Types/XmlTypes.coffee"],"sourcesContent":[""],"sourceRoot":"/source/"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -105,7 +105,7 @@ gulp.task 'upload', [], ()->
run('scp -r ./build ./examples jahns@manet.informatik.rwth-aachen.de:/home/jahns/public_html/collaborative_preview/').exec()
gulp.task 'clean', ->
gulp.src './build/{browser,test,node}/*.{js,map}', { read: false }
gulp.src './build/{browser,test,node}/**/*.{js,map}', { read: false }
.pipe ignore '*.html'
.pipe rimraf()

View File

@ -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