Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rete

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rete - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0-rc.1

src/engine/recursion.js

4

build/rete.min.js
/*!
* rete v1.1.1
* rete v1.2.0-rc.1
* (c) 2019 Ni55aN
* Released under the MIT license.
*/
!function(t){"use strict";var u,e=Object.prototype,c=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag",s="object"==typeof module,a=t.regeneratorRuntime;if(a)s&&(module.exports=a);else{(a=t.regeneratorRuntime=s?module.exports:{}).wrap=k;var l="suspendedStart",d="suspendedYield",f="executing",p="completed",v={},h={};h[o]=function(){return this};var y=Object.getPrototypeOf,m=y&&y(y(L([])));m&&m!==e&&c.call(m,o)&&(h=m);var g=E.prototype=b.prototype=Object.create(h);x.prototype=g.constructor=E,E.constructor=x,E[i]=x.displayName="GeneratorFunction",a.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,E):(t.__proto__=E,i in t||(t[i]="GeneratorFunction")),t.prototype=Object.create(g),t},a.awrap=function(t){return{__await:t}},O(C.prototype),C.prototype[r]=function(){return this},a.AsyncIterator=C,a.async=function(t,e,n,r){var o=new C(k(t,e,n,r));return a.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},O(g),g[i]="Generator",g[o]=function(){return this},g.toString=function(){return"[object Generator]"},a.keys=function(n){var r=[];for(var t in n)r.push(t);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(R),!t)for(var e in this)"t"===e.charAt(0)&&c.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function t(t,e){return i.type="throw",i.arg=n,r.next=t,e&&(r.method="next",r.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var s=c.call(o,"catchLoc"),a=c.call(o,"finallyLoc");if(s&&a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&c.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),R(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;R(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:L(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=u),v}}}function k(t,e,n,r){var i,s,a,u,o=e&&e.prototype instanceof b?e:b,c=Object.create(o.prototype),h=new S(r||[]);return c._invoke=(i=t,s=n,a=h,u=l,function(t,e){if(u===f)throw new Error("Generator is already running");if(u===p){if("throw"===t)throw e;return j()}for(a.method=t,a.arg=e;;){var n=a.delegate;if(n){var r=N(n,a);if(r){if(r===v)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(u===l)throw u=p,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);u=f;var o=w(i,s,a);if("normal"===o.type){if(u=a.done?p:d,o.arg===v)continue;return{value:o.arg,done:a.done}}"throw"===o.type&&(u=p,a.method="throw",a.arg=o.arg)}}),c}function w(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function b(){}function x(){}function E(){}function O(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function C(u){var e;this._invoke=function(n,r){function t(){return new Promise(function(t,e){!function e(t,n,r,o){var i=w(u[t],u,n);if("throw"!==i.type){var s=i.arg,a=s.value;return a&&"object"==typeof a&&c.call(a,"__await")?Promise.resolve(a.__await).then(function(t){e("next",t,r,o)},function(t){e("throw",t,r,o)}):Promise.resolve(a).then(function(t){s.value=t,r(s)},function(t){return e("throw",t,r,o)})}o(i.arg)}(n,r,t,e)})}return e=e?e.then(t,t):t()}}function N(t,e){var n=t.iterator[e.method];if(n===u){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=u,N(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var r=w(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,v;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=u),e.delegate=null,v):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function R(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function L(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(c.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=u,t.done=!0,t};return r.next=r}}return{next:j}}function j(){return{value:u,done:!0}}}(function(){return this||"object"==typeof self&&self}()||Function("return this")()),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Rete={})}(this,function(t){"use strict";function u(t,e,n,r,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(r,o)}function f(a){return function(){var t=this,s=arguments;return new Promise(function(e,n){var r=a.apply(t,s);function o(t){u(r,e,n,o,i,"next",t)}function i(t){u(r,e,n,o,i,"throw",t)}o(void 0)})}}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function v(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function c(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(t){c(e,t,n[t])})}return e}function y(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function g(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?i(t):e}function s(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function k(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var h=function(){function e(t){if(p(this,e),this.constructor===e)throw new TypeError("Can not construct abstract class.");this.name=t,this.data={},this.engine=null}return v(e,[{key:"worker",value:function(){}}]),e}(),e=function(){function e(t){if(p(this,e),this.constructor===e)throw new TypeError("Can not construct abstract class");if(!t)throw new Error("The key parameter is missing in super() of Control ");this.key=t,this.data={},this.parent=null}return v(e,[{key:"getNode",value:function(){if(null===this.parent)throw new Error("Control isn't added to Node/Input");return this.parent instanceof x?this.parent:this.parent.node}},{key:"getData",value:function(t){return this.getNode().data[t]}},{key:"putData",value:function(t,e){this.getNode().data[t]=e}}]),e}(),l=function(){function n(t,e){p(this,n),this.output=t,this.input=e,this.data={},this.input.addConnection(this)}return v(n,[{key:"remove",value:function(){this.input.removeConnection(this),this.output.removeConnection(this)}}]),n}(),d=function(){function o(t,e,n,r){p(this,o),this.node=null,this.multipleConnections=r,this.connections=[],this.key=t,this.name=e,this.socket=n}return v(o,[{key:"removeConnection",value:function(t){this.connections.splice(this.connections.indexOf(t),1)}},{key:"removeConnections",value:function(){var e=this;this.connections.map(function(t){return e.removeConnection(t)})}}]),o}(),o=function(){function n(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};p(this,n),this.name=t,this.data=e,this.compatible=[]}return v(n,[{key:"combineWith",value:function(t){this.compatible.push(t)}},{key:"compatibleWith",value:function(t){return this===t||this.compatible.includes(t)}}]),n}(),w=function(t){function i(t,e,n){var r,o=3<arguments.length&&void 0!==arguments[3]&&arguments[3];return p(this,i),(r=g(this,m(i).call(this,t,e,n,o))).control=null,r}return y(i,d),v(i,[{key:"hasConnection",value:function(){return 0<this.connections.length}},{key:"addConnection",value:function(t){if(!this.multipleConnections&&this.hasConnection())throw new Error("Multiple connections not allowed");this.connections.push(t)}},{key:"addControl",value:function(t){(this.control=t).parent=this}},{key:"showControl",value:function(){return!this.hasConnection()&&null!==this.control}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){return{node:t.output.node.id,output:t.output.key,data:t.data}})}}}]),i}(),b=function(t){function o(t,e,n){var r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];return p(this,o),g(this,m(o).call(this,t,e,n,r))}return y(o,d),v(o,[{key:"hasConnection",value:function(){return 0<this.connections.length}},{key:"connectTo",value:function(t){if(!this.socket.compatibleWith(t.socket))throw new Error("Sockets not compatible");if(!t.multipleConnections&&t.hasConnection())throw new Error("Input already has one connection");if(!this.multipleConnections&&this.hasConnection())throw new Error("Output already has one connection");var e=new l(this,t);return this.connections.push(e),e}},{key:"connectedTo",value:function(e){return this.connections.some(function(t){return t.input===e})}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){return{node:t.input.node.id,input:t.input.key,data:t.data}})}}}]),o}(),x=function(){function n(t){p(this,n),this.name=t,this.id=n.incrementId(),this.position=[0,0],this.inputs=new Map,this.outputs=new Map,this.controls=new Map,this.data={},this.meta={}}return v(n,[{key:"_add",value:function(t,e,n){if(t.has(e.key))throw new Error("Item with key '".concat(e.key,"' already been added to the node"));if(null!==e[n])throw new Error("Item has already been added to some node");e[n]=this,t.set(e.key,e)}},{key:"addControl",value:function(t){return this._add(this.controls,t,"parent"),this}},{key:"removeControl",value:function(t){t.parent=null,this.controls.delete(t.key)}},{key:"addInput",value:function(t){return this._add(this.inputs,t,"node"),this}},{key:"removeInput",value:function(t){t.removeConnections(),t.node=null,this.inputs.delete(t.key)}},{key:"addOutput",value:function(t){return this._add(this.outputs,t,"node"),this}},{key:"removeOutput",value:function(t){t.removeConnections(),t.node=null,this.outputs.delete(t.key)}},{key:"getConnections",value:function(){return[].concat(k(this.inputs.values()),k(this.outputs.values())).reduce(function(t,e){return[].concat(k(t),k(e.connections))},[])}},{key:"update",value:function(){}},{key:"toJSON",value:function(){return{id:this.id,data:this.data,inputs:Array.from(this.inputs).reduce(function(t,e){var n=s(e,2),r=n[0],o=n[1];return t[r]=o.toJSON(),t},{}),outputs:Array.from(this.outputs).reduce(function(t,e){var n=s(e,2),r=n[0],o=n[1];return t[r]=o.toJSON(),t},{}),position:this.position,name:this.name}}}],[{key:"incrementId",value:function(){return this.latestId?this.latestId++:this.latestId=1,this.latestId}},{key:"resetId",value:function(){this.latestId=0}},{key:"fromJSON",value:function(t){var e=new n(t.name);return e.id=t.id,e.data=t.data,e.position=t.position,e.name=t.name,n.latestId=Math.max(e.id,n.latestId),e}}]),n}(),E=function(t){function n(t){var e;if(p(this,n),(e=g(this,m(n).call(this,t))).constructor===n)throw new TypeError("Can not construct abstract class.");return e.editor=null,e.data={},e}var e,r,o;return y(n,h),v(n,[{key:"builder",value:(o=f(regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}},t,this)})),function(){return o.apply(this,arguments)})},{key:"build",value:(r=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.builder(e);case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"createNode",value:(e=f(regeneratorRuntime.mark(function t(){var e,n,r=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=0<r.length&&void 0!==r[0]?r[0]:{},(n=new x(this.name)).data=e,t.next=5,this.build(n);case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}},t,this)})),function(){return e.apply(this,arguments)})}]),n}(),O=function t(e){p(this,t),this.handlers=a({warn:[console.warn],error:[console.error]},e)},C=function(){function e(t){p(this,e),this.events=t instanceof e?t.events:t.handlers,this.silent=!1}return v(e,[{key:"on",value:function(t,e){var n=this;return t.split(" ").forEach(function(t){if(!n.events[t])throw new Error("The event ".concat(t," does not exist"));n.events[t].push(e)}),this}},{key:"trigger",value:function(t,n){if(!(t in this.events))throw new Error("The event ".concat(t," cannot be triggered"));return this.events[t].reduce(function(t,e){return!1!==e(n)&&t},!0)}},{key:"bind",value:function(t){if(this.events[t])throw new Error("The event ".concat(t," is already bound"));this.events[t]=[]}},{key:"exist",value:function(t){return Array.isArray(this.events[t])}}]),e}(),N=function(){function t(){p(this,t)}return v(t,null,[{key:"isValidData",value:function(t){return"string"==typeof t.id&&this.isValidId(t.id)&&t.nodes instanceof Object&&!(t.nodes instanceof Array)}},{key:"isValidId",value:function(t){return/^[\w-]{3,}@[0-9]+\.[0-9]+\.[0-9]+$/.test(t)}},{key:"validate",value:function(t,e){var n="",r=t.split("@"),o=e.id.split("@");return this.isValidData(e)||(n+="Data is not suitable. "),t!==e.id&&(n+="IDs not equal. "),r[0]!==o[0]&&(n+="Names don't match. "),r[1]!==o[1]&&(n+="Versions don't match"),{success:""===n,msg:n}}}]),t}(),P=function(t){function r(t,e){var n;if(p(this,r),n=g(this,m(r).call(this,e)),!N.isValidId(t))throw new Error("ID should be valid to name@0.1.0 format");return n.id=t,n.plugins=new Map,n}return y(r,C),v(r,[{key:"use",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(t.name&&this.plugins.has(t.name))throw new Error("Plugin ".concat(t.name," already in use"));t.install(this,e),this.plugins.set(t.name,e)}}]),r}(),R=function(t){function e(){return p(this,e),g(this,m(e).call(this,{componentregister:[]}))}return y(e,O),e}(),S=0,L=1,j=2,_=function(t){function n(t){var e;return p(this,n),(e=g(this,m(n).call(this,t,new R))).components=[],e.args=[],e.data=null,e.state=S,e.onAbort=function(){},e}var e,r,o,i,s,a,u,c,h,l,d;return y(n,P),v(n,[{key:"clone",value:function(){var e=new n(this.id);return this.components.map(function(t){return e.register(t)}),e}},{key:"register",value:function(t){this.components.push(t),this.trigger("componentregister",t)}},{key:"throwError",value:(d=f(regeneratorRuntime.mark(function t(e){var n,r=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=1<r.length&&void 0!==r[1]?r[1]:null,t.next=3,this.abort();case 3:return this.trigger("error",{message:e,data:n}),this.processDone(),t.abrupt("return","error");case 6:case"end":return t.stop()}},t,this)})),function(t){return d.apply(this,arguments)})},{key:"extractInputNodes",value:function(n,r){return Object.keys(n.inputs).reduce(function(t,e){return[].concat(k(t),k((n.inputs[e].connections||[]).reduce(function(t,e){return[].concat(k(t),[r[e.node]])},[])))},[])}},{key:"detectRecursions",value:function(o){var i=this,t=Object.keys(o).map(function(t){return o[t]});return t.map(function(t){return function t(e,n){if(n.some(function(t){return t===e}))return e;for(var r=0;r<n.length;r++)if(t(e,i.extractInputNodes(n[r],o)))return e;return null}(t,i.extractInputNodes(t,o))}).filter(function(t){return null!==t})}},{key:"processStart",value:function(){return this.state===S?(this.state=L,!0):(this.state===j||console.warn("The process is busy and has not been restarted.\n Use abort() to force it to complete"),!1)}},{key:"processDone",value:function(){var t=this.state!==j;return this.state=S,t||(this.onAbort(),this.onAbort=function(){}),t}},{key:"abort",value:(l=f(regeneratorRuntime.mark(function t(){var e=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){e.state===L?(e.state=j,e.onAbort=t):e.state===j?(e.onAbort(),e.onAbort=t):t()}));case 1:case"end":return t.stop()}},t,this)})),function(){return l.apply(this,arguments)})},{key:"lock",value:(h=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){e.unlockPool=e.unlockPool||[],e.busy&&!e.outputData?e.unlockPool.push(t):t(),e.busy=!0}));case 1:case"end":return t.stop()}},t,this)})),function(t){return h.apply(this,arguments)})},{key:"unlock",value:function(t){t.unlockPool.forEach(function(t){return t()}),t.unlockPool=[],t.busy=!1}},{key:"extractInputData",value:(c=f(regeneratorRuntime.mark(function t(e){var n,r,o,i,s,a,u,c=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n={},r=Object.keys(e.inputs),o=0;case 3:if(o<r.length)return i=r[o],s=e.inputs[i],a=s.connections,t.next=9,Promise.all(a.map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.data.nodes[e.node],t.next=3,c.processNode(n);case 3:if(r=t.sent){t.next=8;break}c.abort(),t.next=9;break;case 8:return t.abrupt("return",r[e.output]);case 9:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()));t.next=14;break;case 9:u=t.sent,n[i]=u;case 11:o++,t.next=3;break;case 14:return t.abrupt("return",n);case 15:case"end":return t.stop()}},t,this)})),function(t){return c.apply(this,arguments)})},{key:"processWorker",value:(u=f(regeneratorRuntime.mark(function t(e){var n,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractInputData(e);case 2:return n=t.sent,r=this.components.find(function(t){return t.name===e.name}),o={},t.prev=5,t.next=8,r.worker.apply(r,[e,n,o].concat(k(this.args)));case 8:t.next=14;break;case 10:t.prev=10,t.t0=t.catch(5),this.abort(),this.trigger("warn",t.t0);case 14:return t.abrupt("return",o);case 15:case"end":return t.stop()}},t,this,[[5,10]])})),function(t){return u.apply(this,arguments)})},{key:"processNode",value:(a=f(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.state!==j&&e){t.next=2;break}return t.abrupt("return",null);case 2:return t.next=4,this.lock(e);case 4:return e.outputData||(e.outputData=this.processWorker(e)),this.unlock(e),t.abrupt("return",e.outputData);case 7:case"end":return t.stop()}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"forwardProcess",value:(s=f(regeneratorRuntime.mark(function t(r){var o=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.state===j)return t.abrupt("return",null);t.next=2;break;case 2:return t.next=4,Promise.all(Object.keys(r.outputs).map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.outputs[e],t.next=3,Promise.all(n.connections.map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.data.nodes[e.node],t.next=3,o.processNode(n);case 3:return t.next=5,o.forwardProcess(n);case 5:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}},t,this)})),function(t){return s.apply(this,arguments)})},{key:"copy",value:function(e){return(e=Object.assign({},e)).nodes=Object.assign({},e.nodes),Object.keys(e.nodes).forEach(function(t){e.nodes[t]=Object.assign({},e.nodes[t])}),e}},{key:"validate",value:(i=f(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if((n=N.validate(this.id,e)).success){t.next=5;break}return t.next=4,this.throwError(n.msg);case 4:return t.abrupt("return",t.sent);case 5:if(0<(r=this.detectRecursions(e.nodes)).length)return t.next=9,this.throwError("Recursion detected",r);t.next=10;break;case 9:return t.abrupt("return",t.sent);case 10:return t.abrupt("return",!0);case 11:case"end":return t.stop()}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"processStartNode",value:(o=f(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=10;break}if(n=this.data.nodes[e]){t.next=6;break}return t.next=5,this.throwError("Node with such id not found");case 5:return t.abrupt("return",t.sent);case 6:return t.next=8,this.processNode(n);case 8:return t.next=10,this.forwardProcess(n);case 10:case"end":return t.stop()}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"processUnreachable",value:(r=f(regeneratorRuntime.mark(function t(){var e,n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=regeneratorRuntime.keys(this.data.nodes);case 1:if((t.t1=t.t0()).done){t.next=11;break}if(e=t.t1.value,void 0===this.data.nodes[e].outputData)return n=this.data.nodes[e],t.next=7,this.processNode(n);t.next=9;break;case 7:return t.next=9,this.forwardProcess(n);case 9:t.next=1;break;case 11:case"end":return t.stop()}},t,this)})),function(){return r.apply(this,arguments)})},{key:"process",value:(e=f(regeneratorRuntime.mark(function t(e){var n,r,o,i,s=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=1<s.length&&void 0!==s[1]?s[1]:null,this.processStart()){t.next=3;break}return t.abrupt("return");case 3:if(this.validate(e)){t.next=5;break}return t.abrupt("return");case 5:for(this.data=this.copy(e),r=s.length,o=new Array(2<r?r-2:0),i=2;i<r;i++)o[i-2]=s[i];return this.args=o,t.next=10,this.processStartNode(n);case 10:return t.next=12,this.processUnreachable();case 12:return t.abrupt("return",this.processDone()?"success":"aborted");case 13:case"end":return t.stop()}},t,this)})),function(t){return e.apply(this,arguments)})}]),n}(),I=function(t){function e(){return p(this,e),g(this,m(e).call(this,{nodecreate:[],nodecreated:[],noderemove:[],noderemoved:[],connectioncreate:[],connectioncreated:[],connectionremove:[],connectionremoved:[],translatenode:[],nodetranslate:[],nodetranslated:[],nodedraged:[],selectnode:[],nodeselect:[],nodeselected:[],rendernode:[],rendersocket:[],rendercontrol:[],renderconnection:[],updateconnection:[],componentregister:[],keydown:[],keyup:[],translate:[],translated:[],zoom:[],zoomed:[],click:[],mousemove:[],contextmenu:[],import:[],export:[],process:[]}))}return y(e,O),e}(),D=function(){function o(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(){},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(){},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(){};p(this,o),this.pointerStart=null,this.el=t,this.onTranslate=e,this.onStart=n,this.onDrag=r,this.initEvents(t)}return v(o,[{key:"initEvents",value:function(t){t.style.touchAction="none",t.addEventListener("pointerdown",this.down.bind(this)),window.addEventListener("pointermove",this.move.bind(this)),window.addEventListener("pointerup",this.up.bind(this))}},{key:"down",value:function(t){t.stopPropagation(),this.pointerStart=[t.pageX,t.pageY],this.onStart(t)}},{key:"move",value:function(t){if(this.pointerStart){t.preventDefault();var e=[t.pageX,t.pageY],n=e[1],r=[e[0]-this.pointerStart[0],n-this.pointerStart[1]],o=this.el.getBoundingClientRect().width/this.el.offsetWidth;this.onTranslate(r[0]/o,r[1]/o,t)}}},{key:"up",value:function(t){this.pointerStart&&(this.pointerStart=null,this.onDrag(t))}}]),o}(),T=function(){function o(t,e,n,r){p(this,o),this.el=e,this.intensity=n,this.onzoom=r,this.distance=null,t.addEventListener("wheel",this.wheel.bind(this)),t.addEventListener("touchmove",this.move.bind(this)),t.addEventListener("touchend",this.end.bind(this)),t.addEventListener("touchcancel",this.end.bind(this)),t.addEventListener("dblclick",this.dblclick.bind(this))}return v(o,[{key:"wheel",value:function(t){t.preventDefault();var e=this.el.getBoundingClientRect(),n=(t.wheelDelta?t.wheelDelta/120:-t.deltaY/3)*this.intensity,r=(e.left-t.clientX)*n,o=(e.top-t.clientY)*n;this.onzoom(n,r,o,"wheel")}},{key:"touches",value:function(t){var e=[t.touches[0].clientX,t.touches[0].clientY],n=e[0],r=e[1],o=[t.touches[1].clientX,t.touches[1].clientY],i=o[0],s=o[1];return{cx:(n+i)/2,cy:(r+s)/2,distance:Math.sqrt(Math.pow(n-i,2)+Math.pow(r-s,2))}}},{key:"move",value:function(t){if(!(t.touches.length<2)){var e=this.el.getBoundingClientRect(),n=this.touches(t),r=n.cx,o=n.cy,i=n.distance;if(null!==this.distance){var s=i/this.distance-1,a=(e.left-r)*s,u=(e.top-o)*s;this.onzoom(s,a,u,"touch")}this.distance=i}}},{key:"end",value:function(){this.distance=null}},{key:"dblclick",value:function(t){t.preventDefault();var e=this.el.getBoundingClientRect(),n=4*this.intensity,r=(e.left-t.clientX)*n,o=(e.top-t.clientY)*n;this.onzoom(n,r,o,"dblclick")}}]),o}(),A=function(t){function o(t,e){var n;p(this,o);var r=(n=g(this,m(o).call(this,e))).el=document.createElement("div");return n.container=t,n.transform={k:1,x:0,y:0},n.mouse={x:0,y:0},r.style.transformOrigin="0 0",n._startPosition=null,n._zoom=new T(t,r,.1,n.onZoom.bind(i(i(n)))),n._drag=new D(t,n.onTranslate.bind(i(i(n))),n.onStart.bind(i(i(n)))),n.container.addEventListener("pointermove",n.pointermove.bind(i(i(n)))),n.update(),n}return y(o,C),v(o,[{key:"update",value:function(){var t=this.transform;this.el.style.transform="translate(".concat(t.x,"px, ").concat(t.y,"px) scale(").concat(t.k,")")}},{key:"pointermove",value:function(t){var e=t.clientX,n=t.clientY,r=this.el.getBoundingClientRect(),o=e-r.left,i=n-r.top,s=this.transform.k;this.mouse={x:o/s,y:i/s},this.trigger("mousemove",a({},this.mouse))}},{key:"onStart",value:function(){this._startPosition=a({},this.transform)}},{key:"onTranslate",value:function(t,e){this.translate(this._startPosition.x+t,this._startPosition.y+e)}},{key:"onZoom",value:function(t,e,n,r){this.zoom(this.transform.k*(1+t),e,n,r),this.update()}},{key:"translate",value:function(t,e){var n={transform:this.transform,x:t,y:e};this.trigger("translate",n)&&(this.transform.x=n.x,this.transform.y=n.y,this.update(),this.trigger("translated"))}},{key:"zoom",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length?arguments[3]:void 0,o=this.transform.k,i={transform:this.transform,zoom:t,source:r};if(this.trigger("zoom",i)){var s=(o-i.zoom)/(o-t||1);this.transform.k=i.zoom||1,this.transform.x+=e*s,this.transform.y+=n*s,this.update(),this.trigger("zoomed",{source:r})}}},{key:"appendChild",value:function(t){this.el.appendChild(t)}},{key:"removeChild",value:function(t){this.el.removeChild(t)}}]),o}(),z=function(t){function o(t,e,n){var r;return p(this,o),(r=g(this,m(o).call(this,n))).trigger("rendercontrol",{el:t,control:e}),r}return y(o,C),o}(),M=function(t){function a(t,e,n,r,o){var i,s;return p(this,a),(s=g(this,m(a).call(this,o))).el=t,s.type=e,s.io=n,s.node=r,s.trigger("rendersocket",(c(i={el:t},e,s.io),c(i,"socket",n.socket),i)),s}return y(a,C),v(a,[{key:"getPosition",value:function(t){var e=t.position,n=this.el;return[e[0]+n.offsetLeft+n.offsetWidth/2,e[1]+n.offsetTop+n.offsetHeight/2]}}]),a}(),J=function(t){function o(t,e,n){var r;return p(this,o),(r=g(this,m(o).call(this,n))).node=t,r.component=e,r.sockets=new Map,r.controls=new Map,r.el=document.createElement("div"),r.el.style.position="absolute",r.el.addEventListener("contextmenu",function(t){return r.trigger("contextmenu",{e:t,node:r.node})}),r._startPosition=null,r._drag=new D(r.el,r.onTranslate.bind(i(i(r))),r.onSelect.bind(i(i(r))),function(){r.trigger("nodedraged",t)}),r.trigger("rendernode",{el:r.el,node:t,component:e.data,bindSocket:r.bindSocket.bind(i(i(r))),bindControl:r.bindControl.bind(i(i(r)))}),r.update(),r}return y(o,C),v(o,[{key:"bindSocket",value:function(t,e,n){this.sockets.set(n,new M(t,e,n,this.node,this))}},{key:"bindControl",value:function(t,e){this.controls.set(e,new z(t,e,this))}},{key:"getSocketPosition",value:function(t){return this.sockets.get(t).getPosition(this.node)}},{key:"onSelect",value:function(t){this.onStart(),this.trigger("selectnode",{node:this.node,accumulate:t.ctrlKey})}},{key:"onStart",value:function(){this._startPosition=k(this.node.position)}},{key:"onTranslate",value:function(t,e){this.trigger("translatenode",{node:this.node,dx:t,dy:e})}},{key:"onDrag",value:function(t,e){var n=this._startPosition[0]+t,r=this._startPosition[1]+e;this.translate(n,r)}},{key:"translate",value:function(t,e){var n=this.node,r={node:n,x:t,y:e};if(this.trigger("nodetranslate",r)){var o=k(n.position);n.position[0]=r.x,n.position[1]=r.y,this.update(),this.trigger("nodetranslated",{node:n,prev:o})}}},{key:"update",value:function(){this.el.style.transform="translate(".concat(this.node.position[0],"px, ").concat(this.node.position[1],"px)")}},{key:"remove",value:function(){}}]),o}(),Y=function(t){function i(t,e,n,r){var o;return p(this,i),(o=g(this,m(i).call(this,r))).connection=t,o.inputNode=e,o.outputNode=n,o.el=document.createElement("div"),o.el.style.position="absolute",o.el.style.zIndex="-1",o.trigger("renderconnection",{el:o.el,connection:o.connection,points:o.getPoints()}),o}return y(i,C),v(i,[{key:"getPoints",value:function(){var t=s(this.outputNode.getSocketPosition(this.connection.output),2),e=t[0],n=t[1],r=s(this.inputNode.getSocketPosition(this.connection.input),2);return[e,n,r[0],r[1]]}},{key:"update",value:function(){this.trigger("updateconnection",{el:this.el,connection:this.connection,points:this.getPoints()})}}]),i}(),G=function(t){function o(t,e,n){var r;return p(this,o),(r=g(this,m(o).call(this,n))).container=t,r.components=e,r.container.style.overflow="hidden",r.nodes=new Map,r.connections=new Map,r.container.addEventListener("click",r.click.bind(i(i(r)))),r.container.addEventListener("contextmenu",function(t){return r.trigger("contextmenu",{e:t,view:i(i(r))})}),window.addEventListener("resize",r.resize.bind(i(i(r)))),r.on("nodetranslated",r.updateConnections.bind(i(i(r)))),r.area=new A(t,i(i(r))),r.container.appendChild(r.area.el),r}return y(o,C),v(o,[{key:"addNode",value:function(t){var e=new J(t,this.components.get(t.name),this);this.nodes.set(t,e),this.area.appendChild(e.el)}},{key:"removeNode",value:function(t){var e=this.nodes.get(t);this.nodes.delete(t),this.area.removeChild(e.el)}},{key:"addConnection",value:function(t){var e=this.nodes.get(t.input.node),n=this.nodes.get(t.output.node),r=new Y(t,e,n,this);this.connections.set(t,r),this.area.appendChild(r.el)}},{key:"removeConnection",value:function(t){var e=this.connections.get(t);this.connections.delete(t),this.area.removeChild(e.el)}},{key:"updateConnections",value:function(t){var e=this;t.node.getConnections().map(function(t){e.connections.get(t).update()})}},{key:"resize",value:function(){var t=this.container,e=t.parentElement.clientWidth,n=t.parentElement.clientHeight;t.style.width=e+"px",t.style.height=n+"px"}},{key:"click",value:function(t){var e=this.container;e===t.target&&this.trigger("click",{e:t,container:e})}}]),o}(),W=function(){function t(){p(this,t),this.list=[]}return v(t,[{key:"add",value:function(t){1<arguments.length&&void 0!==arguments[1]&&arguments[1]?this.contains(t)||this.list.push(t):this.list=[t]}},{key:"clear",value:function(){this.list=[]}},{key:"remove",value:function(t){this.list.splice(this.list.indexOf(t),1)}},{key:"contains",value:function(t){return-1!==this.list.indexOf(t)}},{key:"each",value:function(t){this.list.forEach(t)}}]),t}(),X=function(t){function n(t,e){var r;return p(this,n),(r=g(this,m(n).call(this,t,new I))).nodes=[],r.components=new Map,r.selected=new W,r.view=new G(e,r.components,i(i(r))),window.addEventListener("keydown",function(t){return r.trigger("keydown",t)}),window.addEventListener("keyup",function(t){return r.trigger("keyup",t)}),r.on("selectnode",function(t){var e=t.node,n=t.accumulate;return r.selectNode(e,n)}),r.on("nodeselected",function(){return r.selected.each(function(t){return r.view.nodes.get(t).onStart()})}),r.on("translatenode",function(t){var e=t.dx,n=t.dy;return r.selected.each(function(t){return r.view.nodes.get(t).onDrag(e,n)})}),r}var e;return y(n,P),v(n,[{key:"addNode",value:function(t){this.trigger("nodecreate",t)&&(this.nodes.push(t),this.view.addNode(t),this.trigger("nodecreated",t))}},{key:"removeNode",value:function(t){var e=this;this.trigger("noderemove",t)&&(t.getConnections().forEach(function(t){return e.removeConnection(t)}),this.nodes.splice(this.nodes.indexOf(t),1),this.view.removeNode(t),this.trigger("noderemoved",t))}},{key:"connect",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(this.trigger("connectioncreate",{output:t,input:e}))try{var r=t.connectTo(e);r.data=n,this.view.addConnection(r),this.trigger("connectioncreated",r)}catch(t){this.trigger("warn",t)}}},{key:"removeConnection",value:function(t){this.trigger("connectionremove",t)&&(this.view.removeConnection(t),t.remove(),this.trigger("connectionremoved",t))}},{key:"selectNode",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(-1===this.nodes.indexOf(t))throw new Error("Node not exist in list");this.trigger("nodeselect",t)&&(this.selected.add(t,e),this.trigger("nodeselected",t))}},{key:"getComponent",value:function(t){var e=this.components.get(t);if(!e)throw"Component ".concat(t," not found");return e}},{key:"register",value:function(t){(t.editor=this).components.set(t.name,t),this.trigger("componentregister",t)}},{key:"clear",value:function(){var e=this;k(this.nodes).map(function(t){return e.removeNode(t)})}},{key:"toJSON",value:function(){var e={id:this.id,nodes:{}};return this.nodes.forEach(function(t){return e.nodes[t.id]=t.toJSON()}),this.trigger("export",e),e}},{key:"beforeImport",value:function(t){var e=N.validate(this.id,t);return e.success?(this.silent=!0,this.clear(),this.trigger("import",t),!0):(this.trigger("warn",e.msg),!1)}},{key:"afterImport",value:function(){return!(this.silent=!1)}},{key:"fromJSON",value:(e=f(regeneratorRuntime.mark(function t(o){var a,u=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.beforeImport(o)){t.next=2;break}return t.abrupt("return",!1);case 2:return a={},t.prev=3,t.next=6,Promise.all(Object.keys(o.nodes).map(function(){var e=f(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.nodes[e],r=u.getComponent(n.name),t.next=4,r.build(x.fromJSON(n));case 4:a[e]=t.sent,u.addNode(a[e]);case 6:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()));case 6:Object.keys(o.nodes).forEach(function(t){var e=o.nodes[t],s=a[t];Object.keys(e.outputs).forEach(function(i){e.outputs[i].connections.forEach(function(t){var e=t.node,n=t.data,r=s.outputs.get(i),o=a[e].inputs.get(t.input);u.connect(r,o,n)})})}),t.next=13;break;case 9:return t.prev=9,t.t0=t.catch(3),this.trigger("warn",t.t0),t.abrupt("return",!this.afterImport());case 13:return t.prev=13,t.abrupt("return",this.afterImport());case 16:case"end":return t.stop()}},t,this,[[3,9,13,16]])})),function(t){return e.apply(this,arguments)})}]),n}(),F={Component:E,Control:e,Emitter:C,Engine:_,Input:w,Node:x,NodeEditor:X,Output:b,Socket:o};t.default=F,t.Component=E,t.Control=e,t.Emitter=C,t.Engine=_,t.Input=w,t.Node=x,t.NodeEditor=X,t.Output=b,t.Socket=o,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t){"use strict";var u,e=Object.prototype,c=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag",s="object"==typeof module,a=t.regeneratorRuntime;if(a)s&&(module.exports=a);else{(a=t.regeneratorRuntime=s?module.exports:{}).wrap=k;var l="suspendedStart",f="suspendedYield",d="executing",p="completed",v={},h={};h[o]=function(){return this};var y=Object.getPrototypeOf,m=y&&y(y(j([])));m&&m!==e&&c.call(m,o)&&(h=m);var g=E.prototype=b.prototype=Object.create(h);x.prototype=g.constructor=E,E.constructor=x,E[i]=x.displayName="GeneratorFunction",a.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,E):(t.__proto__=E,i in t||(t[i]="GeneratorFunction")),t.prototype=Object.create(g),t},a.awrap=function(t){return{__await:t}},O(C.prototype),C.prototype[r]=function(){return this},a.AsyncIterator=C,a.async=function(t,e,n,r){var o=new C(k(t,e,n,r));return a.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},O(g),g[i]="Generator",g[o]=function(){return this},g.toString=function(){return"[object Generator]"},a.keys=function(n){var r=[];for(var t in n)r.push(t);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=j,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&c.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function t(t,e){return i.type="throw",i.arg=n,r.next=t,e&&(r.method="next",r.arg=u),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var s=c.call(o,"catchLoc"),a=c.call(o,"finallyLoc");if(s&&a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&c.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;P(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=u),v}}}function k(t,e,n,r){var i,s,a,u,o=e&&e.prototype instanceof b?e:b,c=Object.create(o.prototype),h=new R(r||[]);return c._invoke=(i=t,s=n,a=h,u=l,function(t,e){if(u===d)throw new Error("Generator is already running");if(u===p){if("throw"===t)throw e;return L()}for(a.method=t,a.arg=e;;){var n=a.delegate;if(n){var r=S(n,a);if(r){if(r===v)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(u===l)throw u=p,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);u=d;var o=w(i,s,a);if("normal"===o.type){if(u=a.done?p:f,o.arg===v)continue;return{value:o.arg,done:a.done}}"throw"===o.type&&(u=p,a.method="throw",a.arg=o.arg)}}),c}function w(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function b(){}function x(){}function E(){}function O(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function C(u){var e;this._invoke=function(n,r){function t(){return new Promise(function(t,e){!function e(t,n,r,o){var i=w(u[t],u,n);if("throw"!==i.type){var s=i.arg,a=s.value;return a&&"object"==typeof a&&c.call(a,"__await")?Promise.resolve(a.__await).then(function(t){e("next",t,r,o)},function(t){e("throw",t,r,o)}):Promise.resolve(a).then(function(t){s.value=t,r(s)},function(t){return e("throw",t,r,o)})}o(i.arg)}(n,r,t,e)})}return e=e?e.then(t,t):t()}}function S(t,e){var n=t.iterator[e.method];if(n===u){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=u,S(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var r=w(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,v;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=u),e.delegate=null,v):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function j(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(c.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=u,t.done=!0,t};return r.next=r}}return{next:L}}function L(){return{value:u,done:!0}}}(function(){return this||"object"==typeof self&&self}()||Function("return this")()),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Rete={})}(this,function(t){"use strict";function u(t,e,n,r,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(r,o)}function d(a){return function(){var t=this,s=arguments;return new Promise(function(e,n){var r=a.apply(t,s);function o(t){u(r,e,n,o,i,"next",t)}function i(t){u(r,e,n,o,i,"throw",t)}o(void 0)})}}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function v(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function c(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(t){c(e,t,n[t])})}return e}function y(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function g(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?i(t):e}function o(t,e,n){return(o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=m(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function s(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function k(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var h=function(){function e(t){if(p(this,e),this.constructor===e)throw new TypeError("Can not construct abstract class.");this.name=t,this.data={},this.engine=null}return v(e,[{key:"worker",value:function(){}}]),e}(),l=function t(e){p(this,t),this.handlers=a({warn:[console.warn],error:[console.error]},e)},e=function(){function e(t){p(this,e),this.events=t instanceof e?t.events:t.handlers,this.silent=!1}return v(e,[{key:"on",value:function(t,e){var n=this;return t.split(" ").forEach(function(t){if(!n.events[t])throw new Error("The event ".concat(t," does not exist"));n.events[t].push(e)}),this}},{key:"trigger",value:function(t,n){if(!(t in this.events))throw new Error("The event ".concat(t," cannot be triggered"));return this.events[t].reduce(function(t,e){return!1!==e(n)&&t},!0)}},{key:"bind",value:function(t){if(this.events[t])throw new Error("The event ".concat(t," is already bound"));this.events[t]=[]}},{key:"exist",value:function(t){return Array.isArray(this.events[t])}}]),e}(),w=function(){function t(){p(this,t)}return v(t,null,[{key:"isValidData",value:function(t){return"string"==typeof t.id&&this.isValidId(t.id)&&t.nodes instanceof Object&&!(t.nodes instanceof Array)}},{key:"isValidId",value:function(t){return/^[\w-]{3,}@[0-9]+\.[0-9]+\.[0-9]+$/.test(t)}},{key:"validate",value:function(t,e){var n=t.split("@"),r=e.id.split("@"),o=[];return this.isValidData(e)||o.push("Data is not suitable"),t!==e.id&&o.push("IDs not equal"),n[0]!==r[0]&&o.push("Names don't match"),n[1]!==r[1]&&o.push("Versions don't match"),{success:Boolean(!o.length),msg:o.join(". ")}}}]),t}(),b=function(t){function r(t,e){var n;if(p(this,r),n=g(this,m(r).call(this,e)),!w.isValidId(t))throw new Error("ID should be valid to name@0.1.0 format");return n.id=t,n.plugins=new Map,n.components=new Map,n}return y(r,e),v(r,[{key:"use",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(t.name&&this.plugins.has(t.name))throw new Error("Plugin ".concat(t.name," already in use"));t.install(this,e),this.plugins.set(t.name,e)}},{key:"register",value:function(t){if(this.components.has(t.name))throw new Error("Component ".concat(t.name," already registered"));this.components.set(t.name,t),this.trigger("componentregister",t)}}]),r}(),x=function(t){function e(){return p(this,e),g(this,m(e).call(this,{componentregister:[]}))}return y(e,l),e}();var E=function(){function e(t){p(this,e),this.nodes=t}return v(e,[{key:"extractInputNodes",value:function(n){var r=this;return Object.keys(n.inputs).reduce(function(t,e){return[].concat(k(t),k((n.inputs[e].connections||[]).reduce(function(t,e){return[].concat(k(t),[r.nodes[e.node]])},[])))},[])}},{key:"findSelf",value:function(t,e){var n,r=(n=e,t.filter(function(t){return-1!==n.indexOf(t)}));if(r.length)return r[0];var o=!0,i=!1,s=void 0;try{for(var a,u=e[Symbol.iterator]();!(o=(a=u.next()).done);o=!0){var c=a.value,h=this.findSelf([c].concat(k(t)),this.extractInputNodes(c));if(h)return h}}catch(t){i=!0,s=t}finally{try{o||null==u.return||u.return()}finally{if(i)throw s}}return null}},{key:"detect",value:function(){var e=this,t=Object.keys(this.nodes).map(function(t){return e.nodes[t]}),n=!0,r=!1,o=void 0;try{for(var i,s=t[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var a=i.value,u=this.findSelf([a],this.extractInputNodes(a));if(u)return u}}catch(t){r=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}return null}}]),e}(),O=0,C=1,S=2,f=function(t){function n(t){var e;return p(this,n),(e=g(this,m(n).call(this,t,new x))).args=[],e.data=null,e.state=O,e.onAbort=function(){},e}var e,r,o,i,s,a,u,c,h,l,f;return y(n,b),v(n,[{key:"clone",value:function(){var e=new n(this.id);return this.components.forEach(function(t){return e.register(t)}),e}},{key:"throwError",value:(f=d(regeneratorRuntime.mark(function t(e){var n,r=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=1<r.length&&void 0!==r[1]?r[1]:null,t.next=3,this.abort();case 3:return this.trigger("error",{message:e,data:n}),this.processDone(),t.abrupt("return","error");case 6:case"end":return t.stop()}},t,this)})),function(t){return f.apply(this,arguments)})},{key:"processStart",value:function(){return this.state===O?(this.state=C,!0):(this.state===S||console.warn("The process is busy and has not been restarted.\n Use abort() to force it to complete"),!1)}},{key:"processDone",value:function(){var t=this.state!==S;return this.state=O,t||(this.onAbort(),this.onAbort=function(){}),t}},{key:"abort",value:(l=d(regeneratorRuntime.mark(function t(){var e=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){e.state===C?(e.state=S,e.onAbort=t):e.state===S?(e.onAbort(),e.onAbort=t):t()}));case 1:case"end":return t.stop()}},t,this)})),function(){return l.apply(this,arguments)})},{key:"lock",value:(h=d(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){e.unlockPool=e.unlockPool||[],e.busy&&!e.outputData?e.unlockPool.push(t):t(),e.busy=!0}));case 1:case"end":return t.stop()}},t,this)})),function(t){return h.apply(this,arguments)})},{key:"unlock",value:function(t){t.unlockPool.forEach(function(t){return t()}),t.unlockPool=[],t.busy=!1}},{key:"extractInputData",value:(c=d(regeneratorRuntime.mark(function t(e){var n,r,o,i,s,a,u,c=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n={},r=Object.keys(e.inputs),o=0;case 3:if(o<r.length)return i=r[o],s=e.inputs[i],a=s.connections,t.next=9,Promise.all(a.map(function(){var e=d(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.data.nodes[e.node],t.next=3,c.processNode(n);case 3:if(r=t.sent){t.next=8;break}c.abort(),t.next=9;break;case 8:return t.abrupt("return",r[e.output]);case 9:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()));t.next=14;break;case 9:u=t.sent,n[i]=u;case 11:o++,t.next=3;break;case 14:return t.abrupt("return",n);case 15:case"end":return t.stop()}},t,this)})),function(t){return c.apply(this,arguments)})},{key:"processWorker",value:(u=d(regeneratorRuntime.mark(function t(e){var n,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.extractInputData(e);case 2:return n=t.sent,r=this.components.get(e.name),o={},t.prev=5,t.next=8,r.worker.apply(r,[e,n,o].concat(k(this.args)));case 8:t.next=14;break;case 10:t.prev=10,t.t0=t.catch(5),this.abort(),this.trigger("warn",t.t0);case 14:return t.abrupt("return",o);case 15:case"end":return t.stop()}},t,this,[[5,10]])})),function(t){return u.apply(this,arguments)})},{key:"processNode",value:(a=d(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.state!==S&&e){t.next=2;break}return t.abrupt("return",null);case 2:return t.next=4,this.lock(e);case 4:return e.outputData||(e.outputData=this.processWorker(e)),this.unlock(e),t.abrupt("return",e.outputData);case 7:case"end":return t.stop()}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"forwardProcess",value:(s=d(regeneratorRuntime.mark(function t(r){var o=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.state===S)return t.abrupt("return",null);t.next=2;break;case 2:return t.next=4,Promise.all(Object.keys(r.outputs).map(function(){var e=d(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.outputs[e],t.next=3,Promise.all(n.connections.map(function(){var e=d(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.data.nodes[e.node],t.next=3,o.processNode(n);case 3:return t.next=5,o.forwardProcess(n);case 5:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}},t,this)})),function(t){return s.apply(this,arguments)})},{key:"copy",value:function(e){return(e=Object.assign({},e)).nodes=Object.assign({},e.nodes),Object.keys(e.nodes).forEach(function(t){e.nodes[t]=Object.assign({},e.nodes[t])}),e}},{key:"validate",value:(i=d(regeneratorRuntime.mark(function t(e){var n,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=w.validate(this.id,e),r=new E(e.nodes),n.success){t.next=6;break}return t.next=5,this.throwError(n.msg);case 5:return t.abrupt("return",t.sent);case 6:if(o=r.detect())return t.next=10,this.throwError("Recursion detected",o);t.next=11;break;case 10:return t.abrupt("return",t.sent);case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"processStartNode",value:(o=d(regeneratorRuntime.mark(function t(e){var n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=10;break}if(n=this.data.nodes[e]){t.next=6;break}return t.next=5,this.throwError("Node with such id not found");case 5:return t.abrupt("return",t.sent);case 6:return t.next=8,this.processNode(n);case 8:return t.next=10,this.forwardProcess(n);case 10:case"end":return t.stop()}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"processUnreachable",value:(r=d(regeneratorRuntime.mark(function t(){var e,n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=regeneratorRuntime.keys(this.data.nodes);case 1:if((t.t1=t.t0()).done){t.next=11;break}if(e=t.t1.value,void 0===this.data.nodes[e].outputData)return n=this.data.nodes[e],t.next=7,this.processNode(n);t.next=9;break;case 7:return t.next=9,this.forwardProcess(n);case 9:t.next=1;break;case 11:case"end":return t.stop()}},t,this)})),function(){return r.apply(this,arguments)})},{key:"process",value:(e=d(regeneratorRuntime.mark(function t(e){var n,r,o,i,s=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(n=1<s.length&&void 0!==s[1]?s[1]:null,this.processStart()){t.next=3;break}return t.abrupt("return");case 3:if(this.validate(e)){t.next=5;break}return t.abrupt("return");case 5:for(this.data=this.copy(e),r=s.length,o=new Array(2<r?r-2:0),i=2;i<r;i++)o[i-2]=s[i];return this.args=o,t.next=10,this.processStartNode(n);case 10:return t.next=12,this.processUnreachable();case 12:return t.abrupt("return",this.processDone()?"success":"aborted");case 13:case"end":return t.stop()}},t,this)})),function(t){return e.apply(this,arguments)})}]),n}(),N=function(){function e(t){if(p(this,e),this.constructor===e)throw new TypeError("Can not construct abstract class");if(!t)throw new Error("The key parameter is missing in super() of Control ");this.key=t,this.data={},this.parent=null}return v(e,[{key:"getNode",value:function(){if(null===this.parent)throw new Error("Control isn't added to Node/Input");return this.parent instanceof I?this.parent:this.parent.node}},{key:"getData",value:function(t){return this.getNode().data[t]}},{key:"putData",value:function(t,e){this.getNode().data[t]=e}}]),e}(),P=function(){function n(t,e){p(this,n),this.output=t,this.input=e,this.data={},this.input.addConnection(this)}return v(n,[{key:"remove",value:function(){this.input.removeConnection(this),this.output.removeConnection(this)}}]),n}(),R=function(){function o(t,e,n,r){p(this,o),this.node=null,this.multipleConnections=r,this.connections=[],this.key=t,this.name=e,this.socket=n}return v(o,[{key:"removeConnection",value:function(t){this.connections.splice(this.connections.indexOf(t),1)}},{key:"removeConnections",value:function(){var e=this;this.connections.map(function(t){return e.removeConnection(t)})}}]),o}(),j=function(){function n(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};p(this,n),this.name=t,this.data=e,this.compatible=[]}return v(n,[{key:"combineWith",value:function(t){this.compatible.push(t)}},{key:"compatibleWith",value:function(t){return this===t||this.compatible.includes(t)}}]),n}(),L=function(t){function i(t,e,n){var r,o=3<arguments.length&&void 0!==arguments[3]&&arguments[3];return p(this,i),(r=g(this,m(i).call(this,t,e,n,o))).control=null,r}return y(i,R),v(i,[{key:"hasConnection",value:function(){return 0<this.connections.length}},{key:"addConnection",value:function(t){if(!this.multipleConnections&&this.hasConnection())throw new Error("Multiple connections not allowed");this.connections.push(t)}},{key:"addControl",value:function(t){(this.control=t).parent=this}},{key:"showControl",value:function(){return!this.hasConnection()&&null!==this.control}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){return{node:t.output.node.id,output:t.output.key,data:t.data}})}}}]),i}(),_=function(t){function o(t,e,n){var r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3];return p(this,o),g(this,m(o).call(this,t,e,n,r))}return y(o,R),v(o,[{key:"hasConnection",value:function(){return 0<this.connections.length}},{key:"connectTo",value:function(t){if(!this.socket.compatibleWith(t.socket))throw new Error("Sockets not compatible");if(!t.multipleConnections&&t.hasConnection())throw new Error("Input already has one connection");if(!this.multipleConnections&&this.hasConnection())throw new Error("Output already has one connection");var e=new P(this,t);return this.connections.push(e),e}},{key:"connectedTo",value:function(e){return this.connections.some(function(t){return t.input===e})}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){return{node:t.input.node.id,input:t.input.key,data:t.data}})}}}]),o}(),I=function(){function n(t){p(this,n),this.name=t,this.id=n.incrementId(),this.position=[0,0],this.inputs=new Map,this.outputs=new Map,this.controls=new Map,this.data={},this.meta={}}return v(n,[{key:"_add",value:function(t,e,n){if(t.has(e.key))throw new Error("Item with key '".concat(e.key,"' already been added to the node"));if(null!==e[n])throw new Error("Item has already been added to some node");e[n]=this,t.set(e.key,e)}},{key:"addControl",value:function(t){return this._add(this.controls,t,"parent"),this}},{key:"removeControl",value:function(t){t.parent=null,this.controls.delete(t.key)}},{key:"addInput",value:function(t){return this._add(this.inputs,t,"node"),this}},{key:"removeInput",value:function(t){t.removeConnections(),t.node=null,this.inputs.delete(t.key)}},{key:"addOutput",value:function(t){return this._add(this.outputs,t,"node"),this}},{key:"removeOutput",value:function(t){t.removeConnections(),t.node=null,this.outputs.delete(t.key)}},{key:"getConnections",value:function(){return[].concat(k(this.inputs.values()),k(this.outputs.values())).reduce(function(t,e){return[].concat(k(t),k(e.connections))},[])}},{key:"update",value:function(){}},{key:"toJSON",value:function(){return{id:this.id,data:this.data,inputs:Array.from(this.inputs).reduce(function(t,e){var n=s(e,2),r=n[0],o=n[1];return t[r]=o.toJSON(),t},{}),outputs:Array.from(this.outputs).reduce(function(t,e){var n=s(e,2),r=n[0],o=n[1];return t[r]=o.toJSON(),t},{}),position:this.position,name:this.name}}}],[{key:"incrementId",value:function(){return this.latestId?this.latestId++:this.latestId=1,this.latestId}},{key:"resetId",value:function(){this.latestId=0}},{key:"fromJSON",value:function(t){var e=new n(t.name);return e.id=t.id,e.data=t.data,e.position=t.position,e.name=t.name,n.latestId=Math.max(e.id,n.latestId),e}}]),n}(),D=function(t){function n(t){var e;if(p(this,n),(e=g(this,m(n).call(this,t))).constructor===n)throw new TypeError("Can not construct abstract class.");return e.editor=null,e.data={},e}var e,r,o;return y(n,h),v(n,[{key:"builder",value:(o=d(regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}},t,this)})),function(){return o.apply(this,arguments)})},{key:"build",value:(r=d(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.builder(e);case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"createNode",value:(e=d(regeneratorRuntime.mark(function t(){var e,n,r=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=0<r.length&&void 0!==r[0]?r[0]:{},(n=new I(this.name)).data=e,t.next=5,this.build(n);case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}},t,this)})),function(){return e.apply(this,arguments)})}]),n}(),T=function(t){function e(){return p(this,e),g(this,m(e).call(this,{nodecreate:[],nodecreated:[],noderemove:[],noderemoved:[],connectioncreate:[],connectioncreated:[],connectionremove:[],connectionremoved:[],translatenode:[],nodetranslate:[],nodetranslated:[],nodedraged:[],selectnode:[],nodeselect:[],nodeselected:[],rendernode:[],rendersocket:[],rendercontrol:[],renderconnection:[],updateconnection:[],componentregister:[],keydown:[],keyup:[],translate:[],translated:[],zoom:[],zoomed:[],click:[],mousemove:[],contextmenu:[],import:[],export:[],process:[]}))}return y(e,l),e}(),A=function(){function o(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(){},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(){},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(){};p(this,o),this.pointerStart=null,this.el=t,this.onTranslate=e,this.onStart=n,this.onDrag=r,this.initEvents(t)}return v(o,[{key:"initEvents",value:function(t){t.style.touchAction="none",t.addEventListener("pointerdown",this.down.bind(this)),window.addEventListener("pointermove",this.move.bind(this)),window.addEventListener("pointerup",this.up.bind(this))}},{key:"down",value:function(t){t.stopPropagation(),this.pointerStart=[t.pageX,t.pageY],this.onStart(t)}},{key:"move",value:function(t){if(this.pointerStart){t.preventDefault();var e=[t.pageX,t.pageY],n=e[1],r=[e[0]-this.pointerStart[0],n-this.pointerStart[1]],o=this.el.getBoundingClientRect().width/this.el.offsetWidth;this.onTranslate(r[0]/o,r[1]/o,t)}}},{key:"up",value:function(t){this.pointerStart&&(this.pointerStart=null,this.onDrag(t))}}]),o}(),z=function(){function o(t,e,n,r){p(this,o),this.el=e,this.intensity=n,this.onzoom=r,this.distance=null,t.addEventListener("wheel",this.wheel.bind(this)),t.addEventListener("touchmove",this.move.bind(this)),t.addEventListener("touchend",this.end.bind(this)),t.addEventListener("touchcancel",this.end.bind(this)),t.addEventListener("dblclick",this.dblclick.bind(this))}return v(o,[{key:"wheel",value:function(t){t.preventDefault();var e=this.el.getBoundingClientRect(),n=(t.wheelDelta?t.wheelDelta/120:-t.deltaY/3)*this.intensity,r=(e.left-t.clientX)*n,o=(e.top-t.clientY)*n;this.onzoom(n,r,o,"wheel")}},{key:"touches",value:function(t){var e=[t.touches[0].clientX,t.touches[0].clientY],n=e[0],r=e[1],o=[t.touches[1].clientX,t.touches[1].clientY],i=o[0],s=o[1];return{cx:(n+i)/2,cy:(r+s)/2,distance:Math.sqrt(Math.pow(n-i,2)+Math.pow(r-s,2))}}},{key:"move",value:function(t){if(!(t.touches.length<2)){var e=this.el.getBoundingClientRect(),n=this.touches(t),r=n.cx,o=n.cy,i=n.distance;if(null!==this.distance){var s=i/this.distance-1,a=(e.left-r)*s,u=(e.top-o)*s;this.onzoom(s,a,u,"touch")}this.distance=i}}},{key:"end",value:function(){this.distance=null}},{key:"dblclick",value:function(t){t.preventDefault();var e=this.el.getBoundingClientRect(),n=4*this.intensity,r=(e.left-t.clientX)*n,o=(e.top-t.clientY)*n;this.onzoom(n,r,o,"dblclick")}}]),o}(),M=function(t){function o(t,e){var n;p(this,o);var r=(n=g(this,m(o).call(this,e))).el=document.createElement("div");return n.container=t,n.transform={k:1,x:0,y:0},n.mouse={x:0,y:0},r.style.transformOrigin="0 0",n._startPosition=null,n._zoom=new z(t,r,.1,n.onZoom.bind(i(i(n)))),n._drag=new A(t,n.onTranslate.bind(i(i(n))),n.onStart.bind(i(i(n)))),n.container.addEventListener("pointermove",n.pointermove.bind(i(i(n)))),n.update(),n}return y(o,e),v(o,[{key:"update",value:function(){var t=this.transform;this.el.style.transform="translate(".concat(t.x,"px, ").concat(t.y,"px) scale(").concat(t.k,")")}},{key:"pointermove",value:function(t){var e=t.clientX,n=t.clientY,r=this.el.getBoundingClientRect(),o=e-r.left,i=n-r.top,s=this.transform.k;this.mouse={x:o/s,y:i/s},this.trigger("mousemove",a({},this.mouse))}},{key:"onStart",value:function(){this._startPosition=a({},this.transform)}},{key:"onTranslate",value:function(t,e){this.translate(this._startPosition.x+t,this._startPosition.y+e)}},{key:"onZoom",value:function(t,e,n,r){this.zoom(this.transform.k*(1+t),e,n,r),this.update()}},{key:"translate",value:function(t,e){var n={transform:this.transform,x:t,y:e};this.trigger("translate",n)&&(this.transform.x=n.x,this.transform.y=n.y,this.update(),this.trigger("translated"))}},{key:"zoom",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,r=3<arguments.length?arguments[3]:void 0,o=this.transform.k,i={transform:this.transform,zoom:t,source:r};if(this.trigger("zoom",i)){var s=(o-i.zoom)/(o-t||1);this.transform.k=i.zoom||1,this.transform.x+=e*s,this.transform.y+=n*s,this.update(),this.trigger("zoomed",{source:r})}}},{key:"appendChild",value:function(t){this.el.appendChild(t)}},{key:"removeChild",value:function(t){this.el.removeChild(t)}}]),o}(),J=function(t){function o(t,e,n){var r;return p(this,o),(r=g(this,m(o).call(this,n))).trigger("rendercontrol",{el:t,control:e}),r}return y(o,e),o}(),Y=function(t){function a(t,e,n,r,o){var i,s;return p(this,a),(s=g(this,m(a).call(this,o))).el=t,s.type=e,s.io=n,s.node=r,s.trigger("rendersocket",(c(i={el:t},e,s.io),c(i,"socket",n.socket),i)),s}return y(a,e),v(a,[{key:"getPosition",value:function(t){var e=t.position,n=this.el;return[e[0]+n.offsetLeft+n.offsetWidth/2,e[1]+n.offsetTop+n.offsetHeight/2]}}]),a}(),G=function(t){function o(t,e,n){var r;return p(this,o),(r=g(this,m(o).call(this,n))).node=t,r.component=e,r.sockets=new Map,r.controls=new Map,r.el=document.createElement("div"),r.el.style.position="absolute",r.el.addEventListener("contextmenu",function(t){return r.trigger("contextmenu",{e:t,node:r.node})}),r._startPosition=null,r._drag=new A(r.el,r.onTranslate.bind(i(i(r))),r.onSelect.bind(i(i(r))),function(){r.trigger("nodedraged",t)}),r.trigger("rendernode",{el:r.el,node:t,component:e.data,bindSocket:r.bindSocket.bind(i(i(r))),bindControl:r.bindControl.bind(i(i(r)))}),r.update(),r}return y(o,e),v(o,[{key:"bindSocket",value:function(t,e,n){this.sockets.set(n,new Y(t,e,n,this.node,this))}},{key:"bindControl",value:function(t,e){this.controls.set(e,new J(t,e,this))}},{key:"getSocketPosition",value:function(t){return this.sockets.get(t).getPosition(this.node)}},{key:"onSelect",value:function(t){this.onStart(),this.trigger("selectnode",{node:this.node,accumulate:t.ctrlKey})}},{key:"onStart",value:function(){this._startPosition=k(this.node.position)}},{key:"onTranslate",value:function(t,e){this.trigger("translatenode",{node:this.node,dx:t,dy:e})}},{key:"onDrag",value:function(t,e){var n=this._startPosition[0]+t,r=this._startPosition[1]+e;this.translate(n,r)}},{key:"translate",value:function(t,e){var n=this.node,r={node:n,x:t,y:e};if(this.trigger("nodetranslate",r)){var o=k(n.position);n.position[0]=r.x,n.position[1]=r.y,this.update(),this.trigger("nodetranslated",{node:n,prev:o})}}},{key:"update",value:function(){this.el.style.transform="translate(".concat(this.node.position[0],"px, ").concat(this.node.position[1],"px)")}},{key:"remove",value:function(){}}]),o}(),W=function(t){function i(t,e,n,r){var o;return p(this,i),(o=g(this,m(i).call(this,r))).connection=t,o.inputNode=e,o.outputNode=n,o.el=document.createElement("div"),o.el.style.position="absolute",o.el.style.zIndex="-1",o.trigger("renderconnection",{el:o.el,connection:o.connection,points:o.getPoints()}),o}return y(i,e),v(i,[{key:"getPoints",value:function(){var t=s(this.outputNode.getSocketPosition(this.connection.output),2),e=t[0],n=t[1],r=s(this.inputNode.getSocketPosition(this.connection.input),2);return[e,n,r[0],r[1]]}},{key:"update",value:function(){this.trigger("updateconnection",{el:this.el,connection:this.connection,points:this.getPoints()})}}]),i}(),X=function(t){function o(t,e,n){var r;return p(this,o),(r=g(this,m(o).call(this,n))).container=t,r.components=e,r.container.style.overflow="hidden",r.nodes=new Map,r.connections=new Map,r.container.addEventListener("click",r.click.bind(i(i(r)))),r.container.addEventListener("contextmenu",function(t){return r.trigger("contextmenu",{e:t,view:i(i(r))})}),window.addEventListener("resize",r.resize.bind(i(i(r)))),r.on("nodetranslated",r.updateConnections.bind(i(i(r)))),r.area=new M(t,i(i(r))),r.container.appendChild(r.area.el),r}return y(o,e),v(o,[{key:"addNode",value:function(t){var e=new G(t,this.components.get(t.name),this);this.nodes.set(t,e),this.area.appendChild(e.el)}},{key:"removeNode",value:function(t){var e=this.nodes.get(t);this.nodes.delete(t),this.area.removeChild(e.el)}},{key:"addConnection",value:function(t){var e=this.nodes.get(t.input.node),n=this.nodes.get(t.output.node),r=new W(t,e,n,this);this.connections.set(t,r),this.area.appendChild(r.el)}},{key:"removeConnection",value:function(t){var e=this.connections.get(t);this.connections.delete(t),this.area.removeChild(e.el)}},{key:"updateConnections",value:function(t){var e=this;t.node.getConnections().map(function(t){e.connections.get(t).update()})}},{key:"resize",value:function(){var t=this.container,e=t.parentElement.clientWidth,n=t.parentElement.clientHeight;t.style.width=e+"px",t.style.height=n+"px"}},{key:"click",value:function(t){var e=this.container;e===t.target&&this.trigger("click",{e:t,container:e})}}]),o}(),B=function(){function t(){p(this,t),this.list=[]}return v(t,[{key:"add",value:function(t){1<arguments.length&&void 0!==arguments[1]&&arguments[1]?this.contains(t)||this.list.push(t):this.list=[t]}},{key:"clear",value:function(){this.list=[]}},{key:"remove",value:function(t){this.list.splice(this.list.indexOf(t),1)}},{key:"contains",value:function(t){return-1!==this.list.indexOf(t)}},{key:"each",value:function(t){this.list.forEach(t)}}]),t}(),F=function(t){function n(t,e){var r;return p(this,n),(r=g(this,m(n).call(this,t,new T))).nodes=[],r.selected=new B,r.view=new X(e,r.components,i(i(r))),window.addEventListener("keydown",function(t){return r.trigger("keydown",t)}),window.addEventListener("keyup",function(t){return r.trigger("keyup",t)}),r.on("selectnode",function(t){var e=t.node,n=t.accumulate;return r.selectNode(e,n)}),r.on("nodeselected",function(){return r.selected.each(function(t){return r.view.nodes.get(t).onStart()})}),r.on("translatenode",function(t){var e=t.dx,n=t.dy;return r.selected.each(function(t){return r.view.nodes.get(t).onDrag(e,n)})}),r}var e;return y(n,b),v(n,[{key:"addNode",value:function(t){this.trigger("nodecreate",t)&&(this.nodes.push(t),this.view.addNode(t),this.trigger("nodecreated",t))}},{key:"removeNode",value:function(t){var e=this;this.trigger("noderemove",t)&&(t.getConnections().forEach(function(t){return e.removeConnection(t)}),this.nodes.splice(this.nodes.indexOf(t),1),this.view.removeNode(t),this.trigger("noderemoved",t))}},{key:"connect",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(this.trigger("connectioncreate",{output:t,input:e}))try{var r=t.connectTo(e);r.data=n,this.view.addConnection(r),this.trigger("connectioncreated",r)}catch(t){this.trigger("warn",t)}}},{key:"removeConnection",value:function(t){this.trigger("connectionremove",t)&&(this.view.removeConnection(t),t.remove(),this.trigger("connectionremoved",t))}},{key:"selectNode",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(-1===this.nodes.indexOf(t))throw new Error("Node not exist in list");this.trigger("nodeselect",t)&&(this.selected.add(t,e),this.trigger("nodeselected",t))}},{key:"getComponent",value:function(t){var e=this.components.get(t);if(!e)throw"Component ".concat(t," not found");return e}},{key:"register",value:function(t){o(m(n.prototype),"register",this).call(this,t),t.editor=this}},{key:"clear",value:function(){var e=this;k(this.nodes).map(function(t){return e.removeNode(t)})}},{key:"toJSON",value:function(){var e={id:this.id,nodes:{}};return this.nodes.forEach(function(t){return e.nodes[t.id]=t.toJSON()}),this.trigger("export",e),e}},{key:"beforeImport",value:function(t){var e=w.validate(this.id,t);return e.success?(this.silent=!0,this.clear(),this.trigger("import",t),!0):(this.trigger("warn",e.msg),!1)}},{key:"afterImport",value:function(){return!(this.silent=!1)}},{key:"fromJSON",value:(e=d(regeneratorRuntime.mark(function t(o){var a,u=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.beforeImport(o)){t.next=2;break}return t.abrupt("return",!1);case 2:return a={},t.prev=3,t.next=6,Promise.all(Object.keys(o.nodes).map(function(){var e=d(regeneratorRuntime.mark(function t(e){var n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=o.nodes[e],r=u.getComponent(n.name),t.next=4,r.build(I.fromJSON(n));case 4:a[e]=t.sent,u.addNode(a[e]);case 6:case"end":return t.stop()}},t,this)}));return function(t){return e.apply(this,arguments)}}()));case 6:Object.keys(o.nodes).forEach(function(t){var e=o.nodes[t],s=a[t];Object.keys(e.outputs).forEach(function(i){e.outputs[i].connections.forEach(function(t){var e=t.node,n=t.data,r=s.outputs.get(i),o=a[e].inputs.get(t.input);u.connect(r,o,n)})})}),t.next=13;break;case 9:return t.prev=9,t.t0=t.catch(3),this.trigger("warn",t.t0),t.abrupt("return",!this.afterImport());case 13:return t.prev=13,t.abrupt("return",this.afterImport());case 16:case"end":return t.stop()}},t,this,[[3,9,13,16]])})),function(t){return e.apply(this,arguments)})}]),n}(),V={Engine:f,Recursion:E,Component:D,Control:N,Emitter:e,Input:L,Node:I,NodeEditor:F,Output:_,Socket:j};t.default=V,t.Engine=f,t.Recursion=E,t.Component=D,t.Control=N,t.Emitter=e,t.Input=L,t.Node=I,t.NodeEditor=F,t.Output=_,t.Socket=j,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=rete.min.js.map
{
"name": "rete",
"version": "1.1.1",
"version": "1.2.0-rc.1",
"description": "JavaScript framework",

@@ -5,0 +5,0 @@ "main": "build/rete.common.js",

@@ -14,2 +14,3 @@ import { Emitter } from './emitter'

this.plugins = new Map();
this.components = new Map();
}

@@ -23,2 +24,10 @@

}
register(component) {
if (this.components.has(component.name))
throw new Error(`Component ${component.name} already registered`);
this.components.set(component.name, component);
this.trigger('componentregister', component);
}
}

@@ -14,17 +14,17 @@ export class Validator {

static validate(id, data) {
var msg = '';
var id1 = id.split('@');
var id2 = data.id.split('@');
const id1 = id.split('@');
const id2 = data.id.split('@');
let msg = [];
if (!this.isValidData(data))
msg += 'Data is not suitable. ';
msg.push('Data is not suitable');
if (id !== data.id)
msg += 'IDs not equal. ';
msg.push('IDs not equal');
if (id1[0] !== id2[0])
msg += 'Names don\'t match. ';
msg.push('Names don\'t match');
if (id1[1] !== id2[1])
msg += 'Versions don\'t match';
msg.push('Versions don\'t match');
return { success: msg ==='', msg };
return { success: Boolean(!msg.length), msg: msg.join('. ') };
}
}

@@ -18,3 +18,2 @@ import { Component } from './component';

this.nodes = [];
this.components = new Map();

@@ -96,5 +95,4 @@ this.selected = new Selected();

register(component: Component) {
super.register(component)
component.editor = this;
this.components.set(component.name, component);
this.trigger('componentregister', component)
}

@@ -115,3 +113,3 @@

beforeImport(json: Object) {
var checking = Validator.validate(this.id, json);
const checking = Validator.validate(this.id, json);

@@ -136,8 +134,8 @@ if (!checking.success) {

if (!this.beforeImport(json)) return false;
var nodes = {};
const nodes = {};
try {
await Promise.all(Object.keys(json.nodes).map(async id => {
var node = json.nodes[id];
var component = this.getComponent(node.name);
const node = json.nodes[id];
const component = this.getComponent(node.name);

@@ -149,13 +147,13 @@ nodes[id] = await component.build(Node.fromJSON(node));

Object.keys(json.nodes).forEach(id => {
var jsonNode = json.nodes[id];
var node = nodes[id];
const jsonNode = json.nodes[id];
const node = nodes[id];
Object.keys(jsonNode.outputs).forEach(key => {
var outputJson = jsonNode.outputs[key];
const outputJson = jsonNode.outputs[key];
outputJson.connections.forEach(jsonConnection => {
var nodeId = jsonConnection.node;
var data = jsonConnection.data;
var targetOutput = node.outputs.get(key);
var targetInput = nodes[nodeId].inputs.get(jsonConnection.input);
const nodeId = jsonConnection.node;
const data = jsonConnection.data;
const targetOutput = node.outputs.get(key);
const targetInput = nodes[nodeId].inputs.get(jsonConnection.input);

@@ -162,0 +160,0 @@ this.connect(targetOutput, targetInput, data);

import { Component } from './component';
import { Context } from '../core/context';
import { EngineEvents } from './events';
import { Recursion } from './recursion';
import { State } from './state';
import { Validator } from '../core/validator';
var State = { AVALIABLE:0, PROCESSED: 1, ABORT: 2 };
export { Component, Recursion };
export { Component };
export class Engine extends Context {

@@ -15,6 +15,5 @@

this.components = [];
this.args = [];
this.data = null;
this.state = State.AVALIABLE;
this.state = State.AVAILABLE;
this.onAbort = () => { };

@@ -26,3 +25,3 @@ }

this.components.map(c => engine.register(c));
this.components.forEach(c => engine.register(c));

@@ -32,7 +31,2 @@ return engine;

register(component: Component) {
this.components.push(component);
this.trigger('componentregister', component);
}
async throwError (message, data = null) {

@@ -46,29 +40,4 @@ await this.abort();

extractInputNodes(node, nodes) {
return Object.keys(node.inputs).reduce((a, key) => {
return [...a, ...(node.inputs[key].connections || []).reduce((b, c) => [...b, nodes[c.node]], [])]
}, []);
}
detectRecursions(nodes) {
const nodesArr = Object.keys(nodes).map(id => nodes[id]);
const findSelf = (node, inputNodes) => {
if (inputNodes.some(n => n === node))
return node;
for (var i = 0; i < inputNodes.length; i++) {
if (findSelf(node, this.extractInputNodes(inputNodes[i], nodes)))
return node;
}
return null;
}
return nodesArr.map(node => {
return findSelf(node, this.extractInputNodes(node, nodes))
}).filter(r => r !== null);
}
processStart() {
if (this.state === State.AVALIABLE) {
if (this.state === State.AVAILABLE) {
this.state = State.PROCESSED;

@@ -88,5 +57,5 @@ return true;

processDone() {
var success = this.state !== State.ABORT;
const success = this.state !== State.ABORT;
this.state = State.AVALIABLE;
this.state = State.AVAILABLE;

@@ -138,8 +107,8 @@ if (!success) {

for (let key of Object.keys(node.inputs)) {
let input = node.inputs[key];
var conns = input.connections;
let connData = await Promise.all(conns.map(async (c) => {
const input = node.inputs[key];
const conns = input.connections;
const connData = await Promise.all(conns.map(async (c) => {
const prevNode = this.data.nodes[c.node];
let outputs = await this.processNode(prevNode);
const outputs = await this.processNode(prevNode);

@@ -159,5 +128,5 @@ if (!outputs)

async processWorker(node) {
var inputData = await this.extractInputData(node);
var component = this.components.find(c => c.name === node.name);
var outputData = {};
const inputData = await this.extractInputData(node);
const component = this.components.get(node.name);
const outputData = {};

@@ -215,3 +184,4 @@ try {

async validate(data) {
var checking = Validator.validate(this.id, data);
const checking = Validator.validate(this.id, data);
const recursion = new Recursion(data.nodes);

@@ -221,6 +191,6 @@ if (!checking.success)

var recurentNodes = this.detectRecursions(data.nodes);
const recurrentNode = recursion.detect();
if (recurentNodes.length > 0)
return await this.throwError('Recursion detected', recurentNodes);
if (recurrentNode)
return await this.throwError('Recursion detected', recurrentNode);

@@ -243,5 +213,5 @@ return true;

async processUnreachable() {
for (var i in this.data.nodes) // process nodes that have not been reached
for (let i in this.data.nodes) // process nodes that have not been reached
if (typeof this.data.nodes[i].outputData === 'undefined') {
var node = this.data.nodes[i];
const node = this.data.nodes[i];

@@ -248,0 +218,0 @@ await this.processNode(node);

@@ -0,5 +1,5 @@

import { Engine, Recursion } from './engine/index';
import { Component } from './component';
import { Control } from './control';
import { Emitter } from './core/emitter';
import { Engine } from './engine/index';
import { Input } from './input';

@@ -11,6 +11,6 @@ import { Node } from './node';

export { Engine, Recursion } from './engine/index';
export { Component } from './component';
export { Control } from './control';
export { Emitter } from './core/emitter';
export { Engine } from './engine/index';
export { Input } from './input';

@@ -23,6 +23,7 @@ export { Node } from './node';

export default {
Engine,
Recursion,
Component,
Control,
Emitter,
Engine,
Input,

@@ -29,0 +30,0 @@ Node,

@@ -24,3 +24,3 @@ import { Connection } from './connection';

var connection = new Connection(this, input);
const connection = new Connection(this, input);

@@ -27,0 +27,0 @@ this.connections.push(connection);

@@ -20,7 +20,7 @@ export class Zoom {

var rect = this.el.getBoundingClientRect();
var delta = (e.wheelDelta ? e.wheelDelta / 120 : - e.deltaY / 3) * this.intensity;
const rect = this.el.getBoundingClientRect();
const delta = (e.wheelDelta ? e.wheelDelta / 120 : - e.deltaY / 3) * this.intensity;
var ox = (rect.left - e.clientX) * delta;
var oy = (rect.top - e.clientY) * delta;
const ox = (rect.left - e.clientX) * delta;
const oy = (rect.top - e.clientY) * delta;

@@ -51,4 +51,4 @@ this.onzoom(delta, ox, oy, 'wheel');

var ox = (rect.left - cx) * delta;
var oy = (rect.top - cy) * delta;
const ox = (rect.left - cx) * delta;
const oy = (rect.top - cy) * delta;

@@ -67,7 +67,7 @@ this.onzoom(delta, ox, oy, 'touch');

var rect = this.el.getBoundingClientRect();
var delta = 4 * this.intensity;
const rect = this.el.getBoundingClientRect();
const delta = 4 * this.intensity;
var ox = (rect.left - e.clientX) * delta;
var oy = (rect.top - e.clientY) * delta;
const ox = (rect.left - e.clientX) * delta;
const oy = (rect.top - e.clientY) * delta;

@@ -74,0 +74,0 @@ this.onzoom(delta, ox, oy, 'dblclick');

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc