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

behave-graph

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

behave-graph - npm Package Compare versions

Comparing version 0.9.3 to 0.9.5

dist/graphs/core/logic/Math.json

17

dist/examples/exec-graph/index.js

@@ -10,5 +10,4 @@ import { promises as fs } from 'node:fs';

import { validateGraph } from '../../lib/Graphs/Validation/validateGraph.js';
import { DefaultLogger, ManualLifecycleEventEmitter } from '../../lib/index.js';
import { parseSafeFloat } from '../../lib/parseFloats.js';
import { DefaultLogger } from '../../lib/Profiles/Core/Abstractions/Drivers/DefaultLogger.js';
import { ManualLifecycleEventEmitter } from '../../lib/Profiles/Core/Abstractions/Drivers/ManualLifecycleEventEmitter.js';
import { registerCoreProfile } from '../../lib/Profiles/Core/registerCoreProfile.js';

@@ -31,8 +30,6 @@ import { registerSceneProfile } from '../../lib/Profiles/Scene/registerSceneProfile.js';

const registry = new Registry();
registerCoreProfile(registry);
registerSceneProfile(registry);
registry.abstractions.register('ILogger', new DefaultLogger());
const manualLifecycleEventEmitter = new ManualLifecycleEventEmitter();
registry.abstractions.register('ILifecycleEventEmitter', manualLifecycleEventEmitter);
registry.abstractions.register('IScene', new DummyScene(registry));
const logger = new DefaultLogger();
registerCoreProfile(registry, logger, manualLifecycleEventEmitter);
registerSceneProfile(registry, new DummyScene(registry));
const jsonPattern = program.args[0];

@@ -77,5 +74,5 @@ glob(jsonPattern, {}, async (err, matches) => {

if (manualLifecycleEventEmitter.tickEvent.listenerCount > 0) {
const iteations = parseSafeFloat(programOptions.iterations, 5);
for (let tick = 0; tick < iteations; tick++) {
Logger.verbose(`triggering tick (${tick} of ${iteations})`);
const iterations = parseSafeFloat(programOptions.iterations, 5);
for (let tick = 0; tick < iterations; tick++) {
Logger.verbose(`triggering tick (${tick} of ${iterations})`);
manualLifecycleEventEmitter.tickEvent.emit();

@@ -82,0 +79,0 @@ Logger.verbose('executing all (async)');

@@ -10,2 +10,3 @@ import { promises as fs } from 'node:fs';

import { Registry } from '../../lib/Registry.js';
import { DummyScene } from '../exec-graph/DummyScene.js';
async function main() {

@@ -24,3 +25,3 @@ program

registerCoreProfile(registry);
registerSceneProfile(registry);
registerSceneProfile(registry, new DummyScene(registry));
const errorList = [];

@@ -27,0 +28,0 @@ errorList.push(...validateNodeRegistry(registry));

@@ -32,6 +32,20 @@ import * as THREE from 'three';

}
async function loadThreeScene() {
const gltfPromise = new GLTFLoader()
.setPath('/src/graphs/scene/actions/')
.loadAsync('SpinningSuzanne.gltf');
const gltf = await gltfPromise;
const glTFJsonPath = '/src/graphs/scene/actions/SpinningSuzanne.gltf';
const glTFFetchResponse = await fetch(glTFJsonPath);
const glTFJson = await glTFFetchResponse.json();
const threeScene = new ThreeScene(gltf.scene, glTFJson);
return { threeScene, gltf };
}
async function main() {
const registry = new Registry();
registerCoreProfile(registry);
registerSceneProfile(registry);
const manualLifecycleEventEmitter = new ManualLifecycleEventEmitter();
const logger = new DefaultLogger();
const { threeScene, gltf } = await loadThreeScene();
registerCoreProfile(registry, logger, manualLifecycleEventEmitter);
registerSceneProfile(registry, threeScene);
const graphJsonPath = `/src/graphs/scene/actions/SpinningSuzanne.json`;

@@ -46,5 +60,2 @@ if (graphJsonPath === undefined) {

graph.name = graphJsonPath;
const glTFJsonPath = '/src/graphs/scene/actions/SpinningSuzanne.gltf';
const glTFFetchResponse = await fetch(glTFJsonPath);
const glTFJson = await glTFFetchResponse.json();
const errorList = [];

@@ -68,5 +79,2 @@ errorList.push(...validateRegistry(registry), ...validateGraph(graph));

.loadAsync('pedestrian_overpass_1k.hdr');
const gltfPromise = new GLTFLoader()
.setPath('/src/graphs/scene/actions/')
.loadAsync('SpinningSuzanne.gltf');
const localRenderer = new THREE.WebGLRenderer({ antialias: true });

@@ -81,3 +89,2 @@ localRenderer.setPixelRatio(window.devicePixelRatio);

const texture = await texturePromise;
const gltf = await gltfPromise;
texture.mapping = THREE.EquirectangularReflectionMapping;

@@ -87,7 +94,5 @@ localScene.background = texture;

localScene.add(gltf.scene);
const threeScene = new ThreeScene(gltf.scene, glTFJson);
threeScene.onSceneChanged.addListener(() => {
render();
});
registry.abstractions.register('IScene', threeScene);
render();

@@ -103,5 +108,2 @@ const controls = new OrbitControls(camera, renderer.domElement);

const engine = new Engine(graph);
registry.abstractions.register('ILogger', new DefaultLogger());
const manualLifecycleEventEmitter = new ManualLifecycleEventEmitter();
registry.abstractions.register('ILifecycleEventEmitter', manualLifecycleEventEmitter);
Logger.verbose('initialize graph');

@@ -108,0 +110,0 @@ await engine.executeAllSync();

@@ -7,3 +7,3 @@ import { Object3D } from 'three';

glTFRoot: Object3D;
glTFJson: GLTFJson;
readonly glTFJson: GLTFJson;
private glTFNodeIndexToThreeNode;

@@ -10,0 +10,0 @@ private glTFMaterialIndexToThreeMaterial;

@@ -8,3 +8,2 @@ import * as THREEIFY from 'threeify';

import { registerCoreProfile } from '../../lib/Profiles/Core/registerCoreProfile.js';
import { registerSceneProfile } from '../../lib/Profiles/Scene/registerSceneProfile.js';
import { Registry } from '../../lib/Registry.js';

@@ -15,7 +14,5 @@ async function main() {

const registry = new Registry();
registerCoreProfile(registry);
registerSceneProfile(registry);
registry.abstractions.register('ILogger', new DefaultLogger());
const manualLifecycleEventEmitter = new ManualLifecycleEventEmitter();
registry.abstractions.register('ILifecycleEventEmitter', manualLifecycleEventEmitter);
const logger = new DefaultLogger();
registerCoreProfile(registry, logger, manualLifecycleEventEmitter);
const graphJsonPath = '/dist/graphs/core/HelloWorld.json';

@@ -22,0 +19,0 @@ if (graphJsonPath === undefined) {

import { Assert } from '../Diagnostics/Assert.js';
import { AsyncNode } from '../Nodes/AsyncNode.js';
import { EventNode } from '../Nodes/EventNode.js';
import { FlowNode } from '../Nodes/FlowNode.js';

@@ -42,7 +43,9 @@ import { ImmediateNode } from '../Nodes/ImmediateNode.js';

}
if (upstreamNode instanceof FlowNode) {
if (upstreamNode instanceof FlowNode ||
upstreamNode instanceof EventNode ||
upstreamNode instanceof AsyncNode) {
inputSocket.value = upstreamOutputSocket.value;
return;
}
throw new TypeError('node must be an instance of ImmediateNode');
throw new TypeError(`node, ${upstreamNode.description.typeName}, must be an instance of ImmediateNode`);
}

@@ -112,3 +115,3 @@ commit(node, outputSocketName, fiberCompletedListener = undefined) {

}
throw new TypeError('should not get here');
throw new TypeError(`should not get here, unhandled node ${node.description.typeName}`);
}

@@ -115,0 +118,0 @@ isCompleted() {

import { EventEmitter } from '../../Events/EventEmitter.js';
import { AsyncFlowNode } from '../../Nodes/AsyncFlowNode.js';
import { EventFlowNode } from '../../Nodes/EventFlowNode.js';
import { Link } from '../../Nodes/Link.js';
import { Node } from '../../Nodes/Node.js';
import { Graph } from '../Graph.js';

@@ -10,10 +9,10 @@ import { NodeEvaluationEvent } from './NodeEvaluationEvent.js';

private readonly executionBlockQueue;
readonly asyncFlowNodes: AsyncFlowNode[];
readonly eventFlowNodes: EventFlowNode[];
readonly asyncNodes: Node[];
readonly interruptibleAsyncNodes: Node[];
readonly onNodeEvaluation: EventEmitter<NodeEvaluationEvent>;
constructor(graph: Graph);
asyncCommit(outputFlowSocket: Link, syncEvaluationCompletedListener: (() => void) | undefined): void;
executeAllSync(limitInSeconds?: number, limitInSteps?: number): number;
executeAllAsync(limitInSeconds?: number, limitInSteps?: number): Promise<number>;
executeAll(stepLimit?: number): number;
executeAllAsync(timeLimit?: number, stepLimit?: number): Promise<number>;
}
//# sourceMappingURL=GraphEvaluator.d.ts.map
import { EventEmitter } from '../../Events/EventEmitter.js';
import { EventFlowNode } from '../../Nodes/EventFlowNode.js';
import { Link } from '../../Nodes/Link.js';

@@ -10,7 +9,7 @@ import { sleep } from '../../sleep.js';

this.executionBlockQueue = [];
this.asyncFlowNodes = [];
this.eventFlowNodes = [];
this.asyncNodes = [];
this.interruptibleAsyncNodes = [];
this.onNodeEvaluation = new EventEmitter();
Object.values(this.graph.nodes).forEach((node) => {
if (node instanceof EventFlowNode) {
if (node.evaluateOnStartup) {
this.executionBlockQueue.push(new SyncExecutionBlock(this, new Link(node.id, '')));

@@ -22,9 +21,6 @@ }

const node = this.graph.nodes[outputFlowSocket.nodeId];
const outputSocket = node.outputSockets.find((socket) => socket.name === outputFlowSocket.socketName);
if (outputSocket === undefined) {
throw new Error(`no socket with the name ${outputFlowSocket.socketName}`);
}
const outputSocket = node.getOutputSocket(outputFlowSocket.socketName);
if (outputSocket.links.length > 1) {
throw new Error('invalid for an output flow socket to have multiple downstream links:' +
`${node.description.typeName}.${outputSocket.name} has ${outputSocket.links.length} downlinks`);
`${node.typeName}.${outputSocket.name} has ${outputSocket.links.length} downlinks`);
}

@@ -36,24 +32,16 @@ if (outputSocket.links.length === 1) {

}
executeAllSync(limitInSeconds = 100, limitInSteps = 100000000) {
const startDateTime = Date.now();
let elapsedSeconds = 0;
let elapsedSteps = 0;
while (elapsedSteps < limitInSteps &&
elapsedSeconds < limitInSeconds &&
this.executionBlockQueue.length > 0) {
executeAll(stepLimit = 100000000) {
let stepsExecuted = 0;
while (stepsExecuted < stepLimit && this.executionBlockQueue.length > 0) {
const currentExecutionBlock = this.executionBlockQueue[0];
const localExecutionSteps = currentExecutionBlock.executeStep();
if (localExecutionSteps < 0) {
if (!currentExecutionBlock.executeStep()) {
this.executionBlockQueue.shift();
}
elapsedSeconds = (Date.now() - startDateTime) * 0.001;
if (localExecutionSteps > 0) {
elapsedSteps += localExecutionSteps;
}
stepsExecuted++;
}
return elapsedSteps;
return stepsExecuted;
}
async executeAllAsync(limitInSeconds = 100, limitInSteps = 100000000) {
async executeAllAsync(timeLimit = 100, stepLimit = 100000000) {
const startDateTime = Date.now();
let elapsedSteps = 0;
let stepsExecuted = 0;
let elapsedTime = 0;

@@ -65,11 +53,11 @@ let iterations = 0;

}
elapsedSteps += this.executeAllSync(limitInSeconds - elapsedTime, limitInSteps - elapsedSteps);
stepsExecuted += this.executeAll(stepLimit);
elapsedTime = (Date.now() - startDateTime) * 0.001;
iterations += 1;
} while ((this.asyncFlowNodes.length > 0 || this.executionBlockQueue.length > 0) &&
elapsedTime < limitInSeconds &&
elapsedSteps < limitInSteps);
return elapsedSteps;
} while ((this.asyncNodes.length > 0 || this.executionBlockQueue.length > 0) &&
elapsedTime < timeLimit &&
stepsExecuted < stepLimit);
return stepsExecuted;
}
}
//# sourceMappingURL=GraphEvaluator.js.map

@@ -10,6 +10,6 @@ import { Link } from '../../Nodes/Link.js';

constructor(graphEvaluator: GraphEvaluator, nextEval: Link | null, syncEvaluationCompletedListener?: (() => void) | undefined);
resolveInputValueFromSocket(inputSocket: Socket): number;
resolveInputValueFromSocket(inputSocket: Socket): any;
commit(outputFlowSocket: Link, syncEvaluationCompletedListener?: (() => void) | undefined): void;
executeStep(): number;
executeStep(): boolean;
}
//# sourceMappingURL=SyncExecutionBlock.d.ts.map
import { Assert } from '../../Diagnostics/Assert.js';
import { FlowNode } from '../../Nodes/FlowNode.js';
import { ImmediateNode } from '../../Nodes/ImmediateNode.js';
import { Link } from '../../Nodes/Link.js';
import { NodeEvalContext } from '../../Nodes/NodeEvalContext.js';
import { NodeEvaluationEvent } from './NodeEvaluationEvent.js';
import { NodeEvaluationType } from './NodeEvaluationType.js';
export class SyncExecutionBlock {

@@ -19,29 +15,30 @@ constructor(graphEvaluator, nextEval, syncEvaluationCompletedListener = undefined) {

resolveInputValueFromSocket(inputSocket) {
if (inputSocket.valueTypeName === 'flow') {
throw new Error(`can not resolve input values for Eval input sockets: ${inputSocket.name}`);
}
if (inputSocket.links.length === 0) {
return 0;
if (inputSocket.value === undefined) {
return this.graph.registry.values
.get(inputSocket.valueTypeName)
.creator();
}
return inputSocket.value;
}
if (inputSocket.links.length > 1) {
throw new Error(`input socket has too many links: ${inputSocket.name} has ${inputSocket.links.length} links`);
}
const upstreamLink = inputSocket.links[0];
const upstreamNode = this.graph.nodes[upstreamLink.nodeId];
const upstreamOutputSocket = upstreamNode.outputSockets.find((socket) => socket.name === upstreamLink.socketName);
if (upstreamOutputSocket === undefined) {
throw new Error(`can not find socket with the name ${upstreamLink.socketName}`);
}
if (upstreamNode instanceof FlowNode) {
const upstreamOutputSocket = upstreamNode.getOutputSocket(upstreamLink.socketName);
if (upstreamNode.flow) {
inputSocket.value = upstreamOutputSocket.value;
return 0;
return upstreamOutputSocket.value;
}
if (!(upstreamNode instanceof ImmediateNode)) {
throw new TypeError('node must be an instance of ImmediateNode');
}
let executionStepCount = 0;
for (const upstreamInputSocket of upstreamNode.inputSockets) {
executionStepCount +=
this.resolveInputValueFromSocket(upstreamInputSocket);
}
this.graphEvaluator.onNodeEvaluation.emit(new NodeEvaluationEvent(upstreamNode, NodeEvaluationType.Immediate, false));
upstreamNode.evalFunc();
executionStepCount++;
this.graphEvaluator.onNodeEvaluation.emit(new NodeEvaluationEvent(upstreamNode, NodeEvaluationType.None, false));
upstreamNode.inputSockets.forEach((upstreamInputSocket) => {
this.resolveInputValueFromSocket(upstreamInputSocket);
});
const context = new NodeEvalContext(this, upstreamNode);
context.evalImmediate();
inputSocket.value = upstreamOutputSocket.value;
return executionStepCount;
return inputSocket.value;
}

@@ -51,9 +48,6 @@ commit(outputFlowSocket, syncEvaluationCompletedListener = undefined) {

const node = this.graph.nodes[outputFlowSocket.nodeId];
const outputSocket = node.outputSockets.find((socket) => socket.name === outputFlowSocket.socketName);
if (outputSocket === undefined) {
throw new Error(`can not find socket with the name ${outputFlowSocket.socketName}`);
}
const outputSocket = node.getOutputSocket(outputFlowSocket.socketName);
if (outputSocket.links.length > 1) {
throw new Error('invalid for an output flow socket to have multiple downstream links:' +
`${node.description.typeName}.${outputSocket.name} has ${outputSocket.links.length} downlinks`);
`${node.typeName}.${outputSocket.name} has ${outputSocket.links.length} downlinks`);
}

@@ -76,3 +70,3 @@ if (outputSocket.links.length === 1) {

if (this.syncEvaluationCompletedListenerStack.length === 0) {
return -1;
return false;
}

@@ -84,24 +78,15 @@ const awaitingCallback = this.syncEvaluationCompletedListenerStack.pop();

awaitingCallback();
return 0;
return true;
}
const node = this.graph.nodes[link.nodeId];
let triggeringFlowSocket = undefined;
let executionStepCount = 0;
node.inputSockets.forEach((inputSocket) => {
if (inputSocket.valueTypeName !== 'flow') {
executionStepCount += this.resolveInputValueFromSocket(inputSocket);
this.resolveInputValueFromSocket(inputSocket);
}
else {
if (inputSocket.name === link.socketName) {
inputSocket.value = true;
triggeringFlowSocket = inputSocket;
}
else {
inputSocket.value = false;
}
inputSocket.value = inputSocket.name === link.socketName;
}
});
const context = new NodeEvalContext(this, node, triggeringFlowSocket);
const context = new NodeEvalContext(this, node);
context.evalFlow();
executionStepCount++;
if (context.numCommits === 0 && !context.asyncPending) {

@@ -115,3 +100,3 @@ let numFlowOutputs = 0;

if (numFlowOutputs !== 1) {
throw new Error(`can not use auto-commit if there are multiple flow outputs, number of outputs is ${numFlowOutputs} on ${node.description.typeName}`);
throw new Error(`can not use auto-commit if there are multiple flow outputs, number of outputs is ${numFlowOutputs} on ${node.typeName}`);
}

@@ -124,5 +109,5 @@ node.outputSockets.forEach((outputSocket) => {

}
return executionStepCount;
return true;
}
}
//# sourceMappingURL=SyncExecutionBlock.js.map
import { Logger } from '../../Diagnostics/Logger.js';
import { NodeEvaluationType } from './NodeEvaluationType.js';
export function traceToLogger(event) {
const prefix = `<< ${event.node.description.typeName}:${event.node.id} >> `;
const prefix = `<< ${event.node.typeName}:${event.node.id} >> `;
if (event.nodeEvaluationType === NodeEvaluationType.None) {

@@ -6,0 +6,0 @@ Logger.info(prefix + ` Eval Done`);

@@ -12,7 +12,7 @@ import { Link } from '../../Nodes/Link.js';

constructor(engine: Engine, nextEval: Link | null, fiberCompletedListener?: (() => void) | undefined);
resolveInputValueFromSocket(inputSocket: Socket): 0 | undefined;
resolveInputValueFromSocket(inputSocket: Socket): void;
commit(node: Node, outputSocketName: string, fiberCompletedListener?: (() => void) | undefined): void;
executeStep(): -1 | 0 | undefined;
executeStep(): void;
isCompleted(): boolean;
}
//# sourceMappingURL=Fiber.d.ts.map

@@ -18,24 +18,31 @@ import { Assert } from '../../Diagnostics/Assert.js';

if (inputSocket.links.length === 0) {
return 0;
return;
}
const upstreamLink = inputSocket.links[0];
const upstreamNode = this.graph.nodes[upstreamLink.nodeId];
const upstreamOutputSocket = upstreamNode.outputSockets.find((socket) => socket.name === upstreamLink.socketName);
if (upstreamOutputSocket === undefined) {
throw new Error(`can not find socket with the name ${upstreamLink.socketName}`);
if (upstreamLink._targetNode === undefined ||
upstreamLink._targetSocket === undefined) {
Assert.mustBeTrue(inputSocket.links.length === 1);
upstreamLink._targetNode = this.graph.nodes[upstreamLink.nodeId];
upstreamLink._targetSocket = upstreamLink._targetNode.outputSockets.find((socket) => socket.name === upstreamLink.socketName);
if (upstreamLink._targetSocket === undefined) {
throw new Error(`can not find socket with the name ${upstreamLink.socketName}`);
}
}
const upstreamNode = upstreamLink._targetNode;
const upstreamOutputSocket = upstreamLink._targetSocket;
if (upstreamNode instanceof ImmediateNode) {
for (const upstreamInputSocket of upstreamNode.inputSockets) {
this.resolveInputValueFromSocket(upstreamInputSocket);
}
this.engine.onNodeExecution.emit(upstreamNode);
upstreamNode.exec();
this.executionSteps++;
inputSocket.value = upstreamOutputSocket.value;
return;
}
if (upstreamNode instanceof FlowNode) {
inputSocket.value = upstreamOutputSocket.value;
return 0;
return;
}
if (!(upstreamNode instanceof ImmediateNode)) {
throw new TypeError('node must be an instance of ImmediateNode');
}
for (const upstreamInputSocket of upstreamNode.inputSockets) {
this.resolveInputValueFromSocket(upstreamInputSocket);
}
this.engine.onNodeExecution.emit(upstreamNode);
upstreamNode.exec();
this.executionSteps++;
inputSocket.value = upstreamOutputSocket.value;
throw new TypeError('node must be an instance of ImmediateNode');
}

@@ -69,3 +76,3 @@ commit(node, outputSocketName, fiberCompletedListener = undefined) {

if (this.fiberCompletedListenerStack.length === 0) {
return -1;
return;
}

@@ -77,3 +84,3 @@ const awaitingCallback = this.fiberCompletedListenerStack.pop();

awaitingCallback();
return 0;
return;
}

@@ -83,11 +90,10 @@ const node = this.graph.nodes[link.nodeId];

node.inputSockets.forEach((inputSocket) => {
if (inputSocket.valueTypeName !== 'flow') {
this.resolveInputValueFromSocket(inputSocket);
}
else {
inputSocket.value = inputSocket.name === link.socketName;
if (inputSocket.value) {
if (inputSocket.valueTypeName === 'flow') {
if (inputSocket.name === link.socketName) {
inputSocket.value = true;
triggeredSocketName = inputSocket.name;
}
return;
}
this.resolveInputValueFromSocket(inputSocket);
});

@@ -102,7 +108,10 @@ this.engine.onNodeExecution.emit(node);

});
return;
}
else if (node instanceof FlowNode) {
if (node instanceof FlowNode) {
node.triggered(this, triggeredSocketName);
this.executionSteps++;
return;
}
throw new TypeError('should not get here');
}

@@ -109,0 +118,0 @@ isCompleted() {

@@ -30,3 +30,2 @@ export * from './Events/EventEmitter.js';

export * from './Graphs/IO/NodeSpecJSON.js';
export * from './Abstractions/AbstractionsRegistry.js';
export * from './Profiles/Core/Abstractions/Drivers/DefaultLogger.js';

@@ -33,0 +32,0 @@ export * from './Profiles/Core/Abstractions/Drivers/ManualLifecycleEventEmitter.js';

@@ -30,3 +30,2 @@ export * from './Events/EventEmitter.js';

export * from './Graphs/IO/NodeSpecJSON.js';
export * from './Abstractions/AbstractionsRegistry.js';
export * from './Profiles/Core/Abstractions/Drivers/DefaultLogger.js';

@@ -33,0 +32,0 @@ export * from './Profiles/Core/Abstractions/Drivers/ManualLifecycleEventEmitter.js';

@@ -21,4 +21,3 @@ import { EventEmitter } from '../Events/EventEmitter.js';

evalFlow(): void;
commit(downstreamFlowSocketName: string, syncEvaluationCompletedListener?: (() => void) | undefined): void;
}
//# sourceMappingURL=NodeEvalContext.d.ts.map

@@ -5,3 +5,2 @@ import { EventEmitter } from '../Events/EventEmitter.js';

import { FlowNode } from './FlowNode.js';
import { Link } from './Link.js';
export class NodeEvalContext {

@@ -57,14 +56,5 @@ constructor(fiber, node, triggeringFlowSocket = undefined) {

this.engine.onNodeExecution.emit(flowNode);
flowNode.exec(this);
flowNode.exec(this.fiber);
}
commit(downstreamFlowSocketName, syncEvaluationCompletedListener = undefined) {
this.numCommits++;
if (this.node instanceof AsyncNode) {
this.engine.commitToNewFiber(new Link(this.node.id, downstreamFlowSocketName), syncEvaluationCompletedListener);
}
else {
this.fiber.commit(new Link(this.node.id, downstreamFlowSocketName), syncEvaluationCompletedListener);
}
}
}
//# sourceMappingURL=NodeEvalContext.js.map

@@ -1,11 +0,8 @@

import { NodeDescription } from './NodeDescription.js';
import { Node } from './Node.js';
export declare class NodeTypeRegistry {
private readonly typeNameToNodeDescriptions;
clear(): void;
register(...descriptions: Array<NodeDescription>): void;
contains(typeName: string): boolean;
get(typeName: string): NodeDescription;
private readonly nodeTypeNameToNodeFactory;
register(nodeTypeName: string, nodeTypeFactory: () => Node): void;
create(nodeTypeName: string, nodeId?: string): Node;
getAllNames(): string[];
getAllDescriptions(): NodeDescription[];
}
//# sourceMappingURL=NodeTypeRegistry.d.ts.map

@@ -0,34 +1,27 @@

import { Assert } from '../Diagnostics/Assert.js';
import { generateUuid } from '../generateUuid.js';
export class NodeTypeRegistry {
constructor() {
this.typeNameToNodeDescriptions = {};
this.nodeTypeNameToNodeFactory = {};
}
clear() {
Object.keys(this.typeNameToNodeDescriptions).forEach((nodeTypeName) => {
delete this.typeNameToNodeDescriptions[nodeTypeName];
});
register(nodeTypeName, nodeTypeFactory) {
if (nodeTypeName in this.nodeTypeNameToNodeFactory) {
throw new Error(`already registered node type ${nodeTypeName}`);
}
this.nodeTypeNameToNodeFactory[nodeTypeName] = nodeTypeFactory;
}
register(...descriptions) {
descriptions.forEach((description) => {
if (description.typeName in this.typeNameToNodeDescriptions) {
throw new Error(`already registered node type ${description.typeName} (string)`);
}
this.typeNameToNodeDescriptions[description.typeName] = description;
});
}
contains(typeName) {
return typeName in this.typeNameToNodeDescriptions;
}
get(typeName) {
if (!(typeName in this.typeNameToNodeDescriptions)) {
throw new Error(`no registered node with type name ${typeName}`);
create(nodeTypeName, nodeId = generateUuid()) {
if (!(nodeTypeName in this.nodeTypeNameToNodeFactory)) {
throw new Error(`no registered node with type name ${nodeTypeName}`);
}
return this.typeNameToNodeDescriptions[typeName];
const factory = this.nodeTypeNameToNodeFactory[nodeTypeName];
const node = factory();
node.id = nodeId;
Assert.mustBeTrue(node.typeName === nodeTypeName, `node.typeName: ${node.typeName} must align with registered typeName: ${nodeTypeName}`);
return node;
}
getAllNames() {
return Object.keys(this.typeNameToNodeDescriptions);
return Object.keys(this.nodeTypeNameToNodeFactory);
}
getAllDescriptions() {
return Object.values(this.typeNameToNodeDescriptions);
}
}
//# sourceMappingURL=NodeTypeRegistry.js.map

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

import { Fiber } from '../Graphs/Execution/Fiber.js';
import { Graph } from '../Graphs/Graph.js';

@@ -8,4 +9,4 @@ import { Socket } from '../Sockets/Socket.js';

cachedContext: NodeEvalContext | undefined;
constructor(description: NodeDescription, graph: Graph, inputSockets: Socket[], outputSockets: Socket[], flowEvalFunc: (context: NodeEvalContext) => void);
constructor(description: NodeDescription, graph: Graph, inputSockets: Socket[], outputSockets: Socket[], exec: (fiber: Fiber) => void);
}
//# sourceMappingURL=RentrantNode.d.ts.map
import { AsyncNode } from './AsyncNode.js';
export class RentrantNode extends AsyncNode {
constructor(description, graph, inputSockets, outputSockets, flowEvalFunc) {
super(description, graph, inputSockets, outputSockets, flowEvalFunc);
constructor(description, graph, inputSockets, outputSockets, exec) {
super(description, graph, inputSockets, outputSockets, exec);
this.cachedContext = undefined;

@@ -6,0 +6,0 @@ }

@@ -6,3 +6,3 @@ import { Node } from '../../../Nodes/Node.js';

super('Action', 'action/log', [new Socket('flow', 'flow'), new Socket('string', 'text')], [new Socket('flow', 'flow')], (context) => {
const logger = context.graph.registry.abstractions.get('ILogger');
const logger = context.graph.registry.implementations.get('ILogger');
logger.info(context.readInput('text'));

@@ -9,0 +9,0 @@ });

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

import { Graph } from '../../../Graphs/Graph.js';
import { Node } from '../../../Nodes/Node.js';
export declare class TriggerCustomEvent extends Node {
readonly graph: Graph;
readonly customEventId: string;
constructor(graph: Graph, customEventId: string);
constructor();
}
//# sourceMappingURL=TriggerCustomEvent.d.ts.map
import { Node } from '../../../Nodes/Node.js';
import { Socket } from '../../../Sockets/Socket.js';
export class TriggerCustomEvent extends Node {
constructor(graph, customEventId) {
const customEvent = graph.customEvents[customEventId];
const inputSockets = [
new Socket('flow', 'flow'),
...customEvent.parameters.map((parameter) => new Socket(parameter.valueTypeName, parameter.name, parameter.value))
];
super('Action', `action/triggerCustomEvent/${customEvent.id}`, inputSockets, [new Socket('flow', 'flow')], (context) => {
constructor() {
super('Action', 'action/triggerCustomEvent', [new Socket('flow', 'flow'), new Socket('id', 'customEvent')], [new Socket('flow', 'flow')], (context) => {
const customEventId = context.readInput('customEvent');
const customEvent = context.getCustomEvent(customEventId);
const parameters = {};
for (let i = 1; i < this.inputSockets.length; i++) {
const inputSocketName = inputSockets[i].name;
parameters[inputSocketName] = context.readInput(inputSocketName);
}
customEvent.eventEmitter.emit(parameters);
customEvent.eventEmitter.emit();
});
this.graph = graph;
this.customEventId = customEventId;
}
}
//# sourceMappingURL=TriggerCustomEvent.js.map

@@ -5,7 +5,9 @@ import { Fiber } from '../../../Execution/Fiber.js';

import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js';
import { ILogger } from '../Abstractions/ILogger.js';
export declare class Log extends FlowNode {
static Description: NodeDescription;
constructor(description: NodeDescription, graph: Graph);
private readonly logger;
static Description: (logger: ILogger) => NodeDescription;
constructor(description: NodeDescription, graph: Graph, logger: ILogger);
triggered(fiber: Fiber, triggeredSocketName: string): void;
}
//# sourceMappingURL=DebugLog.d.ts.map

@@ -5,12 +5,12 @@ import { FlowNode } from '../../../Nodes/FlowNode.js';

export class Log extends FlowNode {
constructor(description, graph) {
constructor(description, graph, logger) {
super(description, graph, [new Socket('flow', 'flow'), new Socket('string', 'text')], [new Socket('flow', 'flow')]);
this.logger = logger;
}
triggered(fiber, triggeredSocketName) {
const logger = this.graph.registry.abstractions.get('ILogger');
logger.info(this.readInput('text'));
this.logger.info(this.readInput('text'));
fiber.commit(this, 'flow');
}
}
Log.Description = new NodeDescription('debug/log', 'Action', 'Debug Log', (description, graph) => new Log(description, graph));
Log.Description = (logger) => new NodeDescription('debug/log', 'Action', 'Debug Log', (description, graph) => new Log(description, graph, logger));
//# sourceMappingURL=DebugLog.js.map

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

import { Graph } from '../../../Graphs/Graph.js';
import { Node } from '../../../Nodes/Node.js';
export declare class OnCustomEvent extends Node {
readonly graph: Graph;
readonly customEventId: string;
constructor(graph: Graph, customEventId: string);
constructor();
}
//# sourceMappingURL=OnCustomEvent.d.ts.map
import { Node } from '../../../Nodes/Node.js';
import { Socket } from '../../../Sockets/Socket.js';
export class OnCustomEvent extends Node {
constructor(graph, customEventId) {
const customEvent = graph.customEvents[customEventId];
const outputSockets = [
new Socket('flow', 'flow'),
...customEvent.parameters.map((parameter) => new Socket(parameter.valueTypeName, parameter.name, parameter.value))
];
super('Event', `event/customEvent/${customEvent.id}`, [], outputSockets, (context) => {
customEvent.eventEmitter.addListener((parameters) => {
Object.keys(parameters).forEach((parameterName) => context.writeOutput(parameterName, parameters[parameterName]));
constructor() {
super('Event', 'event/customEvent', [new Socket('id', 'customEvent')], [new Socket('flow', 'flow')], (context) => {
const customEventId = context.readInput('customEvent');
const customEvent = context.getCustomEvent(customEventId);
customEvent.eventEmitter.addListener(() => {
context.commit('flow');
});
});
this.graph = graph;
this.customEventId = customEventId;
this.evaluateOnStartup = true;

@@ -19,0 +13,0 @@ this.async = true;

@@ -9,3 +9,3 @@ import { Node } from '../../../Nodes/Node.js';

};
const lifecycleEvents = context.graph.registry.abstractions.get('ILifecycleEventEmitter');
const lifecycleEvents = context.graph.registry.implementations.get('ILifecycleEventEmitter');
lifecycleEvents.endEvent.addListener(onEndEvent);

@@ -12,0 +12,0 @@ context.onAsyncCancelled.addListener(() => {

@@ -9,3 +9,3 @@ import { Node } from '../../../Nodes/Node.js';

};
const lifecycleEvents = context.graph.registry.abstractions.get('ILifecycleEventEmitter');
const lifecycleEvents = context.graph.registry.implementations.get('ILifecycleEventEmitter');
lifecycleEvents.startEvent.addListener(onStartEvent);

@@ -12,0 +12,0 @@ context.onAsyncCancelled.addListener(() => {

@@ -19,3 +19,3 @@ import { Node } from '../../../Nodes/Node.js';

};
const lifecycleEvents = context.graph.registry.abstractions.get('ILifecycleEventEmitter');
const lifecycleEvents = context.graph.registry.implementations.get('ILifecycleEventEmitter');
lifecycleEvents.tickEvent.addListener(onTickEvent);

@@ -22,0 +22,0 @@ context.onAsyncCancelled.addListener(() => {

@@ -5,5 +5,7 @@ import { Engine } from '../../../Execution/Engine.js';

import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js';
import { ILifecycleEventEmitter } from '../Abstractions/ILifecycleEventEmitter.js';
export declare class LifecycleOnEnd extends EventNode {
static Description: NodeDescription;
constructor(description: NodeDescription, graph: Graph);
private readonly lifecycleEventEmitter;
static Description: (lifecycleEventEmitter: ILifecycleEventEmitter) => NodeDescription;
constructor(description: NodeDescription, graph: Graph, lifecycleEventEmitter: ILifecycleEventEmitter);
private onEndEvent;

@@ -10,0 +12,0 @@ init(engine: Engine): void;

@@ -6,4 +6,5 @@ import { Assert } from '../../../Diagnostics/Assert.js';

export class LifecycleOnEnd extends EventNode {
constructor(description, graph) {
constructor(description, graph, lifecycleEventEmitter) {
super(description, graph, [], [new Socket('flow', 'flow')]);
this.lifecycleEventEmitter = lifecycleEventEmitter;
this.onEndEvent = undefined;

@@ -16,4 +17,3 @@ }

};
const lifecycleEvents = engine.graph.registry.abstractions.get('ILifecycleEventEmitter');
lifecycleEvents.endEvent.removeListener(this.onEndEvent);
this.lifecycleEventEmitter.endEvent.removeListener(this.onEndEvent);
}

@@ -23,8 +23,7 @@ dispose(engine) {

if (this.onEndEvent !== undefined) {
const lifecycleEvents = engine.graph.registry.abstractions.get('ILifecycleEventEmitter');
lifecycleEvents.endEvent.removeListener(this.onEndEvent);
this.lifecycleEventEmitter.endEvent.removeListener(this.onEndEvent);
}
}
}
LifecycleOnEnd.Description = new NodeDescription('lifecycle/onEnd', 'Event', 'On End', (description, graph) => new LifecycleOnEnd(description, graph));
LifecycleOnEnd.Description = (lifecycleEventEmitter) => new NodeDescription('lifecycle/onEnd', 'Event', 'On End', (description, graph) => new LifecycleOnEnd(description, graph, lifecycleEventEmitter));
//# sourceMappingURL=LifecycleOnEnd.js.map

@@ -5,5 +5,7 @@ import { Engine } from '../../../Execution/Engine.js';

import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js';
import { ILifecycleEventEmitter } from '../Abstractions/ILifecycleEventEmitter.js';
export declare class LifecycleOnStart extends EventNode {
static Description: NodeDescription;
constructor(description: NodeDescription, graph: Graph);
private readonly lifecycleEventEmitter;
static Description: (lifecycleEventEmitter: ILifecycleEventEmitter) => NodeDescription;
constructor(description: NodeDescription, graph: Graph, lifecycleEventEmitter: ILifecycleEventEmitter);
private onStartEvent;

@@ -10,0 +12,0 @@ init(engine: Engine): void;

@@ -6,4 +6,5 @@ import { Assert } from '../../../Diagnostics/Assert.js';

export class LifecycleOnStart extends EventNode {
constructor(description, graph) {
constructor(description, graph, lifecycleEventEmitter) {
super(description, graph, [], [new Socket('flow', 'flow')]);
this.lifecycleEventEmitter = lifecycleEventEmitter;
this.onStartEvent = undefined;

@@ -16,4 +17,3 @@ }

};
const lifecycleEvents = engine.graph.registry.abstractions.get('ILifecycleEventEmitter');
lifecycleEvents.startEvent.addListener(this.onStartEvent);
this.lifecycleEventEmitter.startEvent.addListener(this.onStartEvent);
}

@@ -23,8 +23,7 @@ dispose(engine) {

if (this.onStartEvent !== undefined) {
const lifecycleEvents = engine.graph.registry.abstractions.get('ILifecycleEventEmitter');
lifecycleEvents.startEvent.removeListener(this.onStartEvent);
this.lifecycleEventEmitter.startEvent.removeListener(this.onStartEvent);
}
}
}
LifecycleOnStart.Description = new NodeDescription('lifecycle/onStart', 'Event', 'On Start', (description, graph) => new LifecycleOnStart(description, graph));
LifecycleOnStart.Description = (lifecycleEventEmitter) => new NodeDescription('lifecycle/onStart', 'Event', 'On Start', (description, graph) => new LifecycleOnStart(description, graph, lifecycleEventEmitter));
//# sourceMappingURL=LifecycleOnStart.js.map

@@ -5,5 +5,7 @@ import { Engine } from '../../../Execution/Engine.js';

import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js';
import { ILifecycleEventEmitter } from '../Abstractions/ILifecycleEventEmitter.js';
export declare class LifecycleOnTick extends EventNode {
static Description: NodeDescription;
constructor(description: NodeDescription, graph: Graph);
private readonly lifecycleEventEmitter;
static Description: (lifecycleEventEmitter: ILifecycleEventEmitter) => NodeDescription;
constructor(description: NodeDescription, graph: Graph, lifecycleEventEmitter: ILifecycleEventEmitter);
private onTickEvent;

@@ -10,0 +12,0 @@ init(engine: Engine): void;

@@ -6,3 +6,3 @@ import { Assert } from '../../../Diagnostics/Assert.js';

export class LifecycleOnTick extends EventNode {
constructor(description, graph) {
constructor(description, graph, lifecycleEventEmitter) {
super(description, graph, [], [

@@ -13,2 +13,3 @@ new Socket('flow', 'flow'),

]);
this.lifecycleEventEmitter = lifecycleEventEmitter;
this.onTickEvent = undefined;

@@ -27,4 +28,3 @@ }

};
const lifecycleEvents = engine.graph.registry.abstractions.get('ILifecycleEventEmitter');
lifecycleEvents.tickEvent.addListener(this.onTickEvent);
this.lifecycleEventEmitter.tickEvent.addListener(this.onTickEvent);
}

@@ -34,8 +34,7 @@ dispose(engine) {

if (this.onTickEvent !== undefined) {
const lifecycleEvents = engine.graph.registry.abstractions.get('ILifecycleEventEmitter');
lifecycleEvents.tickEvent.removeListener(this.onTickEvent);
this.lifecycleEventEmitter.tickEvent.removeListener(this.onTickEvent);
}
}
}
LifecycleOnTick.Description = new NodeDescription('lifecycle/onTick', 'Event', 'On Tick', (description, graph) => new LifecycleOnTick(description, graph));
LifecycleOnTick.Description = (lifecycleEventEmitter) => new NodeDescription('lifecycle/onTick', 'Event', 'On Tick', (description, graph) => new LifecycleOnTick(description, graph, lifecycleEventEmitter));
//# sourceMappingURL=LifecycleOnTick.js.map
import { Registry } from '../../Registry.js';
export declare function registerCoreProfile(registry: Registry): Registry;
import { ILifecycleEventEmitter } from './Abstractions/ILifecycleEventEmitter.js';
import { ILogger } from './Abstractions/ILogger.js';
export declare function registerCoreProfile(registry: Registry, logger?: ILogger, lifecycleEventEmitter?: ILifecycleEventEmitter): Registry;
//# sourceMappingURL=registerCoreProfile.d.ts.map
import { getNodeDescriptions } from '../../Nodes/Registry/NodeDescription.js';
import { DefaultLogger } from './Abstractions/Drivers/DefaultLogger.js';
import { ManualLifecycleEventEmitter } from './Abstractions/Drivers/ManualLifecycleEventEmitter.js';
import { ExpectTrue as AssertExpectTrue } from './Debug/AssertExpectTrue.js';

@@ -21,3 +23,3 @@ import { Log as DebugLog } from './Debug/DebugLog.js';

import { StringValue } from './Values/StringValue.js';
export function registerCoreProfile(registry) {
export function registerCoreProfile(registry, logger = new DefaultLogger(), lifecycleEventEmitter = new ManualLifecycleEventEmitter()) {
const { nodes, values } = registry;

@@ -32,7 +34,7 @@ values.register(BooleanValue);

nodes.register(...getNodeDescriptions(FloatNodes));
nodes.register(DebugLog.Description);
nodes.register(DebugLog.Description(logger));
nodes.register(AssertExpectTrue.Description);
nodes.register(LifecycleOnStart.Description);
nodes.register(LifecycleOnEnd.Description);
nodes.register(LifecycleOnTick.Description);
nodes.register(LifecycleOnStart.Description(lifecycleEventEmitter));
nodes.register(LifecycleOnEnd.Description(lifecycleEventEmitter));
nodes.register(LifecycleOnTick.Description(lifecycleEventEmitter));
nodes.register(Branch.Description);

@@ -39,0 +41,0 @@ nodes.register(FlipFlop.Description);

@@ -5,8 +5,10 @@ import { Fiber } from '../../../Execution/Fiber.js';

import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js';
import { IScene } from '../Abstractions/IScene.js';
export declare class SetSceneProperty extends FlowNode {
readonly valueTypeName: string;
static GetDescriptions(...valueTypeNames: string[]): NodeDescription[];
constructor(description: NodeDescription, graph: Graph, valueTypeName: string);
private readonly scene;
static GetDescriptions(scene: IScene, ...valueTypeNames: string[]): NodeDescription[];
constructor(description: NodeDescription, graph: Graph, valueTypeName: string, scene: IScene);
triggered(fiber: Fiber, triggeringSocketName: string): void;
}
//# sourceMappingURL=SetSceneProperty.d.ts.map

@@ -6,3 +6,3 @@ import { FlowNode } from '../../../Nodes/FlowNode.js';

export class SetSceneProperty extends FlowNode {
constructor(description, graph, valueTypeName) {
constructor(description, graph, valueTypeName, scene) {
super(description, graph, [

@@ -14,8 +14,9 @@ new Socket('flow', 'flow'),

this.valueTypeName = valueTypeName;
this.scene = scene;
}
static GetDescriptions(...valueTypeNames) {
return valueTypeNames.map((valueTypeName) => new NodeDescription(`scene/set/${valueTypeName}`, 'Action', `Set Scene ${toCamelCase(valueTypeName)}`, (description, graph) => new SetSceneProperty(description, graph, valueTypeName)));
static GetDescriptions(scene, ...valueTypeNames) {
return valueTypeNames.map((valueTypeName) => new NodeDescription(`scene/set/${valueTypeName}`, 'Action', `Set Scene ${toCamelCase(valueTypeName)}`, (description, graph) => new SetSceneProperty(description, graph, valueTypeName, scene)));
}
triggered(fiber, triggeringSocketName) {
const scene = fiber.engine.graph.registry.abstractions.get('IScene');
const scene = this.scene;
const value = this.readInput('value');

@@ -22,0 +23,0 @@ scene.setProperty(this.readInput('jsonPath'), this.valueTypeName, value);

import { Graph } from '../../../Graphs/Graph.js';
import { ImmediateNode } from '../../../Nodes/ImmediateNode.js';
import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js';
import { IScene } from '../Abstractions/IScene.js';
export declare class GetSceneProperty extends ImmediateNode {
readonly valueTypeName: string;
static GetDescriptions(...valueTypeNames: string[]): NodeDescription[];
constructor(description: NodeDescription, graph: Graph, valueTypeName: string);
private readonly scene;
static GetDescriptions(scene: IScene, ...valueTypeNames: string[]): NodeDescription[];
constructor(description: NodeDescription, graph: Graph, valueTypeName: string, scene: IScene);
}
//# sourceMappingURL=GetSceneProperty.d.ts.map

@@ -6,13 +6,13 @@ import { ImmediateNode } from '../../../Nodes/ImmediateNode.js';

export class GetSceneProperty extends ImmediateNode {
constructor(description, graph, valueTypeName) {
constructor(description, graph, valueTypeName, scene) {
super(description, graph, [new Socket('string', 'jsonPath')], [new Socket(valueTypeName, 'value')], () => {
const sceneGraph = this.graph.registry.abstractions.get('IScene');
this.writeOutput('value', sceneGraph.getProperty(this.readInput('jsonPath'), valueTypeName));
this.writeOutput('value', this.scene.getProperty(this.readInput('jsonPath'), valueTypeName));
});
this.valueTypeName = valueTypeName;
this.scene = scene;
}
static GetDescriptions(...valueTypeNames) {
return valueTypeNames.map((valueTypeName) => new NodeDescription(`scene/get/${valueTypeName}`, 'Query', `Get Scene ${toCamelCase(valueTypeName)}`, (description, graph) => new GetSceneProperty(description, graph, valueTypeName)));
static GetDescriptions(scene, ...valueTypeNames) {
return valueTypeNames.map((valueTypeName) => new NodeDescription(`scene/get/${valueTypeName}`, 'Query', `Get Scene ${toCamelCase(valueTypeName)}`, (description, graph) => new GetSceneProperty(description, graph, valueTypeName, scene)));
}
}
//# sourceMappingURL=GetSceneProperty.js.map

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

import { DummyScene } from '../../../examples/exec-graph/DummyScene';
import * as flashSuzanneJson from '../../../graphs/scene/actions/FlashSuzanne.json';

@@ -19,3 +20,3 @@ import * as hierarchyJson from '../../../graphs/scene/actions/Hierarchy.json';

registerCoreProfile(registry);
registerSceneProfile(registry);
registerSceneProfile(registry, new DummyScene(registry));
Logger.onWarn.clear();

@@ -22,0 +23,0 @@ const exampleMap = {

@@ -7,3 +7,3 @@ import { In1Out1FuncNode } from '../../Nodes/Templates/In1Out1FuncNode.js';

import { VecElements } from './Logic/VecElements.js';
import { hexToRGB, hslToRGB, rgbToHex, rgbToHSL, Vec3, vec3Add, vec3FromArray, vec3Mix, vec3Parse, vec3Scale, vec3Subtract, vec3ToArray } from './Values/Vec3.js';
import { hexToRGB, hslToRGB, rgbToHex, rgbToHSL, Vec3, vec3Add, vec3FromArray, vec3Mix, vec3Parse, vec3Scale, vec3Subtract, vec3ToArray, vec3ToString } from './Values/Vec3.js';
export function registerColorValue(registry) {

@@ -18,2 +18,3 @@ const { nodes, values } = registry;

nodes.register('logic/add/color', () => new In2Out1FuncNode('logic/add/color', 'color', 'color', 'color', (a, b) => vec3Add(a, b)));
nodes.register('logic/toString/color', () => new In1Out1FuncNode('logic/toString/color', 'color', 'string', (a) => vec3ToString(a)));
nodes.register('logic/subtract/color', () => new In2Out1FuncNode('logic/subtract/color', 'color', 'color', 'color', (a, b) => vec3Subtract(a, b)));

@@ -20,0 +21,0 @@ nodes.register('logic/scale/color', () => new In2Out1FuncNode('logic/scale/color', 'color', 'float', 'color', (a, b) => vec3Scale(a, b)));

@@ -7,3 +7,3 @@ import { In1Out1FuncNode } from '../../Nodes/Templates/In1Out1FuncNode.js';

import { VecElements } from './Logic/VecElements.js';
import { Vec3, vec3Add, vec3FromArray, vec3Mix, vec3Parse, vec3ToArray } from './Values/Vec3.js';
import { Vec3, vec3Add, vec3FromArray, vec3Mix, vec3Parse, vec3ToArray, vec3ToString } from './Values/Vec3.js';
import { eulerToQuat } from './Values/Vec4.js';

@@ -20,4 +20,5 @@ export function registerEulerValue(registry) {

nodes.register('logic/mix/euler', () => new In3Out1FuncNode('logic/mix/euler', 'euler', 'euler', 'float', 'euler', (a, b, c) => vec3Mix(a, b, c)));
nodes.register('logic/toString/euler', () => new In1Out1FuncNode('logic/toString/euler', 'euler', 'string', (a) => vec3ToString(a)));
nodes.register('logic/toQuat/euler', () => new In1Out1FuncNode('logic/toQuat/euler', 'euler', 'quat', (a) => eulerToQuat(a)));
}
//# sourceMappingURL=registerEulerValue.js.map

@@ -7,3 +7,3 @@ import { In1Out1FuncNode } from '../../Nodes/Templates/In1Out1FuncNode.js';

import { VecElements } from './Logic/VecElements.js';
import { angleAxisToQuat, quatConjugate, quatMultiply, quatSlerp, Vec4, vec4Dot, vec4FromArray, vec4Length, vec4Normalize, vec4Parse, vec4ToArray } from './Values/Vec4.js';
import { angleAxisToQuat, quatConjugate, quatMultiply, quatSlerp, Vec4, vec4Dot, vec4FromArray, vec4Length, vec4Normalize, vec4Parse, vec4ToArray, vec4ToString } from './Values/Vec4.js';
export function registerQuatValue(registry) {

@@ -24,3 +24,4 @@ const { nodes, values } = registry;

nodes.register('logic/length/quat', () => new In1Out1FuncNode('logic/length/quat', 'quat', 'float', (a) => vec4Length(a)));
nodes.register('logic/toString/quat', () => new In1Out1FuncNode('logic/toString/quat', 'quat', 'string', (a) => vec4ToString(a)));
}
//# sourceMappingURL=registerQuatValue.js.map
import { Registry } from '../../Registry.js';
export declare function registerSceneProfile(registry: Registry): Registry;
import { IScene } from './Abstractions/IScene.js';
export declare function registerSceneProfile(registry: Registry, scene: IScene): Registry;
//# sourceMappingURL=registerSceneProfile.d.ts.map

@@ -18,3 +18,3 @@ import { getNodeDescriptions } from '../../Nodes/Registry/NodeDescription.js';

import { Vec4Value } from './Values/Vec4Value.js';
export function registerSceneProfile(registry) {
export function registerSceneProfile(registry, scene) {
const { values, nodes } = registry;

@@ -35,4 +35,4 @@ values.register(Vec2Value);

const allValueTypeNames = values.getAllNames();
nodes.register(...SetSceneProperty.GetDescriptions(...allValueTypeNames));
nodes.register(...GetSceneProperty.GetDescriptions(...allValueTypeNames));
nodes.register(...SetSceneProperty.GetDescriptions(scene, ...allValueTypeNames));
nodes.register(...GetSceneProperty.GetDescriptions(scene, ...allValueTypeNames));
const newValueTypeNames = ['vec2', 'vec3', 'vec4', 'quat', 'euler', 'color'];

@@ -39,0 +39,0 @@ newValueTypeNames.forEach((valueTypeName) => {

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

import { DummyScene } from '../../../examples/exec-graph/DummyScene.js';
import { validateNodeRegistry } from '../../Nodes/Validation/validateNodeRegistry.js';

@@ -9,3 +10,3 @@ import { Registry } from '../../Registry.js';

registerCoreProfile(registry);
registerSceneProfile(registry);
registerSceneProfile(registry, new DummyScene(registry));
test('validate node registry', () => {

@@ -12,0 +13,0 @@ expect(validateNodeRegistry(registry)).toHaveLength(0);

@@ -7,3 +7,3 @@ import { In1Out1FuncNode } from '../../Nodes/Templates/In1Out1FuncNode.js';

import { VecElements } from './Logic/VecElements.js';
import { Vec2, vec2Add, vec2Dot, vec2FromArray, vec2Length, vec2Mix, vec2Negate, vec2Normalize, vec2Parse, vec2Scale, vec2Subtract, vec2ToArray } from './Values/Vec2.js';
import { Vec2, vec2Add, vec2FromArray, vec2Length, vec2Mix, vec2Negate, vec2Normalize, vec2Parse, vec2Scale, vec2Subtract, vec2ToArray, vec2ToString } from './Values/Vec2.js';
export function registerVec2Value(registry) {

@@ -20,3 +20,2 @@ const { nodes, values } = registry;

nodes.register('logic/scale/vec2', () => new In2Out1FuncNode('logic/scale/vec2', 'vec2', 'float', 'vec2', (a, b) => vec2Scale(a, b)));
nodes.register('logic/dot/vec2', () => new In2Out1FuncNode('logic/dot/vec2', 'vec2', 'vec2', 'float', (a, b) => vec2Dot(a, b)));
nodes.register('logic/negate/vec2', () => new In1Out1FuncNode('logic/negate/vec2', 'vec2', 'vec2', (a) => vec2Negate(a)));

@@ -26,3 +25,4 @@ nodes.register('logic/mix/vec2', () => new In3Out1FuncNode('logic/mix/vec2', 'vec2', 'vec2', 'float', 'vec2', (a, b, c) => vec2Mix(a, b, c)));

nodes.register('logic/length/vec2', () => new In1Out1FuncNode('logic/length/vec2', 'vec2', 'float', (a) => vec2Length(a)));
nodes.register('logic/toString/vec2', () => new In1Out1FuncNode('logic/toString/vec2', 'vec2', 'string', (a) => vec2ToString(a)));
}
//# sourceMappingURL=registerVec2Value.js.map

@@ -7,3 +7,3 @@ import { In1Out1FuncNode } from '../../Nodes/Templates/In1Out1FuncNode.js';

import { VecElements } from './Logic/VecElements.js';
import { Vec3, vec3Add, vec3Cross, vec3Dot, vec3FromArray, vec3Length, vec3Mix, vec3Negate, vec3Normalize, vec3Parse, vec3Scale, vec3Subtract, vec3ToArray } from './Values/Vec3.js';
import { Vec3, vec3Add, vec3Cross, vec3Dot, vec3FromArray, vec3Length, vec3Mix, vec3Negate, vec3Normalize, vec3Parse, vec3Scale, vec3Subtract, vec3ToArray, vec3ToString } from './Values/Vec3.js';
export function registerVec3Value(registry) {

@@ -26,3 +26,4 @@ const { nodes, values } = registry;

nodes.register('logic/length/vec3', () => new In1Out1FuncNode('logic/length/vec3', 'vec3', 'float', (a) => vec3Length(a)));
nodes.register('logic/toString/vec3', () => new In1Out1FuncNode('logic/toString/vec3', 'vec3', 'string', (a) => vec3ToString(a)));
}
//# sourceMappingURL=registerVec3Value.js.map

@@ -7,3 +7,3 @@ import { In1Out1FuncNode } from '../../Nodes/Templates/In1Out1FuncNode.js';

import { VecElements } from './Logic/VecElements.js';
import { Vec4, vec4Add, vec4Dot, vec4FromArray, vec4Length, vec4Mix, vec4Negate, vec4Normalize, vec4Parse, vec4Scale, vec4Subtract, vec4ToArray } from './Values/Vec4.js';
import { Vec4, vec4Add, vec4Dot, vec4FromArray, vec4Length, vec4Mix, vec4Normalize, vec4Parse, vec4Scale, vec4Subtract, vec4ToArray, vec4ToString } from './Values/Vec4.js';
export function registerVec4Value(registry) {

@@ -20,3 +20,2 @@ const { nodes, values } = registry;

nodes.register('logic/add/vec4', () => new In2Out1FuncNode('logic/add/vec4', 'vec4', 'vec4', 'vec4', (a, b) => vec4Add(a, b)));
nodes.register('logic/negate/vec4', () => new In1Out1FuncNode('logic/negate/vec4', 'vec4', 'vec4', (a) => vec4Negate(a)));
nodes.register('logic/mix/vec4', () => new In3Out1FuncNode('logic/mix/vec4', 'vec4', 'vec4', 'float', 'vec4', (a, b, c) => vec4Mix(a, b, c)));

@@ -26,3 +25,4 @@ nodes.register('logic/dot/vec4', () => new In2Out1FuncNode('logic/dot/vec4', 'vec4', 'vec4', 'float', (a, b) => vec4Dot(a, b)));

nodes.register('logic/length/vec4', () => new In1Out1FuncNode('logic/length/vec4', 'vec4', 'float', (a) => vec4Length(a)));
nodes.register('logic/toString/vec4', () => new In1Out1FuncNode('logic/toString/vec4', 'vec4', 'string', (a) => vec4ToString(a)));
}
//# sourceMappingURL=registerVec4Value.js.map

@@ -1,6 +0,4 @@

import { AbstractionsRegistry } from './Abstractions/AbstractionsRegistry.js';
import { NodeTypeRegistry } from './Nodes/Registry/NodeTypeRegistry.js';
import { ValueTypeRegistry } from './Values/ValueTypeRegistry.js';
export declare class Registry {
readonly abstractions: AbstractionsRegistry;
readonly values: ValueTypeRegistry;

@@ -7,0 +5,0 @@ readonly nodes: NodeTypeRegistry;

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

import { AbstractionsRegistry } from './Abstractions/AbstractionsRegistry.js';
import { NodeTypeRegistry } from './Nodes/Registry/NodeTypeRegistry.js';

@@ -6,3 +5,2 @@ import { ValueTypeRegistry } from './Values/ValueTypeRegistry.js';

constructor() {
this.abstractions = new AbstractionsRegistry();
this.values = new ValueTypeRegistry();

@@ -9,0 +7,0 @@ this.nodes = new NodeTypeRegistry();

{
"name": "behave-graph",
"version": "0.9.3",
"version": "0.9.5",
"description": "Simple, extensible behavior graph engine",

@@ -58,3 +58,2 @@ "type": "module",

"build": "tsc",
"watch": "tsc --watch --preserveWatchOutput & tgt --watch",
"start": "npm run watch & web-dev-server --watch --open --app-index ./src/examples/three/index.html",

@@ -61,0 +60,0 @@ "lint": "npx eslint \"src/**/*.{ts,json}\"",

@@ -12,5 +12,4 @@ import { promises as fs } from 'node:fs';

import { validateGraph } from '../../lib/Graphs/Validation/validateGraph.js';
import { DefaultLogger, ManualLifecycleEventEmitter } from '../../lib/index.js';
import { parseSafeFloat } from '../../lib/parseFloats.js';
import { DefaultLogger } from '../../lib/Profiles/Core/Abstractions/Drivers/DefaultLogger.js';
import { ManualLifecycleEventEmitter } from '../../lib/Profiles/Core/Abstractions/Drivers/ManualLifecycleEventEmitter.js';
import { registerCoreProfile } from '../../lib/Profiles/Core/registerCoreProfile.js';

@@ -41,12 +40,6 @@ import { registerSceneProfile } from '../../lib/Profiles/Scene/registerSceneProfile.js';

const registry = new Registry();
registerCoreProfile(registry);
registerSceneProfile(registry);
registry.abstractions.register('ILogger', new DefaultLogger());
const manualLifecycleEventEmitter = new ManualLifecycleEventEmitter();
registry.abstractions.register(
'ILifecycleEventEmitter',
manualLifecycleEventEmitter
);
registry.abstractions.register('IScene', new DummyScene(registry));
const logger = new DefaultLogger();
registerCoreProfile(registry, logger, manualLifecycleEventEmitter);
registerSceneProfile(registry, new DummyScene(registry));

@@ -110,5 +103,5 @@ const jsonPattern = program.args[0];

if (manualLifecycleEventEmitter.tickEvent.listenerCount > 0) {
const iteations = parseSafeFloat(programOptions.iterations, 5);
for (let tick = 0; tick < iteations; tick++) {
Logger.verbose(`triggering tick (${tick} of ${iteations})`);
const iterations = parseSafeFloat(programOptions.iterations, 5);
for (let tick = 0; tick < iterations; tick++) {
Logger.verbose(`triggering tick (${tick} of ${iterations})`);
manualLifecycleEventEmitter.tickEvent.emit();

@@ -115,0 +108,0 @@

@@ -12,2 +12,3 @@ import { promises as fs } from 'node:fs';

import { Registry } from '../../lib/Registry.js';
import { DummyScene } from '../exec-graph/DummyScene.js';

@@ -32,3 +33,3 @@ async function main() {

registerCoreProfile(registry);
registerSceneProfile(registry);
registerSceneProfile(registry, new DummyScene(registry));

@@ -35,0 +36,0 @@ const errorList: string[] = [];

@@ -42,6 +42,29 @@ /* eslint-disable no-param-reassign */

async function loadThreeScene() {
const gltfPromise = new GLTFLoader()
.setPath('/src/graphs/scene/actions/')
.loadAsync('SpinningSuzanne.gltf');
const gltf = await gltfPromise;
const glTFJsonPath = '/src/graphs/scene/actions/SpinningSuzanne.gltf';
const glTFFetchResponse = await fetch(glTFJsonPath);
const glTFJson = await glTFFetchResponse.json();
const threeScene = new ThreeScene(gltf.scene, glTFJson);
return { threeScene, gltf };
}
async function main() {
const registry = new Registry();
registerCoreProfile(registry);
registerSceneProfile(registry);
const manualLifecycleEventEmitter = new ManualLifecycleEventEmitter();
const logger = new DefaultLogger();
const { threeScene, gltf } = await loadThreeScene();
registerCoreProfile(registry, logger, manualLifecycleEventEmitter);
registerSceneProfile(registry, threeScene);
const graphJsonPath = `/src/graphs/scene/actions/SpinningSuzanne.json`;

@@ -58,5 +81,2 @@ if (graphJsonPath === undefined) {

const glTFJsonPath = '/src/graphs/scene/actions/SpinningSuzanne.gltf';
const glTFFetchResponse = await fetch(glTFJsonPath);
const glTFJson = await glTFFetchResponse.json();
// await fs.writeFile('./examples/test.json', JSON.stringify(writeGraphToJSON(graph), null, ' '), { encoding: 'utf-8' });

@@ -91,5 +111,2 @@ const errorList: string[] = [];

.loadAsync('pedestrian_overpass_1k.hdr');
const gltfPromise = new GLTFLoader()
.setPath('/src/graphs/scene/actions/')
.loadAsync('SpinningSuzanne.gltf');

@@ -107,3 +124,2 @@ const localRenderer = new THREE.WebGLRenderer({ antialias: true });

const texture = await texturePromise;
const gltf = await gltfPromise;

@@ -116,7 +132,6 @@ texture.mapping = THREE.EquirectangularReflectionMapping;

localScene.add(gltf.scene);
const threeScene = new ThreeScene(gltf.scene, glTFJson);
threeScene.onSceneChanged.addListener(() => {
render();
});
registry.abstractions.register('IScene', threeScene);

@@ -138,9 +153,2 @@ render();

registry.abstractions.register('ILogger', new DefaultLogger());
const manualLifecycleEventEmitter = new ManualLifecycleEventEmitter();
registry.abstractions.register(
'ILifecycleEventEmitter',
manualLifecycleEventEmitter
);
Logger.verbose('initialize graph');

@@ -147,0 +155,0 @@ await engine.executeAllSync();

@@ -71,3 +71,3 @@ import { Material, Object3D, Quaternion, Vector3, Vector4 } from 'three';

constructor(public glTFRoot: Object3D, public glTFJson: GLTFJson) {
constructor(public glTFRoot: Object3D, public readonly glTFJson: GLTFJson) {
this.glTFNodeIndexToThreeNode = mapGlTFNodeIndicesToThreeObject3Ds(

@@ -74,0 +74,0 @@ glTFJson,

@@ -17,11 +17,5 @@ import * as THREEIFY from 'threeify';

const registry = new Registry();
registerCoreProfile(registry);
registerSceneProfile(registry);
registry.abstractions.register('ILogger', new DefaultLogger());
const manualLifecycleEventEmitter = new ManualLifecycleEventEmitter();
registry.abstractions.register(
'ILifecycleEventEmitter',
manualLifecycleEventEmitter
);
const logger = new DefaultLogger();
registerCoreProfile(registry, logger, manualLifecycleEventEmitter);

@@ -28,0 +22,0 @@ const graphJsonPath = '/dist/graphs/core/HelloWorld.json';

import { Assert } from '../Diagnostics/Assert.js';
import { Graph } from '../Graphs/Graph.js';
import { AsyncNode } from '../Nodes/AsyncNode.js';
import { EventNode } from '../Nodes/EventNode.js';
import { FlowNode } from '../Nodes/FlowNode.js';

@@ -77,4 +78,8 @@ import { ImmediateNode } from '../Nodes/ImmediateNode.js';

// if upstream is a flow node, do not evaluate it rather just use its existing output socket values
if (upstreamNode instanceof FlowNode) {
// if upstream is a flow/event/async node, do not evaluate it rather just use its existing output socket values
if (
upstreamNode instanceof FlowNode ||
upstreamNode instanceof EventNode ||
upstreamNode instanceof AsyncNode
) {
inputSocket.value = upstreamOutputSocket.value;

@@ -84,3 +89,5 @@ return;

throw new TypeError('node must be an instance of ImmediateNode');
throw new TypeError(
`node, ${upstreamNode.description.typeName}, must be an instance of ImmediateNode`
);
}

@@ -176,3 +183,5 @@

throw new TypeError('should not get here');
throw new TypeError(
`should not get here, unhandled node ${node.description.typeName}`
);
}

@@ -179,0 +188,0 @@

@@ -44,4 +44,2 @@ export * from './Events/EventEmitter.js';

export * from './Abstractions/AbstractionsRegistry.js';
export * from './Profiles/Core/Abstractions/Drivers/DefaultLogger.js';

@@ -48,0 +46,0 @@ export * from './Profiles/Core/Abstractions/Drivers/ManualLifecycleEventEmitter.js';

@@ -9,10 +9,15 @@ import { Fiber } from '../../../Execution/Fiber.js';

export class Log extends FlowNode {
public static Description = new NodeDescription(
'debug/log',
'Action',
'Debug Log',
(description, graph) => new Log(description, graph)
);
public static Description = (logger: ILogger) =>
new NodeDescription(
'debug/log',
'Action',
'Debug Log',
(description, graph) => new Log(description, graph, logger)
);
constructor(description: NodeDescription, graph: Graph) {
constructor(
description: NodeDescription,
graph: Graph,
private readonly logger: ILogger
) {
super(

@@ -27,6 +32,5 @@ description,

triggered(fiber: Fiber, triggeredSocketName: string) {
const logger = this.graph.registry.abstractions.get<ILogger>('ILogger');
logger.info(this.readInput('text'));
this.logger.info(this.readInput('text'));
fiber.commit(this, 'flow');
}
}

@@ -11,10 +11,16 @@ import { Assert } from '../../../Diagnostics/Assert.js';

export class LifecycleOnEnd extends EventNode {
public static Description = new NodeDescription(
'lifecycle/onEnd',
'Event',
'On End',
(description, graph) => new LifecycleOnEnd(description, graph)
);
public static Description = (lifecycleEventEmitter: ILifecycleEventEmitter) =>
new NodeDescription(
'lifecycle/onEnd',
'Event',
'On End',
(description, graph) =>
new LifecycleOnEnd(description, graph, lifecycleEventEmitter)
);
constructor(description: NodeDescription, graph: Graph) {
constructor(
description: NodeDescription,
graph: Graph,
private readonly lifecycleEventEmitter: ILifecycleEventEmitter
) {
super(description, graph, [], [new Socket('flow', 'flow')]);

@@ -31,7 +37,3 @@ }

const lifecycleEvents =
engine.graph.registry.abstractions.get<ILifecycleEventEmitter>(
'ILifecycleEventEmitter'
);
lifecycleEvents.endEvent.removeListener(this.onEndEvent);
this.lifecycleEventEmitter.endEvent.removeListener(this.onEndEvent);
}

@@ -42,9 +44,5 @@

if (this.onEndEvent !== undefined) {
const lifecycleEvents =
engine.graph.registry.abstractions.get<ILifecycleEventEmitter>(
'ILifecycleEventEmitter'
);
lifecycleEvents.endEvent.removeListener(this.onEndEvent);
this.lifecycleEventEmitter.endEvent.removeListener(this.onEndEvent);
}
}
}

@@ -11,10 +11,16 @@ import { Assert } from '../../../Diagnostics/Assert.js';

export class LifecycleOnStart extends EventNode {
public static Description = new NodeDescription(
'lifecycle/onStart',
'Event',
'On Start',
(description, graph) => new LifecycleOnStart(description, graph)
);
public static Description = (lifecycleEventEmitter: ILifecycleEventEmitter) =>
new NodeDescription(
'lifecycle/onStart',
'Event',
'On Start',
(description, graph) =>
new LifecycleOnStart(description, graph, lifecycleEventEmitter)
);
constructor(description: NodeDescription, graph: Graph) {
constructor(
description: NodeDescription,
graph: Graph,
private readonly lifecycleEventEmitter: ILifecycleEventEmitter
) {
super(description, graph, [], [new Socket('flow', 'flow')]);

@@ -31,7 +37,3 @@ }

const lifecycleEvents =
engine.graph.registry.abstractions.get<ILifecycleEventEmitter>(
'ILifecycleEventEmitter'
);
lifecycleEvents.startEvent.addListener(this.onStartEvent);
this.lifecycleEventEmitter.startEvent.addListener(this.onStartEvent);
}

@@ -42,9 +44,5 @@

if (this.onStartEvent !== undefined) {
const lifecycleEvents =
engine.graph.registry.abstractions.get<ILifecycleEventEmitter>(
'ILifecycleEventEmitter'
);
lifecycleEvents.startEvent.removeListener(this.onStartEvent);
this.lifecycleEventEmitter.startEvent.removeListener(this.onStartEvent);
}
}
}

@@ -11,10 +11,16 @@ import { Assert } from '../../../Diagnostics/Assert.js';

export class LifecycleOnTick extends EventNode {
public static Description = new NodeDescription(
'lifecycle/onTick',
'Event',
'On Tick',
(description, graph) => new LifecycleOnTick(description, graph)
);
public static Description = (lifecycleEventEmitter: ILifecycleEventEmitter) =>
new NodeDescription(
'lifecycle/onTick',
'Event',
'On Tick',
(description, graph) =>
new LifecycleOnTick(description, graph, lifecycleEventEmitter)
);
constructor(description: NodeDescription, graph: Graph) {
constructor(
description: NodeDescription,
graph: Graph,
private readonly lifecycleEventEmitter: ILifecycleEventEmitter
) {
super(

@@ -46,7 +52,3 @@ description,

const lifecycleEvents =
engine.graph.registry.abstractions.get<ILifecycleEventEmitter>(
'ILifecycleEventEmitter'
);
lifecycleEvents.tickEvent.addListener(this.onTickEvent);
this.lifecycleEventEmitter.tickEvent.addListener(this.onTickEvent);
}

@@ -57,9 +59,5 @@

if (this.onTickEvent !== undefined) {
const lifecycleEvents =
engine.graph.registry.abstractions.get<ILifecycleEventEmitter>(
'ILifecycleEventEmitter'
);
lifecycleEvents.tickEvent.removeListener(this.onTickEvent);
this.lifecycleEventEmitter.tickEvent.removeListener(this.onTickEvent);
}
}
}
/* eslint-disable max-len */
import { getNodeDescriptions } from '../../Nodes/Registry/NodeDescription.js';
import { Registry } from '../../Registry.js';
import { DefaultLogger } from './Abstractions/Drivers/DefaultLogger.js';
import { ManualLifecycleEventEmitter } from './Abstractions/Drivers/ManualLifecycleEventEmitter.js';
import { ILifecycleEventEmitter } from './Abstractions/ILifecycleEventEmitter.js';
import { ILogger } from './Abstractions/ILogger.js';
import { ExpectTrue as AssertExpectTrue } from './Debug/AssertExpectTrue.js';

@@ -24,3 +28,7 @@ import { Log as DebugLog } from './Debug/DebugLog.js';

export function registerCoreProfile(registry: Registry) {
export function registerCoreProfile(
registry: Registry,
logger: ILogger = new DefaultLogger(),
lifecycleEventEmitter: ILifecycleEventEmitter = new ManualLifecycleEventEmitter()
) {
const { nodes, values } = registry;

@@ -42,3 +50,3 @@

nodes.register(DebugLog.Description);
nodes.register(DebugLog.Description(logger));
nodes.register(AssertExpectTrue.Description);

@@ -48,5 +56,5 @@

nodes.register(LifecycleOnStart.Description);
nodes.register(LifecycleOnEnd.Description);
nodes.register(LifecycleOnTick.Description);
nodes.register(LifecycleOnStart.Description(lifecycleEventEmitter));
nodes.register(LifecycleOnEnd.Description(lifecycleEventEmitter));
nodes.register(LifecycleOnTick.Description(lifecycleEventEmitter));

@@ -53,0 +61,0 @@ // flow control

@@ -10,3 +10,3 @@ import { Fiber } from '../../../Execution/Fiber.js';

export class SetSceneProperty extends FlowNode {
public static GetDescriptions(...valueTypeNames: string[]) {
public static GetDescriptions(scene: IScene, ...valueTypeNames: string[]) {
return valueTypeNames.map(

@@ -19,3 +19,3 @@ (valueTypeName) =>

(description, graph) =>
new SetSceneProperty(description, graph, valueTypeName)
new SetSceneProperty(description, graph, valueTypeName, scene)
)

@@ -28,3 +28,4 @@ );

graph: Graph,
public readonly valueTypeName: string
public readonly valueTypeName: string,
private readonly scene: IScene
) {

@@ -44,4 +45,3 @@ super(

triggered(fiber: Fiber, triggeringSocketName: string) {
const scene =
fiber.engine.graph.registry.abstractions.get<IScene>('IScene');
const scene = this.scene;
const value = this.readInput('value');

@@ -48,0 +48,0 @@ scene.setProperty(this.readInput('jsonPath'), this.valueTypeName, value);

@@ -9,3 +9,3 @@ import { Graph } from '../../../Graphs/Graph.js';

export class GetSceneProperty extends ImmediateNode {
public static GetDescriptions(...valueTypeNames: string[]) {
public static GetDescriptions(scene: IScene, ...valueTypeNames: string[]) {
return valueTypeNames.map(

@@ -18,3 +18,3 @@ (valueTypeName) =>

(description, graph) =>
new GetSceneProperty(description, graph, valueTypeName)
new GetSceneProperty(description, graph, valueTypeName, scene)
)

@@ -27,3 +27,4 @@ );

graph: Graph,
public readonly valueTypeName: string
public readonly valueTypeName: string,
private readonly scene: IScene
) {

@@ -36,7 +37,5 @@ super(

() => {
const sceneGraph =
this.graph.registry.abstractions.get<IScene>('IScene');
this.writeOutput(
'value',
sceneGraph.getProperty(this.readInput('jsonPath'), valueTypeName)
this.scene.getProperty(this.readInput('jsonPath'), valueTypeName)
);

@@ -43,0 +42,0 @@ }

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

import { DummyScene } from '../../../examples/exec-graph/DummyScene';
import * as flashSuzanneJson from '../../../graphs/scene/actions/FlashSuzanne.json';

@@ -22,3 +23,3 @@ import * as hierarchyJson from '../../../graphs/scene/actions/Hierarchy.json';

registerCoreProfile(registry);
registerSceneProfile(registry);
registerSceneProfile(registry, new DummyScene(registry));

@@ -25,0 +26,0 @@ Logger.onWarn.clear();

@@ -0,1 +1,4 @@

import { Object3D } from 'three';
import { DummyScene } from '../../../examples/exec-graph/DummyScene.js';
import { ThreeScene } from '../../../examples/three/ThreeScene.js';
import { validateNodeRegistry } from '../../Nodes/Validation/validateNodeRegistry.js';

@@ -5,2 +8,3 @@ import { Registry } from '../../Registry.js';

import { registerCoreProfile } from '../Core/registerCoreProfile.js';
import { IScene } from './Abstractions/IScene.js';
import { registerSceneProfile } from './registerSceneProfile.js';

@@ -11,3 +15,3 @@

registerCoreProfile(registry);
registerSceneProfile(registry);
registerSceneProfile(registry, new DummyScene(registry));

@@ -14,0 +18,0 @@ test('validate node registry', () => {

@@ -5,2 +5,3 @@ /* eslint-disable max-len */

import { registerSerializersForValueType } from '../Core/registerSerializersForValueType.js';
import { IScene } from './Abstractions/IScene.js';
import { SetSceneProperty } from './Actions/SetSceneProperty.js';

@@ -22,3 +23,3 @@ import { OnSceneNodeClick } from './Events/OnSceneNodeClick.js';

export function registerSceneProfile(registry: Registry) {
export function registerSceneProfile(registry: Registry, scene: IScene) {
const { values, nodes } = registry;

@@ -48,4 +49,8 @@

const allValueTypeNames = values.getAllNames();
nodes.register(...SetSceneProperty.GetDescriptions(...allValueTypeNames));
nodes.register(...GetSceneProperty.GetDescriptions(...allValueTypeNames));
nodes.register(
...SetSceneProperty.GetDescriptions(scene, ...allValueTypeNames)
);
nodes.register(
...GetSceneProperty.GetDescriptions(scene, ...allValueTypeNames)
);

@@ -52,0 +57,0 @@ const newValueTypeNames = ['vec2', 'vec3', 'vec4', 'quat', 'euler', 'color'];

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

import { AbstractionsRegistry } from './Abstractions/AbstractionsRegistry.js';
import { NodeTypeRegistry } from './Nodes/Registry/NodeTypeRegistry.js';

@@ -6,5 +5,4 @@ import { ValueTypeRegistry } from './Values/ValueTypeRegistry.js';

export class Registry {
public readonly abstractions = new AbstractionsRegistry();
public readonly values = new ValueTypeRegistry();
public readonly nodes = new NodeTypeRegistry();
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc