@ultrst-armada/floks 1.2.4 → 1.2.6
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/README.md +10 -0
- package/package.json +13 -9
- package/packages/canvas-ui/dist/chunk-QRYNQ36L.js +123 -0
- package/packages/canvas-ui/dist/{chunk-OOTTFWXA.js → chunk-RH5NINIT.js} +1 -122
- package/packages/canvas-ui/dist/chunk-VESG3VP3.js +1522 -0
- package/packages/canvas-ui/dist/frnl-editable-node-graph/index.d.ts +110 -0
- package/packages/canvas-ui/dist/frnl-editable-node-graph/index.js +9 -0
- package/packages/canvas-ui/dist/index.d.ts +13 -2
- package/packages/canvas-ui/dist/index.js +63 -485
- package/packages/canvas-ui/dist/predictive/index.js +4 -2
- package/packages/canvas-ui/floks.manifest.json +25 -4
- package/packages/canvas-ui/package.json +11 -7
- package/packages/contracts/dist/index.js +2 -2
- package/packages/ui/dist/chunk-2SD6BIUX.js +0 -0
- package/packages/ui/dist/chunk-DGZBP3ND.js +832 -0
- package/packages/ui/dist/{chunk-2SFOC7KZ.js → chunk-KQAFKNQH.js} +77 -67
- package/packages/ui/dist/chunk-PH4NEHWR.js +99 -0
- package/packages/ui/dist/chunk-PRMOURNW.js +324 -0
- package/packages/ui/dist/{chunk-KYFSUQVT.js → chunk-SXRIBCJX.js} +124 -110
- package/packages/ui/dist/chunk-X4B3EBMY.js +22 -0
- package/packages/ui/dist/{chunk-DT6DZU63.js → chunk-X67KXI3H.js} +190 -152
- package/packages/ui/dist/chunk-YVWJ4SW7.js +394 -0
- package/packages/ui/dist/components/auth/index.d.ts +56 -14
- package/packages/ui/dist/components/auth/index.js +12 -3
- package/packages/ui/dist/components/graph/index.d.ts +29 -0
- package/packages/ui/dist/components/graph/index.js +10 -0
- package/packages/ui/dist/components/settings/index.js +2 -2
- package/packages/ui/dist/components/tiles/index.d.ts +83 -0
- package/packages/ui/dist/components/tiles/index.js +10 -0
- package/packages/ui/dist/components/workspace/index.d.ts +108 -33
- package/packages/ui/dist/components/workspace/index.js +15 -3
- package/packages/ui/dist/frnl/index.css +183 -0
- package/packages/ui/dist/frnl/index.d.ts +555 -0
- package/packages/ui/dist/frnl/index.js +48 -0
- package/packages/ui/dist/frnl/store.d.ts +29 -0
- package/packages/ui/dist/frnl/store.js +12 -0
- package/packages/ui/dist/hierarchy/index.d.ts +15 -51
- package/packages/ui/dist/hierarchy/index.js +6 -19
- package/packages/ui/dist/index.d.ts +9 -4
- package/packages/ui/dist/index.js +101 -46
- package/packages/ui/floks.manifest.json +99 -17
- package/packages/ui/package.json +24 -2
- package/packages/ui/dist/{chunk-ROILFUZW.js → chunk-ZPQC46RO.js} +3 -3
|
@@ -0,0 +1,1522 @@
|
|
|
1
|
+
import {
|
|
2
|
+
usePredictiveGraph2D
|
|
3
|
+
} from "./chunk-QRYNQ36L.js";
|
|
4
|
+
|
|
5
|
+
// src/frnl-editable-node-graph/FrnlEditableNodeGraph.tsx
|
|
6
|
+
import { useEffect as useEffect2, useMemo as useMemo3, useState as useState5 } from "react";
|
|
7
|
+
import { ConnectionRuleStore as ConnectionRuleStore4, MagneticGraphManager } from "@ultrst-armada/kloks/state-graph";
|
|
8
|
+
import { defineFrnlComponent } from "@ultrst-armada/frnlts";
|
|
9
|
+
import { useFrnlComponent } from "@ultrst-armada/frnlts/react";
|
|
10
|
+
import { useFloksFrnlStore } from "@ultrst-armada/floks/ui";
|
|
11
|
+
|
|
12
|
+
// src/NodeGraphCanvas.tsx
|
|
13
|
+
import { useRef as useRef2, useState as useState4, useEffect, useCallback } from "react";
|
|
14
|
+
|
|
15
|
+
// src/MovableSocketView.tsx
|
|
16
|
+
import { useState, useRef } from "react";
|
|
17
|
+
import { getBeamPoints } from "@ultrst-armada/kloks/state-graph";
|
|
18
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
function MovableSocketView({
|
|
20
|
+
nodeId,
|
|
21
|
+
socket,
|
|
22
|
+
isRight = false,
|
|
23
|
+
topOffset = 50,
|
|
24
|
+
onMouseDown,
|
|
25
|
+
onMouseUp,
|
|
26
|
+
onSocketNudgeChange,
|
|
27
|
+
telemetry
|
|
28
|
+
}) {
|
|
29
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
30
|
+
const isDraggingGizmo = useRef(false);
|
|
31
|
+
const dragStart = useRef({ x: 0, y: 0, origX: 0, origY: 0 });
|
|
32
|
+
const nudge = socket.offset ?? { x: 0, y: 0 };
|
|
33
|
+
const isDisplaced = nudge.x !== 0 || nudge.y !== 0;
|
|
34
|
+
const themeColor = isRight ? "var(--skipo-accent, #61afef)" : "#98c379";
|
|
35
|
+
const beamPoints = isDisplaced ? getBeamPoints(nudge, 6, 1.5) : "";
|
|
36
|
+
const handleGizmoMouseDown = (e) => {
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
isDraggingGizmo.current = true;
|
|
40
|
+
dragStart.current = { x: e.clientX, y: e.clientY, origX: nudge.x, origY: nudge.y };
|
|
41
|
+
const handleMouseMove = (ev) => {
|
|
42
|
+
if (!isDraggingGizmo.current) return;
|
|
43
|
+
const updated = {
|
|
44
|
+
x: Math.round(dragStart.current.origX + (ev.clientX - dragStart.current.x)),
|
|
45
|
+
y: Math.round(dragStart.current.origY + (ev.clientY - dragStart.current.y))
|
|
46
|
+
};
|
|
47
|
+
onSocketNudgeChange?.(nodeId, socket.id, updated);
|
|
48
|
+
};
|
|
49
|
+
const handleMouseUpDoc = () => {
|
|
50
|
+
isDraggingGizmo.current = false;
|
|
51
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
52
|
+
window.removeEventListener("mouseup", handleMouseUpDoc);
|
|
53
|
+
};
|
|
54
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
55
|
+
window.addEventListener("mouseup", handleMouseUpDoc);
|
|
56
|
+
};
|
|
57
|
+
return /* @__PURE__ */ jsxs(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
style: {
|
|
61
|
+
position: "absolute",
|
|
62
|
+
left: isRight ? "100%" : "0",
|
|
63
|
+
top: `${topOffset}px`,
|
|
64
|
+
transform: "translate(-50%, -50%)",
|
|
65
|
+
zIndex: 10,
|
|
66
|
+
userSelect: "none"
|
|
67
|
+
},
|
|
68
|
+
onMouseEnter: () => setIsHovered(true),
|
|
69
|
+
onMouseLeave: () => setIsHovered(false),
|
|
70
|
+
children: [
|
|
71
|
+
isDisplaced && /* @__PURE__ */ jsxs(
|
|
72
|
+
"svg",
|
|
73
|
+
{
|
|
74
|
+
style: {
|
|
75
|
+
position: "absolute",
|
|
76
|
+
left: nudge.x + 6,
|
|
77
|
+
top: nudge.y + 6,
|
|
78
|
+
overflow: "visible",
|
|
79
|
+
pointerEvents: "none",
|
|
80
|
+
zIndex: 1
|
|
81
|
+
},
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsx("polygon", { points: beamPoints, fill: themeColor, opacity: 0.5 }),
|
|
84
|
+
/* @__PURE__ */ jsx("polygon", { points: beamPoints, fill: "#ffffff", opacity: 0.8, transform: "scale(0.5)" })
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
telemetry && /* @__PURE__ */ jsx(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
"aria-label": `Live signal on ${socket.label}`,
|
|
92
|
+
style: {
|
|
93
|
+
position: "absolute",
|
|
94
|
+
left: isRight ? 10 : -10,
|
|
95
|
+
top: nudge.y,
|
|
96
|
+
transform: `translateY(-50%) ${isRight ? "" : "translateX(-100%)"}`,
|
|
97
|
+
minWidth: 34,
|
|
98
|
+
padding: "1px 3px",
|
|
99
|
+
borderRadius: 3,
|
|
100
|
+
background: "rgba(0,0,0,0.72)",
|
|
101
|
+
border: `1px solid ${telemetry.gain?.color ?? (telemetry.midi?.active ? "#ec4899" : themeColor)}`,
|
|
102
|
+
color: telemetry.gain?.color ?? (telemetry.midi?.active ? "#ec4899" : themeColor),
|
|
103
|
+
fontSize: 7,
|
|
104
|
+
fontFamily: "monospace",
|
|
105
|
+
pointerEvents: "none",
|
|
106
|
+
zIndex: 8
|
|
107
|
+
},
|
|
108
|
+
children: telemetry.midi?.active ? `MIDI ${telemetry.midi.note}` : telemetry.gain?.formatted ?? (telemetry.trigger?.active ? "TRIGGER" : telemetry.osc?.active ? telemetry.osc.value.toFixed(2) : telemetry.audioStereoLevels ? `${Math.round(Math.max(telemetry.audioStereoLevels.left, telemetry.audioStereoLevels.right) * 100)}%` : "")
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ jsx(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
style: {
|
|
115
|
+
position: "absolute",
|
|
116
|
+
left: nudge.x - 6,
|
|
117
|
+
top: nudge.y - 6,
|
|
118
|
+
width: "12px",
|
|
119
|
+
height: "12px",
|
|
120
|
+
borderRadius: "50%",
|
|
121
|
+
backgroundColor: themeColor,
|
|
122
|
+
cursor: "crosshair",
|
|
123
|
+
border: "2px solid var(--skipo-surface, #222)",
|
|
124
|
+
boxShadow: isHovered ? `0 0 8px ${themeColor}` : "0 2px 4px rgba(0,0,0,0.5)",
|
|
125
|
+
zIndex: 4,
|
|
126
|
+
transition: "box-shadow 0.15s ease"
|
|
127
|
+
},
|
|
128
|
+
title: `${socket.label} (${socket.type})`,
|
|
129
|
+
onMouseDown: (e) => {
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
onMouseDown?.(e, nodeId, socket.id, isRight ? "output" : "input");
|
|
132
|
+
},
|
|
133
|
+
onMouseUp: (e) => {
|
|
134
|
+
e.stopPropagation();
|
|
135
|
+
onMouseUp?.(e, nodeId, socket.id, isRight ? "output" : "input");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
isHovered && /* @__PURE__ */ jsx(
|
|
140
|
+
"div",
|
|
141
|
+
{
|
|
142
|
+
title: "Drag gizmo to move handle without moving node",
|
|
143
|
+
style: {
|
|
144
|
+
position: "absolute",
|
|
145
|
+
left: nudge.x + (isRight ? 10 : -22),
|
|
146
|
+
top: nudge.y - 7,
|
|
147
|
+
width: "14px",
|
|
148
|
+
height: "14px",
|
|
149
|
+
borderRadius: "3px",
|
|
150
|
+
backgroundColor: "var(--skipo-surface, #222)",
|
|
151
|
+
border: "1px solid var(--skipo-accent, #d4af37)",
|
|
152
|
+
cursor: "grab",
|
|
153
|
+
display: "flex",
|
|
154
|
+
alignItems: "center",
|
|
155
|
+
justifyContent: "center",
|
|
156
|
+
zIndex: 6
|
|
157
|
+
},
|
|
158
|
+
onMouseDown: handleGizmoMouseDown,
|
|
159
|
+
children: /* @__PURE__ */ jsxs("svg", { width: "8", height: "8", viewBox: "0 0 24 24", fill: "none", stroke: "var(--skipo-accent, #d4af37)", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
160
|
+
/* @__PURE__ */ jsx("polyline", { points: "5 9 2 12 5 15" }),
|
|
161
|
+
/* @__PURE__ */ jsx("polyline", { points: "9 5 12 2 15 5" }),
|
|
162
|
+
/* @__PURE__ */ jsx("polyline", { points: "15 19 12 22 9 19" }),
|
|
163
|
+
/* @__PURE__ */ jsx("polyline", { points: "19 9 22 12 19 15" }),
|
|
164
|
+
/* @__PURE__ */ jsx("line", { x1: "2", y1: "12", x2: "22", y2: "12" }),
|
|
165
|
+
/* @__PURE__ */ jsx("line", { x1: "12", y1: "2", x2: "12", y2: "22" })
|
|
166
|
+
] })
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/NodeCard.tsx
|
|
175
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
176
|
+
function renderNodeEmblem(type) {
|
|
177
|
+
const t = (type || "").toLowerCase();
|
|
178
|
+
if (t.includes("entity") || t.includes("system")) {
|
|
179
|
+
return /* @__PURE__ */ jsxs2("svg", { width: "38", height: "38", viewBox: "0 0 24 24", fill: "none", stroke: "var(--skipo-accent, #d4af37)", strokeWidth: "1.8", children: [
|
|
180
|
+
/* @__PURE__ */ jsx2("path", { d: "M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" }),
|
|
181
|
+
/* @__PURE__ */ jsx2("polyline", { points: "3.27 6.96 12 12.01 20.73 6.96" }),
|
|
182
|
+
/* @__PURE__ */ jsx2("line", { x1: "12", y1: "22.08", x2: "12", y2: "12" })
|
|
183
|
+
] });
|
|
184
|
+
}
|
|
185
|
+
if (t.includes("func") || t.includes("logic")) {
|
|
186
|
+
return /* @__PURE__ */ jsx2("svg", { width: "38", height: "38", viewBox: "0 0 24 24", fill: "none", stroke: "var(--skipo-accent, #61afef)", strokeWidth: "1.8", children: /* @__PURE__ */ jsx2("polygon", { points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2" }) });
|
|
187
|
+
}
|
|
188
|
+
if (t.includes("data") || t.includes("state") || t.includes("db")) {
|
|
189
|
+
return /* @__PURE__ */ jsxs2("svg", { width: "38", height: "38", viewBox: "0 0 24 24", fill: "none", stroke: "#98c379", strokeWidth: "1.8", children: [
|
|
190
|
+
/* @__PURE__ */ jsx2("ellipse", { cx: "12", cy: "5", rx: "9", ry: "3" }),
|
|
191
|
+
/* @__PURE__ */ jsx2("path", { d: "M21 12c0 1.66-4 3-9 3s-9-1.34-9-3" }),
|
|
192
|
+
/* @__PURE__ */ jsx2("path", { d: "M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5" })
|
|
193
|
+
] });
|
|
194
|
+
}
|
|
195
|
+
return /* @__PURE__ */ jsxs2("svg", { width: "38", height: "38", viewBox: "0 0 24 24", fill: "none", stroke: "var(--skipo-accent, #61afef)", strokeWidth: "1.8", children: [
|
|
196
|
+
/* @__PURE__ */ jsx2("rect", { x: "3", y: "3", width: "18", height: "18", rx: "3" }),
|
|
197
|
+
/* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "4" })
|
|
198
|
+
] });
|
|
199
|
+
}
|
|
200
|
+
function NodeCard({
|
|
201
|
+
node,
|
|
202
|
+
selected,
|
|
203
|
+
onMouseDown,
|
|
204
|
+
onDoubleClick,
|
|
205
|
+
onSocketMouseDown,
|
|
206
|
+
onSocketMouseUp,
|
|
207
|
+
onSocketNudgeChange,
|
|
208
|
+
getSocketTelemetry
|
|
209
|
+
}) {
|
|
210
|
+
const width = node.width ?? 130;
|
|
211
|
+
const height = node.height ?? 130;
|
|
212
|
+
const isLongText = (node.label || "").length > 11;
|
|
213
|
+
return /* @__PURE__ */ jsxs2(
|
|
214
|
+
"div",
|
|
215
|
+
{
|
|
216
|
+
style: {
|
|
217
|
+
position: "absolute",
|
|
218
|
+
left: node.position.x,
|
|
219
|
+
top: node.position.y,
|
|
220
|
+
width,
|
|
221
|
+
height,
|
|
222
|
+
userSelect: "none"
|
|
223
|
+
},
|
|
224
|
+
onMouseDown: (e) => onMouseDown?.(e, node.id),
|
|
225
|
+
onDoubleClick: () => onDoubleClick?.(node.id),
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ jsx2("style", { children: `
|
|
228
|
+
@keyframes skipo-marquee-rtl {
|
|
229
|
+
0% { transform: translateX(0%); }
|
|
230
|
+
100% { transform: translateX(-50%); }
|
|
231
|
+
}
|
|
232
|
+
` }),
|
|
233
|
+
/* @__PURE__ */ jsxs2(
|
|
234
|
+
"div",
|
|
235
|
+
{
|
|
236
|
+
style: {
|
|
237
|
+
width: "100%",
|
|
238
|
+
height: "100%",
|
|
239
|
+
position: "relative",
|
|
240
|
+
display: "flex",
|
|
241
|
+
flexDirection: "column",
|
|
242
|
+
backgroundColor: "var(--skipo-surface, rgba(25, 25, 25, 0.92))",
|
|
243
|
+
backdropFilter: "blur(10px)",
|
|
244
|
+
border: `2px solid ${selected ? "var(--skipo-accent, #d4af37)" : "var(--skipo-border, #333)"}`,
|
|
245
|
+
borderRadius: "8px",
|
|
246
|
+
boxShadow: selected ? "0 0 16px rgba(212, 175, 55, 0.45)" : "0 4px 10px rgba(0,0,0,0.4)",
|
|
247
|
+
overflow: "hidden",
|
|
248
|
+
boxSizing: "border-box"
|
|
249
|
+
},
|
|
250
|
+
children: [
|
|
251
|
+
/* @__PURE__ */ jsx2(
|
|
252
|
+
"div",
|
|
253
|
+
{
|
|
254
|
+
style: {
|
|
255
|
+
flex: "2 1 66.7%",
|
|
256
|
+
height: "66.7%",
|
|
257
|
+
width: "100%",
|
|
258
|
+
display: "flex",
|
|
259
|
+
alignItems: "center",
|
|
260
|
+
justifyContent: "center",
|
|
261
|
+
position: "relative",
|
|
262
|
+
background: "radial-gradient(circle at center, rgba(255,255,255,0.06) 0%, transparent 72%)",
|
|
263
|
+
overflow: "hidden"
|
|
264
|
+
},
|
|
265
|
+
children: renderNodeEmblem(node.type)
|
|
266
|
+
}
|
|
267
|
+
),
|
|
268
|
+
/* @__PURE__ */ jsx2(
|
|
269
|
+
"div",
|
|
270
|
+
{
|
|
271
|
+
style: {
|
|
272
|
+
flex: "1 1 33.3%",
|
|
273
|
+
height: "33.3%",
|
|
274
|
+
width: "100%",
|
|
275
|
+
borderTop: "1px solid var(--skipo-border, #333)",
|
|
276
|
+
backgroundColor: "rgba(0, 0, 0, 0.35)",
|
|
277
|
+
display: "flex",
|
|
278
|
+
alignItems: "center",
|
|
279
|
+
justifyContent: "center",
|
|
280
|
+
padding: "0 4px",
|
|
281
|
+
overflow: "hidden",
|
|
282
|
+
boxSizing: "border-box"
|
|
283
|
+
},
|
|
284
|
+
children: /* @__PURE__ */ jsx2(
|
|
285
|
+
"div",
|
|
286
|
+
{
|
|
287
|
+
style: {
|
|
288
|
+
width: "100%",
|
|
289
|
+
overflow: "hidden",
|
|
290
|
+
display: "flex",
|
|
291
|
+
justifyContent: isLongText ? "flex-start" : "center"
|
|
292
|
+
},
|
|
293
|
+
children: /* @__PURE__ */ jsxs2(
|
|
294
|
+
"div",
|
|
295
|
+
{
|
|
296
|
+
style: {
|
|
297
|
+
display: "inline-flex",
|
|
298
|
+
alignItems: "center",
|
|
299
|
+
whiteSpace: "nowrap",
|
|
300
|
+
fontSize: "11px",
|
|
301
|
+
fontWeight: 600,
|
|
302
|
+
color: "var(--skipo-text, #fff)",
|
|
303
|
+
letterSpacing: "0.02em",
|
|
304
|
+
animation: isLongText ? "skipo-marquee-rtl 6s linear infinite" : "none"
|
|
305
|
+
},
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ jsx2("span", { children: node.label }),
|
|
308
|
+
isLongText && /* @__PURE__ */ jsxs2("span", { style: { paddingLeft: "16px", opacity: 0.8 }, children: [
|
|
309
|
+
"\u2022 ",
|
|
310
|
+
node.label
|
|
311
|
+
] })
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
)
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
),
|
|
322
|
+
node.inputs?.map((socket, idx) => {
|
|
323
|
+
const total = node.inputs?.length ?? 1;
|
|
324
|
+
const topOffset = total === 1 ? height * 0.45 : height * 0.25 + idx * 24;
|
|
325
|
+
return /* @__PURE__ */ jsx2(
|
|
326
|
+
MovableSocketView,
|
|
327
|
+
{
|
|
328
|
+
nodeId: node.id,
|
|
329
|
+
socket,
|
|
330
|
+
topOffset,
|
|
331
|
+
onMouseDown: onSocketMouseDown,
|
|
332
|
+
onMouseUp: onSocketMouseUp,
|
|
333
|
+
onSocketNudgeChange,
|
|
334
|
+
telemetry: getSocketTelemetry?.(node.id, socket.id, false)
|
|
335
|
+
},
|
|
336
|
+
socket.id
|
|
337
|
+
);
|
|
338
|
+
}),
|
|
339
|
+
node.outputs?.map((socket, idx) => {
|
|
340
|
+
const total = node.outputs?.length ?? 1;
|
|
341
|
+
const topOffset = total === 1 ? height * 0.45 : height * 0.25 + idx * 24;
|
|
342
|
+
return /* @__PURE__ */ jsx2(
|
|
343
|
+
MovableSocketView,
|
|
344
|
+
{
|
|
345
|
+
nodeId: node.id,
|
|
346
|
+
socket,
|
|
347
|
+
isRight: true,
|
|
348
|
+
topOffset,
|
|
349
|
+
onMouseDown: onSocketMouseDown,
|
|
350
|
+
onMouseUp: onSocketMouseUp,
|
|
351
|
+
onSocketNudgeChange,
|
|
352
|
+
telemetry: getSocketTelemetry?.(node.id, socket.id, true)
|
|
353
|
+
},
|
|
354
|
+
socket.id
|
|
355
|
+
);
|
|
356
|
+
})
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// src/WireRenderer.tsx
|
|
363
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
364
|
+
function WireRenderer({ edges, nodesData, config: _config, onDeleteEdge, connecting }) {
|
|
365
|
+
const getSocketPosition = (nodeId, socketId, type) => {
|
|
366
|
+
const node = nodesData[nodeId];
|
|
367
|
+
if (!node) return { x: 0, y: 0 };
|
|
368
|
+
const sockets = type === "input" ? node.inputs : node.outputs;
|
|
369
|
+
const socket = sockets?.find((s) => s.id === socketId);
|
|
370
|
+
const socketIndex = sockets && socket ? sockets.indexOf(socket) : 0;
|
|
371
|
+
let x = type === "input" ? node.x : node.x + (node.width ?? 150);
|
|
372
|
+
let y = node.y + 40 + Math.max(0, socketIndex) * 24;
|
|
373
|
+
if (socket?.offset) {
|
|
374
|
+
const zoom = node.zoom ?? 1;
|
|
375
|
+
x += socket.offset.x * zoom;
|
|
376
|
+
y += socket.offset.y * zoom;
|
|
377
|
+
}
|
|
378
|
+
return { x, y };
|
|
379
|
+
};
|
|
380
|
+
const renderBezier = (startX, startY, endX, endY) => {
|
|
381
|
+
const delta = Math.max(Math.abs(endX - startX) * 0.5, 50);
|
|
382
|
+
return `M ${startX},${startY} C ${startX + delta},${startY} ${endX - delta},${endY} ${endX},${endY}`;
|
|
383
|
+
};
|
|
384
|
+
return /* @__PURE__ */ jsxs3("svg", { style: { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", pointerEvents: "none", overflow: "visible" }, children: [
|
|
385
|
+
edges.map((edge) => {
|
|
386
|
+
const start = getSocketPosition(edge.source, edge.sourceSocket, "output");
|
|
387
|
+
const end = getSocketPosition(edge.target, edge.targetSocket, "input");
|
|
388
|
+
const path = renderBezier(start.x, start.y, end.x, end.y);
|
|
389
|
+
const midX = (start.x + end.x) / 2;
|
|
390
|
+
const midY = (start.y + end.y) / 2;
|
|
391
|
+
const color = edge.color || "#61afef";
|
|
392
|
+
return /* @__PURE__ */ jsxs3("g", { style: { pointerEvents: "auto" }, children: [
|
|
393
|
+
/* @__PURE__ */ jsx3(
|
|
394
|
+
"path",
|
|
395
|
+
{
|
|
396
|
+
d: path,
|
|
397
|
+
fill: "none",
|
|
398
|
+
stroke: "transparent",
|
|
399
|
+
strokeWidth: 15
|
|
400
|
+
}
|
|
401
|
+
),
|
|
402
|
+
/* @__PURE__ */ jsx3(
|
|
403
|
+
"path",
|
|
404
|
+
{
|
|
405
|
+
d: path,
|
|
406
|
+
fill: "none",
|
|
407
|
+
stroke: color,
|
|
408
|
+
strokeWidth: 3,
|
|
409
|
+
opacity: 0.8
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
onDeleteEdge && /* @__PURE__ */ jsxs3(
|
|
413
|
+
"g",
|
|
414
|
+
{
|
|
415
|
+
transform: `translate(${midX}, ${midY})`,
|
|
416
|
+
onClick: () => onDeleteEdge(edge.id),
|
|
417
|
+
style: { cursor: "pointer" },
|
|
418
|
+
children: [
|
|
419
|
+
/* @__PURE__ */ jsx3("circle", { r: 8, fill: "#ff4d4f" }),
|
|
420
|
+
/* @__PURE__ */ jsx3("text", { x: 0, y: 0, fontSize: 10, fill: "white", textAnchor: "middle", dominantBaseline: "central", children: "\u2715" })
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
)
|
|
424
|
+
] }, edge.id);
|
|
425
|
+
}),
|
|
426
|
+
connecting && /* @__PURE__ */ jsx3(
|
|
427
|
+
"path",
|
|
428
|
+
{
|
|
429
|
+
d: renderBezier(connecting.startX, connecting.startY, connecting.endX, connecting.endY),
|
|
430
|
+
fill: "none",
|
|
431
|
+
stroke: connecting.color || "#61afef",
|
|
432
|
+
strokeWidth: 3,
|
|
433
|
+
strokeDasharray: "5,5",
|
|
434
|
+
opacity: 0.8
|
|
435
|
+
}
|
|
436
|
+
)
|
|
437
|
+
] });
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/NodeGraphCanvas.tsx
|
|
441
|
+
import { canvasToScreen, isNodeInCenterDeadZone, getCenterPanForNode, getNodesInSelection, ConnectionRuleStore as ConnectionRuleStore3 } from "@ultrst-armada/kloks/state-graph";
|
|
442
|
+
|
|
443
|
+
// src/node-graph-ui/widgets/CompatibleNodePicker.tsx
|
|
444
|
+
import { useState as useState2, useMemo } from "react";
|
|
445
|
+
import { ConnectionRuleStore } from "@ultrst-armada/kloks/state-graph";
|
|
446
|
+
import { useSearchKeyboardNavigation, BaseButton, BaseInput } from "@ultrst-armada/floks/ui";
|
|
447
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
448
|
+
function CompatibleNodePicker({
|
|
449
|
+
x,
|
|
450
|
+
y,
|
|
451
|
+
sourceHandle,
|
|
452
|
+
availableNodeTypes,
|
|
453
|
+
onSelect,
|
|
454
|
+
onClose
|
|
455
|
+
}) {
|
|
456
|
+
const [selectedTypes, setSelectedTypes] = useState2(/* @__PURE__ */ new Set());
|
|
457
|
+
const [searchTerm, setSearchTerm] = useState2("");
|
|
458
|
+
const compatibleNodes = useMemo(() => {
|
|
459
|
+
const isOut = sourceHandle.direction === "output";
|
|
460
|
+
return ConnectionRuleStore.getCompatibleNodeTypes(
|
|
461
|
+
{ dataType: sourceHandle.dataType || "ANY", direction: isOut ? "OUTPUT" : "INPUT", handleCategory: "DATA" },
|
|
462
|
+
availableNodeTypes
|
|
463
|
+
);
|
|
464
|
+
}, [sourceHandle, availableNodeTypes]);
|
|
465
|
+
const filteredNodes = useMemo(() => {
|
|
466
|
+
if (!searchTerm.trim()) return compatibleNodes;
|
|
467
|
+
const term = searchTerm.toLowerCase();
|
|
468
|
+
return compatibleNodes.filter((n) => n.type.toLowerCase().includes(term) || n.label.toLowerCase().includes(term));
|
|
469
|
+
}, [compatibleNodes, searchTerm]);
|
|
470
|
+
const handleQuickSelect = (type) => onSelect([type]);
|
|
471
|
+
const { highlightedIndex, setHighlightedIndex, handleKeyDown, listContainerRef } = useSearchKeyboardNavigation({
|
|
472
|
+
items: filteredNodes,
|
|
473
|
+
onSelect: (node) => handleQuickSelect(node.type),
|
|
474
|
+
onClose
|
|
475
|
+
});
|
|
476
|
+
const toggleSelect = (type) => {
|
|
477
|
+
setSelectedTypes((prev) => {
|
|
478
|
+
const next = new Set(prev);
|
|
479
|
+
if (next.has(type)) next.delete(type);
|
|
480
|
+
else next.add(type);
|
|
481
|
+
return next;
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
return /* @__PURE__ */ jsxs4(
|
|
485
|
+
"div",
|
|
486
|
+
{
|
|
487
|
+
style: {
|
|
488
|
+
position: "absolute",
|
|
489
|
+
left: x,
|
|
490
|
+
top: y,
|
|
491
|
+
transform: "translate(-50%, 0)",
|
|
492
|
+
width: "270px",
|
|
493
|
+
maxHeight: "360px",
|
|
494
|
+
backgroundColor: "var(--skipo-surface)",
|
|
495
|
+
border: "var(--skipo-border)",
|
|
496
|
+
borderRadius: "var(--skipo-radius)",
|
|
497
|
+
boxShadow: "var(--skipo-shadow)",
|
|
498
|
+
color: "var(--skipo-text)",
|
|
499
|
+
zIndex: 50,
|
|
500
|
+
display: "flex",
|
|
501
|
+
flexDirection: "column",
|
|
502
|
+
overflow: "hidden",
|
|
503
|
+
fontFamily: "var(--skipo-font)"
|
|
504
|
+
},
|
|
505
|
+
onClick: (e) => e.stopPropagation(),
|
|
506
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
507
|
+
children: [
|
|
508
|
+
/* @__PURE__ */ jsxs4("div", { style: { padding: "8px 12px", borderBottom: "var(--skipo-border)", display: "flex", alignItems: "center", justifyContent: "space-between", backgroundColor: "var(--skipo-matte-bg)" }, children: [
|
|
509
|
+
/* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column" }, children: [
|
|
510
|
+
/* @__PURE__ */ jsx4("span", { style: { fontSize: "11px", fontWeight: 600, color: "var(--skipo-accent)" }, children: "Compatible Nodes" }),
|
|
511
|
+
/* @__PURE__ */ jsxs4("span", { style: { fontSize: "9px", color: "var(--skipo-text-muted)" }, children: [
|
|
512
|
+
"For ",
|
|
513
|
+
sourceHandle.dataType || "ANY",
|
|
514
|
+
" (",
|
|
515
|
+
sourceHandle.direction,
|
|
516
|
+
")"
|
|
517
|
+
] })
|
|
518
|
+
] }),
|
|
519
|
+
/* @__PURE__ */ jsx4(BaseButton, { variant: "ghost", size: "sm", onClick: onClose, "aria-label": "Close picker", style: { padding: "2px 6px" }, children: "\u2715" })
|
|
520
|
+
] }),
|
|
521
|
+
/* @__PURE__ */ jsx4("div", { style: { padding: "6px 8px", borderBottom: "var(--skipo-border)" }, children: /* @__PURE__ */ jsx4(BaseInput, { autoFocus: true, placeholder: "Filter nodes... (\u2191\u2193 navigate, \u21B5 spawn)", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), onKeyDown: handleKeyDown }) }),
|
|
522
|
+
/* @__PURE__ */ jsx4("div", { ref: listContainerRef, style: { flex: 1, overflowY: "auto", maxHeight: "180px", padding: "4px" }, children: filteredNodes.length === 0 ? /* @__PURE__ */ jsx4("div", { style: { padding: "16px", textAlign: "center", fontSize: "11px", color: "var(--skipo-text-muted)" }, children: "No compatible nodes found" }) : filteredNodes.map((node, idx) => {
|
|
523
|
+
const isSelected = selectedTypes.has(node.type);
|
|
524
|
+
const isHighlighted = idx === highlightedIndex;
|
|
525
|
+
return /* @__PURE__ */ jsxs4(
|
|
526
|
+
"div",
|
|
527
|
+
{
|
|
528
|
+
onMouseEnter: () => setHighlightedIndex(idx),
|
|
529
|
+
onClick: () => toggleSelect(node.type),
|
|
530
|
+
onDoubleClick: () => handleQuickSelect(node.type),
|
|
531
|
+
style: {
|
|
532
|
+
display: "flex",
|
|
533
|
+
alignItems: "center",
|
|
534
|
+
gap: "8px",
|
|
535
|
+
padding: "6px 8px",
|
|
536
|
+
borderRadius: "var(--skipo-radius-sm)",
|
|
537
|
+
cursor: "pointer",
|
|
538
|
+
backgroundColor: isHighlighted ? "var(--skipo-surface-hover)" : isSelected ? "var(--skipo-matte-bg)" : "transparent",
|
|
539
|
+
border: isHighlighted ? "var(--skipo-border)" : "1px solid transparent",
|
|
540
|
+
marginBottom: "2px",
|
|
541
|
+
transition: "background-color 0.1s ease"
|
|
542
|
+
},
|
|
543
|
+
children: [
|
|
544
|
+
/* @__PURE__ */ jsx4("input", { type: "checkbox", checked: isSelected, onChange: () => toggleSelect(node.type), onClick: (e) => e.stopPropagation(), style: { cursor: "pointer" } }),
|
|
545
|
+
/* @__PURE__ */ jsxs4("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
546
|
+
/* @__PURE__ */ jsx4("div", { style: { fontSize: "11px", fontWeight: isHighlighted ? 600 : 500, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", color: isHighlighted ? "var(--skipo-accent)" : "inherit" }, children: node.label || node.type }),
|
|
547
|
+
node.description && /* @__PURE__ */ jsx4("div", { style: { fontSize: "9px", color: "var(--skipo-text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: node.description })
|
|
548
|
+
] }),
|
|
549
|
+
isHighlighted && /* @__PURE__ */ jsx4("span", { style: { fontSize: "8px", fontWeight: 600, color: "var(--skipo-accent)", padding: "1px 4px", borderRadius: "var(--skipo-radius-sm)", backgroundColor: "var(--skipo-matte-bg)", border: "var(--skipo-border)", whiteSpace: "nowrap" }, children: "\u21B5 Enter" })
|
|
550
|
+
]
|
|
551
|
+
},
|
|
552
|
+
node.type
|
|
553
|
+
);
|
|
554
|
+
}) }),
|
|
555
|
+
/* @__PURE__ */ jsxs4("div", { style: { padding: "6px 8px", borderTop: "var(--skipo-border)", display: "flex", justifyContent: "space-between", alignItems: "center", backgroundColor: "var(--skipo-matte-bg)" }, children: [
|
|
556
|
+
/* @__PURE__ */ jsx4("span", { style: { fontSize: "10px", color: "var(--skipo-text-muted)" }, children: selectedTypes.size > 0 ? `${selectedTypes.size} selected` : "\u21B5 Spawn top match" }),
|
|
557
|
+
/* @__PURE__ */ jsxs4("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
558
|
+
/* @__PURE__ */ jsx4(BaseButton, { variant: "secondary", size: "sm", onClick: onClose, style: { padding: "2px 8px", fontSize: "10px" }, children: "Cancel" }),
|
|
559
|
+
/* @__PURE__ */ jsx4(
|
|
560
|
+
BaseButton,
|
|
561
|
+
{
|
|
562
|
+
variant: "accent",
|
|
563
|
+
size: "sm",
|
|
564
|
+
disabled: selectedTypes.size === 0 && filteredNodes.length === 0,
|
|
565
|
+
onClick: () => {
|
|
566
|
+
if (selectedTypes.size > 0) onSelect(Array.from(selectedTypes));
|
|
567
|
+
else if (filteredNodes.length > 0) handleQuickSelect(filteredNodes[highlightedIndex >= 0 ? highlightedIndex : 0].type);
|
|
568
|
+
},
|
|
569
|
+
style: { padding: "2px 10px", fontSize: "10px" },
|
|
570
|
+
children: "Spawn & Solidify"
|
|
571
|
+
}
|
|
572
|
+
)
|
|
573
|
+
] })
|
|
574
|
+
] })
|
|
575
|
+
]
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// src/node-graph-ui/widgets/NodeSearchPalette.tsx
|
|
581
|
+
import { useState as useState3, useMemo as useMemo2 } from "react";
|
|
582
|
+
import { ConnectionRuleStore as ConnectionRuleStore2 } from "@ultrst-armada/kloks/state-graph";
|
|
583
|
+
import { useSearchKeyboardNavigation as useSearchKeyboardNavigation2, BaseButton as BaseButton2, BaseInput as BaseInput2 } from "@ultrst-armada/floks/ui";
|
|
584
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
585
|
+
function menuCategory(node) {
|
|
586
|
+
return node.category || String(node.metadata?.category ?? "Other");
|
|
587
|
+
}
|
|
588
|
+
function menuHidden(node) {
|
|
589
|
+
return node.hidden === true || node.menu?.visible === false || node.metadata?.menuHidden === true;
|
|
590
|
+
}
|
|
591
|
+
function NodeSearchPalette({
|
|
592
|
+
x,
|
|
593
|
+
y,
|
|
594
|
+
availableNodeTypes = [],
|
|
595
|
+
onSpawnNode,
|
|
596
|
+
onClose
|
|
597
|
+
}) {
|
|
598
|
+
const [query, setQuery] = useState3("");
|
|
599
|
+
const nodes = useMemo2(() => {
|
|
600
|
+
const registered = availableNodeTypes.length > 0 ? availableNodeTypes : ConnectionRuleStore2.listNodeTypes();
|
|
601
|
+
return registered.filter((node) => !menuHidden(node));
|
|
602
|
+
}, [availableNodeTypes]);
|
|
603
|
+
const filteredNodes = useMemo2(() => {
|
|
604
|
+
if (!query.trim()) return nodes;
|
|
605
|
+
const q = query.toLowerCase();
|
|
606
|
+
return nodes.filter(
|
|
607
|
+
(n) => n.type.toLowerCase().includes(q) || n.label.toLowerCase().includes(q) || n.description?.toLowerCase().includes(q) || menuCategory(n).toLowerCase().includes(q)
|
|
608
|
+
);
|
|
609
|
+
}, [nodes, query]);
|
|
610
|
+
const groupedNodes = useMemo2(() => {
|
|
611
|
+
const groups = /* @__PURE__ */ new Map();
|
|
612
|
+
for (const node of filteredNodes) {
|
|
613
|
+
const category = menuCategory(node);
|
|
614
|
+
const group = groups.get(category) ?? [];
|
|
615
|
+
group.push(node);
|
|
616
|
+
groups.set(category, group);
|
|
617
|
+
}
|
|
618
|
+
return Array.from(groups.entries()).sort(([a], [b]) => a.localeCompare(b));
|
|
619
|
+
}, [filteredNodes]);
|
|
620
|
+
const {
|
|
621
|
+
highlightedIndex,
|
|
622
|
+
setHighlightedIndex,
|
|
623
|
+
handleKeyDown,
|
|
624
|
+
listContainerRef
|
|
625
|
+
} = useSearchKeyboardNavigation2({
|
|
626
|
+
items: filteredNodes,
|
|
627
|
+
onSelect: (node) => {
|
|
628
|
+
onSpawnNode(node.type);
|
|
629
|
+
onClose();
|
|
630
|
+
},
|
|
631
|
+
onClose
|
|
632
|
+
});
|
|
633
|
+
return /* @__PURE__ */ jsxs5(
|
|
634
|
+
"div",
|
|
635
|
+
{
|
|
636
|
+
style: {
|
|
637
|
+
position: "absolute",
|
|
638
|
+
left: x,
|
|
639
|
+
top: y,
|
|
640
|
+
transform: "translate(-50%, 0)",
|
|
641
|
+
width: "310px",
|
|
642
|
+
maxHeight: "430px",
|
|
643
|
+
backgroundColor: "var(--skipo-surface)",
|
|
644
|
+
border: "var(--skipo-border)",
|
|
645
|
+
borderRadius: "var(--skipo-radius)",
|
|
646
|
+
boxShadow: "var(--skipo-shadow)",
|
|
647
|
+
color: "var(--skipo-text)",
|
|
648
|
+
zIndex: 70,
|
|
649
|
+
display: "flex",
|
|
650
|
+
flexDirection: "column",
|
|
651
|
+
overflow: "hidden",
|
|
652
|
+
fontFamily: "var(--skipo-font)"
|
|
653
|
+
},
|
|
654
|
+
onClick: (e) => e.stopPropagation(),
|
|
655
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
656
|
+
children: [
|
|
657
|
+
/* @__PURE__ */ jsxs5("div", { style: { padding: "10px 12px", borderBottom: "var(--skipo-border)", display: "flex", alignItems: "center", justifyContent: "space-between", backgroundColor: "var(--skipo-matte-bg)" }, children: [
|
|
658
|
+
/* @__PURE__ */ jsxs5("div", { style: { display: "flex", alignItems: "center", gap: "6px" }, children: [
|
|
659
|
+
/* @__PURE__ */ jsx5("span", { style: { fontSize: "11px", fontWeight: 600, color: "var(--skipo-accent)" }, children: "Spawn Node" }),
|
|
660
|
+
/* @__PURE__ */ jsx5("span", { style: { fontSize: "9px", color: "var(--skipo-text-muted)", fontFamily: "var(--skipo-font-mono)", backgroundColor: "var(--skipo-surface)", padding: "1px 4px", borderRadius: "var(--skipo-radius-sm)" }, children: "hotkey [N]" })
|
|
661
|
+
] }),
|
|
662
|
+
/* @__PURE__ */ jsx5(BaseButton2, { variant: "ghost", size: "sm", onClick: onClose, "aria-label": "Close search", style: { padding: "2px 6px", fontSize: "12px" }, children: "\u2715" })
|
|
663
|
+
] }),
|
|
664
|
+
/* @__PURE__ */ jsx5("div", { style: { padding: "8px", borderBottom: "var(--skipo-border)" }, children: /* @__PURE__ */ jsx5(BaseInput2, { autoFocus: true, placeholder: "Search nodes or categories... (\u2191\u2193, \u21B5 spawn)", value: query, onChange: (e) => setQuery(e.target.value), onKeyDown: handleKeyDown }) }),
|
|
665
|
+
/* @__PURE__ */ jsx5("div", { ref: listContainerRef, style: { flex: 1, overflowY: "auto", maxHeight: "270px", padding: "4px 6px" }, children: filteredNodes.length === 0 ? /* @__PURE__ */ jsx5("div", { style: { padding: "20px", textAlign: "center", fontSize: "11px", color: "var(--skipo-text-muted)" }, children: "No matching nodes" }) : groupedNodes.map(([category, categoryNodes]) => /* @__PURE__ */ jsxs5("div", { children: [
|
|
666
|
+
/* @__PURE__ */ jsx5("div", { style: { padding: "6px 8px 3px", fontSize: "9px", fontWeight: 700, letterSpacing: "0.08em", textTransform: "uppercase", color: "var(--skipo-text-muted)" }, children: category }),
|
|
667
|
+
categoryNodes.map((node) => {
|
|
668
|
+
const idx = filteredNodes.findIndex((candidate) => candidate.type === node.type);
|
|
669
|
+
const isHighlighted = idx === highlightedIndex;
|
|
670
|
+
return /* @__PURE__ */ jsxs5(
|
|
671
|
+
"div",
|
|
672
|
+
{
|
|
673
|
+
onMouseEnter: () => setHighlightedIndex(idx),
|
|
674
|
+
onClick: () => {
|
|
675
|
+
onSpawnNode(node.type);
|
|
676
|
+
onClose();
|
|
677
|
+
},
|
|
678
|
+
style: {
|
|
679
|
+
display: "flex",
|
|
680
|
+
alignItems: "center",
|
|
681
|
+
justifyContent: "space-between",
|
|
682
|
+
padding: "7px 10px",
|
|
683
|
+
borderRadius: "var(--skipo-radius-sm)",
|
|
684
|
+
cursor: "pointer",
|
|
685
|
+
backgroundColor: isHighlighted ? "var(--skipo-surface-hover)" : "transparent",
|
|
686
|
+
border: isHighlighted ? "var(--skipo-border)" : "1px solid transparent",
|
|
687
|
+
marginBottom: "2px"
|
|
688
|
+
},
|
|
689
|
+
children: [
|
|
690
|
+
/* @__PURE__ */ jsxs5("div", { style: { minWidth: 0, flex: 1 }, children: [
|
|
691
|
+
/* @__PURE__ */ jsx5("div", { style: { fontSize: "11px", fontWeight: isHighlighted ? 600 : 500, color: isHighlighted ? "var(--skipo-accent)" : "inherit" }, children: node.label || node.type }),
|
|
692
|
+
node.description && /* @__PURE__ */ jsx5("div", { style: { fontSize: "9px", color: "var(--skipo-text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: node.description })
|
|
693
|
+
] }),
|
|
694
|
+
isHighlighted && /* @__PURE__ */ jsx5("span", { style: { fontSize: "9px", fontWeight: 600, color: "var(--skipo-accent)", marginLeft: "6px" }, children: "\u21B5 Spawn" })
|
|
695
|
+
]
|
|
696
|
+
},
|
|
697
|
+
node.type
|
|
698
|
+
);
|
|
699
|
+
})
|
|
700
|
+
] }, category)) }),
|
|
701
|
+
/* @__PURE__ */ jsxs5("div", { style: { padding: "6px 10px", borderTop: "var(--skipo-border)", backgroundColor: "var(--skipo-matte-bg)", fontSize: "9px", color: "var(--skipo-text-muted)" }, children: [
|
|
702
|
+
/* @__PURE__ */ jsxs5("span", { children: [
|
|
703
|
+
filteredNodes.length,
|
|
704
|
+
" visible nodes"
|
|
705
|
+
] }),
|
|
706
|
+
/* @__PURE__ */ jsx5("span", { style: { float: "right" }, children: "Enter \u21B5 to spawn" })
|
|
707
|
+
] })
|
|
708
|
+
]
|
|
709
|
+
}
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// src/node-graph-ui/widgets/CanvasContextMenu.tsx
|
|
714
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
715
|
+
function CanvasContextMenu({
|
|
716
|
+
x,
|
|
717
|
+
y,
|
|
718
|
+
availableNodeTypes,
|
|
719
|
+
hasSelection,
|
|
720
|
+
onSpawnNode,
|
|
721
|
+
onOpenSpawnMenu,
|
|
722
|
+
onSelectAll,
|
|
723
|
+
onDeleteSelected,
|
|
724
|
+
onClearSelection,
|
|
725
|
+
onClose
|
|
726
|
+
}) {
|
|
727
|
+
const itemStyle = {
|
|
728
|
+
padding: "6px 12px",
|
|
729
|
+
fontSize: "11px",
|
|
730
|
+
cursor: "pointer",
|
|
731
|
+
display: "flex",
|
|
732
|
+
alignItems: "center",
|
|
733
|
+
justifyContent: "space-between",
|
|
734
|
+
gap: "12px",
|
|
735
|
+
color: "var(--skipo-text, #fff)",
|
|
736
|
+
borderRadius: "4px",
|
|
737
|
+
userSelect: "none"
|
|
738
|
+
};
|
|
739
|
+
const shortcutStyle = {
|
|
740
|
+
fontSize: "9px",
|
|
741
|
+
color: "var(--skipo-text-muted, #888)",
|
|
742
|
+
fontFamily: "monospace"
|
|
743
|
+
};
|
|
744
|
+
return /* @__PURE__ */ jsxs6(
|
|
745
|
+
"div",
|
|
746
|
+
{
|
|
747
|
+
style: {
|
|
748
|
+
position: "absolute",
|
|
749
|
+
left: x,
|
|
750
|
+
top: y,
|
|
751
|
+
minWidth: "180px",
|
|
752
|
+
backgroundColor: "var(--skipo-surface, #1e1e1e)",
|
|
753
|
+
border: "1px solid var(--skipo-border, #333)",
|
|
754
|
+
borderRadius: "6px",
|
|
755
|
+
boxShadow: "0 6px 20px rgba(0, 0, 0, 0.6)",
|
|
756
|
+
padding: "4px",
|
|
757
|
+
zIndex: 60,
|
|
758
|
+
fontFamily: "Inter, system-ui, sans-serif"
|
|
759
|
+
},
|
|
760
|
+
onClick: (e) => e.stopPropagation(),
|
|
761
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
762
|
+
children: [
|
|
763
|
+
onOpenSpawnMenu && /* @__PURE__ */ jsxs6(
|
|
764
|
+
"div",
|
|
765
|
+
{
|
|
766
|
+
style: {
|
|
767
|
+
...itemStyle,
|
|
768
|
+
fontWeight: 600,
|
|
769
|
+
color: "var(--skipo-accent, #61afef)",
|
|
770
|
+
backgroundColor: "rgba(97, 175, 239, 0.08)"
|
|
771
|
+
},
|
|
772
|
+
onMouseEnter: (e) => e.currentTarget.style.backgroundColor = "rgba(97, 175, 239, 0.16)",
|
|
773
|
+
onMouseLeave: (e) => e.currentTarget.style.backgroundColor = "rgba(97, 175, 239, 0.08)",
|
|
774
|
+
onClick: () => {
|
|
775
|
+
onOpenSpawnMenu();
|
|
776
|
+
onClose();
|
|
777
|
+
},
|
|
778
|
+
children: [
|
|
779
|
+
/* @__PURE__ */ jsx6("span", { children: "Spawn Node Menu..." }),
|
|
780
|
+
/* @__PURE__ */ jsx6("span", { style: shortcutStyle, children: "N" })
|
|
781
|
+
]
|
|
782
|
+
}
|
|
783
|
+
),
|
|
784
|
+
/* @__PURE__ */ jsx6("div", { style: { padding: "4px 8px", fontSize: "9px", textTransform: "uppercase", color: "var(--skipo-text-muted, #888)", fontWeight: 600 }, children: "Quick Spawn" }),
|
|
785
|
+
/* @__PURE__ */ jsx6("div", { style: { maxHeight: "140px", overflowY: "auto" }, children: !availableNodeTypes || availableNodeTypes.length === 0 ? /* @__PURE__ */ jsx6(
|
|
786
|
+
"div",
|
|
787
|
+
{
|
|
788
|
+
style: itemStyle,
|
|
789
|
+
onClick: () => {
|
|
790
|
+
onSpawnNode("default");
|
|
791
|
+
onClose();
|
|
792
|
+
},
|
|
793
|
+
children: /* @__PURE__ */ jsx6("span", { children: "Default Node" })
|
|
794
|
+
}
|
|
795
|
+
) : availableNodeTypes.map((def) => /* @__PURE__ */ jsx6(
|
|
796
|
+
"div",
|
|
797
|
+
{
|
|
798
|
+
style: itemStyle,
|
|
799
|
+
onMouseEnter: (e) => e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.08)",
|
|
800
|
+
onMouseLeave: (e) => e.currentTarget.style.backgroundColor = "transparent",
|
|
801
|
+
onClick: () => {
|
|
802
|
+
onSpawnNode(def.type);
|
|
803
|
+
onClose();
|
|
804
|
+
},
|
|
805
|
+
children: /* @__PURE__ */ jsx6("span", { children: def.label || def.type })
|
|
806
|
+
},
|
|
807
|
+
def.type
|
|
808
|
+
)) }),
|
|
809
|
+
/* @__PURE__ */ jsx6("div", { style: { height: "1px", backgroundColor: "var(--skipo-border, #333)", margin: "4px 0" } }),
|
|
810
|
+
/* @__PURE__ */ jsxs6(
|
|
811
|
+
"div",
|
|
812
|
+
{
|
|
813
|
+
style: itemStyle,
|
|
814
|
+
onMouseEnter: (e) => e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.08)",
|
|
815
|
+
onMouseLeave: (e) => e.currentTarget.style.backgroundColor = "transparent",
|
|
816
|
+
onClick: () => {
|
|
817
|
+
onSelectAll();
|
|
818
|
+
onClose();
|
|
819
|
+
},
|
|
820
|
+
children: [
|
|
821
|
+
/* @__PURE__ */ jsx6("span", { children: "Select All" }),
|
|
822
|
+
/* @__PURE__ */ jsx6("span", { style: shortcutStyle, children: "\u2318A" })
|
|
823
|
+
]
|
|
824
|
+
}
|
|
825
|
+
),
|
|
826
|
+
hasSelection && /* @__PURE__ */ jsxs6(Fragment, { children: [
|
|
827
|
+
/* @__PURE__ */ jsxs6(
|
|
828
|
+
"div",
|
|
829
|
+
{
|
|
830
|
+
style: { ...itemStyle, color: "#e06c75" },
|
|
831
|
+
onMouseEnter: (e) => e.currentTarget.style.backgroundColor = "rgba(224, 108, 117, 0.15)",
|
|
832
|
+
onMouseLeave: (e) => e.currentTarget.style.backgroundColor = "transparent",
|
|
833
|
+
onClick: () => {
|
|
834
|
+
onDeleteSelected();
|
|
835
|
+
onClose();
|
|
836
|
+
},
|
|
837
|
+
children: [
|
|
838
|
+
/* @__PURE__ */ jsx6("span", { children: "Delete Selected" }),
|
|
839
|
+
/* @__PURE__ */ jsx6("span", { style: shortcutStyle, children: "Del" })
|
|
840
|
+
]
|
|
841
|
+
}
|
|
842
|
+
),
|
|
843
|
+
/* @__PURE__ */ jsx6(
|
|
844
|
+
"div",
|
|
845
|
+
{
|
|
846
|
+
style: itemStyle,
|
|
847
|
+
onMouseEnter: (e) => e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.08)",
|
|
848
|
+
onMouseLeave: (e) => e.currentTarget.style.backgroundColor = "transparent",
|
|
849
|
+
onClick: () => {
|
|
850
|
+
onClearSelection();
|
|
851
|
+
onClose();
|
|
852
|
+
},
|
|
853
|
+
children: /* @__PURE__ */ jsx6("span", { children: "Clear Selection" })
|
|
854
|
+
}
|
|
855
|
+
)
|
|
856
|
+
] })
|
|
857
|
+
]
|
|
858
|
+
}
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// src/NodeGraphCanvas.tsx
|
|
863
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
864
|
+
function NodeGraphCanvas({
|
|
865
|
+
nodes,
|
|
866
|
+
edges,
|
|
867
|
+
viewport,
|
|
868
|
+
config,
|
|
869
|
+
selectedNodeIds,
|
|
870
|
+
availableNodeTypes,
|
|
871
|
+
onNodesChange,
|
|
872
|
+
onEdgesChange,
|
|
873
|
+
onNodeDoubleClick,
|
|
874
|
+
onViewportChange,
|
|
875
|
+
onSelectionChange,
|
|
876
|
+
getSocketTelemetry
|
|
877
|
+
}) {
|
|
878
|
+
const containerRef = useRef2(null);
|
|
879
|
+
const [isPanning, setIsPanning] = useState4(false);
|
|
880
|
+
const [dragNodeId, setDragNodeId] = useState4(null);
|
|
881
|
+
const nodeMouseDownPos = useRef2(null);
|
|
882
|
+
const hasDraggedNode = useRef2(false);
|
|
883
|
+
const animFrameRef = useRef2(null);
|
|
884
|
+
const smoothPanTo = useCallback((targetX, targetY) => {
|
|
885
|
+
if (!onViewportChange) return;
|
|
886
|
+
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
|
887
|
+
const startX = viewport.panX;
|
|
888
|
+
const startY = viewport.panY;
|
|
889
|
+
const startTime = performance.now();
|
|
890
|
+
const duration = 220;
|
|
891
|
+
const step = (now) => {
|
|
892
|
+
const elapsed = now - startTime;
|
|
893
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
894
|
+
const ease = 1 - Math.pow(1 - progress, 3);
|
|
895
|
+
onViewportChange({
|
|
896
|
+
...viewport,
|
|
897
|
+
panX: Math.round(startX + (targetX - startX) * ease),
|
|
898
|
+
panY: Math.round(startY + (targetY - startY) * ease)
|
|
899
|
+
});
|
|
900
|
+
if (progress < 1) {
|
|
901
|
+
animFrameRef.current = requestAnimationFrame(step);
|
|
902
|
+
} else {
|
|
903
|
+
animFrameRef.current = null;
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
animFrameRef.current = requestAnimationFrame(step);
|
|
907
|
+
}, [viewport, onViewportChange]);
|
|
908
|
+
useEffect(() => {
|
|
909
|
+
return () => {
|
|
910
|
+
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
|
911
|
+
};
|
|
912
|
+
}, []);
|
|
913
|
+
const [boxSelection, setBoxSelection] = useState4(null);
|
|
914
|
+
const [connecting, setConnecting] = useState4(null);
|
|
915
|
+
const [pickerState, setPickerState] = useState4(null);
|
|
916
|
+
const [contextMenu, setContextMenu] = useState4(null);
|
|
917
|
+
const [spawnMenuState, setSpawnMenuState] = useState4(null);
|
|
918
|
+
const lastMousePos = useRef2({ screenX: 0, screenY: 0 });
|
|
919
|
+
useEffect(() => {
|
|
920
|
+
if (!ConnectionRuleStore3.isInitialized()) ConnectionRuleStore3.initializeDefaults();
|
|
921
|
+
}, []);
|
|
922
|
+
useEffect(() => {
|
|
923
|
+
const handleKeyDown = (e) => {
|
|
924
|
+
if (e.key.toLowerCase() === "n" && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
925
|
+
const activeEl = document.activeElement;
|
|
926
|
+
const isInput = activeEl && (activeEl.tagName === "INPUT" || activeEl.tagName === "TEXTAREA" || activeEl.getAttribute("contenteditable") === "true");
|
|
927
|
+
if (!isInput) {
|
|
928
|
+
e.preventDefault();
|
|
929
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
930
|
+
const screenX = lastMousePos.current.screenX || (rect ? rect.width / 2 : 250);
|
|
931
|
+
const screenY = lastMousePos.current.screenY || (rect ? rect.height / 2 : 200);
|
|
932
|
+
const graphX = (screenX - viewport.panX) / viewport.zoom;
|
|
933
|
+
const graphY = (screenY - viewport.panY) / viewport.zoom;
|
|
934
|
+
setContextMenu(null);
|
|
935
|
+
setPickerState(null);
|
|
936
|
+
setSpawnMenuState({ x: screenX, y: screenY, graphX, graphY });
|
|
937
|
+
}
|
|
938
|
+
} else if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") {
|
|
939
|
+
e.preventDefault();
|
|
940
|
+
onSelectionChange?.(new Set(nodes.map((n) => n.id)));
|
|
941
|
+
} else if (e.key === "Delete" || e.key === "Backspace") {
|
|
942
|
+
if (selectedNodeIds.size > 0 && onNodesChange) {
|
|
943
|
+
const remainingNodes = nodes.filter((n) => !selectedNodeIds.has(n.id));
|
|
944
|
+
onNodesChange(remainingNodes);
|
|
945
|
+
onEdgesChange?.(edges.filter((ed) => !selectedNodeIds.has(ed.source) && !selectedNodeIds.has(ed.target)));
|
|
946
|
+
onSelectionChange?.(/* @__PURE__ */ new Set());
|
|
947
|
+
}
|
|
948
|
+
} else if (e.key === "Escape") {
|
|
949
|
+
setContextMenu(null);
|
|
950
|
+
setPickerState(null);
|
|
951
|
+
setSpawnMenuState(null);
|
|
952
|
+
setConnecting(null);
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
956
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
957
|
+
}, [nodes, edges, selectedNodeIds, viewport, onNodesChange, onEdgesChange, onSelectionChange]);
|
|
958
|
+
const handleWheel = (e) => {
|
|
959
|
+
e.preventDefault();
|
|
960
|
+
if (!onViewportChange) return;
|
|
961
|
+
const zoomDelta = e.deltaY * -1e-3;
|
|
962
|
+
const minZoom = config?.minZoom ?? 0.25;
|
|
963
|
+
const maxZoom = config?.maxZoom ?? 2.5;
|
|
964
|
+
const newZoom = Math.max(minZoom, Math.min(maxZoom, viewport.zoom + zoomDelta));
|
|
965
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
966
|
+
if (!rect) return;
|
|
967
|
+
const mouseX = e.clientX - rect.left;
|
|
968
|
+
const mouseY = e.clientY - rect.top;
|
|
969
|
+
const graphX = (mouseX - viewport.panX) / viewport.zoom;
|
|
970
|
+
const graphY = (mouseY - viewport.panY) / viewport.zoom;
|
|
971
|
+
onViewportChange({ zoom: newZoom, panX: mouseX - graphX * newZoom, panY: mouseY - graphY * newZoom });
|
|
972
|
+
};
|
|
973
|
+
const handleMouseDown = (e) => {
|
|
974
|
+
setContextMenu(null);
|
|
975
|
+
setSpawnMenuState(null);
|
|
976
|
+
if (e.button === 1) {
|
|
977
|
+
setIsPanning(true);
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
if (e.button === 0 && e.target === containerRef.current) {
|
|
981
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
982
|
+
const x = e.clientX - rect.left;
|
|
983
|
+
const y = e.clientY - rect.top;
|
|
984
|
+
setBoxSelection({ startX: x, startY: y, endX: x, endY: y });
|
|
985
|
+
onSelectionChange?.(/* @__PURE__ */ new Set());
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
const handleMouseMove = (e) => {
|
|
989
|
+
if (containerRef.current) {
|
|
990
|
+
const r = containerRef.current.getBoundingClientRect();
|
|
991
|
+
lastMousePos.current = { screenX: e.clientX - r.left, screenY: e.clientY - r.top };
|
|
992
|
+
}
|
|
993
|
+
if (isPanning && onViewportChange) {
|
|
994
|
+
onViewportChange({ ...viewport, panX: viewport.panX + e.movementX, panY: viewport.panY + e.movementY });
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
if (boxSelection && containerRef.current) {
|
|
998
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
999
|
+
setBoxSelection((prev) => prev ? { ...prev, endX: e.clientX - rect.left, endY: e.clientY - rect.top } : null);
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
if (dragNodeId && onNodesChange) {
|
|
1003
|
+
if (nodeMouseDownPos.current) {
|
|
1004
|
+
const dist = Math.hypot(e.clientX - nodeMouseDownPos.current.x, e.clientY - nodeMouseDownPos.current.y);
|
|
1005
|
+
if (dist > 4) {
|
|
1006
|
+
hasDraggedNode.current = true;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
const dx = e.movementX / viewport.zoom;
|
|
1010
|
+
const dy = e.movementY / viewport.zoom;
|
|
1011
|
+
onNodesChange(nodes.map((n) => n.id === dragNodeId ? { ...n, position: { x: n.position.x + dx, y: n.position.y + dy } } : n));
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (connecting && containerRef.current) {
|
|
1015
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
1016
|
+
setConnecting((prev) => prev ? { ...prev, endX: e.clientX - rect.left, endY: e.clientY - rect.top } : null);
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
const handleMouseUp = (e) => {
|
|
1020
|
+
setIsPanning(false);
|
|
1021
|
+
if (nodeMouseDownPos.current && !hasDraggedNode.current) {
|
|
1022
|
+
const clickedId = nodeMouseDownPos.current.nodeId;
|
|
1023
|
+
const clickedNode = nodes.find((n) => n.id === clickedId);
|
|
1024
|
+
if (clickedNode && containerRef.current && onViewportChange) {
|
|
1025
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
1026
|
+
if (!isNodeInCenterDeadZone(clickedNode, viewport, rect.width, rect.height)) {
|
|
1027
|
+
const targetPan = getCenterPanForNode(clickedNode, viewport, rect.width, rect.height);
|
|
1028
|
+
smoothPanTo(targetPan.panX, targetPan.panY);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
nodeMouseDownPos.current = null;
|
|
1033
|
+
hasDraggedNode.current = false;
|
|
1034
|
+
setDragNodeId(null);
|
|
1035
|
+
if (boxSelection) {
|
|
1036
|
+
const selected = getNodesInSelection(boxSelection.startX, boxSelection.startY, boxSelection.endX, boxSelection.endY, nodes, viewport);
|
|
1037
|
+
onSelectionChange?.(new Set(selected));
|
|
1038
|
+
setBoxSelection(null);
|
|
1039
|
+
}
|
|
1040
|
+
if (connecting && containerRef.current) {
|
|
1041
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
1042
|
+
const dropX = e.clientX - rect.left;
|
|
1043
|
+
const dropY = e.clientY - rect.top;
|
|
1044
|
+
const graphX = (dropX - viewport.panX) / viewport.zoom;
|
|
1045
|
+
const graphY = (dropY - viewport.panY) / viewport.zoom;
|
|
1046
|
+
setPickerState({
|
|
1047
|
+
x: dropX,
|
|
1048
|
+
y: dropY,
|
|
1049
|
+
graphX,
|
|
1050
|
+
graphY,
|
|
1051
|
+
sourceHandle: { nodeId: connecting.nodeId, socketId: connecting.socketId, direction: connecting.type, dataType: connecting.dataType }
|
|
1052
|
+
});
|
|
1053
|
+
setConnecting(null);
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
const handleContextMenu = (e) => {
|
|
1057
|
+
e.preventDefault();
|
|
1058
|
+
if (!containerRef.current) return;
|
|
1059
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
1060
|
+
const x = e.clientX - rect.left;
|
|
1061
|
+
const y = e.clientY - rect.top;
|
|
1062
|
+
setContextMenu({ x, y, graphX: (x - viewport.panX) / viewport.zoom, graphY: (y - viewport.panY) / viewport.zoom });
|
|
1063
|
+
};
|
|
1064
|
+
const handleNodeMouseDown = (e, nodeId) => {
|
|
1065
|
+
e.stopPropagation();
|
|
1066
|
+
if (e.button === 0) {
|
|
1067
|
+
nodeMouseDownPos.current = { x: e.clientX, y: e.clientY, nodeId };
|
|
1068
|
+
hasDraggedNode.current = false;
|
|
1069
|
+
setDragNodeId(nodeId);
|
|
1070
|
+
if (e.metaKey || e.ctrlKey) {
|
|
1071
|
+
const next = new Set(selectedNodeIds);
|
|
1072
|
+
if (next.has(nodeId)) next.delete(nodeId);
|
|
1073
|
+
else next.add(nodeId);
|
|
1074
|
+
onSelectionChange?.(next);
|
|
1075
|
+
} else if (!selectedNodeIds.has(nodeId)) {
|
|
1076
|
+
onSelectionChange?.(/* @__PURE__ */ new Set([nodeId]));
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
const handleSocketMouseDown = (e, nodeId, socketId, type) => {
|
|
1081
|
+
e.stopPropagation();
|
|
1082
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
1083
|
+
if (!rect) return;
|
|
1084
|
+
const node = nodes.find((n) => n.id === nodeId);
|
|
1085
|
+
const socket = (type === "input" ? node?.inputs : node?.outputs)?.find((s) => s.id === socketId);
|
|
1086
|
+
const x = e.clientX - rect.left;
|
|
1087
|
+
const y = e.clientY - rect.top;
|
|
1088
|
+
setConnecting({ nodeId, socketId, type, dataType: socket?.dataType, startX: x, startY: y, endX: x, endY: y });
|
|
1089
|
+
};
|
|
1090
|
+
const handleSocketMouseUp = (e, targetNodeId, targetSocketId, targetType) => {
|
|
1091
|
+
e.stopPropagation();
|
|
1092
|
+
if (!connecting || connecting.nodeId === targetNodeId || connecting.type === targetType) {
|
|
1093
|
+
setConnecting(null);
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
const sourceNode = nodes.find((n) => n.id === connecting.nodeId);
|
|
1097
|
+
const targetNode = nodes.find((n) => n.id === targetNodeId);
|
|
1098
|
+
const sourceSocket = (connecting.type === "output" ? sourceNode?.outputs : sourceNode?.inputs)?.find((s) => s.id === connecting.socketId);
|
|
1099
|
+
const targetSocket = (targetType === "input" ? targetNode?.inputs : targetNode?.outputs)?.find((s) => s.id === targetSocketId);
|
|
1100
|
+
const canConnect = ConnectionRuleStore3.canConnect(
|
|
1101
|
+
{ handleCategory: "DATA", dataType: sourceSocket?.dataType || "ANY", direction: connecting.type === "output" ? "OUTPUT" : "INPUT" },
|
|
1102
|
+
{ handleCategory: "DATA", dataType: targetSocket?.dataType || "ANY", direction: targetType === "input" ? "INPUT" : "OUTPUT" }
|
|
1103
|
+
);
|
|
1104
|
+
if (canConnect) {
|
|
1105
|
+
const isOut = connecting.type === "output";
|
|
1106
|
+
const newEdge = {
|
|
1107
|
+
id: `edge-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
1108
|
+
source: isOut ? connecting.nodeId : targetNodeId,
|
|
1109
|
+
sourceSocket: isOut ? connecting.socketId : targetSocketId,
|
|
1110
|
+
target: isOut ? targetNodeId : connecting.nodeId,
|
|
1111
|
+
targetSocket: isOut ? targetSocketId : connecting.socketId,
|
|
1112
|
+
locked: true
|
|
1113
|
+
};
|
|
1114
|
+
onEdgesChange?.([...edges, newEdge]);
|
|
1115
|
+
}
|
|
1116
|
+
setConnecting(null);
|
|
1117
|
+
};
|
|
1118
|
+
const handlePickerSelect = useCallback((selectedTypes) => {
|
|
1119
|
+
if (!pickerState || !onNodesChange) return;
|
|
1120
|
+
const { graphX, graphY, sourceHandle } = pickerState;
|
|
1121
|
+
const newNodes = [];
|
|
1122
|
+
const newEdges = [];
|
|
1123
|
+
selectedTypes.forEach((type, idx) => {
|
|
1124
|
+
const id = `node-${Date.now()}-${idx}`;
|
|
1125
|
+
const posX = graphX + idx * 200;
|
|
1126
|
+
const posY = graphY + idx * 40;
|
|
1127
|
+
const def = availableNodeTypes?.find((d) => d.type === type) || ConnectionRuleStore3.getNodeType(type);
|
|
1128
|
+
const isSourceOut = sourceHandle.direction === "output";
|
|
1129
|
+
const inputs = def?.inputs?.map((i) => ({ id: i.id, label: i.label || i.id, type: "input", dataType: i.dataType })) ?? [{ id: "in-1", label: "In", type: "input", dataType: sourceHandle.dataType || "ANY" }];
|
|
1130
|
+
const outputs = def?.outputs?.map((o) => ({ id: o.id, label: o.label || o.id, type: "output", dataType: o.dataType })) ?? [{ id: "out-1", label: "Out", type: "output", dataType: sourceHandle.dataType || "ANY" }];
|
|
1131
|
+
newNodes.push({ id, type, label: def?.label || type, position: { x: posX, y: posY }, inputs, outputs });
|
|
1132
|
+
const targetSocket = isSourceOut ? inputs[0] : outputs[0];
|
|
1133
|
+
if (targetSocket) {
|
|
1134
|
+
newEdges.push({
|
|
1135
|
+
id: `edge-${Date.now()}-${idx}`,
|
|
1136
|
+
source: isSourceOut ? sourceHandle.nodeId : id,
|
|
1137
|
+
sourceSocket: isSourceOut ? sourceHandle.socketId : targetSocket.id,
|
|
1138
|
+
target: isSourceOut ? id : sourceHandle.nodeId,
|
|
1139
|
+
targetSocket: isSourceOut ? targetSocket.id : sourceHandle.socketId,
|
|
1140
|
+
locked: true
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
onNodesChange([...nodes, ...newNodes]);
|
|
1145
|
+
if (newEdges.length > 0) onEdgesChange?.([...edges, ...newEdges]);
|
|
1146
|
+
setPickerState(null);
|
|
1147
|
+
}, [pickerState, nodes, edges, availableNodeTypes, onNodesChange, onEdgesChange]);
|
|
1148
|
+
const handleSocketNudgeChange = (nodeId, socketId, nudge) => {
|
|
1149
|
+
if (!onNodesChange) return;
|
|
1150
|
+
const updatedNodes = nodes.map((n) => {
|
|
1151
|
+
if (n.id !== nodeId) return n;
|
|
1152
|
+
const updateList = (list) => list?.map((s) => s.id === socketId ? { ...s, offset: nudge } : s);
|
|
1153
|
+
return {
|
|
1154
|
+
...n,
|
|
1155
|
+
inputs: updateList(n.inputs),
|
|
1156
|
+
outputs: updateList(n.outputs)
|
|
1157
|
+
};
|
|
1158
|
+
});
|
|
1159
|
+
onNodesChange(updatedNodes);
|
|
1160
|
+
};
|
|
1161
|
+
const nodesData = nodes.reduce((acc, node) => {
|
|
1162
|
+
const p = canvasToScreen(node.position.x, node.position.y, viewport);
|
|
1163
|
+
acc[node.id] = {
|
|
1164
|
+
x: p.x,
|
|
1165
|
+
y: p.y,
|
|
1166
|
+
width: (node.width ?? 150) * viewport.zoom,
|
|
1167
|
+
height: (node.height ?? 100) * viewport.zoom,
|
|
1168
|
+
inputs: node.inputs || [],
|
|
1169
|
+
outputs: node.outputs || [],
|
|
1170
|
+
zoom: viewport.zoom
|
|
1171
|
+
};
|
|
1172
|
+
return acc;
|
|
1173
|
+
}, {});
|
|
1174
|
+
return /* @__PURE__ */ jsxs7(
|
|
1175
|
+
"div",
|
|
1176
|
+
{
|
|
1177
|
+
ref: containerRef,
|
|
1178
|
+
style: { width: "100%", height: "100%", position: "relative", overflow: "hidden", backgroundColor: "var(--skipo-surface-dark, #181a1f)" },
|
|
1179
|
+
onWheel: handleWheel,
|
|
1180
|
+
onMouseDown: handleMouseDown,
|
|
1181
|
+
onMouseMove: handleMouseMove,
|
|
1182
|
+
onMouseUp: handleMouseUp,
|
|
1183
|
+
onContextMenu: handleContextMenu,
|
|
1184
|
+
children: [
|
|
1185
|
+
/* @__PURE__ */ jsx7(WireRenderer, { edges, nodesData, connecting: connecting ? { startX: connecting.startX, startY: connecting.startY, endX: connecting.endX, endY: connecting.endY } : null }),
|
|
1186
|
+
/* @__PURE__ */ jsx7("div", { style: { position: "absolute", top: 0, left: 0, transformOrigin: "0 0", transform: `translate(${viewport.panX}px, ${viewport.panY}px) scale(${viewport.zoom})` }, children: nodes.map((node) => /* @__PURE__ */ jsx7(
|
|
1187
|
+
NodeCard,
|
|
1188
|
+
{
|
|
1189
|
+
node,
|
|
1190
|
+
selected: selectedNodeIds.has(node.id),
|
|
1191
|
+
onMouseDown: handleNodeMouseDown,
|
|
1192
|
+
onDoubleClick: onNodeDoubleClick,
|
|
1193
|
+
onSocketMouseDown: handleSocketMouseDown,
|
|
1194
|
+
onSocketMouseUp: handleSocketMouseUp,
|
|
1195
|
+
onSocketNudgeChange: handleSocketNudgeChange,
|
|
1196
|
+
getSocketTelemetry: getSocketTelemetry ? (nodeId, socketId, isOutput) => getSocketTelemetry(nodes.find((n) => n.id === nodeId), socketId, isOutput) : void 0
|
|
1197
|
+
},
|
|
1198
|
+
node.id
|
|
1199
|
+
)) }),
|
|
1200
|
+
boxSelection && /* @__PURE__ */ jsx7("div", { style: { position: "absolute", left: Math.min(boxSelection.startX, boxSelection.endX), top: Math.min(boxSelection.startY, boxSelection.endY), width: Math.abs(boxSelection.endX - boxSelection.startX), height: Math.abs(boxSelection.endY - boxSelection.startY), backgroundColor: "rgba(97, 175, 239, 0.18)", border: "1px solid var(--skipo-accent, #61afef)", pointerEvents: "none" } }),
|
|
1201
|
+
pickerState && /* @__PURE__ */ jsx7(CompatibleNodePicker, { x: pickerState.x, y: pickerState.y, sourceHandle: pickerState.sourceHandle, availableNodeTypes, onSelect: handlePickerSelect, onClose: () => setPickerState(null) }),
|
|
1202
|
+
contextMenu && /* @__PURE__ */ jsx7(
|
|
1203
|
+
CanvasContextMenu,
|
|
1204
|
+
{
|
|
1205
|
+
x: contextMenu.x,
|
|
1206
|
+
y: contextMenu.y,
|
|
1207
|
+
availableNodeTypes,
|
|
1208
|
+
hasSelection: selectedNodeIds.size > 0,
|
|
1209
|
+
onSpawnNode: (type) => {
|
|
1210
|
+
const def = availableNodeTypes?.find((d) => d.type === type) || ConnectionRuleStore3.getNodeType(type);
|
|
1211
|
+
const id = `node-${Date.now()}`;
|
|
1212
|
+
const inputs = def?.inputs?.map((i) => ({ id: i.id, label: i.label || i.id, type: "input", dataType: i.dataType })) ?? [{ id: "in-1", label: "In", type: "input" }];
|
|
1213
|
+
const outputs = def?.outputs?.map((o) => ({ id: o.id, label: o.label || o.id, type: "output", dataType: o.dataType })) ?? [{ id: "out-1", label: "Out", type: "output" }];
|
|
1214
|
+
onNodesChange?.([...nodes, { id, type, label: def?.label || type, position: { x: contextMenu.graphX, y: contextMenu.graphY }, inputs, outputs }]);
|
|
1215
|
+
},
|
|
1216
|
+
onOpenSpawnMenu: () => {
|
|
1217
|
+
setSpawnMenuState({
|
|
1218
|
+
x: contextMenu.x,
|
|
1219
|
+
y: contextMenu.y,
|
|
1220
|
+
graphX: contextMenu.graphX,
|
|
1221
|
+
graphY: contextMenu.graphY
|
|
1222
|
+
});
|
|
1223
|
+
},
|
|
1224
|
+
onSelectAll: () => onSelectionChange?.(new Set(nodes.map((n) => n.id))),
|
|
1225
|
+
onDeleteSelected: () => {
|
|
1226
|
+
onNodesChange?.(nodes.filter((n) => !selectedNodeIds.has(n.id)));
|
|
1227
|
+
onEdgesChange?.(edges.filter((ed) => !selectedNodeIds.has(ed.source) && !selectedNodeIds.has(ed.target)));
|
|
1228
|
+
onSelectionChange?.(/* @__PURE__ */ new Set());
|
|
1229
|
+
},
|
|
1230
|
+
onClearSelection: () => onSelectionChange?.(/* @__PURE__ */ new Set()),
|
|
1231
|
+
onClose: () => setContextMenu(null)
|
|
1232
|
+
}
|
|
1233
|
+
),
|
|
1234
|
+
spawnMenuState && /* @__PURE__ */ jsx7(
|
|
1235
|
+
NodeSearchPalette,
|
|
1236
|
+
{
|
|
1237
|
+
x: spawnMenuState.x,
|
|
1238
|
+
y: spawnMenuState.y,
|
|
1239
|
+
availableNodeTypes,
|
|
1240
|
+
onSpawnNode: (type) => {
|
|
1241
|
+
const def = availableNodeTypes?.find((d) => d.type === type) || ConnectionRuleStore3.getNodeType(type);
|
|
1242
|
+
const id = `node-${Date.now()}`;
|
|
1243
|
+
const inputs = def?.inputs?.map((i) => ({ id: i.id, label: i.label || i.id, type: "input", dataType: i.dataType })) ?? [{ id: "in-1", label: "In", type: "input" }];
|
|
1244
|
+
const outputs = def?.outputs?.map((o) => ({ id: o.id, label: o.label || o.id, type: "output", dataType: o.dataType })) ?? [{ id: "out-1", label: "Out", type: "output" }];
|
|
1245
|
+
onNodesChange?.([...nodes, { id, type, label: def?.label || type, position: { x: spawnMenuState.graphX, y: spawnMenuState.graphY }, inputs, outputs }]);
|
|
1246
|
+
setSpawnMenuState(null);
|
|
1247
|
+
},
|
|
1248
|
+
onClose: () => setSpawnMenuState(null)
|
|
1249
|
+
}
|
|
1250
|
+
)
|
|
1251
|
+
]
|
|
1252
|
+
}
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
// src/frnl-editable-node-graph/FrnlEditableNodeGraph.tsx
|
|
1257
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1258
|
+
var frnlEditableNodeGraphDefinition = defineFrnlComponent({
|
|
1259
|
+
name: "frnlEditableNodeGraph",
|
|
1260
|
+
states: {
|
|
1261
|
+
idle: {
|
|
1262
|
+
name: "idle",
|
|
1263
|
+
events: {
|
|
1264
|
+
nodesChange: { functionId: "frnlEditableNodeGraph.idle.nodesChange" },
|
|
1265
|
+
edgesChange: { functionId: "frnlEditableNodeGraph.idle.edgesChange" },
|
|
1266
|
+
selectionChange: { functionId: "frnlEditableNodeGraph.idle.selectionChange" },
|
|
1267
|
+
viewportChange: { functionId: "frnlEditableNodeGraph.idle.viewportChange" },
|
|
1268
|
+
magneticTraceSolidify: { functionId: "frnlEditableNodeGraph.idle.magneticTraceSolidify" },
|
|
1269
|
+
predictiveSolidify: { functionId: "frnlEditableNodeGraph.idle.predictiveSolidify" },
|
|
1270
|
+
predictiveSolidifyAll: { functionId: "frnlEditableNodeGraph.idle.predictiveSolidifyAll" }
|
|
1271
|
+
},
|
|
1272
|
+
visualParameters: {
|
|
1273
|
+
canvasBackground: "var(--frnl-editable-node-graph-background, var(--skipo-surface-dark, #181a1f))",
|
|
1274
|
+
magneticColor: "var(--frnl-editable-node-graph-magnetic, #38bdf8)"
|
|
1275
|
+
},
|
|
1276
|
+
phases: { sustainPhase: { visualDefinition: { parameters: {} } } }
|
|
1277
|
+
},
|
|
1278
|
+
disabled: {
|
|
1279
|
+
name: "disabled",
|
|
1280
|
+
events: {
|
|
1281
|
+
nodesChange: { functionId: "frnlEditableNodeGraph.disabled.nodesChange" },
|
|
1282
|
+
edgesChange: { functionId: "frnlEditableNodeGraph.disabled.edgesChange" },
|
|
1283
|
+
selectionChange: { functionId: "frnlEditableNodeGraph.disabled.selectionChange" },
|
|
1284
|
+
viewportChange: { functionId: "frnlEditableNodeGraph.disabled.viewportChange" },
|
|
1285
|
+
magneticTraceSolidify: { functionId: "frnlEditableNodeGraph.disabled.magneticTraceSolidify" },
|
|
1286
|
+
predictiveSolidify: { functionId: "frnlEditableNodeGraph.disabled.predictiveSolidify" },
|
|
1287
|
+
predictiveSolidifyAll: { functionId: "frnlEditableNodeGraph.disabled.predictiveSolidifyAll" }
|
|
1288
|
+
},
|
|
1289
|
+
visualParameters: { opacity: 0.6 },
|
|
1290
|
+
phases: { sustainPhase: { visualDefinition: { parameters: {} } } }
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
});
|
|
1294
|
+
function socketPoint(node, socketId, output, viewport) {
|
|
1295
|
+
const sockets = output ? node.outputs ?? [] : node.inputs ?? [];
|
|
1296
|
+
const foundIndex = sockets.findIndex((socket) => socket.id === socketId);
|
|
1297
|
+
const index = foundIndex >= 0 ? foundIndex : 0;
|
|
1298
|
+
const width = node.width ?? 150;
|
|
1299
|
+
const height = node.height ?? 100;
|
|
1300
|
+
const y = height / 2 + (index - Math.max(0, sockets.length - 1) / 2) * 28;
|
|
1301
|
+
const x = output ? width : 0;
|
|
1302
|
+
return {
|
|
1303
|
+
x: node.position.x * viewport.zoom + viewport.panX + x * viewport.zoom,
|
|
1304
|
+
y: node.position.y * viewport.zoom + viewport.panY + y * viewport.zoom
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
var FrnlEditableNodeGraph = ({
|
|
1308
|
+
id = "frnlEditableNodeGraph",
|
|
1309
|
+
parentId,
|
|
1310
|
+
nodes,
|
|
1311
|
+
edges,
|
|
1312
|
+
viewport = { panX: 0, panY: 0, zoom: 1 },
|
|
1313
|
+
selectedNodeIds = /* @__PURE__ */ new Set(),
|
|
1314
|
+
availableNodeTypes,
|
|
1315
|
+
magneticEnabled = true,
|
|
1316
|
+
autoSolidifyEnabled = false,
|
|
1317
|
+
magneticCutoff = 320,
|
|
1318
|
+
signalTelemetryEnabled = false,
|
|
1319
|
+
getSocketTelemetry,
|
|
1320
|
+
className,
|
|
1321
|
+
style,
|
|
1322
|
+
onNodesChange,
|
|
1323
|
+
onEdgesChange,
|
|
1324
|
+
onViewportChange,
|
|
1325
|
+
onSelectionChange,
|
|
1326
|
+
onNodeDoubleClick,
|
|
1327
|
+
onMagneticTracesChange,
|
|
1328
|
+
onMagneticTraceSolidify,
|
|
1329
|
+
onPredictiveSolidify,
|
|
1330
|
+
onPredictiveSolidifyAllForNode,
|
|
1331
|
+
onPredictiveSolidifyAll
|
|
1332
|
+
}) => {
|
|
1333
|
+
const store = useFloksFrnlStore();
|
|
1334
|
+
const [traces, setTraces] = useState5([]);
|
|
1335
|
+
const manager = useMemo3(() => new MagneticGraphManager(magneticCutoff), [magneticCutoff]);
|
|
1336
|
+
const predictive = usePredictiveGraph2D({
|
|
1337
|
+
nodes,
|
|
1338
|
+
connections: edges,
|
|
1339
|
+
selectedNodeId: selectedNodeIds.size === 1 ? Array.from(selectedNodeIds)[0] : null,
|
|
1340
|
+
selectedNodeIds: Array.from(selectedNodeIds),
|
|
1341
|
+
onSolidifyPredictiveNodes: (ghosts) => {
|
|
1342
|
+
for (const ghost of ghosts) onPredictiveSolidify?.(ghost.id);
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
useEffect2(() => {
|
|
1346
|
+
if (!ConnectionRuleStore4.isInitialized()) ConnectionRuleStore4.initializeDefaults();
|
|
1347
|
+
}, []);
|
|
1348
|
+
const handlers = useMemo3(() => ({
|
|
1349
|
+
"frnlEditableNodeGraph.idle.nodesChange": (value) => onNodesChange?.(value),
|
|
1350
|
+
"frnlEditableNodeGraph.idle.edgesChange": (value) => onEdgesChange?.(value),
|
|
1351
|
+
"frnlEditableNodeGraph.idle.selectionChange": (value) => onSelectionChange?.(value),
|
|
1352
|
+
"frnlEditableNodeGraph.idle.viewportChange": (value) => onViewportChange?.(value),
|
|
1353
|
+
"frnlEditableNodeGraph.idle.magneticTraceSolidify": (value) => onMagneticTraceSolidify?.(value),
|
|
1354
|
+
"frnlEditableNodeGraph.idle.predictiveSolidify": (value) => onPredictiveSolidify?.(String(value)),
|
|
1355
|
+
"frnlEditableNodeGraph.idle.predictiveSolidifyAll": () => onPredictiveSolidifyAll?.(),
|
|
1356
|
+
"frnlEditableNodeGraph.disabled.nodesChange": () => {
|
|
1357
|
+
},
|
|
1358
|
+
"frnlEditableNodeGraph.disabled.edgesChange": () => {
|
|
1359
|
+
},
|
|
1360
|
+
"frnlEditableNodeGraph.disabled.selectionChange": () => {
|
|
1361
|
+
},
|
|
1362
|
+
"frnlEditableNodeGraph.disabled.viewportChange": () => {
|
|
1363
|
+
},
|
|
1364
|
+
"frnlEditableNodeGraph.disabled.magneticTraceSolidify": () => {
|
|
1365
|
+
},
|
|
1366
|
+
"frnlEditableNodeGraph.disabled.predictiveSolidify": () => {
|
|
1367
|
+
},
|
|
1368
|
+
"frnlEditableNodeGraph.disabled.predictiveSolidifyAll": () => {
|
|
1369
|
+
}
|
|
1370
|
+
}), [
|
|
1371
|
+
onEdgesChange,
|
|
1372
|
+
onMagneticTraceSolidify,
|
|
1373
|
+
onNodesChange,
|
|
1374
|
+
onSelectionChange,
|
|
1375
|
+
onViewportChange,
|
|
1376
|
+
onPredictiveSolidify,
|
|
1377
|
+
onPredictiveSolidifyAll
|
|
1378
|
+
]);
|
|
1379
|
+
const frnl = useFrnlComponent({
|
|
1380
|
+
id,
|
|
1381
|
+
parentId,
|
|
1382
|
+
definition: frnlEditableNodeGraphDefinition,
|
|
1383
|
+
store,
|
|
1384
|
+
state: "idle",
|
|
1385
|
+
properties: { nodeCount: nodes.length, edgeCount: edges.length },
|
|
1386
|
+
handlers
|
|
1387
|
+
});
|
|
1388
|
+
useEffect2(() => {
|
|
1389
|
+
if (!magneticEnabled) {
|
|
1390
|
+
setTraces([]);
|
|
1391
|
+
onMagneticTracesChange?.([]);
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
const next = manager.computeTraces(nodes);
|
|
1395
|
+
setTraces(next);
|
|
1396
|
+
onMagneticTracesChange?.(next);
|
|
1397
|
+
if (autoSolidifyEnabled && next.length > 0) {
|
|
1398
|
+
const resolved = manager.resolveAutoSolidification(nodes, next, edges);
|
|
1399
|
+
for (const trace of resolved) {
|
|
1400
|
+
onMagneticTraceSolidify?.(trace);
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
}, [autoSolidifyEnabled, edges, magneticEnabled, manager, nodes, onMagneticTracesChange, onMagneticTraceSolidify]);
|
|
1404
|
+
const nodeMap = useMemo3(() => new Map(nodes.map((node) => [node.id, node])), [nodes]);
|
|
1405
|
+
return /* @__PURE__ */ jsxs8(
|
|
1406
|
+
"div",
|
|
1407
|
+
{
|
|
1408
|
+
id,
|
|
1409
|
+
"data-frnl-component": "frnlEditableNodeGraph",
|
|
1410
|
+
"data-frnl-state": frnl.state,
|
|
1411
|
+
className,
|
|
1412
|
+
style: {
|
|
1413
|
+
position: "relative",
|
|
1414
|
+
width: "100%",
|
|
1415
|
+
height: "100%",
|
|
1416
|
+
background: frnl.visualParameters.canvasBackground,
|
|
1417
|
+
opacity: frnl.visualParameters.opacity,
|
|
1418
|
+
...style
|
|
1419
|
+
},
|
|
1420
|
+
children: [
|
|
1421
|
+
/* @__PURE__ */ jsx8(
|
|
1422
|
+
NodeGraphCanvas,
|
|
1423
|
+
{
|
|
1424
|
+
nodes,
|
|
1425
|
+
edges,
|
|
1426
|
+
viewport,
|
|
1427
|
+
selectedNodeIds,
|
|
1428
|
+
availableNodeTypes,
|
|
1429
|
+
onNodesChange: (next) => frnl.events.nodesChange(next),
|
|
1430
|
+
onEdgesChange: (next) => frnl.events.edgesChange(next),
|
|
1431
|
+
onViewportChange: (next) => frnl.events.viewportChange(next),
|
|
1432
|
+
onSelectionChange: (next) => frnl.events.selectionChange(next),
|
|
1433
|
+
onNodeDoubleClick,
|
|
1434
|
+
getSocketTelemetry: signalTelemetryEnabled && getSocketTelemetry ? (node, socketId, isOutput) => getSocketTelemetry(node, socketId, isOutput) : void 0
|
|
1435
|
+
}
|
|
1436
|
+
),
|
|
1437
|
+
traces.length > 0 && /* @__PURE__ */ jsx8("svg", { "aria-hidden": "true", style: { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", zIndex: 40 }, children: traces.map((trace) => {
|
|
1438
|
+
const source = nodeMap.get(trace.sourceNodeId);
|
|
1439
|
+
const target = nodeMap.get(trace.targetNodeId);
|
|
1440
|
+
if (!source || !target) return null;
|
|
1441
|
+
const a = socketPoint(source, trace.sourceHandleId, true, viewport);
|
|
1442
|
+
const b = socketPoint(target, trace.targetHandleId, false, viewport);
|
|
1443
|
+
return /* @__PURE__ */ jsx8(
|
|
1444
|
+
"line",
|
|
1445
|
+
{
|
|
1446
|
+
x1: a.x,
|
|
1447
|
+
y1: a.y,
|
|
1448
|
+
x2: b.x,
|
|
1449
|
+
y2: b.y,
|
|
1450
|
+
stroke: String(frnl.visualParameters.magneticColor ?? "#38bdf8"),
|
|
1451
|
+
strokeWidth: 2,
|
|
1452
|
+
strokeDasharray: "6 4",
|
|
1453
|
+
opacity: 0.8
|
|
1454
|
+
},
|
|
1455
|
+
trace.id
|
|
1456
|
+
);
|
|
1457
|
+
}) }),
|
|
1458
|
+
predictive.isActive && predictive.traces.length > 0 && /* @__PURE__ */ jsx8("svg", { "aria-label": "Predictive connection traces", style: { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", zIndex: 44 }, children: predictive.traces.map((trace) => {
|
|
1459
|
+
const ghost = predictive.ghostNodes.find((candidate) => candidate.id === trace.ghostNodeId);
|
|
1460
|
+
if (!ghost) return null;
|
|
1461
|
+
const parentId2 = trace.isFromGhostToParent ? trace.targetNodeId : trace.sourceNodeId;
|
|
1462
|
+
const parent = nodeMap.get(parentId2);
|
|
1463
|
+
if (!parent) return null;
|
|
1464
|
+
const ghostNode = ghost.prototypeNode;
|
|
1465
|
+
const a = trace.isFromGhostToParent ? socketPoint(ghostNode, trace.sourceHandleId, true, viewport) : socketPoint(parent, trace.sourceHandleId, true, viewport);
|
|
1466
|
+
const b = trace.isFromGhostToParent ? socketPoint(parent, trace.targetHandleId, false, viewport) : socketPoint(ghostNode, trace.targetHandleId, false, viewport);
|
|
1467
|
+
return /* @__PURE__ */ jsx8("line", { x1: a.x, y1: a.y, x2: b.x, y2: b.y, stroke: trace.color ?? "var(--skipo-accent, #61afef)", strokeWidth: 2, strokeDasharray: "4 4", opacity: 0.65 }, trace.id);
|
|
1468
|
+
}) }),
|
|
1469
|
+
predictive.isActive && predictive.ghostNodes.length > 0 && /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
1470
|
+
/* @__PURE__ */ jsxs8("div", { style: { position: "absolute", top: 10, right: 10, zIndex: 60, display: "flex", gap: 4, pointerEvents: "auto" }, children: [
|
|
1471
|
+
/* @__PURE__ */ jsx8("button", { type: "button", onClick: predictive.prevScenario, children: "\u2190" }),
|
|
1472
|
+
/* @__PURE__ */ jsxs8("span", { style: { padding: "3px 6px", fontSize: 11 }, children: [
|
|
1473
|
+
"Scenario ",
|
|
1474
|
+
predictive.scenarioIndex + 1
|
|
1475
|
+
] }),
|
|
1476
|
+
/* @__PURE__ */ jsx8("button", { type: "button", onClick: predictive.nextScenario, children: "\u2192" }),
|
|
1477
|
+
/* @__PURE__ */ jsx8("button", { type: "button", onClick: () => {
|
|
1478
|
+
predictive.solidifyAll();
|
|
1479
|
+
onPredictiveSolidifyAll?.();
|
|
1480
|
+
}, children: "Solidify all" })
|
|
1481
|
+
] }),
|
|
1482
|
+
/* @__PURE__ */ jsx8("div", { "aria-label": "Predictive nodes", style: { position: "absolute", inset: 0, pointerEvents: "none", zIndex: 45 }, children: predictive.ghostNodes.map((ghost) => {
|
|
1483
|
+
const position = ghost.worldPosition ?? [ghost.prototypeNode?.position?.x ?? 0, 0, ghost.prototypeNode?.position?.y ?? 0];
|
|
1484
|
+
const x = Number(position[0]) * viewport.zoom + viewport.panX;
|
|
1485
|
+
const y = Number(position[2] ?? position[1] ?? 0) * viewport.zoom + viewport.panY;
|
|
1486
|
+
return /* @__PURE__ */ jsx8(
|
|
1487
|
+
"button",
|
|
1488
|
+
{
|
|
1489
|
+
type: "button",
|
|
1490
|
+
style: { position: "absolute", left: x, top: y, transform: "translate(-50%, -50%)", pointerEvents: "auto", opacity: 0.72, border: "1px dashed var(--skipo-accent, #61afef)", background: "var(--skipo-surface, #20242b)", color: "var(--skipo-text, #fff)", padding: "6px 10px", borderRadius: 6 },
|
|
1491
|
+
onClick: () => onPredictiveSolidify?.(ghost.id),
|
|
1492
|
+
children: ghost.prototypeNode?.label ?? ghost.label ?? ghost.id
|
|
1493
|
+
},
|
|
1494
|
+
ghost.id
|
|
1495
|
+
);
|
|
1496
|
+
}) })
|
|
1497
|
+
] }),
|
|
1498
|
+
predictive.isActive && predictive.selectedNodesWithGhosts.size > 0 && /* @__PURE__ */ jsx8("div", { "aria-label": "Predictive node actions", style: { position: "absolute", left: 10, bottom: 10, zIndex: 60, display: "flex", flexDirection: "column", gap: 4, pointerEvents: "auto" }, children: Array.from(predictive.selectedNodesWithGhosts.entries()).map(([nodeId, ghosts]) => /* @__PURE__ */ jsxs8("button", { type: "button", onClick: () => {
|
|
1499
|
+
predictive.solidifyAllForNode(nodeId);
|
|
1500
|
+
onPredictiveSolidifyAllForNode?.(nodeId);
|
|
1501
|
+
}, children: [
|
|
1502
|
+
"Solidify all for ",
|
|
1503
|
+
nodeId,
|
|
1504
|
+
" (",
|
|
1505
|
+
ghosts.length,
|
|
1506
|
+
")"
|
|
1507
|
+
] }, nodeId)) })
|
|
1508
|
+
]
|
|
1509
|
+
}
|
|
1510
|
+
);
|
|
1511
|
+
};
|
|
1512
|
+
FrnlEditableNodeGraph.displayName = "FrnlEditableNodeGraph";
|
|
1513
|
+
|
|
1514
|
+
export {
|
|
1515
|
+
CompatibleNodePicker,
|
|
1516
|
+
menuCategory,
|
|
1517
|
+
menuHidden,
|
|
1518
|
+
NodeSearchPalette,
|
|
1519
|
+
CanvasContextMenu,
|
|
1520
|
+
frnlEditableNodeGraphDefinition,
|
|
1521
|
+
FrnlEditableNodeGraph
|
|
1522
|
+
};
|