Initial commit

moved from private version control
This commit is contained in:
2025-10-19 21:12:41 +11:00
parent 5e84773bbe
commit e64f3e881e
187 changed files with 25372 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
import { createNodeModule } from "../nodeTypes.js";
/**
* Branches execution based on a boolean condition.
*/
export const ifNode = createNodeModule(
{
id: "if",
title: "If",
category: "Logic",
description: "Branch execution based on a boolean condition.",
searchTags: ["if", "condition", "branch", "logic"],
inputs: [
{ id: "exec_in", name: "Exec", direction: "input", kind: "exec" },
{
id: "condition",
name: "Condition",
direction: "input",
kind: "boolean",
},
],
outputs: [
{ id: "then", name: "Then", direction: "output", kind: "exec" },
{ id: "else", name: "Else", direction: "output", kind: "exec" },
],
properties: [],
},
{
emitExec: ({
indent,
indentLevel,
resolveValueInput,
emitBranch,
findExecTargets,
path,
}) => {
const condition = resolveValueInput("condition", "false");
const lines = [`${indent(indentLevel)}if ${condition} then`];
const thenLines = emitBranch("then", {
indentLevel: indentLevel + 1,
path: new Set(path),
});
if (!thenLines.length) {
lines.push(`${indent(indentLevel + 1)}-- then branch`);
} else {
lines.push(...thenLines);
}
if (findExecTargets("else").length) {
lines.push(`${indent(indentLevel)}else`);
const elseLines = emitBranch("else", {
indentLevel: indentLevel + 1,
path: new Set(path),
});
if (!elseLines.length) {
lines.push(`${indent(indentLevel + 1)}-- else branch`);
} else {
lines.push(...elseLines);
}
}
lines.push(`${indent(indentLevel)}end`);
return lines;
},
}
);