Comparing version 2.0.1 to 2.0.2
@@ -58,3 +58,3 @@ import { Scope } from './scope'; | ||
* Get all nodes | ||
* @returns All nodes | ||
* @returns Copy of array with nodes | ||
*/ | ||
@@ -64,3 +64,3 @@ getNodes(): Scheme["Node"][]; | ||
* Get all connections | ||
* @returns All connections | ||
* @returns Copy of array with onnections | ||
*/ | ||
@@ -67,0 +67,0 @@ getConnections(): Scheme["Connection"][]; |
@@ -10,5 +10,10 @@ /** | ||
* The socket class | ||
* @priority 7 | ||
*/ | ||
export declare class Socket { | ||
name: string; | ||
/** | ||
* @constructor | ||
* @param name Name of the socket | ||
*/ | ||
constructor(name: string); | ||
@@ -23,4 +28,16 @@ } | ||
multipleConnections?: boolean; | ||
/** | ||
* Port id, unique string generated by `getUID` function | ||
*/ | ||
id: PortId; | ||
/** | ||
* Port index, used for sorting ports. Default is `0` | ||
*/ | ||
index?: number; | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the port | ||
* @param multipleConnections Whether the output port can have multiple connections | ||
*/ | ||
constructor(socket: S, label?: string, multipleConnections?: boolean); | ||
@@ -30,7 +47,31 @@ } | ||
* The input port class | ||
* @priority 6 | ||
*/ | ||
export declare class Input<S extends Socket> extends Port<S> { | ||
socket: S; | ||
label?: string; | ||
multipleConnections?: boolean; | ||
/** | ||
* Control instance | ||
*/ | ||
control: Control | null; | ||
/** | ||
* Whether the control is visible. Can be managed dynamically by extensions. Default is `true` | ||
*/ | ||
showControl: boolean; | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the input port | ||
* @param multipleConnections Whether the output port can have multiple connections. Default is `false` | ||
*/ | ||
constructor(socket: S, label?: string, multipleConnections?: boolean); | ||
/** | ||
* Add control to the input port | ||
* @param control Control instance | ||
*/ | ||
addControl(control: Control): void; | ||
/** | ||
* Remove control from the input port | ||
*/ | ||
removeControl(): void; | ||
@@ -40,4 +81,11 @@ } | ||
* The output port class | ||
* @priority 5 | ||
*/ | ||
export declare class Output<S extends Socket> extends Port<S> { | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the output port | ||
* @param multipleConnections Whether the output port can have multiple connections. Default is `true` | ||
*/ | ||
constructor(socket: S, label?: string, multipleConnections?: boolean); | ||
@@ -47,11 +95,24 @@ } | ||
* General control class | ||
* @priority 5 | ||
*/ | ||
export declare class Control { | ||
/** | ||
* Control id, unique string generated by `getUID` function | ||
*/ | ||
id: string; | ||
/** | ||
* Control index, used for sorting controls. Default is `0` | ||
*/ | ||
index?: number; | ||
constructor(); | ||
} | ||
/** | ||
* Input control options | ||
*/ | ||
declare type InputControlOptions<N> = { | ||
/** Whether the control is readonly. Default is `false` */ | ||
readonly?: boolean; | ||
/** Initial value of the control */ | ||
initial?: N; | ||
/** Callback function that is called when the control value changes */ | ||
change?: (value: N) => void; | ||
@@ -68,3 +129,12 @@ }; | ||
readonly: boolean; | ||
/** | ||
* @constructor | ||
* @param type Type of the control: `text` or `number` | ||
* @param options Control options | ||
*/ | ||
constructor(type: T, options?: InputControlOptions<N>); | ||
/** | ||
* Set control value | ||
* @param value Value to set | ||
*/ | ||
setValue(value?: N): void; | ||
@@ -74,5 +144,3 @@ } | ||
* The node class | ||
* @typeParam Inputs - The inputs type | ||
* @typeParam Outputs - The outputs type | ||
* @typeParam Controls - The controls type | ||
* @priority 10 | ||
* @example new Node('math') | ||
@@ -94,10 +162,25 @@ */ | ||
label: string; | ||
/** | ||
* Node id, unique string generated by `getUID` function | ||
*/ | ||
id: NodeBase['id']; | ||
/** | ||
* Node inputs | ||
*/ | ||
inputs: { | ||
[key in keyof Inputs]?: Input<Exclude<Inputs[key], undefined>>; | ||
}; | ||
/** | ||
* Node outputs | ||
*/ | ||
outputs: { | ||
[key in keyof Outputs]?: Output<Exclude<Outputs[key], undefined>>; | ||
}; | ||
/** | ||
* Node controls | ||
*/ | ||
controls: Controls; | ||
/** | ||
* Whether the node is selected. Default is `false` | ||
*/ | ||
selected?: boolean; | ||
@@ -115,8 +198,28 @@ constructor(label: string); | ||
} | ||
/** | ||
* The connection class | ||
* @priority 9 | ||
*/ | ||
export declare class Connection<Source extends Node, Target extends Node> implements ConnectionBase { | ||
sourceOutput: keyof Source['outputs']; | ||
targetInput: keyof Target['inputs']; | ||
/** | ||
* Connection id, unique string generated by `getUID` function | ||
*/ | ||
id: ConnectionBase['id']; | ||
/** | ||
* Source node id | ||
*/ | ||
source: NodeBase['id']; | ||
/** | ||
* Target node id | ||
*/ | ||
target: NodeBase['id']; | ||
/** | ||
* @constructor | ||
* @param source Source node instance | ||
* @param sourceOutput Source node output key | ||
* @param target Target node instance | ||
* @param targetInput Target node input key | ||
*/ | ||
constructor(source: Source, sourceOutput: keyof Source['outputs'], target: Target, targetInput: keyof Target['inputs']); | ||
@@ -123,0 +226,0 @@ } |
{ | ||
"name": "rete", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "JavaScript framework", | ||
@@ -34,2 +34,2 @@ "author": "Vitaliy Stoliarov", | ||
"typings": "_types/index.d.ts" | ||
} | ||
} |
@@ -235,3 +235,3 @@ /*! | ||
* Get all nodes | ||
* @returns All nodes | ||
* @returns Copy of array with nodes | ||
*/ | ||
@@ -241,3 +241,3 @@ }, { | ||
value: function getNodes() { | ||
return this.nodes; | ||
return this.nodes.slice(); | ||
} | ||
@@ -247,3 +247,3 @@ | ||
* Get all connections | ||
* @returns All connections | ||
* @returns Copy of array with onnections | ||
*/ | ||
@@ -253,3 +253,3 @@ }, { | ||
value: function getConnections() { | ||
return this.connections; | ||
return this.connections.slice(); | ||
} | ||
@@ -614,4 +614,10 @@ | ||
* The socket class | ||
* @priority 7 | ||
*/ | ||
var Socket = /*#__PURE__*/_createClass__default["default"](function Socket(name) { | ||
var Socket = /*#__PURE__*/_createClass__default["default"]( | ||
/** | ||
* @constructor | ||
* @param name Name of the socket | ||
*/ | ||
function Socket(name) { | ||
_classCallCheck__default["default"](this, Socket); | ||
@@ -624,3 +630,18 @@ this.name = name; | ||
*/ | ||
var Port = /*#__PURE__*/_createClass__default["default"](function Port(socket, label, multipleConnections) { | ||
var Port = /*#__PURE__*/_createClass__default["default"]( | ||
/** | ||
* Port id, unique string generated by `getUID` function | ||
*/ | ||
/** | ||
* Port index, used for sorting ports. Default is `0` | ||
*/ | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the port | ||
* @param multipleConnections Whether the output port can have multiple connections | ||
*/ | ||
function Port(socket, label, multipleConnections) { | ||
_classCallCheck__default["default"](this, Port); | ||
@@ -635,2 +656,3 @@ this.socket = socket; | ||
* The input port class | ||
* @priority 6 | ||
*/ | ||
@@ -640,13 +662,30 @@ var Input = /*#__PURE__*/function (_Port) { | ||
var _super = _createSuper(Input); | ||
function Input() { | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the input port | ||
* @param multipleConnections Whether the output port can have multiple connections. Default is `false` | ||
*/ | ||
function Input(socket, label, multipleConnections) { | ||
var _this; | ||
_classCallCheck__default["default"](this, Input); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this = _super.call(this, socket, label, multipleConnections); | ||
/** | ||
* Control instance | ||
*/ | ||
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "control", null); | ||
/** | ||
* Whether the control is visible. Can be managed dynamically by extensions. Default is `true` | ||
*/ | ||
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "showControl", true); | ||
_this.socket = socket; | ||
_this.label = label; | ||
_this.multipleConnections = multipleConnections; | ||
return _this; | ||
} | ||
/** | ||
* Add control to the input port | ||
* @param control Control instance | ||
*/ | ||
_createClass__default["default"](Input, [{ | ||
@@ -658,2 +697,6 @@ key: "addControl", | ||
} | ||
/** | ||
* Remove control from the input port | ||
*/ | ||
}, { | ||
@@ -670,2 +713,3 @@ key: "removeControl", | ||
* The output port class | ||
* @priority 5 | ||
*/ | ||
@@ -675,2 +719,8 @@ var Output = /*#__PURE__*/function (_Port2) { | ||
var _super2 = _createSuper(Output); | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the output port | ||
* @param multipleConnections Whether the output port can have multiple connections. Default is `true` | ||
*/ | ||
function Output(socket, label, multipleConnections) { | ||
@@ -685,8 +735,23 @@ _classCallCheck__default["default"](this, Output); | ||
* General control class | ||
* @priority 5 | ||
*/ | ||
var Control = /*#__PURE__*/_createClass__default["default"](function Control() { | ||
var Control = /*#__PURE__*/_createClass__default["default"]( | ||
/** | ||
* Control id, unique string generated by `getUID` function | ||
*/ | ||
/** | ||
* Control index, used for sorting controls. Default is `0` | ||
*/ | ||
function Control() { | ||
_classCallCheck__default["default"](this, Control); | ||
this.id = getUID(); | ||
}); | ||
/** | ||
* Input control options | ||
*/ | ||
/** | ||
* The input control class | ||
@@ -698,2 +763,7 @@ * @example new InputControl('text', { readonly: true, initial: 'hello' }) | ||
var _super3 = _createSuper(InputControl); | ||
/** | ||
* @constructor | ||
* @param type Type of the control: `text` or `number` | ||
* @param options Control options | ||
*/ | ||
function InputControl(type, options) { | ||
@@ -710,2 +780,7 @@ var _this2; | ||
} | ||
/** | ||
* Set control value | ||
* @param value Value to set | ||
*/ | ||
_createClass__default["default"](InputControl, [{ | ||
@@ -724,12 +799,26 @@ key: "setValue", | ||
* The node class | ||
* @typeParam Inputs - The inputs type | ||
* @typeParam Outputs - The outputs type | ||
* @typeParam Controls - The controls type | ||
* @priority 10 | ||
* @example new Node('math') | ||
*/ | ||
var Node = /*#__PURE__*/function () { | ||
/** | ||
* Whether the node is selected. Default is `false` | ||
*/ | ||
function Node(label) { | ||
_classCallCheck__default["default"](this, Node); | ||
/** | ||
* Node id, unique string generated by `getUID` function | ||
*/ | ||
/** | ||
* Node inputs | ||
*/ | ||
_defineProperty__default["default"](this, "inputs", {}); | ||
/** | ||
* Node outputs | ||
*/ | ||
_defineProperty__default["default"](this, "outputs", {}); | ||
/** | ||
* Node controls | ||
*/ | ||
_defineProperty__default["default"](this, "controls", {}); | ||
@@ -802,3 +891,28 @@ this.label = label; | ||
}(); | ||
var Connection = /*#__PURE__*/_createClass__default["default"](function Connection(source, sourceOutput, target, targetInput) { | ||
/** | ||
* The connection class | ||
* @priority 9 | ||
*/ | ||
var Connection = /*#__PURE__*/_createClass__default["default"]( | ||
/** | ||
* Connection id, unique string generated by `getUID` function | ||
*/ | ||
/** | ||
* Source node id | ||
*/ | ||
/** | ||
* Target node id | ||
*/ | ||
/** | ||
* @constructor | ||
* @param source Source node instance | ||
* @param sourceOutput Source node output key | ||
* @param target Target node instance | ||
* @param targetInput Target node input key | ||
*/ | ||
function Connection(source, sourceOutput, target, targetInput) { | ||
_classCallCheck__default["default"](this, Connection); | ||
@@ -805,0 +919,0 @@ this.sourceOutput = sourceOutput; |
146
rete.esm.js
@@ -219,3 +219,3 @@ /*! | ||
* Get all nodes | ||
* @returns All nodes | ||
* @returns Copy of array with nodes | ||
*/ | ||
@@ -225,3 +225,3 @@ }, { | ||
value: function getNodes() { | ||
return this.nodes; | ||
return this.nodes.slice(); | ||
} | ||
@@ -231,3 +231,3 @@ | ||
* Get all connections | ||
* @returns All connections | ||
* @returns Copy of array with onnections | ||
*/ | ||
@@ -237,3 +237,3 @@ }, { | ||
value: function getConnections() { | ||
return this.connections; | ||
return this.connections.slice(); | ||
} | ||
@@ -598,4 +598,10 @@ | ||
* The socket class | ||
* @priority 7 | ||
*/ | ||
var Socket = /*#__PURE__*/_createClass(function Socket(name) { | ||
var Socket = /*#__PURE__*/_createClass( | ||
/** | ||
* @constructor | ||
* @param name Name of the socket | ||
*/ | ||
function Socket(name) { | ||
_classCallCheck(this, Socket); | ||
@@ -608,3 +614,18 @@ this.name = name; | ||
*/ | ||
var Port = /*#__PURE__*/_createClass(function Port(socket, label, multipleConnections) { | ||
var Port = /*#__PURE__*/_createClass( | ||
/** | ||
* Port id, unique string generated by `getUID` function | ||
*/ | ||
/** | ||
* Port index, used for sorting ports. Default is `0` | ||
*/ | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the port | ||
* @param multipleConnections Whether the output port can have multiple connections | ||
*/ | ||
function Port(socket, label, multipleConnections) { | ||
_classCallCheck(this, Port); | ||
@@ -619,2 +640,3 @@ this.socket = socket; | ||
* The input port class | ||
* @priority 6 | ||
*/ | ||
@@ -624,13 +646,30 @@ var Input = /*#__PURE__*/function (_Port) { | ||
var _super = _createSuper(Input); | ||
function Input() { | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the input port | ||
* @param multipleConnections Whether the output port can have multiple connections. Default is `false` | ||
*/ | ||
function Input(socket, label, multipleConnections) { | ||
var _this; | ||
_classCallCheck(this, Input); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this = _super.call(this, socket, label, multipleConnections); | ||
/** | ||
* Control instance | ||
*/ | ||
_defineProperty(_assertThisInitialized(_this), "control", null); | ||
/** | ||
* Whether the control is visible. Can be managed dynamically by extensions. Default is `true` | ||
*/ | ||
_defineProperty(_assertThisInitialized(_this), "showControl", true); | ||
_this.socket = socket; | ||
_this.label = label; | ||
_this.multipleConnections = multipleConnections; | ||
return _this; | ||
} | ||
/** | ||
* Add control to the input port | ||
* @param control Control instance | ||
*/ | ||
_createClass(Input, [{ | ||
@@ -642,2 +681,6 @@ key: "addControl", | ||
} | ||
/** | ||
* Remove control from the input port | ||
*/ | ||
}, { | ||
@@ -654,2 +697,3 @@ key: "removeControl", | ||
* The output port class | ||
* @priority 5 | ||
*/ | ||
@@ -659,2 +703,8 @@ var Output = /*#__PURE__*/function (_Port2) { | ||
var _super2 = _createSuper(Output); | ||
/** | ||
* @constructor | ||
* @param socket Socket instance | ||
* @param label Label of the output port | ||
* @param multipleConnections Whether the output port can have multiple connections. Default is `true` | ||
*/ | ||
function Output(socket, label, multipleConnections) { | ||
@@ -669,8 +719,23 @@ _classCallCheck(this, Output); | ||
* General control class | ||
* @priority 5 | ||
*/ | ||
var Control = /*#__PURE__*/_createClass(function Control() { | ||
var Control = /*#__PURE__*/_createClass( | ||
/** | ||
* Control id, unique string generated by `getUID` function | ||
*/ | ||
/** | ||
* Control index, used for sorting controls. Default is `0` | ||
*/ | ||
function Control() { | ||
_classCallCheck(this, Control); | ||
this.id = getUID(); | ||
}); | ||
/** | ||
* Input control options | ||
*/ | ||
/** | ||
* The input control class | ||
@@ -682,2 +747,7 @@ * @example new InputControl('text', { readonly: true, initial: 'hello' }) | ||
var _super3 = _createSuper(InputControl); | ||
/** | ||
* @constructor | ||
* @param type Type of the control: `text` or `number` | ||
* @param options Control options | ||
*/ | ||
function InputControl(type, options) { | ||
@@ -694,2 +764,7 @@ var _this2; | ||
} | ||
/** | ||
* Set control value | ||
* @param value Value to set | ||
*/ | ||
_createClass(InputControl, [{ | ||
@@ -708,12 +783,26 @@ key: "setValue", | ||
* The node class | ||
* @typeParam Inputs - The inputs type | ||
* @typeParam Outputs - The outputs type | ||
* @typeParam Controls - The controls type | ||
* @priority 10 | ||
* @example new Node('math') | ||
*/ | ||
var Node = /*#__PURE__*/function () { | ||
/** | ||
* Whether the node is selected. Default is `false` | ||
*/ | ||
function Node(label) { | ||
_classCallCheck(this, Node); | ||
/** | ||
* Node id, unique string generated by `getUID` function | ||
*/ | ||
/** | ||
* Node inputs | ||
*/ | ||
_defineProperty(this, "inputs", {}); | ||
/** | ||
* Node outputs | ||
*/ | ||
_defineProperty(this, "outputs", {}); | ||
/** | ||
* Node controls | ||
*/ | ||
_defineProperty(this, "controls", {}); | ||
@@ -786,3 +875,28 @@ this.label = label; | ||
}(); | ||
var Connection = /*#__PURE__*/_createClass(function Connection(source, sourceOutput, target, targetInput) { | ||
/** | ||
* The connection class | ||
* @priority 9 | ||
*/ | ||
var Connection = /*#__PURE__*/_createClass( | ||
/** | ||
* Connection id, unique string generated by `getUID` function | ||
*/ | ||
/** | ||
* Source node id | ||
*/ | ||
/** | ||
* Target node id | ||
*/ | ||
/** | ||
* @constructor | ||
* @param source Source node instance | ||
* @param sourceOutput Source node output key | ||
* @param target Target node instance | ||
* @param targetInput Target node input key | ||
*/ | ||
function Connection(source, sourceOutput, target, targetInput) { | ||
_classCallCheck(this, Connection); | ||
@@ -789,0 +903,0 @@ this.sourceOutput = sourceOutput; |
@@ -6,3 +6,3 @@ /*! | ||
* */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Rete={})}(this,(function(t){"use strict";function e(){e=function(){return t};var t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),u=new P(r||[]);return o(a,"_invoke",{value:k(t,n,u)}),a}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h={};function p(){}function d(){}function y(){}var v={};s(v,a,(function(){return this}));var b=Object.getPrototypeOf,m=b&&b(b(S([])));m&&m!==n&&r.call(m,a)&&(v=m);var w=y.prototype=p.prototype=Object.create(v);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,u){var c=l(t[o],t,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function k(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return _()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=O(a,n);if(u){if(u===h)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=l(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function O(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var o=l(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function E(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:_}}function _(){return{value:void 0,done:!0}}return d.prototype=y,o(w,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:d,configurable:!0}),d.displayName=s(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,c,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},g(x.prototype),s(x.prototype,u,(function(){return this})),t.AsyncIterator=x,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new x(f(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(w),s(w,c,"Generator"),s(w,a,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=S,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),j(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;j(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}function n(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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,y(r.key),r)}}function a(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&f(t,e)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function f(t,e){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},f(t,e)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=s(t);if(e){var o=s(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}(this,n)}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function d(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function y(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var v=function(){function t(){o(this,t),u(this,"pipes",[])}var n;return a(t,[{key:"addPipe",value:function(t){this.pipes.push(t)}},{key:"emit",value:(n=r(e().mark((function t(n){var r,o,i,a;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n,o=d(this.pipes),t.prev=2,o.s();case 4:if((i=o.n()).done){t.next=13;break}return a=i.value,t.next=8,a(r);case 8:if(void 0!==(r=t.sent)){t.next=11;break}return t.abrupt("return");case 11:t.next=4;break;case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(2),o.e(t.t0);case 18:return t.prev=18,o.f(),t.finish(18);case 21:return t.abrupt("return",r);case 22:case"end":return t.stop()}}),t,this,[[2,15,18,21]])}))),function(t){return n.apply(this,arguments)})}]),t}(),b=function(){function t(e){o(this,t),u(this,"signal",new v),this.name=e}return a(t,[{key:"addPipe",value:function(t){this.signal.addPipe(t)}},{key:"use",value:function(e){if(!(e instanceof t))throw new Error("cannot use non-Scope instance");return e.setParent(this),this.addPipe((function(t){return e.signal.emit(t)})),{debug:function(t){}}}},{key:"setParent",value:function(t){this.parent=t}},{key:"emit",value:function(t){return this.signal.emit(t)}},{key:"hasParent",value:function(){return Boolean(this.parent)}},{key:"parentScope",value:function(t){if(!this.parent)throw new Error("cannot find parent");if(t&&this.parent instanceof t)return this.parent;if(t)throw new Error("actual parent is not instance of type");return this.parent}}]),t}(),m=function(t){c(v,t);var n,i,s,f,p,y=h(v);function v(){var t;return o(this,v),u(l(t=y.call(this,"NodeEditor")),"nodes",[]),u(l(t),"connections",[]),t}return a(v,[{key:"getNode",value:function(t){return this.nodes.find((function(e){return e.id===t}))}},{key:"getNodes",value:function(){return this.nodes}},{key:"getConnections",value:function(){return this.connections}},{key:"getConnection",value:function(t){return this.connections.find((function(e){return e.id===t}))}},{key:"addNode",value:(p=r(e().mark((function t(n){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.getNode(n.id)){t.next=2;break}throw new Error("node has already been added");case 2:return t.next=4,this.emit({type:"nodecreate",data:n});case 4:if(t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return this.nodes.push(n),t.next=9,this.emit({type:"nodecreated",data:n});case 9:return t.abrupt("return",!0);case 10:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"addConnection",value:(f=r(e().mark((function t(n){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.getConnection(n.id)){t.next=2;break}throw new Error("connection has already been added");case 2:return t.next=4,this.emit({type:"connectioncreate",data:n});case 4:if(t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return this.connections.push(n),t.next=9,this.emit({type:"connectioncreated",data:n});case 9:return t.abrupt("return",!0);case 10:case"end":return t.stop()}}),t,this)}))),function(t){return f.apply(this,arguments)})},{key:"removeNode",value:(s=r(e().mark((function t(n){var r,o;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.nodes.findIndex((function(t){return t.id===n})),o=this.nodes[r],!(r<0)){t.next=4;break}throw new Error("cannot find node");case 4:return t.next=6,this.emit({type:"noderemove",data:o});case 6:if(t.sent){t.next=8;break}return t.abrupt("return",!1);case 8:return this.nodes.splice(r,1),t.next=11,this.emit({type:"noderemoved",data:o});case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"removeConnection",value:(i=r(e().mark((function t(n){var r,o;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.connections.findIndex((function(t){return t.id===n})),o=this.connections[r],!(r<0)){t.next=4;break}throw new Error("cannot find connection");case 4:return t.next=6,this.emit({type:"connectionremove",data:o});case 6:if(t.sent){t.next=8;break}return t.abrupt("return",!1);case 8:return this.connections.splice(r,1),t.next=11,this.emit({type:"connectionremoved",data:o});case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"clear",value:(n=r(e().mark((function t(){var n,r,o,i,a,u;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.emit({type:"clear"});case 2:if(t.sent){t.next=6;break}return t.next=5,this.emit({type:"clearcancelled"});case 5:return t.abrupt("return",!1);case 6:n=d(this.connections.slice()),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return o=r.value,t.next=13,this.removeConnection(o.id);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:i=d(this.nodes.slice()),t.prev=24,i.s();case 26:if((a=i.n()).done){t.next=32;break}return u=a.value,t.next=30,this.removeNode(u.id);case 30:t.next=26;break;case 32:t.next=37;break;case 34:t.prev=34,t.t1=t.catch(24),i.e(t.t1);case 37:return t.prev=37,i.f(),t.finish(37);case 40:return t.next=42,this.emit({type:"cleared"});case 42:return t.abrupt("return",!0);case 43:case"end":return t.stop()}}),t,this,[[7,17,20,23],[24,34,37,40]])}))),function(){return n.apply(this,arguments)})}]),v}(b),w=globalThis.crypto;function g(){if("randomBytes"in w)return w.randomBytes(8).toString("hex");var t=w.getRandomValues(new Uint8Array(8));return Array.from(t).map((function(t){return t.toString(16).padStart(2,"0")})).join("")}var x=a((function t(e){o(this,t),this.name=e})),k=a((function t(e,n,r){o(this,t),this.socket=e,this.label=n,this.multipleConnections=r,this.id=g()})),O=function(t){c(n,t);var e=h(n);function n(){var t;o(this,n);for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return u(l(t=e.call.apply(e,[this].concat(i))),"control",null),u(l(t),"showControl",!0),t}return a(n,[{key:"addControl",value:function(t){if(this.control)throw new Error("control already added for this input");this.control=t}},{key:"removeControl",value:function(){this.control=null}}]),n}(k),E=function(t){c(n,t);var e=h(n);function n(t,r,i){return o(this,n),e.call(this,t,r,!1!==i)}return a(n)}(k),j=a((function t(){o(this,t),this.id=g()})),P=function(t){c(n,t);var e=h(n);function n(t,r){var i;return o(this,n),(i=e.call(this)).type=t,i.options=r,i.id=g(),i.readonly=null==r?void 0:r.readonly,void 0!==(null==r?void 0:r.initial)&&(i.value=r.initial),i}return a(n,[{key:"setValue",value:function(t){var e;this.value=t,null!==(e=this.options)&&void 0!==e&&e.change&&this.options.change(t)}}]),n}(j),S=function(){function t(e){o(this,t),u(this,"inputs",{}),u(this,"outputs",{}),u(this,"controls",{}),this.label=e,this.id=g()}return a(t,[{key:"hasInput",value:function(t){return Object.prototype.hasOwnProperty.call(this.inputs,t)}},{key:"addInput",value:function(t,e){if(this.hasInput(t))throw new Error("input with key '".concat(String(t),"' already added"));Object.defineProperty(this.inputs,t,{value:e,enumerable:!0,configurable:!0})}},{key:"removeInput",value:function(t){delete this.inputs[t]}},{key:"hasOutput",value:function(t){return Object.prototype.hasOwnProperty.call(this.outputs,t)}},{key:"addOutput",value:function(t,e){if(this.hasOutput(t))throw new Error("output with key '".concat(String(t),"' already added"));Object.defineProperty(this.outputs,t,{value:e,enumerable:!0,configurable:!0})}},{key:"removeOutput",value:function(t){delete this.outputs[t]}},{key:"hasControl",value:function(t){return Object.prototype.hasOwnProperty.call(this.controls,t)}},{key:"addControl",value:function(t,e){if(this.hasControl(t))throw new Error("control with key '".concat(String(t),"' already added"));Object.defineProperty(this.controls,t,{value:e,enumerable:!0,configurable:!0})}},{key:"removeControl",value:function(t){delete this.controls[t]}}]),t}(),_=a((function t(e,n,r,i){if(o(this,t),this.sourceOutput=n,this.targetInput=i,!e.outputs[n])throw new Error("source node doesn't have output with a key ".concat(String(n)));if(!r.inputs[i])throw new Error("target node doesn't have input with a key ".concat(String(i)));this.id=g(),this.source=e.id,this.target=r.id})),L=Object.freeze({__proto__:null,Socket:x,Port:k,Input:O,Output:E,Control:j,InputControl:P,Node:S,Connection:_});t.ClassicPreset=L,t.NodeEditor=m,t.Scope=b,t.Signal=v,t.getUID=g,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Rete={})}(this,(function(t){"use strict";function e(){e=function(){return t};var t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),u=new P(r||[]);return o(a,"_invoke",{value:k(t,n,u)}),a}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h={};function p(){}function d(){}function y(){}var v={};s(v,a,(function(){return this}));var b=Object.getPrototypeOf,m=b&&b(b(S([])));m&&m!==n&&r.call(m,a)&&(v=m);var w=y.prototype=p.prototype=Object.create(v);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,i,a,u){var c=l(t[o],t,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function k(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return _()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=O(a,n);if(u){if(u===h)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=l(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}function O(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var o=l(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function E(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:_}}function _(){return{value:void 0,done:!0}}return d.prototype=y,o(w,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:d,configurable:!0}),d.displayName=s(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,c,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},g(x.prototype),s(x.prototype,u,(function(){return this})),t.AsyncIterator=x,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new x(f(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(w),s(w,c,"Generator"),s(w,a,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=S,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},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),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),j(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;j(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},t}function n(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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,y(r.key),r)}}function a(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&f(t,e)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function f(t,e){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},f(t,e)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=s(t);if(e){var o=s(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}(this,n)}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function d(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function y(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var v=function(){function t(){o(this,t),u(this,"pipes",[])}var n;return a(t,[{key:"addPipe",value:function(t){this.pipes.push(t)}},{key:"emit",value:(n=r(e().mark((function t(n){var r,o,i,a;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=n,o=d(this.pipes),t.prev=2,o.s();case 4:if((i=o.n()).done){t.next=13;break}return a=i.value,t.next=8,a(r);case 8:if(void 0!==(r=t.sent)){t.next=11;break}return t.abrupt("return");case 11:t.next=4;break;case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(2),o.e(t.t0);case 18:return t.prev=18,o.f(),t.finish(18);case 21:return t.abrupt("return",r);case 22:case"end":return t.stop()}}),t,this,[[2,15,18,21]])}))),function(t){return n.apply(this,arguments)})}]),t}(),b=function(){function t(e){o(this,t),u(this,"signal",new v),this.name=e}return a(t,[{key:"addPipe",value:function(t){this.signal.addPipe(t)}},{key:"use",value:function(e){if(!(e instanceof t))throw new Error("cannot use non-Scope instance");return e.setParent(this),this.addPipe((function(t){return e.signal.emit(t)})),{debug:function(t){}}}},{key:"setParent",value:function(t){this.parent=t}},{key:"emit",value:function(t){return this.signal.emit(t)}},{key:"hasParent",value:function(){return Boolean(this.parent)}},{key:"parentScope",value:function(t){if(!this.parent)throw new Error("cannot find parent");if(t&&this.parent instanceof t)return this.parent;if(t)throw new Error("actual parent is not instance of type");return this.parent}}]),t}(),m=function(t){c(v,t);var n,i,s,f,p,y=h(v);function v(){var t;return o(this,v),u(l(t=y.call(this,"NodeEditor")),"nodes",[]),u(l(t),"connections",[]),t}return a(v,[{key:"getNode",value:function(t){return this.nodes.find((function(e){return e.id===t}))}},{key:"getNodes",value:function(){return this.nodes.slice()}},{key:"getConnections",value:function(){return this.connections.slice()}},{key:"getConnection",value:function(t){return this.connections.find((function(e){return e.id===t}))}},{key:"addNode",value:(p=r(e().mark((function t(n){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.getNode(n.id)){t.next=2;break}throw new Error("node has already been added");case 2:return t.next=4,this.emit({type:"nodecreate",data:n});case 4:if(t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return this.nodes.push(n),t.next=9,this.emit({type:"nodecreated",data:n});case 9:return t.abrupt("return",!0);case 10:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"addConnection",value:(f=r(e().mark((function t(n){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.getConnection(n.id)){t.next=2;break}throw new Error("connection has already been added");case 2:return t.next=4,this.emit({type:"connectioncreate",data:n});case 4:if(t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return this.connections.push(n),t.next=9,this.emit({type:"connectioncreated",data:n});case 9:return t.abrupt("return",!0);case 10:case"end":return t.stop()}}),t,this)}))),function(t){return f.apply(this,arguments)})},{key:"removeNode",value:(s=r(e().mark((function t(n){var r,o;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.nodes.findIndex((function(t){return t.id===n})),o=this.nodes[r],!(r<0)){t.next=4;break}throw new Error("cannot find node");case 4:return t.next=6,this.emit({type:"noderemove",data:o});case 6:if(t.sent){t.next=8;break}return t.abrupt("return",!1);case 8:return this.nodes.splice(r,1),t.next=11,this.emit({type:"noderemoved",data:o});case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"removeConnection",value:(i=r(e().mark((function t(n){var r,o;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.connections.findIndex((function(t){return t.id===n})),o=this.connections[r],!(r<0)){t.next=4;break}throw new Error("cannot find connection");case 4:return t.next=6,this.emit({type:"connectionremove",data:o});case 6:if(t.sent){t.next=8;break}return t.abrupt("return",!1);case 8:return this.connections.splice(r,1),t.next=11,this.emit({type:"connectionremoved",data:o});case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"clear",value:(n=r(e().mark((function t(){var n,r,o,i,a,u;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.emit({type:"clear"});case 2:if(t.sent){t.next=6;break}return t.next=5,this.emit({type:"clearcancelled"});case 5:return t.abrupt("return",!1);case 6:n=d(this.connections.slice()),t.prev=7,n.s();case 9:if((r=n.n()).done){t.next=15;break}return o=r.value,t.next=13,this.removeConnection(o.id);case 13:t.next=9;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(7),n.e(t.t0);case 20:return t.prev=20,n.f(),t.finish(20);case 23:i=d(this.nodes.slice()),t.prev=24,i.s();case 26:if((a=i.n()).done){t.next=32;break}return u=a.value,t.next=30,this.removeNode(u.id);case 30:t.next=26;break;case 32:t.next=37;break;case 34:t.prev=34,t.t1=t.catch(24),i.e(t.t1);case 37:return t.prev=37,i.f(),t.finish(37);case 40:return t.next=42,this.emit({type:"cleared"});case 42:return t.abrupt("return",!0);case 43:case"end":return t.stop()}}),t,this,[[7,17,20,23],[24,34,37,40]])}))),function(){return n.apply(this,arguments)})}]),v}(b),w=globalThis.crypto;function g(){if("randomBytes"in w)return w.randomBytes(8).toString("hex");var t=w.getRandomValues(new Uint8Array(8));return Array.from(t).map((function(t){return t.toString(16).padStart(2,"0")})).join("")}var x=a((function t(e){o(this,t),this.name=e})),k=a((function t(e,n,r){o(this,t),this.socket=e,this.label=n,this.multipleConnections=r,this.id=g()})),O=function(t){c(n,t);var e=h(n);function n(t,r,i){var a;return o(this,n),u(l(a=e.call(this,t,r,i)),"control",null),u(l(a),"showControl",!0),a.socket=t,a.label=r,a.multipleConnections=i,a}return a(n,[{key:"addControl",value:function(t){if(this.control)throw new Error("control already added for this input");this.control=t}},{key:"removeControl",value:function(){this.control=null}}]),n}(k),E=function(t){c(n,t);var e=h(n);function n(t,r,i){return o(this,n),e.call(this,t,r,!1!==i)}return a(n)}(k),j=a((function t(){o(this,t),this.id=g()})),P=function(t){c(n,t);var e=h(n);function n(t,r){var i;return o(this,n),(i=e.call(this)).type=t,i.options=r,i.id=g(),i.readonly=null==r?void 0:r.readonly,void 0!==(null==r?void 0:r.initial)&&(i.value=r.initial),i}return a(n,[{key:"setValue",value:function(t){var e;this.value=t,null!==(e=this.options)&&void 0!==e&&e.change&&this.options.change(t)}}]),n}(j),S=function(){function t(e){o(this,t),u(this,"inputs",{}),u(this,"outputs",{}),u(this,"controls",{}),this.label=e,this.id=g()}return a(t,[{key:"hasInput",value:function(t){return Object.prototype.hasOwnProperty.call(this.inputs,t)}},{key:"addInput",value:function(t,e){if(this.hasInput(t))throw new Error("input with key '".concat(String(t),"' already added"));Object.defineProperty(this.inputs,t,{value:e,enumerable:!0,configurable:!0})}},{key:"removeInput",value:function(t){delete this.inputs[t]}},{key:"hasOutput",value:function(t){return Object.prototype.hasOwnProperty.call(this.outputs,t)}},{key:"addOutput",value:function(t,e){if(this.hasOutput(t))throw new Error("output with key '".concat(String(t),"' already added"));Object.defineProperty(this.outputs,t,{value:e,enumerable:!0,configurable:!0})}},{key:"removeOutput",value:function(t){delete this.outputs[t]}},{key:"hasControl",value:function(t){return Object.prototype.hasOwnProperty.call(this.controls,t)}},{key:"addControl",value:function(t,e){if(this.hasControl(t))throw new Error("control with key '".concat(String(t),"' already added"));Object.defineProperty(this.controls,t,{value:e,enumerable:!0,configurable:!0})}},{key:"removeControl",value:function(t){delete this.controls[t]}}]),t}(),_=a((function t(e,n,r,i){if(o(this,t),this.sourceOutput=n,this.targetInput=i,!e.outputs[n])throw new Error("source node doesn't have output with a key ".concat(String(n)));if(!r.inputs[i])throw new Error("target node doesn't have input with a key ".concat(String(i)));this.id=g(),this.source=e.id,this.target=r.id})),L=Object.freeze({__proto__:null,Socket:x,Port:k,Input:O,Output:E,Control:j,InputControl:P,Node:S,Connection:_});t.ClassicPreset=L,t.NodeEditor=m,t.Scope=b,t.Signal=v,t.getUID=g,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=rete.min.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
228322
24
2364