@nodl/core
Advanced tools
Comparing version 0.1.2 to 0.1.3
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Connection = void 0; | ||
const mobx_1 = require("mobx"); | ||
const rxjs_1 = require("rxjs"); | ||
@@ -22,2 +23,9 @@ const uuid_1 = require("uuid"); | ||
this.to.connection = this; | ||
(0, mobx_1.makeObservable)(this, { | ||
id: mobx_1.observable, | ||
from: mobx_1.observable, | ||
to: mobx_1.observable, | ||
subscription: mobx_1.observable, | ||
dispose: mobx_1.action | ||
}); | ||
} | ||
@@ -29,3 +37,3 @@ /** Disposes the Connection */ | ||
this.from.connections = this.from.connections.filter(connection => connection !== this); | ||
this.to.connection = undefined; | ||
this.to.connection = null; | ||
this.to.next(this.to.defaultValue); | ||
@@ -32,0 +40,0 @@ } |
@@ -15,3 +15,3 @@ import { BehaviorSubject } from 'rxjs'; | ||
/** Associated Connection */ | ||
connection: Connection<TValue> | undefined; | ||
connection: Connection<TValue> | null; | ||
constructor(props: IInputProps<TValue>); | ||
@@ -18,0 +18,0 @@ /** Determines if input is connected */ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Input = void 0; | ||
const mobx_1 = require("mobx"); | ||
const rxjs_1 = require("rxjs"); | ||
@@ -14,2 +15,12 @@ const uuid_1 = require("uuid"); | ||
this.defaultValue = props.defaultValue; | ||
this.connection = null; | ||
(0, mobx_1.makeObservable)(this, { | ||
id: mobx_1.observable, | ||
name: mobx_1.observable, | ||
type: mobx_1.observable, | ||
defaultValue: mobx_1.observable, | ||
connection: mobx_1.observable, | ||
connected: mobx_1.computed, | ||
dispose: mobx_1.action | ||
}); | ||
} | ||
@@ -24,3 +35,3 @@ /** Determines if input is connected */ | ||
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.dispose(); | ||
this.connection = undefined; | ||
this.connection = null; | ||
this.unsubscribe(); | ||
@@ -27,0 +38,0 @@ } |
@@ -0,4 +1,6 @@ | ||
import { Connection } from '../Connection/Connection'; | ||
import { Input } from '../Input/Input'; | ||
import { Output } from '../Output/Output'; | ||
export declare abstract class Node { | ||
import { NodeData } from './Node.types'; | ||
export declare abstract class Node<TData extends NodeData = NodeData> { | ||
/** Identifier */ | ||
@@ -13,5 +15,8 @@ id: string; | ||
/** Arbitrary Data Store */ | ||
data: Record<string, unknown>; | ||
data: TData; | ||
constructor(); | ||
/** Associated connections */ | ||
get connections(): Connection<unknown>[]; | ||
/** Disposes the Node */ | ||
dispose(): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Node = void 0; | ||
const mobx_1 = require("mobx"); | ||
const uuid_1 = require("uuid"); | ||
@@ -17,3 +18,18 @@ class Node { | ||
this.data = {}; | ||
(0, mobx_1.makeObservable)(this, { | ||
id: mobx_1.observable, | ||
name: mobx_1.observable, | ||
inputs: mobx_1.observable, | ||
outputs: mobx_1.observable, | ||
data: mobx_1.observable, | ||
connections: mobx_1.computed, | ||
dispose: mobx_1.action | ||
}); | ||
} | ||
/** Associated connections */ | ||
get connections() { | ||
return [...Object.values(this.inputs), ...Object.values(this.outputs)] | ||
.flatMap(port => ('connection' in port ? [port.connection] : port.connections)) | ||
.filter((connection) => Boolean(connection)); | ||
} | ||
/** Disposes the Node */ | ||
@@ -20,0 +36,0 @@ dispose() { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Output = void 0; | ||
const mobx_1 = require("mobx"); | ||
const rxjs_1 = require("rxjs"); | ||
@@ -17,2 +18,13 @@ const uuid_1 = require("uuid"); | ||
this.connections = []; | ||
(0, mobx_1.makeObservable)(this, { | ||
id: mobx_1.observable, | ||
name: mobx_1.observable, | ||
type: mobx_1.observable, | ||
observable: mobx_1.observable, | ||
subscription: mobx_1.observable, | ||
connections: mobx_1.observable, | ||
connected: mobx_1.computed, | ||
connect: mobx_1.action, | ||
dispose: mobx_1.action | ||
}); | ||
} | ||
@@ -19,0 +31,0 @@ /** Determines if output is connected */ |
{ | ||
"name": "@nodl/core", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Core implementation of the Nodl framework", | ||
@@ -26,2 +26,3 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"mobx": "^6.8.0", | ||
"rxjs": "^7.8.0", | ||
@@ -28,0 +29,0 @@ "typescript": "^4.9.4", |
@@ -20,2 +20,17 @@ # @nodl/core | ||
#### Additional dependencies | ||
Make sure to also install the following packages: | ||
``` | ||
# Using NPM | ||
npm install rxjs zod | ||
# Using Yarn | ||
yarn add rxjs zod | ||
# Using Bun | ||
bun install rxjs zod | ||
``` | ||
### API | ||
@@ -25,3 +40,3 @@ | ||
Nodes are units that consists of inputs and outputs. They're conceptually very similar to functions, with the difference that outputs may be multiple, compared to a function's single return value. | ||
Nodes are units that consists of inputs and outputs. They're conceptually very similar to functions, with the difference that outputs may be multiple, compared to a function's single return value. | ||
@@ -28,0 +43,0 @@ An Addition Node may for instance have two inputs and a single output, which computes the sum of the inputs. |
16054
21
342
111
5
+ Addedmobx@^6.8.0
+ Addedmobx@6.13.6(transitive)