@lupinum/board-connections 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,113 @@
1
+ import type { Bounds, BoardEventMap, BoardNode, EdgeId, NodeId, Point } from '@lupinum/board-core';
2
+ /** Public events installed with the connections plugin. */
3
+ export interface ConnectionsEventMap extends BoardEventMap {
4
+ 'edge:created': (edge: BoardEdge) => void;
5
+ 'edge:updated': (edge: BoardEdge, prev: BoardEdge) => void;
6
+ 'edge:deleted': (edgeId: EdgeId) => void;
7
+ }
8
+ /** Side of a rectangular node used for connection anchors. */
9
+ export type AnchorSide = 'top' | 'right' | 'bottom' | 'left';
10
+ /** Routing strategy used when rendering a connection edge. */
11
+ export type ConnectionRouting = 'bezier' | 'smooth-step' | 'step' | 'straight' | 'arc';
12
+ /** How UI-created and reconnected edge endpoints choose node anchors. */
13
+ export type ConnectionEndpointMode = 'auto' | 'manual';
14
+ /** Marker rendered at either end of an edge. */
15
+ export type EdgeEnd = 'none' | 'arrow';
16
+ /** Whether an endpoint came from an explicit anchor or automatic side resolution. */
17
+ type EndpointResolutionKind = 'explicit' | 'auto';
18
+ /** Anchor location along a given node side, with `offset` normalized from 0 to 1. */
19
+ export interface AnchorPosition {
20
+ side: AnchorSide;
21
+ offset: number;
22
+ }
23
+ /** Persistent edge record owned by the connections plugin. */
24
+ export interface BoardEdge<T = Record<string, unknown>> {
25
+ id: EdgeId;
26
+ from: NodeId;
27
+ to: NodeId;
28
+ fromAnchor?: AnchorPosition;
29
+ toAnchor?: AnchorPosition;
30
+ fromEnd?: EdgeEnd;
31
+ toEnd?: EdgeEnd;
32
+ label?: string;
33
+ color?: string;
34
+ data: T;
35
+ zIndex: number;
36
+ }
37
+ /** Partial update payload accepted by `updateEdge`. */
38
+ export interface BoardEdgePatch<T = Record<string, unknown>> {
39
+ from?: NodeId;
40
+ to?: NodeId;
41
+ fromAnchor?: AnchorPosition;
42
+ toAnchor?: AnchorPosition;
43
+ fromEnd?: EdgeEnd;
44
+ toEnd?: EdgeEnd;
45
+ label?: string;
46
+ color?: string;
47
+ data?: T;
48
+ }
49
+ /** Options for configuring the connections plugin defaults. */
50
+ export interface ConnectionPluginOptions {
51
+ routing?: ConnectionRouting;
52
+ endpointMode?: ConnectionEndpointMode;
53
+ defaultArrow?: 'none' | 'start' | 'end' | 'both';
54
+ }
55
+ /** Context passed when a host opts into creating a node from an empty connection drop. */
56
+ export interface CreateNodeForConnectionContext {
57
+ sourceNodeId: NodeId;
58
+ sourceSide: AnchorSide;
59
+ pointerWorld: Point;
60
+ candidateAnchor: AnchorPosition | null;
61
+ }
62
+ /** Resolved connection defaults installed with the engine plugin. */
63
+ export interface ConnectionConfig {
64
+ routing: ConnectionRouting;
65
+ endpointMode: ConnectionEndpointMode;
66
+ defaultArrow: NonNullable<ConnectionPluginOptions['defaultArrow']>;
67
+ }
68
+ /** Engine API installed by the connections plugin. */
69
+ export interface ConnectionsApi {
70
+ createEdge<T extends Record<string, unknown> = Record<string, unknown>>(input: Omit<BoardEdge<T>, 'id' | 'zIndex'> & {
71
+ id?: EdgeId;
72
+ zIndex?: number;
73
+ }): BoardEdge<T>;
74
+ updateEdge<T extends Record<string, unknown> = Record<string, unknown>>(id: EdgeId, patch: BoardEdgePatch<T>): BoardEdge<T>;
75
+ deleteEdge(id: EdgeId): void;
76
+ getEdge(id: EdgeId): BoardEdge | undefined;
77
+ getEdges(): BoardEdge[];
78
+ getEdgesFrom(id: NodeId): BoardEdge[];
79
+ getEdgesTo(id: NodeId): BoardEdge[];
80
+ getEdgesBetween(from: NodeId, to: NodeId): BoardEdge[];
81
+ getConfig(): ConnectionConfig;
82
+ }
83
+ /** Fully resolved endpoint used for rendering and hit-testing an edge. */
84
+ export interface ResolvedConnectionEndpoint {
85
+ nodeId: NodeId;
86
+ node: Pick<BoardNode, 'id' | 'x' | 'y' | 'width' | 'height'>;
87
+ side: AnchorSide;
88
+ offset: number;
89
+ point: Point;
90
+ kind: EndpointResolutionKind;
91
+ }
92
+ /** Low-level path segment used to render a connection route. */
93
+ export type ConnectionRouteSegment = {
94
+ type: 'line';
95
+ from: Point;
96
+ to: Point;
97
+ } | {
98
+ type: 'cubic';
99
+ from: Point;
100
+ control1: Point;
101
+ control2: Point;
102
+ to: Point;
103
+ };
104
+ /** Render-ready edge route including path data, bounds, and label position. */
105
+ export interface ConnectionRoute {
106
+ routing: ConnectionRouting;
107
+ path: string;
108
+ labelPoint: Point;
109
+ bounds: Bounds;
110
+ waypoints: Point[];
111
+ segments: ConnectionRouteSegment[];
112
+ }
113
+ export {};
package/dist/vue.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** Vue rendering shell for connections installed on the enclosing BoardRoot. */
2
+ export { BoardConnectionLayer } from './layer.js';