chore(ts): strict mode migration, resolved colors/constants, graph event typing#280
Draft
chore(ts): strict mode migration, resolved colors/constants, graph event typing#280
Conversation
…tion - Add TResolvedGraphColors and merge helpers; wire Graph, Layer, events, API - Accept RecursivePartial for color/constant updates; fix useGraph view config - Export TResolvedGraphColors; add TS strict mode analysis doc Made-with: Cursor
Made-with: Cursor
…hrow - Block, Blocks, BaseConnection, BlockConnection: types and guards - Anchor optional store binding; PublicGraphApi updateConnection no-op if missing - Add logDev for NODE_ENV !== production Made-with: Cursor
… unknown - BatchPath2D, BlockConnections, MultipointConnection, EventedComponent - GraphComponent drag/root events; settings legacy canDrag map - Tests: Graph stub via CoreComponent chain; Resolver/ReactLayer/camera - Story: mergeResolvedGraphConstants; BaseSelectionBucket type guard Made-with: Cursor
- Harden Graph, Layers emitter typing, Layer canvas/html lifecycle - Improve CoreComponent children updates and generic unmount - Tighten GraphComponent drag coords, MultipointConnection, groups - Update strict-mode analysis doc Made-with: Cursor
- Tighten ConnectionState signals, ids, port computeds, view component - Fix ConnectionsStore map updates and selection event typing - Harden PortState signal init and meta merge; optional port owner - Type getCoord, addEventListeners, dragListener, and text helpers Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
…init Made-with: Cursor
Reviewer's GuideMigrates the core graph library to TypeScript strict mode by tightening types across core components, graph configuration, events and React bindings; introduces resolved color/constants types, safer canvas/layer handling, and stronger typing for graph events and selections while fixing several latent runtime edge cases. Sequence diagram for typed React graph event handlingsequenceDiagram
actor ReactUser
participant GraphCanvas
participant ReactLayer
participant ReactHook as useGraphEvents
participant Graph
participant DOMEmitter
ReactUser->>GraphCanvas: render GraphCanvas with graph and callbacks
GraphCanvas->>ReactLayer: create ReactLayer via useLayer
GraphCanvas->>ReactHook: useGraphEvents(graph, callbacks)
ReactHook->>Graph: graph.on(eventName, GraphEventListener)
Graph-->>ReactHook: returns unsubscribe function
DOMEmitter->>Graph: dispatch CustomEvent<GraphEventsDefinitions[EvName]>
Graph->>GraphEventListener: invoke listener(event)
GraphEventListener->>ReactUser: callback(detail, event)
ReactUser->>GraphCanvas: unmount GraphCanvas
GraphCanvas->>ReactHook: cleanup effect
ReactHook->>Graph: off(eventName, GraphEventListener)
Class diagram for resolved graph colors and constantsclassDiagram
class Graph {
-Layers layers
-Signal_TResolvedGraphColors_ $graphColors
-Signal_TGraphConstants_ $graphConstants
-TGraphConfig config
+Graph(config: TGraphConfig, rootEl: HTMLDivElement, graphColors: RecursivePartial_TGraphColors_, graphConstants: RecursivePartial_TGraphConstants_)
+get graphColors() TResolvedGraphColors
+get graphConstants() TGraphConstants
+setColors(colors: RecursivePartial_TGraphColors_) void
+setConstants(constants: RecursivePartial_TGraphConstants_) void
}
class Layers {
+rootSize: Signal_TLayersRootSize_
+attach(root: HTMLDivElement) void
+start() void
+on_update_size_(listener: function) void
}
class TLayersRootSize {
+width: number
+height: number
+dpr: number
}
class TGraphConfig {
+blocks: any
+connections: any
+configurationName: string
+viewConfiguration: any
}
class TGraphColors {
<<type>>
+canvas: TCanvasColors
+block: TBlockColors
+anchor: TAnchorColors
+connection: TConnectionColors
+connectionLabel: TConnectionLabelColors
+selection: TSelectionColors
}
class TResolvedGraphColors {
<<type>>
+canvas: TCanvasColors
+block: TBlockColors
+anchor: TAnchorColors
+connection: TConnectionColors
+connectionLabel: TConnectionLabelColors
+selection: TSelectionColors
}
class TGraphConstants {
<<type>>
+block: any
+connection: any
+text: any
}
class RecursivePartial_TGraphColors_ {
<<type>>
}
class RecursivePartial_TGraphConstants_ {
<<type>>
}
class createInitialResolvedGraphColors {
<<function>>
+createInitialResolvedGraphColors() TResolvedGraphColors
}
class mergeResolvedGraphColors {
<<function>>
+mergeResolvedGraphColors(current: TResolvedGraphColors, patch: RecursivePartial_TGraphColors_) TResolvedGraphColors
}
class mergeResolvedGraphConstants {
<<function>>
+mergeResolvedGraphConstants(current: TGraphConstants, patch: RecursivePartial_TGraphConstants_) TGraphConstants
}
class PublicGraphApi {
-graph: Graph
+getGraphColors() TResolvedGraphColors
+updateGraphColors(colors: RecursivePartial_TGraphColors_) void
+getGraphConstants() TGraphConstants
+updateGraphConstants(constants: RecursivePartial_TGraphConstants_) void
}
Graph --> Layers : uses
Graph --> TGraphConfig : config
Graph --> TResolvedGraphColors : graphColors
Graph --> TGraphConstants : graphConstants
Graph ..> RecursivePartial_TGraphColors_ : setColors input
Graph ..> RecursivePartial_TGraphConstants_ : setConstants input
createInitialResolvedGraphColors ..> TResolvedGraphColors : returns
mergeResolvedGraphColors ..> TResolvedGraphColors : returns
mergeResolvedGraphColors ..> RecursivePartial_TGraphColors_ : patch
mergeResolvedGraphConstants ..> TGraphConstants : returns
mergeResolvedGraphConstants ..> RecursivePartial_TGraphConstants_ : patch
PublicGraphApi --> Graph : wraps
PublicGraphApi ..> TResolvedGraphColors : exposes
PublicGraphApi ..> TGraphConstants : exposes
TLayersRootSize <.. Layers : rootSize value
Class diagram for graph events and React event hooksclassDiagram
class GraphEventsDefinitions {
<<interface>>
+camera-change: function
+constants-changed: function
+colors-changed: function
+state-change: function
+connection-selection-change: function
+click: function
+dblclick: function
+block-drag-start: function
+block-drag: function
+block-drag-end: function
+blocks-selection-change: function
+block-anchor-selection-change: function
+block-change: function
}
class UnwrapGraphEvents {
<<type>>
}
class UnwrapGraphEventsDetail {
<<type>>
}
class GraphEventListener {
<<type>>
+GraphEventListener_EventName_(event: UnwrapGraphEvents_EventName_) void
}
class Graph {
-eventEmitter: EventTarget
+on_EventName_(type: EventName, cb: GraphEventListener_EventName_, options: AddEventListenerOptions) function
+off_EventName_(type: EventName, cb: GraphEventListener_EventName_) void
}
class GraphComponent {
+onGraphEvent_EventName_(eventName: EventName, handler: GraphEventListener_EventName_, options: AddEventListenerOptions) function
}
class Layer {
+onGraphEvent_EventName_(eventName: EventName, handler: GraphEventListener_EventName_, options: AddEventListenerOptions) function
}
class GraphReactHandler_N_ {
<<type>>
+GraphReactHandler_N_(data: UnwrapGraphEventsDetail_N_, event: UnwrapGraphEvents_N_) void
}
class TGraphEventCallbacks {
<<type>>
+click: GraphReactHandler_click_
+dblclick: GraphReactHandler_dblclick_
+onCameraChange: GraphReactHandler_camera-change_
+onBlockDragStart: GraphReactHandler_block-drag-start_
+onBlockDrag: GraphReactHandler_block-drag_
+onBlockDragEnd: GraphReactHandler_block-drag-end_
+onBlockSelectionChange: GraphReactHandler_blocks-selection-change_
+onBlockAnchorSelectionChange: GraphReactHandler_block-anchor-selection-change_
+onBlockChange: GraphReactHandler_block-change_
+onConnectionSelectionChange: GraphReactHandler_connection-selection-change_
+onStateChanged: GraphReactHandler_state-change_
}
class GraphCallbacksMap {
<<const object>>
+click: click
+dblclick: dblclick
+onCameraChange: camera-change
+onBlockDragStart: block-drag-start
+onBlockDrag: block-drag
+onBlockDragEnd: block-drag-end
+onBlockSelectionChange: blocks-selection-change
+onBlockAnchorSelectionChange: block-anchor-selection-change
+onBlockChange: block-change
+onConnectionSelectionChange: connection-selection-change
+onStateChanged: state-change
}
class useGraphEvent {
<<hook>>
+useGraphEvent_EvName_(graph: Graph, event: EvName, cb: function, debounceParams) void
}
class useGraphEvents {
<<hook>>
+useGraphEvents(graph: Graph, events: Partial_TGraphEventCallbacks_) void
}
class bindReactGraphCallback {
<<function>>
+bindReactGraphCallback(graph: Graph, key: GraphCallbackKey, cb: TGraphEventCallbacks_key_) function
}
GraphEventsDefinitions <.. UnwrapGraphEvents : based on
GraphEventsDefinitions <.. UnwrapGraphEventsDetail : based on
GraphEventListener ..> UnwrapGraphEvents : param
Graph --> GraphEventListener : uses in on_off_
Graph --> GraphEventsDefinitions : events typed by
GraphComponent --> Graph : via context.graph
GraphComponent ..> GraphEventListener : handler type
Layer --> Graph : via props.graph
Layer ..> GraphEventListener : handler type
TGraphEventCallbacks --> GraphReactHandler_N_ : mapped
GraphCallbacksMap --> TGraphEventCallbacks : keys align
useGraphEvent --> Graph : subscribes
useGraphEvent ..> UnwrapGraphEvents : event type
useGraphEvent ..> UnwrapGraphEventsDetail : detail type
useGraphEvents --> Graph : subscribes
useGraphEvents --> TGraphEventCallbacks : callbacks map
useGraphEvents --> bindReactGraphCallback : uses
bindReactGraphCallback --> Graph : calls on
bindReactGraphCallback --> GraphCallbacksMap : lookup
bindReactGraphCallback --> GraphEventListener : constructs listener
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
|
Preview is ready. |
…ler tests Made-with: Cursor
…ixes Made-with: Cursor
Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TypeScript strict baseline for library sources, resolved graph colors/constants API, safer canvas/React patterns, and clearer graph event typing.
Highlights
tsconfigwithstrict(stories/tests excluded where appropriate); publish typecheck may still usestrict: falseuntil remaining errors are cleared.TResolvedGraphColors, merge helpers, public API returns fully merged colors.GraphEventListener,graph.on/offuse explicit listener type; ReactuseGraphEvents/TGraphEventCallbacksderived fromGraphCallbacksMapwithout casts.getPortwithout assertion, drag/clickinstanceof MouseEvent,Block.subscribeview cleanup on rebind, orphan connection port ids,BlockStatesignal init withoutundefined,Groupclick guard,addEventListenersunsubscribe fix, etc.Notes
npm run typecheck:strictto see remaining strict-only diagnostics outside publish config.Made with Cursor
Summary by Sourcery
Tighten TypeScript typing across the graph core, colors/constants configuration, and event APIs while hardening canvas/React integration and selection/connection behavior under strict mode.
New Features:
Bug Fixes:
Enhancements:
Build:
Documentation:
Tests: