Comparing version 2.0.0-beta.2 to 2.0.0-beta.3
{ | ||
"name": "rete", | ||
"version": "2.0.0-beta.2", | ||
"version": "2.0.0-beta.3", | ||
"description": "JavaScript framework", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/retejs/rete.git" | ||
}, | ||
"author": "Vitaliy Stoliarov", | ||
"license": "MIT", | ||
"keywords": [ | ||
@@ -13,10 +11,13 @@ "dataflow", | ||
"node editor", | ||
"js" | ||
"rete", | ||
"Rete.js" | ||
], | ||
"author": "Vitaliy Stoliarov", | ||
"license": "MIT", | ||
"homepage": "https://retejs.org", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/retejs/rete.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/retejs/rete/issues" | ||
}, | ||
"homepage": "https://github.com/retejs/rete#readme", | ||
"scripts": { | ||
@@ -23,0 +24,0 @@ "postinstall": "node postinstall.js" |
@@ -1,10 +0,11 @@ | ||
Rete.js [![Build Status](https://app.travis-ci.com/retejs/rete.svg?branch=master)](https://app.travis-ci.com/retejs/rete) | ||
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=retejs_rete&metric=alert_status)](https://sonarcloud.io/dashboard?id=retejs_rete) | ||
[![Join the chat at https://gitter.im/retejs/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/retejs/Lobby) | ||
Rete.js | ||
==== | ||
#### JavaScript framework for visual programming | ||
[![Made in Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua) | ||
[![Discord](https://img.shields.io/discord/1081223198055604244?color=%237289da&label=Discord)](https://discord.gg/cxSFkPZdsV) | ||
![rete logo](https://i.imgur.com/rydGu6B.png) | ||
**JavaScript framework for visual programming** | ||
#StandWithUkraine 💛💙 | ||
![rete logo](https://raw.githubusercontent.com/retejs/rete/assets/preview.svg) | ||
#StandWithUkraine 💙💛 | ||
---- | ||
@@ -21,25 +22,34 @@ | ||
---- | ||
**Rete** is a modular framework for visual programming. **Rete** allows you to create node-based editor directly in the browser. You can define nodes and workers that allow users to create instructions for processing data in your editor without a single line of code. | ||
Documentation | ||
---- | ||
Check the [docs](https://rete.js.org/#/docs) and learn about the components and capabilities. | ||
**Rete.js** is a framework for creating visual interfaces and workflows. It provides out-of-the-box solutions for visualization using various libraries and frameworks, as well as solutions for processing graphs based on dataflow and control flow approaches. | ||
Examples | ||
Getting Started | ||
---- | ||
[Flow-based programming](https://codepen.io/Ni55aN/pen/xzgQYq) | ||
[Events (tasks)](https://codepen.io/Ni55aN/pen/MOYPEz) | ||
- [Concepts](https://retejs.org/docs/concepts/plugin-system) | ||
- [Guides](https://retejs.org/docs/guides/basic) | ||
- [FAQ](https://retejs.org/docs/faq) | ||
- [Examples](https://retejs.org/examples) | ||
[Modules](https://codepen.io/Ni55aN/pen/QOEbEW) | ||
## Sponsors | ||
[Programming a Messenger Bot](https://codepen.io/Ni55aN/pen/rpOKNb) | ||
Thank you to all our sponsors! [Become a sponsor](https://opencollective.com/rete#sponsor) | ||
[3D Car configurator](https://codesandbox.io/embed/9jp88p1jpy?view=preview) | ||
<a href="https://opencollective.com/rete#sponsors" target="_blank"><img src="https://opencollective.com/rete/sponsors.svg?width=890"></a> | ||
License | ||
---- | ||
[MIT](http://opensource.org/licenses/MIT) | ||
## Backers | ||
[Donate](http://rete.js.org/#support) | ||
--- | ||
Thank you to all our backers! [Become a backer](https://opencollective.com/rete#backer) | ||
<a href="https://opencollective.com/rete#backers" target="_blank"><img src="https://opencollective.com/rete/backers.svg?width=890"></a> | ||
## Contributors | ||
This project exists thanks to all the people who contribute. [Contribute](https://retejs.org/docs/contribution). | ||
<a href="https://github.com/retejs/rete/graphs/contributors"><img src="https://opencollective.com/rete/contributors.svg?width=890" /></a> | ||
## License | ||
[MIT](https://github.com/retejs/rete/blob/master/LICENSE) |
1477
rete.common.js
/*! | ||
* rete v2.0.0-beta.2 | ||
* rete v2.0.0-beta.3 | ||
* (c) 2023 Vitaliy Stoliarov | ||
@@ -10,355 +10,2 @@ * Released under the MIT license. | ||
function _regeneratorRuntime() { | ||
_regeneratorRuntime = function () { | ||
return exports; | ||
}; | ||
var exports = {}, | ||
Op = Object.prototype, | ||
hasOwn = Op.hasOwnProperty, | ||
defineProperty = Object.defineProperty || function (obj, key, desc) { | ||
obj[key] = desc.value; | ||
}, | ||
$Symbol = "function" == typeof Symbol ? Symbol : {}, | ||
iteratorSymbol = $Symbol.iterator || "@@iterator", | ||
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", | ||
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
function define(obj, key, value) { | ||
return Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}), obj[key]; | ||
} | ||
try { | ||
define({}, ""); | ||
} catch (err) { | ||
define = function (obj, key, value) { | ||
return obj[key] = value; | ||
}; | ||
} | ||
function wrap(innerFn, outerFn, self, tryLocsList) { | ||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, | ||
generator = Object.create(protoGenerator.prototype), | ||
context = new Context(tryLocsList || []); | ||
return defineProperty(generator, "_invoke", { | ||
value: makeInvokeMethod(innerFn, self, context) | ||
}), generator; | ||
} | ||
function tryCatch(fn, obj, arg) { | ||
try { | ||
return { | ||
type: "normal", | ||
arg: fn.call(obj, arg) | ||
}; | ||
} catch (err) { | ||
return { | ||
type: "throw", | ||
arg: err | ||
}; | ||
} | ||
} | ||
exports.wrap = wrap; | ||
var ContinueSentinel = {}; | ||
function Generator() {} | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
var IteratorPrototype = {}; | ||
define(IteratorPrototype, iteratorSymbol, function () { | ||
return this; | ||
}); | ||
var getProto = Object.getPrototypeOf, | ||
NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); | ||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); | ||
function defineIteratorMethods(prototype) { | ||
["next", "throw", "return"].forEach(function (method) { | ||
define(prototype, method, function (arg) { | ||
return this._invoke(method, arg); | ||
}); | ||
}); | ||
} | ||
function AsyncIterator(generator, PromiseImpl) { | ||
function invoke(method, arg, resolve, reject) { | ||
var record = tryCatch(generator[method], generator, arg); | ||
if ("throw" !== record.type) { | ||
var result = record.arg, | ||
value = result.value; | ||
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { | ||
invoke("next", value, resolve, reject); | ||
}, function (err) { | ||
invoke("throw", err, resolve, reject); | ||
}) : PromiseImpl.resolve(value).then(function (unwrapped) { | ||
result.value = unwrapped, resolve(result); | ||
}, function (error) { | ||
return invoke("throw", error, resolve, reject); | ||
}); | ||
} | ||
reject(record.arg); | ||
} | ||
var previousPromise; | ||
defineProperty(this, "_invoke", { | ||
value: function (method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function (resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
} | ||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); | ||
} | ||
}); | ||
} | ||
function makeInvokeMethod(innerFn, self, context) { | ||
var state = "suspendedStart"; | ||
return function (method, arg) { | ||
if ("executing" === state) throw new Error("Generator is already running"); | ||
if ("completed" === state) { | ||
if ("throw" === method) throw arg; | ||
return doneResult(); | ||
} | ||
for (context.method = method, context.arg = arg;;) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { | ||
if ("suspendedStart" === state) throw state = "completed", context.arg; | ||
context.dispatchException(context.arg); | ||
} else "return" === context.method && context.abrupt("return", context.arg); | ||
state = "executing"; | ||
var record = tryCatch(innerFn, self, context); | ||
if ("normal" === record.type) { | ||
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} | ||
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); | ||
} | ||
}; | ||
} | ||
function maybeInvokeDelegate(delegate, context) { | ||
var methodName = context.method, | ||
method = delegate.iterator[methodName]; | ||
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; | ||
var record = tryCatch(method, delegate.iterator, context.arg); | ||
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; | ||
var info = record.arg; | ||
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); | ||
} | ||
function pushTryEntry(locs) { | ||
var entry = { | ||
tryLoc: locs[0] | ||
}; | ||
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); | ||
} | ||
function resetTryEntry(entry) { | ||
var record = entry.completion || {}; | ||
record.type = "normal", delete record.arg, entry.completion = record; | ||
} | ||
function Context(tryLocsList) { | ||
this.tryEntries = [{ | ||
tryLoc: "root" | ||
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); | ||
} | ||
function values(iterable) { | ||
if (iterable) { | ||
var iteratorMethod = iterable[iteratorSymbol]; | ||
if (iteratorMethod) return iteratorMethod.call(iterable); | ||
if ("function" == typeof iterable.next) return iterable; | ||
if (!isNaN(iterable.length)) { | ||
var i = -1, | ||
next = function next() { | ||
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; | ||
return next.value = undefined, next.done = !0, next; | ||
}; | ||
return next.next = next; | ||
} | ||
} | ||
return { | ||
next: doneResult | ||
}; | ||
} | ||
function doneResult() { | ||
return { | ||
value: undefined, | ||
done: !0 | ||
}; | ||
} | ||
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { | ||
value: GeneratorFunctionPrototype, | ||
configurable: !0 | ||
}), defineProperty(GeneratorFunctionPrototype, "constructor", { | ||
value: GeneratorFunction, | ||
configurable: !0 | ||
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { | ||
var ctor = "function" == typeof genFun && genFun.constructor; | ||
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); | ||
}, exports.mark = function (genFun) { | ||
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; | ||
}, exports.awrap = function (arg) { | ||
return { | ||
__await: arg | ||
}; | ||
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { | ||
return this; | ||
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
void 0 === PromiseImpl && (PromiseImpl = Promise); | ||
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); | ||
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { | ||
return result.done ? result.value : iter.next(); | ||
}); | ||
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { | ||
return this; | ||
}), define(Gp, "toString", function () { | ||
return "[object Generator]"; | ||
}), exports.keys = function (val) { | ||
var object = Object(val), | ||
keys = []; | ||
for (var key in object) keys.push(key); | ||
return keys.reverse(), function next() { | ||
for (; keys.length;) { | ||
var key = keys.pop(); | ||
if (key in object) return next.value = key, next.done = !1, next; | ||
} | ||
return next.done = !0, next; | ||
}; | ||
}, exports.values = values, Context.prototype = { | ||
constructor: Context, | ||
reset: function (skipTempReset) { | ||
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); | ||
}, | ||
stop: function () { | ||
this.done = !0; | ||
var rootRecord = this.tryEntries[0].completion; | ||
if ("throw" === rootRecord.type) throw rootRecord.arg; | ||
return this.rval; | ||
}, | ||
dispatchException: function (exception) { | ||
if (this.done) throw exception; | ||
var context = this; | ||
function handle(loc, caught) { | ||
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; | ||
} | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i], | ||
record = entry.completion; | ||
if ("root" === entry.tryLoc) return handle("end"); | ||
if (entry.tryLoc <= this.prev) { | ||
var hasCatch = hasOwn.call(entry, "catchLoc"), | ||
hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
if (hasCatch && hasFinally) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} else if (hasCatch) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
} else { | ||
if (!hasFinally) throw new Error("try statement without catch or finally"); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} | ||
} | ||
} | ||
}, | ||
abrupt: function (type, arg) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { | ||
var finallyEntry = entry; | ||
break; | ||
} | ||
} | ||
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); | ||
var record = finallyEntry ? finallyEntry.completion : {}; | ||
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); | ||
}, | ||
complete: function (record, afterLoc) { | ||
if ("throw" === record.type) throw record.arg; | ||
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; | ||
}, | ||
finish: function (finallyLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; | ||
} | ||
}, | ||
catch: function (tryLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc === tryLoc) { | ||
var record = entry.completion; | ||
if ("throw" === record.type) { | ||
var thrown = record.arg; | ||
resetTryEntry(entry); | ||
} | ||
return thrown; | ||
} | ||
} | ||
throw new Error("illegal catch attempt"); | ||
}, | ||
delegateYield: function (iterable, resultName, nextLoc) { | ||
return this.delegate = { | ||
iterator: values(iterable), | ||
resultName: resultName, | ||
nextLoc: nextLoc | ||
}, "next" === this.method && (this.arg = undefined), ContinueSentinel; | ||
} | ||
}, exports; | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
@@ -378,146 +25,2 @@ key = _toPropertyKey(key); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (typeof call === "object" || typeof call === "function")) { | ||
return call; | ||
} else if (call !== void 0) { | ||
throw new TypeError("Derived constructors may only return object or undefined"); | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function _createSuperInternal() { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
} else { | ||
result = Super.apply(this, arguments); | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _createForOfIteratorHelper(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (!it) { | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
var F = function () {}; | ||
return { | ||
s: F, | ||
n: function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}, | ||
e: function (e) { | ||
throw e; | ||
}, | ||
f: F | ||
}; | ||
} | ||
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 normalCompletion = true, | ||
didErr = false, | ||
err; | ||
return { | ||
s: function () { | ||
it = it.call(o); | ||
}, | ||
n: function () { | ||
var step = it.next(); | ||
normalCompletion = step.done; | ||
return step; | ||
}, | ||
e: function (e) { | ||
didErr = true; | ||
err = e; | ||
}, | ||
f: function () { | ||
try { | ||
if (!normalCompletion && it.return != null) it.return(); | ||
} finally { | ||
if (didErr) throw err; | ||
} | ||
} | ||
}; | ||
} | ||
function _toPrimitive(input, hint) { | ||
@@ -538,572 +41,175 @@ if (typeof input !== "object" || input === null) return input; | ||
var Signal = /*#__PURE__*/function () { | ||
function Signal() { | ||
_classCallCheck(this, Signal); | ||
class Signal { | ||
constructor() { | ||
_defineProperty(this, "pipes", []); | ||
} | ||
_createClass(Signal, [{ | ||
key: "addPipe", | ||
value: function addPipe(pipe) { | ||
this.pipes.push(pipe); | ||
addPipe(pipe) { | ||
this.pipes.push(pipe); | ||
} | ||
async emit(context) { | ||
let current = context; | ||
for (const pipe of this.pipes) { | ||
current = await pipe(current); | ||
if (typeof current === 'undefined') return; | ||
} | ||
}, { | ||
key: "emit", | ||
value: function () { | ||
var _emit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(context) { | ||
var current, _iterator, _step, pipe; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
current = context; | ||
_iterator = _createForOfIteratorHelper(this.pipes); | ||
_context.prev = 2; | ||
_iterator.s(); | ||
case 4: | ||
if ((_step = _iterator.n()).done) { | ||
_context.next = 13; | ||
break; | ||
} | ||
pipe = _step.value; | ||
_context.next = 8; | ||
return pipe(current); | ||
case 8: | ||
current = _context.sent; | ||
if (!(typeof current === 'undefined')) { | ||
_context.next = 11; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
case 11: | ||
_context.next = 4; | ||
break; | ||
case 13: | ||
_context.next = 18; | ||
break; | ||
case 15: | ||
_context.prev = 15; | ||
_context.t0 = _context["catch"](2); | ||
_iterator.e(_context.t0); | ||
case 18: | ||
_context.prev = 18; | ||
_iterator.f(); | ||
return _context.finish(18); | ||
case 21: | ||
return _context.abrupt("return", current); | ||
case 22: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this, [[2, 15, 18, 21]]); | ||
})); | ||
function emit(_x) { | ||
return _emit.apply(this, arguments); | ||
} | ||
return emit; | ||
}() | ||
}]); | ||
return Signal; | ||
}(); | ||
var Scope = /*#__PURE__*/function () { | ||
return current; | ||
} | ||
} | ||
class Scope { | ||
// Parents['length'] extends 0 ? undefined : Scope<Parents[0], Tail<Parents>> | ||
function Scope(name) { | ||
_classCallCheck(this, Scope); | ||
constructor(name) { | ||
_defineProperty(this, "signal", new Signal()); | ||
this.name = name; | ||
} | ||
_createClass(Scope, [{ | ||
key: "addPipe", | ||
value: function addPipe(middleware) { | ||
this.signal.addPipe(middleware); | ||
} | ||
}, { | ||
key: "use", | ||
value: function use(scope) { | ||
scope.setParent(this); | ||
this.addPipe(function (context) { | ||
return scope.signal.emit(context); | ||
}); | ||
} | ||
}, { | ||
key: "setParent", | ||
value: function setParent(scope) { | ||
this.parent = scope; | ||
} | ||
}, { | ||
key: "emit", | ||
value: function emit(context) { | ||
return this.signal.emit(context); | ||
} | ||
}, { | ||
key: "hasParent", | ||
value: function hasParent() { | ||
return Boolean(this.parent); | ||
} | ||
}, { | ||
key: "parentScope", | ||
value: function parentScope(type) { | ||
if (!this.parent) throw new Error('cannot find parent'); | ||
if (type && this.parent instanceof type) return this.parent; | ||
if (type) throw new Error('actual parent is not instance of type'); | ||
return this.parent; | ||
} | ||
}]); | ||
return Scope; | ||
}(); | ||
addPipe(middleware) { | ||
this.signal.addPipe(middleware); | ||
} | ||
use(scope) { | ||
scope.setParent(this); | ||
this.addPipe(context => { | ||
return scope.signal.emit(context); | ||
}); | ||
} | ||
setParent(scope) { | ||
this.parent = scope; | ||
} | ||
emit(context) { | ||
return this.signal.emit(context); | ||
} | ||
hasParent() { | ||
return Boolean(this.parent); | ||
} | ||
parentScope(type) { | ||
if (!this.parent) throw new Error('cannot find parent'); | ||
if (type && this.parent instanceof type) return this.parent; | ||
if (type) throw new Error('actual parent is not instance of type'); | ||
return this.parent; | ||
} | ||
} | ||
var NodeEditor = /*#__PURE__*/function (_Scope) { | ||
_inherits(NodeEditor, _Scope); | ||
var _super = _createSuper(NodeEditor); | ||
function NodeEditor() { | ||
var _this; | ||
_classCallCheck(this, NodeEditor); | ||
_this = _super.call(this, 'NodeEditor'); | ||
_defineProperty(_assertThisInitialized(_this), "nodes", []); | ||
_defineProperty(_assertThisInitialized(_this), "connections", []); | ||
return _this; | ||
class NodeEditor extends Scope { | ||
constructor() { | ||
super('NodeEditor'); | ||
_defineProperty(this, "nodes", []); | ||
_defineProperty(this, "connections", []); | ||
} | ||
_createClass(NodeEditor, [{ | ||
key: "getNode", | ||
value: function getNode(id) { | ||
return this.nodes.find(function (node) { | ||
return node.id === id; | ||
getNode(id) { | ||
return this.nodes.find(node => node.id === id); | ||
} | ||
getNodes() { | ||
return this.nodes; | ||
} | ||
getConnections() { | ||
return this.connections; | ||
} | ||
getConnection(id) { | ||
return this.connections.find(connection => connection.id === id); | ||
} | ||
async addNode(data) { | ||
if (this.getNode(data.id)) throw new Error('node has already been added'); | ||
if (!(await this.emit({ | ||
type: 'nodecreate', | ||
data | ||
}))) return false; | ||
this.nodes.push(data); | ||
await this.emit({ | ||
type: 'nodecreated', | ||
data | ||
}); | ||
return true; | ||
} | ||
async addConnection(data) { | ||
if (this.getConnection(data.id)) throw new Error('connection has already been added'); | ||
if (!(await this.emit({ | ||
type: 'connectioncreate', | ||
data | ||
}))) return false; | ||
this.connections.push(data); | ||
await this.emit({ | ||
type: 'connectioncreated', | ||
data | ||
}); | ||
return true; | ||
} | ||
async removeNode(id) { | ||
const index = this.nodes.findIndex(n => n.id === id); | ||
const node = this.nodes[index]; | ||
if (index < 0) throw new Error('cannot find node'); | ||
if (!(await this.emit({ | ||
type: 'noderemove', | ||
data: node | ||
}))) return false; | ||
this.nodes.splice(index, 1); | ||
await this.emit({ | ||
type: 'noderemoved', | ||
data: node | ||
}); | ||
return true; | ||
} | ||
async removeConnection(id) { | ||
const index = this.connections.findIndex(n => n.id === id); | ||
const connection = this.connections[index]; | ||
if (index < 0) throw new Error('cannot find connection'); | ||
if (!(await this.emit({ | ||
type: 'connectionremove', | ||
data: connection | ||
}))) return false; | ||
this.connections.splice(index, 1); | ||
await this.emit({ | ||
type: 'connectionremoved', | ||
data: connection | ||
}); | ||
return true; | ||
} | ||
async clear() { | ||
if (!(await this.emit({ | ||
type: 'clear' | ||
}))) { | ||
await this.emit({ | ||
type: 'clearcancelled' | ||
}); | ||
return false; | ||
} | ||
}, { | ||
key: "getNodes", | ||
value: function getNodes() { | ||
return this.nodes; | ||
} | ||
}, { | ||
key: "getConnections", | ||
value: function getConnections() { | ||
return this.connections; | ||
} | ||
}, { | ||
key: "getConnection", | ||
value: function getConnection(id) { | ||
return this.connections.find(function (connection) { | ||
return connection.id === id; | ||
}); | ||
} | ||
}, { | ||
key: "addNode", | ||
value: function () { | ||
var _addNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!this.getNode(data.id)) { | ||
_context.next = 2; | ||
break; | ||
} | ||
throw new Error('node has already been added'); | ||
case 2: | ||
_context.next = 4; | ||
return this.emit({ | ||
type: 'nodecreate', | ||
data: data | ||
}); | ||
case 4: | ||
if (_context.sent) { | ||
_context.next = 6; | ||
break; | ||
} | ||
return _context.abrupt("return", false); | ||
case 6: | ||
this.nodes.push(data); | ||
_context.next = 9; | ||
return this.emit({ | ||
type: 'nodecreated', | ||
data: data | ||
}); | ||
case 9: | ||
return _context.abrupt("return", true); | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this); | ||
})); | ||
function addNode(_x) { | ||
return _addNode.apply(this, arguments); | ||
} | ||
return addNode; | ||
}() | ||
}, { | ||
key: "addConnection", | ||
value: function () { | ||
var _addConnection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (!this.getConnection(data.id)) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
throw new Error('connection has already been added'); | ||
case 2: | ||
_context2.next = 4; | ||
return this.emit({ | ||
type: 'connectioncreate', | ||
data: data | ||
}); | ||
case 4: | ||
if (_context2.sent) { | ||
_context2.next = 6; | ||
break; | ||
} | ||
return _context2.abrupt("return", false); | ||
case 6: | ||
this.connections.push(data); | ||
_context2.next = 9; | ||
return this.emit({ | ||
type: 'connectioncreated', | ||
data: data | ||
}); | ||
case 9: | ||
return _context2.abrupt("return", true); | ||
case 10: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2, this); | ||
})); | ||
function addConnection(_x2) { | ||
return _addConnection.apply(this, arguments); | ||
} | ||
return addConnection; | ||
}() | ||
}, { | ||
key: "removeNode", | ||
value: function () { | ||
var _removeNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id) { | ||
var index, node; | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
index = this.nodes.findIndex(function (n) { | ||
return n.id === id; | ||
}); | ||
node = this.nodes[index]; | ||
if (!(index < 0)) { | ||
_context3.next = 4; | ||
break; | ||
} | ||
throw new Error('cannot find node'); | ||
case 4: | ||
_context3.next = 6; | ||
return this.emit({ | ||
type: 'noderemove', | ||
data: node | ||
}); | ||
case 6: | ||
if (_context3.sent) { | ||
_context3.next = 8; | ||
break; | ||
} | ||
return _context3.abrupt("return", false); | ||
case 8: | ||
this.nodes.splice(index, 1); | ||
_context3.next = 11; | ||
return this.emit({ | ||
type: 'noderemoved', | ||
data: node | ||
}); | ||
case 11: | ||
return _context3.abrupt("return", true); | ||
case 12: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
}, _callee3, this); | ||
})); | ||
function removeNode(_x3) { | ||
return _removeNode.apply(this, arguments); | ||
} | ||
return removeNode; | ||
}() | ||
}, { | ||
key: "removeConnection", | ||
value: function () { | ||
var _removeConnection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id) { | ||
var index, connection; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
index = this.connections.findIndex(function (n) { | ||
return n.id === id; | ||
}); | ||
connection = this.connections[index]; | ||
if (!(index < 0)) { | ||
_context4.next = 4; | ||
break; | ||
} | ||
throw new Error('cannot find connection'); | ||
case 4: | ||
_context4.next = 6; | ||
return this.emit({ | ||
type: 'connectionremove', | ||
data: connection | ||
}); | ||
case 6: | ||
if (_context4.sent) { | ||
_context4.next = 8; | ||
break; | ||
} | ||
return _context4.abrupt("return", false); | ||
case 8: | ||
this.connections.splice(index, 1); | ||
_context4.next = 11; | ||
return this.emit({ | ||
type: 'connectionremoved', | ||
data: connection | ||
}); | ||
case 11: | ||
return _context4.abrupt("return", true); | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
}, _callee4, this); | ||
})); | ||
function removeConnection(_x4) { | ||
return _removeConnection.apply(this, arguments); | ||
} | ||
return removeConnection; | ||
}() | ||
}, { | ||
key: "clear", | ||
value: function () { | ||
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() { | ||
var _iterator, _step, connection, _iterator2, _step2, node; | ||
return _regeneratorRuntime().wrap(function _callee5$(_context5) { | ||
while (1) switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context5.next = 2; | ||
return this.emit({ | ||
type: 'clear' | ||
}); | ||
case 2: | ||
if (_context5.sent) { | ||
_context5.next = 6; | ||
break; | ||
} | ||
_context5.next = 5; | ||
return this.emit({ | ||
type: 'clearcancelled' | ||
}); | ||
case 5: | ||
return _context5.abrupt("return", false); | ||
case 6: | ||
_iterator = _createForOfIteratorHelper(this.connections.slice()); | ||
_context5.prev = 7; | ||
_iterator.s(); | ||
case 9: | ||
if ((_step = _iterator.n()).done) { | ||
_context5.next = 15; | ||
break; | ||
} | ||
connection = _step.value; | ||
_context5.next = 13; | ||
return this.removeConnection(connection.id); | ||
case 13: | ||
_context5.next = 9; | ||
break; | ||
case 15: | ||
_context5.next = 20; | ||
break; | ||
case 17: | ||
_context5.prev = 17; | ||
_context5.t0 = _context5["catch"](7); | ||
_iterator.e(_context5.t0); | ||
case 20: | ||
_context5.prev = 20; | ||
_iterator.f(); | ||
return _context5.finish(20); | ||
case 23: | ||
_iterator2 = _createForOfIteratorHelper(this.nodes.slice()); | ||
_context5.prev = 24; | ||
_iterator2.s(); | ||
case 26: | ||
if ((_step2 = _iterator2.n()).done) { | ||
_context5.next = 32; | ||
break; | ||
} | ||
node = _step2.value; | ||
_context5.next = 30; | ||
return this.removeNode(node.id); | ||
case 30: | ||
_context5.next = 26; | ||
break; | ||
case 32: | ||
_context5.next = 37; | ||
break; | ||
case 34: | ||
_context5.prev = 34; | ||
_context5.t1 = _context5["catch"](24); | ||
_iterator2.e(_context5.t1); | ||
case 37: | ||
_context5.prev = 37; | ||
_iterator2.f(); | ||
return _context5.finish(37); | ||
case 40: | ||
_context5.next = 42; | ||
return this.emit({ | ||
type: 'cleared' | ||
}); | ||
case 42: | ||
return _context5.abrupt("return", true); | ||
case 43: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
}, _callee5, this, [[7, 17, 20, 23], [24, 34, 37, 40]]); | ||
})); | ||
function clear() { | ||
return _clear.apply(this, arguments); | ||
} | ||
return clear; | ||
}() | ||
}, { | ||
key: "import", | ||
value: function () { | ||
var _import2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data) { | ||
var _iterator3, _step3, node, _iterator4, _step4, connection; | ||
return _regeneratorRuntime().wrap(function _callee6$(_context6) { | ||
while (1) switch (_context6.prev = _context6.next) { | ||
case 0: | ||
_context6.next = 2; | ||
return this.emit({ | ||
type: 'import', | ||
data: data | ||
}); | ||
case 2: | ||
if (_context6.sent) { | ||
_context6.next = 4; | ||
break; | ||
} | ||
return _context6.abrupt("return", false); | ||
case 4: | ||
_iterator3 = _createForOfIteratorHelper(data.nodes); | ||
_context6.prev = 5; | ||
_iterator3.s(); | ||
case 7: | ||
if ((_step3 = _iterator3.n()).done) { | ||
_context6.next = 13; | ||
break; | ||
} | ||
node = _step3.value; | ||
_context6.next = 11; | ||
return this.addNode(node); | ||
case 11: | ||
_context6.next = 7; | ||
break; | ||
case 13: | ||
_context6.next = 18; | ||
break; | ||
case 15: | ||
_context6.prev = 15; | ||
_context6.t0 = _context6["catch"](5); | ||
_iterator3.e(_context6.t0); | ||
case 18: | ||
_context6.prev = 18; | ||
_iterator3.f(); | ||
return _context6.finish(18); | ||
case 21: | ||
_iterator4 = _createForOfIteratorHelper(data.connections); | ||
_context6.prev = 22; | ||
_iterator4.s(); | ||
case 24: | ||
if ((_step4 = _iterator4.n()).done) { | ||
_context6.next = 30; | ||
break; | ||
} | ||
connection = _step4.value; | ||
_context6.next = 28; | ||
return this.addConnection(connection); | ||
case 28: | ||
_context6.next = 24; | ||
break; | ||
case 30: | ||
_context6.next = 35; | ||
break; | ||
case 32: | ||
_context6.prev = 32; | ||
_context6.t1 = _context6["catch"](22); | ||
_iterator4.e(_context6.t1); | ||
case 35: | ||
_context6.prev = 35; | ||
_iterator4.f(); | ||
return _context6.finish(35); | ||
case 38: | ||
_context6.next = 40; | ||
return this.emit({ | ||
type: 'imported', | ||
data: data | ||
}); | ||
case 40: | ||
return _context6.abrupt("return", true); | ||
case 41: | ||
case "end": | ||
return _context6.stop(); | ||
} | ||
}, _callee6, this, [[5, 15, 18, 21], [22, 32, 35, 38]]); | ||
})); | ||
function _import(_x5) { | ||
return _import2.apply(this, arguments); | ||
} | ||
return _import; | ||
}() | ||
}, { | ||
key: "export", | ||
value: function () { | ||
var _export2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() { | ||
var _data$nodes, _data$connections; | ||
var data; | ||
return _regeneratorRuntime().wrap(function _callee7$(_context7) { | ||
while (1) switch (_context7.prev = _context7.next) { | ||
case 0: | ||
data = { | ||
nodes: [], | ||
connections: [] | ||
}; | ||
_context7.next = 3; | ||
return this.emit({ | ||
type: 'export', | ||
data: data | ||
}); | ||
case 3: | ||
if (_context7.sent) { | ||
_context7.next = 5; | ||
break; | ||
} | ||
return _context7.abrupt("return", false); | ||
case 5: | ||
(_data$nodes = data.nodes).push.apply(_data$nodes, _toConsumableArray(this.nodes)); | ||
(_data$connections = data.connections).push.apply(_data$connections, _toConsumableArray(this.connections)); | ||
_context7.next = 9; | ||
return this.emit({ | ||
type: 'exported', | ||
data: data | ||
}); | ||
case 9: | ||
return _context7.abrupt("return", data); | ||
case 10: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
}, _callee7, this); | ||
})); | ||
function _export() { | ||
return _export2.apply(this, arguments); | ||
} | ||
return _export; | ||
}() | ||
}]); | ||
return NodeEditor; | ||
}(Scope); | ||
for (const connection of this.connections.slice()) await this.removeConnection(connection.id); | ||
for (const node of this.nodes.slice()) await this.removeNode(node.id); | ||
await this.emit({ | ||
type: 'cleared' | ||
}); | ||
return true; | ||
} | ||
async import(data) { | ||
if (!(await this.emit({ | ||
type: 'import', | ||
data | ||
}))) return false; | ||
for (const node of data.nodes) await this.addNode(node); | ||
for (const connection of data.connections) await this.addConnection(connection); | ||
await this.emit({ | ||
type: 'imported', | ||
data | ||
}); | ||
return true; | ||
} | ||
async export() { | ||
const data = { | ||
nodes: [], | ||
connections: [] | ||
}; | ||
if (!(await this.emit({ | ||
type: 'export', | ||
data | ||
}))) return false; | ||
data.nodes.push(...this.nodes); | ||
data.connections.push(...this.connections); | ||
await this.emit({ | ||
type: 'exported', | ||
data | ||
}); | ||
return data; | ||
} | ||
} | ||
/* global globalThis*/ | ||
var crypto = globalThis.crypto; | ||
const crypto = globalThis.crypto; | ||
function getUID() { | ||
@@ -1113,89 +219,61 @@ if ('randomBytes' in crypto) { | ||
} | ||
var bytes = crypto.getRandomValues(new Uint8Array(8)); | ||
var array = Array.from(bytes); | ||
var hexPairs = array.map(function (b) { | ||
return b.toString(16).padStart(2, '0'); | ||
}); | ||
const bytes = crypto.getRandomValues(new Uint8Array(8)); | ||
const array = Array.from(bytes); | ||
const hexPairs = array.map(b => b.toString(16).padStart(2, '0')); | ||
return hexPairs.join(''); | ||
} | ||
var Socket = /*#__PURE__*/_createClass(function Socket(name) { | ||
_classCallCheck(this, Socket); | ||
this.name = name; | ||
}); | ||
var Port = /*#__PURE__*/_createClass(function Port(socket, label, multipleConnections) { | ||
_classCallCheck(this, Port); | ||
this.socket = socket; | ||
this.label = label; | ||
this.multipleConnections = multipleConnections; | ||
this.id = getUID(); | ||
}); | ||
var Input = /*#__PURE__*/function (_Port) { | ||
_inherits(Input, _Port); | ||
var _super = _createSuper(Input); | ||
function Input() { | ||
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)); | ||
_defineProperty(_assertThisInitialized(_this), "control", null); | ||
_defineProperty(_assertThisInitialized(_this), "showControl", true); | ||
return _this; | ||
class Socket { | ||
constructor(name) { | ||
this.name = name; | ||
} | ||
_createClass(Input, [{ | ||
key: "addControl", | ||
value: function addControl(control) { | ||
if (this.control) throw new Error('control already added for this input'); | ||
this.control = control; | ||
} | ||
}, { | ||
key: "removeControl", | ||
value: function removeControl() { | ||
this.control = null; | ||
} | ||
}]); | ||
return Input; | ||
}(Port); | ||
var Output = /*#__PURE__*/function (_Port2) { | ||
_inherits(Output, _Port2); | ||
var _super2 = _createSuper(Output); | ||
function Output(socket, label, multipleConnections) { | ||
_classCallCheck(this, Output); | ||
return _super2.call(this, socket, label, multipleConnections !== false); | ||
} | ||
class Port { | ||
constructor(socket, label, multipleConnections) { | ||
this.socket = socket; | ||
this.label = label; | ||
this.multipleConnections = multipleConnections; | ||
this.id = getUID(); | ||
} | ||
return _createClass(Output); | ||
}(Port); | ||
var Control = /*#__PURE__*/_createClass(function Control() { | ||
_classCallCheck(this, Control); | ||
this.id = getUID(); | ||
}); | ||
var InputControl = /*#__PURE__*/function (_Control) { | ||
_inherits(InputControl, _Control); | ||
var _super3 = _createSuper(InputControl); | ||
function InputControl(type, options) { | ||
var _this2; | ||
_classCallCheck(this, InputControl); | ||
_this2 = _super3.call(this); | ||
_this2.type = type; | ||
_this2.options = options; | ||
_this2.id = getUID(); | ||
_this2.readonly = options === null || options === void 0 ? void 0 : options.readonly; | ||
if (typeof (options === null || options === void 0 ? void 0 : options.initial) !== 'undefined') _this2.value = options.initial; | ||
return _this2; | ||
} | ||
class Input extends Port { | ||
constructor() { | ||
super(...arguments); | ||
_defineProperty(this, "control", null); | ||
_defineProperty(this, "showControl", true); | ||
} | ||
_createClass(InputControl, [{ | ||
key: "setValue", | ||
value: function setValue(value) { | ||
var _this$options; | ||
this.value = value; | ||
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.change) this.options.change(value); | ||
} | ||
}]); | ||
return InputControl; | ||
}(Control); | ||
var Node = /*#__PURE__*/function () { | ||
function Node(label) { | ||
_classCallCheck(this, Node); | ||
addControl(control) { | ||
if (this.control) throw new Error('control already added for this input'); | ||
this.control = control; | ||
} | ||
removeControl() { | ||
this.control = null; | ||
} | ||
} | ||
class Output extends Port { | ||
constructor(socket, label, multipleConnections) { | ||
super(socket, label, multipleConnections !== false); | ||
} | ||
} | ||
class Control { | ||
constructor() { | ||
this.id = getUID(); | ||
} | ||
} | ||
class InputControl extends Control { | ||
constructor(type, options) { | ||
super(); | ||
this.type = type; | ||
this.options = options; | ||
this.id = getUID(); | ||
this.readonly = options?.readonly; | ||
if (typeof options?.initial !== 'undefined') this.value = options.initial; | ||
} | ||
setValue(value) { | ||
this.value = value; | ||
if (this.options?.change) this.options.change(value); | ||
} | ||
} | ||
class Node { | ||
constructor(label) { | ||
_defineProperty(this, "inputs", {}); | ||
@@ -1207,79 +285,60 @@ _defineProperty(this, "outputs", {}); | ||
} | ||
_createClass(Node, [{ | ||
key: "hasInput", | ||
value: function hasInput(key) { | ||
return Object.prototype.hasOwnProperty.call(this.inputs, key); | ||
hasInput(key) { | ||
return Object.prototype.hasOwnProperty.call(this.inputs, key); | ||
} | ||
addInput(key, input) { | ||
if (this.hasInput(key)) throw new Error(`input with key '${String(key)}' already added`); | ||
Object.defineProperty(this.inputs, key, { | ||
value: input, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
removeInput(key) { | ||
delete this.inputs[key]; | ||
} | ||
hasOutput(key) { | ||
return Object.prototype.hasOwnProperty.call(this.outputs, key); | ||
} | ||
addOutput(key, output) { | ||
if (this.hasOutput(key)) throw new Error(`output with key '${String(key)}' already added`); | ||
Object.defineProperty(this.outputs, key, { | ||
value: output, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
removeOutput(key) { | ||
delete this.outputs[key]; | ||
} | ||
hasControl(key) { | ||
return Object.prototype.hasOwnProperty.call(this.controls, key); | ||
} | ||
addControl(key, control) { | ||
if (this.hasControl(key)) throw new Error(`control with key '${String(key)}' already added`); | ||
Object.defineProperty(this.controls, key, { | ||
value: control, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
removeControl(key) { | ||
delete this.controls[key]; | ||
} | ||
} | ||
class Connection { | ||
constructor(source, sourceOutput, target, targetInput) { | ||
this.sourceOutput = sourceOutput; | ||
this.targetInput = targetInput; | ||
if (!source.outputs[sourceOutput]) { | ||
throw new Error(`source node doesn't have output with a key ${String(sourceOutput)}`); | ||
} | ||
}, { | ||
key: "addInput", | ||
value: function addInput(key, input) { | ||
if (this.hasInput(key)) throw new Error("input with key '".concat(String(key), "' already added")); | ||
Object.defineProperty(this.inputs, key, { | ||
value: input, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
if (!target.inputs[targetInput]) { | ||
throw new Error(`target node doesn't have input with a key ${String(targetInput)}`); | ||
} | ||
}, { | ||
key: "removeInput", | ||
value: function removeInput(key) { | ||
delete this.inputs[key]; | ||
} | ||
}, { | ||
key: "hasOutput", | ||
value: function hasOutput(key) { | ||
return Object.prototype.hasOwnProperty.call(this.outputs, key); | ||
} | ||
}, { | ||
key: "addOutput", | ||
value: function addOutput(key, output) { | ||
if (this.hasOutput(key)) throw new Error("output with key '".concat(String(key), "' already added")); | ||
Object.defineProperty(this.outputs, key, { | ||
value: output, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
}, { | ||
key: "removeOutput", | ||
value: function removeOutput(key) { | ||
delete this.outputs[key]; | ||
} | ||
}, { | ||
key: "hasControl", | ||
value: function hasControl(key) { | ||
return Object.prototype.hasOwnProperty.call(this.controls, key); | ||
} | ||
}, { | ||
key: "addControl", | ||
value: function addControl(key, control) { | ||
if (this.hasControl(key)) throw new Error("control with key '".concat(String(key), "' already added")); | ||
Object.defineProperty(this.controls, key, { | ||
value: control, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
}, { | ||
key: "removeControl", | ||
value: function removeControl(key) { | ||
delete this.controls[key]; | ||
} | ||
}]); | ||
return Node; | ||
}(); | ||
var Connection = /*#__PURE__*/_createClass(function Connection(source, sourceOutput, target, targetInput) { | ||
_classCallCheck(this, Connection); | ||
this.sourceOutput = sourceOutput; | ||
this.targetInput = targetInput; | ||
if (!source.outputs[sourceOutput]) { | ||
throw new Error("source node doesn't have output with a key ".concat(String(sourceOutput))); | ||
this.id = getUID(); | ||
this.source = source.id; | ||
this.target = target.id; | ||
} | ||
if (!target.inputs[targetInput]) { | ||
throw new Error("target node doesn't have input with a key ".concat(String(targetInput))); | ||
} | ||
this.id = getUID(); | ||
this.source = source.id; | ||
this.target = target.id; | ||
}); | ||
} | ||
@@ -1286,0 +345,0 @@ var classic = /*#__PURE__*/Object.freeze({ |
1477
rete.esm.js
/*! | ||
* rete v2.0.0-beta.2 | ||
* rete v2.0.0-beta.3 | ||
* (c) 2023 Vitaliy Stoliarov | ||
* Released under the MIT license. | ||
* */ | ||
function _regeneratorRuntime() { | ||
_regeneratorRuntime = function () { | ||
return exports; | ||
}; | ||
var exports = {}, | ||
Op = Object.prototype, | ||
hasOwn = Op.hasOwnProperty, | ||
defineProperty = Object.defineProperty || function (obj, key, desc) { | ||
obj[key] = desc.value; | ||
}, | ||
$Symbol = "function" == typeof Symbol ? Symbol : {}, | ||
iteratorSymbol = $Symbol.iterator || "@@iterator", | ||
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", | ||
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
function define(obj, key, value) { | ||
return Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}), obj[key]; | ||
} | ||
try { | ||
define({}, ""); | ||
} catch (err) { | ||
define = function (obj, key, value) { | ||
return obj[key] = value; | ||
}; | ||
} | ||
function wrap(innerFn, outerFn, self, tryLocsList) { | ||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, | ||
generator = Object.create(protoGenerator.prototype), | ||
context = new Context(tryLocsList || []); | ||
return defineProperty(generator, "_invoke", { | ||
value: makeInvokeMethod(innerFn, self, context) | ||
}), generator; | ||
} | ||
function tryCatch(fn, obj, arg) { | ||
try { | ||
return { | ||
type: "normal", | ||
arg: fn.call(obj, arg) | ||
}; | ||
} catch (err) { | ||
return { | ||
type: "throw", | ||
arg: err | ||
}; | ||
} | ||
} | ||
exports.wrap = wrap; | ||
var ContinueSentinel = {}; | ||
function Generator() {} | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
var IteratorPrototype = {}; | ||
define(IteratorPrototype, iteratorSymbol, function () { | ||
return this; | ||
}); | ||
var getProto = Object.getPrototypeOf, | ||
NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); | ||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); | ||
function defineIteratorMethods(prototype) { | ||
["next", "throw", "return"].forEach(function (method) { | ||
define(prototype, method, function (arg) { | ||
return this._invoke(method, arg); | ||
}); | ||
}); | ||
} | ||
function AsyncIterator(generator, PromiseImpl) { | ||
function invoke(method, arg, resolve, reject) { | ||
var record = tryCatch(generator[method], generator, arg); | ||
if ("throw" !== record.type) { | ||
var result = record.arg, | ||
value = result.value; | ||
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { | ||
invoke("next", value, resolve, reject); | ||
}, function (err) { | ||
invoke("throw", err, resolve, reject); | ||
}) : PromiseImpl.resolve(value).then(function (unwrapped) { | ||
result.value = unwrapped, resolve(result); | ||
}, function (error) { | ||
return invoke("throw", error, resolve, reject); | ||
}); | ||
} | ||
reject(record.arg); | ||
} | ||
var previousPromise; | ||
defineProperty(this, "_invoke", { | ||
value: function (method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function (resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
} | ||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); | ||
} | ||
}); | ||
} | ||
function makeInvokeMethod(innerFn, self, context) { | ||
var state = "suspendedStart"; | ||
return function (method, arg) { | ||
if ("executing" === state) throw new Error("Generator is already running"); | ||
if ("completed" === state) { | ||
if ("throw" === method) throw arg; | ||
return doneResult(); | ||
} | ||
for (context.method = method, context.arg = arg;;) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { | ||
if ("suspendedStart" === state) throw state = "completed", context.arg; | ||
context.dispatchException(context.arg); | ||
} else "return" === context.method && context.abrupt("return", context.arg); | ||
state = "executing"; | ||
var record = tryCatch(innerFn, self, context); | ||
if ("normal" === record.type) { | ||
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} | ||
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); | ||
} | ||
}; | ||
} | ||
function maybeInvokeDelegate(delegate, context) { | ||
var methodName = context.method, | ||
method = delegate.iterator[methodName]; | ||
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; | ||
var record = tryCatch(method, delegate.iterator, context.arg); | ||
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; | ||
var info = record.arg; | ||
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); | ||
} | ||
function pushTryEntry(locs) { | ||
var entry = { | ||
tryLoc: locs[0] | ||
}; | ||
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); | ||
} | ||
function resetTryEntry(entry) { | ||
var record = entry.completion || {}; | ||
record.type = "normal", delete record.arg, entry.completion = record; | ||
} | ||
function Context(tryLocsList) { | ||
this.tryEntries = [{ | ||
tryLoc: "root" | ||
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); | ||
} | ||
function values(iterable) { | ||
if (iterable) { | ||
var iteratorMethod = iterable[iteratorSymbol]; | ||
if (iteratorMethod) return iteratorMethod.call(iterable); | ||
if ("function" == typeof iterable.next) return iterable; | ||
if (!isNaN(iterable.length)) { | ||
var i = -1, | ||
next = function next() { | ||
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; | ||
return next.value = undefined, next.done = !0, next; | ||
}; | ||
return next.next = next; | ||
} | ||
} | ||
return { | ||
next: doneResult | ||
}; | ||
} | ||
function doneResult() { | ||
return { | ||
value: undefined, | ||
done: !0 | ||
}; | ||
} | ||
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { | ||
value: GeneratorFunctionPrototype, | ||
configurable: !0 | ||
}), defineProperty(GeneratorFunctionPrototype, "constructor", { | ||
value: GeneratorFunction, | ||
configurable: !0 | ||
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { | ||
var ctor = "function" == typeof genFun && genFun.constructor; | ||
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); | ||
}, exports.mark = function (genFun) { | ||
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; | ||
}, exports.awrap = function (arg) { | ||
return { | ||
__await: arg | ||
}; | ||
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { | ||
return this; | ||
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
void 0 === PromiseImpl && (PromiseImpl = Promise); | ||
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); | ||
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { | ||
return result.done ? result.value : iter.next(); | ||
}); | ||
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { | ||
return this; | ||
}), define(Gp, "toString", function () { | ||
return "[object Generator]"; | ||
}), exports.keys = function (val) { | ||
var object = Object(val), | ||
keys = []; | ||
for (var key in object) keys.push(key); | ||
return keys.reverse(), function next() { | ||
for (; keys.length;) { | ||
var key = keys.pop(); | ||
if (key in object) return next.value = key, next.done = !1, next; | ||
} | ||
return next.done = !0, next; | ||
}; | ||
}, exports.values = values, Context.prototype = { | ||
constructor: Context, | ||
reset: function (skipTempReset) { | ||
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); | ||
}, | ||
stop: function () { | ||
this.done = !0; | ||
var rootRecord = this.tryEntries[0].completion; | ||
if ("throw" === rootRecord.type) throw rootRecord.arg; | ||
return this.rval; | ||
}, | ||
dispatchException: function (exception) { | ||
if (this.done) throw exception; | ||
var context = this; | ||
function handle(loc, caught) { | ||
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; | ||
} | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i], | ||
record = entry.completion; | ||
if ("root" === entry.tryLoc) return handle("end"); | ||
if (entry.tryLoc <= this.prev) { | ||
var hasCatch = hasOwn.call(entry, "catchLoc"), | ||
hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
if (hasCatch && hasFinally) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} else if (hasCatch) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
} else { | ||
if (!hasFinally) throw new Error("try statement without catch or finally"); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} | ||
} | ||
} | ||
}, | ||
abrupt: function (type, arg) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { | ||
var finallyEntry = entry; | ||
break; | ||
} | ||
} | ||
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); | ||
var record = finallyEntry ? finallyEntry.completion : {}; | ||
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); | ||
}, | ||
complete: function (record, afterLoc) { | ||
if ("throw" === record.type) throw record.arg; | ||
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; | ||
}, | ||
finish: function (finallyLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; | ||
} | ||
}, | ||
catch: function (tryLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc === tryLoc) { | ||
var record = entry.completion; | ||
if ("throw" === record.type) { | ||
var thrown = record.arg; | ||
resetTryEntry(entry); | ||
} | ||
return thrown; | ||
} | ||
} | ||
throw new Error("illegal catch attempt"); | ||
}, | ||
delegateYield: function (iterable, resultName, nextLoc) { | ||
return this.delegate = { | ||
iterator: values(iterable), | ||
resultName: resultName, | ||
nextLoc: nextLoc | ||
}, "next" === this.method && (this.arg = undefined), ContinueSentinel; | ||
} | ||
}, exports; | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
@@ -373,146 +20,2 @@ key = _toPropertyKey(key); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (typeof call === "object" || typeof call === "function")) { | ||
return call; | ||
} else if (call !== void 0) { | ||
throw new TypeError("Derived constructors may only return object or undefined"); | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function _createSuperInternal() { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
} else { | ||
result = Super.apply(this, arguments); | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _createForOfIteratorHelper(o, allowArrayLike) { | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (!it) { | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
var F = function () {}; | ||
return { | ||
s: F, | ||
n: function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}, | ||
e: function (e) { | ||
throw e; | ||
}, | ||
f: F | ||
}; | ||
} | ||
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 normalCompletion = true, | ||
didErr = false, | ||
err; | ||
return { | ||
s: function () { | ||
it = it.call(o); | ||
}, | ||
n: function () { | ||
var step = it.next(); | ||
normalCompletion = step.done; | ||
return step; | ||
}, | ||
e: function (e) { | ||
didErr = true; | ||
err = e; | ||
}, | ||
f: function () { | ||
try { | ||
if (!normalCompletion && it.return != null) it.return(); | ||
} finally { | ||
if (didErr) throw err; | ||
} | ||
} | ||
}; | ||
} | ||
function _toPrimitive(input, hint) { | ||
@@ -533,572 +36,175 @@ if (typeof input !== "object" || input === null) return input; | ||
var Signal = /*#__PURE__*/function () { | ||
function Signal() { | ||
_classCallCheck(this, Signal); | ||
class Signal { | ||
constructor() { | ||
_defineProperty(this, "pipes", []); | ||
} | ||
_createClass(Signal, [{ | ||
key: "addPipe", | ||
value: function addPipe(pipe) { | ||
this.pipes.push(pipe); | ||
addPipe(pipe) { | ||
this.pipes.push(pipe); | ||
} | ||
async emit(context) { | ||
let current = context; | ||
for (const pipe of this.pipes) { | ||
current = await pipe(current); | ||
if (typeof current === 'undefined') return; | ||
} | ||
}, { | ||
key: "emit", | ||
value: function () { | ||
var _emit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(context) { | ||
var current, _iterator, _step, pipe; | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
current = context; | ||
_iterator = _createForOfIteratorHelper(this.pipes); | ||
_context.prev = 2; | ||
_iterator.s(); | ||
case 4: | ||
if ((_step = _iterator.n()).done) { | ||
_context.next = 13; | ||
break; | ||
} | ||
pipe = _step.value; | ||
_context.next = 8; | ||
return pipe(current); | ||
case 8: | ||
current = _context.sent; | ||
if (!(typeof current === 'undefined')) { | ||
_context.next = 11; | ||
break; | ||
} | ||
return _context.abrupt("return"); | ||
case 11: | ||
_context.next = 4; | ||
break; | ||
case 13: | ||
_context.next = 18; | ||
break; | ||
case 15: | ||
_context.prev = 15; | ||
_context.t0 = _context["catch"](2); | ||
_iterator.e(_context.t0); | ||
case 18: | ||
_context.prev = 18; | ||
_iterator.f(); | ||
return _context.finish(18); | ||
case 21: | ||
return _context.abrupt("return", current); | ||
case 22: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this, [[2, 15, 18, 21]]); | ||
})); | ||
function emit(_x) { | ||
return _emit.apply(this, arguments); | ||
} | ||
return emit; | ||
}() | ||
}]); | ||
return Signal; | ||
}(); | ||
var Scope = /*#__PURE__*/function () { | ||
return current; | ||
} | ||
} | ||
class Scope { | ||
// Parents['length'] extends 0 ? undefined : Scope<Parents[0], Tail<Parents>> | ||
function Scope(name) { | ||
_classCallCheck(this, Scope); | ||
constructor(name) { | ||
_defineProperty(this, "signal", new Signal()); | ||
this.name = name; | ||
} | ||
_createClass(Scope, [{ | ||
key: "addPipe", | ||
value: function addPipe(middleware) { | ||
this.signal.addPipe(middleware); | ||
} | ||
}, { | ||
key: "use", | ||
value: function use(scope) { | ||
scope.setParent(this); | ||
this.addPipe(function (context) { | ||
return scope.signal.emit(context); | ||
}); | ||
} | ||
}, { | ||
key: "setParent", | ||
value: function setParent(scope) { | ||
this.parent = scope; | ||
} | ||
}, { | ||
key: "emit", | ||
value: function emit(context) { | ||
return this.signal.emit(context); | ||
} | ||
}, { | ||
key: "hasParent", | ||
value: function hasParent() { | ||
return Boolean(this.parent); | ||
} | ||
}, { | ||
key: "parentScope", | ||
value: function parentScope(type) { | ||
if (!this.parent) throw new Error('cannot find parent'); | ||
if (type && this.parent instanceof type) return this.parent; | ||
if (type) throw new Error('actual parent is not instance of type'); | ||
return this.parent; | ||
} | ||
}]); | ||
return Scope; | ||
}(); | ||
addPipe(middleware) { | ||
this.signal.addPipe(middleware); | ||
} | ||
use(scope) { | ||
scope.setParent(this); | ||
this.addPipe(context => { | ||
return scope.signal.emit(context); | ||
}); | ||
} | ||
setParent(scope) { | ||
this.parent = scope; | ||
} | ||
emit(context) { | ||
return this.signal.emit(context); | ||
} | ||
hasParent() { | ||
return Boolean(this.parent); | ||
} | ||
parentScope(type) { | ||
if (!this.parent) throw new Error('cannot find parent'); | ||
if (type && this.parent instanceof type) return this.parent; | ||
if (type) throw new Error('actual parent is not instance of type'); | ||
return this.parent; | ||
} | ||
} | ||
var NodeEditor = /*#__PURE__*/function (_Scope) { | ||
_inherits(NodeEditor, _Scope); | ||
var _super = _createSuper(NodeEditor); | ||
function NodeEditor() { | ||
var _this; | ||
_classCallCheck(this, NodeEditor); | ||
_this = _super.call(this, 'NodeEditor'); | ||
_defineProperty(_assertThisInitialized(_this), "nodes", []); | ||
_defineProperty(_assertThisInitialized(_this), "connections", []); | ||
return _this; | ||
class NodeEditor extends Scope { | ||
constructor() { | ||
super('NodeEditor'); | ||
_defineProperty(this, "nodes", []); | ||
_defineProperty(this, "connections", []); | ||
} | ||
_createClass(NodeEditor, [{ | ||
key: "getNode", | ||
value: function getNode(id) { | ||
return this.nodes.find(function (node) { | ||
return node.id === id; | ||
getNode(id) { | ||
return this.nodes.find(node => node.id === id); | ||
} | ||
getNodes() { | ||
return this.nodes; | ||
} | ||
getConnections() { | ||
return this.connections; | ||
} | ||
getConnection(id) { | ||
return this.connections.find(connection => connection.id === id); | ||
} | ||
async addNode(data) { | ||
if (this.getNode(data.id)) throw new Error('node has already been added'); | ||
if (!(await this.emit({ | ||
type: 'nodecreate', | ||
data | ||
}))) return false; | ||
this.nodes.push(data); | ||
await this.emit({ | ||
type: 'nodecreated', | ||
data | ||
}); | ||
return true; | ||
} | ||
async addConnection(data) { | ||
if (this.getConnection(data.id)) throw new Error('connection has already been added'); | ||
if (!(await this.emit({ | ||
type: 'connectioncreate', | ||
data | ||
}))) return false; | ||
this.connections.push(data); | ||
await this.emit({ | ||
type: 'connectioncreated', | ||
data | ||
}); | ||
return true; | ||
} | ||
async removeNode(id) { | ||
const index = this.nodes.findIndex(n => n.id === id); | ||
const node = this.nodes[index]; | ||
if (index < 0) throw new Error('cannot find node'); | ||
if (!(await this.emit({ | ||
type: 'noderemove', | ||
data: node | ||
}))) return false; | ||
this.nodes.splice(index, 1); | ||
await this.emit({ | ||
type: 'noderemoved', | ||
data: node | ||
}); | ||
return true; | ||
} | ||
async removeConnection(id) { | ||
const index = this.connections.findIndex(n => n.id === id); | ||
const connection = this.connections[index]; | ||
if (index < 0) throw new Error('cannot find connection'); | ||
if (!(await this.emit({ | ||
type: 'connectionremove', | ||
data: connection | ||
}))) return false; | ||
this.connections.splice(index, 1); | ||
await this.emit({ | ||
type: 'connectionremoved', | ||
data: connection | ||
}); | ||
return true; | ||
} | ||
async clear() { | ||
if (!(await this.emit({ | ||
type: 'clear' | ||
}))) { | ||
await this.emit({ | ||
type: 'clearcancelled' | ||
}); | ||
return false; | ||
} | ||
}, { | ||
key: "getNodes", | ||
value: function getNodes() { | ||
return this.nodes; | ||
} | ||
}, { | ||
key: "getConnections", | ||
value: function getConnections() { | ||
return this.connections; | ||
} | ||
}, { | ||
key: "getConnection", | ||
value: function getConnection(id) { | ||
return this.connections.find(function (connection) { | ||
return connection.id === id; | ||
}); | ||
} | ||
}, { | ||
key: "addNode", | ||
value: function () { | ||
var _addNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!this.getNode(data.id)) { | ||
_context.next = 2; | ||
break; | ||
} | ||
throw new Error('node has already been added'); | ||
case 2: | ||
_context.next = 4; | ||
return this.emit({ | ||
type: 'nodecreate', | ||
data: data | ||
}); | ||
case 4: | ||
if (_context.sent) { | ||
_context.next = 6; | ||
break; | ||
} | ||
return _context.abrupt("return", false); | ||
case 6: | ||
this.nodes.push(data); | ||
_context.next = 9; | ||
return this.emit({ | ||
type: 'nodecreated', | ||
data: data | ||
}); | ||
case 9: | ||
return _context.abrupt("return", true); | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
}, _callee, this); | ||
})); | ||
function addNode(_x) { | ||
return _addNode.apply(this, arguments); | ||
} | ||
return addNode; | ||
}() | ||
}, { | ||
key: "addConnection", | ||
value: function () { | ||
var _addConnection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (!this.getConnection(data.id)) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
throw new Error('connection has already been added'); | ||
case 2: | ||
_context2.next = 4; | ||
return this.emit({ | ||
type: 'connectioncreate', | ||
data: data | ||
}); | ||
case 4: | ||
if (_context2.sent) { | ||
_context2.next = 6; | ||
break; | ||
} | ||
return _context2.abrupt("return", false); | ||
case 6: | ||
this.connections.push(data); | ||
_context2.next = 9; | ||
return this.emit({ | ||
type: 'connectioncreated', | ||
data: data | ||
}); | ||
case 9: | ||
return _context2.abrupt("return", true); | ||
case 10: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2, this); | ||
})); | ||
function addConnection(_x2) { | ||
return _addConnection.apply(this, arguments); | ||
} | ||
return addConnection; | ||
}() | ||
}, { | ||
key: "removeNode", | ||
value: function () { | ||
var _removeNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(id) { | ||
var index, node; | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) switch (_context3.prev = _context3.next) { | ||
case 0: | ||
index = this.nodes.findIndex(function (n) { | ||
return n.id === id; | ||
}); | ||
node = this.nodes[index]; | ||
if (!(index < 0)) { | ||
_context3.next = 4; | ||
break; | ||
} | ||
throw new Error('cannot find node'); | ||
case 4: | ||
_context3.next = 6; | ||
return this.emit({ | ||
type: 'noderemove', | ||
data: node | ||
}); | ||
case 6: | ||
if (_context3.sent) { | ||
_context3.next = 8; | ||
break; | ||
} | ||
return _context3.abrupt("return", false); | ||
case 8: | ||
this.nodes.splice(index, 1); | ||
_context3.next = 11; | ||
return this.emit({ | ||
type: 'noderemoved', | ||
data: node | ||
}); | ||
case 11: | ||
return _context3.abrupt("return", true); | ||
case 12: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
}, _callee3, this); | ||
})); | ||
function removeNode(_x3) { | ||
return _removeNode.apply(this, arguments); | ||
} | ||
return removeNode; | ||
}() | ||
}, { | ||
key: "removeConnection", | ||
value: function () { | ||
var _removeConnection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id) { | ||
var index, connection; | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) switch (_context4.prev = _context4.next) { | ||
case 0: | ||
index = this.connections.findIndex(function (n) { | ||
return n.id === id; | ||
}); | ||
connection = this.connections[index]; | ||
if (!(index < 0)) { | ||
_context4.next = 4; | ||
break; | ||
} | ||
throw new Error('cannot find connection'); | ||
case 4: | ||
_context4.next = 6; | ||
return this.emit({ | ||
type: 'connectionremove', | ||
data: connection | ||
}); | ||
case 6: | ||
if (_context4.sent) { | ||
_context4.next = 8; | ||
break; | ||
} | ||
return _context4.abrupt("return", false); | ||
case 8: | ||
this.connections.splice(index, 1); | ||
_context4.next = 11; | ||
return this.emit({ | ||
type: 'connectionremoved', | ||
data: connection | ||
}); | ||
case 11: | ||
return _context4.abrupt("return", true); | ||
case 12: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
}, _callee4, this); | ||
})); | ||
function removeConnection(_x4) { | ||
return _removeConnection.apply(this, arguments); | ||
} | ||
return removeConnection; | ||
}() | ||
}, { | ||
key: "clear", | ||
value: function () { | ||
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() { | ||
var _iterator, _step, connection, _iterator2, _step2, node; | ||
return _regeneratorRuntime().wrap(function _callee5$(_context5) { | ||
while (1) switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context5.next = 2; | ||
return this.emit({ | ||
type: 'clear' | ||
}); | ||
case 2: | ||
if (_context5.sent) { | ||
_context5.next = 6; | ||
break; | ||
} | ||
_context5.next = 5; | ||
return this.emit({ | ||
type: 'clearcancelled' | ||
}); | ||
case 5: | ||
return _context5.abrupt("return", false); | ||
case 6: | ||
_iterator = _createForOfIteratorHelper(this.connections.slice()); | ||
_context5.prev = 7; | ||
_iterator.s(); | ||
case 9: | ||
if ((_step = _iterator.n()).done) { | ||
_context5.next = 15; | ||
break; | ||
} | ||
connection = _step.value; | ||
_context5.next = 13; | ||
return this.removeConnection(connection.id); | ||
case 13: | ||
_context5.next = 9; | ||
break; | ||
case 15: | ||
_context5.next = 20; | ||
break; | ||
case 17: | ||
_context5.prev = 17; | ||
_context5.t0 = _context5["catch"](7); | ||
_iterator.e(_context5.t0); | ||
case 20: | ||
_context5.prev = 20; | ||
_iterator.f(); | ||
return _context5.finish(20); | ||
case 23: | ||
_iterator2 = _createForOfIteratorHelper(this.nodes.slice()); | ||
_context5.prev = 24; | ||
_iterator2.s(); | ||
case 26: | ||
if ((_step2 = _iterator2.n()).done) { | ||
_context5.next = 32; | ||
break; | ||
} | ||
node = _step2.value; | ||
_context5.next = 30; | ||
return this.removeNode(node.id); | ||
case 30: | ||
_context5.next = 26; | ||
break; | ||
case 32: | ||
_context5.next = 37; | ||
break; | ||
case 34: | ||
_context5.prev = 34; | ||
_context5.t1 = _context5["catch"](24); | ||
_iterator2.e(_context5.t1); | ||
case 37: | ||
_context5.prev = 37; | ||
_iterator2.f(); | ||
return _context5.finish(37); | ||
case 40: | ||
_context5.next = 42; | ||
return this.emit({ | ||
type: 'cleared' | ||
}); | ||
case 42: | ||
return _context5.abrupt("return", true); | ||
case 43: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
}, _callee5, this, [[7, 17, 20, 23], [24, 34, 37, 40]]); | ||
})); | ||
function clear() { | ||
return _clear.apply(this, arguments); | ||
} | ||
return clear; | ||
}() | ||
}, { | ||
key: "import", | ||
value: function () { | ||
var _import2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data) { | ||
var _iterator3, _step3, node, _iterator4, _step4, connection; | ||
return _regeneratorRuntime().wrap(function _callee6$(_context6) { | ||
while (1) switch (_context6.prev = _context6.next) { | ||
case 0: | ||
_context6.next = 2; | ||
return this.emit({ | ||
type: 'import', | ||
data: data | ||
}); | ||
case 2: | ||
if (_context6.sent) { | ||
_context6.next = 4; | ||
break; | ||
} | ||
return _context6.abrupt("return", false); | ||
case 4: | ||
_iterator3 = _createForOfIteratorHelper(data.nodes); | ||
_context6.prev = 5; | ||
_iterator3.s(); | ||
case 7: | ||
if ((_step3 = _iterator3.n()).done) { | ||
_context6.next = 13; | ||
break; | ||
} | ||
node = _step3.value; | ||
_context6.next = 11; | ||
return this.addNode(node); | ||
case 11: | ||
_context6.next = 7; | ||
break; | ||
case 13: | ||
_context6.next = 18; | ||
break; | ||
case 15: | ||
_context6.prev = 15; | ||
_context6.t0 = _context6["catch"](5); | ||
_iterator3.e(_context6.t0); | ||
case 18: | ||
_context6.prev = 18; | ||
_iterator3.f(); | ||
return _context6.finish(18); | ||
case 21: | ||
_iterator4 = _createForOfIteratorHelper(data.connections); | ||
_context6.prev = 22; | ||
_iterator4.s(); | ||
case 24: | ||
if ((_step4 = _iterator4.n()).done) { | ||
_context6.next = 30; | ||
break; | ||
} | ||
connection = _step4.value; | ||
_context6.next = 28; | ||
return this.addConnection(connection); | ||
case 28: | ||
_context6.next = 24; | ||
break; | ||
case 30: | ||
_context6.next = 35; | ||
break; | ||
case 32: | ||
_context6.prev = 32; | ||
_context6.t1 = _context6["catch"](22); | ||
_iterator4.e(_context6.t1); | ||
case 35: | ||
_context6.prev = 35; | ||
_iterator4.f(); | ||
return _context6.finish(35); | ||
case 38: | ||
_context6.next = 40; | ||
return this.emit({ | ||
type: 'imported', | ||
data: data | ||
}); | ||
case 40: | ||
return _context6.abrupt("return", true); | ||
case 41: | ||
case "end": | ||
return _context6.stop(); | ||
} | ||
}, _callee6, this, [[5, 15, 18, 21], [22, 32, 35, 38]]); | ||
})); | ||
function _import(_x5) { | ||
return _import2.apply(this, arguments); | ||
} | ||
return _import; | ||
}() | ||
}, { | ||
key: "export", | ||
value: function () { | ||
var _export2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() { | ||
var _data$nodes, _data$connections; | ||
var data; | ||
return _regeneratorRuntime().wrap(function _callee7$(_context7) { | ||
while (1) switch (_context7.prev = _context7.next) { | ||
case 0: | ||
data = { | ||
nodes: [], | ||
connections: [] | ||
}; | ||
_context7.next = 3; | ||
return this.emit({ | ||
type: 'export', | ||
data: data | ||
}); | ||
case 3: | ||
if (_context7.sent) { | ||
_context7.next = 5; | ||
break; | ||
} | ||
return _context7.abrupt("return", false); | ||
case 5: | ||
(_data$nodes = data.nodes).push.apply(_data$nodes, _toConsumableArray(this.nodes)); | ||
(_data$connections = data.connections).push.apply(_data$connections, _toConsumableArray(this.connections)); | ||
_context7.next = 9; | ||
return this.emit({ | ||
type: 'exported', | ||
data: data | ||
}); | ||
case 9: | ||
return _context7.abrupt("return", data); | ||
case 10: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
}, _callee7, this); | ||
})); | ||
function _export() { | ||
return _export2.apply(this, arguments); | ||
} | ||
return _export; | ||
}() | ||
}]); | ||
return NodeEditor; | ||
}(Scope); | ||
for (const connection of this.connections.slice()) await this.removeConnection(connection.id); | ||
for (const node of this.nodes.slice()) await this.removeNode(node.id); | ||
await this.emit({ | ||
type: 'cleared' | ||
}); | ||
return true; | ||
} | ||
async import(data) { | ||
if (!(await this.emit({ | ||
type: 'import', | ||
data | ||
}))) return false; | ||
for (const node of data.nodes) await this.addNode(node); | ||
for (const connection of data.connections) await this.addConnection(connection); | ||
await this.emit({ | ||
type: 'imported', | ||
data | ||
}); | ||
return true; | ||
} | ||
async export() { | ||
const data = { | ||
nodes: [], | ||
connections: [] | ||
}; | ||
if (!(await this.emit({ | ||
type: 'export', | ||
data | ||
}))) return false; | ||
data.nodes.push(...this.nodes); | ||
data.connections.push(...this.connections); | ||
await this.emit({ | ||
type: 'exported', | ||
data | ||
}); | ||
return data; | ||
} | ||
} | ||
/* global globalThis*/ | ||
var crypto = globalThis.crypto; | ||
const crypto = globalThis.crypto; | ||
function getUID() { | ||
@@ -1108,89 +214,61 @@ if ('randomBytes' in crypto) { | ||
} | ||
var bytes = crypto.getRandomValues(new Uint8Array(8)); | ||
var array = Array.from(bytes); | ||
var hexPairs = array.map(function (b) { | ||
return b.toString(16).padStart(2, '0'); | ||
}); | ||
const bytes = crypto.getRandomValues(new Uint8Array(8)); | ||
const array = Array.from(bytes); | ||
const hexPairs = array.map(b => b.toString(16).padStart(2, '0')); | ||
return hexPairs.join(''); | ||
} | ||
var Socket = /*#__PURE__*/_createClass(function Socket(name) { | ||
_classCallCheck(this, Socket); | ||
this.name = name; | ||
}); | ||
var Port = /*#__PURE__*/_createClass(function Port(socket, label, multipleConnections) { | ||
_classCallCheck(this, Port); | ||
this.socket = socket; | ||
this.label = label; | ||
this.multipleConnections = multipleConnections; | ||
this.id = getUID(); | ||
}); | ||
var Input = /*#__PURE__*/function (_Port) { | ||
_inherits(Input, _Port); | ||
var _super = _createSuper(Input); | ||
function Input() { | ||
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)); | ||
_defineProperty(_assertThisInitialized(_this), "control", null); | ||
_defineProperty(_assertThisInitialized(_this), "showControl", true); | ||
return _this; | ||
class Socket { | ||
constructor(name) { | ||
this.name = name; | ||
} | ||
_createClass(Input, [{ | ||
key: "addControl", | ||
value: function addControl(control) { | ||
if (this.control) throw new Error('control already added for this input'); | ||
this.control = control; | ||
} | ||
}, { | ||
key: "removeControl", | ||
value: function removeControl() { | ||
this.control = null; | ||
} | ||
}]); | ||
return Input; | ||
}(Port); | ||
var Output = /*#__PURE__*/function (_Port2) { | ||
_inherits(Output, _Port2); | ||
var _super2 = _createSuper(Output); | ||
function Output(socket, label, multipleConnections) { | ||
_classCallCheck(this, Output); | ||
return _super2.call(this, socket, label, multipleConnections !== false); | ||
} | ||
class Port { | ||
constructor(socket, label, multipleConnections) { | ||
this.socket = socket; | ||
this.label = label; | ||
this.multipleConnections = multipleConnections; | ||
this.id = getUID(); | ||
} | ||
return _createClass(Output); | ||
}(Port); | ||
var Control = /*#__PURE__*/_createClass(function Control() { | ||
_classCallCheck(this, Control); | ||
this.id = getUID(); | ||
}); | ||
var InputControl = /*#__PURE__*/function (_Control) { | ||
_inherits(InputControl, _Control); | ||
var _super3 = _createSuper(InputControl); | ||
function InputControl(type, options) { | ||
var _this2; | ||
_classCallCheck(this, InputControl); | ||
_this2 = _super3.call(this); | ||
_this2.type = type; | ||
_this2.options = options; | ||
_this2.id = getUID(); | ||
_this2.readonly = options === null || options === void 0 ? void 0 : options.readonly; | ||
if (typeof (options === null || options === void 0 ? void 0 : options.initial) !== 'undefined') _this2.value = options.initial; | ||
return _this2; | ||
} | ||
class Input extends Port { | ||
constructor() { | ||
super(...arguments); | ||
_defineProperty(this, "control", null); | ||
_defineProperty(this, "showControl", true); | ||
} | ||
_createClass(InputControl, [{ | ||
key: "setValue", | ||
value: function setValue(value) { | ||
var _this$options; | ||
this.value = value; | ||
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.change) this.options.change(value); | ||
} | ||
}]); | ||
return InputControl; | ||
}(Control); | ||
var Node = /*#__PURE__*/function () { | ||
function Node(label) { | ||
_classCallCheck(this, Node); | ||
addControl(control) { | ||
if (this.control) throw new Error('control already added for this input'); | ||
this.control = control; | ||
} | ||
removeControl() { | ||
this.control = null; | ||
} | ||
} | ||
class Output extends Port { | ||
constructor(socket, label, multipleConnections) { | ||
super(socket, label, multipleConnections !== false); | ||
} | ||
} | ||
class Control { | ||
constructor() { | ||
this.id = getUID(); | ||
} | ||
} | ||
class InputControl extends Control { | ||
constructor(type, options) { | ||
super(); | ||
this.type = type; | ||
this.options = options; | ||
this.id = getUID(); | ||
this.readonly = options?.readonly; | ||
if (typeof options?.initial !== 'undefined') this.value = options.initial; | ||
} | ||
setValue(value) { | ||
this.value = value; | ||
if (this.options?.change) this.options.change(value); | ||
} | ||
} | ||
class Node { | ||
constructor(label) { | ||
_defineProperty(this, "inputs", {}); | ||
@@ -1202,79 +280,60 @@ _defineProperty(this, "outputs", {}); | ||
} | ||
_createClass(Node, [{ | ||
key: "hasInput", | ||
value: function hasInput(key) { | ||
return Object.prototype.hasOwnProperty.call(this.inputs, key); | ||
hasInput(key) { | ||
return Object.prototype.hasOwnProperty.call(this.inputs, key); | ||
} | ||
addInput(key, input) { | ||
if (this.hasInput(key)) throw new Error(`input with key '${String(key)}' already added`); | ||
Object.defineProperty(this.inputs, key, { | ||
value: input, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
removeInput(key) { | ||
delete this.inputs[key]; | ||
} | ||
hasOutput(key) { | ||
return Object.prototype.hasOwnProperty.call(this.outputs, key); | ||
} | ||
addOutput(key, output) { | ||
if (this.hasOutput(key)) throw new Error(`output with key '${String(key)}' already added`); | ||
Object.defineProperty(this.outputs, key, { | ||
value: output, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
removeOutput(key) { | ||
delete this.outputs[key]; | ||
} | ||
hasControl(key) { | ||
return Object.prototype.hasOwnProperty.call(this.controls, key); | ||
} | ||
addControl(key, control) { | ||
if (this.hasControl(key)) throw new Error(`control with key '${String(key)}' already added`); | ||
Object.defineProperty(this.controls, key, { | ||
value: control, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
removeControl(key) { | ||
delete this.controls[key]; | ||
} | ||
} | ||
class Connection { | ||
constructor(source, sourceOutput, target, targetInput) { | ||
this.sourceOutput = sourceOutput; | ||
this.targetInput = targetInput; | ||
if (!source.outputs[sourceOutput]) { | ||
throw new Error(`source node doesn't have output with a key ${String(sourceOutput)}`); | ||
} | ||
}, { | ||
key: "addInput", | ||
value: function addInput(key, input) { | ||
if (this.hasInput(key)) throw new Error("input with key '".concat(String(key), "' already added")); | ||
Object.defineProperty(this.inputs, key, { | ||
value: input, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
if (!target.inputs[targetInput]) { | ||
throw new Error(`target node doesn't have input with a key ${String(targetInput)}`); | ||
} | ||
}, { | ||
key: "removeInput", | ||
value: function removeInput(key) { | ||
delete this.inputs[key]; | ||
} | ||
}, { | ||
key: "hasOutput", | ||
value: function hasOutput(key) { | ||
return Object.prototype.hasOwnProperty.call(this.outputs, key); | ||
} | ||
}, { | ||
key: "addOutput", | ||
value: function addOutput(key, output) { | ||
if (this.hasOutput(key)) throw new Error("output with key '".concat(String(key), "' already added")); | ||
Object.defineProperty(this.outputs, key, { | ||
value: output, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
}, { | ||
key: "removeOutput", | ||
value: function removeOutput(key) { | ||
delete this.outputs[key]; | ||
} | ||
}, { | ||
key: "hasControl", | ||
value: function hasControl(key) { | ||
return Object.prototype.hasOwnProperty.call(this.controls, key); | ||
} | ||
}, { | ||
key: "addControl", | ||
value: function addControl(key, control) { | ||
if (this.hasControl(key)) throw new Error("control with key '".concat(String(key), "' already added")); | ||
Object.defineProperty(this.controls, key, { | ||
value: control, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
} | ||
}, { | ||
key: "removeControl", | ||
value: function removeControl(key) { | ||
delete this.controls[key]; | ||
} | ||
}]); | ||
return Node; | ||
}(); | ||
var Connection = /*#__PURE__*/_createClass(function Connection(source, sourceOutput, target, targetInput) { | ||
_classCallCheck(this, Connection); | ||
this.sourceOutput = sourceOutput; | ||
this.targetInput = targetInput; | ||
if (!source.outputs[sourceOutput]) { | ||
throw new Error("source node doesn't have output with a key ".concat(String(sourceOutput))); | ||
this.id = getUID(); | ||
this.source = source.id; | ||
this.target = target.id; | ||
} | ||
if (!target.inputs[targetInput]) { | ||
throw new Error("target node doesn't have input with a key ".concat(String(targetInput))); | ||
} | ||
this.id = getUID(); | ||
this.source = source.id; | ||
this.target = target.id; | ||
}); | ||
} | ||
@@ -1281,0 +340,0 @@ var classic = /*#__PURE__*/Object.freeze({ |
/*! | ||
* rete v2.0.0-beta.2 | ||
* rete v2.0.0-beta.3 | ||
* (c) 2023 Vitaliy Stoliarov | ||
* Released under the MIT license. | ||
* */ | ||
!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,b(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=b(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){return function(t){if(Array.isArray(t))return y(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||d(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,e){if(t){if("string"==typeof t)return y(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)?y(t,e):void 0}}function y(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 v(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=d(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 b(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 m=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=v(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}(),w=function(){function t(e){o(this,t),u(this,"signal",new m),this.name=e}return a(t,[{key:"addPipe",value:function(t){this.signal.addPipe(t)}},{key:"use",value:function(t){t.setParent(this),this.addPipe((function(e){return t.signal.emit(e)}))}},{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}(),g=function(t){c(w,t);var n,i,s,f,d,y,b,m=h(w);function w(){var t;return o(this,w),u(l(t=m.call(this,"NodeEditor")),"nodes",[]),u(l(t),"connections",[]),t}return a(w,[{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:(b=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 b.apply(this,arguments)})},{key:"addConnection",value:(y=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 y.apply(this,arguments)})},{key:"removeNode",value:(d=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 d.apply(this,arguments)})},{key:"removeConnection",value:(f=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 f.apply(this,arguments)})},{key:"clear",value:(s=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=v(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=v(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 s.apply(this,arguments)})},{key:"import",value:(i=r(e().mark((function t(n){var r,o,i,a,u,c;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.emit({type:"import",data:n});case 2:if(t.sent){t.next=4;break}return t.abrupt("return",!1);case 4:r=v(n.nodes),t.prev=5,r.s();case 7:if((o=r.n()).done){t.next=13;break}return i=o.value,t.next=11,this.addNode(i);case 11:t.next=7;break;case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(5),r.e(t.t0);case 18:return t.prev=18,r.f(),t.finish(18);case 21:a=v(n.connections),t.prev=22,a.s();case 24:if((u=a.n()).done){t.next=30;break}return c=u.value,t.next=28,this.addConnection(c);case 28:t.next=24;break;case 30:t.next=35;break;case 32:t.prev=32,t.t1=t.catch(22),a.e(t.t1);case 35:return t.prev=35,a.f(),t.finish(35);case 38:return t.next=40,this.emit({type:"imported",data:n});case 40:return t.abrupt("return",!0);case 41:case"end":return t.stop()}}),t,this,[[5,15,18,21],[22,32,35,38]])}))),function(t){return i.apply(this,arguments)})},{key:"export",value:(n=r(e().mark((function t(){var n,r,o;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o={nodes:[],connections:[]},t.next=3,this.emit({type:"export",data:o});case 3:if(t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return(n=o.nodes).push.apply(n,p(this.nodes)),(r=o.connections).push.apply(r,p(this.connections)),t.next=9,this.emit({type:"exported",data:o});case 9:return t.abrupt("return",o);case 10:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})}]),w}(w),x=globalThis.crypto;function k(){if("randomBytes"in x)return x.randomBytes(8).toString("hex");var t=x.getRandomValues(new Uint8Array(8));return Array.from(t).map((function(t){return t.toString(16).padStart(2,"0")})).join("")}var O=a((function t(e){o(this,t),this.name=e})),E=a((function t(e,n,r){o(this,t),this.socket=e,this.label=n,this.multipleConnections=r,this.id=k()})),j=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}(E),P=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)}(E),S=a((function t(){o(this,t),this.id=k()})),_=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=k(),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}(S),L=function(){function t(e){o(this,t),u(this,"inputs",{}),u(this,"outputs",{}),u(this,"controls",{}),this.label=e,this.id=k()}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}(),C=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=k(),this.source=e.id,this.target=r.id})),N=Object.freeze({__proto__:null,Socket:O,Port:E,Input:j,Output:P,Control:S,InputControl:_,Node:L,Connection:C});t.ClassicPreset=N,t.NodeEditor=g,t.Scope=w,t.Signal=m,t.getUID=k,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(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}class n{constructor(){e(this,"pipes",[])}addPipe(t){this.pipes.push(t)}async emit(t){let e=t;for(const t of this.pipes)if(e=await t(e),void 0===e)return;return e}}class i{constructor(t){e(this,"signal",new n),this.name=t}addPipe(t){this.signal.addPipe(t)}use(t){t.setParent(this),this.addPipe((e=>t.signal.emit(e)))}setParent(t){this.parent=t}emit(t){return this.signal.emit(t)}hasParent(){return Boolean(this.parent)}parentScope(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}}const o=globalThis.crypto;function r(){if("randomBytes"in o)return o.randomBytes(8).toString("hex");const t=o.getRandomValues(new Uint8Array(8));return Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("")}class s{constructor(t,e,n){this.socket=t,this.label=e,this.multipleConnections=n,this.id=r()}}class a{constructor(){this.id=r()}}var c=Object.freeze({__proto__:null,Socket:class{constructor(t){this.name=t}},Port:s,Input:class extends s{constructor(){super(...arguments),e(this,"control",null),e(this,"showControl",!0)}addControl(t){if(this.control)throw new Error("control already added for this input");this.control=t}removeControl(){this.control=null}},Output:class extends s{constructor(t,e,n){super(t,e,!1!==n)}},Control:a,InputControl:class extends a{constructor(t,e){super(),this.type=t,this.options=e,this.id=r(),this.readonly=e?.readonly,void 0!==e?.initial&&(this.value=e.initial)}setValue(t){this.value=t,this.options?.change&&this.options.change(t)}},Node:class{constructor(t){e(this,"inputs",{}),e(this,"outputs",{}),e(this,"controls",{}),this.label=t,this.id=r()}hasInput(t){return Object.prototype.hasOwnProperty.call(this.inputs,t)}addInput(t,e){if(this.hasInput(t))throw new Error(`input with key '${String(t)}' already added`);Object.defineProperty(this.inputs,t,{value:e,enumerable:!0,configurable:!0})}removeInput(t){delete this.inputs[t]}hasOutput(t){return Object.prototype.hasOwnProperty.call(this.outputs,t)}addOutput(t,e){if(this.hasOutput(t))throw new Error(`output with key '${String(t)}' already added`);Object.defineProperty(this.outputs,t,{value:e,enumerable:!0,configurable:!0})}removeOutput(t){delete this.outputs[t]}hasControl(t){return Object.prototype.hasOwnProperty.call(this.controls,t)}addControl(t,e){if(this.hasControl(t))throw new Error(`control with key '${String(t)}' already added`);Object.defineProperty(this.controls,t,{value:e,enumerable:!0,configurable:!0})}removeControl(t){delete this.controls[t]}},Connection:class{constructor(t,e,n,i){if(this.sourceOutput=e,this.targetInput=i,!t.outputs[e])throw new Error(`source node doesn't have output with a key ${String(e)}`);if(!n.inputs[i])throw new Error(`target node doesn't have input with a key ${String(i)}`);this.id=r(),this.source=t.id,this.target=n.id}}});t.ClassicPreset=c,t.NodeEditor=class extends i{constructor(){super("NodeEditor"),e(this,"nodes",[]),e(this,"connections",[])}getNode(t){return this.nodes.find((e=>e.id===t))}getNodes(){return this.nodes}getConnections(){return this.connections}getConnection(t){return this.connections.find((e=>e.id===t))}async addNode(t){if(this.getNode(t.id))throw new Error("node has already been added");return!!await this.emit({type:"nodecreate",data:t})&&(this.nodes.push(t),await this.emit({type:"nodecreated",data:t}),!0)}async addConnection(t){if(this.getConnection(t.id))throw new Error("connection has already been added");return!!await this.emit({type:"connectioncreate",data:t})&&(this.connections.push(t),await this.emit({type:"connectioncreated",data:t}),!0)}async removeNode(t){const e=this.nodes.findIndex((e=>e.id===t)),n=this.nodes[e];if(e<0)throw new Error("cannot find node");return!!await this.emit({type:"noderemove",data:n})&&(this.nodes.splice(e,1),await this.emit({type:"noderemoved",data:n}),!0)}async removeConnection(t){const e=this.connections.findIndex((e=>e.id===t)),n=this.connections[e];if(e<0)throw new Error("cannot find connection");return!!await this.emit({type:"connectionremove",data:n})&&(this.connections.splice(e,1),await this.emit({type:"connectionremoved",data:n}),!0)}async clear(){if(!await this.emit({type:"clear"}))return await this.emit({type:"clearcancelled"}),!1;for(const t of this.connections.slice())await this.removeConnection(t.id);for(const t of this.nodes.slice())await this.removeNode(t.id);return await this.emit({type:"cleared"}),!0}async import(t){if(!await this.emit({type:"import",data:t}))return!1;for(const e of t.nodes)await this.addNode(e);for(const e of t.connections)await this.addConnection(e);return await this.emit({type:"imported",data:t}),!0}async export(){const t={nodes:[],connections:[]};return!!await this.emit({type:"export",data:t})&&(t.nodes.push(...this.nodes),t.connections.push(...this.connections),await this.emit({type:"exported",data:t}),t)}},t.Scope=i,t.Signal=n,t.getUID=r,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
55
107816
952
1