Module: context/WorkflowContext

Global state store for the workflow editor. Holds all editor state (nodes, connections, selection, zoom/pan, and undo/redo history) via a reducer and exposes it to the component tree through a React Context provider and the useWorkflow hook.
Source:

Members

(static, constant) initialState

Initial reducer state for a fresh, empty workflow editor session.
Source:

(inner, constant) MAX_HISTORY_SIZE

Maximum number of history entries retained for undo/redo.
Source:

(inner, constant) UNDOABLE_ACTIONS

Action types that should be recorded in the undo/redo history.
Source:

Methods

(static) WorkflowProvider(props) → {JSX.Element}

Context provider that owns the workflow reducer state and dispatch, making them available to descendant components. On mount it loads the component catalog via loadComponents (local backend, or bundled JSON for the web build).
Parameters:
Name Type Description
props Object Component props.
Properties
Name Type Description
children JSX.Element The subtree that consumes the context.
Source:
Returns:
The provider wrapping its children.
Type
JSX.Element

(static) useWorkflow() → {Object}

Custom hook for accessing the workflow context. Must be called within a WorkflowProvider, otherwise it throws.
Source:
Returns:
The context value: `{ state, dispatch }`.
Type
Object

(static) workflowReducer(state, action) → {Object}

Core reducer that applies a single action to the workflow state. Handles node lifecycle (ADD_NODE, UPDATE_NODE, UPDATE_NODE_POSITION, DELETE_NODE), connection lifecycle (ADD_CONNECTION, DELETE_CONNECTION, UPDATE_CONNECTION_PORTS), selection (SELECT_NODE, SELECT_CONNECTION, DESELECT_ALL), connecting/drag gestures, viewport (SET_ZOOM, SET_PAN), workflow load/clear, and undo/redo.
Parameters:
Name Type Description
state Object The current workflow state.
action Object The dispatched action with a `type` and optional `payload`.
Source:
Returns:
The next workflow state.
Type
Object

(inner) undoableReducer(state, action) → {Object}

Reducer wrapper that layers undo/redo history management over workflowReducer. UNDO/REDO are delegated directly; END_DRAG commits the pre-drag snapshot as a single history entry; other undoable actions push the prior state onto the history stack (capped at MAX_HISTORY_SIZE) and clear the redo future when nodes or connections actually change. Non-undoable actions pass through unchanged.
Parameters:
Name Type Description
state Object The current workflow state.
action Object The dispatched action with a `type` and optional `payload`.
Source:
Returns:
The next workflow state, including updated history.
Type
Object