New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@baklavajs/core

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baklavajs/core - npm Package Compare versions

Comparing version 1.9.1 to 1.9.3

dist/index.js.LICENSE.txt

0

dist/baklavajs-core/src/connection.d.ts

@@ -0,0 +0,0 @@ import { NodeInterface } from "./nodeInterface";

@@ -0,0 +0,0 @@ import { Node } from "./node";

export default function generateId(): string;

@@ -0,0 +0,0 @@ export * from "./connection";

@@ -0,0 +0,0 @@ import { NodeInterface } from "./nodeInterface";

@@ -0,0 +0,0 @@ import { Node } from "./node";

@@ -0,0 +0,0 @@ import { IInterfaceState } from "../types/state";

@@ -0,0 +0,0 @@ import { INodeOption } from "../types/nodeOption";

@@ -0,0 +0,0 @@ import { INodeInterface } from "./nodeInterface";

@@ -0,0 +0,0 @@ import { IAddConnectionEventData, IAddNodeTypeEventData } from "./eventDataTypes";

@@ -0,0 +0,0 @@ import { INodeInterface } from "./nodeInterface";

@@ -0,0 +0,0 @@ export * from "./connection";

@@ -0,0 +0,0 @@ import { IBaklavaEvent, IPreventableBaklavaEvent, IHook } from "../../baklavajs-events/types";

@@ -0,0 +0,0 @@ import { INode } from "./node";

@@ -0,0 +0,0 @@ import { IBaklavaEvent, IPreventableBaklavaEvent } from "../../baklavajs-events/types";

@@ -0,0 +0,0 @@ import { IEditor } from "./editor";

@@ -0,0 +0,0 @@ export interface IState extends Record<string, any> {

@@ -0,0 +0,0 @@ export declare type TokenType = object | symbol;

18

dist/index.js

@@ -1,16 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("BaklavaJS",[],t):"object"==typeof exports?exports.BaklavaJS=t():e.BaklavaJS=t()}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SequentialHook=t.Hook=t.PreventableBaklavaEvent=t.BaklavaEvent=void 0;var o=n(1),r=function(){function e(){this.listeners=new Map}return e.prototype.addListener=function(e,t){this.listeners.set(e,t)},e.prototype.removeListener=function(e){this.listeners.has(e)&&this.listeners.delete(e)},e.prototype.emit=function(e){this.listeners.forEach((function(t){return t(e)}))},e}();t.BaklavaEvent=r;var i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o.__extends(t,e),t.prototype.emit=function(e){var t,n;try{for(var r=o.__values(Array.from(this.listeners.values())),i=r.next();!i.done;i=r.next()){if(!1===(0,i.value)(e))return!0}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!1},t}(r);t.PreventableBaklavaEvent=i;var a=function(){function e(){this.tapMap=new Map,this.taps=[]}return e.prototype.tap=function(e,t){this.tapMap.has(e)&&this.untap(e),this.tapMap.set(e,t),this.taps.push(t)},e.prototype.untap=function(e){if(this.tapMap.has(e)){var t=this.tapMap.get(e);this.tapMap.delete(e);var n=this.taps.indexOf(t);n>=0&&this.taps.splice(n,1)}},e}();t.Hook=a;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o.__extends(t,e),t.prototype.execute=function(e){var t,n,r=e;try{for(var i=o.__values(this.taps),a=i.next();!a.done;a=i.next()){r=(0,a.value)(r)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},t}(a);t.SequentialHook=u},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return r})),n.d(t,"__assign",(function(){return i})),n.d(t,"__rest",(function(){return a})),n.d(t,"__decorate",(function(){return u})),n.d(t,"__param",(function(){return s})),n.d(t,"__metadata",(function(){return c})),n.d(t,"__awaiter",(function(){return f})),n.d(t,"__generator",(function(){return l})),n.d(t,"__createBinding",(function(){return d})),n.d(t,"__exportStar",(function(){return p})),n.d(t,"__values",(function(){return h})),n.d(t,"__read",(function(){return v})),n.d(t,"__spread",(function(){return y})),n.d(t,"__spreadArrays",(function(){return m})),n.d(t,"__await",(function(){return b})),n.d(t,"__asyncGenerator",(function(){return _})),n.d(t,"__asyncDelegator",(function(){return w})),n.d(t,"__asyncValues",(function(){return g})),n.d(t,"__makeTemplateObject",(function(){return O})),n.d(t,"__importStar",(function(){return k})),n.d(t,"__importDefault",(function(){return E})),n.d(t,"__classPrivateFieldGet",(function(){return P})),n.d(t,"__classPrivateFieldSet",(function(){return j}));
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function r(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function a(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function u(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var u=e.length-1;u>=0;u--)(r=e[u])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function s(e,t){return function(n,o){t(n,o,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}s((o=o.apply(e,t||[])).next())}))}function l(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function d(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}function p(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||(t[n]=e[n])}function h(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function m(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,u=i.length;a<u;a++,r++)o[r]=i[a];return o}function b(e){return this instanceof b?(this.v=e,this):new b(e)}function _(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),i=[];return o={},a("next"),a("throw"),a("return"),o[Symbol.asyncIterator]=function(){return this},o;function a(e){r[e]&&(o[e]=function(t){return new Promise((function(n,o){i.push([e,t,n,o])>1||u(e,t)}))})}function u(e,t){try{(n=r[e](t)).value instanceof b?Promise.resolve(n.value.v).then(s,c):f(i[0][2],n)}catch(e){f(i[0][3],e)}var n}function s(e){u("next",e)}function c(e){u("throw",e)}function f(e,t){e(t),i.shift(),i.length&&u(i[0][0],i[0][1])}}function w(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:b(e[o](t)),done:"return"===o}:r?r(t):t}:r}}function g(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=h(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}}function O(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function k(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function E(e){return e&&e.__esModule?e:{default:e}}function P(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function j(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}},function(e,t,n){"use strict";n.r(t),n.d(t,"Connection",(function(){return a})),n.d(t,"DummyConnection",(function(){return u})),n.d(t,"Editor",(function(){return c})),n.d(t,"Node",(function(){return d})),n.d(t,"NodeBuilder",(function(){return h})),n.d(t,"NodeInterface",(function(){return f})),n.d(t,"NodeOption",(function(){return l}));var o=0;function r(){return Date.now().toString()+(o++).toString()}var i=n(0),a=function(){function e(e,t){if(this.isInDanger=!1,this.destructed=!1,this.events={destruct:new i.BaklavaEvent},!e||!t)throw new Error("Cannot initialize connection with null/undefined for 'from' or 'to' values");this.id=r(),this.from=e,this.to=t,this.from.connectionCount++,this.to.connectionCount++}return e.prototype.destruct=function(){this.events.destruct.emit(),this.from.connectionCount--,this.to.connectionCount--,this.destructed=!0},e}(),u=function(e,t){if(!e||!t)throw new Error("Cannot initialize connection with null/undefined for 'from' or 'to' values");this.id=r(),this.from=e,this.to=t},s=n(1),c=function(){function e(){this._plugins=new Set,this._nodes=[],this._connections=[],this._nodeTypes=new Map,this._nodeCategories=new Map([["default",[]]]),this.events={beforeRegisterNodeType:new i.PreventableBaklavaEvent,registerNodeType:new i.BaklavaEvent,beforeAddNode:new i.PreventableBaklavaEvent,addNode:new i.BaklavaEvent,beforeRemoveNode:new i.PreventableBaklavaEvent,removeNode:new i.BaklavaEvent,beforeAddConnection:new i.PreventableBaklavaEvent,addConnection:new i.BaklavaEvent,checkConnection:new i.PreventableBaklavaEvent,beforeRemoveConnection:new i.PreventableBaklavaEvent,removeConnection:new i.BaklavaEvent,beforeUsePlugin:new i.PreventableBaklavaEvent,usePlugin:new i.BaklavaEvent},this.hooks={save:new i.SequentialHook,load:new i.SequentialHook}}return Object.defineProperty(e.prototype,"nodes",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){return this._connections},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nodeTypes",{get:function(){return this._nodeTypes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nodeCategories",{get:function(){return this._nodeCategories},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"plugins",{get:function(){return this._plugins},enumerable:!1,configurable:!0}),e.prototype.registerNodeType=function(e,t,n){void 0===n&&(n="default"),this.events.beforeRegisterNodeType.emit({typeName:e,type:t,category:n})||(this._nodeTypes.set(e,t),this.nodeCategories.has(n)||this._nodeCategories.set(n,[]),this.nodeCategories.get(n).push(e),this.events.registerNodeType.emit({typeName:e,type:t,category:n}))},e.prototype.addNode=function(e){if(!this.events.beforeAddNode.emit(e))return e.registerEditor(this),this._nodes.push(e),this.events.addNode.emit(e),e},e.prototype.removeNode=function(e){var t=this;if(this.nodes.includes(e)){if(this.events.beforeRemoveNode.emit(e))return;this.connections.filter((function(t){return t.from.parent===e||t.to.parent===e})).forEach((function(e){return t.removeConnection(e)})),this._nodes.splice(this.nodes.indexOf(e),1),this.events.removeNode.emit(e)}},e.prototype.addConnection=function(e,t){var n=this.checkConnection(e,t);if(n&&!this.events.beforeAddConnection.emit({from:e,to:t})){var o=new a(n.from,n.to);return this._connections.push(o),this.events.addConnection.emit(o),o}},e.prototype.removeConnection=function(e){if(this.connections.includes(e)){if(this.events.beforeRemoveConnection.emit(e))return;e.destruct(),this._connections.splice(this.connections.indexOf(e),1),this.events.removeConnection.emit(e)}},e.prototype.checkConnection=function(e,t){if(!e||!t)return!1;if(e.parent===t.parent)return!1;if(e.isInput&&!t.isInput){var n=e;e=t,t=n}return!(e.isInput||!t.isInput)&&(!this.connections.some((function(n){return n.from===e&&n.to===t}))&&(!this.events.checkConnection.emit({from:e,to:t})&&new u(e,t)))},e.prototype.load=function(e){for(var t,n,o,r,i=[],a=this.connections.length-1;a>=0;a--)this.removeConnection(this.connections[a]);for(a=this.nodes.length-1;a>=0;a--)this.removeNode(this.nodes[a]);try{for(var u=Object(s.__values)(e.nodes),c=u.next();!c.done;c=u.next()){var f=c.value,l=this.nodeTypes.get(f.type);if(l){var d=new l;this.addNode(d),d.load(f)}else i.push("Node type "+f.type+" is not registered")}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}try{for(var p=Object(s.__values)(e.connections),h=p.next();!h.done;h=p.next()){var v=h.value,y=this.findNodeInterface(v.from),m=this.findNodeInterface(v.to);if(y)if(m){var b=this.addConnection(y,m);b?b.id=v.id:i.push("Unable to create connection from "+v.from+" to "+v.to)}else i.push("Could not find interface with id "+v.to);else i.push("Could not find interface with id "+v.from)}}catch(e){o={error:e}}finally{try{h&&!h.done&&(r=p.return)&&r.call(p)}finally{if(o)throw o.error}}return this.hooks.load.execute(e),i.forEach((function(e){return console.warn(e)})),i},e.prototype.save=function(){var e={nodes:this.nodes.map((function(e){return e.save()})),connections:this.connections.map((function(e){return{id:e.id,from:e.from.id,to:e.to.id}}))};return this.hooks.save.execute(e)},e.prototype.use=function(e){return!this.events.beforeUsePlugin.emit(e)&&(this._plugins.add(e),e.register(this),this.events.usePlugin.emit(e),!0)},e.prototype.generateId=function(e){return void 0===e&&(e=""),e+r()},e.prototype.findNodeInterface=function(e){var t,n,o,r;try{for(var i=Object(s.__values)(this.nodes),a=i.next();!a.done;a=i.next()){var u=a.value;try{for(var c=(o=void 0,Object(s.__values)(u.interfaces.keys())),f=c.next();!f.done;f=c.next()){var l=f.value;if(u.interfaces.get(l).id===e)return u.interfaces.get(l)}}catch(e){o={error:e}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(o)throw o.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},e}(),f=function(){function e(e,t){this.events={setConnectionCount:new i.BaklavaEvent,beforeSetValue:new i.PreventableBaklavaEvent,setValue:new i.BaklavaEvent,updated:new i.BaklavaEvent},this.hooks={load:new i.SequentialHook,save:new i.SequentialHook},this._connectionCount=0,this._value=null,this.parent=e,this.isInput=t,this.id="ni_"+r()}return Object.defineProperty(e.prototype,"connectionCount",{get:function(){return this._connectionCount},set:function(e){this._connectionCount=e,this.events.setConnectionCount.emit(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){this.events.beforeSetValue.emit(e)||(this._value=e,this.events.setValue.emit(e))},enumerable:!1,configurable:!0}),e.prototype.load=function(e){this.id=e.id,this.value=e.value,this.hooks.load.execute(e)},e.prototype.save=function(){var e={id:this.id,value:this.value};return this.hooks.save.execute(e)},e}(),l=function(){function e(e,t,n){this.events={beforeSetValue:new i.PreventableBaklavaEvent,setValue:new i.BaklavaEvent,updated:new i.BaklavaEvent},this.optionComponent=e,this.sidebarComponent=n,this._value=t}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){this.events.beforeSetValue.emit(e)||(this._value=e,this.events.setValue.emit(e))},enumerable:!1,configurable:!0}),e}(),d=function(){function e(){this.id="node_"+r(),this.interfaces=new Map,this.options=new Map,this.state={},this.events={beforeAddInterface:new i.PreventableBaklavaEvent,addInterface:new i.BaklavaEvent,beforeRemoveInterface:new i.PreventableBaklavaEvent,removeInterface:new i.BaklavaEvent,beforeAddOption:new i.PreventableBaklavaEvent,addOption:new i.BaklavaEvent,beforeRemoveOption:new i.PreventableBaklavaEvent,removeOption:new i.BaklavaEvent,update:new i.BaklavaEvent},this.hooks={load:new i.SequentialHook,save:new i.SequentialHook}}return Object.defineProperty(e.prototype,"inputInterfaces",{get:function(){var e={};return this.interfaces.forEach((function(t,n){t.isInput&&(e[n]=t)})),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outputInterfaces",{get:function(){var e={};return this.interfaces.forEach((function(t,n){t.isInput||(e[n]=t)})),e},enumerable:!1,configurable:!0}),e.prototype.load=function(e){var t=this;this.id=e.id,this.name=e.name,this.state=e.state,e.options.forEach((function(e){var n=Object(s.__read)(e,2),o=n[0],r=n[1];t.options.has(o)&&(t.options.get(o).value=r)})),e.interfaces.forEach((function(e){var n=Object(s.__read)(e,2),o=n[0],r=n[1];t.interfaces.has(o)&&t.interfaces.get(o).load(r)})),this.hooks.load.execute(e)},e.prototype.save=function(){var e={type:this.type,id:this.id,name:this.name,options:Array.from(this.options.entries()).map((function(e){var t=Object(s.__read)(e,2);return[t[0],t[1].value]})),state:this.state,interfaces:Array.from(this.interfaces.entries()).map((function(e){var t=Object(s.__read)(e,2);return[t[0],t[1].save()]}))};return this.hooks.save.execute(e)},e.prototype.calculate=function(e){},e.prototype.addInputInterface=function(e,t,n,o){var r=this;if(void 0===n&&(n=null),!this.events.beforeAddInterface.emit({name:e,isInput:!0,option:t,defaultValue:n})){var i=this.addInterface(!0,e,t);return i.events.setValue.addListener(this,(function(){return r.events.update.emit({name:e,interface:i})})),i.value=n,Object.entries(o||{}).forEach((function(e){var t=Object(s.__read)(e,2),n=t[0],o=t[1];i[n]=o})),this.events.addInterface.emit(i),i}},e.prototype.addOutputInterface=function(e,t){if(!this.events.beforeAddInterface.emit({name:e,isInput:!1})){var n=this.addInterface(!1,e);return Object.entries(t||{}).forEach((function(e){var t=Object(s.__read)(e,2),o=t[0],r=t[1];n[o]=r})),this.events.addInterface.emit(n),n}},e.prototype.removeInterface=function(e){var t=this,n=this.getInterface(e);if(n){if(this.events.beforeRemoveInterface.emit(n))return;if(n.connectionCount>0){if(!this.editorInstance)throw new Error("Interface is connected, but no editor instance is specified. Unable to delete interface");this.editorInstance.connections.filter((function(e){return e.from===n||e.to===n})).forEach((function(e){t.editorInstance.removeConnection(e)}))}this.interfaces.delete(e),this.events.removeInterface.emit(n)}},e.prototype.addOption=function(e,t,n,o,r){var i=this;if(void 0===n&&(n=null),!this.events.beforeAddOption.emit({name:e,component:t,defaultValue:n,sidebarComponent:o})){var a=new l(t,n,o);return Object.entries(r||{}).forEach((function(e){var t=Object(s.__read)(e,2),n=t[0],o=t[1];a[n]=o})),a.events.setValue.addListener(this,(function(){i.events.update.emit({name:e,option:a})})),this.options.set(e,a),this.events.addOption.emit({name:e,option:a}),a}},e.prototype.removeOption=function(e){if(this.options.has(e)){var t=this.options.get(e);if(this.events.beforeRemoveOption.emit({name:e,option:t}))return;this.options.delete(e),this.events.removeOption.emit({name:e,option:t})}},e.prototype.getInterface=function(e){if(!this.interfaces.has(e))throw new Error("No interface named '"+e+"'");return this.interfaces.get(e)},e.prototype.getOptionValue=function(e){if(!this.options.has(e))throw new Error("No option named '"+e+"'");return this.options.get(e).value},e.prototype.setOptionValue=function(e,t){if(!this.options.has(e))throw new Error("No option named '"+e+"'");this.options.get(e).value=t},e.prototype.registerEditor=function(e){this.editorInstance=e},e.prototype.addInterface=function(e,t,n){var o=new f(this,e);return o.option=n,this.interfaces.set(t,o),o},e}();function p(e){return"function"==typeof e?e():e}var h=function(){function e(e,t){this.type="",this.name="",this.intfs=[],this.options=new Map,this.type=e,this.name=e,this.additionalProperties=t}return e.prototype.build=function(){return e=this.type,t=this.name,n=this.additionalProperties,o=this.intfs,r=this.options,i=this.calcFunction,function(a){function u(){var i,u,c=a.call(this)||this;c.type=e,c.name=t,n&&Object.assign(c,n);try{for(var f=Object(s.__values)(o),l=f.next();!l.done;l=f.next()){var d=l.value;d.isInput?c.addInputInterface(d.name,d.option,p(d.defaultValue),d.additionalProperties):c.addOutputInterface(d.name,d.additionalProperties)}}catch(e){i={error:e}}finally{try{l&&!l.done&&(u=f.return)&&u.call(f)}finally{if(i)throw i.error}}return Array.from(r.entries()).forEach((function(e){var t=Object(s.__read)(e,2),n=t[0],o=t[1];c.addOption(n,o.optionComponent,p(o.value),o.sidebarComponent,o.additionalProperties)})),c}return Object(s.__extends)(u,a),u.prototype.calculate=function(e){if(i)return i.call(this,this,e)},u}(d);var e,t,n,o,r,i},e.prototype.setName=function(e){return this.name=e,this},e.prototype.addInputInterface=function(e,t,n,o){return void 0===n&&(n=null),this.checkDefaultValue(n),this.intfs.push({isInput:!0,name:e,option:t,defaultValue:n,additionalProperties:o}),this},e.prototype.addOutputInterface=function(e,t){return this.intfs.push({isInput:!1,name:e,additionalProperties:t}),this},e.prototype.addOption=function(e,t,n,o,r){return void 0===n&&(n=null),this.checkDefaultValue(n),this.options.set(e,{value:n,optionComponent:t,sidebarComponent:o,additionalProperties:r}),this},e.prototype.onCalculate=function(e){return this.calcFunction=e,this},e.prototype.checkDefaultValue=function(e){if("object"==typeof e&&null!==e)throw new Error("If the default value is an object, provide a generator function instead of the object")},e}()}])}));
/*! For license information please see index.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("BaklavaJS",[],t):"object"==typeof exports?exports.BaklavaJS=t():e.BaklavaJS=t()}("undefined"!=typeof self?self:this,(function(){return(()=>{"use strict";var e={163:(e,t,n)=>{n.r(t),n.d(t,{__assign:()=>i,__asyncDelegator:()=>g,__asyncGenerator:()=>_,__asyncValues:()=>O,__await:()=>b,__awaiter:()=>f,__classPrivateFieldGet:()=>P,__classPrivateFieldSet:()=>j,__createBinding:()=>l,__decorate:()=>s,__exportStar:()=>d,__extends:()=>r,__generator:()=>p,__importDefault:()=>x,__importStar:()=>E,__makeTemplateObject:()=>I,__metadata:()=>u,__param:()=>c,__read:()=>v,__rest:()=>a,__spread:()=>y,__spreadArray:()=>w,__spreadArrays:()=>m,__values:()=>h});var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)};function a(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function s(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function c(e,t){return function(n,o){t(n,o,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function s(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))}function p(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var l=Object.create?function(e,t,n,o){void 0===o&&(o=n),Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]};function d(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||l(t,e,n)}function h(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function m(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o}function w(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function b(e){return this instanceof b?(this.v=e,this):new b(e)}function _(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),i=[];return o={},a("next"),a("throw"),a("return"),o[Symbol.asyncIterator]=function(){return this},o;function a(e){r[e]&&(o[e]=function(t){return new Promise((function(n,o){i.push([e,t,n,o])>1||s(e,t)}))})}function s(e,t){try{(n=r[e](t)).value instanceof b?Promise.resolve(n.value.v).then(c,u):f(i[0][2],n)}catch(e){f(i[0][3],e)}var n}function c(e){s("next",e)}function u(e){s("throw",e)}function f(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function g(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:b(e[o](t)),done:"return"===o}:r?r(t):t}:r}}function O(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=h(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){!function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)}(o,r,(t=e[n](t)).done,t.value)}))}}}function I(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var C=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function E(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&l(t,e,n);return C(t,e),t}function x(e){return e&&e.__esModule?e:{default:e}}function P(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)}function j(e,t,n,o,r){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?r.call(e,n):r?r.value=n:t.set(e,n),n}},749:(e,t,n)=>{t.p$=t.wD=t.EZ=void 0;var o=n(163),r=function(){function e(){this.listeners=new Map}return e.prototype.addListener=function(e,t){this.listeners.set(e,t)},e.prototype.removeListener=function(e){this.listeners.has(e)&&this.listeners.delete(e)},e.prototype.emit=function(e){this.listeners.forEach((function(t){return t(e)}))},e}();t.EZ=r;var i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o.__extends(t,e),t.prototype.emit=function(e){var t,n;try{for(var r=o.__values(Array.from(this.listeners.values())),i=r.next();!i.done;i=r.next())if(!1===(0,i.value)(e))return!0}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!1},t}(r);t.wD=i;var a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o.__extends(t,e),t.prototype.execute=function(e){var t,n,r=e;try{for(var i=o.__values(this.taps),a=i.next();!a.done;a=i.next())r=(0,a.value)(r)}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},t}(function(){function e(){this.tapMap=new Map,this.taps=[]}return e.prototype.tap=function(e,t){this.tapMap.has(e)&&this.untap(e),this.tapMap.set(e,t),this.taps.push(t)},e.prototype.untap=function(e){if(this.tapMap.has(e)){var t=this.tapMap.get(e);this.tapMap.delete(e);var n=this.taps.indexOf(t);n>=0&&this.taps.splice(n,1)}},e}());t.p$=a}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{Connection:()=>i,DummyConnection:()=>a,Editor:()=>c,Node:()=>p,NodeBuilder:()=>d,NodeInterface:()=>u,NodeOption:()=>f});var e=0;function t(){return Date.now().toString()+(e++).toString()}var r=n(749),i=function(){function e(e,n){if(this.isInDanger=!1,this.destructed=!1,this.events={destruct:new r.EZ},!e||!n)throw new Error("Cannot initialize connection with null/undefined for 'from' or 'to' values");this.id=t(),this.from=e,this.to=n,this.from.connectionCount++,this.to.connectionCount++}return e.prototype.destruct=function(){this.events.destruct.emit(),this.from.connectionCount--,this.to.connectionCount--,this.destructed=!0},e}(),a=function(e,n){if(!e||!n)throw new Error("Cannot initialize connection with null/undefined for 'from' or 'to' values");this.id=t(),this.from=e,this.to=n},s=n(163),c=function(){function e(){this._plugins=new Set,this._nodes=[],this._connections=[],this._nodeTypes=new Map,this._nodeCategories=new Map([["default",[]]]),this.events={beforeRegisterNodeType:new r.wD,registerNodeType:new r.EZ,beforeAddNode:new r.wD,addNode:new r.EZ,beforeRemoveNode:new r.wD,removeNode:new r.EZ,beforeAddConnection:new r.wD,addConnection:new r.EZ,checkConnection:new r.wD,beforeRemoveConnection:new r.wD,removeConnection:new r.EZ,beforeUsePlugin:new r.wD,usePlugin:new r.EZ},this.hooks={save:new r.p$,load:new r.p$}}return Object.defineProperty(e.prototype,"nodes",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){return this._connections},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nodeTypes",{get:function(){return this._nodeTypes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nodeCategories",{get:function(){return this._nodeCategories},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"plugins",{get:function(){return this._plugins},enumerable:!1,configurable:!0}),e.prototype.registerNodeType=function(e,t,n){void 0===n&&(n="default"),this.events.beforeRegisterNodeType.emit({typeName:e,type:t,category:n})||(this._nodeTypes.set(e,t),this.nodeCategories.has(n)||this._nodeCategories.set(n,[]),this.nodeCategories.get(n).push(e),this.events.registerNodeType.emit({typeName:e,type:t,category:n}))},e.prototype.addNode=function(e){if(!this.events.beforeAddNode.emit(e))return e.registerEditor(this),this._nodes.push(e),this.events.addNode.emit(e),e},e.prototype.removeNode=function(e){var t=this;if(this.nodes.includes(e)){if(this.events.beforeRemoveNode.emit(e))return;this.connections.filter((function(t){return t.from.parent===e||t.to.parent===e})).forEach((function(e){return t.removeConnection(e)})),this._nodes.splice(this.nodes.indexOf(e),1),this.events.removeNode.emit(e)}},e.prototype.addConnection=function(e,t){var n=this.checkConnection(e,t);if(n&&!this.events.beforeAddConnection.emit({from:e,to:t})){var o=new i(n.from,n.to);return this._connections.push(o),this.events.addConnection.emit(o),o}},e.prototype.removeConnection=function(e){if(this.connections.includes(e)){if(this.events.beforeRemoveConnection.emit(e))return;e.destruct(),this._connections.splice(this.connections.indexOf(e),1),this.events.removeConnection.emit(e)}},e.prototype.checkConnection=function(e,t){if(!e||!t)return!1;if(e.parent===t.parent)return!1;if(e.isInput&&!t.isInput){var n=e;e=t,t=n}return!(e.isInput||!t.isInput)&&!this.connections.some((function(n){return n.from===e&&n.to===t}))&&!this.events.checkConnection.emit({from:e,to:t})&&new a(e,t)},e.prototype.load=function(e){for(var t,n,o,r,i=[],a=this.connections.length-1;a>=0;a--)this.removeConnection(this.connections[a]);for(a=this.nodes.length-1;a>=0;a--)this.removeNode(this.nodes[a]);try{for(var c=(0,s.__values)(e.nodes),u=c.next();!u.done;u=c.next()){var f=u.value,p=this.nodeTypes.get(f.type);if(p){var l=new p;this.addNode(l),l.load(f)}else i.push("Node type ".concat(f.type," is not registered"))}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}try{for(var d=(0,s.__values)(e.connections),h=d.next();!h.done;h=d.next()){var v=h.value,y=this.findNodeInterface(v.from),m=this.findNodeInterface(v.to);if(y)if(m){var w=this.addConnection(y,m);w?w.id=v.id:i.push("Unable to create connection from ".concat(v.from," to ").concat(v.to))}else i.push("Could not find interface with id ".concat(v.to));else i.push("Could not find interface with id ".concat(v.from))}}catch(e){o={error:e}}finally{try{h&&!h.done&&(r=d.return)&&r.call(d)}finally{if(o)throw o.error}}return this.hooks.load.execute(e),i.forEach((function(e){return console.warn(e)})),i},e.prototype.save=function(){var e={nodes:this.nodes.map((function(e){return e.save()})),connections:this.connections.map((function(e){return{id:e.id,from:e.from.id,to:e.to.id}}))};return this.hooks.save.execute(e)},e.prototype.use=function(e){return!this.events.beforeUsePlugin.emit(e)&&(this._plugins.add(e),e.register(this),this.events.usePlugin.emit(e),!0)},e.prototype.generateId=function(e){return void 0===e&&(e=""),e+t()},e.prototype.findNodeInterface=function(e){var t,n,o,r;try{for(var i=(0,s.__values)(this.nodes),a=i.next();!a.done;a=i.next()){var c=a.value;try{for(var u=(o=void 0,(0,s.__values)(c.interfaces.keys())),f=u.next();!f.done;f=u.next()){var p=f.value;if(c.interfaces.get(p).id===e)return c.interfaces.get(p)}}catch(e){o={error:e}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(o)throw o.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},e}(),u=function(){function e(e,n){this.events={setConnectionCount:new r.EZ,beforeSetValue:new r.wD,setValue:new r.EZ,updated:new r.EZ},this.hooks={load:new r.p$,save:new r.p$},this._connectionCount=0,this._value=null,this.parent=e,this.isInput=n,this.id="ni_"+t()}return Object.defineProperty(e.prototype,"connectionCount",{get:function(){return this._connectionCount},set:function(e){this._connectionCount=e,this.events.setConnectionCount.emit(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){this.events.beforeSetValue.emit(e)||(this._value=e,this.events.setValue.emit(e))},enumerable:!1,configurable:!0}),e.prototype.load=function(e){this.id=e.id,this.value=e.value,this.hooks.load.execute(e)},e.prototype.save=function(){var e={id:this.id,value:this.value};return this.hooks.save.execute(e)},e}(),f=function(){function e(e,t,n){this.events={beforeSetValue:new r.wD,setValue:new r.EZ,updated:new r.EZ},this.optionComponent=e,this.sidebarComponent=n,this._value=t}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){this.events.beforeSetValue.emit(e)||(this._value=e,this.events.setValue.emit(e))},enumerable:!1,configurable:!0}),e}(),p=function(){function e(){this.id="node_"+t(),this.interfaces=new Map,this.options=new Map,this.state={},this.events={beforeAddInterface:new r.wD,addInterface:new r.EZ,beforeRemoveInterface:new r.wD,removeInterface:new r.EZ,beforeAddOption:new r.wD,addOption:new r.EZ,beforeRemoveOption:new r.wD,removeOption:new r.EZ,update:new r.EZ},this.hooks={load:new r.p$,save:new r.p$}}return Object.defineProperty(e.prototype,"inputInterfaces",{get:function(){var e={};return this.interfaces.forEach((function(t,n){t.isInput&&(e[n]=t)})),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outputInterfaces",{get:function(){var e={};return this.interfaces.forEach((function(t,n){t.isInput||(e[n]=t)})),e},enumerable:!1,configurable:!0}),e.prototype.load=function(e){var t=this;this.id=e.id,this.name=e.name,this.state=e.state,e.options.forEach((function(e){var n=(0,s.__read)(e,2),o=n[0],r=n[1];t.options.has(o)&&(t.options.get(o).value=r)})),e.interfaces.forEach((function(e){var n=(0,s.__read)(e,2),o=n[0],r=n[1];t.interfaces.has(o)&&t.interfaces.get(o).load(r)})),this.hooks.load.execute(e)},e.prototype.save=function(){var e={type:this.type,id:this.id,name:this.name,options:Array.from(this.options.entries()).map((function(e){var t=(0,s.__read)(e,2);return[t[0],t[1].value]})),state:this.state,interfaces:Array.from(this.interfaces.entries()).map((function(e){var t=(0,s.__read)(e,2);return[t[0],t[1].save()]}))};return this.hooks.save.execute(e)},e.prototype.calculate=function(e){},e.prototype.addInputInterface=function(e,t,n,o){var r=this;if(void 0===n&&(n=null),!this.events.beforeAddInterface.emit({name:e,isInput:!0,option:t,defaultValue:n})){var i=this.addInterface(!0,e,t);return i.events.setValue.addListener(this,(function(){return r.events.update.emit({name:e,interface:i})})),i.value=n,Object.entries(o||{}).forEach((function(e){var t=(0,s.__read)(e,2),n=t[0],o=t[1];i[n]=o})),this.events.addInterface.emit(i),i}},e.prototype.addOutputInterface=function(e,t){if(!this.events.beforeAddInterface.emit({name:e,isInput:!1})){var n=this.addInterface(!1,e);return Object.entries(t||{}).forEach((function(e){var t=(0,s.__read)(e,2),o=t[0],r=t[1];n[o]=r})),this.events.addInterface.emit(n),n}},e.prototype.removeInterface=function(e){var t=this,n=this.getInterface(e);if(n){if(this.events.beforeRemoveInterface.emit(n))return;if(n.connectionCount>0){if(!this.editorInstance)throw new Error("Interface is connected, but no editor instance is specified. Unable to delete interface");this.editorInstance.connections.filter((function(e){return e.from===n||e.to===n})).forEach((function(e){t.editorInstance.removeConnection(e)}))}this.interfaces.delete(e),this.events.removeInterface.emit(n)}},e.prototype.addOption=function(e,t,n,o,r){var i=this;if(void 0===n&&(n=null),!this.events.beforeAddOption.emit({name:e,component:t,defaultValue:n,sidebarComponent:o})){var a=new f(t,n,o);return Object.entries(r||{}).forEach((function(e){var t=(0,s.__read)(e,2),n=t[0],o=t[1];a[n]=o})),a.events.setValue.addListener(this,(function(){i.events.update.emit({name:e,option:a})})),this.options.set(e,a),this.events.addOption.emit({name:e,option:a}),a}},e.prototype.removeOption=function(e){if(this.options.has(e)){var t=this.options.get(e);if(this.events.beforeRemoveOption.emit({name:e,option:t}))return;this.options.delete(e),this.events.removeOption.emit({name:e,option:t})}},e.prototype.getInterface=function(e){if(!this.interfaces.has(e))throw new Error("No interface named '".concat(e,"'"));return this.interfaces.get(e)},e.prototype.getOptionValue=function(e){if(!this.options.has(e))throw new Error("No option named '".concat(e,"'"));return this.options.get(e).value},e.prototype.setOptionValue=function(e,t){if(!this.options.has(e))throw new Error("No option named '".concat(e,"'"));this.options.get(e).value=t},e.prototype.registerEditor=function(e){this.editorInstance=e},e.prototype.addInterface=function(e,t,n){var o=new u(this,e);return o.option=n,this.interfaces.set(t,o),o},e}();function l(e){return"function"==typeof e?e():e}var d=function(){function e(e,t){this.type="",this.name="",this.intfs=[],this.options=new Map,this.type=e,this.name=e,this.additionalProperties=t}return e.prototype.build=function(){return e=this.type,t=this.name,n=this.additionalProperties,o=this.intfs,r=this.options,i=this.calcFunction,function(a){function c(){var i,c,u=a.call(this)||this;u.type=e,u.name=t,n&&Object.assign(u,n);try{for(var f=(0,s.__values)(o),p=f.next();!p.done;p=f.next()){var d=p.value;d.isInput?u.addInputInterface(d.name,d.option,l(d.defaultValue),d.additionalProperties):u.addOutputInterface(d.name,d.additionalProperties)}}catch(e){i={error:e}}finally{try{p&&!p.done&&(c=f.return)&&c.call(f)}finally{if(i)throw i.error}}return Array.from(r.entries()).forEach((function(e){var t=(0,s.__read)(e,2),n=t[0],o=t[1];u.addOption(n,o.optionComponent,l(o.value),o.sidebarComponent,o.additionalProperties)})),u}return(0,s.__extends)(c,a),c.prototype.calculate=function(e){if(i)return i.call(this,this,e)},c}(p);var e,t,n,o,r,i},e.prototype.setName=function(e){return this.name=e,this},e.prototype.addInputInterface=function(e,t,n,o){return void 0===n&&(n=null),this.checkDefaultValue(n),this.intfs.push({isInput:!0,name:e,option:t,defaultValue:n,additionalProperties:o}),this},e.prototype.addOutputInterface=function(e,t){return this.intfs.push({isInput:!1,name:e,additionalProperties:t}),this},e.prototype.addOption=function(e,t,n,o,r){return void 0===n&&(n=null),this.checkDefaultValue(n),this.options.set(e,{value:n,optionComponent:t,sidebarComponent:o,additionalProperties:r}),this},e.prototype.onCalculate=function(e){return this.calcFunction=e,this},e.prototype.checkDefaultValue=function(e){if("object"==typeof e&&null!==e)throw new Error("If the default value is an object, provide a generator function instead of the object")},e}()})(),o})()}));
{
"name": "@baklavajs/core",
"version": "1.9.1",
"version": "1.9.3",
"description": "Core logic of BaklavaJS, a graph editor / node editor for the web",

@@ -26,19 +26,19 @@ "author": "newcat <freddy.wagner@web.de>",

"dependencies": {
"@baklavajs/events": "^1.8.2"
"@baklavajs/events": "^1.9.3"
},
"devDependencies": {
"@ts-tools/node": "^2.1.1",
"@types/chai": "^4.2.14",
"@types/mocha": "^8.2.0",
"@types/sinon": "^9.0.10",
"chai": "^4.2.0",
"clean-webpack-plugin": "^3.0.0",
"mocha": "^8.2.1",
"sinon": "^9.2.4",
"ts-loader": "^8.0.14",
"typescript": "^4.1.3",
"webpack": "^4.42.1",
"webpack-bundle-analyzer": "^4.4.0",
"webpack-cli": "^4.4.0",
"webpack-merge": "^4.2.2"
"@ts-tools/node": "^3.0.1",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.1.0",
"@types/sinon": "^10.0.11",
"chai": "^4.3.6",
"clean-webpack-plugin": "^4.0.0",
"mocha": "^9.2.1",
"sinon": "^13.0.1",
"ts-loader": "^9.2.7",
"typescript": "^4.6.2",
"webpack": "^5.70.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.9.2",
"webpack-merge": "^5.8.0"
},

@@ -48,3 +48,3 @@ "publishConfig": {

},
"gitHead": "16ba1018c9a96e94e7596944218729faf228ce1d"
"gitHead": "e4ce5c4e355652de421db822f31a73a48dc35831"
}

@@ -0,0 +0,0 @@ # `baklavajs-core`

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