@babylonjs/core 6.33.1 → 6.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.js +2 -2
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/animationGroupMask.d.ts +4 -0
- package/Animations/animationGroupMask.js +4 -0
- package/Animations/animationGroupMask.js.map +1 -1
- package/Compute/computeShader.d.ts +5 -0
- package/Compute/computeShader.js +42 -32
- package/Compute/computeShader.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js +4 -2
- package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/engine.d.ts +16 -10
- package/Engines/thinEngine.js +3 -2
- package/Engines/thinEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.d.ts +296 -0
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js +758 -0
- package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js.map +1 -0
- package/FlowGraph/Blocks/Data/Math/index.d.ts +1 -5
- package/FlowGraph/Blocks/Data/Math/index.js +1 -5
- package/FlowGraph/Blocks/Data/Math/index.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +3 -3
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +3 -3
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js +5 -0
- package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +25 -0
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +22 -0
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +11 -5
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +12 -6
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.d.ts +19 -0
- package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js +22 -0
- package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/index.d.ts +1 -0
- package/FlowGraph/Blocks/Data/index.js +1 -0
- package/FlowGraph/Blocks/Data/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +10 -5
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +15 -5
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +2 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js +3 -2
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +3 -3
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +0 -5
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +2 -3
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +3 -3
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js +2 -2
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +3 -3
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +3 -3
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +13 -5
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +14 -12
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.d.ts +2 -6
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +3 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.d.ts +16 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js +26 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +3 -3
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.d.ts +1 -6
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js +4 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +2 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +4 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +3 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +6 -5
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/index.d.ts +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/index.js +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/index.js.map +1 -1
- package/FlowGraph/Blocks/Execution/{flowGraphLogBlock.d.ts → flowGraphConsoleLogBlock.d.ts} +3 -2
- package/FlowGraph/Blocks/Execution/{flowGraphLogBlock.js → flowGraphConsoleLogBlock.js} +7 -6
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -0
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +16 -8
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +17 -10
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +4 -3
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +7 -6
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +12 -7
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +10 -9
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/index.d.ts +1 -2
- package/FlowGraph/Blocks/Execution/index.js +1 -3
- package/FlowGraph/Blocks/Execution/index.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +3 -1
- package/FlowGraph/flowGraph.js +6 -2
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +6 -2
- package/FlowGraph/flowGraphAsyncExecutionBlock.js +2 -1
- package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphBlock.d.ts +7 -2
- package/FlowGraph/flowGraphBlock.js +36 -14
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +9 -5
- package/FlowGraph/flowGraphContext.js +7 -2
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +4 -5
- package/FlowGraph/flowGraphCoordinator.js +12 -7
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphEventBlock.js +1 -1
- package/FlowGraph/flowGraphEventBlock.js.map +1 -1
- package/FlowGraph/flowGraphExecutionBlock.d.ts +3 -2
- package/FlowGraph/flowGraphExecutionBlock.js +7 -11
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphPath.d.ts +20 -2
- package/FlowGraph/flowGraphPath.js +27 -7
- package/FlowGraph/flowGraphPath.js.map +1 -1
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +3 -3
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +3 -3
- package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -1
- package/FlowGraph/index.d.ts +3 -0
- package/FlowGraph/index.js +3 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/serialization.js +20 -6
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +33 -0
- package/FlowGraph/typeDefinitions.js +2 -0
- package/FlowGraph/typeDefinitions.js.map +1 -0
- package/Lights/light.d.ts +15 -0
- package/Lights/light.js +18 -0
- package/Lights/light.js.map +1 -1
- package/Lights/shadowLight.d.ts +18 -1
- package/Lights/shadowLight.js +34 -1
- package/Lights/shadowLight.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.js +9 -1
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/abstractMesh.js +3 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/XR/features/WebXRMeshDetector.d.ts +14 -2
- package/XR/features/WebXRMeshDetector.js +43 -8
- package/XR/features/WebXRMeshDetector.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -2
- package/scene.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.d.ts +0 -172
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.js +0 -235
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.js.map +0 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.d.ts +0 -269
- package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js +0 -429
- package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js.map +0 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.d.ts +0 -115
- package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.js +0 -146
- package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.js.map +0 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.d.ts +0 -155
- package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.js +0 -190
- package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.js.map +0 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.d.ts +0 -116
- package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.js +0 -144
- package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.js.map +0 -1
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +0 -1
|
@@ -3,6 +3,7 @@ import { FlowGraphConnectionType } from "./flowGraphConnection.js";
|
|
|
3
3
|
import { FlowGraphDataConnection } from "./flowGraphDataConnection.js";
|
|
4
4
|
import { Tools } from "../Misc/tools.js";
|
|
5
5
|
import { FlowGraphExecutionBlock } from "./flowGraphExecutionBlock.js";
|
|
6
|
+
import { defaultValueParseFunction, defaultValueSerializationFunction } from "./serialization.js";
|
|
6
7
|
/**
|
|
7
8
|
* @experimental
|
|
8
9
|
* A block in a flow graph. The most basic form
|
|
@@ -45,7 +46,10 @@ export class FlowGraphBlock {
|
|
|
45
46
|
getDataInput(name) {
|
|
46
47
|
return this.dataInputs.find((i) => i.name === name);
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
getDataOutput(name) {
|
|
50
|
+
return this.dataOutputs.find((i) => i.name === name);
|
|
51
|
+
}
|
|
52
|
+
serialize(serializationObject = {}, _valueSerializeFunction = defaultValueSerializationFunction) {
|
|
49
53
|
serializationObject.uniqueId = this.uniqueId;
|
|
50
54
|
serializationObject.config = {};
|
|
51
55
|
if (this.config) {
|
|
@@ -68,35 +72,53 @@ export class FlowGraphBlock {
|
|
|
68
72
|
getClassName() {
|
|
69
73
|
return "FGBlock";
|
|
70
74
|
}
|
|
71
|
-
static Parse(serializationObject) {
|
|
75
|
+
static Parse(serializationObject, scene, valueParseFunction = defaultValueParseFunction) {
|
|
72
76
|
const classType = Tools.Instantiate(serializationObject.className);
|
|
73
77
|
const parsedConfig = {};
|
|
74
78
|
if (serializationObject.config) {
|
|
75
79
|
for (const key in serializationObject.config) {
|
|
76
|
-
|
|
77
|
-
if (value && value.className) {
|
|
78
|
-
const valueClassType = Tools.Instantiate(value.className);
|
|
79
|
-
parsedConfig[key] = valueClassType.prototype.Parse(value);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
parsedConfig[key] = value;
|
|
83
|
-
}
|
|
80
|
+
parsedConfig[key] = valueParseFunction(key, serializationObject.config, scene);
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
83
|
const obj = new classType(parsedConfig);
|
|
87
84
|
obj.uniqueId = serializationObject.uniqueId;
|
|
88
85
|
for (let i = 0; i < serializationObject.dataInputs.length; i++) {
|
|
89
|
-
obj.
|
|
86
|
+
const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);
|
|
87
|
+
if (dataInput) {
|
|
88
|
+
dataInput.deserialize(serializationObject.dataInputs[i]);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new Error("Could not find data input with name " + serializationObject.dataInputs[i].name + " in block " + serializationObject.className);
|
|
92
|
+
}
|
|
90
93
|
}
|
|
91
94
|
for (let i = 0; i < serializationObject.dataOutputs.length; i++) {
|
|
92
|
-
obj.
|
|
95
|
+
const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);
|
|
96
|
+
if (dataOutput) {
|
|
97
|
+
dataOutput.deserialize(serializationObject.dataOutputs[i]);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new Error("Could not find data output with name " + serializationObject.dataOutputs[i].name + " in block " + serializationObject.className);
|
|
101
|
+
}
|
|
93
102
|
}
|
|
103
|
+
obj.metadata = serializationObject.metadata;
|
|
94
104
|
if (obj instanceof FlowGraphExecutionBlock) {
|
|
95
105
|
for (let i = 0; i < serializationObject.signalInputs.length; i++) {
|
|
96
|
-
obj.
|
|
106
|
+
const signalInput = obj.getSignalInput(serializationObject.signalInputs[i].name);
|
|
107
|
+
if (signalInput) {
|
|
108
|
+
signalInput.deserialize(serializationObject.signalInputs[i]);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
throw new Error("Could not find signal input with name " + serializationObject.signalInputs[i].name + " in block " + serializationObject.className);
|
|
112
|
+
}
|
|
97
113
|
}
|
|
98
114
|
for (let i = 0; i < serializationObject.signalOutputs.length; i++) {
|
|
99
|
-
obj.
|
|
115
|
+
const signalOutput = obj.getSignalOutput(serializationObject.signalOutputs[i].name);
|
|
116
|
+
if (signalOutput) {
|
|
117
|
+
signalOutput.deserialize(serializationObject.signalOutputs[i]);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new Error("Could not find signal output with name " + serializationObject.signalOutputs[i].name + " in block " + serializationObject.className);
|
|
121
|
+
}
|
|
100
122
|
}
|
|
101
123
|
}
|
|
102
124
|
return obj;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,KAAK,EAAE,yBAAwB;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAMpE;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAkBvB,sEAAsE;IACtE,YAA6B,MAAqC;QAArC,WAAM,GAAN,MAAM,C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AAC;IACf,CAAC;CACJ","sourcesContent":["import { RandomGUID } from \"../Misc/guid\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { RichType } from \"./flowGraphRichTypes\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\n\r\nexport interface IFlowGraphBlockConfiguration {\r\n name?: string;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block in a flow graph. The most basic form\r\n * of a block has inputs and outputs that contain\r\n * data.\r\n */\r\nexport class FlowGraphBlock {\r\n /**\r\n * A randomly generated GUID for each block.\r\n */\r\n public uniqueId = RandomGUID();\r\n /**\r\n * The name of the block.\r\n */\r\n public name: string;\r\n /**\r\n * The data inputs of the block.\r\n */\r\n public dataInputs: FlowGraphDataConnection<any>[];\r\n /**\r\n * The data outputs of the block.\r\n */\r\n public dataOutputs: FlowGraphDataConnection<any>[];\r\n\r\n /** Constructor is protected so only subclasses can be instantiated */\r\n protected constructor(public config?: IFlowGraphBlockConfiguration) {\r\n this.configure();\r\n }\r\n\r\n public configure() {\r\n // overriden in child classes, uses config\r\n this.name = this.config?.name ?? this.getClassName();\r\n this.dataInputs = [];\r\n this.dataOutputs = [];\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _updateOutputs(_context: FlowGraphContext): void {\r\n // empty by default, overriden in data blocks\r\n }\r\n\r\n public registerDataInput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T> {\r\n const input = new FlowGraphDataConnection(name, FlowGraphConnectionType.Input, this, className);\r\n this.dataInputs.push(input);\r\n return input;\r\n }\r\n\r\n public registerDataOutput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T> {\r\n const output = new FlowGraphDataConnection(name, FlowGraphConnectionType.Output, this, className);\r\n this.dataOutputs.push(output);\r\n return output;\r\n }\r\n\r\n public getDataInput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataInputs.find((i) => i.name === name);\r\n }\r\n\r\n public serialize(serializationObject: any = {}) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject.config = {};\r\n if (this.config) {\r\n serializationObject.config[\"name\"] = this.config.name;\r\n }\r\n serializationObject.dataInputs = [];\r\n serializationObject.dataOutputs = [];\r\n serializationObject.className = this.getClassName();\r\n for (const input of this.dataInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.dataInputs.push(serializedInput);\r\n }\r\n for (const output of this.dataOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.dataOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGBlock\";\r\n }\r\n\r\n public static Parse(serializationObject: any): FlowGraphBlock {\r\n const classType = Tools.Instantiate(serializationObject.className);\r\n const parsedConfig: any = {};\r\n if (serializationObject.config) {\r\n for (const key in serializationObject.config) {\r\n const value = serializationObject.config[key];\r\n if (value && value.className) {\r\n const valueClassType = Tools.Instantiate(value.className);\r\n parsedConfig[key] = valueClassType.prototype.Parse(value);\r\n } else {\r\n parsedConfig[key] = value;\r\n }\r\n }\r\n }\r\n const obj = new classType(parsedConfig);\r\n obj.uniqueId = serializationObject.uniqueId;\r\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\r\n obj.dataInputs[i].deserialize(serializationObject.dataInputs[i]);\r\n }\r\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\r\n obj.dataOutputs[i].deserialize(serializationObject.dataOutputs[i]);\r\n }\r\n if (obj instanceof FlowGraphExecutionBlock) {\r\n for (let i = 0; i < serializationObject.signalInputs.length; i++) {\r\n obj.signalInputs[i].deserialize(serializationObject.signalInputs[i]);\r\n }\r\n for (let i = 0; i < serializationObject.signalOutputs.length; i++) {\r\n obj.signalOutputs[i].deserialize(serializationObject.signalOutputs[i]);\r\n }\r\n }\r\n return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EAAE,EAAE;gBAC/D,MAAM,YAAY,GAAG,GAAG,CAAC,eAAe,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBACpF,IAAI,YAAY,EAAE;oBACd,YAAY,CAAC,WAAW,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;iBAClE;qBAAM;oBACH,MAAM,IAAI,KAAK,CAAC,yCAAyC,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,YAAY,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;iBACzJ;aACJ;SACJ;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ","sourcesContent":["import { RandomGUID } from \"../Misc/guid\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { RichType } from \"./flowGraphRichTypes\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { ISerializedFlowGraphBlock } from \"./typeDefinitions\";\r\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { Scene } from \"../scene\";\r\n\r\nexport interface IFlowGraphBlockConfiguration {\r\n name?: string;\r\n [extraPropertyKey: string]: any;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * A block in a flow graph. The most basic form\r\n * of a block has inputs and outputs that contain\r\n * data.\r\n */\r\nexport class FlowGraphBlock {\r\n /**\r\n * A randomly generated GUID for each block.\r\n */\r\n public uniqueId = RandomGUID();\r\n /**\r\n * The name of the block.\r\n */\r\n public name: string;\r\n /**\r\n * The data inputs of the block.\r\n */\r\n public dataInputs: FlowGraphDataConnection<any>[];\r\n /**\r\n * The data outputs of the block.\r\n */\r\n public dataOutputs: FlowGraphDataConnection<any>[];\r\n\r\n public metadata: any;\r\n\r\n /** Constructor is protected so only subclasses can be instantiated */\r\n protected constructor(public config?: IFlowGraphBlockConfiguration) {\r\n this.configure();\r\n }\r\n\r\n public configure() {\r\n // overriden in child classes, uses config\r\n this.name = this.config?.name ?? this.getClassName();\r\n this.dataInputs = [];\r\n this.dataOutputs = [];\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _updateOutputs(_context: FlowGraphContext): void {\r\n // empty by default, overriden in data blocks\r\n }\r\n\r\n public registerDataInput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T> {\r\n const input = new FlowGraphDataConnection(name, FlowGraphConnectionType.Input, this, className);\r\n this.dataInputs.push(input);\r\n return input;\r\n }\r\n\r\n public registerDataOutput<T>(name: string, className: RichType<T>): FlowGraphDataConnection<T> {\r\n const output = new FlowGraphDataConnection(name, FlowGraphConnectionType.Output, this, className);\r\n this.dataOutputs.push(output);\r\n return output;\r\n }\r\n\r\n public getDataInput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataInputs.find((i) => i.name === name);\r\n }\r\n\r\n public getDataOutput(name: string): FlowGraphDataConnection<any> | undefined {\r\n return this.dataOutputs.find((i) => i.name === name);\r\n }\r\n\r\n public serialize(serializationObject: any = {}, _valueSerializeFunction: (key: string, value: any, serializationObject: any) => any = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject.config = {};\r\n if (this.config) {\r\n serializationObject.config[\"name\"] = this.config.name;\r\n }\r\n serializationObject.dataInputs = [];\r\n serializationObject.dataOutputs = [];\r\n serializationObject.className = this.getClassName();\r\n for (const input of this.dataInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.dataInputs.push(serializedInput);\r\n }\r\n for (const output of this.dataOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.dataOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGBlock\";\r\n }\r\n\r\n public static Parse(\r\n serializationObject: ISerializedFlowGraphBlock,\r\n scene: Scene,\r\n valueParseFunction: (key: string, serializationObject: any, scene: Scene) => any = defaultValueParseFunction\r\n ): FlowGraphBlock {\r\n const classType = Tools.Instantiate(serializationObject.className);\r\n const parsedConfig: any = {};\r\n if (serializationObject.config) {\r\n for (const key in serializationObject.config) {\r\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, scene);\r\n }\r\n }\r\n const obj = new classType(parsedConfig);\r\n obj.uniqueId = serializationObject.uniqueId;\r\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\r\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\r\n if (dataInput) {\r\n dataInput.deserialize(serializationObject.dataInputs[i]);\r\n } else {\r\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\r\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\r\n if (dataOutput) {\r\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\r\n } else {\r\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n obj.metadata = serializationObject.metadata;\r\n if (obj instanceof FlowGraphExecutionBlock) {\r\n for (let i = 0; i < serializationObject.signalInputs.length; i++) {\r\n const signalInput = obj.getSignalInput(serializationObject.signalInputs[i].name);\r\n if (signalInput) {\r\n signalInput.deserialize(serializationObject.signalInputs[i]);\r\n } else {\r\n throw new Error(\"Could not find signal input with name \" + serializationObject.signalInputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n for (let i = 0; i < serializationObject.signalOutputs.length; i++) {\r\n const signalOutput = obj.getSignalOutput(serializationObject.signalOutputs[i].name);\r\n if (signalOutput) {\r\n signalOutput.deserialize(serializationObject.signalOutputs[i]);\r\n } else {\r\n throw new Error(\"Could not find signal output with name \" + serializationObject.signalOutputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n }\r\n return obj;\r\n }\r\n}\r\n"]}
|
|
@@ -3,6 +3,7 @@ import type { FlowGraphAsyncExecutionBlock } from "./flowGraphAsyncExecutionBloc
|
|
|
3
3
|
import type { FlowGraphBlock } from "./flowGraphBlock";
|
|
4
4
|
import type { FlowGraphDataConnection } from "./flowGraphDataConnection";
|
|
5
5
|
import type { FlowGraph } from "./flowGraph";
|
|
6
|
+
import type { ISerializedFlowGraphContext } from "./typeDefinitions";
|
|
6
7
|
import type { FlowGraphCoordinator } from "./flowGraphCoordinator";
|
|
7
8
|
import { Observable } from "../Misc/observable";
|
|
8
9
|
/**
|
|
@@ -32,12 +33,9 @@ export declare class FlowGraphContext {
|
|
|
32
33
|
*/
|
|
33
34
|
uniqueId: string;
|
|
34
35
|
/**
|
|
35
|
-
* @internal
|
|
36
36
|
* These are the variables defined by a user.
|
|
37
37
|
*/
|
|
38
|
-
_userVariables
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
};
|
|
38
|
+
private _userVariables;
|
|
41
39
|
/**
|
|
42
40
|
* These are the variables set by the blocks.
|
|
43
41
|
*/
|
|
@@ -82,6 +80,12 @@ export declare class FlowGraphContext {
|
|
|
82
80
|
* @returns
|
|
83
81
|
*/
|
|
84
82
|
getVariable(name: string): any;
|
|
83
|
+
/**
|
|
84
|
+
* Gets all user variables map
|
|
85
|
+
*/
|
|
86
|
+
get userVariables(): {
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
};
|
|
85
89
|
private _getUniqueIdPrefixedName;
|
|
86
90
|
/**
|
|
87
91
|
* Set an internal execution variable
|
|
@@ -186,5 +190,5 @@ export declare class FlowGraphContext {
|
|
|
186
190
|
* @param valueParseFunction a function to parse complex values
|
|
187
191
|
* @returns
|
|
188
192
|
*/
|
|
189
|
-
static Parse(serializationObject:
|
|
193
|
+
static Parse(serializationObject: ISerializedFlowGraphContext, graph: FlowGraph, valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any): FlowGraphContext;
|
|
190
194
|
}
|
|
@@ -17,7 +17,6 @@ export class FlowGraphContext {
|
|
|
17
17
|
*/
|
|
18
18
|
this.uniqueId = RandomGUID();
|
|
19
19
|
/**
|
|
20
|
-
* @internal
|
|
21
20
|
* These are the variables defined by a user.
|
|
22
21
|
*/
|
|
23
22
|
this._userVariables = {};
|
|
@@ -68,6 +67,12 @@ export class FlowGraphContext {
|
|
|
68
67
|
getVariable(name) {
|
|
69
68
|
return this._userVariables[name];
|
|
70
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets all user variables map
|
|
72
|
+
*/
|
|
73
|
+
get userVariables() {
|
|
74
|
+
return this._userVariables;
|
|
75
|
+
}
|
|
71
76
|
_getUniqueIdPrefixedName(obj, name) {
|
|
72
77
|
return `${obj.uniqueId}_${name}`;
|
|
73
78
|
}
|
|
@@ -225,7 +230,7 @@ export class FlowGraphContext {
|
|
|
225
230
|
* @param valueParseFunction a function to parse complex values
|
|
226
231
|
* @returns
|
|
227
232
|
*/
|
|
228
|
-
static Parse(serializationObject
|
|
233
|
+
static Parse(serializationObject, graph, valueParseFunction = defaultValueParseFunction) {
|
|
229
234
|
const result = graph.createContext();
|
|
230
235
|
result.uniqueId = serializationObject.uniqueId;
|
|
231
236
|
for (const key in serializationObject._userVariables) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAgBhD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAqCzB,YAAY,MAAsC;QApClD;;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Aa,EAAE,CAAC;QACrC,MAAM,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAC/C,KAAK,MAAM,GAAG,IAAI,mBAAmB,CAAC,cAAc,EAAE;YAClD,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,CAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACvG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACtC;QACD,KAAK,MAAM,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,EAAE;YACrD,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1G,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACzC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA7PU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n * @experimental\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n}\r\n/**\r\n * @experimental\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * @internal\r\n * These are the variables defined by a user.\r\n */\r\n public _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name\r\n * @returns\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name\r\n * @param value\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name\r\n * @returns\r\n */\r\n public getVariable(name: string): any {\r\n return this._userVariables[name];\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable(block: FlowGraphBlock, name: string, defaultValue?: any): any {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n this._pendingBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGContext\";\r\n }\r\n\r\n /**\r\n * Parses a context\r\n * @param serializationObject the object containing the context serialization values\r\n * @param graph the graph to which the context should belong\r\n * @param valueParseFunction a function to parse complex values\r\n * @returns\r\n */\r\n public static Parse(\r\n serializationObject: any = {},\r\n graph: FlowGraph,\r\n valueParseFunction: (key: string, serializationObject: any, scene: Scene) => any = defaultValueParseFunction\r\n ): FlowGraphContext {\r\n const result = graph.createContext();\r\n result.uniqueId = serializationObject.uniqueId;\r\n for (const key in serializationObject._userVariables) {\r\n const value = valueParseFunction(key, serializationObject._userVariables, result._configuration.scene);\r\n result._userVariables[key] = value;\r\n }\r\n for (const key in serializationObject._connectionValues) {\r\n const value = valueParseFunction(key, serializationObject._connectionValues, result._configuration.scene);\r\n result._connectionValues[key] = value;\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAgBhD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAoCzB,YAAY,MAAsC;QAnClD;;WAEG;QAEI,aAAQ,GAAG,UAAU,EAAE,CAAC;QAC/B;;WAEG;QACK,mBAAc,GAA2B,EAAE,CAAC;QACpD;;WAEG;QACK,wBAAmB,GAA2B,EAAE,CAAC;QACzD;;WAEG;QACK,sBAAiB,GAA2B,EAAE,CAAC;QAKvD;;WAEG;QACK,mBAAc,GAAmC,EAAE,CAAC;QAC5D;;;WAGG;QACK,iBAAY,GAAG,CAAC,CAAC;QACzB;;WAEG;QACI,6BAAwB,GAA+B,IAAI,UAAU,EAAkB,CAAC;QAG3F,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,IAAY;QAC3B,OAAO,IA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EAAE;YACrD,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,CAAC,iBAAiB,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1G,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACzC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAnQU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport type { ISerializedFlowGraphContext } from \"./typeDefinitions\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n * @experimental\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n}\r\n/**\r\n * @experimental\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * These are the variables defined by a user.\r\n */\r\n private _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name\r\n * @returns\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name\r\n * @param value\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name\r\n * @returns\r\n */\r\n public getVariable(name: string): any {\r\n return this._userVariables[name];\r\n }\r\n\r\n /**\r\n * Gets all user variables map\r\n */\r\n public get userVariables() {\r\n return this._userVariables;\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable(block: FlowGraphBlock, name: string, defaultValue?: any): any {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n this._pendingBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGContext\";\r\n }\r\n\r\n /**\r\n * Parses a context\r\n * @param serializationObject the object containing the context serialization values\r\n * @param graph the graph to which the context should belong\r\n * @param valueParseFunction a function to parse complex values\r\n * @returns\r\n */\r\n public static Parse(\r\n serializationObject: ISerializedFlowGraphContext,\r\n graph: FlowGraph,\r\n valueParseFunction: (key: string, serializationObject: any, scene: Scene) => any = defaultValueParseFunction\r\n ): FlowGraphContext {\r\n const result = graph.createContext();\r\n result.uniqueId = serializationObject.uniqueId;\r\n for (const key in serializationObject._userVariables) {\r\n const value = valueParseFunction(key, serializationObject._userVariables, result._configuration.scene);\r\n result._userVariables[key] = value;\r\n }\r\n for (const key in serializationObject._connectionValues) {\r\n const value = valueParseFunction(key, serializationObject._connectionValues, result._configuration.scene);\r\n result._connectionValues[key] = value;\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -16,7 +16,7 @@ export declare class IFlowGraphCoordinatorConfiguration {
|
|
|
16
16
|
* It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator
|
|
17
17
|
*/
|
|
18
18
|
export declare class FlowGraphCoordinator {
|
|
19
|
-
|
|
19
|
+
config: IFlowGraphCoordinatorConfiguration;
|
|
20
20
|
/**
|
|
21
21
|
* @internal
|
|
22
22
|
* A list of all the coordinators per scene. Will be used by the inspector
|
|
@@ -24,7 +24,7 @@ export declare class FlowGraphCoordinator {
|
|
|
24
24
|
static readonly SceneCoordinators: Map<Scene, FlowGraphCoordinator[]>;
|
|
25
25
|
private readonly _flowGraphs;
|
|
26
26
|
private _customEventsMap;
|
|
27
|
-
constructor(
|
|
27
|
+
constructor(config: IFlowGraphCoordinatorConfiguration);
|
|
28
28
|
/**
|
|
29
29
|
* Creates a new flow graph and adds it to the list of existing flow graphs
|
|
30
30
|
* @returns a new flow graph
|
|
@@ -46,10 +46,9 @@ export declare class FlowGraphCoordinator {
|
|
|
46
46
|
serialize(serializationObject: any, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void): void;
|
|
47
47
|
static Parse(serializedObject: any, scene: Scene, valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any): FlowGraphCoordinator;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param id the id of the event
|
|
51
|
-
* @returns the observable for the event
|
|
49
|
+
* Gets the list of flow graphs
|
|
52
50
|
*/
|
|
51
|
+
get flowGraphs(): FlowGraph[];
|
|
53
52
|
getCustomEventObservable(id: string): Observable<any>;
|
|
54
53
|
/**
|
|
55
54
|
* Notifies the observable for the given event id with the given data.
|
|
@@ -11,17 +11,17 @@ export class IFlowGraphCoordinatorConfiguration {
|
|
|
11
11
|
* It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator
|
|
12
12
|
*/
|
|
13
13
|
export class FlowGraphCoordinator {
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(config) {
|
|
15
15
|
var _a;
|
|
16
|
-
this.
|
|
16
|
+
this.config = config;
|
|
17
17
|
this._flowGraphs = [];
|
|
18
18
|
this._customEventsMap = new Map();
|
|
19
19
|
// When the scene is disposed, dispose all graphs currently running on it.
|
|
20
|
-
this.
|
|
20
|
+
this.config.scene.onDisposeObservable.add(() => {
|
|
21
21
|
this.dispose();
|
|
22
22
|
});
|
|
23
23
|
// Add itself to the SceneCoordinators list for the Inspector.
|
|
24
|
-
const coordinators = (_a = FlowGraphCoordinator.SceneCoordinators.get(this.
|
|
24
|
+
const coordinators = (_a = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene)) !== null && _a !== void 0 ? _a : [];
|
|
25
25
|
coordinators.push(this);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -29,7 +29,7 @@ export class FlowGraphCoordinator {
|
|
|
29
29
|
* @returns a new flow graph
|
|
30
30
|
*/
|
|
31
31
|
createGraph() {
|
|
32
|
-
const graph = new FlowGraph({ scene: this.
|
|
32
|
+
const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });
|
|
33
33
|
this._flowGraphs.push(graph);
|
|
34
34
|
return graph;
|
|
35
35
|
}
|
|
@@ -58,7 +58,7 @@ export class FlowGraphCoordinator {
|
|
|
58
58
|
this._flowGraphs.forEach((graph) => graph.dispose());
|
|
59
59
|
this._flowGraphs.length = 0;
|
|
60
60
|
// Remove itself from the SceneCoordinators list for the Inspector.
|
|
61
|
-
const coordinators = (_a = FlowGraphCoordinator.SceneCoordinators.get(this.
|
|
61
|
+
const coordinators = (_a = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene)) !== null && _a !== void 0 ? _a : [];
|
|
62
62
|
const index = coordinators.indexOf(this);
|
|
63
63
|
if (index !== -1) {
|
|
64
64
|
coordinators.splice(index, 1);
|
|
@@ -81,7 +81,12 @@ export class FlowGraphCoordinator {
|
|
|
81
81
|
return coordinator;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
84
|
+
* Gets the list of flow graphs
|
|
85
|
+
*/
|
|
86
|
+
get flowGraphs() {
|
|
87
|
+
return this._flowGraphs;
|
|
88
|
+
}
|
|
89
|
+
/* Get an observable that will be notified when the event with the given id is fired.
|
|
85
90
|
* @param id the id of the event
|
|
86
91
|
* @returns the observable for the event
|
|
87
92
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,MAAM,OAAO,kCAAkC;CAK9C;AACD;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAW7B,
|
|
1
|
+
{"version":3,"file":"flowGraphCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,MAAM,OAAO,kCAAkC;CAK9C;AACD;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAW7B,YAAmB,MAA0C;;QAA1C,WAAM,GAAN,MAAM,CAAoC;QAJ5C,gBAAW,GAAgB,EAAE,CAAC;QAEvC,qBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;QAG/D,0EAA0E;QAC1E,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;QAEH,8DAA8D;QAC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;IAED;;;;OAIG;IACH,iBAAiB,CAAC,EAAU,EAAE,IAAS;QACnC,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SACpC;IACL,CAAC;;AAhHD;;;GAGG;AACoB,sCAAiB,GAAuC,IAAI,GAAG,EAAE,AAAhD,CAAiD","sourcesContent":["import { Observable } from \"core/Misc/observable\";\r\nimport type { Scene } from \"../scene\";\r\nimport { FlowGraph } from \"./flowGraph\";\r\n\r\n/**\r\n * @experimental\r\n * Parameters used to create a flow graph engine.\r\n */\r\nexport class IFlowGraphCoordinatorConfiguration {\r\n /**\r\n * The scene that the flow graph engine belongs to.\r\n */\r\n scene: Scene;\r\n}\r\n/**\r\n * This class holds all of the existing flow graphs and is responsible for creating new ones.\r\n * It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator\r\n */\r\nexport class FlowGraphCoordinator {\r\n /**\r\n * @internal\r\n * A list of all the coordinators per scene. Will be used by the inspector\r\n */\r\n public static readonly SceneCoordinators: Map<Scene, FlowGraphCoordinator[]> = new Map();\r\n\r\n private readonly _flowGraphs: FlowGraph[] = [];\r\n\r\n private _customEventsMap: Map<string, Observable<any>> = new Map();\r\n\r\n constructor(public config: IFlowGraphCoordinatorConfiguration) {\r\n // When the scene is disposed, dispose all graphs currently running on it.\r\n this.config.scene.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n\r\n // Add itself to the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n coordinators.push(this);\r\n }\r\n\r\n /**\r\n * Creates a new flow graph and adds it to the list of existing flow graphs\r\n * @returns a new flow graph\r\n */\r\n createGraph(): FlowGraph {\r\n const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });\r\n this._flowGraphs.push(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * Removes a flow graph from the list of existing flow graphs and disposes it\r\n * @param graph the graph to remove\r\n */\r\n removeGraph(graph: FlowGraph) {\r\n const index = this._flowGraphs.indexOf(graph);\r\n if (index !== -1) {\r\n graph.dispose();\r\n this._flowGraphs.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Starts all graphs\r\n */\r\n start() {\r\n this._flowGraphs.forEach((graph) => graph.start());\r\n }\r\n\r\n /**\r\n * Disposes all graphs\r\n */\r\n dispose() {\r\n this._flowGraphs.forEach((graph) => graph.dispose());\r\n this._flowGraphs.length = 0;\r\n\r\n // Remove itself from the SceneCoordinators list for the Inspector.\r\n const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];\r\n const index = coordinators.indexOf(this);\r\n if (index !== -1) {\r\n coordinators.splice(index, 1);\r\n }\r\n }\r\n\r\n serialize(serializationObject: any, valueSerializeFunction?: (key: string, value: any, serializationObject: any) => void) {\r\n serializationObject._flowGraphs = [];\r\n this._flowGraphs.forEach((graph) => {\r\n const serializedGraph = {};\r\n graph.serialize(serializedGraph, valueSerializeFunction);\r\n serializationObject._flowGraphs.push(serializedGraph);\r\n });\r\n }\r\n\r\n public static Parse(serializedObject: any, scene: Scene, valueParseFunction?: (key: string, serializationObject: any, scene: Scene) => any) {\r\n const coordinator = new FlowGraphCoordinator({ scene });\r\n serializedObject._flowGraphs?.forEach((serializedGraph: any) => {\r\n FlowGraph.Parse(serializedGraph, coordinator, valueParseFunction);\r\n });\r\n return coordinator;\r\n }\r\n\r\n /**\r\n * Gets the list of flow graphs\r\n */\r\n public get flowGraphs() {\r\n return this._flowGraphs;\r\n }\r\n\r\n /* Get an observable that will be notified when the event with the given id is fired.\r\n * @param id the id of the event\r\n * @returns the observable for the event\r\n */\r\n getCustomEventObservable(id: string): Observable<any> {\r\n let observable = this._customEventsMap.get(id);\r\n if (!observable) {\r\n observable = new Observable<any>();\r\n this._customEventsMap.set(id, observable);\r\n }\r\n return observable;\r\n }\r\n\r\n /**\r\n * Notifies the observable for the given event id with the given data.\r\n * @param id the id of the event\r\n * @param data the data to send with the event\r\n */\r\n notifyCustomEvent(id: string, data: any) {\r\n const observable = this._customEventsMap.get(id);\r\n if (observable) {\r\n observable.notifyObservers(data);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -10,7 +10,7 @@ export class FlowGraphEventBlock extends FlowGraphAsyncExecutionBlock {
|
|
|
10
10
|
*/
|
|
11
11
|
_execute(context) {
|
|
12
12
|
context._notifyExecuteNode(this);
|
|
13
|
-
this.
|
|
13
|
+
this.out._activateSignal(context);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=flowGraphEventBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphEventBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphEventBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAG9E;;;;GAIG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,4BAA4B;IAC1E;;OAEG;IACI,QAAQ,CAAC,OAAyB;QACrC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"flowGraphEventBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphEventBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAG9E;;;;GAIG;AACH,MAAM,OAAgB,mBAAoB,SAAQ,4BAA4B;IAC1E;;OAEG;IACI,QAAQ,CAAC,OAAyB;QACrC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACJ","sourcesContent":["import { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\n\r\n/**\r\n * @experimental\r\n * A type of block that listens to an event observable and activates\r\n * its output signal when the event is triggered.\r\n */\r\nexport abstract class FlowGraphEventBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * @internal\r\n */\r\n public _execute(context: FlowGraphContext): void {\r\n context._notifyExecuteNode(this);\r\n this.out._activateSignal(context);\r\n }\r\n}\r\n"]}
|
|
@@ -11,7 +11,7 @@ export declare abstract class FlowGraphExecutionBlock extends FlowGraphBlock {
|
|
|
11
11
|
/**
|
|
12
12
|
* Input connection: The input signal of the block.
|
|
13
13
|
*/
|
|
14
|
-
readonly
|
|
14
|
+
readonly in: FlowGraphSignalConnection;
|
|
15
15
|
signalInputs: FlowGraphSignalConnection[];
|
|
16
16
|
signalOutputs: FlowGraphSignalConnection[];
|
|
17
17
|
protected constructor(config?: IFlowGraphBlockConfiguration);
|
|
@@ -23,7 +23,8 @@ export declare abstract class FlowGraphExecutionBlock extends FlowGraphBlock {
|
|
|
23
23
|
abstract _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void;
|
|
24
24
|
protected _registerSignalInput(name: string): FlowGraphSignalConnection;
|
|
25
25
|
protected _registerSignalOutput(name: string): FlowGraphSignalConnection;
|
|
26
|
+
getSignalInput(name: string): FlowGraphSignalConnection | undefined;
|
|
27
|
+
getSignalOutput(name: string): FlowGraphSignalConnection | undefined;
|
|
26
28
|
serialize(serializationObject?: any): void;
|
|
27
29
|
getClassName(): string;
|
|
28
|
-
static Parse(serializationObject?: any): FlowGraphExecutionBlock;
|
|
29
30
|
}
|
|
@@ -9,7 +9,7 @@ import { FlowGraphSignalConnection } from "./flowGraphSignalConnection.js";
|
|
|
9
9
|
export class FlowGraphExecutionBlock extends FlowGraphBlock {
|
|
10
10
|
constructor(config) {
|
|
11
11
|
super(config);
|
|
12
|
-
this.
|
|
12
|
+
this.in = this._registerSignalInput("in");
|
|
13
13
|
}
|
|
14
14
|
configure() {
|
|
15
15
|
super.configure();
|
|
@@ -26,6 +26,12 @@ export class FlowGraphExecutionBlock extends FlowGraphBlock {
|
|
|
26
26
|
this.signalOutputs.push(output);
|
|
27
27
|
return output;
|
|
28
28
|
}
|
|
29
|
+
getSignalInput(name) {
|
|
30
|
+
return this.signalInputs.find((input) => input.name === name);
|
|
31
|
+
}
|
|
32
|
+
getSignalOutput(name) {
|
|
33
|
+
return this.signalOutputs.find((output) => output.name === name);
|
|
34
|
+
}
|
|
29
35
|
serialize(serializationObject = {}) {
|
|
30
36
|
super.serialize(serializationObject);
|
|
31
37
|
serializationObject.signalInputs = [];
|
|
@@ -44,15 +50,5 @@ export class FlowGraphExecutionBlock extends FlowGraphBlock {
|
|
|
44
50
|
getClassName() {
|
|
45
51
|
return "FGExecutionBlock";
|
|
46
52
|
}
|
|
47
|
-
static Parse(serializationObject = {}) {
|
|
48
|
-
const block = super.Parse(serializationObject);
|
|
49
|
-
for (let i = 0; i < serializationObject.signalInputs.length; i++) {
|
|
50
|
-
block.signalInputs[i].deserialize(serializationObject.signalInputs[i]);
|
|
51
|
-
}
|
|
52
|
-
for (let i = 0; i < serializationObject.signalOutputs.length; i++) {
|
|
53
|
-
block.signalOutputs[i].deserialize(serializationObject.signalOutputs[i]);
|
|
54
|
-
}
|
|
55
|
-
return block;
|
|
56
|
-
}
|
|
57
53
|
}
|
|
58
54
|
//# sourceMappingURL=flowGraphExecutionBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphExecutionBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphExecutionBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;;GAIG;AACH,MAAM,OAAgB,uBAAwB,SA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EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAClE,CAAC;IAEM,eAAe,CAAC,IAAY;QAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACrE,CAAC;IAEM,SAAS,CAAC,sBAA2B,EAAE;QAC1C,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACrC,mBAAmB,CAAC,YAAY,GAAG,EAAE,CAAC;QACtC,mBAAmB,CAAC,aAAa,GAAG,EAAE,CAAC;QACvC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE;YACnC,MAAM,eAAe,GAAQ,EAAE,CAAC;YAChC,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YACjC,mBAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;SAC1D;QACD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,aAAa,EAAE;YACrC,MAAM,gBAAgB,GAAQ,EAAE,CAAC;YACjC,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;YACnC,mBAAmB,CAAC,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SAC5D;IACL,CAAC;IAEM,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ","sourcesContent":["import type { IFlowGraphBlockConfiguration } from \"./flowGraphBlock\";\r\nimport { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\n\r\n/**\r\n * @experimental\r\n * A block that executes some action. Always has an input signal (which is not used by event blocks).\r\n * Can have one or more output signals.\r\n */\r\nexport abstract class FlowGraphExecutionBlock extends FlowGraphBlock {\r\n /**\r\n * Input connection: The input signal of the block.\r\n */\r\n public readonly in: FlowGraphSignalConnection;\r\n\r\n public signalInputs: FlowGraphSignalConnection[];\r\n public signalOutputs: FlowGraphSignalConnection[];\r\n\r\n protected constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n this.in = this._registerSignalInput(\"in\");\r\n }\r\n\r\n public configure() {\r\n super.configure();\r\n this.signalInputs = [];\r\n this.signalOutputs = [];\r\n }\r\n\r\n /**\r\n * @internal\r\n * Executes the flow graph execution block.\r\n */\r\n public abstract _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void;\r\n\r\n protected _registerSignalInput(name: string): FlowGraphSignalConnection {\r\n const input = new FlowGraphSignalConnection(name, FlowGraphConnectionType.Input, this);\r\n this.signalInputs.push(input);\r\n return input;\r\n }\r\n\r\n protected _registerSignalOutput(name: string): FlowGraphSignalConnection {\r\n const output = new FlowGraphSignalConnection(name, FlowGraphConnectionType.Output, this);\r\n this.signalOutputs.push(output);\r\n return output;\r\n }\r\n\r\n public getSignalInput(name: string): FlowGraphSignalConnection | undefined {\r\n return this.signalInputs.find((input) => input.name === name);\r\n }\r\n\r\n public getSignalOutput(name: string): FlowGraphSignalConnection | undefined {\r\n return this.signalOutputs.find((output) => output.name === name);\r\n }\r\n\r\n public serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n serializationObject.signalInputs = [];\r\n serializationObject.signalOutputs = [];\r\n for (const input of this.signalInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.signalInputs.push(serializedInput);\r\n }\r\n for (const output of this.signalOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.signalOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n public getClassName(): string {\r\n return \"FGExecutionBlock\";\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { FlowGraphContext } from "./flowGraphContext";
|
|
2
|
+
/**
|
|
3
|
+
* @experimental
|
|
4
|
+
* An extension to add new functionality to path resolution
|
|
5
|
+
*/
|
|
6
|
+
export interface IPathExtension {
|
|
7
|
+
shouldProcess(path: FlowGraphPath): boolean;
|
|
8
|
+
processGet(path: FlowGraphPath, context: FlowGraphContext): any;
|
|
9
|
+
processSet(path: FlowGraphPath, context: FlowGraphContext, value: any): void;
|
|
10
|
+
}
|
|
2
11
|
export declare class FlowGraphPath {
|
|
12
|
+
/**
|
|
13
|
+
* Extensions that can be used to extend the functionality of the path.
|
|
14
|
+
*/
|
|
15
|
+
static Extensions: IPathExtension[];
|
|
3
16
|
private _path;
|
|
4
17
|
private _templateSubstitutions;
|
|
5
18
|
private _pathParts;
|
|
@@ -17,11 +30,16 @@ export declare class FlowGraphPath {
|
|
|
17
30
|
getTemplateStrings(): string[];
|
|
18
31
|
setTemplateSubstitution(template: string, value: number): void;
|
|
19
32
|
private _evaluateTemplates;
|
|
20
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Gets the final path after all template strings have been substituted.
|
|
35
|
+
* @returns a string representing the final path.
|
|
36
|
+
*/
|
|
37
|
+
getFinalPath(): string;
|
|
21
38
|
private _evaluatePath;
|
|
22
39
|
getProperty(context: FlowGraphContext): any;
|
|
23
40
|
setProperty(context: FlowGraphContext, value: any): void;
|
|
24
41
|
getClassName(): string;
|
|
25
42
|
serialize(serializationObject?: any): any;
|
|
26
|
-
Parse(serializationObject: any): FlowGraphPath;
|
|
43
|
+
static Parse(serializationObject: any): FlowGraphPath;
|
|
44
|
+
static ClassName: string;
|
|
27
45
|
}
|
|
@@ -73,7 +73,11 @@ export class FlowGraphPath {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Gets the final path after all template strings have been substituted.
|
|
78
|
+
* @returns a string representing the final path.
|
|
79
|
+
*/
|
|
80
|
+
getFinalPath() {
|
|
77
81
|
let finalPath = "";
|
|
78
82
|
for (const pathPart of this._pathParts) {
|
|
79
83
|
finalPath += pathPart.separator;
|
|
@@ -95,14 +99,14 @@ export class FlowGraphPath {
|
|
|
95
99
|
this._evaluateTemplates();
|
|
96
100
|
const entityChain = [];
|
|
97
101
|
const splitPath = [];
|
|
98
|
-
let currentTarget = context.
|
|
102
|
+
let currentTarget = context.userVariables;
|
|
99
103
|
for (const pathPart of this._pathParts) {
|
|
100
104
|
if (currentTarget === undefined) {
|
|
101
|
-
throw new Error(`Could not find path ${this.
|
|
105
|
+
throw new Error(`Could not find path ${this.getFinalPath()} in target context`);
|
|
102
106
|
}
|
|
103
107
|
const value = pathPart.isTemplate ? pathPart.replacedValue : pathPart.value;
|
|
104
108
|
if (!value) {
|
|
105
|
-
throw new Error(`Invalid path ${this.
|
|
109
|
+
throw new Error(`Invalid path ${this.getFinalPath()}`);
|
|
106
110
|
}
|
|
107
111
|
currentTarget = currentTarget[value];
|
|
108
112
|
entityChain.push(currentTarget);
|
|
@@ -111,26 +115,42 @@ export class FlowGraphPath {
|
|
|
111
115
|
return { entityChain, splitPath };
|
|
112
116
|
}
|
|
113
117
|
getProperty(context) {
|
|
118
|
+
for (const extension of FlowGraphPath.Extensions) {
|
|
119
|
+
if (extension.shouldProcess(this)) {
|
|
120
|
+
return extension.processGet(this, context);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
114
123
|
const { entityChain } = this._evaluatePath(context);
|
|
115
124
|
return entityChain[entityChain.length - 1];
|
|
116
125
|
}
|
|
117
126
|
setProperty(context, value) {
|
|
127
|
+
for (const extension of FlowGraphPath.Extensions) {
|
|
128
|
+
if (extension.shouldProcess(this)) {
|
|
129
|
+
extension.processSet(this, context, value);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
118
133
|
const { entityChain, splitPath } = this._evaluatePath(context);
|
|
119
134
|
const target = entityChain[entityChain.length - 2];
|
|
120
135
|
const property = splitPath[splitPath.length - 1];
|
|
121
136
|
target[property] = value;
|
|
122
137
|
}
|
|
123
138
|
getClassName() {
|
|
124
|
-
return
|
|
139
|
+
return FlowGraphPath.ClassName;
|
|
125
140
|
}
|
|
126
141
|
serialize(serializationObject = {}) {
|
|
127
142
|
serializationObject.path = this._path;
|
|
128
143
|
serializationObject.className = this.getClassName();
|
|
129
144
|
return serializationObject;
|
|
130
145
|
}
|
|
131
|
-
Parse(serializationObject) {
|
|
146
|
+
static Parse(serializationObject) {
|
|
132
147
|
return new FlowGraphPath(serializationObject.path);
|
|
133
148
|
}
|
|
134
149
|
}
|
|
135
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Extensions that can be used to extend the functionality of the path.
|
|
152
|
+
*/
|
|
153
|
+
FlowGraphPath.Extensions = [];
|
|
154
|
+
FlowGraphPath.ClassName = "FGPath";
|
|
155
|
+
RegisterClass(FlowGraphPath.ClassName, FlowGraphPath);
|
|
136
156
|
//# sourceMappingURL=flowGraphPath.js.map
|