@erd-studio/renderer 0.3.0 → 0.4.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +7 -3
  3. package/dist/{chunk-DUQ2TTQH.js → chunk-64BVOHOR.js} +4 -3
  4. package/dist/chunk-7VFJNN4P.js +10461 -0
  5. package/dist/{chunk-WOTSQZCQ.js → chunk-YLXBIRPE.js} +132 -2
  6. package/dist/editor.js +43 -3
  7. package/dist/index.js +14 -3
  8. package/dist/sizing.js +2 -2
  9. package/dist/store.js +1 -1
  10. package/dist/styles.css +912 -359
  11. package/dist/types/ErdCanvas.d.ts +29 -1
  12. package/dist/types/canvas/CanvasBackdrop.d.ts +3 -2
  13. package/dist/types/canvas/EdgeRouting.d.ts +56 -0
  14. package/dist/types/canvas/useCanvasGraph.d.ts +7 -1
  15. package/dist/types/canvas/useHoverFocus.d.ts +64 -0
  16. package/dist/types/components/DetailPanel/AliasEditor.d.ts +15 -1
  17. package/dist/types/components/DetailPanel/ColumnEditor.d.ts +18 -2
  18. package/dist/types/components/DetailPanel/DescriptionEditor.d.ts +1 -1
  19. package/dist/types/components/DetailPanel/DetailPanel.d.ts +31 -2
  20. package/dist/types/components/DetailPanel/FieldsSection.d.ts +68 -0
  21. package/dist/types/components/Graph/EdgeFlow.d.ts +55 -0
  22. package/dist/types/components/Graph/EdgeLabels.d.ts +18 -0
  23. package/dist/types/components/Graph/FkEdge.d.ts +8 -1
  24. package/dist/types/components/Graph/ModelNode.d.ts +1 -1
  25. package/dist/types/components/Legend/Legend.d.ts +34 -3
  26. package/dist/types/components/StatusBar/StatusBar.d.ts +45 -0
  27. package/dist/types/components/common/ColumnRowEditor.d.ts +18 -2
  28. package/dist/types/components/common/KeyBadgeGroup.d.ts +5 -1
  29. package/dist/types/editor.d.ts +8 -2
  30. package/dist/types/hooks/usePrefersReducedMotion.d.ts +13 -0
  31. package/dist/types/index.d.ts +2 -1
  32. package/dist/types/lib/badgeLabels.d.ts +6 -0
  33. package/dist/types/lib/canvasContext.d.ts +20 -0
  34. package/dist/types/lib/canvasFocus.d.ts +66 -0
  35. package/dist/types/lib/edgeFlow.d.ts +84 -0
  36. package/dist/types/lib/edgeRouting/index.d.ts +146 -0
  37. package/dist/types/lib/edgeRouting/input.d.ts +35 -0
  38. package/dist/types/lib/edgeRouting/lineStyle.d.ts +16 -0
  39. package/dist/types/lib/edgeRouting/render/corners.d.ts +52 -0
  40. package/dist/types/lib/edgeRouting/render/crossings.d.ts +27 -0
  41. package/dist/types/lib/edgeRouting/render/curveCrossings.d.ts +35 -0
  42. package/dist/types/lib/edgeRouting/render/pathRender.d.ts +74 -0
  43. package/dist/types/lib/edgeRouting/render/tunnels.d.ts +49 -0
  44. package/dist/types/lib/edgeRouting/routeAll.d.ts +20 -0
  45. package/dist/types/lib/edgeRouting/routers/orthogonal/geom.d.ts +58 -0
  46. package/dist/types/lib/edgeRouting/routers/orthogonal/grid.d.ts +77 -0
  47. package/dist/types/lib/edgeRouting/routers/orthogonal/nudge.d.ts +62 -0
  48. package/dist/types/lib/edgeRouting/routers/orthogonal/params.d.ts +152 -0
  49. package/dist/types/lib/edgeRouting/routers/orthogonal/router.d.ts +51 -0
  50. package/dist/types/lib/edgeRouting/routers/orthogonal/search.d.ts +81 -0
  51. package/dist/types/lib/edgeRouting/routers/orthogonalAvoid.d.ts +11 -0
  52. package/dist/types/lib/edgeRouting/types.d.ts +113 -0
  53. package/dist/types/lib/edgeRouting/worker/client.d.ts +23 -0
  54. package/dist/types/lib/edgeRouting/worker/entry.d.ts +1 -0
  55. package/dist/types/lib/edgeRouting/worker/protocol.d.ts +23 -0
  56. package/dist/types/lib/hoverIntent.d.ts +44 -0
  57. package/dist/types/lib/layerCues.d.ts +26 -0
  58. package/dist/types/lib/nodeOverlays.d.ts +6 -0
  59. package/dist/types/lib/nodeSizing.d.ts +1 -1
  60. package/dist/types/lib/pathGeometry.d.ts +45 -0
  61. package/dist/types/lib/reuseUnchanged.d.ts +28 -0
  62. package/dist/types/lib/roleOptions.d.ts +13 -0
  63. package/dist/types/store/editorStore.d.ts +58 -1
  64. package/dist/types/types/graph.d.ts +20 -1
  65. package/package.json +2 -2
  66. package/dist/chunk-HWA32XG5.js +0 -5652
  67. package/dist/types/components/DetailPanel/GrainEditor.d.ts +0 -16
  68. package/dist/types/components/DetailPanel/MetaEditor.d.ts +0 -21
  69. package/dist/types/components/DetailPanel/ModelRationale.d.ts +0 -27
  70. package/dist/types/components/DetailPanel/RationaleField.d.ts +0 -28
  71. package/dist/types/components/DetailPanel/RoleEditor.d.ts +0 -13
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Edge routing — shared types.
3
+ *
4
+ * Every FK line on the canvas is routed in one pass over the whole graph
5
+ * (`routeAll`), so the router can see every table (obstacles) and every other
6
+ * line (crossings, shared channels). An `FkEdge` reads its routed path from
7
+ * the canvas store and falls back to the smooth-step path when there is none.
8
+ *
9
+ * Coordinates are React Flow flow coordinates (the same space as node
10
+ * `positionAbsolute`).
11
+ */
12
+ export type Side = 'top' | 'right' | 'bottom' | 'left';
13
+ export interface Point {
14
+ x: number;
15
+ y: number;
16
+ }
17
+ /** A node's box on the canvas. Tables and sticky notes are both obstacles. */
18
+ export interface Rect {
19
+ id: string;
20
+ x: number;
21
+ y: number;
22
+ width: number;
23
+ height: number;
24
+ /** 'model' for a table card, 'annotation' for a sticky note. */
25
+ kind: 'model' | 'annotation';
26
+ }
27
+ /** Where a line meets a table: the point on the card's border and which side. */
28
+ export interface Anchor extends Point {
29
+ side: Side;
30
+ }
31
+ /** How far (px) the drawn line stops short of the card, leaving room for the `*` / `1`. */
32
+ export declare const PATH_GAP = 20;
33
+ /** How far (px) from the card border the `*` / `1` label sits. */
34
+ export declare const LABEL_OFFSET = 8;
35
+ /** One FK line to route, as the graph transformer + edge distribution placed it. */
36
+ export interface EdgeSpec {
37
+ id: string;
38
+ source: string;
39
+ target: string;
40
+ /** The current (smooth-step) anchors: handle side + distributed slot. */
41
+ sourceAnchor: Anchor;
42
+ targetAnchor: Anchor;
43
+ isSelfLoop: boolean;
44
+ loopIndex: number;
45
+ /** 'many-to-one' | 'one-to-one' | 'one-to-many' | 'many-to-many'. */
46
+ cardinality: string;
47
+ }
48
+ export interface RoutingInput {
49
+ obstacles: Rect[];
50
+ edges: EdgeSpec[];
51
+ }
52
+ /**
53
+ * A router's answer for one line. `points` is an orthogonal-or-not polyline
54
+ * from the source stub to the target stub (each stub is the anchor pushed
55
+ * out by PATH_GAP along its side); the first and last segments should leave
56
+ * / enter perpendicular to the side. A router may move the anchors (choose
57
+ * another side or slot); the `*` / `1` labels follow the anchors.
58
+ */
59
+ export interface RoutedLine {
60
+ sourceAnchor: Anchor;
61
+ targetAnchor: Anchor;
62
+ points: Point[];
63
+ }
64
+ /** What the canvas draws for one line, after crossings and tunnels are worked out. */
65
+ export interface RoutedEdge extends RoutedLine {
66
+ /** The SVG path. */
67
+ d: string;
68
+ /** Midpoint along the drawn path (role label, swap button, badges). */
69
+ mid: Point;
70
+ /** Draw a background-coloured casing under the line (crossings = 'halo'). */
71
+ halo?: boolean;
72
+ /**
73
+ * crossings = 'halo', on a line that passes under another: `d` with the
74
+ * breaks cut out. FkEdge draws the visible stroke and its casing with it;
75
+ * `d` stays whole for the moving arrows and the hit area.
76
+ */
77
+ strokeD?: string;
78
+ /**
79
+ * Stretches of the line that pass under a table card (not its own two
80
+ * ends): polylines, drawn above the cards as a faint "x-ray" dashed line.
81
+ */
82
+ tunnels?: Point[][];
83
+ }
84
+ export type CrossingMode = 'none'
85
+ /** A small semicircle bridge where one line hops over another. */
86
+ | 'hops'
87
+ /** Every line has a canvas-coloured casing, and the line underneath is cut where it passes under another. */
88
+ | 'halo';
89
+ export type UnderTablesMode =
90
+ /** The card hides the line. */
91
+ 'hidden'
92
+ /** The hidden stretch is drawn faintly over the card, with portal rings where it enters and leaves. */
93
+ | 'xray';
94
+ export type CornerMode = 'rounded' | 'curved' | 'sharp';
95
+ /** How the router's polylines are drawn: one line style's settings. */
96
+ export interface LineStyleOptions {
97
+ crossings: CrossingMode;
98
+ underTables: UnderTablesMode;
99
+ corners: CornerMode;
100
+ }
101
+ /** What `routeAll` needs of a router (the route-around router is the one the canvas uses). */
102
+ export interface LineRouter {
103
+ route(input: RoutingInput): {
104
+ lines: Map<string, RoutedLine>;
105
+ };
106
+ /** Drop anything kept from earlier passes. */
107
+ reset(): void;
108
+ }
109
+ export interface RouteResult {
110
+ edges: Map<string, RoutedEdge>;
111
+ /** How long the pass took (ms), for the performance guard. */
112
+ millis: number;
113
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Starts a canvas's line-routing worker, or says it cannot (returns null) so
3
+ * the canvas routes on the main thread with a lower cap instead.
4
+ *
5
+ * The worker's code is inlined at build time as `__ERD_EDGE_ROUTING_WORKER__`
6
+ * (the extension's `esbuild.js` and the package's `build.mjs` both define
7
+ * it). Where it is not defined (unit tests, a consumer bundling the source
8
+ * itself), where `Worker` or blob URLs are missing, or where the page's CSP
9
+ * refuses a blob worker, there is no worker.
10
+ */
11
+ import type { WorkerRouteRequest, WorkerRouteResult } from './protocol.js';
12
+ export interface RoutingWorkerEvents {
13
+ onResult: (result: WorkerRouteResult) => void;
14
+ /** The worker failed to start or crashed: it is terminated and never answers again. */
15
+ onFailure: (err: unknown) => void;
16
+ }
17
+ export interface RoutingWorkerHandle {
18
+ post: (request: WorkerRouteRequest) => void;
19
+ terminate: () => void;
20
+ }
21
+ /** Starts a worker for one canvas. */
22
+ export type RoutingWorkerFactory = (events: RoutingWorkerEvents) => RoutingWorkerHandle | null;
23
+ export declare const createRoutingWorker: RoutingWorkerFactory;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Messages between a canvas and its line-routing worker (`worker/entry.ts`).
3
+ * Everything here is structured-clone safe: plain objects, arrays and Maps.
4
+ */
5
+ import type { LineStyle } from '../lineStyle.js';
6
+ import type { RoutedEdge, RoutingInput } from '../types.js';
7
+ /** Route `input` in `style`. `seq` comes back on the answer, so a canvas can drop a stale one. */
8
+ export interface WorkerRouteRequest {
9
+ type: 'route';
10
+ seq: number;
11
+ input: RoutingInput;
12
+ style: LineStyle;
13
+ zoom: number;
14
+ }
15
+ /** The worker's answer to one request. */
16
+ export interface WorkerRouteResult {
17
+ seq: number;
18
+ edges: Map<string, RoutedEdge>;
19
+ /** How long the pass took in the worker. */
20
+ millis: number;
21
+ /** A router or renderer error in this pass (the routes then leave those lines out). */
22
+ error?: string;
23
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Hover intent — decides when a pointer resting on a table becomes a hover
3
+ * focus, so skimming across the canvas does not flash every table it crosses.
4
+ *
5
+ * - From nothing to a table: wait `HOVER_ENTER_DELAY_MS`.
6
+ * - From table A to table B: wait `HOVER_SWITCH_DELAY_MS`, then commit B
7
+ * directly (never null in between, so nothing un-dims and re-dims).
8
+ * - Leaving: wait `HOVER_LEAVE_GRACE_MS` before clearing; entering again,
9
+ * or `hold()` (the pointer is on one of the focus's bright lines), cancels
10
+ * the clear.
11
+ *
12
+ * `cancelEnter()` drops only a pending enter; a pending clear still runs, so
13
+ * a pointer that has left a table never leaves its focus behind.
14
+ *
15
+ * An enter is ignored while a mouse button is held (`buttons !== 0`), while
16
+ * `isSuppressed()` says so (it is asked again when the timer fires), or when
17
+ * the table is already the focus. At most two timers exist at a time.
18
+ *
19
+ * Framework-free; timers are injected so tests can use fake ones.
20
+ */
21
+ export declare const HOVER_ENTER_DELAY_MS = 120;
22
+ export declare const HOVER_SWITCH_DELAY_MS = 60;
23
+ export declare const HOVER_LEAVE_GRACE_MS = 150;
24
+ type TimerId = ReturnType<typeof setTimeout>;
25
+ export interface HoverIntentOptions {
26
+ /** Make `id` the focus, or clear it with null. */
27
+ commit: (id: string | null) => void;
28
+ /** The id currently in focus (read at event time). */
29
+ current: () => string | null;
30
+ /** True while hover must not start a focus (drags, menus, pans). */
31
+ isSuppressed: () => boolean;
32
+ setTimeout?: (fn: () => void, ms: number) => TimerId;
33
+ clearTimeout?: (id: TimerId) => void;
34
+ }
35
+ export interface HoverIntent {
36
+ enter(id: string, buttons: number): void;
37
+ leave(): void;
38
+ hold(): void;
39
+ cancelEnter(): void;
40
+ cancelPending(): void;
41
+ dispose(): void;
42
+ }
43
+ export declare function createHoverIntent(options: HoverIntentOptions): HoverIntent;
44
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Layer cues: how the canvas names the layer a table lives in.
3
+ *
4
+ * A table's header badge has one meaning, its layer, and the layer is named
5
+ * the same way wherever the canvas names one (the node badge, the toolbar
6
+ * chip, the status-bar key): the layer's abbreviation, then its label.
7
+ *
8
+ * A project with a single layer has nothing to tell apart, so the per-table
9
+ * badge, its colour strip, the status-bar key and the toolbar chip are left
10
+ * off there ({@link isSingleLayerProject}).
11
+ */
12
+ import type { DisplaySubjectArea, LayerConfig } from '@erd-studio/core';
13
+ /** Abbreviations for the default layers, for when a layer has no config. */
14
+ export declare const LAYER_BADGE_FALLBACK: Readonly<Record<string, string>>;
15
+ /**
16
+ * A layer's badge text: its configured abbreviation, else the default
17
+ * layers' abbreviation, else the first three letters of its id.
18
+ */
19
+ export declare function layerAbbreviation(id: string, config?: Pick<LayerConfig, 'abbreviation'>): string;
20
+ /**
21
+ * Whether the project has one layer at most, with every table on the diagram
22
+ * in the diagram's layer: the layer badge, strip, key and chip are then left
23
+ * off. Needs `layerConfigs`: a domain from an older core (or a host that
24
+ * sends no layer list) keeps every layer cue, as it did before.
25
+ */
26
+ export declare function isSingleLayerProject(domain: Pick<DisplaySubjectArea, 'layer' | 'layerConfigs' | 'models'>): boolean;
@@ -14,6 +14,12 @@
14
14
  * This lets selection / search / expansion changes avoid re-running the full
15
15
  * domain transform (which would also drop `measured` and force React Flow to
16
16
  * re-measure every node).
17
+ *
18
+ * What counts as "connected" is `computeCanvasFocus` (`canvasFocus.ts`), the
19
+ * same rule the hover preview uses. Hover itself never comes through here:
20
+ * every `setEdges` re-renders every `FkEdge`, which is fine once per click but
21
+ * not on every pointer move, so hover dims with a root CSS class instead
22
+ * (`useHoverFocus`).
17
23
  */
18
24
  import type { TableFlowNode, FkFlowEdge, AnnotationFlowNode, AnnotationFlowEdge } from '../types/graph.js';
19
25
  export type GraphNode = TableFlowNode | AnnotationFlowNode;
@@ -47,4 +47,4 @@ export declare function resolveNodeDimensions(node: Pick<TableFlowNode, 'data' |
47
47
  * slightly more space than the minimum estimate, preventing overlap
48
48
  * when font rendering or badge widths differ from the approximation.
49
49
  */
50
- export declare function estimateNodeWidth(data: Pick<TableNodeData, 'modelName' | 'label' | 'columns' | 'provenance'>): number;
50
+ export declare function estimateNodeWidth(data: Pick<TableNodeData, 'modelName' | 'label' | 'columns' | 'provenance'> & Partial<Pick<TableNodeData, 'tableLayer' | 'shownSchema' | 'alias' | 'singleLayer'>>): number;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Path geometry for the relationship flow glyphs: how long a drawn edge path
3
+ * is, where its straight runs are, and the point and heading at a fraction
4
+ * of its length.
5
+ *
6
+ * Reads the absolute commands the canvas draws: `M`, `L`, `H`, `V` (xyflow's
7
+ * smooth-step path and the Legend samples), `Q` (smooth-step bends) and `C`
8
+ * (self-loops). Curves are flattened into a few chords, which is accurate to
9
+ * well under a pixel for the radii used here. Anything else ends the parse;
10
+ * what was read so far is kept.
11
+ *
12
+ * Pure: no React, no DOM (`SVGPathElement.getTotalLength` would need a
13
+ * mounted element and a layout).
14
+ */
15
+ export interface PathPoint {
16
+ x: number;
17
+ y: number;
18
+ }
19
+ export interface PathPose extends PathPoint {
20
+ /** Heading in degrees, along increasing path length (SVG `rotate="auto"`). */
21
+ angle: number;
22
+ }
23
+ export interface PathGeometry {
24
+ /** The flattened path. */
25
+ readonly points: readonly PathPoint[];
26
+ /** Cumulative length at each point (`cumulative[0] === 0`). */
27
+ readonly cumulative: readonly number[];
28
+ readonly length: number;
29
+ /** Straight runs (`L` / `H` / `V`) as fractions of the length, in path order. */
30
+ readonly straights: readonly {
31
+ start: number;
32
+ end: number;
33
+ }[];
34
+ }
35
+ /** Flatten and measure a path. An unreadable path has length 0. */
36
+ export declare function measurePath(d: string): PathGeometry;
37
+ /** The point and heading at `fraction` (0..1) of the path's length. */
38
+ export declare function poseAt(geom: PathGeometry, fraction: number): PathPose;
39
+ /**
40
+ * Where two still glyphs sit so that neither lands on a bend: the middle of
41
+ * the first and of the last usable straight run, or a third and two thirds
42
+ * of the only one. Null when the path has no usable straight run (a
43
+ * self-loop's curve): the planner's defaults then apply.
44
+ */
45
+ export declare function stillPositions(geom: PathGeometry): readonly [number, number] | null;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Structural sharing for a rebuilt graph: every rebuilt node or edge that is
3
+ * structurally equal to the one already in the store is replaced by that
4
+ * same object.
5
+ *
6
+ * The canvas rebuilds every node and edge whenever the domain changes —
7
+ * including the optimistic update after a drag, where only the moved
8
+ * tables' positions (and the sides of their edges) differ. React Flow reuses
9
+ * its internal node for a user node that is the same object as last time,
10
+ * and memoised node and edge components skip rendering when their props keep
11
+ * their identity, so handing back the old objects for everything that did
12
+ * not change turns a 500-table re-render into a handful.
13
+ *
14
+ * Correct by construction: the result is equal, field for field, to what the
15
+ * rebuild produced; only identities change. Transient React Flow fields that
16
+ * the rebuild never sets (`dragging`, `resizing`) are ignored, and an absent
17
+ * `selected` equals `false`.
18
+ */
19
+ /** Structural equality of plain data: functions, Maps, Sets and class instances compare by identity. */
20
+ export declare function sameData(a: unknown, b: unknown): boolean;
21
+ /**
22
+ * `next` with each element replaced by the element of `prev` with the same
23
+ * id when the two are structurally equal. Returns `prev` itself when every
24
+ * element was reused in the same order (nothing to set at all).
25
+ */
26
+ export declare function reuseUnchanged<T extends {
27
+ id: string;
28
+ }>(prev: readonly T[], next: T[]): T[];
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The words the canvas shows for each table role. The stored keys
3
+ * (`gold-fact`, …) never change; only the labels are for people. The order is
4
+ * core's `TABLE_ROLE_VALUES` (the role field's choices).
5
+ */
6
+ import type { TableRole } from '@erd-studio/core';
7
+ /** Human-readable labels for each role (the stored key stays as it is). */
8
+ export declare const ROLE_OPTIONS: ReadonlyArray<{
9
+ value: TableRole;
10
+ label: string;
11
+ }>;
12
+ /** The label for a role key, or the key itself for a role this renderer does not know. */
13
+ export declare function roleLabel(role: string): string;
@@ -14,8 +14,11 @@
14
14
  */
15
15
  import { type ReactNode } from 'react';
16
16
  import { type StoreApi } from 'zustand';
17
- import type { DisplaySubjectArea, ExistingTablePreview } from '@erd-studio/core';
17
+ import type { CanvasContext, DisplaySubjectArea, ExistingTablePreview } from '@erd-studio/core';
18
18
  import type { TableFlowNode, FkFlowEdge, FkEdgeData, AnnotationFlowNode, AnnotationFlowEdge } from '../types/graph.js';
19
+ import { type CanvasFocus } from '../lib/canvasFocus.js';
20
+ import type { RoutedEdge } from '../lib/edgeRouting/types.js';
21
+ import { type LineStyle } from '../lib/edgeRouting/lineStyle.js';
19
22
  /** Context menu state for edge right-click. */
20
23
  export interface EdgeContextMenu {
21
24
  type: 'edge';
@@ -101,6 +104,44 @@ export interface CanvasState {
101
104
  editingColumn: string | null;
102
105
  /** Currently selected annotation ID, or null. */
103
106
  selectedAnnotation: string | null;
107
+ /**
108
+ * Hover preview focus: the table the pointer rests on, its related tables
109
+ * and lines (`useHoverFocus`). Ephemeral UI state: never persisted, never
110
+ * posted to the host, never written to a file.
111
+ */
112
+ hoverFocus: CanvasFocus | null;
113
+ /**
114
+ * What carries the moving relationship arrows: `hoverFocus`, else the
115
+ * focus of the clicked table or line. Ephemeral, like `hoverFocus`.
116
+ */
117
+ flowFocus: CanvasFocus | null;
118
+ /**
119
+ * The project has no dbt project, so there is one stage only: the canvas
120
+ * drops the stage colours (`editor-canvas--neutral`) and the legend its
121
+ * Physical, ghost and comparison entries. Default false, today's look. The
122
+ * extension's store sets it from the host's `logicalOnly` flag; ErdCanvas
123
+ * from its `logicalOnly` prop.
124
+ */
125
+ logicalOnly: boolean;
126
+ /**
127
+ * What the editing host knows beyond the diagram (`CanvasContext`): each
128
+ * table's file, its relationships to tables not on the diagram, who reviews
129
+ * it. Logical stage only. Null by default and in the viewer, which never
130
+ * gets one: then the detail panel has no File line or "Not on this
131
+ * diagram" list and no node shows a "+n" chip.
132
+ */
133
+ canvasContext: CanvasContext | null;
134
+ /**
135
+ * How FK lines are drawn (`curved` or `hops`), a reader's view preference.
136
+ * The extension's store sets it from the host's `lineStyle` message (the
137
+ * `erdStudio.canvas.lineStyle` setting); ErdCanvas from its `lineStyle` prop.
138
+ */
139
+ lineStyle: LineStyle;
140
+ /**
141
+ * The routed FK lines by edge id, from `EdgeRouter`'s last pass. Null (or
142
+ * a line missing from it) means `FkEdge` draws its smooth-step fallback.
143
+ */
144
+ edgeRoutes: Map<string, RoutedEdge> | null;
104
145
  }
105
146
  export interface CanvasActions {
106
147
  setSearchQuery: (query: string) => void;
@@ -162,6 +203,16 @@ export interface CanvasActions {
162
203
  setEditingColumn: (name: string | null) => void;
163
204
  /** Select an annotation (clears model selection). */
164
205
  selectAnnotation: (annotationId: string | null) => void;
206
+ /** Set the hover preview focus; a focus equal by value is not written. */
207
+ setHoverFocus: (focus: CanvasFocus | null) => void;
208
+ /** Set the flowing focus; a focus equal by value is not written. */
209
+ setFlowFocus: (focus: CanvasFocus | null) => void;
210
+ /** Store the host's canvas context, or clear it (null). */
211
+ setCanvasContext: (context: CanvasContext | null) => void;
212
+ /** Change how FK lines are drawn. */
213
+ setLineStyle: (lineStyle: LineStyle) => void;
214
+ /** Store the router's latest routes (null: every line on the fallback). */
215
+ setEdgeRoutes: (routes: Map<string, RoutedEdge> | null) => void;
165
216
  }
166
217
  export type CanvasStore = CanvasState & CanvasActions;
167
218
  export type CanvasStoreApi = StoreApi<CanvasStore>;
@@ -183,3 +234,9 @@ export declare function CanvasStoreProvider({ store, children }: {
183
234
  export declare function useEditorStoreApi(): CanvasStoreApi;
184
235
  /** Select a value from the nearest canvas store; re-renders when it changes. */
185
236
  export declare function useEditorStore<T>(selector: (s: CanvasStore) => T): T;
237
+ /**
238
+ * Like `useEditorStore`, but returns `fallback` instead of throwing when no
239
+ * `CanvasStoreProvider` is above. For presentation-only reads in components
240
+ * that are also rendered on their own (an `FkEdge` in a unit test).
241
+ */
242
+ export declare function useEditorStoreOr<T>(selector: (s: CanvasStore) => T, fallback: T): T;
@@ -44,10 +44,29 @@ export type TableNodeData = {
44
44
  stage: Stage;
45
45
  /** Data warehouse layer. */
46
46
  layer: Layer;
47
- /** Database schema the model materializes in (shown as badge text). */
47
+ /** Database schema the model materializes in (named in the badge's hover card). */
48
48
  schema?: string;
49
49
  /** Layer configuration for dynamic badge styling (color, abbreviation). */
50
50
  layerConfig?: LayerConfig;
51
+ /**
52
+ * The layer the table itself belongs to (`DisplayTable.layer`), when known.
53
+ * The header's badge always names the layer the table lives in: this one,
54
+ * else the diagram's `layer`. A known layer also draws the colour strip.
55
+ */
56
+ tableLayer?: Layer;
57
+ /** {@link tableLayer}'s config (its colour and abbreviation). */
58
+ tableLayerConfig?: LayerConfig;
59
+ /** Set when {@link tableLayer} is not the diagram's layer: a table this diagram borrows. */
60
+ otherLayer?: true;
61
+ /** The schema as a prefix of the name (`sales.fct_order`): set only when it is not the badge's layer id. */
62
+ shownSchema?: string;
63
+ /**
64
+ * Set when the project has one layer and every table is in it
65
+ * (`isSingleLayerProject`): the layer badge and colour strip are left off.
66
+ */
67
+ singleLayer?: true;
68
+ /** The warehouse name when it differs from the model name (`alias`), shown after it: `gold_orders as orders`. */
69
+ alias?: string;
51
70
  /** Columns to display, enriched with PK/FK flags. */
52
71
  columns: ColumnDisplay[];
53
72
  /** Whether the node is dimmed (doesn't match current search query). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erd-studio/renderer",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "ERD Studio's React Flow canvas: the entity-relationship diagram renderer shared by the VS Code extension, with a read-only viewer mode.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -47,7 +47,7 @@
47
47
  "prepack": "npm run build"
48
48
  },
49
49
  "dependencies": {
50
- "@erd-studio/core": "0.3.0",
50
+ "@erd-studio/core": "0.4.0",
51
51
  "zustand": "^5.0.0"
52
52
  },
53
53
  "peerDependencies": {