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

Miso.Flow.Utils.Store

Description

Pure port of utils/store.ts from @xyflow/system: turning user nodes into internal nodes (adoptUserNodes), keeping absolute positions up to date, parent expansion, and the connection lookup.

The only part of the original left on the JavaScript side of the bridge is updateNodeInternals' DOM measurement; its results are merged back with applyMeasurement.

Synopsis

Documentation

data UpdateNodesOptions n Source #

Options shared by adoptUserNodes and updateAbsolutePositions; port of UpdateNodesOptions (the defaults field is a function here).

Constructors

UpdateNodesOptions 

Fields

adoptUserNodes Source #

Arguments

:: Eq n 
=> [Node n] 
-> NodeLookup n

previous lookup (pass empty initially)

-> UpdateNodesOptions n 
-> (NodeLookup n, ParentLookup n, AdoptUserNodesReturn) 

Build the internal NodeLookup / ParentLookup from user nodes; port of adoptUserNodes. The previous lookup preserves measured dimensions and DOM-measured handle bounds across updates (standing in for the TS reference-equality cache, using Eq instead).

updateAbsolutePositions :: NodeLookup n -> UpdateNodesOptions n -> NodeLookup n Source #

Refresh positionAbsolute of every node in the lookup; port of updateAbsolutePositions.

data ParentExpandChild Source #

A child that may cause its parent to expand.

Constructors

ParentExpandChild 

Fields

handleExpandParent :: [ParentExpandChild] -> NodeLookup n -> ParentLookup n -> NodeOrigin -> [NodeChange n] Source #

Changes needed to expand parents so the given children fit; port of handleExpandParent.

updateConnectionLookup :: [Edge e] -> (ConnectionLookup, EdgeLookup e) Source #

Build the ConnectionLookup and EdgeLookup from edges; port of updateConnectionLookup.

applyMeasurement :: [NodeMeasurement] -> NodeLookup n -> NodeLookup n Source #

Merge measured dimensions and handle bounds into the lookup (the Haskell half of updateNodeInternals).

data NodeMeasurement Source #

DOM measurement of one node, as reported over the bridge by the JavaScript side's updateNodeInternals.