@coral-viz/viz 0.2.3
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 +4 -0
- package/README.md +11 -0
- package/dist/compatibility/CompatibilityEdge.d.ts +106 -0
- package/dist/compatibility/CompatibilityEdge.d.ts.map +1 -0
- package/dist/compatibility/CompatibilityEdge.js +233 -0
- package/dist/compatibility/CompatibilityEdge.js.map +1 -0
- package/dist/compatibility/IncompatibilityTooltip.d.ts +44 -0
- package/dist/compatibility/IncompatibilityTooltip.d.ts.map +1 -0
- package/dist/compatibility/IncompatibilityTooltip.js +145 -0
- package/dist/compatibility/IncompatibilityTooltip.js.map +1 -0
- package/dist/compatibility/index.d.ts +10 -0
- package/dist/compatibility/index.d.ts.map +1 -0
- package/dist/compatibility/index.js +10 -0
- package/dist/compatibility/index.js.map +1 -0
- package/dist/compatibility/useEdgeCompatibility.d.ts +82 -0
- package/dist/compatibility/useEdgeCompatibility.d.ts.map +1 -0
- package/dist/compatibility/useEdgeCompatibility.js +170 -0
- package/dist/compatibility/useEdgeCompatibility.js.map +1 -0
- package/dist/compatibility/validateConnection.d.ts +56 -0
- package/dist/compatibility/validateConnection.d.ts.map +1 -0
- package/dist/compatibility/validateConnection.js +382 -0
- package/dist/compatibility/validateConnection.js.map +1 -0
- package/dist/components/EditContext.d.ts +45 -0
- package/dist/components/EditContext.d.ts.map +1 -0
- package/dist/components/EditContext.js +41 -0
- package/dist/components/EditContext.js.map +1 -0
- package/dist/components/ShapeRenderer.d.ts +35 -0
- package/dist/components/ShapeRenderer.d.ts.map +1 -0
- package/dist/components/ShapeRenderer.js +77 -0
- package/dist/components/ShapeRenderer.js.map +1 -0
- package/dist/components/SymbolNode.d.ts +53 -0
- package/dist/components/SymbolNode.d.ts.map +1 -0
- package/dist/components/SymbolNode.js +333 -0
- package/dist/components/SymbolNode.js.map +1 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +10 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/nodes.d.ts +43 -0
- package/dist/components/nodes.d.ts.map +1 -0
- package/dist/components/nodes.js +111 -0
- package/dist/components/nodes.js.map +1 -0
- package/dist/editor/CoralEditor.d.ts +29 -0
- package/dist/editor/CoralEditor.d.ts.map +1 -0
- package/dist/editor/CoralEditor.js +112 -0
- package/dist/editor/CoralEditor.js.map +1 -0
- package/dist/editor/FileControls.d.ts +34 -0
- package/dist/editor/FileControls.d.ts.map +1 -0
- package/dist/editor/FileControls.js +139 -0
- package/dist/editor/FileControls.js.map +1 -0
- package/dist/editor/LayoutControls.d.ts +41 -0
- package/dist/editor/LayoutControls.d.ts.map +1 -0
- package/dist/editor/LayoutControls.js +124 -0
- package/dist/editor/LayoutControls.js.map +1 -0
- package/dist/editor/converter.d.ts +37 -0
- package/dist/editor/converter.d.ts.map +1 -0
- package/dist/editor/converter.js +256 -0
- package/dist/editor/converter.js.map +1 -0
- package/dist/editor/index.d.ts +8 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +8 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/file/deserialize.d.ts +15 -0
- package/dist/file/deserialize.d.ts.map +1 -0
- package/dist/file/deserialize.js +145 -0
- package/dist/file/deserialize.js.map +1 -0
- package/dist/file/index.d.ts +15 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/file/index.js +20 -0
- package/dist/file/index.js.map +1 -0
- package/dist/file/migrate.d.ts +29 -0
- package/dist/file/migrate.d.ts.map +1 -0
- package/dist/file/migrate.js +103 -0
- package/dist/file/migrate.js.map +1 -0
- package/dist/file/schema.d.ts +385 -0
- package/dist/file/schema.d.ts.map +1 -0
- package/dist/file/schema.js +180 -0
- package/dist/file/schema.js.map +1 -0
- package/dist/file/serialize.d.ts +30 -0
- package/dist/file/serialize.d.ts.map +1 -0
- package/dist/file/serialize.js +218 -0
- package/dist/file/serialize.js.map +1 -0
- package/dist/file/validate.d.ts +21 -0
- package/dist/file/validate.d.ts.map +1 -0
- package/dist/file/validate.js +165 -0
- package/dist/file/validate.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/elk.d.ts +77 -0
- package/dist/layout/elk.d.ts.map +1 -0
- package/dist/layout/elk.js +379 -0
- package/dist/layout/elk.js.map +1 -0
- package/dist/layout/index.d.ts +12 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +12 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/nodeSizing.d.ts +65 -0
- package/dist/layout/nodeSizing.d.ts.map +1 -0
- package/dist/layout/nodeSizing.js +319 -0
- package/dist/layout/nodeSizing.js.map +1 -0
- package/dist/layout/positionStability.d.ts +73 -0
- package/dist/layout/positionStability.d.ts.map +1 -0
- package/dist/layout/positionStability.js +199 -0
- package/dist/layout/positionStability.js.map +1 -0
- package/dist/layout/useAxisConstrain.d.ts +20 -0
- package/dist/layout/useAxisConstrain.d.ts.map +1 -0
- package/dist/layout/useAxisConstrain.js +106 -0
- package/dist/layout/useAxisConstrain.js.map +1 -0
- package/dist/layout/useDiagramState.d.ts +92 -0
- package/dist/layout/useDiagramState.d.ts.map +1 -0
- package/dist/layout/useDiagramState.js +256 -0
- package/dist/layout/useDiagramState.js.map +1 -0
- package/dist/layout/useLayoutHistory.d.ts +53 -0
- package/dist/layout/useLayoutHistory.d.ts.map +1 -0
- package/dist/layout/useLayoutHistory.js +124 -0
- package/dist/layout/useLayoutHistory.js.map +1 -0
- package/dist/properties/NodePropertiesPanel.d.ts +47 -0
- package/dist/properties/NodePropertiesPanel.d.ts.map +1 -0
- package/dist/properties/NodePropertiesPanel.js +199 -0
- package/dist/properties/NodePropertiesPanel.js.map +1 -0
- package/dist/properties/index.d.ts +10 -0
- package/dist/properties/index.d.ts.map +1 -0
- package/dist/properties/index.js +10 -0
- package/dist/properties/index.js.map +1 -0
- package/dist/properties/propertyUtils.d.ts +60 -0
- package/dist/properties/propertyUtils.d.ts.map +1 -0
- package/dist/properties/propertyUtils.js +89 -0
- package/dist/properties/propertyUtils.js.map +1 -0
- package/dist/settings/FontSettingsForm.d.ts +28 -0
- package/dist/settings/FontSettingsForm.d.ts.map +1 -0
- package/dist/settings/FontSettingsForm.js +129 -0
- package/dist/settings/FontSettingsForm.js.map +1 -0
- package/dist/settings/LayoutSettingsForm.d.ts +37 -0
- package/dist/settings/LayoutSettingsForm.d.ts.map +1 -0
- package/dist/settings/LayoutSettingsForm.js +165 -0
- package/dist/settings/LayoutSettingsForm.js.map +1 -0
- package/dist/settings/SettingsPanel.d.ts +55 -0
- package/dist/settings/SettingsPanel.d.ts.map +1 -0
- package/dist/settings/SettingsPanel.js +84 -0
- package/dist/settings/SettingsPanel.js.map +1 -0
- package/dist/settings/index.d.ts +13 -0
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +13 -0
- package/dist/settings/index.js.map +1 -0
- package/dist/settings/useSettings.d.ts +51 -0
- package/dist/settings/useSettings.d.ts.map +1 -0
- package/dist/settings/useSettings.js +154 -0
- package/dist/settings/useSettings.js.map +1 -0
- package/dist/text-editor/SplitEditor.d.ts +72 -0
- package/dist/text-editor/SplitEditor.d.ts.map +1 -0
- package/dist/text-editor/SplitEditor.js +172 -0
- package/dist/text-editor/SplitEditor.js.map +1 -0
- package/dist/text-editor/TextEditor.d.ts +53 -0
- package/dist/text-editor/TextEditor.d.ts.map +1 -0
- package/dist/text-editor/TextEditor.js +181 -0
- package/dist/text-editor/TextEditor.js.map +1 -0
- package/dist/text-editor/hooks/useBidirectionalSync.d.ts +106 -0
- package/dist/text-editor/hooks/useBidirectionalSync.d.ts.map +1 -0
- package/dist/text-editor/hooks/useBidirectionalSync.js +151 -0
- package/dist/text-editor/hooks/useBidirectionalSync.js.map +1 -0
- package/dist/text-editor/index.d.ts +9 -0
- package/dist/text-editor/index.d.ts.map +1 -0
- package/dist/text-editor/index.js +11 -0
- package/dist/text-editor/index.js.map +1 -0
- package/dist/types.d.ts +242 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/waypoints/index.d.ts +8 -0
- package/dist/waypoints/index.d.ts.map +1 -0
- package/dist/waypoints/index.js +7 -0
- package/dist/waypoints/index.js.map +1 -0
- package/dist/waypoints/operations.d.ts +29 -0
- package/dist/waypoints/operations.d.ts.map +1 -0
- package/dist/waypoints/operations.js +85 -0
- package/dist/waypoints/operations.js.map +1 -0
- package/dist/waypoints/router.d.ts +23 -0
- package/dist/waypoints/router.d.ts.map +1 -0
- package/dist/waypoints/router.js +109 -0
- package/dist/waypoints/router.js.map +1 -0
- package/dist/waypoints/types.d.ts +15 -0
- package/dist/waypoints/types.d.ts.map +1 -0
- package/dist/waypoints/types.js +5 -0
- package/dist/waypoints/types.js.map +1 -0
- package/dist/waypoints/useWaypointManager.d.ts +38 -0
- package/dist/waypoints/useWaypointManager.d.ts.map +1 -0
- package/dist/waypoints/useWaypointManager.js +106 -0
- package/dist/waypoints/useWaypointManager.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection Validation Utilities (CORAL-REQ-010)
|
|
3
|
+
*
|
|
4
|
+
* Validates connections against notation rules and provides
|
|
5
|
+
* compatibility information for visual feedback.
|
|
6
|
+
*/
|
|
7
|
+
import { getNotation } from '@coral-viz/render';
|
|
8
|
+
import { symbolRegistry } from '@coral-viz/render';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Port Direction Validation
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Check if port directions are compatible
|
|
14
|
+
*
|
|
15
|
+
* @param sourceDirection - Direction of source port (in/out/inout)
|
|
16
|
+
* @param targetDirection - Direction of target port (in/out/inout)
|
|
17
|
+
*/
|
|
18
|
+
export function checkPortDirection(sourceDirection, targetDirection) {
|
|
19
|
+
// Source must be 'out' or 'inout'
|
|
20
|
+
if (sourceDirection === 'in') {
|
|
21
|
+
return {
|
|
22
|
+
valid: false,
|
|
23
|
+
hasWarning: false,
|
|
24
|
+
reason: 'port-direction-mismatch',
|
|
25
|
+
message: "Input port cannot be used as source; only 'out' or 'inout' ports can originate connections",
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Target must be 'in' or 'inout'
|
|
29
|
+
if (targetDirection === 'out') {
|
|
30
|
+
return {
|
|
31
|
+
valid: false,
|
|
32
|
+
hasWarning: false,
|
|
33
|
+
reason: 'port-direction-mismatch',
|
|
34
|
+
message: "Output port cannot be used as target; only 'in' or 'inout' ports can receive connections",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return { valid: true, hasWarning: false };
|
|
38
|
+
}
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Max Connections Validation
|
|
41
|
+
// ============================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Check if adding a connection would exceed max connections
|
|
44
|
+
*
|
|
45
|
+
* @param nodeId - Node ID to check
|
|
46
|
+
* @param portId - Port ID (optional)
|
|
47
|
+
* @param maxConnections - Maximum allowed connections (undefined = unlimited)
|
|
48
|
+
* @param existingEdges - Current edges in the diagram
|
|
49
|
+
* @param checkAs - Check as 'source' (outgoing) or 'target' (incoming)
|
|
50
|
+
*/
|
|
51
|
+
export function checkMaxConnections(nodeId, portId, maxConnections, existingEdges, checkAs) {
|
|
52
|
+
if (maxConnections === undefined) {
|
|
53
|
+
return { valid: true, hasWarning: false };
|
|
54
|
+
}
|
|
55
|
+
// Count existing connections
|
|
56
|
+
let count;
|
|
57
|
+
if (checkAs === 'source') {
|
|
58
|
+
count = existingEdges.filter((e) => {
|
|
59
|
+
if (e.source !== nodeId)
|
|
60
|
+
return false;
|
|
61
|
+
if (portId && e.sourcePort && e.sourcePort !== portId)
|
|
62
|
+
return false;
|
|
63
|
+
return true;
|
|
64
|
+
}).length;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
count = existingEdges.filter((e) => {
|
|
68
|
+
if (e.target !== nodeId)
|
|
69
|
+
return false;
|
|
70
|
+
if (portId && e.targetPort && e.targetPort !== portId)
|
|
71
|
+
return false;
|
|
72
|
+
return true;
|
|
73
|
+
}).length;
|
|
74
|
+
}
|
|
75
|
+
if (count >= maxConnections) {
|
|
76
|
+
const direction = checkAs === 'source' ? 'outgoing' : 'incoming';
|
|
77
|
+
return {
|
|
78
|
+
valid: true,
|
|
79
|
+
hasWarning: true,
|
|
80
|
+
reason: 'max-connections-exceeded',
|
|
81
|
+
message: `Node has reached maximum ${direction} connections (${maxConnections})`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return { valid: true, hasWarning: false };
|
|
85
|
+
}
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Symbol Connection Rules
|
|
88
|
+
// ============================================================================
|
|
89
|
+
/**
|
|
90
|
+
* Find ALL matching connection rules for source symbol/variant
|
|
91
|
+
*/
|
|
92
|
+
function findConnectionRules(notation, sourceSymbolId, sourceVariant) {
|
|
93
|
+
const rules = [];
|
|
94
|
+
// First try to find rules with matching variant
|
|
95
|
+
if (sourceVariant) {
|
|
96
|
+
const variantRules = notation.connectionRules.filter((rule) => rule.from === sourceSymbolId && rule.fromVariant === sourceVariant);
|
|
97
|
+
if (variantRules.length > 0) {
|
|
98
|
+
return variantRules; // Variant-specific rules take precedence
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Fall back to rules without variant
|
|
102
|
+
return notation.connectionRules.filter((rule) => rule.from === sourceSymbolId && !rule.fromVariant);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Find a single matching connection rule (for backward compatibility)
|
|
106
|
+
*/
|
|
107
|
+
function findConnectionRule(notation, sourceSymbolId, sourceVariant) {
|
|
108
|
+
const rules = findConnectionRules(notation, sourceSymbolId, sourceVariant);
|
|
109
|
+
return rules[0];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Check if source symbol can connect to target symbol
|
|
113
|
+
*/
|
|
114
|
+
function checkSymbolConnection(notation, sourceInfo, targetInfo, existingEdges) {
|
|
115
|
+
const rules = findConnectionRules(notation, sourceInfo.symbolId, sourceInfo.variant);
|
|
116
|
+
// No rules found for source - warn but allow
|
|
117
|
+
if (rules.length === 0) {
|
|
118
|
+
return {
|
|
119
|
+
valid: true,
|
|
120
|
+
hasWarning: true,
|
|
121
|
+
message: `No connection rules defined for ${sourceInfo.symbolId}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// Check if ANY rule allows this target
|
|
125
|
+
// Also collect all allowed targets for error message
|
|
126
|
+
const allAllowedTargets = new Set();
|
|
127
|
+
let matchingRule;
|
|
128
|
+
for (const rule of rules) {
|
|
129
|
+
rule.to.forEach((t) => allAllowedTargets.add(t));
|
|
130
|
+
if (rule.to.includes(targetInfo.symbolId)) {
|
|
131
|
+
matchingRule = rule;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Check if all rules have empty 'to' arrays (no outgoing allowed)
|
|
136
|
+
if (allAllowedTargets.size === 0) {
|
|
137
|
+
return {
|
|
138
|
+
valid: false,
|
|
139
|
+
hasWarning: false,
|
|
140
|
+
reason: 'symbol-not-allowed',
|
|
141
|
+
message: `${sourceInfo.symbolId}${sourceInfo.variant ? ` (${sourceInfo.variant})` : ''} cannot have outgoing connections`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// Target not allowed by any rule
|
|
145
|
+
if (!matchingRule) {
|
|
146
|
+
return {
|
|
147
|
+
valid: false,
|
|
148
|
+
hasWarning: false,
|
|
149
|
+
reason: 'symbol-not-allowed',
|
|
150
|
+
message: `${sourceInfo.symbolId} cannot connect to ${targetInfo.symbolId}`,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// Check constraints on the matching rule
|
|
154
|
+
if (matchingRule.constraints) {
|
|
155
|
+
// Check maxOutgoing
|
|
156
|
+
if (matchingRule.constraints.maxOutgoing !== undefined) {
|
|
157
|
+
const outgoingCount = existingEdges.filter((e) => e.source === sourceInfo.id).length;
|
|
158
|
+
if (outgoingCount >= matchingRule.constraints.maxOutgoing) {
|
|
159
|
+
return {
|
|
160
|
+
valid: true,
|
|
161
|
+
hasWarning: true,
|
|
162
|
+
reason: 'max-connections-exceeded',
|
|
163
|
+
message: `${sourceInfo.symbolId} has reached maximum outgoing connections (${matchingRule.constraints.maxOutgoing})`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Check if target symbol has maxIncoming constraint
|
|
169
|
+
const targetRule = findConnectionRule(notation, targetInfo.symbolId, targetInfo.variant);
|
|
170
|
+
if (targetRule?.constraints?.maxIncoming !== undefined) {
|
|
171
|
+
const maxIncoming = targetRule.constraints.maxIncoming;
|
|
172
|
+
const incomingCount = existingEdges.filter((e) => e.target === targetInfo.id).length;
|
|
173
|
+
// maxIncoming: 0 means "never allowed" - use symbol-not-allowed
|
|
174
|
+
if (maxIncoming === 0) {
|
|
175
|
+
return {
|
|
176
|
+
valid: false,
|
|
177
|
+
hasWarning: false,
|
|
178
|
+
reason: 'symbol-not-allowed',
|
|
179
|
+
message: `${targetInfo.symbolId}${targetInfo.variant ? ` (${targetInfo.variant})` : ''} cannot receive incoming connections`,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (incomingCount >= maxIncoming) {
|
|
183
|
+
return {
|
|
184
|
+
valid: true,
|
|
185
|
+
hasWarning: true,
|
|
186
|
+
reason: 'max-connections-exceeded',
|
|
187
|
+
message: `${targetInfo.symbolId} has reached maximum incoming connections (${maxIncoming})`,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return { valid: true, hasWarning: false };
|
|
192
|
+
}
|
|
193
|
+
// ============================================================================
|
|
194
|
+
// Port-Level Validation
|
|
195
|
+
// ============================================================================
|
|
196
|
+
/**
|
|
197
|
+
* Get ports for a symbol
|
|
198
|
+
*/
|
|
199
|
+
function getSymbolPorts(symbolId, variant) {
|
|
200
|
+
const symbol = symbolRegistry.get(symbolId);
|
|
201
|
+
if (!symbol) {
|
|
202
|
+
return [
|
|
203
|
+
{ id: 'in', anchor: 'NORTH', direction: 'in' },
|
|
204
|
+
{ id: 'out', anchor: 'SOUTH', direction: 'out' },
|
|
205
|
+
];
|
|
206
|
+
}
|
|
207
|
+
// Check for variant-specific ports
|
|
208
|
+
if (variant && symbol.variants?.[variant]?.ports) {
|
|
209
|
+
return symbol.variants[variant].ports;
|
|
210
|
+
}
|
|
211
|
+
// Fall back to symbol ports
|
|
212
|
+
if (symbol.ports && symbol.ports.length > 0) {
|
|
213
|
+
return symbol.ports;
|
|
214
|
+
}
|
|
215
|
+
// Default ports
|
|
216
|
+
return [
|
|
217
|
+
{ id: 'in', anchor: 'NORTH', direction: 'in' },
|
|
218
|
+
{ id: 'out', anchor: 'SOUTH', direction: 'out' },
|
|
219
|
+
];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Validate port-level compatibility
|
|
223
|
+
*/
|
|
224
|
+
function validatePorts(sourceInfo, targetInfo, sourcePortId, targetPortId, existingEdges = []) {
|
|
225
|
+
const sourcePorts = getSymbolPorts(sourceInfo.symbolId, sourceInfo.variant);
|
|
226
|
+
const targetPorts = getSymbolPorts(targetInfo.symbolId, targetInfo.variant);
|
|
227
|
+
// Find the specific ports if IDs provided
|
|
228
|
+
const sourcePort = sourcePortId
|
|
229
|
+
? sourcePorts.find((p) => p.id === sourcePortId)
|
|
230
|
+
: sourcePorts.find((p) => p.direction === 'out' || p.direction === 'inout');
|
|
231
|
+
const targetPort = targetPortId
|
|
232
|
+
? targetPorts.find((p) => p.id === targetPortId)
|
|
233
|
+
: targetPorts.find((p) => p.direction === 'in' || p.direction === 'inout');
|
|
234
|
+
// Check port directions if we have both ports
|
|
235
|
+
if (sourcePort && targetPort) {
|
|
236
|
+
const directionCheck = checkPortDirection(sourcePort.direction, targetPort.direction);
|
|
237
|
+
if (!directionCheck.valid) {
|
|
238
|
+
return directionCheck;
|
|
239
|
+
}
|
|
240
|
+
let warning;
|
|
241
|
+
// Check max connections on source port
|
|
242
|
+
if (sourcePort.maxConnections !== undefined) {
|
|
243
|
+
const maxCheck = checkMaxConnections(sourceInfo.id, sourcePort.id, sourcePort.maxConnections, existingEdges, 'source');
|
|
244
|
+
if (!maxCheck.valid) {
|
|
245
|
+
return maxCheck;
|
|
246
|
+
}
|
|
247
|
+
if (maxCheck.hasWarning)
|
|
248
|
+
warning = maxCheck;
|
|
249
|
+
}
|
|
250
|
+
// Check max connections on target port
|
|
251
|
+
if (targetPort.maxConnections !== undefined) {
|
|
252
|
+
const maxCheck = checkMaxConnections(targetInfo.id, targetPort.id, targetPort.maxConnections, existingEdges, 'target');
|
|
253
|
+
if (!maxCheck.valid) {
|
|
254
|
+
return maxCheck;
|
|
255
|
+
}
|
|
256
|
+
if (maxCheck.hasWarning && !warning)
|
|
257
|
+
warning = maxCheck;
|
|
258
|
+
}
|
|
259
|
+
if (warning)
|
|
260
|
+
return warning;
|
|
261
|
+
}
|
|
262
|
+
return { valid: true, hasWarning: false };
|
|
263
|
+
}
|
|
264
|
+
// ============================================================================
|
|
265
|
+
// Main Validation Function
|
|
266
|
+
// ============================================================================
|
|
267
|
+
/**
|
|
268
|
+
* Validate a connection against notation rules
|
|
269
|
+
*
|
|
270
|
+
* @param connection - The connection to validate
|
|
271
|
+
* @param context - Validation context with notation and node info
|
|
272
|
+
* @returns Validation result with compatibility status and message
|
|
273
|
+
*/
|
|
274
|
+
export function validateConnection(connection, context) {
|
|
275
|
+
const { sourceNodeId, targetNodeId, sourcePortId, targetPortId } = connection;
|
|
276
|
+
const { notationId, nodeInfo, existingEdges } = context;
|
|
277
|
+
// Check for self-connection
|
|
278
|
+
if (sourceNodeId === targetNodeId) {
|
|
279
|
+
return {
|
|
280
|
+
valid: false,
|
|
281
|
+
hasWarning: false,
|
|
282
|
+
reason: 'self-connection',
|
|
283
|
+
message: 'A node cannot connect to itself',
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
// Get node info
|
|
287
|
+
const sourceInfo = nodeInfo.get(sourceNodeId);
|
|
288
|
+
const targetInfo = nodeInfo.get(targetNodeId);
|
|
289
|
+
// Handle unknown nodes (warn but allow)
|
|
290
|
+
if (!sourceInfo) {
|
|
291
|
+
return {
|
|
292
|
+
valid: true,
|
|
293
|
+
hasWarning: true,
|
|
294
|
+
message: `Unknown source node: ${sourceNodeId}`,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (!targetInfo) {
|
|
298
|
+
return {
|
|
299
|
+
valid: true,
|
|
300
|
+
hasWarning: true,
|
|
301
|
+
message: `Unknown target node: ${targetNodeId}`,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
// Get notation
|
|
305
|
+
const notation = getNotation(notationId);
|
|
306
|
+
if (!notation) {
|
|
307
|
+
return {
|
|
308
|
+
valid: true,
|
|
309
|
+
hasWarning: true,
|
|
310
|
+
message: `Unknown notation: ${notationId}. Connection allowed but not validated.`,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
// Check symbol-level rules
|
|
314
|
+
const symbolCheck = checkSymbolConnection(notation, sourceInfo, targetInfo, existingEdges);
|
|
315
|
+
if (!symbolCheck.valid) {
|
|
316
|
+
return symbolCheck;
|
|
317
|
+
}
|
|
318
|
+
// Check port-level rules
|
|
319
|
+
const portCheck = validatePorts(sourceInfo, targetInfo, sourcePortId, targetPortId, existingEdges);
|
|
320
|
+
if (!portCheck.valid) {
|
|
321
|
+
return portCheck;
|
|
322
|
+
}
|
|
323
|
+
// Merge any warnings (preserve reason from the first warning)
|
|
324
|
+
if (symbolCheck.hasWarning || portCheck.hasWarning) {
|
|
325
|
+
const primary = symbolCheck.hasWarning ? symbolCheck : portCheck;
|
|
326
|
+
return {
|
|
327
|
+
valid: true,
|
|
328
|
+
hasWarning: true,
|
|
329
|
+
reason: primary.reason,
|
|
330
|
+
message: primary.message,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
return { valid: true, hasWarning: false };
|
|
334
|
+
}
|
|
335
|
+
// ============================================================================
|
|
336
|
+
// Batch Validation for Edges
|
|
337
|
+
// ============================================================================
|
|
338
|
+
/**
|
|
339
|
+
* Get compatibility status for multiple edges
|
|
340
|
+
*
|
|
341
|
+
* When validating existing edges, we exclude the edge being validated from
|
|
342
|
+
* the existingEdges count. This prevents false positives where an edge at
|
|
343
|
+
* the maxConnections limit would fail validation because it counts itself.
|
|
344
|
+
*
|
|
345
|
+
* @param edges - Edges to check
|
|
346
|
+
* @param context - Validation context
|
|
347
|
+
* @returns Array of edge compatibility info
|
|
348
|
+
*/
|
|
349
|
+
export function getEdgeCompatibility(edges, context) {
|
|
350
|
+
return edges.map((edge) => {
|
|
351
|
+
// Create a modified context that excludes the current edge
|
|
352
|
+
// This is needed because when validating an EXISTING edge,
|
|
353
|
+
// we shouldn't count it in the max connections check
|
|
354
|
+
const otherEdges = context.existingEdges.filter((e) => !(e.source === edge.source && e.target === edge.target));
|
|
355
|
+
const edgeContext = {
|
|
356
|
+
...context,
|
|
357
|
+
existingEdges: otherEdges,
|
|
358
|
+
};
|
|
359
|
+
const validation = validateConnection({
|
|
360
|
+
sourceNodeId: edge.source,
|
|
361
|
+
targetNodeId: edge.target,
|
|
362
|
+
sourcePortId: edge.sourcePort,
|
|
363
|
+
targetPortId: edge.targetPort,
|
|
364
|
+
}, edgeContext);
|
|
365
|
+
let status;
|
|
366
|
+
if (!validation.valid) {
|
|
367
|
+
status = 'incompatible';
|
|
368
|
+
}
|
|
369
|
+
else if (validation.hasWarning) {
|
|
370
|
+
status = 'warning';
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
status = 'compatible';
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
edgeId: edge.id,
|
|
377
|
+
status,
|
|
378
|
+
validation,
|
|
379
|
+
};
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
//# sourceMappingURL=validateConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateConnection.js","sourceRoot":"","sources":["../../src/compatibility/validateConnection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,eAAuC,EACvC,eAAuC;IAEvC,kCAAkC;IAClC,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,UAAU,EAAE,KAAK;YACjB,MAAM,EAAE,yBAAyB;YACjC,OAAO,EAAE,4FAA4F;SACtG,CAAC;IACJ,CAAC;IAED,iCAAiC;IACjC,IAAI,eAAe,KAAK,KAAK,EAAE,CAAC;QAC9B,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,UAAU,EAAE,KAAK;YACjB,MAAM,EAAE,yBAAyB;YACjC,OAAO,EAAE,0FAA0F;SACpG,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAC5C,CAAC;AAED,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAc,EACd,MAA0B,EAC1B,cAAkC,EAClC,aAAkG,EAClG,OAA4B;IAE5B,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;IAED,6BAA6B;IAC7B,IAAI,KAAa,CAAC;IAClB,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,K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|
5
|
+
* This is necessary because React Flow doesn't pass custom callbacks directly to nodes.
|
|
6
|
+
*/
|
|
7
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* Callback type for label edits
|
|
10
|
+
*/
|
|
11
|
+
export type OnLabelEditCallback = (nodeId: string, newLabel: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Edit context value
|
|
14
|
+
*/
|
|
15
|
+
interface EditContextValue {
|
|
16
|
+
/** Callback when a node label is edited */
|
|
17
|
+
onLabelEdit?: OnLabelEditCallback;
|
|
18
|
+
/** ID of the node currently being edited (only one at a time) */
|
|
19
|
+
editingNodeId: string | null;
|
|
20
|
+
/** Start editing a node */
|
|
21
|
+
startEditing: (nodeId: string) => void;
|
|
22
|
+
/** Stop editing */
|
|
23
|
+
stopEditing: () => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Props for EditProvider
|
|
27
|
+
*/
|
|
28
|
+
export interface EditProviderProps {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
onLabelEdit?: OnLabelEditCallback;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Provider component for edit context
|
|
34
|
+
*/
|
|
35
|
+
export declare function EditProvider({ children, onLabelEdit }: EditProviderProps): React.ReactElement;
|
|
36
|
+
/**
|
|
37
|
+
* Hook to access edit context
|
|
38
|
+
*/
|
|
39
|
+
export declare function useEditContext(): EditContextValue;
|
|
40
|
+
/**
|
|
41
|
+
* Hook to check if a specific node is being edited
|
|
42
|
+
*/
|
|
43
|
+
export declare function useIsEditing(nodeId: string): boolean;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=EditContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditContext.d.ts","sourceRoot":"","sources":["../../src/components/EditContext.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;AAE7E;;GAEG;AACH,UAAU,gBAAgB;IACxB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,iEAAiE;IACjE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,2BAA2B;IAC3B,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,mBAAmB;IACnB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AASD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAgB7F;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAEjD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGpD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Edit Context
|
|
4
|
+
*
|
|
5
|
+
* Provides label editing callbacks to React Flow nodes.
|
|
6
|
+
* This is necessary because React Flow doesn't pass custom callbacks directly to nodes.
|
|
7
|
+
*/
|
|
8
|
+
import { createContext, useContext, useCallback, useState } from 'react';
|
|
9
|
+
const EditContext = createContext({
|
|
10
|
+
onLabelEdit: undefined,
|
|
11
|
+
editingNodeId: null,
|
|
12
|
+
startEditing: () => { },
|
|
13
|
+
stopEditing: () => { },
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Provider component for edit context
|
|
17
|
+
*/
|
|
18
|
+
export function EditProvider({ children, onLabelEdit }) {
|
|
19
|
+
const [editingNodeId, setEditingNodeId] = useState(null);
|
|
20
|
+
const startEditing = useCallback((nodeId) => {
|
|
21
|
+
setEditingNodeId(nodeId);
|
|
22
|
+
}, []);
|
|
23
|
+
const stopEditing = useCallback(() => {
|
|
24
|
+
setEditingNodeId(null);
|
|
25
|
+
}, []);
|
|
26
|
+
return (_jsx(EditContext.Provider, { value: { onLabelEdit, editingNodeId, startEditing, stopEditing }, children: children }));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hook to access edit context
|
|
30
|
+
*/
|
|
31
|
+
export function useEditContext() {
|
|
32
|
+
return useContext(EditContext);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Hook to check if a specific node is being edited
|
|
36
|
+
*/
|
|
37
|
+
export function useIsEditing(nodeId) {
|
|
38
|
+
const { editingNodeId } = useEditContext();
|
|
39
|
+
return editingNodeId === nodeId;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=EditContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditContext.js","sourceRoot":"","sources":["../../src/components/EditContext.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAqBzF,MAAM,WAAW,GAAG,aAAa,CAAmB;IAClD,WAAW,EAAE,SAAS;IACtB,aAAa,EAAE,IAAI;IACnB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;CACtB,CAAC,CAAC;AAUH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAqB;IACvE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAExE,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,MAAc,EAAE,EAAE;QAClD,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,YACnF,QAAQ,GACY,CACxB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,EAAE,aAAa,EAAE,GAAG,cAAc,EAAE,CAAC;IAC3C,OAAO,aAAa,KAAK,MAAM,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ShapeRenderer - Renders SVG shapes from ShapeDefinition
|
|
3
|
+
*
|
|
4
|
+
* This component takes a shape definition and renders the SVG path
|
|
5
|
+
* with proper scaling and styling.
|
|
6
|
+
*/
|
|
7
|
+
import type { ShapeDefinition } from '../types.js';
|
|
8
|
+
export interface ShapeRendererProps {
|
|
9
|
+
/** Shape definition to render */
|
|
10
|
+
shape: ShapeDefinition;
|
|
11
|
+
/** Width to render at (overrides defaultSize) */
|
|
12
|
+
width?: number;
|
|
13
|
+
/** Height to render at (overrides defaultSize) */
|
|
14
|
+
height?: number;
|
|
15
|
+
/** Fill color */
|
|
16
|
+
fill?: string;
|
|
17
|
+
/** Stroke color */
|
|
18
|
+
stroke?: string;
|
|
19
|
+
/** Stroke width */
|
|
20
|
+
strokeWidth?: number;
|
|
21
|
+
/** Stroke dash array (for dashed/dotted lines) */
|
|
22
|
+
strokeDasharray?: string;
|
|
23
|
+
/** Additional CSS class */
|
|
24
|
+
className?: string;
|
|
25
|
+
/** Parameter overrides for parametric shapes */
|
|
26
|
+
parameters?: Record<string, number | string | boolean>;
|
|
27
|
+
/** Enable hand-drawn sketch mode (SVG turbulence filter) */
|
|
28
|
+
sketch?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Render an SVG shape from a ShapeDefinition
|
|
32
|
+
*/
|
|
33
|
+
export declare function ShapeRenderer({ shape, width, height, fill, stroke, strokeWidth, strokeDasharray, className, parameters, sketch, }: ShapeRendererProps): import("react").JSX.Element;
|
|
34
|
+
export default ShapeRenderer;
|
|
35
|
+
//# sourceMappingURL=ShapeRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShapeRenderer.d.ts","sourceRoot":"","sources":["../../src/components/ShapeRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,KAAK,EAAE,eAAe,CAAC;IACvB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mBAAmB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACvD,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAsCD;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,MAAM,EACN,IAAgB,EAChB,MAAkB,EAClB,WAAe,EACf,eAAe,EACf,SAAS,EACT,UAAU,EACV,MAAM,GACP,EAAE,kBAAkB,+BAyEpB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Parse a viewBox string into values
|
|
4
|
+
*/
|
|
5
|
+
function parseViewBox(viewBox) {
|
|
6
|
+
const parts = viewBox.split(' ').map(Number);
|
|
7
|
+
return {
|
|
8
|
+
x: parts[0] || 0,
|
|
9
|
+
y: parts[1] || 0,
|
|
10
|
+
width: parts[2] || 100,
|
|
11
|
+
height: parts[3] || 60,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generate an SVG path with rounded corners for rectangle shapes
|
|
16
|
+
*/
|
|
17
|
+
function getRoundedRectPath(width, height, cornerRadius) {
|
|
18
|
+
const r = Math.min(cornerRadius, width / 2, height / 2);
|
|
19
|
+
return `
|
|
20
|
+
M ${r},0
|
|
21
|
+
L ${width - r},0
|
|
22
|
+
Q ${width},0 ${width},${r}
|
|
23
|
+
L ${width},${height - r}
|
|
24
|
+
Q ${width},${height} ${width - r},${height}
|
|
25
|
+
L ${r},${height}
|
|
26
|
+
Q 0,${height} 0,${height - r}
|
|
27
|
+
L 0,${r}
|
|
28
|
+
Q 0,0 ${r},0
|
|
29
|
+
Z
|
|
30
|
+
`.replace(/\s+/g, ' ').trim();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Render an SVG shape from a ShapeDefinition
|
|
34
|
+
*/
|
|
35
|
+
export function ShapeRenderer({ shape, width, height, fill = '#ffffff', stroke = '#000000', strokeWidth = 2, strokeDasharray, className, parameters, sketch, }) {
|
|
36
|
+
const finalWidth = width ?? shape.defaultSize.width;
|
|
37
|
+
const finalHeight = height ?? shape.defaultSize.height;
|
|
38
|
+
const viewBox = parseViewBox(shape.viewBox);
|
|
39
|
+
// Calculate scale factors
|
|
40
|
+
const scaleX = finalWidth / viewBox.width;
|
|
41
|
+
const scaleY = finalHeight / viewBox.height;
|
|
42
|
+
// Determine the path to use
|
|
43
|
+
let pathData = shape.path;
|
|
44
|
+
// Handle parametric shapes (like rounded rectangles)
|
|
45
|
+
if (shape.id === 'rectangle' && parameters?.cornerRadius) {
|
|
46
|
+
const cornerRadius = Number(parameters.cornerRadius) || 0;
|
|
47
|
+
if (cornerRadius > 0) {
|
|
48
|
+
pathData = getRoundedRectPath(viewBox.width, viewBox.height, cornerRadius);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// For strokeOnly shapes (like actor), don't fill
|
|
52
|
+
const finalFill = shape.strokeOnly ? 'none' : fill;
|
|
53
|
+
// Sketch mode: slightly thicker stroke for hand-drawn feel
|
|
54
|
+
const finalStrokeWidth = sketch
|
|
55
|
+
? (strokeWidth + 0.5) / Math.min(scaleX, scaleY)
|
|
56
|
+
: strokeWidth / Math.min(scaleX, scaleY);
|
|
57
|
+
// Unique filter ID for sketch mode
|
|
58
|
+
const filterId = sketch ? `sketch-wobble-${shape.id}` : undefined;
|
|
59
|
+
// Handle compound paths (multiple subpaths)
|
|
60
|
+
const paths = pathData.split(' M ').map((p, i) => (i === 0 ? p : 'M ' + p));
|
|
61
|
+
const pathProps = {
|
|
62
|
+
d: pathData,
|
|
63
|
+
fill: finalFill,
|
|
64
|
+
stroke,
|
|
65
|
+
strokeWidth: finalStrokeWidth,
|
|
66
|
+
strokeDasharray,
|
|
67
|
+
strokeLinecap: 'round',
|
|
68
|
+
strokeLinejoin: 'round',
|
|
69
|
+
...(filterId ? { filter: `url(#${filterId})` } : {}),
|
|
70
|
+
};
|
|
71
|
+
return (_jsxs("svg", { width: finalWidth, height: finalHeight, viewBox: `0 0 ${viewBox.width} ${viewBox.height}`, className: className, style: {
|
|
72
|
+
display: 'block',
|
|
73
|
+
overflow: 'visible',
|
|
74
|
+
}, children: [sketch && (_jsx("defs", { children: _jsxs("filter", { id: filterId, x: "-5%", y: "-5%", width: "110%", height: "110%", children: [_jsx("feTurbulence", { type: "turbulence", baseFrequency: "0.04", numOctaves: "3", seed: shape.id.length, result: "turbulence" }), _jsx("feDisplacementMap", { in: "SourceGraphic", in2: "turbulence", scale: 1.5, xChannelSelector: "R", yChannelSelector: "G" })] }) })), paths.length === 1 ? (_jsx("path", { ...pathProps })) : (_jsx("g", { children: _jsx("path", { ...pathProps }) }))] }));
|
|
75
|
+
}
|
|
76
|
+
export default ShapeRenderer;
|
|
77
|
+
//# sourceMappingURL=ShapeRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShapeRenderer.js","sourceRoot":"","sources":["../../src/components/ShapeRenderer.tsx"],"names":[],"mappings":";AAgCA;;GAEG;AACH,SAAS,YAAY,CAAC,OAAe;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO;QACL,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAChB,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAChB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG;QACtB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;KACvB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CACzB,KAAa,EACb,MAAc,EACd,YAAoB;IAEpB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACxD,OAAO;QACD,CAAC;QACD,KAAK,GAAG,CAAC;QACT,KAAK,MAAM,KAAK,IAAI,CAAC;QACrB,KAAK,IAAI,MAAM,GAAG,CAA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