1 line
5.7 KiB
Plaintext
Executable File
1 line
5.7 KiB
Plaintext
Executable 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,UA4DA,cAAe,SAAC,EAAa,GAC3B,GAAA,SAAA,GAAS,KACN,UAAU,QAAU,GACpB,EAAA,UAAA,GAAa,EAAA,UAAA,GACd,GACE,OAAQ,EACR,UAAW,GACX,KAAM,GACN,SAAU,GACV,OAAQ,kBACR,OAAQ,IAEV,EAAS,UAAU,GAErB,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<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 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 # @overload sendIwcIntent intent\n # @param {Object} intent The intent object.\n # @overload sendIwcIntent action_name, content\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 = null\n if arguments.length >= 2\n [action_name, content] = arguments\n intent =\n action: action_name\n component: \"\"\n data: \"\"\n dataType: \"\"\n flags: [\"PUBLISH_GLOBAL\"]\n extras: content\n else\n intent = arguments[0]\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/"} |