miso-flow
LicenseBSD3-style (see the file LICENSE)
Safe HaskellNone
LanguageHaskell2010

Miso.Flow.Internal.Bridge

Description

Low-level bindings to the miso-flow JavaScript bridge (js/miso-flow.js, built from ts/miso-flow.ts), which drives the imperative @xyflow/system modules (XYPanZoom, XYDrag, XYHandle, XYResizer, XYMinimap) against the DOM rendered by miso.

Everything crossing the boundary is JSON. Higher layers (Miso.Flow.Component and the Miso.Flow.* instance modules) wrap this into MVU-friendly interfaces.

Synopsis

Store handle

newtype FlowStore Source #

Handle to a JavaScript-side MisoFlowStore.

Constructors

FlowStore JSVal 

Instances

Instances details
Eq FlowStore Source #

A component holds at most one store for its whole lifetime, so all handles are interchangeable; this lets models containing a FlowStore satisfy the Eq model constraint of the miso runtime.

Instance details

Defined in Miso.Flow.Internal.Bridge

Options

data StoreOptions Source #

Options handed to the JavaScript store; mirrors the union of pane, drag and connection settings across @xyflow/system's modules.

defaultStoreOptions :: StoreOptions Source #

Defaults matching xyflow's.

Callbacks out of the gesture system

data BridgeCallbacks Source #

Haskell handlers for events raised by the gesture system. Payloads arrive parsed; hook the ones you need and leave the rest as no-ops (see emptyBridgeCallbacks).

Constructors

BridgeCallbacks 

Fields

Wire types (JS -> Haskell payloads)

data WireNodeChange Source #

One node change as reported by the JavaScript side (drag steps, measurements, resizes). Unlike NodeChange this can carry the DOM-measured handle bounds and absolute position.

Constructors

WirePositionChange NodeId (Maybe XYPosition) (Maybe XYPosition) (Maybe Bool)

id, position, positionAbsolute, dragging

WireDimensionChange NodeId (Maybe Dimensions) (Maybe Bool) SetAttributes (Maybe NodeHandleBounds) (Maybe XYPosition)

id, dimensions, resizing, setAttributes, handleBounds, positionAbsolute

WireSelectionChange NodeId Bool 
WireRemoveChange NodeId 

data ConnectionStateWire Source #

Connection state as serialized by the bridge: nodes are referred to by id (resolve them against your NodeLookup via wireConnectionState). Mirroring @xyflow/system, cwFrom is in flow coordinates while cwTo and cwPointer arrive in pane (screen) coordinates — convert them with pointToRendererPoint before rendering.

wireConnectionState :: (NodeId -> Maybe (InternalNode n)) -> ConnectionStateWire -> ConnectionState n Source #

Resolve a ConnectionStateWire into a ConnectionState using a node resolver (typically a lookup into your NodeLookup).

Store lifecycle

createFlowStore Source #

Arguments

:: DOMRef 
-> StoreOptions 
-> Maybe (Connection -> Bool)

synchronous connection validator (XYHandle consults it while the pointer moves, so it cannot go through the action queue)

-> BridgeCallbacks 
-> IO FlowStore 

Create a JavaScript store over the flow's root element. Expects the element to contain a pane (.<lib>-flow__pane) and a viewport (.xyflow__viewport), as rendered by flowView.

Requires js/miso-flow.js (it defines globalThis.MisoFlow). On the GHCJS/JS backends the library's js-sources links it into the compiled output; on WASM it is spliced in at compile time and evaluated here on first use.

Graph sync

Viewport control

Node measurement

Dragging

Connections

Resizer

Minimap