kevoree-chan-local
Version:
Kevoree channel that only sends messages to components in the same node
1 lines • 12.5 kB
JavaScript
!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";var r=n(1),i=n(2),s=n(3);r.register(i.name,i.version,s)},function(t,e){t.exports=KevoreeModuleLoader},function(t,e){t.exports={name:"kevoree-chan-local",version:"5.3.23",main:"./lib/LocalChannel.js",description:"Kevoree channel that only sends messages to components in the same node",kevoree:{namespace:"kevoree",browser:"lib/browser.js"},scripts:{prestart:"npm run build",pretest:"npm run build",prepublishOnly:"npm run test",start:"kevoree-scripts start",build:"kevoree-scripts build",test:"mocha test","kev:publish":"kevoree-scripts publish",postpublish:"npm run kev:publish"},dependencies:{"kevoree-entities":"^9.2.4"},devDependencies:{eslint:"^4.3.0","eslint-config-kevoree":"^1.0.1","kevoree-scripts":"^1.1.2",mocha:"^3.4.2"},keywords:["kevoree-std-lib","kevoree","library","channel"],author:"Maxime Tricoire <max.tricoire@gmail.com>",license:"LGPL-3.0",repository:{type:"git",url:"https://github.com/kevoree/kevoree-js.git"},bugs:{url:"https://github.com/kevoree/kevoree-js/issues"},homepage:"https://github.com/kevoree/kevoree-js"}},function(t,e,n){"use strict";var r=n(4),i=r.extend({toString:"LocalChannel",tdef_version:1,dic_delay:{optional:!1,defaultValue:0},onSend:function(t,e,n,r){var i=this;setTimeout(function(){i.started&&i.localDispatch(n,r)},this.dictionary.getNumber("delay",0))}});t.exports=i},function(t,e,n){"use strict";function r(t){return t&&t.length>15&&(t=t.substr(0,15)+"..."),t}var i=n(5),s=i.extend({toString:"AbstractChannel",construct:function(){this.inputs={},this.pendings=[]},__start__:function(t){var e=this;this._super(function(){e.pendings.forEach(function(t){e.internalSend(t.outputPath,t.content,t.callback)}),e.pendings.length=0,t()})},internalSend:function(t,e,n){var i=[],s=[],o=this.getKevoreeCore().getCurrentModel();o&&Object.keys(this.inputs).forEach(function(t){var e=o.findByPath(t);if(e){var n=e.eContainer();n&&n.started&&(i.push(t),s.push(n.eContainer().name+"."+n.name+"."+e.name))}}),this.started?(this.log.debug("-> "+r(e)+" -> ["+s.join(", ")+"]"),this.onSend(t,i,e+"",n)):(this.log.debug("-> "+r(e)+" -> ["+s.join(", ")+"] (queued)"),this.pendings.push({outputPath:t,content:e,callback:n}))},onSend:function(){},localDispatch:function(t,e){e=e||function(){},this.getLocalInputPorts().forEach(function(n){n.call(t,e)})},getOutputs:function(){var t=this,e=[],n=this.getModelEntity();return n&&n.bindings.array.forEach(function(n){n.port&&"required"===n.port.getRefInParent()&&n.port.eContainer().eContainer().name===t.getNodeName()&&-1===e.indexOf(n.port.path())&&e.push(n.port.path())}),e},getInputs:function(){var t=[],e=this.getModelEntity();return e&&e.bindings.array.forEach(function(e){e.port&&"provided"===e.port.getRefInParent()&&-1===t.indexOf(e.port.path())&&t.push(e.port.path())}),t},getInputPorts:function(){var t=this;return Object.keys(this.inputs).map(function(e){return t.inputs[e]})},getLocalInputPorts:function(){return this.getInputPorts().filter(function(t){return!t.isRemote})},getRemoteInputPorts:function(){return this.getInputPorts().filter(function(t){return t.isRemote})},addInputPort:function(t){this.inputs[t.path]=t},removeInputPort:function(t){delete this.inputs[t.path]}});t.exports=s},function(t,e,n){"use strict";var r=n(6),i=n(7),s=r({toString:"KevoreeEntity",construct:function(t,e,n){this.kCore=t,this.nodeName=n,this.name=e.name,this.path=e.path(),this.started=!1,this.dictionary=new i(this),this.log=this.kCore.getLoggerFactory().create(e.typeDefinition.name,e.name)},start:function(t){t()},stop:function(t){t()},update:function(t){t()},__start__:function(t){this.started=!0,this.start(t)},__stop__:function(t){this.started=!1,this.stop(t)},__update__:function(t){this.update(t)},__destruct__:function(){this.kCore.getLoggerFactory().delete(this.log)},getKevoreeCore:function(){return this.kCore},getDictionary:function(){return this.dictionary},getName:function(){return this.name},getNodeName:function(){return this.nodeName},getPath:function(){return this.path},getModelEntity:function(){var t=this.kCore.getDeployModel();return t||(t=this.kCore.getCurrentModel()),t.findByPath(this.path)},getNetworkInfos:function(t){var e=this.kCore.getDeployModel();e||this.kCore.getCurrentModel();var n=e.findNodesByID(t);return n?n.networkInformation.iterator():null},isStarted:function(){return this.started},submitScript:function(t,e){this.getKevoreeCore().submitScript(t,e)}});s.DIC="dic_",t.exports=s},function(t,e,n){"use strict";!function(e){function n(){var t,e,n,r,i;for(n=arguments,t=0,e=n.length;t<e;t++){r=n[t];for(i in r)this[i]=r[i]}return this}function r(t){return function(){return this[t].apply(this,arguments)}}function i(t,e){var i,s,o,u,a,c;t.properties=e,a={},i=t;do{if(i.properties)for(o in i.properties)c=a[o]||(a[o]=[]),c.unshift(i.properties[o]);i=i.superConstructor}while(i);u={};for(o in a)s=u[o]=n.apply({},a[o]),"string"==typeof s.set&&(s.set=r(s.set)),"string"==typeof s.get&&(s.get=r(s.get));t.properties=u}var s=function(){},o=/xyz/.test(function(){return"xyz"})?/\._super\b/:{test:function(){return!0}},u=function(t,e,n){return function(){var r=this._super;this._super=n[t];var i=e.apply(this,arguments);return this._super=r,i}},a=function(t,e,n){var r=n[t];return function(){return this._super=r,e.apply(this,arguments)}},c=function(t,e){e=e||this.constructor&&this.constructor.prototype;for(var n in t){var r=t[n];if("construct"!==n&&"destruct"!==n){e&&"function"==typeof r&&"function"==typeof e[n]&&o.test(r)?this.hasOwnProperty(n)?this[n]=a(n,r,this):this[n]=u(n,r,e):this[n]=r}}},h=function t(e){return e&&e.extend?e.extend.extend(e):t.extend(e)};h.prototype.mixin=c,h.extend=function t(e){function n(){if(this instanceof n==!1)throw new Error("Cannot create instance without new operator");var t=n.properties;t&&Object.defineProperties(this,t),this.construct.apply(this,arguments),this.init()}var r=this,o=this.prototype;n.superConstructor=r,n.extend=t;var u=n.prototype=Object.create(o);if(u.constructor=n,u.superPrototype=o,e){var a=e.properties;if(delete e.properties,c.call(u,e,o),Array.isArray(e.mixins))for(var h=0,p=e.mixins.length;h<p;h++)c.call(u,e.mixins[h],u);if(i(n,a),e.construct){var f=e.construct;o.construct?u.construct=function(){o.construct.apply(this,arguments),f.apply(this,arguments)}:u.construct=f}if(e.destruct){var l=e.destruct;o.destruct?u.destruct=function(){l.apply(this,arguments),o.destruct.apply(this,arguments)}:u.destruct=l}if("string"==typeof e.toString){var v=e.toString;u.toString=function(){return v}}}return"function"!=typeof u.construct&&(u.construct=s),"function"!=typeof u.init&&(u.init=s),n},void 0!==t&&t.exports?t.exports=h:"function"==typeof e.define?function(t){t(function(){return h})}(e.define):(e.PseudoClass=h,e.Class||(e.Class=h))}(void 0)},function(t,e,n){"use strict";function r(t){this.entity=t,this.emitter=new s.EventEmitter,this.map={}}var i=n(8),s=n(9);r.prototype={on:function(t,e){this.emitter.addListener(t,e.bind(this.entity))},off:function(t,e){this.emitter.removeListener(t,e)},getValue:function(t){return this.map[t]},getBoolean:function(t,e){var n=this.map[t];return"true"===n||"false"===n?"true"===n:(void 0===e&&(e=!1),e)},getString:function(t,e){var n=this.map[t];return"string"==typeof n?n:("string"!=typeof e&&(e=null),e)},getNumber:function(t,e){var n=void 0;return n=this.map[t]&&0===this.map[t].length?null:+this.map[t],isNaN(n)?"number"!=typeof e?null:e:n},setValue:function(t,e){var n=new i.factory.DefaultKevoreeFactory,r=this.entity.getModelEntity();r.dictionary||(r.dictionary=n.createDictionary()),e=r.dictionary.findValuesByID(t),e||(e=n.createDictionaryValue(),e.name=t,r.dictionary.addValues(e)),e.value=e,this.setEntry(t,e)},setEntry:function(t,e){var n=this.map[t];this.map[t]=e,this.entity.isStarted()&&this.emitter.emit(t,e,n)},setMap:function(t){var e=void 0;if(Object.keys(this.map).length>0)for(var n in t){var r=!1;for(e in this.map)if(n===e){var i=this.map[e];i!==t[e]&&(this.map[e]=t[e],this.emitter.emit(e,this.map[e],i)),r=!0}r||(this.map[n]=t[n])}else this.map=t},getMap:function(){return this.map},cloneMap:function(){var t={};for(var e in this.map)t[e]=this.map[e];return t},toString:function(){return"Dictionary"}},t.exports=r},function(t,e){t.exports=KevoreeLibrary},function(t,e,n){"use strict";function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function s(t){return"number"==typeof t}function o(t){return"object"===(void 0===t?"undefined":a(t))&&null!==t}function u(t){return void 0===t}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!s(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,n,r,s,a,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var h=new Error('Uncaught, unspecified "error" event. ('+e+")");throw h.context=e,h}if(n=this._events[t],u(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(o(n))for(s=Array.prototype.slice.call(arguments,1),c=n.slice(),r=c.length,a=0;a<r;a++)c[a].apply(this,s);return!0},r.prototype.addListener=function(t,e){var n;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(n=u(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var r=!1;return n.listener=e,this.on(t,n),this},r.prototype.removeListener=function(t,e){var n,r,s,u;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,r=-1,n===e||i(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(n)){for(u=s;u-- >0;)if(n[u]===e||n[u].listener&&n[u].listener===e){r=u;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],i(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}}]);