@erd-studio/renderer 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.
- package/LICENSE +167 -0
- package/README.md +132 -0
- package/dist/chunk-3PJCC7BX.js +5049 -0
- package/dist/chunk-6XQXDZ4R.js +0 -0
- package/dist/chunk-HOQPSLHQ.js +90 -0
- package/dist/chunk-QZGU5NZH.js +0 -0
- package/dist/chunk-WOTSQZCQ.js +151 -0
- package/dist/editor.js +124 -0
- package/dist/index.js +16 -0
- package/dist/sizing.js +16 -0
- package/dist/store.js +15 -0
- package/dist/styles.css +2963 -0
- package/dist/types/ErdCanvas.d.ts +54 -0
- package/dist/types/canvas/CanvasBackdrop.d.ts +7 -0
- package/dist/types/canvas/flowTypes.d.ts +10 -0
- package/dist/types/canvas/useCanvasGraph.d.ts +37 -0
- package/dist/types/components/DetailPanel/BulkColumnActions.d.ts +15 -0
- package/dist/types/components/DetailPanel/ColumnEditor.d.ts +19 -0
- package/dist/types/components/DetailPanel/DescriptionEditor.d.ts +16 -0
- package/dist/types/components/DetailPanel/DetailPanel.d.ts +10 -0
- package/dist/types/components/DetailPanel/GrainEditor.d.ts +16 -0
- package/dist/types/components/DetailPanel/ModelRationale.d.ts +27 -0
- package/dist/types/components/DetailPanel/RationaleField.d.ts +28 -0
- package/dist/types/components/DetailPanel/RoleEditor.d.ts +13 -0
- package/dist/types/components/Graph/AnnotationEdge.d.ts +11 -0
- package/dist/types/components/Graph/AnnotationNode.d.ts +18 -0
- package/dist/types/components/Graph/ColumnTooltip.d.ts +25 -0
- package/dist/types/components/Graph/FkEdge.d.ts +21 -0
- package/dist/types/components/Graph/HoverTip.d.ts +47 -0
- package/dist/types/components/Graph/ModelNode.d.ts +21 -0
- package/dist/types/components/Legend/Legend.d.ts +11 -0
- package/dist/types/components/common/ColumnRowEditor.d.ts +75 -0
- package/dist/types/components/common/DataTypeSelect.d.ts +20 -0
- package/dist/types/components/common/KeyBadge.d.ts +16 -0
- package/dist/types/components/common/KeyBadgeGroup.d.ts +20 -0
- package/dist/types/editor.d.ts +27 -0
- package/dist/types/hooks/useColumnExpansion.d.ts +36 -0
- package/dist/types/hooks/useColumnReorder.d.ts +36 -0
- package/dist/types/hooks/useFocusWithinRow.d.ts +23 -0
- package/dist/types/hooks/useLongPressDrag.d.ts +31 -0
- package/dist/types/host/canvasEnvironment.d.ts +36 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/lib/annotationColors.d.ts +13 -0
- package/dist/types/lib/badgeLabels.d.ts +63 -0
- package/dist/types/lib/cardinalityUtils.d.ts +14 -0
- package/dist/types/lib/dataTypeColors.d.ts +15 -0
- package/dist/types/lib/dragHandleSides.d.ts +27 -0
- package/dist/types/lib/edgeDistribution.d.ts +165 -0
- package/dist/types/lib/graphTransformer.d.ts +65 -0
- package/dist/types/lib/nodeOverlays.d.ts +41 -0
- package/dist/types/lib/nodeSizing.d.ts +50 -0
- package/dist/types/lib/stageColors.d.ts +16 -0
- package/dist/types/sizing.d.ts +1 -0
- package/dist/types/store/editorStore.d.ts +185 -0
- package/dist/types/store.d.ts +2 -0
- package/dist/types/types/graph.d.ts +145 -0
- package/package.json +72 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zustand store for the canvas: the state the shared canvas components
|
|
3
|
+
* (model and annotation nodes, FK edges, detail panel, legend) read and write.
|
|
4
|
+
*
|
|
5
|
+
* The store is provided through React context rather than imported as a
|
|
6
|
+
* module singleton, so every canvas instance can have its own:
|
|
7
|
+
*
|
|
8
|
+
* - `createCanvasStore()` makes a standalone store holding just this slice.
|
|
9
|
+
* - A host with more state (the VS Code extension) composes its own store
|
|
10
|
+
* from `createCanvasSlice(set)` and passes it to `CanvasStoreProvider`.
|
|
11
|
+
*
|
|
12
|
+
* Components keep the familiar `useEditorStore((s) => …)` selector call; it
|
|
13
|
+
* reads whichever store the nearest `CanvasStoreProvider` supplies.
|
|
14
|
+
*/
|
|
15
|
+
import { type ReactNode } from 'react';
|
|
16
|
+
import { type StoreApi } from 'zustand';
|
|
17
|
+
import type { DisplayDomain, ExistingModelPreview } from '@erd-studio/core';
|
|
18
|
+
import type { ModelFlowNode, FkFlowEdge, FkEdgeData, AnnotationFlowNode, AnnotationFlowEdge } from '../types/graph.js';
|
|
19
|
+
/** Context menu state for edge right-click. */
|
|
20
|
+
export interface EdgeContextMenu {
|
|
21
|
+
type: 'edge';
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
data: FkEdgeData;
|
|
25
|
+
}
|
|
26
|
+
/** Context menu state for node right-click. */
|
|
27
|
+
export interface NodeContextMenu {
|
|
28
|
+
type: 'node';
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
modelName: string;
|
|
32
|
+
}
|
|
33
|
+
/** Context menu state for annotation right-click. */
|
|
34
|
+
export interface AnnotationContextMenu {
|
|
35
|
+
type: 'annotation';
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
annotationId: string;
|
|
39
|
+
}
|
|
40
|
+
/** Union of context menu states. */
|
|
41
|
+
export type ContextMenuState = EdgeContextMenu | NodeContextMenu | AnnotationContextMenu | null;
|
|
42
|
+
/** Active drag line state for creating relationships via column drag. */
|
|
43
|
+
export interface DragLineState {
|
|
44
|
+
sourceModelName: string;
|
|
45
|
+
sourceColumnName: string;
|
|
46
|
+
sourceX: number;
|
|
47
|
+
sourceY: number;
|
|
48
|
+
currentX: number;
|
|
49
|
+
currentY: number;
|
|
50
|
+
}
|
|
51
|
+
/** Active drag line state for linking an annotation to a model via drag. */
|
|
52
|
+
export interface AnnotationLinkDragState {
|
|
53
|
+
annotationId: string;
|
|
54
|
+
sourceX: number;
|
|
55
|
+
sourceY: number;
|
|
56
|
+
currentX: number;
|
|
57
|
+
currentY: number;
|
|
58
|
+
}
|
|
59
|
+
export interface CanvasState {
|
|
60
|
+
/** Current search query for filtering/highlighting nodes. */
|
|
61
|
+
searchQuery: string;
|
|
62
|
+
/** Name of the currently selected model node, or null. */
|
|
63
|
+
selectedNode: string | null;
|
|
64
|
+
/** IDs of currently selected edges. */
|
|
65
|
+
selectedEdges: string[];
|
|
66
|
+
/** Edge ID selected for dimming (highlights endpoints, dims everything else). */
|
|
67
|
+
selectedEdge: string | null;
|
|
68
|
+
/** Whether the detail panel is open. */
|
|
69
|
+
detailPanelOpen: boolean;
|
|
70
|
+
/** Whether a delete confirmation is pending (triggered by Delete key). */
|
|
71
|
+
pendingDeleteConfirmation: boolean;
|
|
72
|
+
/** The loaded domain data from the extension host (already reconciled with manifest). */
|
|
73
|
+
domain: DisplayDomain | null;
|
|
74
|
+
/** React Flow nodes (local state for selection/drag). */
|
|
75
|
+
nodes: (ModelFlowNode | AnnotationFlowNode)[];
|
|
76
|
+
/** React Flow edges. */
|
|
77
|
+
edges: (FkFlowEdge | AnnotationFlowEdge)[];
|
|
78
|
+
/** Annotation currently being edited (auto-focus textarea), or null. */
|
|
79
|
+
editingAnnotationId: string | null;
|
|
80
|
+
/** Models available to add from logical-models/ and manifest. */
|
|
81
|
+
existingModels: ExistingModelPreview[];
|
|
82
|
+
/** Context menu state (position and target), or null if closed. */
|
|
83
|
+
contextMenu: ContextMenuState;
|
|
84
|
+
/** Whether the legend panel is visible. */
|
|
85
|
+
legendOpen: boolean;
|
|
86
|
+
/** Active drag line state for creating relationships via column drag. */
|
|
87
|
+
dragLineState: DragLineState | null;
|
|
88
|
+
/** Active drag line state for linking an annotation to a model via drag. */
|
|
89
|
+
annotationLinkDrag: AnnotationLinkDragState | null;
|
|
90
|
+
/** Set of "modelName:columnName" keys for columns involved in selected edges. */
|
|
91
|
+
highlightedColumns: Set<string>;
|
|
92
|
+
/** Set of model IDs with columns expanded. */
|
|
93
|
+
expandedNodes: Set<string>;
|
|
94
|
+
/** Whether columns are in global "all expanded" mode. */
|
|
95
|
+
allExpanded: boolean;
|
|
96
|
+
/** Selected column names in the DetailPanel (scoped to current model). */
|
|
97
|
+
selectedColumns: string[];
|
|
98
|
+
/** Anchor column for Shift+click range selection. */
|
|
99
|
+
lastSelectedColumn: string | null;
|
|
100
|
+
/** Column currently in edit mode (name field), or null. */
|
|
101
|
+
editingColumn: string | null;
|
|
102
|
+
/** Currently selected annotation ID, or null. */
|
|
103
|
+
selectedAnnotation: string | null;
|
|
104
|
+
}
|
|
105
|
+
export interface CanvasActions {
|
|
106
|
+
setSearchQuery: (query: string) => void;
|
|
107
|
+
selectNode: (nodeName: string | null) => void;
|
|
108
|
+
setSelectedEdges: (edgeIds: string[]) => void;
|
|
109
|
+
setSelectedEdge: (edgeId: string | null) => void;
|
|
110
|
+
setDetailPanelOpen: (open: boolean) => void;
|
|
111
|
+
/** Set pending delete confirmation state (triggered by Delete key). */
|
|
112
|
+
setPendingDeleteConfirmation: (pending: boolean) => void;
|
|
113
|
+
setDomain: (domain: DisplayDomain) => void;
|
|
114
|
+
setNodes: (nodes: (ModelFlowNode | AnnotationFlowNode)[]) => void;
|
|
115
|
+
setEdges: (edges: (FkFlowEdge | AnnotationFlowEdge)[]) => void;
|
|
116
|
+
/** Set the annotation currently being edited (auto-focus). */
|
|
117
|
+
setEditingAnnotationId: (id: string | null) => void;
|
|
118
|
+
setExistingModels: (models: ExistingModelPreview[]) => void;
|
|
119
|
+
/** Open context menu for an edge at the given position. */
|
|
120
|
+
openEdgeContextMenu: (x: number, y: number, data: FkEdgeData) => void;
|
|
121
|
+
/** Open context menu for a node at the given position. */
|
|
122
|
+
openNodeContextMenu: (x: number, y: number, modelName: string) => void;
|
|
123
|
+
/** Open context menu for an annotation at the given position. */
|
|
124
|
+
openAnnotationContextMenu: (x: number, y: number, annotationId: string) => void;
|
|
125
|
+
/** Close the context menu. */
|
|
126
|
+
closeContextMenu: () => void;
|
|
127
|
+
/** Toggle the legend panel visibility. */
|
|
128
|
+
setLegendOpen: (open: boolean) => void;
|
|
129
|
+
/** Start drag line for column relationship creation. */
|
|
130
|
+
startDragLine: (modelName: string, columnName: string, sourceX: number, sourceY: number) => void;
|
|
131
|
+
/** Update drag line endpoint as mouse moves. */
|
|
132
|
+
updateDragLineMouse: (mouseX: number, mouseY: number) => void;
|
|
133
|
+
/** End drag line (on drop or cancel). */
|
|
134
|
+
endDragLine: () => void;
|
|
135
|
+
/** Start drag line for annotation-to-model linking. */
|
|
136
|
+
startAnnotationLinkDrag: (annotationId: string, sourceX: number, sourceY: number) => void;
|
|
137
|
+
/** Update annotation link drag endpoint. */
|
|
138
|
+
updateAnnotationLinkDrag: (mouseX: number, mouseY: number) => void;
|
|
139
|
+
/** End annotation link drag. */
|
|
140
|
+
endAnnotationLinkDrag: () => void;
|
|
141
|
+
/** Set highlighted columns (for edge click). */
|
|
142
|
+
setHighlightedColumns: (columns: Set<string>) => void;
|
|
143
|
+
/** Expand all listed model IDs (sets allExpanded mode). */
|
|
144
|
+
expandAll: (modelIds: string[]) => void;
|
|
145
|
+
/** Expand only new model IDs without resetting existing state. */
|
|
146
|
+
expandNew: (modelIds: string[]) => void;
|
|
147
|
+
/** Collapse all models. */
|
|
148
|
+
collapseAll: () => void;
|
|
149
|
+
/** Toggle expand/collapse for a single model. */
|
|
150
|
+
toggleExpansion: (modelId: string) => void;
|
|
151
|
+
/** Restore expansion state from persisted data. */
|
|
152
|
+
setExpandedNodes: (nodes: string[], allExpanded: boolean) => void;
|
|
153
|
+
/** Select a single column (replaces selection, sets anchor). */
|
|
154
|
+
selectColumn: (name: string) => void;
|
|
155
|
+
/** Toggle a column in/out of the selection (Ctrl+click). */
|
|
156
|
+
toggleColumnSelection: (name: string) => void;
|
|
157
|
+
/** Select a range of columns from anchor to target (Shift+click). */
|
|
158
|
+
selectColumnRange: (name: string, allNames: string[]) => void;
|
|
159
|
+
/** Clear all column selection. */
|
|
160
|
+
clearColumnSelection: () => void;
|
|
161
|
+
/** Set the column currently being edited (F2 / double-click). */
|
|
162
|
+
setEditingColumn: (name: string | null) => void;
|
|
163
|
+
/** Select an annotation (clears model selection). */
|
|
164
|
+
selectAnnotation: (annotationId: string | null) => void;
|
|
165
|
+
}
|
|
166
|
+
export type CanvasStore = CanvasState & CanvasActions;
|
|
167
|
+
export type CanvasStoreApi = StoreApi<CanvasStore>;
|
|
168
|
+
export type CanvasSet = CanvasStoreApi['setState'];
|
|
169
|
+
/**
|
|
170
|
+
* The canvas state defaults and actions. A host that keeps more state spreads
|
|
171
|
+
* this into its own zustand initialiser and adds its fields and actions after
|
|
172
|
+
* it (overriding any action it needs to extend, such as `setDomain`).
|
|
173
|
+
*/
|
|
174
|
+
export declare function createCanvasSlice(set: CanvasSet): CanvasStore;
|
|
175
|
+
/** A standalone store holding just the canvas slice, optionally seeded. */
|
|
176
|
+
export declare function createCanvasStore(initial?: Partial<CanvasState>): CanvasStoreApi;
|
|
177
|
+
/** Supplies the store that canvas components below it read and write. */
|
|
178
|
+
export declare function CanvasStoreProvider({ store, children }: {
|
|
179
|
+
store: CanvasStoreApi;
|
|
180
|
+
children: ReactNode;
|
|
181
|
+
}): JSX.Element;
|
|
182
|
+
/** The store supplied by the nearest `CanvasStoreProvider`, for `getState()` in handlers. */
|
|
183
|
+
export declare function useEditorStoreApi(): CanvasStoreApi;
|
|
184
|
+
/** Select a value from the nearest canvas store; re-renders when it changes. */
|
|
185
|
+
export declare function useEditorStore<T>(selector: (s: CanvasStore) => T): T;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createCanvasSlice, createCanvasStore, CanvasStoreProvider, useEditorStoreApi, useEditorStore, } from './store/editorStore.js';
|
|
2
|
+
export type { EdgeContextMenu, NodeContextMenu, AnnotationContextMenu, ContextMenuState, DragLineState, AnnotationLinkDragState, CanvasState, CanvasActions, CanvasStore, CanvasStoreApi, CanvasSet, } from './store/editorStore.js';
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for React Flow graph nodes and edges.
|
|
3
|
+
*
|
|
4
|
+
* These types define the data payloads for custom React Flow node and edge
|
|
5
|
+
* components. The graph transformer converts DisplayDomain data into
|
|
6
|
+
* these shapes.
|
|
7
|
+
*/
|
|
8
|
+
import type { Node, Edge } from '@xyflow/react';
|
|
9
|
+
import type { AnnotationColor, Cardinality, Layer, ModelRole, Stage } from '@erd-studio/core';
|
|
10
|
+
import type { LayerConfig } from '@erd-studio/core';
|
|
11
|
+
import type { ModelDiscrepancy } from '@erd-studio/core';
|
|
12
|
+
import type { PhysicalProvenance } from '@erd-studio/core';
|
|
13
|
+
/** Column data enriched with PK/FK/NK indicators for display in ModelNode. */
|
|
14
|
+
export interface ColumnDisplay {
|
|
15
|
+
name: string;
|
|
16
|
+
dataType: string;
|
|
17
|
+
/** Column description (optional — shown in tooltip on hover). */
|
|
18
|
+
description?: string;
|
|
19
|
+
isPrimaryKey: boolean;
|
|
20
|
+
/** True if this column is the source of an FK relationship. */
|
|
21
|
+
isForeignKey: boolean;
|
|
22
|
+
/** True if this column is a natural key (business identifier). */
|
|
23
|
+
isNaturalKey: boolean;
|
|
24
|
+
/** SCD type for dimension columns (0 = never changes, 1 = overwrite, 2 = track history). */
|
|
25
|
+
scdType?: 0 | 1 | 2;
|
|
26
|
+
/** Additive type for fact measure columns. */
|
|
27
|
+
additiveType?: 'additive' | 'semi-additive' | 'non-additive';
|
|
28
|
+
}
|
|
29
|
+
/** Data payload for a ModelNode React Flow node. */
|
|
30
|
+
export type ModelNodeData = {
|
|
31
|
+
/** Model name (unique within a domain). */
|
|
32
|
+
modelName: string;
|
|
33
|
+
/** The active design stage. */
|
|
34
|
+
stage: Stage;
|
|
35
|
+
/** Data warehouse layer. */
|
|
36
|
+
layer: Layer;
|
|
37
|
+
/** Database schema the model materializes in (shown as badge text). */
|
|
38
|
+
schema?: string;
|
|
39
|
+
/** Layer configuration for dynamic badge styling (color, abbreviation). */
|
|
40
|
+
layerConfig?: LayerConfig;
|
|
41
|
+
/** Columns to display, enriched with PK/FK flags. */
|
|
42
|
+
columns: ColumnDisplay[];
|
|
43
|
+
/** Whether the node is dimmed (doesn't match current search query). */
|
|
44
|
+
dimmed?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether columns are expanded.
|
|
47
|
+
* When false, only first N columns are shown with node-level handles only.
|
|
48
|
+
* Ephemeral state — not persisted, resets on domain refresh.
|
|
49
|
+
*/
|
|
50
|
+
isExpanded?: boolean;
|
|
51
|
+
/** Callback to toggle expansion state. Receives model name as argument. */
|
|
52
|
+
onToggleExpansion?: (modelName: string) => void;
|
|
53
|
+
/** Whether this model has design rationale metadata. */
|
|
54
|
+
hasRationale?: boolean;
|
|
55
|
+
/** Grain statement — "One row per ___". Shown as subtitle on node. */
|
|
56
|
+
grain?: string;
|
|
57
|
+
/** Model's role in the data warehouse architecture. Shown as badge on node. */
|
|
58
|
+
modelRole?: ModelRole;
|
|
59
|
+
/** Whether this stage is read-only (physical). */
|
|
60
|
+
readOnly?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Render this node as a ghost. Set from two unrelated places: a physical
|
|
63
|
+
* model that does not exist in the dbt project, and a model the active
|
|
64
|
+
* discrepancy report reports 'missing' (which also fires on the logical
|
|
65
|
+
* canvas). `ghostReason` is what tells them apart.
|
|
66
|
+
*/
|
|
67
|
+
isGhost?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Why the node is a ghost — drives the border treatment and the tooltip.
|
|
70
|
+
* 'not-in-project' / 'disabled' come from the physical stage;
|
|
71
|
+
* 'missing-in-comparison' from the discrepancy overlay.
|
|
72
|
+
*/
|
|
73
|
+
ghostReason?: 'not-in-project' | 'disabled' | 'missing-in-comparison';
|
|
74
|
+
/**
|
|
75
|
+
* Where the physical model's columns and types came from. Physical stage
|
|
76
|
+
* only — logical nodes never carry it, which is what keeps the header chip
|
|
77
|
+
* off the logical canvas without a stage check.
|
|
78
|
+
*/
|
|
79
|
+
provenance?: PhysicalProvenance;
|
|
80
|
+
/** Whether this model is in stub display mode (PK/NK columns only). */
|
|
81
|
+
isStub: boolean;
|
|
82
|
+
/** Per-model discrepancy data when a cross-stage comparison report is active. */
|
|
83
|
+
discrepancy?: ModelDiscrepancy;
|
|
84
|
+
/** The stage currently being viewed (set when discrepancy overlay is active). */
|
|
85
|
+
discrepancySourceStage?: Stage;
|
|
86
|
+
/** The stage being compared against (set when discrepancy overlay is active). */
|
|
87
|
+
discrepancyTargetStage?: Stage;
|
|
88
|
+
/**
|
|
89
|
+
* Index signature required by React Flow's Node generic.
|
|
90
|
+
*
|
|
91
|
+
* It also means an unknown or misspelled key type-checks, and a field written
|
|
92
|
+
* here but never destructured in ModelNode ships as dead payload — which is
|
|
93
|
+
* exactly how `hasRationale` and `modelRole` gained matching dead CSS. Add a
|
|
94
|
+
* field here only together with the code that reads it.
|
|
95
|
+
*/
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
};
|
|
98
|
+
/** Typed React Flow node for a semantic model. */
|
|
99
|
+
export type ModelFlowNode = Node<ModelNodeData, 'model'>;
|
|
100
|
+
/** Data payload for an FkEdge React Flow edge. */
|
|
101
|
+
export type FkEdgeData = {
|
|
102
|
+
fromModel: string;
|
|
103
|
+
fromColumn: string;
|
|
104
|
+
toModel: string;
|
|
105
|
+
toColumn: string;
|
|
106
|
+
cardinality: Cardinality;
|
|
107
|
+
/** Stage of the owning domain canvas — drives CSS colour class. */
|
|
108
|
+
stage?: Stage;
|
|
109
|
+
/** Discrepancy status for ghost/extra/mismatch edges. */
|
|
110
|
+
discrepancyStatus?: 'extra' | 'missing' | 'cardinality-mismatch';
|
|
111
|
+
/** Whether the edge is dimmed (not connected to current selection). */
|
|
112
|
+
dimmed?: boolean;
|
|
113
|
+
/** Whether the edge is in a read-only context (physical stage). */
|
|
114
|
+
readOnly?: boolean;
|
|
115
|
+
/** True when source === target — renders a loop arc over the top-right corner. */
|
|
116
|
+
isSelfLoop?: boolean;
|
|
117
|
+
/** Index signature required by React Flow's Edge generic. */
|
|
118
|
+
[key: string]: unknown;
|
|
119
|
+
};
|
|
120
|
+
/** Typed React Flow edge for a semantic FK relationship. */
|
|
121
|
+
export type FkFlowEdge = Edge<FkEdgeData, 'fk'>;
|
|
122
|
+
/** Data payload for an AnnotationNode React Flow node. */
|
|
123
|
+
export type AnnotationNodeData = {
|
|
124
|
+
annotationId: string;
|
|
125
|
+
text: string;
|
|
126
|
+
color: AnnotationColor;
|
|
127
|
+
width?: number;
|
|
128
|
+
height?: number;
|
|
129
|
+
linkedModel?: string;
|
|
130
|
+
/** Whether this annotation is in a read-only context (physical stage). */
|
|
131
|
+
readOnly?: boolean;
|
|
132
|
+
/** Index signature required by React Flow's Node generic. */
|
|
133
|
+
[key: string]: unknown;
|
|
134
|
+
};
|
|
135
|
+
/** Typed React Flow node for a canvas annotation. */
|
|
136
|
+
export type AnnotationFlowNode = Node<AnnotationNodeData, 'annotation'>;
|
|
137
|
+
/** Data payload for the dashed edge linking an annotation to a model. */
|
|
138
|
+
export type AnnotationEdgeData = {
|
|
139
|
+
annotationId: string;
|
|
140
|
+
targetModel: string;
|
|
141
|
+
/** Index signature required by React Flow's Edge generic. */
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
};
|
|
144
|
+
/** Typed React Flow edge for an annotation-to-model link. */
|
|
145
|
+
export type AnnotationFlowEdge = Edge<AnnotationEdgeData, 'annotationLink'>;
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@erd-studio/renderer",
|
|
3
|
+
"version": "0.1.0",
|
|
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
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/liam-machine/erd-studio",
|
|
9
|
+
"directory": "packages/renderer"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"*.css"
|
|
14
|
+
],
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/types/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./editor": {
|
|
23
|
+
"types": "./dist/types/editor.d.ts",
|
|
24
|
+
"default": "./dist/editor.js"
|
|
25
|
+
},
|
|
26
|
+
"./store": {
|
|
27
|
+
"types": "./dist/types/store.d.ts",
|
|
28
|
+
"default": "./dist/store.js"
|
|
29
|
+
},
|
|
30
|
+
"./sizing": {
|
|
31
|
+
"types": "./dist/types/sizing.d.ts",
|
|
32
|
+
"default": "./dist/sizing.js"
|
|
33
|
+
},
|
|
34
|
+
"./styles.css": "./dist/styles.css",
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "node build.mjs && tsc -p tsconfig.build.json && node scripts/dts-extensions.mjs",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"prepack": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@erd-studio/core": "0.1.0",
|
|
50
|
+
"zustand": "^5.0.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@xyflow/react": "^12.4.0",
|
|
54
|
+
"react": "^18.3.0",
|
|
55
|
+
"react-dom": "^18.3.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@testing-library/react": "^16.1.0",
|
|
59
|
+
"@types/react": "^18.3.0",
|
|
60
|
+
"@types/react-dom": "^18.3.0",
|
|
61
|
+
"@xyflow/react": "^12.4.0",
|
|
62
|
+
"esbuild": "^0.24.0",
|
|
63
|
+
"jsdom": "^25.0.0",
|
|
64
|
+
"react": "^18.3.0",
|
|
65
|
+
"react-dom": "^18.3.0",
|
|
66
|
+
"typescript": "^5.6.0",
|
|
67
|
+
"vitest": "^2.1.0"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
}
|
|
72
|
+
}
|