@aura3d/scripting 1.4.0 → 1.4.1

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/src/VisualNode.ts DELETED
@@ -1,44 +0,0 @@
1
- export type VisualPortDirection = "input" | "output";
2
- export type VisualPortType = "flow" | "number" | "boolean" | "string" | "object" | "any";
3
-
4
- export interface VisualPort {
5
- readonly id: string;
6
- readonly direction: VisualPortDirection;
7
- readonly type: VisualPortType;
8
- readonly optional?: boolean;
9
- readonly defaultValue?: unknown;
10
- }
11
-
12
- export interface VisualNode {
13
- readonly id: string;
14
- readonly kind: string;
15
- readonly ports: readonly VisualPort[];
16
- readonly data?: Readonly<Record<string, unknown>>;
17
- }
18
-
19
- export function validateNode(node: VisualNode): readonly string[] {
20
- const errors: string[] = [];
21
- const ports = new Set<string>();
22
-
23
- if (node.id.length === 0) {
24
- errors.push("Node id is required");
25
- }
26
-
27
- for (const port of node.ports) {
28
- if (port.id.length === 0) {
29
- errors.push(`Port id is required on node ${node.id}`);
30
- }
31
- if (ports.has(port.id)) {
32
- errors.push(`Duplicate port id on node ${node.id}: ${port.id}`);
33
- }
34
- ports.add(port.id);
35
- if (port.direction !== "input" && port.direction !== "output") {
36
- errors.push(`Invalid port direction on node ${node.id}.${port.id}`);
37
- }
38
- if (!["flow", "number", "boolean", "string", "object", "any"].includes(port.type)) {
39
- errors.push(`Invalid port type on node ${node.id}.${port.id}`);
40
- }
41
- }
42
-
43
- return errors;
44
- }
@@ -1,202 +0,0 @@
1
- import { type VisualNode, type VisualPort } from "./VisualNode";
2
- import { animationVisualNodeDefinitions } from "./AnimationVisualNodes";
3
-
4
- export type VisualNodeCategory =
5
- | "value"
6
- | "math"
7
- | "logic"
8
- | "flow"
9
- | "debug"
10
- | "runtime"
11
- | "input"
12
- | "animation"
13
- | "physics"
14
- | "combat"
15
- | "scene"
16
- | "dialogue"
17
- | "audio"
18
- | "timing"
19
- | "publishing"
20
- | "camera"
21
- | "evidence";
22
-
23
- export interface VisualNodeDefinition {
24
- readonly kind: string;
25
- readonly category: VisualNodeCategory;
26
- readonly title: string;
27
- readonly description: string;
28
- readonly ports: readonly VisualPort[];
29
- readonly oldBranchSource: readonly string[];
30
- }
31
-
32
- const definitions: readonly VisualNodeDefinition[] = [
33
- define("const", "value", "Constant", "Constant value node.", [], [{ id: "out", direction: "output", type: "any" }], ["src/scripting/nodes/VariableNodes.ts"]),
34
- define("log", "debug", "Log", "Pass-through debug log value.", [{ id: "in", direction: "input", type: "any", optional: true }], [{ id: "out", direction: "output", type: "any" }], ["src/scripting/nodes/DebugNodes.ts"]),
35
- define("add", "math", "Add", "Add all connected numeric inputs.", [{ id: "in", direction: "input", type: "number", defaultValue: 0 }], [{ id: "out", direction: "output", type: "number" }], ["src/scripting/nodes/MathNodes.ts"]),
36
- define("subtract", "math", "Subtract", "Subtract b from a.", numericBinaryInputs(), numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
37
- define("multiply", "math", "Multiply", "Multiply a by b.", numericBinaryInputs(1, 1), numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
38
- define("divide", "math", "Divide", "Divide a by b with zero division rejection.", numericBinaryInputs(1, 1), numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
39
- define("power", "math", "Power", "Raise base to exponent.", [{ id: "base", direction: "input", type: "number", defaultValue: 2 }, { id: "exponent", direction: "input", type: "number", defaultValue: 2 }], numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
40
- define("sqrt", "math", "Square Root", "Calculate square root with negative input rejection.", [{ id: "value", direction: "input", type: "number", defaultValue: 4 }], numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
41
- define("abs", "math", "Absolute", "Absolute numeric value.", numericUnaryInputs(), numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
42
- define("sin", "math", "Sine", "Sine in radians.", [{ id: "angle", direction: "input", type: "number", defaultValue: 0 }], numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
43
- define("cos", "math", "Cosine", "Cosine in radians.", [{ id: "angle", direction: "input", type: "number", defaultValue: 0 }], numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
44
- define("tan", "math", "Tangent", "Tangent in radians.", [{ id: "angle", direction: "input", type: "number", defaultValue: 0 }], numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
45
- define("min", "math", "Minimum", "Minimum of two numbers.", numericBinaryInputs(), numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
46
- define("max", "math", "Maximum", "Maximum of two numbers.", numericBinaryInputs(), numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
47
- define("clamp", "math", "Clamp", "Clamp value between min and max.", [{ id: "value", direction: "input", type: "number", defaultValue: 0 }, { id: "min", direction: "input", type: "number", defaultValue: 0 }, { id: "max", direction: "input", type: "number", defaultValue: 1 }], numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
48
- define("lerp", "math", "Lerp", "Linear interpolation.", [{ id: "a", direction: "input", type: "number", defaultValue: 0 }, { id: "b", direction: "input", type: "number", defaultValue: 1 }, { id: "t", direction: "input", type: "number", defaultValue: 0.5 }], numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
49
- define("inverseLerp", "math", "Inverse Lerp", "Calculate interpolation factor for value between a and b.", [{ id: "a", direction: "input", type: "number", defaultValue: 0 }, { id: "b", direction: "input", type: "number", defaultValue: 1 }, { id: "value", direction: "input", type: "number", defaultValue: 0.5 }], numberOutput(), ["src/scripting/nodes/MathNodes.ts"]),
50
- define("and", "logic", "AND", "Boolean AND.", booleanBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
51
- define("or", "logic", "OR", "Boolean OR.", booleanBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
52
- define("not", "logic", "NOT", "Boolean NOT.", [{ id: "value", direction: "input", type: "boolean", defaultValue: false }], booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
53
- define("xor", "logic", "XOR", "Boolean exclusive OR.", booleanBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
54
- define("equal", "logic", "Equal", "Strict equality comparison.", anyBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
55
- define("notEqual", "logic", "Not Equal", "Strict inequality comparison.", anyBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
56
- define("greater", "logic", "Greater", "Numeric greater-than comparison.", numericBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
57
- define("less", "logic", "Less", "Numeric less-than comparison.", numericBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
58
- define("greaterEqual", "logic", "Greater Equal", "Numeric greater-or-equal comparison.", numericBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
59
- define("lessEqual", "logic", "Less Equal", "Numeric less-or-equal comparison.", numericBinaryInputs(), booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
60
- define("isNull", "logic", "Is Null", "Null or undefined check.", [{ id: "value", direction: "input", type: "any", optional: true }], booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
61
- define("isValid", "logic", "Is Valid", "Non-null and non-undefined check.", [{ id: "value", direction: "input", type: "any", optional: true }], booleanOutput(), ["src/scripting/nodes/LogicNodes.ts"]),
62
- define("select", "logic", "Select", "Ternary select by condition.", [{ id: "condition", direction: "input", type: "boolean", defaultValue: false }, { id: "ifTrue", direction: "input", type: "any", optional: true }, { id: "ifFalse", direction: "input", type: "any", optional: true }], [{ id: "out", direction: "output", type: "any" }], ["src/scripting/nodes/LogicNodes.ts"]),
63
- define("branch", "flow", "Branch", "Choose true or false flow path from a boolean condition.", [{ id: "in", direction: "input", type: "flow", optional: true }, { id: "condition", direction: "input", type: "boolean", defaultValue: false }], [{ id: "true", direction: "output", type: "flow" }, { id: "false", direction: "output", type: "flow" }, { id: "selected", direction: "output", type: "string" }], ["src/scripting/nodes/FlowNodes.ts"]),
64
- define("switch", "flow", "Switch", "Choose a numbered case or default path.", [{ id: "in", direction: "input", type: "flow", optional: true }, { id: "value", direction: "input", type: "number", defaultValue: 0 }, { id: "caseCount", direction: "input", type: "number", defaultValue: 3 }], [{ id: "case0", direction: "output", type: "flow" }, { id: "case1", direction: "output", type: "flow" }, { id: "case2", direction: "output", type: "flow" }, { id: "default", direction: "output", type: "flow" }, { id: "selected", direction: "output", type: "string" }], ["src/scripting/nodes/FlowNodes.ts"]),
65
- define("sequence", "flow", "Sequence", "Publish a deterministic ordered flow-output list.", [{ id: "in", direction: "input", type: "flow", optional: true }, { id: "count", direction: "input", type: "number", defaultValue: 3 }], [{ id: "out0", direction: "output", type: "flow" }, { id: "out1", direction: "output", type: "flow" }, { id: "out2", direction: "output", type: "flow" }, { id: "outputs", direction: "output", type: "object" }], ["src/scripting/nodes/FlowNodes.ts"]),
66
- define("forRange", "flow", "For Range", "Summarize bounded integer loop iterations.", [{ id: "in", direction: "input", type: "flow", optional: true }, { id: "startIndex", direction: "input", type: "number", defaultValue: 0 }, { id: "endIndex", direction: "input", type: "number", defaultValue: 10 }], [{ id: "body", direction: "output", type: "flow" }, { id: "completed", direction: "output", type: "flow" }, { id: "index", direction: "output", type: "number" }, { id: "indices", direction: "output", type: "object" }], ["src/scripting/nodes/FlowNodes.ts"]),
67
- define("gate", "flow", "Gate", "Allow or block flow with an initial open/closed state.", [{ id: "in", direction: "input", type: "flow", optional: true }, { id: "startClosed", direction: "input", type: "boolean", defaultValue: false }], [{ id: "out", direction: "output", type: "flow" }, { id: "isOpen", direction: "output", type: "boolean" }], ["src/scripting/nodes/FlowNodes.ts"]),
68
-
69
- define("onStart", "runtime", "On Start", "Emit flow when the deterministic frame context is at start.", [], [{ id: "out", direction: "output", type: "flow" }, { id: "active", direction: "output", type: "boolean" }], ["src/scripting/nodes/RuntimeNodes.ts"]),
70
- define("onFrame", "runtime", "On Frame", "Emit deterministic frame timing from app.onFrame or app.step context.", [], [{ id: "out", direction: "output", type: "flow" }, { id: "dt", direction: "output", type: "number" }, { id: "time", direction: "output", type: "number" }, { id: "frame", direction: "output", type: "number" }, { id: "context", direction: "output", type: "object" }], ["src/scripting/nodes/RuntimeNodes.ts"]),
71
- define("getNode", "runtime", "Get Runtime Node", "Read a runtime node snapshot by id.", [stringInput("nodeId")], [{ id: "node", direction: "output", type: "object" }, { id: "nodeId", direction: "output", type: "string" }, { id: "exists", direction: "output", type: "boolean" }, { id: "position", direction: "output", type: "object" }], ["src/scripting/nodes/RuntimeNodes.ts"]),
72
- define("setPosition", "runtime", "Set Position", "Create a deterministic runtime node position command.", [flowInput(), stringInput("nodeId"), objectInput("position")], commandOutputs(), ["src/scripting/nodes/RuntimeNodes.ts"]),
73
- define("translate", "runtime", "Translate", "Create a deterministic runtime node translation command.", [flowInput(), stringInput("nodeId"), objectInput("delta")], commandOutputs(), ["src/scripting/nodes/RuntimeNodes.ts"]),
74
- define("rotate", "runtime", "Rotate", "Create a deterministic runtime node rotation command.", [flowInput(), stringInput("nodeId"), objectInput("rotation")], commandOutputs(), ["src/scripting/nodes/RuntimeNodes.ts"]),
75
- define("setVisible", "runtime", "Set Visible", "Create a deterministic runtime node visibility command.", [flowInput(), stringInput("nodeId"), booleanInput("visible", true)], commandOutputs(), ["src/scripting/nodes/RuntimeNodes.ts"]),
76
- define("setMaterial", "runtime", "Set Material", "Create a deterministic runtime node material override command.", [flowInput(), stringInput("nodeId"), objectInput("material")], commandOutputs(), ["src/scripting/nodes/RuntimeNodes.ts"]),
77
-
78
- define("pressed", "input", "Pressed", "Read a deterministic pressed input action snapshot.", [stringInput("action")], booleanOutput(), ["src/scripting/nodes/InputNodes.ts"]),
79
- define("held", "input", "Held", "Read a deterministic held input action snapshot.", [stringInput("action")], booleanOutput(), ["src/scripting/nodes/InputNodes.ts"]),
80
- define("released", "input", "Released", "Read a deterministic released input action snapshot.", [stringInput("action")], booleanOutput(), ["src/scripting/nodes/InputNodes.ts"]),
81
- define("axis", "input", "Axis", "Read a deterministic input axis snapshot.", [stringInput("axis")], numberOutput(), ["src/scripting/nodes/InputNodes.ts"]),
82
- define("buffered", "input", "Buffered", "Read a deterministic buffered input action snapshot.", [stringInput("action")], booleanOutput(), ["src/scripting/nodes/InputNodes.ts"]),
83
- define("combo", "input", "Combo", "Read a deterministic combo match snapshot.", [stringInput("combo")], booleanOutput(), ["src/scripting/nodes/InputNodes.ts"]),
84
-
85
- define("playClip", "animation", "Play Clip", "Create an animation play command for a named clip.", [flowInput(), stringInput("controllerId"), stringInput("clip"), booleanInput("loop", true)], commandOutputs(), ["src/scripting/nodes/AnimationNodes.ts"]),
86
- define("restartClip", "animation", "Restart Clip", "Create an animation restart command for a named clip.", [flowInput(), stringInput("controllerId"), stringInput("clip")], commandOutputs(), ["src/scripting/nodes/AnimationNodes.ts"]),
87
- define("crossFade", "animation", "Cross Fade", "Create an animation crossfade command for a named clip.", [flowInput(), stringInput("controllerId"), stringInput("clip"), numberInput("duration", 0.12), booleanInput("restart", false), stringInput("layer", true)], commandOutputs(), ["src/scripting/nodes/AnimationNodes.ts"]),
88
- define("setLayerWeight", "animation", "Set Layer Weight", "Create an animation layer weight command.", [flowInput(), stringInput("controllerId"), stringInput("layer"), numberInput("weight", 1)], commandOutputs(), ["src/scripting/nodes/AnimationNodes.ts"]),
89
- define("onAnimationEvent", "animation", "On Animation Event", "Read a deterministic animation event emitted from clip-local time.", [stringInput("controllerId"), stringInput("eventType"), stringInput("clip", true)], [{ id: "out", direction: "output", type: "flow" }, { id: "fired", direction: "output", type: "boolean" }, { id: "event", direction: "output", type: "object" }], ["src/scripting/nodes/AnimationNodes.ts"]),
90
- define("setMorphTarget", "animation", "Set Morph Target", "Create a morph target weight command.", [flowInput(), stringInput("controllerId"), stringInput("morphTarget"), numberInput("weight", 0)], commandOutputs(), ["src/scripting/nodes/AnimationNodes.ts"]),
91
- define("setMorphTargets", "animation", "Set Morph Targets", "Create a batch morph target weight command.", [flowInput(), stringInput("controllerId"), objectInput("weights")], commandOutputs(), ["src/scripting/nodes/AnimationNodes.ts"]),
92
- define("getClipTime", "animation", "Get Clip Time", "Read deterministic animation clip time from a controller snapshot.", [stringInput("controllerId")], [{ id: "out", direction: "output", type: "number" }, { id: "clip", direction: "output", type: "string" }], ["src/scripting/nodes/AnimationNodes.ts"]),
93
-
94
- define("setVelocity", "physics", "Set Velocity", "Create a kinematic body velocity command.", [flowInput(), stringInput("bodyId"), objectInput("velocity")], commandOutputs(), ["src/scripting/nodes/PhysicsNodes.ts"]),
95
- define("jump", "physics", "Jump", "Create a kinematic jump command.", [flowInput(), stringInput("bodyId"), numberInput("impulse", 1)], commandOutputs(), ["src/scripting/nodes/PhysicsNodes.ts"]),
96
- define("dash", "physics", "Dash", "Create a kinematic dash command.", [flowInput(), stringInput("bodyId"), objectInput("direction"), numberInput("speed", 1)], commandOutputs(), ["src/scripting/nodes/PhysicsNodes.ts"]),
97
- define("onCollisionEnter", "physics", "On Collision Enter", "Read a deterministic collision-enter event snapshot.", [stringInput("bodyId"), stringInput("otherBodyId", true)], [{ id: "out", direction: "output", type: "flow" }, { id: "collided", direction: "output", type: "boolean" }, { id: "event", direction: "output", type: "object" }], ["src/scripting/nodes/PhysicsNodes.ts"]),
98
- define("onCollisionExit", "physics", "On Collision Exit", "Read a deterministic collision-exit event snapshot.", [stringInput("bodyId"), stringInput("otherBodyId", true)], [{ id: "out", direction: "output", type: "flow" }, { id: "collided", direction: "output", type: "boolean" }, { id: "event", direction: "output", type: "object" }], ["src/scripting/nodes/PhysicsNodes.ts"]),
99
- define("raycast", "physics", "Raycast", "Read a deterministic raycast result by query id.", [stringInput("queryId")], [{ id: "hit", direction: "output", type: "boolean" }, { id: "result", direction: "output", type: "object" }], ["src/scripting/nodes/PhysicsNodes.ts"]),
100
- define("overlap", "physics", "Overlap", "Read a deterministic overlap result by query id.", [stringInput("queryId")], [{ id: "hit", direction: "output", type: "boolean" }, { id: "result", direction: "output", type: "object" }], ["src/scripting/nodes/PhysicsNodes.ts"]),
101
-
102
- define("openHitbox", "combat", "Open Hitbox", "Create a combat hitbox-open command.", [flowInput(), stringInput("hitboxId"), stringInput("ownerId"), numberInput("damage", 0), objectInput("payload", true)], commandOutputs(), ["src/scripting/nodes/CombatNodes.ts"]),
103
- define("closeHitbox", "combat", "Close Hitbox", "Create a combat hitbox-close command.", [flowInput(), stringInput("hitboxId")], commandOutputs(), ["src/scripting/nodes/CombatNodes.ts"]),
104
- define("setHurtbox", "combat", "Set Hurtbox", "Create a combat hurtbox command.", [flowInput(), stringInput("hurtboxId"), stringInput("ownerId"), objectInput("payload", true)], commandOutputs(), ["src/scripting/nodes/CombatNodes.ts"]),
105
- define("onHit", "combat", "On Hit", "Read a deterministic combat hit event snapshot.", [stringInput("actorId", true), stringInput("hitboxId", true)], [{ id: "out", direction: "output", type: "flow" }, { id: "hit", direction: "output", type: "boolean" }, { id: "event", direction: "output", type: "object" }], ["src/scripting/nodes/CombatNodes.ts"]),
106
- define("applyDamage", "combat", "Apply Damage", "Create a deterministic damage command.", [flowInput(), stringInput("targetId"), numberInput("amount", 0), stringInput("sourceId", true)], commandOutputs(), ["src/scripting/nodes/CombatNodes.ts"]),
107
- define("applyKnockback", "combat", "Apply Knockback", "Create a deterministic knockback command.", [flowInput(), stringInput("targetId"), objectInput("velocity"), stringInput("sourceId", true)], commandOutputs(), ["src/scripting/nodes/CombatNodes.ts"]),
108
-
109
- define("follow", "camera", "Follow", "Create a camera follow command.", [flowInput(), stringInput("targetId"), numberInput("stiffness", 1)], commandOutputs(), ["src/scripting/nodes/CameraNodes.ts"]),
110
- define("frameTargets", "camera", "Frame Targets", "Create a camera framing command for a deterministic target list.", [flowInput(), objectInput("targetIds"), numberInput("padding", 0)], commandOutputs(), ["src/scripting/nodes/CameraNodes.ts"]),
111
- define("shake", "camera", "Shake", "Create a deterministic camera shake command.", [flowInput(), numberInput("intensity", 0.2), numberInput("duration", 0.12)], commandOutputs(), ["src/scripting/nodes/CameraNodes.ts"]),
112
- define("cutTo", "camera", "Cut To", "Create a camera cut command.", [flowInput(), objectInput("position"), objectInput("target", true)], commandOutputs(), ["src/scripting/nodes/CameraNodes.ts"]),
113
-
114
- define("captureSnapshot", "evidence", "Capture Snapshot", "Create an evidence snapshot command from deterministic graph context.", [flowInput(), stringInput("label", true)], [{ id: "out", direction: "output", type: "flow" }, { id: "snapshot", direction: "output", type: "object" }], ["src/scripting/nodes/EvidenceNodes.ts"]),
115
- define("markProof", "evidence", "Mark Proof", "Create a deterministic proof marker command.", [flowInput(), stringInput("proofId"), objectInput("details", true)], commandOutputs(), ["src/scripting/nodes/EvidenceNodes.ts"]),
116
- define("assertState", "evidence", "Assert State", "Compare actual and expected values for deterministic evidence.", [{ id: "actual", direction: "input", type: "any", optional: true }, { id: "expected", direction: "input", type: "any", optional: true }, stringInput("operator", true)], [{ id: "out", direction: "output", type: "flow" }, { id: "passed", direction: "output", type: "boolean" }, { id: "assertion", direction: "output", type: "object" }], ["src/scripting/nodes/EvidenceNodes.ts"]),
117
- ...animationVisualNodeDefinitions
118
- ];
119
-
120
- export function listVisualNodeDefinitions(): readonly VisualNodeDefinition[] {
121
- return definitions.map((definition) => ({
122
- ...definition,
123
- ports: definition.ports.map((port) => ({ ...port })),
124
- oldBranchSource: [...definition.oldBranchSource]
125
- }));
126
- }
127
-
128
- export function getVisualNodeDefinition(kind: string): VisualNodeDefinition | undefined {
129
- const definition = definitions.find((entry) => entry.kind === kind);
130
- return definition ? { ...definition, ports: definition.ports.map((port) => ({ ...port })), oldBranchSource: [...definition.oldBranchSource] } : undefined;
131
- }
132
-
133
- export function createVisualNode(kind: string, id: string, data?: Readonly<Record<string, unknown>>): VisualNode {
134
- const definition = getVisualNodeDefinition(kind);
135
- if (!definition) throw new Error(`Unknown visual node kind: ${kind}`);
136
- return {
137
- id,
138
- kind,
139
- ports: definition.ports.map((port) => ({ ...port })),
140
- ...(data ? { data: { ...data } } : {})
141
- };
142
- }
143
-
144
- function define(
145
- kind: string,
146
- category: VisualNodeCategory,
147
- title: string,
148
- description: string,
149
- inputs: readonly VisualPort[],
150
- outputs: readonly VisualPort[],
151
- oldBranchSource: readonly string[]
152
- ): VisualNodeDefinition {
153
- return { kind, category, title, description, ports: [...inputs, ...outputs], oldBranchSource };
154
- }
155
-
156
- function numericUnaryInputs(defaultValue = 0): readonly VisualPort[] {
157
- return [{ id: "value", direction: "input", type: "number", defaultValue }];
158
- }
159
-
160
- function numericBinaryInputs(a = 0, b = 0): readonly VisualPort[] {
161
- return [{ id: "a", direction: "input", type: "number", defaultValue: a }, { id: "b", direction: "input", type: "number", defaultValue: b }];
162
- }
163
-
164
- function booleanBinaryInputs(): readonly VisualPort[] {
165
- return [{ id: "a", direction: "input", type: "boolean", defaultValue: false }, { id: "b", direction: "input", type: "boolean", defaultValue: false }];
166
- }
167
-
168
- function anyBinaryInputs(): readonly VisualPort[] {
169
- return [{ id: "a", direction: "input", type: "any", optional: true }, { id: "b", direction: "input", type: "any", optional: true }];
170
- }
171
-
172
- function numberOutput(): readonly VisualPort[] {
173
- return [{ id: "out", direction: "output", type: "number" }];
174
- }
175
-
176
- function booleanOutput(): readonly VisualPort[] {
177
- return [{ id: "out", direction: "output", type: "boolean" }];
178
- }
179
-
180
- function flowInput(): VisualPort {
181
- return { id: "in", direction: "input", type: "flow", optional: true };
182
- }
183
-
184
- function stringInput(id: string, optional = false): VisualPort {
185
- return { id, direction: "input", type: "string", ...(optional ? { optional: true } : {}) };
186
- }
187
-
188
- function numberInput(id: string, defaultValue: number): VisualPort {
189
- return { id, direction: "input", type: "number", defaultValue };
190
- }
191
-
192
- function booleanInput(id: string, defaultValue: boolean): VisualPort {
193
- return { id, direction: "input", type: "boolean", defaultValue };
194
- }
195
-
196
- function objectInput(id: string, optional = false): VisualPort {
197
- return { id, direction: "input", type: "object", ...(optional ? { optional: true } : {}) };
198
- }
199
-
200
- function commandOutputs(): readonly VisualPort[] {
201
- return [{ id: "out", direction: "output", type: "flow" }, { id: "command", direction: "output", type: "object" }];
202
- }