@bian-womp/spark-graph 0.3.88 → 0.3.90
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/lib/cjs/index.cjs +9 -5
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/HandleResolver.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/lib/esm/index.js +9 -5
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/HandleResolver.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/lib/src/builder/GraphBuilder.d.ts +43 -0
- package/lib/src/builder/GraphBuilder.d.ts.map +1 -0
- package/lib/src/builder/GraphBuilder.js +279 -0
- package/lib/src/builder/GraphBuilder.js.map +1 -0
- package/lib/src/builder/Registry.d.ts +87 -0
- package/lib/src/builder/Registry.d.ts.map +1 -0
- package/lib/src/builder/Registry.js +390 -0
- package/lib/src/builder/Registry.js.map +1 -0
- package/lib/src/core/categories.d.ts +22 -0
- package/lib/src/core/categories.d.ts.map +1 -0
- package/lib/src/core/categories.js +2 -0
- package/lib/src/core/categories.js.map +1 -0
- package/lib/src/core/order.d.ts +7 -0
- package/lib/src/core/order.d.ts.map +1 -0
- package/lib/src/core/order.js +66 -0
- package/lib/src/core/order.js.map +1 -0
- package/lib/src/core/type-utils.d.ts +29 -0
- package/lib/src/core/type-utils.d.ts.map +1 -0
- package/lib/src/core/type-utils.js +92 -0
- package/lib/src/core/type-utils.js.map +1 -0
- package/lib/src/core/types.d.ts +95 -0
- package/lib/src/core/types.d.ts.map +1 -0
- package/lib/src/core/types.js +2 -0
- package/lib/src/core/types.js.map +1 -0
- package/lib/src/examples/arrays.d.ts +5 -0
- package/lib/src/examples/arrays.d.ts.map +1 -0
- package/lib/src/examples/arrays.js +49 -0
- package/lib/src/examples/arrays.js.map +1 -0
- package/lib/src/examples/async.d.ts +5 -0
- package/lib/src/examples/async.d.ts.map +1 -0
- package/lib/src/examples/async.js +91 -0
- package/lib/src/examples/async.js.map +1 -0
- package/lib/src/examples/progress.d.ts +5 -0
- package/lib/src/examples/progress.d.ts.map +1 -0
- package/lib/src/examples/progress.js +51 -0
- package/lib/src/examples/progress.js.map +1 -0
- package/lib/src/examples/run.d.ts +2 -0
- package/lib/src/examples/run.d.ts.map +1 -0
- package/lib/src/examples/run.js +32 -0
- package/lib/src/examples/run.js.map +1 -0
- package/lib/src/examples/runMode.d.ts +2 -0
- package/lib/src/examples/runMode.d.ts.map +1 -0
- package/lib/src/examples/runMode.js +223 -0
- package/lib/src/examples/runMode.js.map +1 -0
- package/lib/src/examples/shared.d.ts +5 -0
- package/lib/src/examples/shared.d.ts.map +1 -0
- package/lib/src/examples/shared.js +47 -0
- package/lib/src/examples/shared.js.map +1 -0
- package/lib/src/examples/simple.d.ts +5 -0
- package/lib/src/examples/simple.d.ts.map +1 -0
- package/lib/src/examples/simple.js +79 -0
- package/lib/src/examples/simple.js.map +1 -0
- package/lib/src/examples/snapshot.d.ts +4 -0
- package/lib/src/examples/snapshot.d.ts.map +1 -0
- package/lib/src/examples/snapshot.js +58 -0
- package/lib/src/examples/snapshot.js.map +1 -0
- package/lib/src/examples/validation.d.ts +5 -0
- package/lib/src/examples/validation.d.ts.map +1 -0
- package/lib/src/examples/validation.js +105 -0
- package/lib/src/examples/validation.js.map +1 -0
- package/lib/src/index.d.ts +27 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/src/index.js +19 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/misc/base.d.ts +51 -0
- package/lib/src/misc/base.d.ts.map +1 -0
- package/lib/src/misc/base.js +1091 -0
- package/lib/src/misc/base.js.map +1 -0
- package/lib/src/misc/utils/LevelLogger.d.ts +150 -0
- package/lib/src/misc/utils/LevelLogger.d.ts.map +1 -0
- package/lib/src/misc/utils/LevelLogger.js +420 -0
- package/lib/src/misc/utils/LevelLogger.js.map +1 -0
- package/lib/src/misc/utils/LevelLogger.test.d.ts +2 -0
- package/lib/src/misc/utils/LevelLogger.test.d.ts.map +1 -0
- package/lib/src/misc/utils/LevelLogger.test.js +283 -0
- package/lib/src/misc/utils/LevelLogger.test.js.map +1 -0
- package/lib/src/misc/utils/json.d.ts +34 -0
- package/lib/src/misc/utils/json.d.ts.map +1 -0
- package/lib/src/misc/utils/json.js +471 -0
- package/lib/src/misc/utils/json.js.map +1 -0
- package/lib/src/misc/utils/merge.d.ts +51 -0
- package/lib/src/misc/utils/merge.d.ts.map +1 -0
- package/lib/src/misc/utils/merge.js +591 -0
- package/lib/src/misc/utils/merge.js.map +1 -0
- package/lib/src/misc/utils/test-logger-output.d.ts +7 -0
- package/lib/src/misc/utils/test-logger-output.d.ts.map +1 -0
- package/lib/src/misc/utils/test-logger-output.js +48 -0
- package/lib/src/misc/utils/test-logger-output.js.map +1 -0
- package/lib/src/plugins/composite.d.ts +22 -0
- package/lib/src/plugins/composite.d.ts.map +1 -0
- package/lib/src/plugins/composite.js +59 -0
- package/lib/src/plugins/composite.js.map +1 -0
- package/lib/src/plugins/compute.d.ts +5 -0
- package/lib/src/plugins/compute.d.ts.map +1 -0
- package/lib/src/plugins/compute.js +39 -0
- package/lib/src/plugins/compute.js.map +1 -0
- package/lib/src/runtime/Engine.d.ts +26 -0
- package/lib/src/runtime/Engine.d.ts.map +1 -0
- package/lib/src/runtime/Engine.js +2 -0
- package/lib/src/runtime/Engine.js.map +1 -0
- package/lib/src/runtime/GraphLifecycleApi.d.ts +46 -0
- package/lib/src/runtime/GraphLifecycleApi.d.ts.map +1 -0
- package/lib/src/runtime/GraphLifecycleApi.js +2 -0
- package/lib/src/runtime/GraphLifecycleApi.js.map +1 -0
- package/lib/src/runtime/GraphRuntime.d.ts +111 -0
- package/lib/src/runtime/GraphRuntime.d.ts.map +1 -0
- package/lib/src/runtime/GraphRuntime.js +791 -0
- package/lib/src/runtime/GraphRuntime.js.map +1 -0
- package/lib/src/runtime/LocalEngine.d.ts +41 -0
- package/lib/src/runtime/LocalEngine.d.ts.map +1 -0
- package/lib/src/runtime/LocalEngine.js +89 -0
- package/lib/src/runtime/LocalEngine.js.map +1 -0
- package/lib/src/runtime/components/EdgePropagator.d.ts +93 -0
- package/lib/src/runtime/components/EdgePropagator.d.ts.map +1 -0
- package/lib/src/runtime/components/EdgePropagator.js +378 -0
- package/lib/src/runtime/components/EdgePropagator.js.map +1 -0
- package/lib/src/runtime/components/EventEmitter.d.ts +12 -0
- package/lib/src/runtime/components/EventEmitter.d.ts.map +1 -0
- package/lib/src/runtime/components/EventEmitter.js +33 -0
- package/lib/src/runtime/components/EventEmitter.js.map +1 -0
- package/lib/src/runtime/components/Graph.d.ts +208 -0
- package/lib/src/runtime/components/Graph.d.ts.map +1 -0
- package/lib/src/runtime/components/Graph.js +452 -0
- package/lib/src/runtime/components/Graph.js.map +1 -0
- package/lib/src/runtime/components/HandleResolver.d.ts +36 -0
- package/lib/src/runtime/components/HandleResolver.d.ts.map +1 -0
- package/lib/src/runtime/components/HandleResolver.js +229 -0
- package/lib/src/runtime/components/HandleResolver.js.map +1 -0
- package/lib/src/runtime/components/NodeExecutor.d.ts +116 -0
- package/lib/src/runtime/components/NodeExecutor.d.ts.map +1 -0
- package/lib/src/runtime/components/NodeExecutor.js +648 -0
- package/lib/src/runtime/components/NodeExecutor.js.map +1 -0
- package/lib/src/runtime/components/RunContextManager.d.ts +90 -0
- package/lib/src/runtime/components/RunContextManager.d.ts.map +1 -0
- package/lib/src/runtime/components/RunContextManager.js +329 -0
- package/lib/src/runtime/components/RunContextManager.js.map +1 -0
- package/lib/src/runtime/components/RuntimeValidatorManager.d.ts +31 -0
- package/lib/src/runtime/components/RuntimeValidatorManager.d.ts.map +1 -0
- package/lib/src/runtime/components/RuntimeValidatorManager.js +56 -0
- package/lib/src/runtime/components/RuntimeValidatorManager.js.map +1 -0
- package/lib/src/runtime/components/graph-utils.d.ts +33 -0
- package/lib/src/runtime/components/graph-utils.d.ts.map +1 -0
- package/lib/src/runtime/components/graph-utils.js +300 -0
- package/lib/src/runtime/components/graph-utils.js.map +1 -0
- package/lib/src/runtime/components/interfaces.d.ts +59 -0
- package/lib/src/runtime/components/interfaces.d.ts.map +1 -0
- package/lib/src/runtime/components/interfaces.js +2 -0
- package/lib/src/runtime/components/interfaces.js.map +1 -0
- package/lib/src/runtime/components/types.d.ts +57 -0
- package/lib/src/runtime/components/types.d.ts.map +1 -0
- package/lib/src/runtime/components/types.js +2 -0
- package/lib/src/runtime/components/types.js.map +1 -0
- package/lib/src/runtime/utils.d.ts +21 -0
- package/lib/src/runtime/utils.d.ts.map +1 -0
- package/lib/src/runtime/utils.js +41 -0
- package/lib/src/runtime/utils.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../../../src/core/type-utils.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,KAAK,CAAc,MAAkB,EAAE,KAAQ;IAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;AACjG,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAU;IACrC,IAAI,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,IAAI,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,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AAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAyD,EACzD,MAAgB;IAEhB,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9C,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACtE,OAAO,CAAC,CAAC,QAAsC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { DataTypeId, NodeTypeId, HandleId, InputHandleDescriptor, NodeCategoryId, ResolvedHandles, ExecutionPolicy, LogLevel } from "@bian-womp/spark-protocol";
|
|
2
|
+
export interface DataTypeDescriptor<T = unknown> {
|
|
3
|
+
id: DataTypeId;
|
|
4
|
+
displayName?: string;
|
|
5
|
+
validate(value: T): boolean;
|
|
6
|
+
helpers?: Record<string, unknown>;
|
|
7
|
+
bakeTarget?: {
|
|
8
|
+
nodeTypeId: NodeTypeId;
|
|
9
|
+
inputHandle: HandleId;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export type InvalidateReason = "input-changed" | "dependency-changed" | "manual" | "disposed";
|
|
13
|
+
export type NodeDisposeReason = "node-removed" | "runtime-dispose" | "runtime-rebuild" | "adapter-dispose";
|
|
14
|
+
export interface NodeContext<State> {
|
|
15
|
+
state: State;
|
|
16
|
+
setState(next: Partial<State>): void;
|
|
17
|
+
disposeReason?: NodeDisposeReason;
|
|
18
|
+
}
|
|
19
|
+
export interface ExecutionContext<State> extends NodeContext<State> {
|
|
20
|
+
nodeId: string;
|
|
21
|
+
environment: Record<string, unknown>;
|
|
22
|
+
customNodeData?: Record<string, unknown>;
|
|
23
|
+
runId: string;
|
|
24
|
+
abortSignal: AbortSignal;
|
|
25
|
+
emit: (handle: HandleId, value: unknown) => void;
|
|
26
|
+
invalidateDownstream: () => void;
|
|
27
|
+
execute: (opts?: {
|
|
28
|
+
propagate?: boolean;
|
|
29
|
+
resolve?: () => void;
|
|
30
|
+
reason?: string;
|
|
31
|
+
}) => void;
|
|
32
|
+
getInput: (handle: HandleId) => unknown;
|
|
33
|
+
reportProgress?: (value: number) => void;
|
|
34
|
+
setCustomData?: (data: Record<string, unknown>) => void;
|
|
35
|
+
log: (level: LogLevel, message: string, context?: Record<string, unknown>) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extract State type from ExecutionContext<State>
|
|
39
|
+
*/
|
|
40
|
+
export type ExtractStateFromContext<T> = T extends ExecutionContext<infer S> ? S : never;
|
|
41
|
+
/**
|
|
42
|
+
* Extract State type from impl function signature
|
|
43
|
+
*/
|
|
44
|
+
export type ExtractStateFromImpl<Impl> = Impl extends (inputs: any, ctx: ExecutionContext<infer State>) => any ? State : never;
|
|
45
|
+
/**
|
|
46
|
+
* Extract Inputs type from impl function signature
|
|
47
|
+
*/
|
|
48
|
+
export type ExtractInputsFromImpl<Impl> = Impl extends (inputs: infer I, ctx: any) => any ? I : never;
|
|
49
|
+
export interface RuntimeNodeStats {
|
|
50
|
+
runs: number;
|
|
51
|
+
active: number;
|
|
52
|
+
queued: number;
|
|
53
|
+
lastStartAt?: number;
|
|
54
|
+
lastEndAt?: number;
|
|
55
|
+
lastDurationMs?: number;
|
|
56
|
+
progress: number;
|
|
57
|
+
lastError?: unknown;
|
|
58
|
+
}
|
|
59
|
+
export interface RuntimeEdgeStats {
|
|
60
|
+
runs: number;
|
|
61
|
+
inFlight: boolean;
|
|
62
|
+
lastStartAt?: number;
|
|
63
|
+
lastEndAt?: number;
|
|
64
|
+
lastDurationMs?: number;
|
|
65
|
+
progress: number;
|
|
66
|
+
lastError?: unknown;
|
|
67
|
+
}
|
|
68
|
+
export type TypedValue<T = unknown> = {
|
|
69
|
+
__spark_type: DataTypeId;
|
|
70
|
+
__spark_value: T;
|
|
71
|
+
};
|
|
72
|
+
type InferState<Impl, State> = ExtractStateFromImpl<Impl> extends never ? State : ExtractStateFromImpl<Impl>;
|
|
73
|
+
export interface NodeTypeDescriptor<I extends Record<string, InputHandleDescriptor> = Record<string, InputHandleDescriptor>, O extends Record<string, DataTypeId | DataTypeId[]> = Record<string, DataTypeId | DataTypeId[]>, State = unknown, Impl extends (inputs: any, ctx: ExecutionContext<any>) => any = (inputs: Record<string, unknown>, ctx: ExecutionContext<State>) => void | Record<string, unknown> | Promise<void | Record<string, unknown>>> {
|
|
74
|
+
id: NodeTypeId;
|
|
75
|
+
categoryId: NodeCategoryId;
|
|
76
|
+
displayName?: string;
|
|
77
|
+
inputs: I;
|
|
78
|
+
outputs: O;
|
|
79
|
+
impl: Impl;
|
|
80
|
+
policy?: Partial<ExecutionPolicy>;
|
|
81
|
+
logLevel?: LogLevel;
|
|
82
|
+
resolveHandles?: (ctx: {
|
|
83
|
+
nodeId: string;
|
|
84
|
+
environment: Record<string, unknown>;
|
|
85
|
+
params?: Record<string, unknown>;
|
|
86
|
+
inputs?: Record<string, unknown>;
|
|
87
|
+
}) => Partial<ResolvedHandles> | Promise<Partial<ResolvedHandles>>;
|
|
88
|
+
inputDefaults?: Record<string, unknown>;
|
|
89
|
+
lifecycle?: {
|
|
90
|
+
prepare?: (params: Record<string, unknown>, ctx: ExecutionContext<InferState<Impl, State>>) => void | Promise<void>;
|
|
91
|
+
dispose?: (ctx: NodeContext<InferState<Impl, State>>) => void;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,EACf,QAAQ,EACT,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,kBA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,CAAC;IACV,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IAEX,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAElC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAGpB,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,KAAK,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAEnE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,gBAAgB,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACpH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;KAC/D,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GraphDefinition } from "@bian-womp/spark-protocol";
|
|
2
|
+
export declare function createArrayComposeDecomposeDef(): GraphDefinition;
|
|
3
|
+
export declare function createArrayComposeDecomposeRegistry(): import("..").Registry;
|
|
4
|
+
export declare function main(): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=arrays.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../../../src/examples/arrays.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAKjE,wBAAgB,8BAA8B,IAAI,eAAe,CAchE;AAED,wBAAgB,mCAAmC,0BAElD;AAED,wBAAsB,IAAI,kBA6CzB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { setupBasicGraphRegistry, createRuntime } from "../misc/base";
|
|
2
|
+
import { LocalEngine } from "../runtime/LocalEngine";
|
|
3
|
+
import { installLogging } from "./shared";
|
|
4
|
+
export function createArrayComposeDecomposeDef() {
|
|
5
|
+
return {
|
|
6
|
+
nodes: [
|
|
7
|
+
{ nodeId: "compose", typeId: "base.array.compose" },
|
|
8
|
+
{ nodeId: "decompose", typeId: "base.array.decompose" },
|
|
9
|
+
],
|
|
10
|
+
edges: [
|
|
11
|
+
{
|
|
12
|
+
id: "e_compose_items_to_decompose_items",
|
|
13
|
+
source: { nodeId: "compose", handle: "Items" },
|
|
14
|
+
target: { nodeId: "decompose", handle: "Items" },
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function createArrayComposeDecomposeRegistry() {
|
|
20
|
+
return setupBasicGraphRegistry();
|
|
21
|
+
}
|
|
22
|
+
export async function main() {
|
|
23
|
+
console.log("Array compose/decompose example: dynamic handle resolution");
|
|
24
|
+
console.log("- compose(base.array.compose) -> decompose(base.array.decompose)");
|
|
25
|
+
console.log("- Setting compose.Length will dynamically add inputs compose.Item0..ItemN and drive decompose.Item0..ItemN outputs via Items array");
|
|
26
|
+
const runtime = createRuntime(createArrayComposeDecomposeRegistry(), createArrayComposeDecomposeDef());
|
|
27
|
+
const engine = new LocalEngine(runtime, "auto");
|
|
28
|
+
installLogging(engine);
|
|
29
|
+
engine.launch();
|
|
30
|
+
// Compose 3 items and observe decompose dynamic outputs
|
|
31
|
+
engine.setInputs("compose", {
|
|
32
|
+
Length: 3,
|
|
33
|
+
Item0: "alpha",
|
|
34
|
+
Item1: "beta",
|
|
35
|
+
Item2: "gamma",
|
|
36
|
+
});
|
|
37
|
+
await engine.whenIdle();
|
|
38
|
+
console.log("d.Item0..2 =>", engine.getOutput("decompose", "Item0"), engine.getOutput("decompose", "Item1"), engine.getOutput("decompose", "Item2"));
|
|
39
|
+
// Grow to 5 items; dynamic inputs/outputs should expand automatically
|
|
40
|
+
engine.setInputs("compose", { Length: 5, Item3: "delta", Item4: "epsilon" });
|
|
41
|
+
await engine.whenIdle();
|
|
42
|
+
console.log("d.Item0..4 =>", engine.getOutput("decompose", "Item0"), engine.getOutput("decompose", "Item1"), engine.getOutput("decompose", "Item2"), engine.getOutput("decompose", "Item3"), engine.getOutput("decompose", "Item4"));
|
|
43
|
+
// Shrink to 2 items; dynamic outputs should shrink
|
|
44
|
+
engine.setInputs("compose", { Length: 2 });
|
|
45
|
+
await engine.whenIdle();
|
|
46
|
+
console.log("d.Item0..1 =>", engine.getOutput("decompose", "Item0"), engine.getOutput("decompose", "Item1"));
|
|
47
|
+
engine.dispose();
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=arrays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrays.js","sourceRoot":"","sources":["../../../src/examples/arrays.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,UAAU,8BAA8B;IAC5C,OAAO;QACL,KAAK,EAAE;YACL,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAE;YACnD,EAAE,MAAM,EAAE,WA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AAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7E,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;IACxB,OAAO,CAAC,GAAG,CACT,eAAe,EACf,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,EACtC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,EACtC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,EACtC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,EACtC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CACvC,CAAC;IAEF,mDAAmD;IACnD,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3C,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;IACxB,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IAE7G,MAAM,CAAC,OAAO,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GraphDefinition } from "@bian-womp/spark-protocol";
|
|
2
|
+
export declare function createAsyncGraphDef(): GraphDefinition;
|
|
3
|
+
export declare function createAsyncGraphRegistry(id?: string): import("..").Registry;
|
|
4
|
+
export declare function main(): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/examples/async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAKjE,wBAAgB,mBAAmB,oBAoDlC;AAED,wBAAgB,wBAAwB,CAAC,EAAE,CAAC,EAAE,MAAM,yBAInD;AAED,wBAAsB,IAAI,kBAgCzB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { setupBasicGraphRegistry, registerDelayNode, createRuntime, BaseMathOperation } from "../misc/base";
|
|
2
|
+
import { LocalEngine } from "../runtime/LocalEngine";
|
|
3
|
+
import { installLogging } from "./shared";
|
|
4
|
+
export function createAsyncGraphDef() {
|
|
5
|
+
const def = {
|
|
6
|
+
nodes: [
|
|
7
|
+
{
|
|
8
|
+
nodeId: "n1",
|
|
9
|
+
typeId: "base.math",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
nodeId: "n2",
|
|
13
|
+
typeId: "async.delay",
|
|
14
|
+
params: { policy: { asyncConcurrency: "queue", maxQueue: 4 } },
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
nodeId: "n3",
|
|
18
|
+
typeId: "base.separateXYZ",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
nodeId: "n4",
|
|
22
|
+
typeId: "base.compareXYZ",
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
edges: [
|
|
26
|
+
{
|
|
27
|
+
id: "e1",
|
|
28
|
+
source: { nodeId: "n1", handle: "Result" },
|
|
29
|
+
target: { nodeId: "n2", handle: "Value" },
|
|
30
|
+
},
|
|
31
|
+
// Demonstrate async edge conversion: vec3[] -> float[] using coercion
|
|
32
|
+
{
|
|
33
|
+
id: "e2",
|
|
34
|
+
source: { nodeId: "n4", handle: "XYZ" },
|
|
35
|
+
target: { nodeId: "n1", handle: "A" },
|
|
36
|
+
typeId: "base.vec3[]",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "e3",
|
|
40
|
+
source: { nodeId: "n3", handle: "X" },
|
|
41
|
+
target: { nodeId: "n4", handle: "X" },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "e4",
|
|
45
|
+
source: { nodeId: "n3", handle: "Y" },
|
|
46
|
+
target: { nodeId: "n4", handle: "Y" },
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "e5",
|
|
50
|
+
source: { nodeId: "n3", handle: "Z" },
|
|
51
|
+
target: { nodeId: "n4", handle: "Z" },
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
return def;
|
|
56
|
+
}
|
|
57
|
+
export function createAsyncGraphRegistry(id) {
|
|
58
|
+
const registry = setupBasicGraphRegistry(id);
|
|
59
|
+
registerDelayNode(registry);
|
|
60
|
+
return registry;
|
|
61
|
+
}
|
|
62
|
+
export async function main() {
|
|
63
|
+
const runtime = createRuntime(createAsyncGraphRegistry(), createAsyncGraphDef());
|
|
64
|
+
const engine = new LocalEngine(runtime, "auto");
|
|
65
|
+
installLogging(engine);
|
|
66
|
+
engine.launch();
|
|
67
|
+
// Set base ms
|
|
68
|
+
engine.setInputs("n1", { Operation: BaseMathOperation.Add, A: [1], B: [2] });
|
|
69
|
+
engine.setInputs("n2", { DelayMs: 250 });
|
|
70
|
+
// Provide XYZ and route through async conversion edge
|
|
71
|
+
engine.setInputs("n3", {
|
|
72
|
+
XYZ: [
|
|
73
|
+
[1, 2, 3],
|
|
74
|
+
[4, 5, 6],
|
|
75
|
+
[7, 8, 9],
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
// Rapid inputs to n1.B should cancel prior runs (switch)
|
|
79
|
+
// Note: n1.A is edge-driven from n4.XYZ, so we change n1.B instead
|
|
80
|
+
engine.setInputs("n1", { B: [3] });
|
|
81
|
+
engine.setInputs("n1", { B: [4] });
|
|
82
|
+
engine.setInputs("n1", { B: [5] });
|
|
83
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
84
|
+
engine.setInputs("n1", { B: [10] });
|
|
85
|
+
engine.setInputs("n1", { B: [11] });
|
|
86
|
+
engine.setInputs("n1", { B: [12] });
|
|
87
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
88
|
+
await engine.whenIdle();
|
|
89
|
+
engine.dispose();
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../../src/examples/async.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,UAAU,mBAAmB;IACjC,MAAM,GAAG,GAAoB;QAC3B,KAAK,EAAE;YACL;gBACE,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,WAAW;aACpB;YACD;gBACE,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,aAAa;gBACrB,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE;aAC/D;YACD;gBACE,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,kBAAkB;aAC3B;YACD;gBACE,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,iBAAiB;aAC1B;SACF;QACD,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,IAAI;gBACR,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE;gBAC1C,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;aAC1C;YACD,sEAAsE;YACtE;gBACE,EAAE,EAAE,IAAI;gBACR,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE;gBACvC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;gBACrC,MAAM,EAAE,aAAa;aACtB;YACD;gBACE,EAAE,EAA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
1
|
+
import type { GraphDefinition } from "@bian-womp/spark-protocol";
|
|
2
|
+
export declare function createProgressGraphDef(): GraphDefinition;
|
|
3
|
+
export declare function createProgressGraphRegistry(id?: string): import("..").Registry;
|
|
4
|
+
export declare function main(): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/examples/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAKjE,wBAAgB,sBAAsB,oBAsBrC;AAED,wBAAgB,2BAA2B,CAAC,EAAE,CAAC,EAAE,MAAM,yBAItD;AAED,wBAAsB,IAAI,kBAsBzB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { registerProgressNodes, setupBasicGraphRegistry, createRuntime } from "../misc/base";
|
|
2
|
+
import { LocalEngine } from "../runtime/LocalEngine";
|
|
3
|
+
import { installLogging } from "./shared";
|
|
4
|
+
export function createProgressGraphDef() {
|
|
5
|
+
const def = {
|
|
6
|
+
nodes: [
|
|
7
|
+
{ nodeId: "steps", typeId: "base.input.number" },
|
|
8
|
+
{ nodeId: "delay", typeId: "base.input.number" },
|
|
9
|
+
{ nodeId: "work", typeId: "async.progress" },
|
|
10
|
+
],
|
|
11
|
+
edges: [
|
|
12
|
+
{
|
|
13
|
+
id: "e1",
|
|
14
|
+
source: { nodeId: "steps", handle: "Result" },
|
|
15
|
+
target: { nodeId: "work", handle: "Steps" },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "e2",
|
|
19
|
+
source: { nodeId: "delay", handle: "Result" },
|
|
20
|
+
target: { nodeId: "work", handle: "DelayMs" },
|
|
21
|
+
},
|
|
22
|
+
// not wiring ShouldError to show manual input driven error later
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
return def;
|
|
26
|
+
}
|
|
27
|
+
export function createProgressGraphRegistry(id) {
|
|
28
|
+
const registry = setupBasicGraphRegistry(id);
|
|
29
|
+
registerProgressNodes(registry);
|
|
30
|
+
return registry;
|
|
31
|
+
}
|
|
32
|
+
export async function main() {
|
|
33
|
+
const runtime = createRuntime(createProgressGraphRegistry(), createProgressGraphDef());
|
|
34
|
+
const engine = new LocalEngine(runtime, "auto");
|
|
35
|
+
installLogging(engine);
|
|
36
|
+
engine.launch();
|
|
37
|
+
// Seed initial values
|
|
38
|
+
engine.setInputs("steps", { Value: 12 });
|
|
39
|
+
engine.setInputs("delay", { Value: 80 });
|
|
40
|
+
// Manually set ShouldError on the worker (unwired input)
|
|
41
|
+
engine.setInputs("work", { ShouldError: false });
|
|
42
|
+
// After 2s, trigger an error run
|
|
43
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
44
|
+
console.log("-- triggering error run --");
|
|
45
|
+
engine.setInputs("work", { ShouldError: true });
|
|
46
|
+
// After 5s, stop and exit
|
|
47
|
+
await new Promise((r) => setTimeout(r, 5000));
|
|
48
|
+
await engine.whenIdle();
|
|
49
|
+
engine.dispose();
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../../src/examples/progress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAoB;QAC3B,KAAK,EAAE;YACL,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE;YAChD,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE;YAChD,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,E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O,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC1C,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhD,0BAA0B;IAC1B,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IAC9C,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;IACxB,MAAM,CAAC,OAAO,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/examples/run.ts"],"names":[],"mappings":"AAAA,wBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,iBA0BxC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export async function run(example) {
|
|
2
|
+
switch (example) {
|
|
3
|
+
case "simple":
|
|
4
|
+
await import("./simple").then((m) => m.main());
|
|
5
|
+
break;
|
|
6
|
+
case "runMode":
|
|
7
|
+
await import("./runMode").then((m) => m.main());
|
|
8
|
+
break;
|
|
9
|
+
case "async":
|
|
10
|
+
await import("./async").then((m) => m.main());
|
|
11
|
+
break;
|
|
12
|
+
case "progress":
|
|
13
|
+
await import("./progress").then((m) => m.main());
|
|
14
|
+
break;
|
|
15
|
+
case "validation":
|
|
16
|
+
await import("./validation").then((m) => m.main());
|
|
17
|
+
break;
|
|
18
|
+
case "snapshot":
|
|
19
|
+
await import("./snapshot").then((m) => m.main());
|
|
20
|
+
break;
|
|
21
|
+
case "arrays":
|
|
22
|
+
await import("./arrays").then((m) => m.main());
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`Unknown example: ${example}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const exampleArg = (process.argv && process.argv[2]) || "simple";
|
|
29
|
+
console.log(`Running example: ${exampleArg}`);
|
|
30
|
+
// top-level await is supported by tsx
|
|
31
|
+
run(exampleArg);
|
|
32
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/examples/run.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAe;IACvC,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,QAAQ;YACX,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAC/C,MAAM;QACR,KAAK,SAAS;YACZ,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAChD,MAAM;QACR,KAAK,OAAO;YACV,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAC9C,MAAM;QACR,KAAK,UAAU;YACb,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACjD,MAAM;QACR,KAAK,YAAY;YACf,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACnD,MAAM;QACR,KAAK,UAAU;YACb,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACjD,MAAM;QACR,KAAK,QAAQ;YACX,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAC/C,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC;AACjE,OAAO,CAAC,GAAG,CAAC,oBAAoB,UAAU,EAAE,CAAC,CAAC;AAE9C,sCAAsC;AACtC,GAAG,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runMode.d.ts","sourceRoot":"","sources":["../../../src/examples/runMode.ts"],"names":[],"mappings":"AA8OA,wBAAsB,IAAI,kBAmBzB"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { GraphBuilder } from "../builder/GraphBuilder";
|
|
2
|
+
import { setupBasicGraphRegistry, registerDelayNode, BaseMathOperation } from "../misc/base";
|
|
3
|
+
import { LocalEngine } from "../runtime/LocalEngine";
|
|
4
|
+
import { installLogging } from "./shared";
|
|
5
|
+
function buildDef() {
|
|
6
|
+
return {
|
|
7
|
+
nodes: [
|
|
8
|
+
{ nodeId: "input1", typeId: "base.input.number" },
|
|
9
|
+
{ nodeId: "input2", typeId: "base.input.number" },
|
|
10
|
+
{ nodeId: "math1", typeId: "base.math" },
|
|
11
|
+
{ nodeId: "math2", typeId: "base.math" },
|
|
12
|
+
{
|
|
13
|
+
nodeId: "delay1",
|
|
14
|
+
typeId: "async.delay",
|
|
15
|
+
params: { policy: { asyncConcurrency: "queue", maxQueue: 4 } },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
nodeId: "delay2",
|
|
19
|
+
typeId: "async.delay",
|
|
20
|
+
params: { policy: { asyncConcurrency: "queue", maxQueue: 4 } },
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
edges: [
|
|
24
|
+
{
|
|
25
|
+
id: "e1",
|
|
26
|
+
source: { nodeId: "input1", handle: "Result" },
|
|
27
|
+
target: { nodeId: "math1", handle: "A" },
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "e2",
|
|
31
|
+
source: { nodeId: "input2", handle: "Result" },
|
|
32
|
+
target: { nodeId: "math1", handle: "B" },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "e3",
|
|
36
|
+
source: { nodeId: "math1", handle: "Result" },
|
|
37
|
+
target: { nodeId: "math2", handle: "A" },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "e4",
|
|
41
|
+
source: { nodeId: "math2", handle: "Result" },
|
|
42
|
+
target: { nodeId: "delay1", handle: "Value" },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "e5",
|
|
46
|
+
source: { nodeId: "delay1", handle: "Result" },
|
|
47
|
+
target: { nodeId: "delay2", handle: "Value" },
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async function demoAutoMode() {
|
|
53
|
+
console.log("\n" + "=".repeat(60));
|
|
54
|
+
console.log("AUTO MODE DEMONSTRATION");
|
|
55
|
+
console.log("=".repeat(60));
|
|
56
|
+
console.log("In auto mode, nodes automatically execute when inputs change.\n");
|
|
57
|
+
const registry = setupBasicGraphRegistry();
|
|
58
|
+
registerDelayNode(registry);
|
|
59
|
+
const builder = new GraphBuilder(registry);
|
|
60
|
+
const def = buildDef();
|
|
61
|
+
const runtime = builder.build(def);
|
|
62
|
+
const engine = new LocalEngine(runtime, "auto");
|
|
63
|
+
installLogging(engine);
|
|
64
|
+
engine.launch();
|
|
65
|
+
// Configure nodes
|
|
66
|
+
engine.setInputs("math1", { Operation: BaseMathOperation.Add });
|
|
67
|
+
engine.setInputs("math2", { Operation: BaseMathOperation.Multiply, B: [2] });
|
|
68
|
+
engine.setInputs("delay1", { DelayMs: 100 });
|
|
69
|
+
engine.setInputs("delay2", { DelayMs: 100 });
|
|
70
|
+
console.log("Step 1: Set input1 = 5");
|
|
71
|
+
console.log(" → input1 runs and outputs 5");
|
|
72
|
+
console.log(" → math1.A gets set to 5, but math1 waits for input2 (B)\n");
|
|
73
|
+
engine.setInputs("input1", { Value: 5 });
|
|
74
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
75
|
+
console.log("Step 2: Set input2 = 3");
|
|
76
|
+
console.log(" → input2 runs and outputs 3");
|
|
77
|
+
console.log(" → math1 automatically runs (A=5, B=3) → Result=8");
|
|
78
|
+
console.log(" → math2 automatically runs (A=8, B=2) → Result=16");
|
|
79
|
+
console.log(" → delay1 automatically runs → delay2 automatically runs\n");
|
|
80
|
+
engine.setInputs("input2", { Value: 3 });
|
|
81
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
82
|
+
console.log("Step 3: Set input1 = 10");
|
|
83
|
+
console.log(" → math1 automatically runs (A=10, B=3) → Result=13");
|
|
84
|
+
console.log(" → math2 automatically runs (A=13, B=2) → Result=26");
|
|
85
|
+
console.log(" → delay1 automatically runs → delay2 automatically runs\n");
|
|
86
|
+
engine.setInputs("input1", { Value: 10 });
|
|
87
|
+
await engine.whenIdle();
|
|
88
|
+
engine.dispose();
|
|
89
|
+
}
|
|
90
|
+
async function demoManualMode() {
|
|
91
|
+
console.log("\n" + "=".repeat(60));
|
|
92
|
+
console.log("MANUAL MODE DEMONSTRATION");
|
|
93
|
+
console.log("=".repeat(60));
|
|
94
|
+
console.log("In manual mode, nodes only execute when explicitly called.\n");
|
|
95
|
+
const registry = setupBasicGraphRegistry();
|
|
96
|
+
registerDelayNode(registry);
|
|
97
|
+
const builder = new GraphBuilder(registry);
|
|
98
|
+
const def = buildDef();
|
|
99
|
+
const runtime = builder.build(def);
|
|
100
|
+
const engine = new LocalEngine(runtime, "manual");
|
|
101
|
+
installLogging(engine);
|
|
102
|
+
engine.launch();
|
|
103
|
+
// Configure nodes
|
|
104
|
+
engine.setInputs("math1", { Operation: BaseMathOperation.Add });
|
|
105
|
+
engine.setInputs("math2", { Operation: BaseMathOperation.Multiply, B: [2] });
|
|
106
|
+
engine.setInputs("delay1", { DelayMs: 100 });
|
|
107
|
+
engine.setInputs("delay2", { DelayMs: 100 });
|
|
108
|
+
console.log("Step 1: Set input1 = 5");
|
|
109
|
+
console.log(" → input1 runs immediately (input nodes run when Value is set, even in manual mode)");
|
|
110
|
+
console.log(" → math1 does NOT run automatically (waits for explicit call)\n");
|
|
111
|
+
engine.setInputs("input1", { Value: 5 });
|
|
112
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
113
|
+
console.log("Step 2: computeNode('math1') - runs math1 and upstream nodes");
|
|
114
|
+
console.log(" → math1 runs using input1's output (A=5, B=undefined) → Result=5 (uses defaults for B)");
|
|
115
|
+
console.log(" → math2 does NOT run (no propagation)\n");
|
|
116
|
+
await engine.computeNode("math1");
|
|
117
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
118
|
+
console.log("Step 3: Set input1=7, then computeNode('math1')");
|
|
119
|
+
console.log(" → input1 runs immediately when Value is set");
|
|
120
|
+
console.log(" → math1 runs as an isolated compute (no downstream propagation)");
|
|
121
|
+
console.log(" → Note: math1 may use previous B value if input2 hasn't run yet\n");
|
|
122
|
+
engine.setInputs("input1", { Value: 7 });
|
|
123
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
124
|
+
await engine.computeNode("math1");
|
|
125
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
126
|
+
console.log("Step 4: Set input1=7, then runFromHere('math1') - runs math1 AND all downstream");
|
|
127
|
+
console.log(" → input1 runs immediately when Value is set");
|
|
128
|
+
console.log(" → math1 runs (A=7, B=undefined) → Result=7 (uses defaults for B)");
|
|
129
|
+
console.log(" → math2 runs → delay1 runs → delay2 runs\n");
|
|
130
|
+
engine.setInputs("input1", { Value: 7 });
|
|
131
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
132
|
+
await engine.runFromHere("math1");
|
|
133
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
134
|
+
console.log("Step 5: Set input2 = 4, then runFromHere('math1') - runs upstream and downstream");
|
|
135
|
+
console.log(" → input2 runs immediately when Value is set");
|
|
136
|
+
console.log(" → math1 runs (A=7, B=4) → Result=11");
|
|
137
|
+
console.log(" → math2 runs (A=11, B=2) → Result=22");
|
|
138
|
+
console.log(" → delay1 runs (delay2 may run after delay1 completes)\n");
|
|
139
|
+
engine.setInputs("input2", { Value: 4 });
|
|
140
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
141
|
+
await engine.runFromHere("math1");
|
|
142
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
143
|
+
console.log("Step 6: computeNode('math2') - runs ONLY math2");
|
|
144
|
+
console.log(" → math2 runs with current inputs (A=11, B=2) → Result=22");
|
|
145
|
+
console.log(" → delay1 does NOT run (no propagation)\n");
|
|
146
|
+
await engine.computeNode("math2");
|
|
147
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
148
|
+
await engine.whenIdle();
|
|
149
|
+
engine.dispose();
|
|
150
|
+
}
|
|
151
|
+
async function demoModeSwitching() {
|
|
152
|
+
console.log("\n" + "=".repeat(60));
|
|
153
|
+
console.log("MODE SWITCHING DEMONSTRATION");
|
|
154
|
+
console.log("=".repeat(60));
|
|
155
|
+
console.log("You can switch between modes at runtime.\n");
|
|
156
|
+
const registry = setupBasicGraphRegistry();
|
|
157
|
+
registerDelayNode(registry);
|
|
158
|
+
const builder = new GraphBuilder(registry);
|
|
159
|
+
const def = buildDef();
|
|
160
|
+
const runtime = builder.build(def);
|
|
161
|
+
const engine = new LocalEngine(runtime, "manual");
|
|
162
|
+
installLogging(engine);
|
|
163
|
+
engine.launch();
|
|
164
|
+
// Configure nodes
|
|
165
|
+
engine.setInputs("math1", { Operation: BaseMathOperation.Add });
|
|
166
|
+
engine.setInputs("math2", { Operation: BaseMathOperation.Multiply, B: [2] });
|
|
167
|
+
engine.setInputs("delay1", { DelayMs: 100 });
|
|
168
|
+
engine.setInputs("delay2", { DelayMs: 100 });
|
|
169
|
+
console.log("Starting in MANUAL mode");
|
|
170
|
+
console.log("Step 1: Set input1 = 5");
|
|
171
|
+
console.log(" → input1 runs immediately (input nodes run when Value is set)\n");
|
|
172
|
+
engine.setInputs("input1", { Value: 5 });
|
|
173
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
174
|
+
console.log("Step 2: Set input2 = 0, then switch to AUTO mode");
|
|
175
|
+
engine.setInputs("input2", { Value: 0 });
|
|
176
|
+
engine.setRunMode("auto");
|
|
177
|
+
console.log(" → input2 runs and outputs 0");
|
|
178
|
+
console.log(" → math1 automatically runs (A=5, B=0) → Result=5");
|
|
179
|
+
console.log(" → math2 automatically runs (A=5, B=2) → Result=10");
|
|
180
|
+
console.log(" → delay1 automatically runs → delay2 automatically runs\n");
|
|
181
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
182
|
+
console.log("Step 3: Switch back to MANUAL mode");
|
|
183
|
+
engine.setRunMode("manual");
|
|
184
|
+
console.log("Step 4: Set input2 = 8");
|
|
185
|
+
console.log(" → input2.Value is set to 8");
|
|
186
|
+
console.log(" → In manual mode, input nodes run when Value is set, but after mode switching they may need explicit trigger");
|
|
187
|
+
console.log(" → math1 does NOT run automatically (waits for explicit call)\n");
|
|
188
|
+
engine.setInputs("input2", { Value: 8 });
|
|
189
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
190
|
+
console.log("Step 5a: runFromHere('math1') - may use old input2 value");
|
|
191
|
+
console.log(" → math1 runs, but input2 may not have run yet, so uses old B=0 → Result=5");
|
|
192
|
+
console.log(" → math2 does NOT run (math1 output didn't change)\n");
|
|
193
|
+
await engine.runFromHere("math1");
|
|
194
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
195
|
+
console.log("Step 5b: Explicitly run input2, then runFromHere('math1') - uses new value");
|
|
196
|
+
console.log(" → input2 runs and outputs 8");
|
|
197
|
+
console.log(" → math1 runs with current inputs (A=5, B=8) → Result=13");
|
|
198
|
+
console.log(" → math2 runs (A=13, B=2) → Result=26");
|
|
199
|
+
console.log(" → delay1 runs → delay2 runs\n");
|
|
200
|
+
await engine.computeNode("input2");
|
|
201
|
+
await engine.runFromHere("math1");
|
|
202
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
203
|
+
await engine.whenIdle();
|
|
204
|
+
engine.dispose();
|
|
205
|
+
}
|
|
206
|
+
export async function main() {
|
|
207
|
+
await demoAutoMode();
|
|
208
|
+
await demoManualMode();
|
|
209
|
+
await demoModeSwitching();
|
|
210
|
+
console.log("\n" + "=".repeat(60));
|
|
211
|
+
console.log("SUMMARY");
|
|
212
|
+
console.log("=".repeat(60));
|
|
213
|
+
console.log("AUTO MODE:");
|
|
214
|
+
console.log(" • Nodes automatically execute when inputs change");
|
|
215
|
+
console.log(" • Changes propagate through the entire graph automatically");
|
|
216
|
+
console.log(" • Use setInputs() and nodes run themselves\n");
|
|
217
|
+
console.log("MANUAL MODE:");
|
|
218
|
+
console.log(" • Nodes only execute when explicitly called");
|
|
219
|
+
console.log(" • Use computeNode(nodeId) to run a node (no downstream propagation, but upstream nodes run if needed)");
|
|
220
|
+
console.log(" • Use runFromHere(nodeId) to run a node and all downstream nodes (upstream nodes run if needed)");
|
|
221
|
+
console.log(" • Use computeNode(nodeId) to run one node without downstream propagation\n");
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=runMode.js.map
|