API

Interface FgBlockDef

Pure behaviour record for one block type. No classes, no this. A def is stateless — all per-run state lives in FgContext, keyed by block id.

interface FgBlockDef {
    build: (
        config: Readonly<Record<string, unknown>> | undefined,
    ) => FgBlockShape;
    cancelPending?: (block: FgBlock, ctx: FgContext, env: FgEnv) => void;
    execute?: (
        block: FgBlock,
        ctx: FgContext,
        env: FgEnv,
        incomingSignal: string,
    ) => void;
    onTick?: (
        block: FgBlock,
        ctx: FgContext,
        env: FgEnv,
        deltaMs: number,
        task: FgPendingTask,
    ) => void;
    type: string;
    updateOutputs?: (block: FgBlock, ctx: FgContext, env: FgEnv) => void;
}
Index
build: (config: Readonly<Record<string, unknown>> | undefined) => FgBlockShape

Declare sockets/signals from config (called once at instantiation).

cancelPending?: (block: FgBlock, ctx: FgContext, env: FgEnv) => void

ASYNC blocks: teardown hook called on dispose/cancel; mark tasks canceled.

execute?: (
    block: FgBlock,
    ctx: FgContext,
    env: FgEnv,
    incomingSignal: string,
) => void

EXECUTION blocks: run when an input signal fires (PUSH). For async blocks this is also where a task is started, via addPending(ctx, block).

onTick?: (
    block: FgBlock,
    ctx: FgContext,
    env: FgEnv,
    deltaMs: number,
    task: FgPendingTask,
) => void

ASYNC blocks: advance one outstanding task each frame (e.g. delay countdown, animation progress). The tick loop passes the specific task.

type: string
updateOutputs?: (block: FgBlock, ctx: FgContext, env: FgEnv) => void

DATA blocks: compute outputs from inputs (PULL). Writes via setDataValue.