@hology/core 0.0.211 → 0.0.213
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/dist/effects/sequence/index.d.ts +1 -0
- package/dist/effects/sequence/index.js +1 -1
- package/dist/effects/sequence/sequence-action.d.ts +5 -0
- package/dist/effects/sequence/sequence-actor.d.ts +7 -0
- package/dist/effects/sequence/sequence-actor.js +1 -1
- package/dist/effects/sequence/sequence-animation-retiming.js +1 -1
- package/dist/effects/sequence/sequence-data.d.ts +9 -0
- package/dist/effects/sequence/sequence-data.js +1 -1
- package/dist/effects/sequence/sequence-player.d.ts +12 -1
- package/dist/effects/sequence/sequence-player.js +1 -1
- package/dist/effects/sequence/sequence-transform.d.ts +10 -0
- package/dist/effects/sequence/sequence-transform.js +4 -0
- package/dist/effects/sequence/sequence-value-lane.d.ts +2 -0
- package/dist/effects/sequence/sequence-value-lane.js +1 -1
- package/dist/effects/vfx/initializsers.d.ts +8 -1
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/vfx-actor.d.ts +5 -0
- package/dist/effects/vfx/vfx-actor.js +1 -1
- package/dist/effects/vfx/vfx-asset.d.ts +2 -1
- package/dist/effects/vfx/vfx-asset.js +1 -1
- package/dist/effects/vfx/vfx-collision-behaviour.js +1 -1
- package/dist/effects/vfx/vfx-defs.d.ts +10 -1
- package/dist/effects/vfx/vfx-defs.js +1 -1
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/effects/vfx/vfx-renderers.d.ts +2 -0
- package/dist/effects/vfx/vfx-renderers.js +1 -1
- package/dist/gameplay/actors/actor.d.ts +21 -1
- package/dist/gameplay/actors/actor.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -0
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement-like.d.ts +25 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-like.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-policy.d.ts +26 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-policy.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +158 -55
- package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.d.ts +128 -0
- package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/old-character-movement.d.ts +100 -0
- package/dist/gameplay/actors/builtin/components/character/old-character-movement.js +4 -0
- package/dist/gameplay/actors/builtin/components/index.d.ts +2 -0
- package/dist/gameplay/actors/builtin/components/index.js +1 -1
- package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
- package/dist/gameplay/actors/builtin/components/tween-component.js +1 -1
- package/dist/gameplay/actors/builtin/navmesh-actor.d.ts +2 -0
- package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
- package/dist/gameplay/actors/builtin/trigger-volume.d.ts +3 -3
- package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
- package/dist/gameplay/actors/camera/camera-component.d.ts +1 -3
- package/dist/gameplay/actors/camera/camera-component.js +1 -1
- package/dist/gameplay/actors/camera/third-person-camera-component.d.ts +3 -0
- package/dist/gameplay/actors/camera/third-person-camera-component.js +1 -1
- package/dist/gameplay/actors/component.d.ts +3 -0
- package/dist/gameplay/actors/component.js +1 -1
- package/dist/gameplay/actors/controller/actor-controller.d.ts +16 -0
- package/dist/gameplay/actors/controller/actor-controller.js +4 -0
- package/dist/gameplay/actors/factory.d.ts +3 -0
- package/dist/gameplay/actors/factory.js +1 -1
- package/dist/gameplay/actors/index.d.ts +4 -0
- package/dist/gameplay/actors/index.js +1 -1
- package/dist/gameplay/actors/internal/component-init.js +1 -1
- package/dist/gameplay/actors/type-registry.d.ts +10 -0
- package/dist/gameplay/actors/type-registry.js +4 -0
- package/dist/gameplay/ai/behavior-tree/move.d.ts +2 -2
- package/dist/gameplay/animation/retarget.d.ts +50 -0
- package/dist/gameplay/animation/retarget.js +4 -0
- package/dist/gameplay/animation/root-motion.js +1 -1
- package/dist/gameplay/event-graph/actor-transform-properties.d.ts +6 -0
- package/dist/gameplay/event-graph/actor-transform-properties.js +4 -0
- package/dist/gameplay/event-graph/asset-actor-types.d.ts +3 -0
- package/dist/gameplay/event-graph/asset-actor-types.js +4 -0
- package/dist/gameplay/event-graph/asset-references.d.ts +12 -0
- package/dist/gameplay/event-graph/asset-references.js +4 -0
- package/dist/gameplay/event-graph/compiler.d.ts +107 -0
- package/dist/gameplay/event-graph/compiler.js +4 -0
- package/dist/gameplay/event-graph/decorators.d.ts +74 -0
- package/dist/gameplay/event-graph/decorators.js +4 -0
- package/dist/gameplay/event-graph/document-compiler.d.ts +107 -0
- package/dist/gameplay/event-graph/document-compiler.js +4 -0
- package/dist/gameplay/event-graph/event-graph-demo.d.ts +2 -0
- package/dist/gameplay/event-graph/event-graph-demo.js +4 -0
- package/dist/gameplay/event-graph/graph.d.ts +106 -0
- package/dist/gameplay/event-graph/graph.js +4 -0
- package/dist/gameplay/event-graph/index.d.ts +13 -0
- package/dist/gameplay/event-graph/index.js +4 -0
- package/dist/gameplay/event-graph/model.d.ts +71 -0
- package/dist/gameplay/event-graph/model.js +4 -0
- package/dist/gameplay/event-graph/nodes/execution-nodes.d.ts +115 -0
- package/dist/gameplay/event-graph/nodes/execution-nodes.js +4 -0
- package/dist/gameplay/event-graph/nodes/gameplay-nodes.d.ts +208 -0
- package/dist/gameplay/event-graph/nodes/gameplay-nodes.js +4 -0
- package/dist/gameplay/event-graph/nodes/index.d.ts +4 -0
- package/dist/gameplay/event-graph/nodes/index.js +4 -0
- package/dist/gameplay/event-graph/nodes/value-nodes.d.ts +53 -0
- package/dist/gameplay/event-graph/nodes/value-nodes.js +4 -0
- package/dist/gameplay/event-graph/registry.d.ts +33 -0
- package/dist/gameplay/event-graph/registry.js +4 -0
- package/dist/gameplay/event-graph/runtime-assets.d.ts +21 -0
- package/dist/gameplay/event-graph/runtime-assets.js +4 -0
- package/dist/gameplay/event-graph/runtime.d.ts +160 -0
- package/dist/gameplay/event-graph/runtime.js +4 -0
- package/dist/gameplay/event-graph/type-inference.d.ts +41 -0
- package/dist/gameplay/event-graph/type-inference.js +4 -0
- package/dist/gameplay/event-graph/types.d.ts +77 -0
- package/dist/gameplay/event-graph/types.js +4 -0
- package/dist/gameplay/index.d.ts +17 -2
- package/dist/gameplay/index.js +1 -1
- package/dist/gameplay/initiate.d.ts +4 -0
- package/dist/gameplay/initiate.js +1 -1
- package/dist/gameplay/input/input.d.ts +22 -17
- package/dist/gameplay/input/input.js +1 -1
- package/dist/gameplay/net/browser/index.d.ts +147 -0
- package/dist/gameplay/net/browser/index.js +4 -0
- package/dist/gameplay/net/index.d.ts +7 -0
- package/dist/gameplay/net/index.js +4 -0
- package/dist/gameplay/net/net-connection.d.ts +25 -0
- package/dist/gameplay/net/net-connection.js +4 -0
- package/dist/gameplay/net/net-session.d.ts +70 -0
- package/dist/gameplay/net/net-session.js +4 -0
- package/dist/gameplay/net/service/net-actor-role.d.ts +12 -0
- package/dist/gameplay/net/service/net-actor-role.js +4 -0
- package/dist/gameplay/net/service/net-decorator.d.ts +29 -0
- package/dist/gameplay/net/service/net-decorator.js +4 -0
- package/dist/gameplay/net/service/net-serializer.d.ts +15 -0
- package/dist/gameplay/net/service/net-serializer.js +4 -0
- package/dist/gameplay/net/service/net-service.d.ts +171 -0
- package/dist/gameplay/net/service/net-service.js +4 -0
- package/dist/gameplay/net/service/net-utils.d.ts +8 -0
- package/dist/gameplay/net/service/net-utils.js +4 -0
- package/dist/gameplay/net/service/replication.d.ts +31 -0
- package/dist/gameplay/net/service/replication.js +4 -0
- package/dist/gameplay/net/service/rpc-decorator.d.ts +21 -0
- package/dist/gameplay/net/service/rpc-decorator.js +4 -0
- package/dist/gameplay/net/service/rpc.d.ts +35 -0
- package/dist/gameplay/net/service/rpc.js +4 -0
- package/dist/gameplay/services/asset-loader.d.ts +10 -2
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/physics/physics-system.d.ts +16 -1
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/gameplay/services/world.d.ts +25 -2
- package/dist/gameplay/services/world.js +1 -1
- package/dist/rendering/color-pass.js +1 -1
- package/dist/rendering.d.ts +2 -0
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.d.ts +7 -1
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/batched-mesh-2.d.ts +9 -0
- package/dist/scene/batched-mesh-2.js +1 -1
- package/dist/scene/bootstrap.d.ts +2 -0
- package/dist/scene/bootstrap.js +1 -1
- package/dist/scene/custom-param-deserialize.js +1 -1
- package/dist/scene/custom-param-runtime-types.js +1 -1
- package/dist/scene/materializer.d.ts +29 -0
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/model.d.ts +114 -2
- package/dist/scene/model.js +1 -1
- package/dist/scene/objects/prefab.js +1 -1
- package/dist/scene/storage/storage.d.ts +1 -1
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/shader/builtin/toon-shader.js +1 -1
- package/dist/shader/builtin/unlit-shader.js +1 -1
- package/dist/shader/color-layer.js +1 -1
- package/dist/shader/graph/compiler.d.ts +3 -0
- package/dist/shader/graph/compiler.js +1 -1
- package/dist/shader/graph/model.d.ts +1 -1
- package/dist/shader/graph/registry.js +1 -1
- package/dist/shader/parameter.d.ts +1 -1
- package/dist/shader/parameter.js +1 -1
- package/dist/shader-nodes/depth.js +1 -1
- package/dist/shader-nodes/scene-sample.js +1 -1
- package/dist/test/animation-retarget.test.d.ts +2 -0
- package/dist/test/animation-retarget.test.js +4 -0
- package/dist/test/batched-mesh-2.test.d.ts +2 -0
- package/dist/test/batched-mesh-2.test.js +4 -0
- package/dist/test/browser-net-session.test.d.ts +2 -0
- package/dist/test/browser-net-session.test.js +4 -0
- package/dist/test/event-graph-generated-code.test.d.ts +2 -0
- package/dist/test/event-graph-generated-code.test.js +4 -0
- package/dist/test/event-graph-types.test.d.ts +2 -0
- package/dist/test/event-graph-types.test.js +4 -0
- package/dist/test/event-graph.test.d.ts +2 -0
- package/dist/test/event-graph.test.js +4 -0
- package/dist/test/first-person-camera-component.test.js +1 -1
- package/dist/test/input.test.d.ts +2 -0
- package/dist/test/input.test.js +4 -0
- package/dist/test/net-character-movement.test.d.ts +2 -0
- package/dist/test/net-character-movement.test.js +4 -0
- package/dist/test/net-property-snapshot.test.d.ts +2 -0
- package/dist/test/net-property-snapshot.test.js +4 -0
- package/dist/test/prefab-instance-params.test.js +1 -1
- package/dist/test/sequence-animation-retiming.test.js +1 -1
- package/dist/test/sequence-camera-control.test.js +1 -1
- package/dist/test/sequence-scene-binding.test.d.ts +2 -0
- package/dist/test/sequence-scene-binding.test.js +4 -0
- package/dist/test/sequence-transform.test.d.ts +2 -0
- package/dist/test/sequence-transform.test.js +4 -0
- package/dist/test/shader-graph.test.js +1 -1
- package/dist/test/vfx-random-color-initializer.test.d.ts +2 -0
- package/dist/test/vfx-random-color-initializer.test.js +4 -0
- package/dist/test/world-prefab-spawn.test.d.ts +2 -0
- package/dist/test/world-prefab-spawn.test.js +4 -0
- package/dist/utils/three/placeholder-texture.d.ts +3 -0
- package/dist/utils/three/placeholder-texture.js +4 -0
- package/package.json +18 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Euler, Vector2, Vector3 } from 'three';
|
|
2
|
+
import type { EventGraphDocument, EventGraphTransformAxis, EventGraphTransformSpace } from './model.js';
|
|
3
|
+
import { type EventGraphTypeAnalysis, type EventGraphTypeContext } from './type-inference.js';
|
|
4
|
+
export type EventGraphHandler = (runtime: EventGraphExecutionContext, eventValue?: unknown) => unknown;
|
|
5
|
+
export interface EventGraphExecutionContext {
|
|
6
|
+
actor(id: string): unknown;
|
|
7
|
+
component(target: unknown, property: string): unknown;
|
|
8
|
+
getProperty(target: unknown, property: string): unknown;
|
|
9
|
+
setProperty(target: unknown, property: string, value: unknown): void;
|
|
10
|
+
tweenProperty(target: unknown, property: string, to: unknown, duration: number, curve: string, completed: (() => unknown) | undefined, eventNodeId: string): void;
|
|
11
|
+
tweenMoveTo(target: unknown, position: Vector3, duration: number, curve: string, space: EventGraphTransformSpace, completed: (() => unknown) | undefined, eventNodeId: string): void;
|
|
12
|
+
tweenMoveBy(target: unknown, offset: Vector3, duration: number, curve: string, space: EventGraphTransformSpace, completed: (() => unknown) | undefined, eventNodeId: string): void;
|
|
13
|
+
tweenRotateTo(target: unknown, rotation: Euler, duration: number, curve: string, space: EventGraphTransformSpace, completed: (() => unknown) | undefined, eventNodeId: string): void;
|
|
14
|
+
tweenRotateBy(target: unknown, angleDegrees: number, duration: number, curve: string, space: EventGraphTransformSpace, axis: EventGraphTransformAxis, completed: (() => unknown) | undefined, eventNodeId: string): void;
|
|
15
|
+
tweenScaleTo(target: unknown, scale: Vector3, duration: number, curve: string, completed: (() => unknown) | undefined, eventNodeId: string): void;
|
|
16
|
+
tweenScaleBy(target: unknown, factor: Vector3, duration: number, curve: string, completed: (() => unknown) | undefined, eventNodeId: string): void;
|
|
17
|
+
callMethod(target: unknown, method: string, args: unknown[]): unknown;
|
|
18
|
+
actorClass(classId: string): unknown;
|
|
19
|
+
findActorByType(actorClass: unknown): unknown;
|
|
20
|
+
findActorsByType(actorClass: unknown): unknown[];
|
|
21
|
+
bindEventSource(nodeId: string, target: unknown, method: string, args: unknown[], callback: ((value: unknown) => unknown) | undefined, eventNodeId: string): void;
|
|
22
|
+
spawnActor(classId: string): Promise<unknown>;
|
|
23
|
+
spawnPrefab(assetId: string, position: Vector3, rotation: Euler): Promise<{
|
|
24
|
+
instance: unknown;
|
|
25
|
+
mainActor: unknown | null;
|
|
26
|
+
}>;
|
|
27
|
+
playVfx(assetId: string, position: Vector3, rotation: Euler, autoDestroy: boolean): Promise<unknown>;
|
|
28
|
+
playSequence(assetId: string, target: unknown | null, cameraControlEnabled: boolean, autoDestroy: boolean): Promise<unknown>;
|
|
29
|
+
onActorCompleted(actor: unknown, callback: () => unknown, eventNodeId: string): void;
|
|
30
|
+
destroyPrefab(instance: unknown): void;
|
|
31
|
+
destroyActor(actor: unknown): void;
|
|
32
|
+
getVariable(name: string): unknown;
|
|
33
|
+
setVariable(name: string, value: unknown): void;
|
|
34
|
+
delay(durationMs: number): Promise<void>;
|
|
35
|
+
setInterval(nodeId: string, intervalMs: number, callback: (() => unknown) | undefined, eventNodeId: string): number | undefined;
|
|
36
|
+
clearInterval(intervalId: number): void;
|
|
37
|
+
doOnce(nodeId: string, entryPort: string, startClosed: boolean): boolean;
|
|
38
|
+
gate(nodeId: string, entryPort: string, startClosed: boolean): boolean;
|
|
39
|
+
readValue(value: unknown): unknown;
|
|
40
|
+
mathAdd(a: unknown, b: unknown): unknown;
|
|
41
|
+
mathSubtract(a: unknown, b: unknown): unknown;
|
|
42
|
+
mathMultiply(a: unknown, b: unknown): unknown;
|
|
43
|
+
mathDivide(a: unknown, b: unknown): unknown;
|
|
44
|
+
mathModulo(a: unknown, b: unknown): unknown;
|
|
45
|
+
vectorLength(value: unknown): number;
|
|
46
|
+
vectorLengthSquared(value: unknown): number;
|
|
47
|
+
vectorDistance(a: unknown, b: unknown): number;
|
|
48
|
+
vectorDistanceSquared(a: unknown, b: unknown): number;
|
|
49
|
+
vectorNormalize(value: unknown): unknown;
|
|
50
|
+
vectorDot(a: unknown, b: unknown): number;
|
|
51
|
+
vectorCross(a: unknown, b: unknown): Vector3;
|
|
52
|
+
vectorLerp(a: unknown, b: unknown, alpha: number): unknown;
|
|
53
|
+
vectorApplyRotation(value: unknown, rotation: Euler): Vector3;
|
|
54
|
+
createVector2(x: number, y: number): Vector2;
|
|
55
|
+
createVector3(x: number, y: number, z: number): Vector3;
|
|
56
|
+
createEuler(x: number, y: number, z: number): Euler;
|
|
57
|
+
}
|
|
58
|
+
export interface CompiledEventGraphHandler {
|
|
59
|
+
eventNodeId: string;
|
|
60
|
+
source: string;
|
|
61
|
+
async: boolean;
|
|
62
|
+
invoke: EventGraphHandler;
|
|
63
|
+
}
|
|
64
|
+
export interface CompiledObservableEvent extends CompiledEventGraphHandler {
|
|
65
|
+
actorId: string;
|
|
66
|
+
component?: string;
|
|
67
|
+
property: string;
|
|
68
|
+
}
|
|
69
|
+
export type CompiledEventSourceArgument = {
|
|
70
|
+
kind: 'actor';
|
|
71
|
+
actorId: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'actorClass';
|
|
74
|
+
classId: string;
|
|
75
|
+
};
|
|
76
|
+
export interface CompiledEventSourceEvent extends CompiledEventGraphHandler {
|
|
77
|
+
actorId: string;
|
|
78
|
+
component?: string;
|
|
79
|
+
method: string;
|
|
80
|
+
args: CompiledEventSourceArgument[];
|
|
81
|
+
}
|
|
82
|
+
export interface CompiledEventGraph {
|
|
83
|
+
beginPlay: CompiledEventGraphHandler[];
|
|
84
|
+
update: CompiledEventGraphHandler[];
|
|
85
|
+
endPlay: CompiledEventGraphHandler[];
|
|
86
|
+
observables: CompiledObservableEvent[];
|
|
87
|
+
eventSources: CompiledEventSourceEvent[];
|
|
88
|
+
}
|
|
89
|
+
export interface EventGraphDiagnostic {
|
|
90
|
+
code: string;
|
|
91
|
+
severity: 'error' | 'warning';
|
|
92
|
+
nodeId?: string;
|
|
93
|
+
portId?: string;
|
|
94
|
+
path: readonly (string | number)[];
|
|
95
|
+
message: string;
|
|
96
|
+
}
|
|
97
|
+
export interface EventGraphValidationResult {
|
|
98
|
+
diagnostics: readonly EventGraphDiagnostic[];
|
|
99
|
+
typeAnalysis: EventGraphTypeAnalysis | null;
|
|
100
|
+
}
|
|
101
|
+
/** Validates a persisted document, lowers it into node IR, and compiles each event entry point. */
|
|
102
|
+
export declare class EventGraphCompiler {
|
|
103
|
+
compile(graph: EventGraphDocument, typeContext?: EventGraphTypeContext): CompiledEventGraph;
|
|
104
|
+
}
|
|
105
|
+
/** Runs the same structural and type checks used by compilation without throwing. */
|
|
106
|
+
export declare function validateEventGraphDocument(graph: EventGraphDocument, typeContext?: EventGraphTypeContext): EventGraphValidationResult;
|
|
107
|
+
//# sourceMappingURL=document-compiler.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{getActorClassById as e,getComponentClassById as t}from"../actors/type-registry.js";import{collectEventGraphAssetReferences as n,isEventGraphAssetReference as r}from"./asset-references.js";import{Compiler as o}from"./compiler.js";import{ExecutionNode as i,PureNode as s}from"./graph.js";import{normalizeEventGraphDocument as a}from"./model.js";import{EVENT_GRAPH_NODE_DEFINITIONS as u,getEventGraphInputDefault as d,getEventGraphNodePorts as c,getEventGraphPortDefinition as l}from"./registry.js";import{isEventGraphLiteralAssignableToType as p,isEventGraphType as h}from"./types.js";import{analyzeEventGraphTypes as f}from"./type-inference.js";import{BranchNode as w,ClearIntervalNode as m,DelayNode as g,DoOnceNode as y,ForLoopNode as v,GateNode as N,IntervalNode as E,ForEachNode as $,LogNode as k,ParallelNode as S,SequenceNode as b,IsValidNode as I,SelectNode as O,StartNode as J}from"./nodes/execution-nodes.js";import{ActorReferenceNode as x,AssetReferenceNode as A,BinaryOperatorNode as T,CallMethodNode as q,ComponentReferenceNode as C,DestroyActorNode as j,DestroyPrefabNode as M,EventValueNode as P,BindEventSourceNode as R,FindActorByTypeNode as B,FindActorsByTypeNode as z,GetPropertyNode as V,GraphVariableNode as D,LiteralNode as L,NotNode as F,PlaySequenceNode as G,PlayVfxNode as U,RuntimeCallbackNode as W,RuntimeLiteralNode as _,SetGraphVariableNode as H,SetPropertyNode as K,SpawnActorNode as Q,SpawnPrefabNode as X,TryCallMethodNode as Y,VectorApplyRotationNode as Z,VectorBinaryOperatorNode as ee,VectorEqualityNode as te,VectorLerpNode as ne,VectorMathOperatorNode as re,VectorUnaryOperatorNode as oe}from"./nodes/gameplay-nodes.js";import{getEventGraphEventSourceInfo as ie,getEventGraphPropertyInfo as se}from"./decorators.js";const ae=Object.getPrototypeOf(async function(){}).constructor;export class EventGraphCompiler{compile(e,t={}){const n=ue(e=a(e),t),r=n.result.diagnostics.filter(e=>"error"===e.severity);if(r.length>0||null==n.document)throw new Error(`Event graph validation failed:\n${r.map(de).join("\n")}`);const o=n.document,i=n.result.typeAnalysis,s={beginPlay:[],update:[],endPlay:[],observables:[],eventSources:[]};for(const n of e.nodes){if(!0!==u[n.kind].event)continue;const e=new le(o,n,i).compile();if("event.beginPlay"===n.kind&&s.beginPlay.push(e),"event.update"===n.kind&&s.update.push(e),"event.endPlay"===n.kind&&s.endPlay.push(e),"event.observable"===n.kind){const t=Je(n,"component");s.observables.push({...e,actorId:Oe(n,"actorId"),property:Oe(n,"property"),...null!=t?{component:t}:{}})}if("event.source"===n.kind){const r=Je(n,"component"),o=Oe(n,"source"),i=he(pe(n,t),o);s.eventSources.push({...e,actorId:Oe(n,"actorId"),method:o,args:fe(n,i),...null!=r?{component:r}:{}})}}return s}}export function validateEventGraphDocument(e,t={}){return ue(e,t).result}function ue(e,t){e=a(e);const r=[],o=new ce(e);let i=!0;try{o.validate()}catch(e){i=!1,r.push({code:"invalid-structure",severity:"error",path:[],message:e instanceof Error?e.message:String(e)})}i&&r.push(...function(e){const t=new Map(e.nodes.map(e=>[e.id,e])),n=[];for(const r of["data","execution"]){const o=new Map;for(const n of e.edges){const e=t.get(n.from.nodeId);if(null==e||l(e,n.from.port,"outputs")?.kind!==r)continue;const i=o.get(n.from.nodeId)??[];i.push(n),o.set(n.from.nodeId,i)}const i=new Set,s=new Set;let a;const u=e=>{if(i.has(e))return!0;if(s.has(e))return!1;i.add(e);for(const t of o.get(e)??[])if(u(t.to.nodeId))return a=t,!0;return i.delete(e),s.add(e),!1};for(const t of e.nodes)if(u(t.id))break;null!=a&&n.push({code:`${r}-cycle`,severity:"error",nodeId:a.to.nodeId,portId:a.to.port,path:["edges"],message:`Event graph contains a ${r} cycle`})}return n}(e)),i&&r.push(...function(e,t){return null==t.resolveAssetType?[]:n(e).flatMap(e=>{const n=t.resolveAssetType(e.reference.assetId);return void 0===n?[{code:"missing-asset",severity:"error",...null!=e.nodeId?{nodeId:e.nodeId}:{},...null!=e.portId?{portId:e.portId}:{},path:e.path,message:`Asset ${JSON.stringify(e.reference.assetId)} does not exist`}]:n!==e.reference.assetType?[{code:"wrong-asset-type",severity:"error",...null!=e.nodeId?{nodeId:e.nodeId}:{},...null!=e.portId?{portId:e.portId}:{},path:e.path,message:`Expected ${e.reference.assetType} asset, received ${n}`}]:[]})}(e,t));let s=null;if(i)try{s=f(e,t),r.push(...function(e,t){const n=new Set(e.edges.map(e=>Te(e.to))),r=[];for(const o of e.nodes)for(const e of c(o,"inputs"))"data"===e.kind&&!0!==e.optional&&(null!=o.inputs?.[e.name]||n.has(Te({nodeId:o.id,port:e.name}))||void 0===d(o,e.name)&&(ke(o)&&void 0!==Se(t.getInputType(o.id,e.name))||r.push({code:"missing-input",severity:"error",nodeId:o.id,portId:e.name,path:["nodes",o.id,"inputs",e.name],message:`Required input ${JSON.stringify(e.label??e.name)} is not connected and has no fallback value`})));return r}(e,s),...function(e,t){const n=new Map(e.nodes.map(e=>[e.id,e])),r=[],o=new Set,i=e=>{const i=n.get(e.nodeId);if(null==i||null!=l(i,e.port,"outputs",t))return;const s=Te(e);o.has(s)||(o.add(s),r.push({code:"unavailable-output-port",severity:"error",nodeId:i.id,portId:e.port,path:["nodes",i.id,"outputs",e.port],message:`Output ${JSON.stringify(e.port)} is unavailable for its inferred type`}))};for(const t of e.edges)i(t.from);for(const t of e.nodes)for(const e of Object.values(t.inputs??{}))"nodeId"in e&&i(e);return r}(e,s)),r.push(...s.diagnostics.map(e=>({code:"incompatible-type",severity:e.severity,nodeId:e.nodeId,...null!=e.port?{portId:e.port}:{},path:["nodes",e.nodeId,...null!=e.port?["inputs",e.port]:[]],message:e.message})))}catch(e){r.push({code:"type-analysis-failed",severity:"error",path:[],message:e instanceof Error?e.message:String(e)})}return{result:{diagnostics:r,typeAnalysis:s},document:i?o:null}}function de(e){const t=null==e.nodeId?"":` at ${e.nodeId}${null!=e.portId?`:${e.portId}`:""}`;return`[${e.code}]${t} ${e.message}`}class ce{constructor(e){this.graph=e,this.nodes=new Map,this.variables=new Set,this.incomingEdges=new Map,this.executionEdges=new Map}validate(){if(1!==this.graph.version)throw new Error(`Unsupported event graph version ${String(this.graph.version)}`);for(const e of this.graph.variables??[]){if(0===e.name.trim().length)throw new Error("Event graph variable names must not be empty");if(this.variables.has(e.name))throw new Error(`Duplicate event graph variable ${JSON.stringify(e.name)}`);if(null!=e.type&&!h(e.type))throw new Error(`Event graph variable ${JSON.stringify(e.name)} has an invalid type`);if(null!=e.type&&void 0!==e.defaultValue&&!p(e.defaultValue,e.type))throw new Error(`Event graph variable ${JSON.stringify(e.name)} has an incompatible default value`);this.variables.add(e.name)}for(const e of this.graph.nodes){if(this.nodes.has(e.id))throw new Error(`Duplicate event graph node id ${JSON.stringify(e.id)}`);if(null==u[e.kind])throw new Error(`Unknown event graph node kind ${JSON.stringify(e.kind)}`);if(this.nodes.set(e.id,e),e.kind.startsWith("constant.")&&Ee(e),"asset.reference"===e.kind&&!r(e.params?.reference))throw new Error(`Asset Reference node ${JSON.stringify(e.id)} requires a valid reference`);"flow.sequence"!==e.kind&&"flow.parallel"!==e.kind||ye(e),"flow.switch"===e.kind&&ve(e)}for(const e of this.graph.edges){const t=this.getNode(e.from.nodeId),n=this.getNode(e.to.nodeId),r=Ne(t,e.from.port,"outputs"),o=Ne(n,e.to.port,"inputs");if(r.kind!==o.kind)throw new Error(`Event graph edge ${qe(e)} mixes data and execution ports`);if("data"===o.kind){const t=Te(e.to);if(this.incomingEdges.has(t))throw new Error(`Event graph input ${JSON.stringify(t)} has more than one connection`);this.incomingEdges.set(t,e)}if("execution"===r.kind){const t=Te(e.from);if(this.executionEdges.has(t))throw new Error(`Execution output ${JSON.stringify(t)} has more than one connection`);if(!0===u[n.kind].event)throw new Error("Event nodes cannot be reached through execution inputs");this.executionEdges.set(t,e)}}for(const e of this.graph.nodes)for(const[t,n]of Object.entries(e.inputs??{})){if("data"!==Ne(e,t,"inputs").kind)throw new Error(`Explicit node input ${JSON.stringify(`${e.id}:${t}`)} must be a data port`);if("nodeId"in n){if("data"!==Ne(this.getNode(n.nodeId),n.port,"outputs").kind)throw new Error(`Explicit node input ${JSON.stringify(`${e.id}:${t}`)} references an execution port`)}}}getNode(e){const t=this.nodes.get(e);if(null==t)throw new Error(`Event graph references missing node ${JSON.stringify(e)}`);return t}getInput(e,t){const n=this.incomingEdges.get(Te({nodeId:e.id,port:t}))?.from??e.inputs?.[t];if(null!=n)return n;const r=d(e,t);return void 0!==r?{value:r}:void 0}getExecutionTarget(e,t){const n=this.executionEdges.get(Te({nodeId:e.id,port:t}));return null!=n?{node:this.getNode(n.to.nodeId),inputPort:n.to.port}:void 0}}class le{constructor(e,t,n){this.document=e,this.eventNode=t,this.typeAnalysis=n,this.compiler=new o,this.loweredNodes=new Map,this.loweringNodes=new Set,this.connectedExecutionNodes=new Set,this.loweredExecutionNodes=new Map,this.eventValues=new Map}compile(){const e=new J;e.id=this.eventNode.id,this.connectExecutionOutputs(this.eventNode,e);const t=this.compiler.compile(e),n=`"use strict"\n${t.source}`,r=t.async?ae:Function;return{eventNodeId:this.eventNode.id,source:n,async:t.async,invoke:new r("runtime","eventValue",n)}}connectExecutionOutputs(e,t,n="exec"){const r=`${e.id}:${n}`;if(this.connectedExecutionNodes.has(r))return;this.connectedExecutionNodes.add(r);const o=c(e,"outputs").filter(e=>"execution"===e.kind).map(e=>e.name);for(const n of o){const r=this.document.getExecutionTarget(e,n);if(null==r)continue;const o=this.lowerExecutionNode(r.node,r.inputPort);t.connect(n,o),this.connectExecutionOutputs(r.node,o,r.inputPort)}}lowerExecutionNode(e,t="exec"){const n=`${e.id}:${t}`,r=this.loweredExecutionNodes.get(n);if(null!=r)return r;const o=this.lowerNode(e,t);if(!(o instanceof i))throw new Error(`Node ${JSON.stringify(e.id)} cannot be placed on an execution line`);return this.loweredExecutionNodes.set(n,o),o}lowerNode(e,t="exec"){const n=this.loweredNodes.get(e.id),r="flow.doOnce"===e.kind||"flow.gate"===e.kind;if(null!=n&&!r)return n;if(this.loweringNodes.has(e.id))throw new Error(`Circular data dependency at ${JSON.stringify(e.id)}`);if(!0===u[e.kind].event)throw new Error(`Event node ${JSON.stringify(e.id)} cannot be lowered as a regular node`);this.loweringNodes.add(e.id);try{const n=this.createNode(e,t);return n.id=e.id,r||this.loweredNodes.set(e.id,n),n}finally{this.loweringNodes.delete(e.id)}}createNode(e,t="exec"){if(e.kind.startsWith("constant.")){const t=Ee(e),n=this.typeAnalysis.getOutputType(e.id,"value");return $e(n)?new _(t,n):new L(t)}if("compare.equal"===e.kind||"compare.notEqual"===e.kind){const t=this.typeAnalysis.getInputType(e.id,"a");if("vector2"===t.kind||"vector3"===t.kind||"euler"===t.kind)return new te(this.input(e,"a"),this.input(e,"b"),"compare.notEqual"===e.kind)}const n={"math.add":"+","math.subtract":"-","math.multiply":"*","math.divide":"/","math.modulo":"%","compare.equal":"===","compare.notEqual":"!==","compare.greaterThan":">","compare.greaterThanOrEqual":">=","compare.lessThan":"<","compare.lessThanOrEqual":"<=","boolean.and":"&&","boolean.or":"||"}[e.kind];if(null!=n){const t=function(e){return{"math.add":"add","math.subtract":"subtract","math.multiply":"multiply","math.divide":"divide","math.modulo":"modulo"}[e]}(e.kind),r=this.typeAnalysis.getOutputType(e.id,"value");return null==t||"vector2"!==r.kind&&"vector3"!==r.kind?new T(this.input(e,"a"),this.input(e,"b"),n):new re(this.input(e,"a"),this.input(e,"b"),t)}const o=function(e){return{"vector.length":"length","vector.lengthSquared":"lengthSquared","vector.normalize":"normalize"}[e]}(e.kind);if(null!=o)return new oe(this.input(e,"value"),o);const i=function(e){return{"vector.distance":"distance","vector.distanceSquared":"distanceSquared","vector.dot":"dot","vector.cross":"cross"}[e]}(e.kind);if(null!=i)return new ee(this.input(e,"a"),this.input(e,"b"),i);switch(e.kind){case"vector.lerp":return new ne(this.input(e,"a"),this.input(e,"b"),this.input(e,"alpha"));case"vector.applyRotation":return new Z(this.input(e,"value"),this.input(e,"rotation"));case"boolean.not":return new F(this.input(e,"value"));case"flow.branch":return new w(this.input(e,"condition"));case"flow.sequence":return new b(ye(e));case"flow.parallel":return new S(...ye(e));case"flow.switch":return new O(this.input(e,"value"),ve(e));case"flow.delay":return new g(this.input(e,"durationMs"));case"flow.interval":return new E(e.id,this.input(e,"intervalMs"));case"flow.clearInterval":return new m(this.input(e,"timerId"));case"flow.forLoop":return new v(this.input(e,"firstIndex"),this.input(e,"lastIndex"));case"flow.isValid":return new I(this.input(e,"value"));case"flow.forEach":return new $(this.input(e,"array"));case"flow.doOnce":return new y(e.id,t,this.input(e,"startClosed"));case"flow.gate":return new N(e.id,t,this.input(e,"startClosed"));case"debug.log":return new k(this.input(e,"value"));case"variable.get":{const t=Ie(e,this.document.variables);return new D(t)}case"variable.set":{const t=Ie(e,this.document.variables);return new H(t,this.input(e,"value"))}case"actor.reference":return new x(Oe(e,"actorId"));case"asset.reference":return new A(function(e){const t=e.params?.reference;if(!r(t)||0===t.assetId.length)throw new Error(`Node ${JSON.stringify(e.id)} requires a valid asset reference`);return t}(e).assetId);case"actor.component":return new C(this.input(e,"target"),Oe(e,"property"));case"actor.getProperty":return new V(this.input(e,"target"),Oe(e,"property"));case"actor.setProperty":return new K(this.input(e,"target"),Oe(e,"property"),this.input(e,"value"));case"actor.tweenProperty":return new W("tweenProperty",[this.input(e,"target"),Oe(e,"property"),this.input(e,"to"),this.input(e,"duration"),Je(e,"curve")??"Linear"]);case"transform.moveTo":return new W("tweenMoveTo",this.transformTweenArgs(e,"position",!0));case"transform.moveBy":return new W("tweenMoveBy",this.transformTweenArgs(e,"offset",!0));case"transform.rotateTo":return new W("tweenRotateTo",this.transformTweenArgs(e,"rotation",!0));case"transform.rotateBy":return new W("tweenRotateBy",[this.input(e,"target"),this.input(e,"angle"),this.input(e,"duration"),Je(e,"curve")??"Linear",xe(e),Ae(e)]);case"transform.scaleTo":return new W("tweenScaleTo",this.transformTweenArgs(e,"scale",!1));case"transform.scaleBy":return new W("tweenScaleBy",this.transformTweenArgs(e,"factor",!1));case"actor.callMethod":{const t=this.callArguments(e);return new q(this.input(e,"target"),Oe(e,"method"),t,!0===e.params?.awaitResult)}case"actor.tryCallMethod":return new Y(this.input(e,"target"),Oe(e,"method"),this.callArguments(e),!0===e.params?.awaitResult);case"actor.findByType":return new B(this.input(e,"actorClass"));case"actor.findAllByType":return new z(this.input(e,"actorClass"));case"event.bindSource":{const t=this.dynamicEventSourceInfo(e);return new R(e.id,this.input(e,"target"),Oe(e,"source"),this.eventSourceRuntimeArguments(e,t),Je(e,"component"))}case"actor.spawnClass":return new Q(Oe(e,"classId"));case"actor.spawnPrefab":return new X(this.input(e,"prefab"),this.input(e,"position"),this.input(e,"rotation"));case"vfx.play":return new U(this.input(e,"vfx"),this.input(e,"position"),this.input(e,"rotation"),this.input(e,"autoDestroy"));case"sequence.play":return new G(this.input(e,"sequence"),this.input(e,"target"),this.input(e,"cameraControlEnabled"),this.input(e,"autoDestroy"));case"prefab.destroy":return new M(this.input(e,"instance"));case"actor.destroy":return new j(this.input(e,"actor"));default:throw new Error(`Node kind ${JSON.stringify(e.kind)} has no lowering implementation`)}}input(e,t){const n=this.document.getInput(e,t);if(null==n){const n=this.typeAnalysis.getInputType(e.id,t),r=ke(e)?Se(n):void 0;if(void 0!==r)return $e(n)?new _(r,n):r;throw new Error(`Node ${JSON.stringify(e.id)} is missing input ${JSON.stringify(t)}`)}if("value"in n){const r=this.typeAnalysis.getInputType(e.id,t);return $e(r)?new _(n.value,r):n.value}return this.output(n)}transformTweenArgs(e,t,n){return[this.input(e,"target"),this.input(e,t),this.input(e,"duration"),Je(e,"curve")??"Linear",...n?[xe(e)]:[]]}callArguments(e){const t=function(e,t){const n=e.params?.[t];if(null==n)return;if("number"!=typeof n)throw new Error(`Node ${JSON.stringify(e.id)} parameter ${JSON.stringify(t)} must be a number`);return n}(e,"argumentCount")??0;if(!Number.isInteger(t)||t<0)throw new Error(`Call Method node ${JSON.stringify(e.id)} has an invalid argumentCount`);return Array.from({length:t},(t,n)=>this.input(e,`arg${n}`))}dynamicEventSourceInfo(e){let t=this.connectedInputType(e,"target");return t=we(t,Je(e,"component"),Je(e,"componentTypeId")),he(t,Oe(e,"source"))}connectedInputType(e,t){const n=this.document.getInput(e,t);return null!=n&&"nodeId"in n?this.typeAnalysis.getOutputType(n.nodeId,n.port):this.typeAnalysis.getInputType(e.id,t)}eventSourceRuntimeArguments(e,t){let n=0;return t.parameters.map((t,r)=>"actorClass"===t.type.kind?{kind:"actorClass",classId:Oe(e,`arg${r}ActorClassId`)}:this.input(e,"arg"+n++))}output(e){const t=this.document.getNode(e.nodeId);if("data"!==Ne(t,e.port,"outputs").kind)throw new Error(`Socket ${JSON.stringify(Te(e))} is not a data output`);if(!0===u[t.kind].event){if(t.id!==this.eventNode.id)throw new Error(`Handler ${JSON.stringify(this.eventNode.id)} cannot read data from event ${JSON.stringify(t.id)}`);if(!function(e,t){return"event.update"===e.kind&&"deltaTime"===t||"event.observable"===e.kind&&"value"===t||"event.source"===e.kind&&"value"===t}(t,e.port))throw new Error(`Event node ${JSON.stringify(t.id)} has no data output ${JSON.stringify(e.port)}`);let n=this.eventValues.get(e.port);return null==n&&(n=new P,n.id=`${t.id}:${e.port}`,this.eventValues.set(e.port,n)),n}const n=this.lowerNode(t);return n instanceof s&&"value"===e.port?n:n.output(e.port)}}function pe(e,t){const n=Oe(e,"actorId"),r=t.resolveActorClass?.(n);return we(null!=r?{kind:"actor",classId:ge(r)}:{kind:"actor"},Je(e,"component"),Je(e,"componentTypeId"))}function he(e,t){const n=me(e),r=null!=n?ie(n,t):void 0;if(null==r)throw new Error(`Event source ${JSON.stringify(t)} is not exposed to event graphs`);return r}function fe(e,t){return t.parameters.map((n,r)=>{if("actorClass"===n.type.kind)return{kind:"actorClass",classId:Oe(e,`arg${r}ActorClassId`)};if("actor"===n.type.kind)return{kind:"actor",actorId:Oe(e,`arg${r}ActorId`)};throw new Error(`Static event source ${JSON.stringify(t.label)} parameter ${JSON.stringify(n.name)} must be an actor or actor class selector`)})}function we(e,t,n){if(null!=t){const n=function(e,t){const n=me(e);return null!=n?se(n,t):void 0}(e,t)?.type;if(null!=n)return n}return null!=n?{kind:"component",classId:n}:null!=t?{kind:"component"}:e}function me(n){return"actor"===n.kind&&null!=n.classId?e(n.classId):"component"===n.kind&&null!=n.classId?t(n.classId):void 0}function ge(e){return e.__actorId??e.name}function ye(e){const t=e.params?.ports;if(!Array.isArray(t)||0===t.length||t.some(e=>"string"!=typeof e||0===e.length))throw new Error(`${u[e.kind].label} node ${JSON.stringify(e.id)} requires non-empty string ports`);const n=t;if(n.includes("then"))throw new Error(`${u[e.kind].label} node reserves the "then" port for its continuation`);if(new Set(n).size!==n.length)throw new Error(`${u[e.kind].label} node branch names must be unique`);return n}function ve(e){const t=e.params?.cases;if(!Array.isArray(t)||0===t.length)throw new Error(`Switch node ${JSON.stringify(e.id)} requires at least one case`);const n=t.map(t=>{if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error(`Switch node ${JSON.stringify(e.id)} has an invalid case`);const n=t.port;if("string"!=typeof n||0===n.length||"then"===n||"default"===n)throw new Error(`Switch node ${JSON.stringify(e.id)} has an invalid case port`);if(!Object.prototype.hasOwnProperty.call(t,"value"))throw new Error(`Switch node ${JSON.stringify(e.id)} case ${JSON.stringify(n)} is missing a value`);return{match:be(t.value),port:n}});if(new Set(n.map(e=>e.port)).size!==n.length)throw new Error(`Switch node ${JSON.stringify(e.id)} case ports must be unique`);if(new Set(n.map(e=>e.match)).size!==n.length)throw new Error(`Switch node ${JSON.stringify(e.id)} case values must be unique`);return n}function Ne(e,t,n){const r=l(e,t,n);if(null!=r)return r;throw new Error(`Node ${JSON.stringify(e.id)} has no ${n.slice(0,-1)} port ${JSON.stringify(t)}`)}function Ee(e){const t=e.params?.value;if("constant.vector2"===e.kind||"constant.vector3"===e.kind){const n="constant.vector2"===e.kind?{kind:"vector2"}:{kind:"vector3"};if(!p(t,n))throw new Error(`Node ${JSON.stringify(e.id)} requires a finite ${n.kind} tuple`);return t}const n="constant.boolean"===e.kind?"boolean":"constant.number"===e.kind?"number":"string";if(typeof t!==n)throw new Error(`Node ${JSON.stringify(e.id)} requires a ${n} value`);if("number"==typeof t&&!Number.isFinite(t))throw new Error("Event graph numbers must be finite");return t}function $e(e){return"vector2"===e.kind||"vector3"===e.kind||"euler"===e.kind||"asset"===e.kind||"actorClass"===e.kind||"optional"===e.kind&&$e(e.value)||"array"===e.kind&&$e(e.element)}function ke(e){return"compare.equal"===e.kind||"compare.notEqual"===e.kind}function Se(e){return"boolean"!==e.kind&&("number"===e.kind?0:"string"===e.kind?"":"vector2"===e.kind?[0,0]:"vector3"===e.kind||"euler"===e.kind?[0,0,0]:void 0)}function be(e){if("number"==typeof e&&!Number.isFinite(e))throw new Error("Event graph numbers must be finite");const t=JSON.stringify(e);if(null==t)throw new Error("Event graph value cannot be serialized to JavaScript");return t}function Ie(e,t){const n=Oe(e,"variable");if(!t.has(n))throw new Error(`Node ${JSON.stringify(e.id)} references undeclared variable ${JSON.stringify(n)}`);return n}function Oe(e,t){const n=e.params?.[t];if("string"!=typeof n||0===n.length)throw new Error(`Node ${JSON.stringify(e.id)} requires a non-empty string parameter ${JSON.stringify(t)}`);return n}function Je(e,t){const n=e.params?.[t];if(null!=n&&""!==n){if("string"!=typeof n)throw new Error(`Node ${JSON.stringify(e.id)} parameter ${JSON.stringify(t)} must be a string`);return n}}function xe(e){const t=Je(e,"space")??"local";if("local"!==t&&"world"!==t)throw new Error(`Node ${JSON.stringify(e.id)} has invalid transform space ${JSON.stringify(t)}`);return t}function Ae(e){const t=Je(e,"axis")??"y";if("x"!==t&&"y"!==t&&"z"!==t)throw new Error(`Node ${JSON.stringify(e.id)} has invalid rotation axis ${JSON.stringify(t)}`);return t}function Te(e){return`${e.nodeId}:${e.port}`}function qe(e){return`${Te(e.from)} -> ${Te(e.to)}`}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{AssignNode as e,BranchNode as n,CallScopeNode as o,ConstantNumberNode as t,DelayNode as c,LogNode as s,ParallelNode as w,ParseNumberNode as l,SplitStringNode as r,StartNode as a,ThisNode as h,VariableNode as i}from"./nodes/index.js";import{Compiler as d}from"./compiler.js";const m=Object.getPrototypeOf(async function(){}).constructor,p=new d;{const d=new a,u=new t(1).add(2),f=new s(u),g=new s(new h),b=new e("assignTest",u.asString().add(" hi")),y=new s(new i("assignTest")),j=new c(1e3),O=new o,T=new w("slow","fast"),P=new c(30),v=new c(5),x=new s("both parallel branches completed"),C=new n(!0),D=new s("branch completed"),F=new l("not a number"),S=new r("hello:world",":"),k=new s(S.before),q=new s(S.after);d.then(f),f.then(g),g.then(b),b.then(y),y.then(j),j.then(O),O.then(T),T.connect("slow",P),P.then(new s("slow branch completed")),T.connect("fast",v),v.then(new s("fast branch completed")).then(q),T.then(x),x.then(C),C.connect("true",F),C.connect("false",new s("condition was false")),C.then(D),D.then(k),k.then(q),F.connect("success",new s(F.value));const z=new s(F.error);F.connect("error",z);const A=p.compile(d);console.log("----- Code -----"),console.log(A.source),console.log("----- Output -----");const B=new(A.async?m:Function)("runtime",A.source);await B.apply({foo:()=>console.log("passed function")},[{delay:e=>new Promise(n=>setTimeout(n,e))}]),console.log("----- Done ------")}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { CompilationContext } from './compiler.js';
|
|
2
|
+
export type ValueLiteral = string | number | boolean | null | ValueLiteral[] | {
|
|
3
|
+
[key: string]: ValueLiteral;
|
|
4
|
+
};
|
|
5
|
+
export type DataCompileResult = {
|
|
6
|
+
/** Setup emitted once before this node's outputs are first used in a block. */
|
|
7
|
+
setup?: string;
|
|
8
|
+
outputs: Readonly<Record<string, string>>;
|
|
9
|
+
};
|
|
10
|
+
export type ExecutionRoute = {
|
|
11
|
+
kind: 'branch';
|
|
12
|
+
condition: string;
|
|
13
|
+
truePort: string;
|
|
14
|
+
falsePort: string;
|
|
15
|
+
continuationPort?: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'select';
|
|
18
|
+
expression: string;
|
|
19
|
+
cases: ReadonlyArray<{
|
|
20
|
+
match: string;
|
|
21
|
+
port: string;
|
|
22
|
+
}>;
|
|
23
|
+
defaultPort?: string;
|
|
24
|
+
continuationPort?: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'parallel';
|
|
27
|
+
ports: ReadonlyArray<string>;
|
|
28
|
+
continuationPort: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'sequence';
|
|
31
|
+
ports: ReadonlyArray<string>;
|
|
32
|
+
continuationPort: string;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'forLoop';
|
|
35
|
+
firstIndexExpression: string;
|
|
36
|
+
lastIndexExpression: string;
|
|
37
|
+
indexOutput: string;
|
|
38
|
+
bodyPort: string;
|
|
39
|
+
continuationPort: string;
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'forEach';
|
|
42
|
+
arrayExpression: string;
|
|
43
|
+
elementOutput: string;
|
|
44
|
+
indexOutput: string;
|
|
45
|
+
bodyPort: string;
|
|
46
|
+
continuationPort: string;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'try';
|
|
49
|
+
attempt: string;
|
|
50
|
+
catchVariable: string;
|
|
51
|
+
recover?: string;
|
|
52
|
+
successPort: string;
|
|
53
|
+
errorPort: string;
|
|
54
|
+
continuationPort?: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'completion';
|
|
57
|
+
actorExpression: string;
|
|
58
|
+
completedPort: string;
|
|
59
|
+
continuationPort: string;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'runtimeCallback';
|
|
62
|
+
callee: string;
|
|
63
|
+
arguments: readonly string[];
|
|
64
|
+
completedPort: string;
|
|
65
|
+
continuationPort: string;
|
|
66
|
+
callbackValueOutput?: string;
|
|
67
|
+
returnValueOutput?: string;
|
|
68
|
+
};
|
|
69
|
+
export type ExecutionCompileResult = {
|
|
70
|
+
/** Code executed when control reaches the node. */
|
|
71
|
+
chunk?: string;
|
|
72
|
+
/** A promise that must settle before routing to the next node. */
|
|
73
|
+
done?: string;
|
|
74
|
+
/** Structured control flow that chooses a named execution output. */
|
|
75
|
+
route?: ExecutionRoute;
|
|
76
|
+
/** The node changes values that cached pure computations may depend on. */
|
|
77
|
+
invalidatesValues?: boolean;
|
|
78
|
+
/** The emitted chunk contains await and requires an async handler. */
|
|
79
|
+
requiresAsync?: boolean;
|
|
80
|
+
};
|
|
81
|
+
export declare class DataOutput<T = unknown> {
|
|
82
|
+
readonly node: Node;
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly type: T;
|
|
85
|
+
constructor(node: Node, name: string);
|
|
86
|
+
}
|
|
87
|
+
export type ValueInput<T = unknown> = ValueLiteral | PureNode | DataOutput<T>;
|
|
88
|
+
export declare abstract class Node {
|
|
89
|
+
/** Used by editor integrations, breakpoints, and profiling. */
|
|
90
|
+
id?: string;
|
|
91
|
+
private readonly dataOutputs;
|
|
92
|
+
output<T = unknown>(name?: string): DataOutput<T>;
|
|
93
|
+
}
|
|
94
|
+
/** A side-effect-free node whose outputs may inline or share block-local setup. */
|
|
95
|
+
export declare abstract class PureNode extends Node {
|
|
96
|
+
abstract compileData(c: CompilationContext): DataCompileResult;
|
|
97
|
+
}
|
|
98
|
+
/** A node reached through execution pins and emitted as a basic block. */
|
|
99
|
+
export declare abstract class ExecutionNode extends Node {
|
|
100
|
+
private readonly executionOutputs;
|
|
101
|
+
connect(output: string, downstream: ExecutionNode): ExecutionNode;
|
|
102
|
+
then(downstream: ExecutionNode): ExecutionNode;
|
|
103
|
+
getExecutionOutputs(): ReadonlyMap<string, ExecutionNode>;
|
|
104
|
+
abstract compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export class DataOutput{constructor(t,e){this.node=t,this.name=e}}export class Node{constructor(){this.dataOutputs=new Map}output(t="value"){let e=this.dataOutputs.get(t);return null==e&&(e=new DataOutput(this,t),this.dataOutputs.set(t,e)),e}}export class PureNode extends Node{}export class ExecutionNode extends Node{constructor(){super(...arguments),this.executionOutputs=new Map}connect(t,e){if(this.executionOutputs.has(t))throw new Error(`Execution output ${JSON.stringify(t)} is already connected`);return this.executionOutputs.set(t,e),e}then(t){return this.connect("then",t)}getExecutionOutputs(){return this.executionOutputs}}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './compiler.js';
|
|
2
|
+
export * from './asset-references.js';
|
|
3
|
+
export * from './decorators.js';
|
|
4
|
+
export * from './document-compiler.js';
|
|
5
|
+
export * from './graph.js';
|
|
6
|
+
export * from './model.js';
|
|
7
|
+
export * from './nodes/index.js';
|
|
8
|
+
export * from './registry.js';
|
|
9
|
+
export * from './runtime.js';
|
|
10
|
+
export * from './runtime-assets.js';
|
|
11
|
+
export * from './type-inference.js';
|
|
12
|
+
export * from './types.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export*from"./compiler.js";export*from"./asset-references.js";export*from"./decorators.js";export*from"./document-compiler.js";export*from"./graph.js";export*from"./model.js";export*from"./nodes/index.js";export*from"./registry.js";export*from"./runtime.js";export*from"./runtime-assets.js";export*from"./type-inference.js";export*from"./types.js";/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { EventGraphType } from './types.js';
|
|
2
|
+
export type EventGraphNodeKind = 'event.beginPlay' | 'event.update' | 'event.endPlay' | 'event.observable' | 'event.source' | 'event.bindSource' | 'flow.branch' | 'flow.sequence' | 'flow.parallel' | 'flow.switch' | 'flow.delay' | 'flow.interval' | 'flow.clearInterval' | 'flow.forLoop' | 'flow.isValid' | 'flow.forEach' | 'flow.doOnce' | 'flow.gate' | 'debug.log' | 'constant.boolean' | 'constant.number' | 'constant.string' | 'constant.vector2' | 'constant.vector3' | 'math.add' | 'math.subtract' | 'math.multiply' | 'math.divide' | 'math.modulo' | 'vector.length' | 'vector.lengthSquared' | 'vector.distance' | 'vector.distanceSquared' | 'vector.normalize' | 'vector.dot' | 'vector.cross' | 'vector.lerp' | 'vector.applyRotation' | 'compare.equal' | 'compare.notEqual' | 'compare.greaterThan' | 'compare.greaterThanOrEqual' | 'compare.lessThan' | 'compare.lessThanOrEqual' | 'boolean.and' | 'boolean.or' | 'boolean.not' | 'variable.get' | 'variable.set' | 'actor.reference' | 'actor.component' | 'actor.getProperty' | 'actor.setProperty' | 'actor.tweenProperty' | 'transform.moveTo' | 'transform.moveBy' | 'transform.rotateTo' | 'transform.rotateBy' | 'transform.scaleTo' | 'transform.scaleBy' | 'actor.callMethod' | 'actor.tryCallMethod' | 'actor.findByType' | 'actor.findAllByType' | 'actor.spawnClass' | 'actor.spawnPrefab' | 'actor.destroy' | 'asset.reference' | 'vfx.play' | 'sequence.play' | 'prefab.destroy';
|
|
3
|
+
export type EventGraphAssetKind = 'prefab' | 'vfx' | 'sequence';
|
|
4
|
+
export type EventGraphTransformSpace = 'local' | 'world';
|
|
5
|
+
export type EventGraphTransformAxis = 'x' | 'y' | 'z';
|
|
6
|
+
/** Persisted soft reference. Runtime graph values lower this to the stable asset id. */
|
|
7
|
+
export interface EventGraphAssetReference {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
assetId: string;
|
|
10
|
+
assetType: EventGraphAssetKind;
|
|
11
|
+
}
|
|
12
|
+
export type EventGraphSerializableValue = null | boolean | number | string | EventGraphSerializableValue[] | {
|
|
13
|
+
[key: string]: EventGraphSerializableValue;
|
|
14
|
+
};
|
|
15
|
+
export type EventGraphVector2Literal = [number, number];
|
|
16
|
+
export type EventGraphVector3Literal = [number, number, number];
|
|
17
|
+
export type EventGraphEulerLiteral = [number, number, number];
|
|
18
|
+
export interface EventGraphSocketRef {
|
|
19
|
+
nodeId: string;
|
|
20
|
+
port: string;
|
|
21
|
+
}
|
|
22
|
+
export interface EventGraphInputLiteral {
|
|
23
|
+
value: EventGraphSerializableValue;
|
|
24
|
+
}
|
|
25
|
+
export type EventGraphInput = EventGraphSocketRef | EventGraphInputLiteral;
|
|
26
|
+
export interface EventGraphNode {
|
|
27
|
+
id: string;
|
|
28
|
+
kind: EventGraphNodeKind;
|
|
29
|
+
params?: Record<string, EventGraphSerializableValue>;
|
|
30
|
+
inputs?: Record<string, EventGraphInput>;
|
|
31
|
+
}
|
|
32
|
+
export interface EventGraphEdge {
|
|
33
|
+
id?: string;
|
|
34
|
+
from: EventGraphSocketRef;
|
|
35
|
+
to: EventGraphSocketRef;
|
|
36
|
+
}
|
|
37
|
+
export interface EventGraphGroup {
|
|
38
|
+
id: string;
|
|
39
|
+
title: string;
|
|
40
|
+
nodeIds: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface EventGraphLayout {
|
|
43
|
+
nodes?: Record<string, {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
}>;
|
|
47
|
+
groups?: EventGraphGroup[];
|
|
48
|
+
}
|
|
49
|
+
export interface EventGraphVariable {
|
|
50
|
+
name: string;
|
|
51
|
+
type?: EventGraphType;
|
|
52
|
+
defaultValue?: EventGraphSerializableValue;
|
|
53
|
+
}
|
|
54
|
+
/** Persisted event graph data. Editor-only selection and viewport state do not belong here. */
|
|
55
|
+
export interface EventGraphDocument {
|
|
56
|
+
version: 1;
|
|
57
|
+
variables?: EventGraphVariable[];
|
|
58
|
+
nodes: EventGraphNode[];
|
|
59
|
+
edges: EventGraphEdge[];
|
|
60
|
+
layout?: EventGraphLayout;
|
|
61
|
+
}
|
|
62
|
+
export declare function createDefaultEventGraphDocument(): EventGraphDocument;
|
|
63
|
+
/**
|
|
64
|
+
* Returns true only when an authored event entry point can start an execution
|
|
65
|
+
* chain. Layout-only/default event nodes should not make prefab spawning pay
|
|
66
|
+
* for graph compilation or subscriptions.
|
|
67
|
+
*/
|
|
68
|
+
export declare function hasExecutableEventGraphDocument(document: EventGraphDocument | null | undefined): document is EventGraphDocument;
|
|
69
|
+
/** Normalizes additive version-1 aliases without cloning current documents. */
|
|
70
|
+
export declare function normalizeEventGraphDocument(document: EventGraphDocument): EventGraphDocument;
|
|
71
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function createDefaultEventGraphDocument(){return{version:1,variables:[],nodes:[{id:"begin-play",kind:"event.beginPlay"},{id:"update",kind:"event.update"},{id:"end-play",kind:"event.endPlay"}],edges:[],layout:{nodes:{"begin-play":{x:0,y:0},update:{x:0,y:220},"end-play":{x:0,y:440}}}}}export function hasExecutableEventGraphDocument(e){if(null==e)return!1;const n=new Set(e.nodes.filter(e=>"event.bindSource"!==e.kind&&e.kind.startsWith("event.")).map(e=>e.id));return e.edges.some(e=>n.has(e.from.nodeId)&&"then"===e.from.port)}export function normalizeEventGraphDocument(e){var n;const o=new Set(e.nodes.filter(e=>"actor.spawnPrefab"===e.kind||"vfx.play"===e.kind).map(e=>e.id)),t=new Set(e.nodes.filter(e=>"flow.doOnce"===e.kind).map(e=>e.id)),d=e.nodes.some(e=>o.has(e.id)&&null!=e.inputs?.location)||e.edges.some(e=>o.has(e.to.nodeId)&&"location"===e.to.port),i=e.edges.some(e=>t.has(e.from.nodeId)&&"completed"===e.from.port);if(!d&&!i)return e;const r=structuredClone(e);for(const e of r.nodes)o.has(e.id)&&null!=e.inputs?.location&&((n=e.inputs).position??(n.position=e.inputs.location),delete e.inputs.location);for(const e of r.edges)o.has(e.to.nodeId)&&"location"===e.to.port&&(e.to.port="position"),t.has(e.from.nodeId)&&"completed"===e.from.port&&(e.from.port="then");return r}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { CompilationContext } from '../compiler.js';
|
|
2
|
+
import { ExecutionNode, type ExecutionCompileResult, type ValueInput } from '../graph.js';
|
|
3
|
+
export declare class StartNode extends ExecutionNode {
|
|
4
|
+
compileExecution(): ExecutionCompileResult;
|
|
5
|
+
}
|
|
6
|
+
export declare class LogNode extends ExecutionNode {
|
|
7
|
+
readonly value: ValueInput;
|
|
8
|
+
constructor(value: ValueInput);
|
|
9
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
10
|
+
}
|
|
11
|
+
export declare class CallScopeNode extends ExecutionNode {
|
|
12
|
+
compileExecution(): ExecutionCompileResult;
|
|
13
|
+
}
|
|
14
|
+
export declare class DelayNode extends ExecutionNode {
|
|
15
|
+
readonly delayMs: ValueInput;
|
|
16
|
+
constructor(delayMs: ValueInput);
|
|
17
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
18
|
+
}
|
|
19
|
+
export declare class IntervalNode extends ExecutionNode {
|
|
20
|
+
private readonly nodeId;
|
|
21
|
+
private readonly intervalMs;
|
|
22
|
+
readonly timerId: import("../graph.js").DataOutput<number>;
|
|
23
|
+
constructor(nodeId: string, intervalMs: ValueInput);
|
|
24
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
25
|
+
}
|
|
26
|
+
export declare class ClearIntervalNode extends ExecutionNode {
|
|
27
|
+
private readonly timerId;
|
|
28
|
+
constructor(timerId: ValueInput);
|
|
29
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
30
|
+
}
|
|
31
|
+
export declare class SequenceNode extends ExecutionNode {
|
|
32
|
+
private readonly ports;
|
|
33
|
+
constructor(ports: readonly string[]);
|
|
34
|
+
compileExecution(): ExecutionCompileResult;
|
|
35
|
+
}
|
|
36
|
+
export declare class ForLoopNode extends ExecutionNode {
|
|
37
|
+
private readonly firstIndex;
|
|
38
|
+
private readonly lastIndex;
|
|
39
|
+
readonly index: import("../graph.js").DataOutput<number>;
|
|
40
|
+
constructor(firstIndex: ValueInput, lastIndex: ValueInput);
|
|
41
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
42
|
+
}
|
|
43
|
+
export declare class DoOnceNode extends ExecutionNode {
|
|
44
|
+
private readonly nodeId;
|
|
45
|
+
private readonly entryPort;
|
|
46
|
+
private readonly startClosed;
|
|
47
|
+
constructor(nodeId: string, entryPort: string, startClosed: ValueInput);
|
|
48
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
49
|
+
}
|
|
50
|
+
export declare class GateNode extends ExecutionNode {
|
|
51
|
+
private readonly nodeId;
|
|
52
|
+
private readonly entryPort;
|
|
53
|
+
private readonly startClosed;
|
|
54
|
+
constructor(nodeId: string, entryPort: string, startClosed: ValueInput);
|
|
55
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
56
|
+
}
|
|
57
|
+
export declare class AssignNode extends ExecutionNode {
|
|
58
|
+
private readonly variable;
|
|
59
|
+
private readonly value;
|
|
60
|
+
constructor(variable: string, value: ValueInput);
|
|
61
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
62
|
+
}
|
|
63
|
+
export declare class AddAssignNode extends ExecutionNode {
|
|
64
|
+
private readonly variable;
|
|
65
|
+
private readonly value;
|
|
66
|
+
constructor(variable: string, value: ValueInput);
|
|
67
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
68
|
+
}
|
|
69
|
+
/** Chooses exactly one named execution output without producing a data value. */
|
|
70
|
+
export declare class BranchNode extends ExecutionNode {
|
|
71
|
+
private readonly condition;
|
|
72
|
+
constructor(condition: ValueInput);
|
|
73
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
74
|
+
}
|
|
75
|
+
export declare class IsValidNode extends ExecutionNode {
|
|
76
|
+
private readonly input;
|
|
77
|
+
readonly value: import("../graph.js").DataOutput<unknown>;
|
|
78
|
+
constructor(input: ValueInput);
|
|
79
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
80
|
+
}
|
|
81
|
+
export declare class ForEachNode extends ExecutionNode {
|
|
82
|
+
private readonly array;
|
|
83
|
+
readonly arrayElement: import("../graph.js").DataOutput<unknown>;
|
|
84
|
+
readonly arrayIndex: import("../graph.js").DataOutput<number>;
|
|
85
|
+
constructor(array: ValueInput);
|
|
86
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
87
|
+
}
|
|
88
|
+
/** Runs named branches concurrently and continues after all complete successfully. */
|
|
89
|
+
export declare class ParallelNode extends ExecutionNode {
|
|
90
|
+
readonly ports: ReadonlyArray<string>;
|
|
91
|
+
constructor(...ports: string[]);
|
|
92
|
+
compileExecution(): ExecutionCompileResult;
|
|
93
|
+
}
|
|
94
|
+
export declare class SelectNode extends ExecutionNode {
|
|
95
|
+
private readonly expression;
|
|
96
|
+
private readonly cases;
|
|
97
|
+
private readonly defaultPort;
|
|
98
|
+
constructor(expression: ValueInput, cases: ReadonlyArray<{
|
|
99
|
+
match: string;
|
|
100
|
+
port: string;
|
|
101
|
+
}>, defaultPort?: string);
|
|
102
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Demonstrates an impure node with both named execution outputs and named data
|
|
106
|
+
* outputs. The data pins refer to storage populated when this node executes.
|
|
107
|
+
*/
|
|
108
|
+
export declare class ParseNumberNode extends ExecutionNode {
|
|
109
|
+
private readonly input;
|
|
110
|
+
readonly value: import("../graph.js").DataOutput<number>;
|
|
111
|
+
readonly error: import("../graph.js").DataOutput<string>;
|
|
112
|
+
constructor(input: ValueInput<string>);
|
|
113
|
+
compileExecution(c: CompilationContext): ExecutionCompileResult;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=execution-nodes.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{ExecutionNode as t}from"../graph.js";export class StartNode extends t{compileExecution(){return{}}}export class LogNode extends t{constructor(t){super(),this.value=t}compileExecution(t){return{chunk:`console.log(${t.get(this.value)})`}}}export class CallScopeNode extends t{compileExecution(){return{chunk:"this.foo()",invalidatesValues:!0}}}export class DelayNode extends t{constructor(t){super(),this.delayMs=t}compileExecution(t){return{done:`runtime.delay(${t.get(this.delayMs)})`}}}export class IntervalNode extends t{constructor(t,e){super(),this.nodeId=t,this.intervalMs=e,this.timerId=this.output("timerId")}compileExecution(t){return{route:{kind:"runtimeCallback",callee:"runtime.setInterval",arguments:[JSON.stringify(this.nodeId),t.get(this.intervalMs)],completedPort:"interval",continuationPort:"then",returnValueOutput:t.getOutputVariable(this.timerId)},invalidatesValues:!0}}}export class ClearIntervalNode extends t{constructor(t){super(),this.timerId=t}compileExecution(t){return{chunk:`runtime.clearInterval(${t.get(this.timerId)})`}}}export class SequenceNode extends t{constructor(t){super(),this.ports=t}compileExecution(){return{route:{kind:"sequence",ports:this.ports,continuationPort:"then"}}}}export class ForLoopNode extends t{constructor(t,e){super(),this.firstIndex=t,this.lastIndex=e,this.index=this.output("index")}compileExecution(t){return{route:{kind:"forLoop",firstIndexExpression:t.get(this.firstIndex),lastIndexExpression:t.get(this.lastIndex),indexOutput:t.getOutputVariable(this.index),bodyPort:"loopBody",continuationPort:"completed"}}}}export class DoOnceNode extends t{constructor(t,e,r){super(),this.nodeId=t,this.entryPort=e,this.startClosed=r}compileExecution(t){return{route:{kind:"branch",condition:`runtime.doOnce(${JSON.stringify(this.nodeId)}, ${JSON.stringify(this.entryPort)}, ${t.get(this.startClosed)})`,truePort:"then",falsePort:"__blocked"},invalidatesValues:!0}}}export class GateNode extends t{constructor(t,e,r){super(),this.nodeId=t,this.entryPort=e,this.startClosed=r}compileExecution(t){return{route:{kind:"branch",condition:`runtime.gate(${JSON.stringify(this.nodeId)}, ${JSON.stringify(this.entryPort)}, ${t.get(this.startClosed)})`,truePort:"exit",falsePort:"__blocked"},invalidatesValues:!0}}}export class AssignNode extends t{constructor(t,e){super(),this.variable=t,this.value=e}compileExecution(t){return{chunk:`${t.getVariableName(this.variable)} = ${t.get(this.value)}`,invalidatesValues:!0}}}export class AddAssignNode extends t{constructor(t,e){super(),this.variable=t,this.value=e}compileExecution(t){return{chunk:`${t.getVariableName(this.variable)} += ${t.get(this.value)}`,invalidatesValues:!0}}}export class BranchNode extends t{constructor(t){super(),this.condition=t}compileExecution(t){return{route:{kind:"branch",condition:t.get(this.condition),truePort:"true",falsePort:"false",continuationPort:"then"}}}}export class IsValidNode extends t{constructor(t){super(),this.input=t,this.value=this.output("value")}compileExecution(t){const e=t.getOutputVariable(this.value);return{chunk:`${e} = ${t.get(this.input)}`,route:{kind:"branch",condition:`${e} !== null && ${e} !== undefined`,truePort:"valid",falsePort:"invalid",continuationPort:"then"}}}}export class ForEachNode extends t{constructor(t){super(),this.array=t,this.arrayElement=this.output("arrayElement"),this.arrayIndex=this.output("arrayIndex")}compileExecution(t){return{route:{kind:"forEach",arrayExpression:t.get(this.array),elementOutput:t.getOutputVariable(this.arrayElement),indexOutput:t.getOutputVariable(this.arrayIndex),bodyPort:"loopBody",continuationPort:"completed"}}}}export class ParallelNode extends t{constructor(...t){if(super(),0===t.length)throw new Error("ParallelNode needs at least one branch");if(t.includes("then"))throw new Error('ParallelNode reserves the "then" port for its continuation');if(new Set(t).size!==t.length)throw new Error("ParallelNode branch names must be unique");this.ports=t}compileExecution(){return{route:{kind:"parallel",ports:this.ports,continuationPort:"then"}}}}export class SelectNode extends t{constructor(t,e,r="default"){super(),this.expression=t,this.cases=e,this.defaultPort=r}compileExecution(t){return{route:{kind:"select",expression:t.get(this.expression),cases:this.cases,defaultPort:this.defaultPort,continuationPort:"then"}}}}export class ParseNumberNode extends t{constructor(t){super(),this.input=t,this.value=this.output("value"),this.error=this.output("error")}compileExecution(t){const e=t.getOutputVariable(this.value),r=t.getOutputVariable(this.error),o=`parsed_${t.variable()}`,s=`caught_${t.variable()}`;return{route:{kind:"try",attempt:`const ${o} = Number(${t.get(this.input)})\nif (Number.isNaN(${o})) {\n throw new Error('The input is not a number')\n}\n${e} = ${o}\n${r} = undefined`,catchVariable:s,recover:`${e} = undefined\n${r} = ${s} instanceof Error ? ${s}.message : String(${s})`,successPort:"success",errorPort:"error"}}}}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|