@lace-cloud/canvas 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -7
- package/dist/{chunk-HZWABSPP.mjs → chunk-ID563WHD.mjs} +795 -583
- package/dist/chunk-ID563WHD.mjs.map +1 -0
- package/dist/engine/index.cjs +784 -580
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.mts +2 -2
- package/dist/engine/index.d.ts +2 -2
- package/dist/engine/index.mjs +5 -1
- package/dist/index.cjs +1261 -962
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -9
- package/dist/index.d.ts +3 -9
- package/dist/index.mjs +333 -242
- package/dist/index.mjs.map +1 -1
- package/dist/{mapping-Z-STJQRP.d.mts → registry-BhFAgvlq.d.mts} +96 -16
- package/dist/{mapping-Z-STJQRP.d.ts → registry-BhFAgvlq.d.ts} +96 -16
- package/package.json +3 -3
- package/dist/chunk-HZWABSPP.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
MODULE_COMMAND_ACTIONS,
|
|
11
11
|
Reason,
|
|
12
12
|
SCHEMAS,
|
|
13
|
+
actionState,
|
|
14
|
+
answering,
|
|
13
15
|
bridgeCaller,
|
|
14
16
|
carriesFailure,
|
|
15
17
|
connectCaller,
|
|
@@ -34,7 +36,7 @@ import {
|
|
|
34
36
|
rowActions,
|
|
35
37
|
toArgv,
|
|
36
38
|
uniqueDiagnostics
|
|
37
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-ID563WHD.mjs";
|
|
38
40
|
|
|
39
41
|
// src/index.ts
|
|
40
42
|
import { projectCanvasView as projectCanvasView2 } from "@lace-cloud/proto";
|
|
@@ -44,10 +46,11 @@ import { Toast } from "@lace-cloud/ui/feedback";
|
|
|
44
46
|
import { ReactFlowProvider } from "@xyflow/react";
|
|
45
47
|
import {
|
|
46
48
|
Fragment as Fragment14,
|
|
47
|
-
useCallback as
|
|
49
|
+
useCallback as useCallback15,
|
|
48
50
|
useEffect as useEffect11,
|
|
51
|
+
useLayoutEffect as useLayoutEffect3,
|
|
49
52
|
useMemo as useMemo9,
|
|
50
|
-
useRef as
|
|
53
|
+
useRef as useRef11,
|
|
51
54
|
useState as useState22,
|
|
52
55
|
useSyncExternalStore
|
|
53
56
|
} from "react";
|
|
@@ -56,7 +59,7 @@ import "./App-IFIOMNV7.css";
|
|
|
56
59
|
// src/Canvas.tsx
|
|
57
60
|
import "@xyflow/react/dist/style.css";
|
|
58
61
|
import "./Canvas-JRY2HAY6.css";
|
|
59
|
-
import { instanceAddress as instanceAddress4, localIn as localIn3 } from "@lace-cloud/proto";
|
|
62
|
+
import { drawnRect as drawnRect2, extentOf as extentOf2, instanceAddress as instanceAddress4, localIn as localIn3 } from "@lace-cloud/proto";
|
|
60
63
|
import {
|
|
61
64
|
applyEdgeChanges,
|
|
62
65
|
applyNodeChanges,
|
|
@@ -64,7 +67,7 @@ import {
|
|
|
64
67
|
useNodesInitialized,
|
|
65
68
|
useReactFlow as useReactFlow2
|
|
66
69
|
} from "@xyflow/react";
|
|
67
|
-
import { useCallback as
|
|
70
|
+
import { useCallback as useCallback6, useEffect as useEffect7, useMemo as useMemo3, useRef as useRef7, useState as useState8 } from "react";
|
|
68
71
|
|
|
69
72
|
// src/components/CanvasControls.tsx
|
|
70
73
|
import { IconButton } from "@lace-cloud/ui";
|
|
@@ -261,10 +264,6 @@ function isEmphasized(action, ctx) {
|
|
|
261
264
|
if (!action.primary) return false;
|
|
262
265
|
return action.primary.when === void 0 || keySatisfied(ctx, action.primary.when);
|
|
263
266
|
}
|
|
264
|
-
function busyLabelOf(action, ctx, commandBusy) {
|
|
265
|
-
if (action.busy && keySatisfied(ctx, action.busy.when)) return action.busy.label;
|
|
266
|
-
return commandBusy ? action.label : void 0;
|
|
267
|
-
}
|
|
268
267
|
|
|
269
268
|
// src/utils/key-chord.ts
|
|
270
269
|
function parseChord(spec) {
|
|
@@ -602,11 +601,10 @@ import {
|
|
|
602
601
|
collapsedGroupSize,
|
|
603
602
|
GROUP_HEADER_HEIGHT,
|
|
604
603
|
groupPinY,
|
|
605
|
-
instanceAddress as instanceAddress2,
|
|
606
604
|
NODE_ROW_HEIGHT
|
|
607
605
|
} from "@lace-cloud/proto";
|
|
608
606
|
import { Handle, Position } from "@xyflow/react";
|
|
609
|
-
import { useCallback, useEffect as useEffect3, useRef as
|
|
607
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
610
608
|
|
|
611
609
|
// src/core/editor-actions.ts
|
|
612
610
|
import {
|
|
@@ -687,8 +685,7 @@ function withGroupCollapsed(bundle, arrangement, canvasPath, collapsed) {
|
|
|
687
685
|
};
|
|
688
686
|
return next;
|
|
689
687
|
}
|
|
690
|
-
function withRenameCarried(
|
|
691
|
-
if (bundle.modules[scopeKey]?.modules?.some((u) => u.id === newId)) return arrangement;
|
|
688
|
+
function withRenameCarried(arrangement, scopeKey, oldId, newId) {
|
|
692
689
|
const scopeEntry = arrangement[scopeKey];
|
|
693
690
|
const position = scopeEntry?.nodes?.[oldId];
|
|
694
691
|
const group2 = scopeEntry?.groups?.[oldId];
|
|
@@ -766,36 +763,6 @@ function inEntryScope(view, ids) {
|
|
|
766
763
|
return ids.filter((id) => entry.has(id));
|
|
767
764
|
}
|
|
768
765
|
|
|
769
|
-
// src/core/pipeline.ts
|
|
770
|
-
import { projectCanvasView } from "@lace-cloud/proto";
|
|
771
|
-
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
772
|
-
function projectFrame(frame, arrangement) {
|
|
773
|
-
return projectCanvasView(frame.bundle, arrangement, {
|
|
774
|
-
canUndo: frame.canUndo,
|
|
775
|
-
canRedo: frame.canRedo,
|
|
776
|
-
unsaved: frame.unsaved,
|
|
777
|
-
conflict: frame.conflict ? { base_tree_hash: frame.conflict.baseTreeHash, tree_hash: frame.conflict.treeHash } : void 0,
|
|
778
|
-
ungenerated: frame.ungenerated
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
function useCanvasSource(source, onCommandResult, onSessionEnd) {
|
|
782
|
-
const [state, setState] = useState3({ source: null, end: null, session: null });
|
|
783
|
-
useEffect2(() => {
|
|
784
|
-
const session = {};
|
|
785
|
-
setState({ source: null, end: null, session });
|
|
786
|
-
const unsubscribe = source.subscribe(
|
|
787
|
-
(next) => setState({ source: next, end: null, session }),
|
|
788
|
-
(end) => setState((prev) => ({ source: prev.source, end, session })),
|
|
789
|
-
(result) => onCommandResult(result, session)
|
|
790
|
-
);
|
|
791
|
-
return () => {
|
|
792
|
-
unsubscribe();
|
|
793
|
-
onSessionEnd(session);
|
|
794
|
-
};
|
|
795
|
-
}, [source, onCommandResult, onSessionEnd]);
|
|
796
|
-
return state;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
766
|
// src/core/editor-actions.ts
|
|
800
767
|
function emptyApplyResult(message) {
|
|
801
768
|
if (!message) return { success: true, errors: [], created: [], ties: [] };
|
|
@@ -976,8 +943,6 @@ async function groupRun(env) {
|
|
|
976
943
|
groups: { ...parentEntry.groups, [created.id]: { collapsed: true } }
|
|
977
944
|
});
|
|
978
945
|
env.arrangement.update(written);
|
|
979
|
-
const card = drawnRect(projectFrame(frame, written), groupPath);
|
|
980
|
-
if (card) env.layout.panIntoView(card);
|
|
981
946
|
return result;
|
|
982
947
|
}
|
|
983
948
|
function groupTarget(id) {
|
|
@@ -1223,6 +1188,84 @@ function useEditorEnvExtras() {
|
|
|
1223
1188
|
|
|
1224
1189
|
// src/components/nodes/GroupNode.tsx
|
|
1225
1190
|
import "./GroupNode-QWSLBFCH.css";
|
|
1191
|
+
|
|
1192
|
+
// src/components/nodes/use-rename-instance.ts
|
|
1193
|
+
import { instanceAddress as instanceAddress2 } from "@lace-cloud/proto";
|
|
1194
|
+
import { useCallback, useRef as useRef2 } from "react";
|
|
1195
|
+
|
|
1196
|
+
// src/core/pipeline.ts
|
|
1197
|
+
import { projectCanvasView } from "@lace-cloud/proto";
|
|
1198
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1199
|
+
function projectFrame(frame, arrangement) {
|
|
1200
|
+
return projectCanvasView(frame.bundle, arrangement, {
|
|
1201
|
+
canUndo: frame.canUndo,
|
|
1202
|
+
canRedo: frame.canRedo,
|
|
1203
|
+
unsaved: frame.unsaved,
|
|
1204
|
+
conflict: frame.conflict ? { base_tree_hash: frame.conflict.baseTreeHash, tree_hash: frame.conflict.treeHash } : void 0,
|
|
1205
|
+
ungenerated: frame.ungenerated
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
function reconcileSelection(view, selection) {
|
|
1209
|
+
const held = new Set([...view.nodes, ...view.groups].map((n) => n.id));
|
|
1210
|
+
const nodes = selection.nodes.filter((id) => held.has(id));
|
|
1211
|
+
const { edge } = selection;
|
|
1212
|
+
const keptEdge = edge && view.edges.some((e) => e.id === edge.id) ? edge : null;
|
|
1213
|
+
if (nodes.length === selection.nodes.length && keptEdge === edge) return selection;
|
|
1214
|
+
return { nodes, edge: keptEdge };
|
|
1215
|
+
}
|
|
1216
|
+
function carrySelection(selection, oldPath, newPath) {
|
|
1217
|
+
const copies = selection.nodes.flatMap(
|
|
1218
|
+
(id) => id === oldPath || id.startsWith(`${oldPath}.`) ? [newPath + id.slice(oldPath.length)] : []
|
|
1219
|
+
);
|
|
1220
|
+
if (copies.length === 0) return selection;
|
|
1221
|
+
return { ...selection, nodes: [...selection.nodes, ...copies] };
|
|
1222
|
+
}
|
|
1223
|
+
function useCanvasSource(source, onCommandResult, onSessionEnd) {
|
|
1224
|
+
const [state, setState] = useState3({ source: null, end: null, session: null });
|
|
1225
|
+
useEffect2(() => {
|
|
1226
|
+
const session = {};
|
|
1227
|
+
setState({ source: null, end: null, session });
|
|
1228
|
+
const unsubscribe = source.subscribe(
|
|
1229
|
+
(next) => setState({ source: next, end: null, session }),
|
|
1230
|
+
(end) => setState((prev) => ({ source: prev.source, end, session })),
|
|
1231
|
+
(result) => onCommandResult(result, session)
|
|
1232
|
+
);
|
|
1233
|
+
return () => {
|
|
1234
|
+
unsubscribe();
|
|
1235
|
+
onSessionEnd(session);
|
|
1236
|
+
};
|
|
1237
|
+
}, [source, onCommandResult, onSessionEnd]);
|
|
1238
|
+
return state;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// src/components/nodes/use-rename-instance.ts
|
|
1242
|
+
function useRenameInstance() {
|
|
1243
|
+
const { bundle, view, arrangement, updateArrangement, selection, setSelection, runner } = useCanvas();
|
|
1244
|
+
const latest = useRef2({ view, selection });
|
|
1245
|
+
latest.current = { view, selection };
|
|
1246
|
+
return useCallback(
|
|
1247
|
+
async (canvasPath, newId) => {
|
|
1248
|
+
const { scope, id: oldId } = instanceAddress2(bundle, canvasPath);
|
|
1249
|
+
if (!newId || newId === oldId) return;
|
|
1250
|
+
const taken = bundle.modules[scope]?.modules?.some((u) => u.id === newId) ?? false;
|
|
1251
|
+
const newPath = canvasPath.slice(0, canvasPath.length - oldId.length) + newId;
|
|
1252
|
+
const carriedArrangement = taken ? arrangement : withRenameCarried(arrangement, scope, oldId, newId);
|
|
1253
|
+
const carriedSelection = taken ? selection : carrySelection(selection, canvasPath, newPath);
|
|
1254
|
+
if (carriedArrangement !== arrangement) updateArrangement(carriedArrangement);
|
|
1255
|
+
if (carriedSelection !== selection) setSelection(carriedSelection);
|
|
1256
|
+
const result = await runner.apply([
|
|
1257
|
+
{ rename_instance: { scope, old_id: oldId, new_id: newId } }
|
|
1258
|
+
]);
|
|
1259
|
+
if (result?.success || carriedSelection === selection) return;
|
|
1260
|
+
const now = latest.current;
|
|
1261
|
+
const held = reconcileSelection(now.view, now.selection);
|
|
1262
|
+
if (held !== now.selection) setSelection(held);
|
|
1263
|
+
},
|
|
1264
|
+
[bundle, arrangement, updateArrangement, selection, setSelection, runner]
|
|
1265
|
+
);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// src/components/nodes/GroupNode.tsx
|
|
1226
1269
|
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1227
1270
|
var GroupHeader = ({
|
|
1228
1271
|
label,
|
|
@@ -1344,11 +1387,12 @@ var InterfacePinRow = ({ pin, y }) => {
|
|
|
1344
1387
|
};
|
|
1345
1388
|
var GroupNode = ({ data }) => {
|
|
1346
1389
|
const { editable, ctx, runner, bundle, arrangement, updateArrangement } = useCanvas();
|
|
1390
|
+
const rename = useRenameInstance();
|
|
1347
1391
|
const envExtras = useEditorEnvExtras();
|
|
1348
1392
|
const [editing, setEditing] = useState4(false);
|
|
1349
1393
|
const [editValue, setEditValue] = useState4(data.label);
|
|
1350
1394
|
const [hovered, setHovered] = useState4(false);
|
|
1351
|
-
const inputRef =
|
|
1395
|
+
const inputRef = useRef3(null);
|
|
1352
1396
|
const collapsed = data.collapsed;
|
|
1353
1397
|
useEffect3(() => {
|
|
1354
1398
|
if (editing && inputRef.current) {
|
|
@@ -1356,7 +1400,7 @@ var GroupNode = ({ data }) => {
|
|
|
1356
1400
|
inputRef.current.select();
|
|
1357
1401
|
}
|
|
1358
1402
|
}, [editing]);
|
|
1359
|
-
const onDoubleClick =
|
|
1403
|
+
const onDoubleClick = useCallback2(
|
|
1360
1404
|
(e) => {
|
|
1361
1405
|
if (!editable) return;
|
|
1362
1406
|
e.stopPropagation();
|
|
@@ -1365,22 +1409,15 @@ var GroupNode = ({ data }) => {
|
|
|
1365
1409
|
},
|
|
1366
1410
|
[data.label, editable]
|
|
1367
1411
|
);
|
|
1368
|
-
const renamingRef =
|
|
1369
|
-
const commitRename =
|
|
1412
|
+
const renamingRef = useRef3(false);
|
|
1413
|
+
const commitRename = useCallback2(async () => {
|
|
1370
1414
|
if (renamingRef.current) return;
|
|
1371
1415
|
renamingRef.current = true;
|
|
1372
1416
|
setEditing(false);
|
|
1373
|
-
|
|
1374
|
-
const address = instanceAddress2(bundle, data.groupId);
|
|
1375
|
-
if (trimmed && trimmed !== address.id) {
|
|
1376
|
-
updateArrangement(withRenameCarried(bundle, arrangement, address.scope, address.id, trimmed));
|
|
1377
|
-
await runner.apply([
|
|
1378
|
-
{ rename_instance: { scope: address.scope, old_id: address.id, new_id: trimmed } }
|
|
1379
|
-
]);
|
|
1380
|
-
}
|
|
1417
|
+
await rename(data.groupId, editValue.trim());
|
|
1381
1418
|
renamingRef.current = false;
|
|
1382
|
-
}, [editValue, data.groupId,
|
|
1383
|
-
const onKeyDown =
|
|
1419
|
+
}, [editValue, data.groupId, rename]);
|
|
1420
|
+
const onKeyDown = useCallback2(
|
|
1384
1421
|
(e) => {
|
|
1385
1422
|
e.stopPropagation();
|
|
1386
1423
|
if (e.key === "Enter") commitRename();
|
|
@@ -1388,14 +1425,14 @@ var GroupNode = ({ data }) => {
|
|
|
1388
1425
|
},
|
|
1389
1426
|
[commitRename]
|
|
1390
1427
|
);
|
|
1391
|
-
const toggleCollapsed =
|
|
1428
|
+
const toggleCollapsed = useCallback2(
|
|
1392
1429
|
(e) => {
|
|
1393
1430
|
e.stopPropagation();
|
|
1394
1431
|
updateArrangement(withGroupCollapsed(bundle, arrangement, data.groupId, !data.collapsed));
|
|
1395
1432
|
},
|
|
1396
1433
|
[bundle, data.groupId, data.collapsed, arrangement, updateArrangement]
|
|
1397
1434
|
);
|
|
1398
|
-
const onUngroup =
|
|
1435
|
+
const onUngroup = useCallback2(
|
|
1399
1436
|
async (e) => {
|
|
1400
1437
|
e.stopPropagation();
|
|
1401
1438
|
const action = ctx.contributions.actions.find((a) => a.id === "ungroup");
|
|
@@ -1474,7 +1511,7 @@ import {
|
|
|
1474
1511
|
useStore as useStore3,
|
|
1475
1512
|
useUpdateNodeInternals
|
|
1476
1513
|
} from "@xyflow/react";
|
|
1477
|
-
import { useCallback as
|
|
1514
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useMemo, useRef as useRef5, useState as useState5 } from "react";
|
|
1478
1515
|
|
|
1479
1516
|
// src/core/decorate.ts
|
|
1480
1517
|
import { nodeIdForDiagnostic } from "@lace-cloud/proto";
|
|
@@ -1555,16 +1592,16 @@ function typedName(name, type) {
|
|
|
1555
1592
|
import "./ModuleNode-RRZ37SFM.css";
|
|
1556
1593
|
|
|
1557
1594
|
// src/components/nodes/node-config-bus.tsx
|
|
1558
|
-
import { createContext as createContext2, useContext as useContext2, useRef as
|
|
1595
|
+
import { createContext as createContext2, useContext as useContext2, useRef as useRef4 } from "react";
|
|
1559
1596
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1560
1597
|
var NodeConfigBusContext = createContext2(null);
|
|
1561
1598
|
function NodeConfigBusProvider({
|
|
1562
1599
|
onOpen,
|
|
1563
1600
|
children
|
|
1564
1601
|
}) {
|
|
1565
|
-
const onOpenRef =
|
|
1602
|
+
const onOpenRef = useRef4(onOpen);
|
|
1566
1603
|
onOpenRef.current = onOpen;
|
|
1567
|
-
const stableRef =
|
|
1604
|
+
const stableRef = useRef4((instanceId) => onOpenRef.current(instanceId));
|
|
1568
1605
|
return /* @__PURE__ */ jsx7(NodeConfigBusContext.Provider, { value: stableRef.current, children });
|
|
1569
1606
|
}
|
|
1570
1607
|
function useOpenNodeConfig() {
|
|
@@ -1697,7 +1734,8 @@ ${about}` : about,
|
|
|
1697
1734
|
);
|
|
1698
1735
|
};
|
|
1699
1736
|
var ModuleNode = ({ id, data }) => {
|
|
1700
|
-
const { editable, ctx, runner, bundle
|
|
1737
|
+
const { editable, ctx, runner, bundle } = useCanvas();
|
|
1738
|
+
const rename = useRenameInstance();
|
|
1701
1739
|
const connecting = useStore3(nodeDragging);
|
|
1702
1740
|
const openNodeConfig = useOpenNodeConfig();
|
|
1703
1741
|
const envExtras = useEditorEnvExtras();
|
|
@@ -1707,8 +1745,8 @@ var ModuleNode = ({ id, data }) => {
|
|
|
1707
1745
|
const [imgFailed, setImgFailed] = useState5(false);
|
|
1708
1746
|
const [collapsed, setCollapsed] = useState5(false);
|
|
1709
1747
|
const [showAllInputs, setShowAllInputs] = useState5(false);
|
|
1710
|
-
const inputRef =
|
|
1711
|
-
const renamingRef =
|
|
1748
|
+
const inputRef = useRef5(null);
|
|
1749
|
+
const renamingRef = useRef5(false);
|
|
1712
1750
|
useEffect4(() => {
|
|
1713
1751
|
if (editing && inputRef.current) {
|
|
1714
1752
|
inputRef.current.focus();
|
|
@@ -1735,7 +1773,7 @@ var ModuleNode = ({ id, data }) => {
|
|
|
1735
1773
|
useEffect4(() => {
|
|
1736
1774
|
updateNodeInternals(id);
|
|
1737
1775
|
}, [id, drawnHandles, updateNodeInternals]);
|
|
1738
|
-
const onDoubleClick =
|
|
1776
|
+
const onDoubleClick = useCallback3(
|
|
1739
1777
|
(e) => {
|
|
1740
1778
|
if (!editable) return;
|
|
1741
1779
|
e.stopPropagation();
|
|
@@ -1744,21 +1782,14 @@ var ModuleNode = ({ id, data }) => {
|
|
|
1744
1782
|
},
|
|
1745
1783
|
[id, editable, bundle]
|
|
1746
1784
|
);
|
|
1747
|
-
const commitRename =
|
|
1785
|
+
const commitRename = useCallback3(async () => {
|
|
1748
1786
|
if (renamingRef.current) return;
|
|
1749
1787
|
renamingRef.current = true;
|
|
1750
1788
|
setEditing(false);
|
|
1751
|
-
|
|
1752
|
-
const address = instanceAddress3(bundle, id);
|
|
1753
|
-
if (trimmed && trimmed !== address.id) {
|
|
1754
|
-
updateArrangement(withRenameCarried(bundle, arrangement, address.scope, address.id, trimmed));
|
|
1755
|
-
await runner.apply([
|
|
1756
|
-
{ rename_instance: { scope: address.scope, old_id: address.id, new_id: trimmed } }
|
|
1757
|
-
]);
|
|
1758
|
-
}
|
|
1789
|
+
await rename(id, editValue.trim());
|
|
1759
1790
|
renamingRef.current = false;
|
|
1760
|
-
}, [editValue, id,
|
|
1761
|
-
const onKeyDown =
|
|
1791
|
+
}, [editValue, id, rename]);
|
|
1792
|
+
const onKeyDown = useCallback3(
|
|
1762
1793
|
(e) => {
|
|
1763
1794
|
e.stopPropagation();
|
|
1764
1795
|
if (e.key === "Enter") commitRename();
|
|
@@ -1766,7 +1797,7 @@ var ModuleNode = ({ id, data }) => {
|
|
|
1766
1797
|
},
|
|
1767
1798
|
[commitRename]
|
|
1768
1799
|
);
|
|
1769
|
-
const onHeaderClick =
|
|
1800
|
+
const onHeaderClick = useCallback3(
|
|
1770
1801
|
(e) => {
|
|
1771
1802
|
if (!e.shiftKey && !e.metaKey && !e.ctrlKey) {
|
|
1772
1803
|
openNodeConfig(data.id);
|
|
@@ -1774,7 +1805,7 @@ var ModuleNode = ({ id, data }) => {
|
|
|
1774
1805
|
},
|
|
1775
1806
|
[data.id, openNodeConfig]
|
|
1776
1807
|
);
|
|
1777
|
-
const onDeleteInstance =
|
|
1808
|
+
const onDeleteInstance = useCallback3(
|
|
1778
1809
|
async (e) => {
|
|
1779
1810
|
e.stopPropagation();
|
|
1780
1811
|
const action = ctx.contributions.actions.find((a) => a.id === "delete-node");
|
|
@@ -1783,11 +1814,11 @@ var ModuleNode = ({ id, data }) => {
|
|
|
1783
1814
|
},
|
|
1784
1815
|
[ctx, runner, envExtras, data.id]
|
|
1785
1816
|
);
|
|
1786
|
-
const toggleCollapsed =
|
|
1817
|
+
const toggleCollapsed = useCallback3((e) => {
|
|
1787
1818
|
e.stopPropagation();
|
|
1788
1819
|
setCollapsed((v) => !v);
|
|
1789
1820
|
}, []);
|
|
1790
|
-
const toggleShowAllInputs =
|
|
1821
|
+
const toggleShowAllInputs = useCallback3((e) => {
|
|
1791
1822
|
e.stopPropagation();
|
|
1792
1823
|
setShowAllInputs((v) => !v);
|
|
1793
1824
|
}, []);
|
|
@@ -2122,10 +2153,10 @@ function useActionKeys(actions, ctx, runner, envExtras) {
|
|
|
2122
2153
|
}
|
|
2123
2154
|
|
|
2124
2155
|
// src/hooks/useContextMenu.ts
|
|
2125
|
-
import { useCallback as
|
|
2156
|
+
import { useCallback as useCallback4, useState as useState6 } from "react";
|
|
2126
2157
|
function useContextMenu() {
|
|
2127
2158
|
const [contextMenu, setContextMenu] = useState6(null);
|
|
2128
|
-
const showContextMenu =
|
|
2159
|
+
const showContextMenu = useCallback4((request) => {
|
|
2129
2160
|
setContextMenu({
|
|
2130
2161
|
x: request.x,
|
|
2131
2162
|
y: request.y,
|
|
@@ -2133,7 +2164,7 @@ function useContextMenu() {
|
|
|
2133
2164
|
groupId: request.groupId
|
|
2134
2165
|
});
|
|
2135
2166
|
}, []);
|
|
2136
|
-
const dismissContextMenu =
|
|
2167
|
+
const dismissContextMenu = useCallback4(() => {
|
|
2137
2168
|
setContextMenu(null);
|
|
2138
2169
|
}, []);
|
|
2139
2170
|
return { contextMenu, showContextMenu, dismissContextMenu };
|
|
@@ -2255,29 +2286,34 @@ function renderEdgeToRfEdge(e) {
|
|
|
2255
2286
|
}
|
|
2256
2287
|
|
|
2257
2288
|
// src/hooks/useNewNodeTracking.ts
|
|
2258
|
-
import { useCallback as
|
|
2289
|
+
import { useCallback as useCallback5, useEffect as useEffect6, useRef as useRef6, useState as useState7 } from "react";
|
|
2259
2290
|
function useNewNodeTracking(view) {
|
|
2291
|
+
const [addedIds, setAddedIds] = useState7(/* @__PURE__ */ new Set());
|
|
2260
2292
|
const [newNodeIds, setNewNodeIds] = useState7(/* @__PURE__ */ new Set());
|
|
2261
|
-
const
|
|
2262
|
-
const sessionLoadedRef =
|
|
2293
|
+
const prevCardIdsRef = useRef6(/* @__PURE__ */ new Set());
|
|
2294
|
+
const sessionLoadedRef = useRef6(false);
|
|
2263
2295
|
useEffect6(() => {
|
|
2264
2296
|
if (!view) return;
|
|
2265
|
-
const
|
|
2297
|
+
const nodeIds = new Set(view.nodes.map((n) => n.id));
|
|
2298
|
+
const cardIds = /* @__PURE__ */ new Set([...nodeIds, ...view.groups.map((g) => g.id)]);
|
|
2266
2299
|
if (!sessionLoadedRef.current) {
|
|
2267
2300
|
sessionLoadedRef.current = true;
|
|
2268
|
-
|
|
2301
|
+
prevCardIdsRef.current = cardIds;
|
|
2269
2302
|
return;
|
|
2270
2303
|
}
|
|
2271
|
-
const prev =
|
|
2272
|
-
const added =
|
|
2273
|
-
|
|
2274
|
-
const
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2304
|
+
const prev = prevCardIdsRef.current;
|
|
2305
|
+
const added = [...cardIds].filter((id) => !prev.has(id));
|
|
2306
|
+
const track = (drawn) => (s) => {
|
|
2307
|
+
const arrived = added.filter((id) => drawn.has(id));
|
|
2308
|
+
const next = new Set([...s].filter((id) => drawn.has(id)));
|
|
2309
|
+
for (const id of arrived) next.add(id);
|
|
2310
|
+
return next.size !== s.size || arrived.length > 0 ? next : s;
|
|
2311
|
+
};
|
|
2312
|
+
setAddedIds(track(cardIds));
|
|
2313
|
+
setNewNodeIds(track(nodeIds));
|
|
2314
|
+
prevCardIdsRef.current = cardIds;
|
|
2279
2315
|
}, [view]);
|
|
2280
|
-
const clearNew =
|
|
2316
|
+
const clearNew = useCallback5((...ids) => {
|
|
2281
2317
|
setNewNodeIds((s) => {
|
|
2282
2318
|
const next = new Set(s);
|
|
2283
2319
|
let changed = false;
|
|
@@ -2287,7 +2323,7 @@ function useNewNodeTracking(view) {
|
|
|
2287
2323
|
return changed ? next : s;
|
|
2288
2324
|
});
|
|
2289
2325
|
}, []);
|
|
2290
|
-
return { newNodeIds, clearNew };
|
|
2326
|
+
return { addedIds, newNodeIds, clearNew };
|
|
2291
2327
|
}
|
|
2292
2328
|
|
|
2293
2329
|
// src/utils/viewport.ts
|
|
@@ -2343,10 +2379,23 @@ var FIT_VIEW_OPTIONS = { padding: 0.2, duration: 300, maxZoom: 1 };
|
|
|
2343
2379
|
var REVEAL_MARGIN = 24;
|
|
2344
2380
|
var NO_ENV_EXTRAS_TARGET = {};
|
|
2345
2381
|
var isValidConnection = (c) => c.sourceHandle === NODE_HANDLE ? c.targetHandle === NODE_HANDLE && c.source !== c.target : c.targetHandle !== NODE_HANDLE;
|
|
2382
|
+
function edgeRefOf(edge) {
|
|
2383
|
+
const data = rfEdgeData(edge);
|
|
2384
|
+
if (!data) return null;
|
|
2385
|
+
return {
|
|
2386
|
+
id: edge.id,
|
|
2387
|
+
source: edge.source,
|
|
2388
|
+
target: edge.target,
|
|
2389
|
+
sourceOutput: data.source_output,
|
|
2390
|
+
targetInput: data.target_input
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2346
2393
|
function CompositeEditor({
|
|
2347
2394
|
view,
|
|
2348
2395
|
editable,
|
|
2396
|
+
addedIds,
|
|
2349
2397
|
newNodeIds,
|
|
2398
|
+
editing,
|
|
2350
2399
|
onDragStop,
|
|
2351
2400
|
onConnect,
|
|
2352
2401
|
onEdgeClick,
|
|
@@ -2358,6 +2407,7 @@ function CompositeEditor({
|
|
|
2358
2407
|
registerGoToNode,
|
|
2359
2408
|
layout,
|
|
2360
2409
|
focusIds,
|
|
2410
|
+
selection,
|
|
2361
2411
|
paneRef,
|
|
2362
2412
|
decorations
|
|
2363
2413
|
}) {
|
|
@@ -2371,7 +2421,7 @@ function CompositeEditor({
|
|
|
2371
2421
|
layout.panIntoView(withMargin(bounds, REVEAL_MARGIN, getViewport().zoom));
|
|
2372
2422
|
});
|
|
2373
2423
|
}, [registerGoToNode, getNode, getNodesBounds, getViewport, layout]);
|
|
2374
|
-
const focusRef =
|
|
2424
|
+
const focusRef = useRef7(focusIds);
|
|
2375
2425
|
focusRef.current = focusIds;
|
|
2376
2426
|
useEffect7(() => {
|
|
2377
2427
|
const pane = paneRef.current;
|
|
@@ -2423,19 +2473,39 @@ function CompositeEditor({
|
|
|
2423
2473
|
);
|
|
2424
2474
|
};
|
|
2425
2475
|
}, [layout, getViewport, setViewport, paneRef]);
|
|
2426
|
-
const firedRef =
|
|
2476
|
+
const firedRef = useRef7(false);
|
|
2427
2477
|
useEffect7(() => {
|
|
2428
2478
|
if (firedRef.current || !nodesInitialized || view.nodes.length === 0) return;
|
|
2429
2479
|
firedRef.current = true;
|
|
2430
2480
|
requestAnimationFrame(() => fitView(FIT_VIEW_OPTIONS));
|
|
2431
2481
|
}, [nodesInitialized, view.nodes.length, fitView]);
|
|
2432
2482
|
const groupLogic = useGroupLogic(view.nodes, view.edges, view.groups, newNodeIds, decorations);
|
|
2483
|
+
const revealedRef = useRef7(addedIds);
|
|
2484
|
+
useEffect7(() => {
|
|
2485
|
+
if (editing) return;
|
|
2486
|
+
const arrived = [...addedIds].filter((id) => !revealedRef.current.has(id));
|
|
2487
|
+
revealedRef.current = addedIds;
|
|
2488
|
+
const shown = arrived.flatMap((id) => {
|
|
2489
|
+
const node = groupLogic.rfNodes.find((n) => n.id === id);
|
|
2490
|
+
const rect = node && !node.hidden ? drawnRect2(view, id) : void 0;
|
|
2491
|
+
return rect ? [rect] : [];
|
|
2492
|
+
});
|
|
2493
|
+
if (shown.length === 0) return;
|
|
2494
|
+
layout.panIntoView(withMargin(extentOf2(shown), REVEAL_MARGIN, getViewport().zoom));
|
|
2495
|
+
}, [editing, addedIds, groupLogic.rfNodes, view, layout, getViewport]);
|
|
2433
2496
|
const rfEdgesFromView = groupLogic.rfEdges;
|
|
2497
|
+
const selectedNodeIds = useMemo3(() => new Set(selection.nodes), [selection.nodes]);
|
|
2498
|
+
const selectedEdgeId = selection.edge?.id;
|
|
2434
2499
|
const [rfEdges, setRfEdges] = useState8(rfEdgesFromView);
|
|
2435
2500
|
useEffect7(() => {
|
|
2436
|
-
setRfEdges(
|
|
2437
|
-
|
|
2438
|
-
|
|
2501
|
+
setRfEdges((prev) => {
|
|
2502
|
+
const held = new Set(prev.filter((e) => e.selected).map((e) => e.id));
|
|
2503
|
+
return rfEdgesFromView.map(
|
|
2504
|
+
(e) => held.has(e.id) || e.id === selectedEdgeId ? { ...e, selected: true } : e
|
|
2505
|
+
);
|
|
2506
|
+
});
|
|
2507
|
+
}, [rfEdgesFromView, selectedEdgeId]);
|
|
2508
|
+
const onEdgesChange = useCallback6((changes) => {
|
|
2439
2509
|
setRfEdges((prev) => applyEdgeChanges(changes, prev));
|
|
2440
2510
|
}, []);
|
|
2441
2511
|
const rfNodesFromView = groupLogic.rfNodes;
|
|
@@ -2445,21 +2515,22 @@ function CompositeEditor({
|
|
|
2445
2515
|
const current = new Map(prev.map((n) => [n.id, n]));
|
|
2446
2516
|
return rfNodesFromView.map((n) => {
|
|
2447
2517
|
const existing = current.get(n.id);
|
|
2448
|
-
|
|
2518
|
+
const selected = (existing?.selected === true || selectedNodeIds.has(n.id)) && !n.hidden;
|
|
2519
|
+
if (!existing) return selected ? { ...n, selected } : n;
|
|
2449
2520
|
return {
|
|
2450
2521
|
...n,
|
|
2451
2522
|
position: existing.dragging ? existing.position : n.position,
|
|
2452
2523
|
dragging: existing.dragging,
|
|
2453
|
-
selected
|
|
2524
|
+
selected,
|
|
2454
2525
|
measured: existing.measured
|
|
2455
2526
|
};
|
|
2456
2527
|
});
|
|
2457
2528
|
});
|
|
2458
|
-
}, [rfNodesFromView]);
|
|
2459
|
-
const onNodesChange =
|
|
2529
|
+
}, [rfNodesFromView, selectedNodeIds]);
|
|
2530
|
+
const onNodesChange = useCallback6((changes) => {
|
|
2460
2531
|
setRfNodes((prev) => applyNodeChanges(changes, prev));
|
|
2461
2532
|
}, []);
|
|
2462
|
-
const onNodeDragStop =
|
|
2533
|
+
const onNodeDragStop = useCallback6(
|
|
2463
2534
|
(_e, _draggedNode, draggedNodes) => {
|
|
2464
2535
|
const positions = {};
|
|
2465
2536
|
for (const n of draggedNodes) {
|
|
@@ -2538,7 +2609,7 @@ function Canvas({ height }) {
|
|
|
2538
2609
|
layout
|
|
2539
2610
|
} = useCanvas();
|
|
2540
2611
|
const editor = ctx.ports.editor;
|
|
2541
|
-
const makeEnvExtras =
|
|
2612
|
+
const makeEnvExtras = useCallback6(
|
|
2542
2613
|
() => ({
|
|
2543
2614
|
bundle,
|
|
2544
2615
|
arrangement: { get: () => arrangement, update: updateArrangement },
|
|
@@ -2551,29 +2622,37 @@ function Canvas({ height }) {
|
|
|
2551
2622
|
[selection]
|
|
2552
2623
|
);
|
|
2553
2624
|
const { contextMenu, showContextMenu, dismissContextMenu } = useContextMenu();
|
|
2554
|
-
const { newNodeIds } = useNewNodeTracking(view);
|
|
2555
|
-
|
|
2556
|
-
|
|
2625
|
+
const { addedIds, newNodeIds, clearNew } = useNewNodeTracking(view);
|
|
2626
|
+
useEffect7(() => {
|
|
2627
|
+
clearNew(...selection.nodes);
|
|
2628
|
+
}, [selection.nodes, clearNew]);
|
|
2629
|
+
const [editing, setEditing] = useState8(() => runner.editing());
|
|
2630
|
+
useEffect7(() => {
|
|
2631
|
+
setEditing(runner.editing());
|
|
2632
|
+
return runner.onEditingChange(setEditing);
|
|
2633
|
+
}, [runner]);
|
|
2634
|
+
const paneRef = useRef7(null);
|
|
2635
|
+
const surfaceRef = useRef7(null);
|
|
2557
2636
|
useEffect7(() => {
|
|
2558
2637
|
registerKeyTarget(ctx, "surface", surfaceRef.current);
|
|
2559
2638
|
return () => registerKeyTarget(ctx, "surface", null);
|
|
2560
2639
|
}, [ctx]);
|
|
2561
|
-
const onSurfacePointerDown =
|
|
2640
|
+
const onSurfacePointerDown = useCallback6((e) => {
|
|
2562
2641
|
if (isFormTarget(e.target)) return;
|
|
2563
2642
|
surfaceRef.current?.focus();
|
|
2564
2643
|
}, []);
|
|
2565
|
-
const goToNodeRef =
|
|
2566
|
-
const registerGoToNode =
|
|
2644
|
+
const goToNodeRef = useRef7(null);
|
|
2645
|
+
const registerGoToNode = useCallback6((fn) => {
|
|
2567
2646
|
goToNodeRef.current = fn;
|
|
2568
2647
|
}, []);
|
|
2569
|
-
const onOpenNodeConfig =
|
|
2648
|
+
const onOpenNodeConfig = useCallback6(
|
|
2570
2649
|
(instanceId) => {
|
|
2571
2650
|
setSelection({ nodes: [instanceId], edge: null });
|
|
2572
2651
|
goToNodeRef.current?.(instanceId);
|
|
2573
2652
|
},
|
|
2574
2653
|
[setSelection]
|
|
2575
2654
|
);
|
|
2576
|
-
const onDragStop =
|
|
2655
|
+
const onDragStop = useCallback6(
|
|
2577
2656
|
(positions) => {
|
|
2578
2657
|
const pinned = Object.keys(positions).reduce(
|
|
2579
2658
|
(next, id) => withScopesPinned(bundle, view, next, id),
|
|
@@ -2583,7 +2662,7 @@ function Canvas({ height }) {
|
|
|
2583
2662
|
},
|
|
2584
2663
|
[bundle, view, arrangement, updateArrangement]
|
|
2585
2664
|
);
|
|
2586
|
-
const onConnect =
|
|
2665
|
+
const onConnect = useCallback6(
|
|
2587
2666
|
async (conn) => {
|
|
2588
2667
|
if (!conn.source || !conn.target || !editor) return;
|
|
2589
2668
|
const source = instanceAddress4(bundle, conn.source);
|
|
@@ -2605,24 +2684,14 @@ function Canvas({ height }) {
|
|
|
2605
2684
|
},
|
|
2606
2685
|
[editor, runner, bundle]
|
|
2607
2686
|
);
|
|
2608
|
-
const onEdgeClick =
|
|
2687
|
+
const onEdgeClick = useCallback6(
|
|
2609
2688
|
(_e, edge) => {
|
|
2610
|
-
const
|
|
2611
|
-
if (
|
|
2612
|
-
setSelection({
|
|
2613
|
-
nodes: [],
|
|
2614
|
-
edge: {
|
|
2615
|
-
id: edge.id,
|
|
2616
|
-
source: edge.source,
|
|
2617
|
-
target: edge.target,
|
|
2618
|
-
sourceOutput: data.source_output,
|
|
2619
|
-
targetInput: data.target_input
|
|
2620
|
-
}
|
|
2621
|
-
});
|
|
2689
|
+
const ref = edgeRefOf(edge);
|
|
2690
|
+
if (ref) setSelection({ nodes: [], edge: ref });
|
|
2622
2691
|
},
|
|
2623
2692
|
[setSelection]
|
|
2624
2693
|
);
|
|
2625
|
-
const onEdgesDelete =
|
|
2694
|
+
const onEdgesDelete = useCallback6(
|
|
2626
2695
|
async (edges) => {
|
|
2627
2696
|
for (const edge of edges) {
|
|
2628
2697
|
const data = rfEdgeData(edge);
|
|
@@ -2635,7 +2704,7 @@ function Canvas({ height }) {
|
|
|
2635
2704
|
},
|
|
2636
2705
|
[runner, bundle]
|
|
2637
2706
|
);
|
|
2638
|
-
const onNodesDelete =
|
|
2707
|
+
const onNodesDelete = useCallback6(
|
|
2639
2708
|
async (nodes) => {
|
|
2640
2709
|
const action = ctx.contributions.actions.find((a) => a.id === "delete-node");
|
|
2641
2710
|
if (!action) return;
|
|
@@ -2646,12 +2715,15 @@ function Canvas({ height }) {
|
|
|
2646
2715
|
},
|
|
2647
2716
|
[ctx, runner, makeEnvExtras]
|
|
2648
2717
|
);
|
|
2649
|
-
const onSelectionChange =
|
|
2718
|
+
const onSelectionChange = useCallback6(
|
|
2650
2719
|
(params) => {
|
|
2651
|
-
const
|
|
2652
|
-
setSelection({
|
|
2720
|
+
const [wire, ...more] = params.edges;
|
|
2721
|
+
setSelection({
|
|
2722
|
+
nodes: params.nodes.map((n) => n.id),
|
|
2723
|
+
edge: wire && more.length === 0 && params.nodes.length === 0 ? edgeRefOf(wire) : null
|
|
2724
|
+
});
|
|
2653
2725
|
},
|
|
2654
|
-
[setSelection
|
|
2726
|
+
[setSelection]
|
|
2655
2727
|
);
|
|
2656
2728
|
const menuTarget = contextMenu ? contextMenu.groupId ? groupTarget(contextMenu.groupId) : { nodeId: contextMenu.nodeId ?? void 0 } : NO_ENV_EXTRAS_TARGET;
|
|
2657
2729
|
const menuActions = useMemo3(() => {
|
|
@@ -2661,7 +2733,7 @@ function Canvas({ height }) {
|
|
|
2661
2733
|
(a) => a.placement === placement
|
|
2662
2734
|
);
|
|
2663
2735
|
}, [contextMenu, ctx, menuTarget]);
|
|
2664
|
-
const runMenuAction =
|
|
2736
|
+
const runMenuAction = useCallback6(
|
|
2665
2737
|
(action) => {
|
|
2666
2738
|
void runner.run(action, ctx, menuTarget, makeEnvExtras());
|
|
2667
2739
|
},
|
|
@@ -2697,7 +2769,9 @@ function Canvas({ height }) {
|
|
|
2697
2769
|
{
|
|
2698
2770
|
view,
|
|
2699
2771
|
editable,
|
|
2772
|
+
addedIds,
|
|
2700
2773
|
newNodeIds,
|
|
2774
|
+
editing,
|
|
2701
2775
|
onDragStop,
|
|
2702
2776
|
onConnect,
|
|
2703
2777
|
onEdgeClick,
|
|
@@ -2710,6 +2784,7 @@ function Canvas({ height }) {
|
|
|
2710
2784
|
registerGoToNode,
|
|
2711
2785
|
layout,
|
|
2712
2786
|
focusIds,
|
|
2787
|
+
selection,
|
|
2713
2788
|
paneRef,
|
|
2714
2789
|
decorations
|
|
2715
2790
|
}
|
|
@@ -2722,7 +2797,7 @@ function Canvas({ height }) {
|
|
|
2722
2797
|
}
|
|
2723
2798
|
|
|
2724
2799
|
// src/components/Drawer.tsx
|
|
2725
|
-
import { useCallback as
|
|
2800
|
+
import { useCallback as useCallback7, useLayoutEffect as useLayoutEffect2, useRef as useRef8, useState as useState9 } from "react";
|
|
2726
2801
|
|
|
2727
2802
|
// src/utils/style-vars.ts
|
|
2728
2803
|
function readTokenPx(el, name) {
|
|
@@ -2743,30 +2818,30 @@ function clampWidth(width, bounds) {
|
|
|
2743
2818
|
return Math.min(bounds.max, Math.max(bounds.min, width));
|
|
2744
2819
|
}
|
|
2745
2820
|
function Drawer({ label, children }) {
|
|
2746
|
-
const ref =
|
|
2821
|
+
const ref = useRef8(null);
|
|
2747
2822
|
const [bounds, setBounds] = useState9(null);
|
|
2748
2823
|
const [width, setWidth] = useState9(null);
|
|
2749
2824
|
const [measured, setMeasured] = useState9(0);
|
|
2750
|
-
const drag =
|
|
2825
|
+
const drag = useRef8(null);
|
|
2751
2826
|
useLayoutEffect2(() => {
|
|
2752
2827
|
if (ref.current) setBounds(readDrawerBounds(ref.current));
|
|
2753
2828
|
}, []);
|
|
2754
2829
|
useLayoutEffect2(() => {
|
|
2755
2830
|
if (ref.current) setMeasured(Math.round(ref.current.getBoundingClientRect().width));
|
|
2756
2831
|
}, [width]);
|
|
2757
|
-
const onPointerDown =
|
|
2832
|
+
const onPointerDown = useCallback7((e) => {
|
|
2758
2833
|
e.preventDefault();
|
|
2759
2834
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
2760
2835
|
drag.current = { x: e.clientX, width: ref.current?.getBoundingClientRect().width ?? 0 };
|
|
2761
2836
|
}, []);
|
|
2762
|
-
const onPointerMove =
|
|
2837
|
+
const onPointerMove = useCallback7(
|
|
2763
2838
|
(e) => {
|
|
2764
2839
|
if (!drag.current) return;
|
|
2765
2840
|
setWidth(clampWidth(drag.current.width + drag.current.x - e.clientX, bounds));
|
|
2766
2841
|
},
|
|
2767
2842
|
[bounds]
|
|
2768
2843
|
);
|
|
2769
|
-
const onPointerUp =
|
|
2844
|
+
const onPointerUp = useCallback7((e) => {
|
|
2770
2845
|
drag.current = null;
|
|
2771
2846
|
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
2772
2847
|
}, []);
|
|
@@ -2963,7 +3038,7 @@ import { nodeIdForAddress } from "@lace-cloud/proto";
|
|
|
2963
3038
|
import { useMemo as useMemo6 } from "react";
|
|
2964
3039
|
|
|
2965
3040
|
// src/core/use-command-read.ts
|
|
2966
|
-
import { useEffect as useEffect8, useMemo as useMemo5, useRef as
|
|
3041
|
+
import { useEffect as useEffect8, useMemo as useMemo5, useRef as useRef9, useState as useState11 } from "react";
|
|
2967
3042
|
|
|
2968
3043
|
// src/core/panel-scope.tsx
|
|
2969
3044
|
import { createContext as createContext3, useContext as useContext3, useMemo as useMemo4 } from "react";
|
|
@@ -3022,14 +3097,14 @@ function useCommandRead(read, target) {
|
|
|
3022
3097
|
const args = read.args(scope.ctx, effectiveTarget);
|
|
3023
3098
|
const key = args === null ? null : stableJson(args);
|
|
3024
3099
|
const [state, setState] = useState11(INITIAL);
|
|
3025
|
-
const prevKeyRef =
|
|
3100
|
+
const prevKeyRef = useRef9(NOT_YET_READ);
|
|
3026
3101
|
const inputs = {
|
|
3027
3102
|
path: read.path,
|
|
3028
3103
|
args,
|
|
3029
3104
|
commands: scope.ctx.ports.commands,
|
|
3030
3105
|
reportError: scope.reportError
|
|
3031
3106
|
};
|
|
3032
|
-
const inputsRef =
|
|
3107
|
+
const inputsRef = useRef9(inputs);
|
|
3033
3108
|
useEffect8(() => {
|
|
3034
3109
|
inputsRef.current = inputs;
|
|
3035
3110
|
});
|
|
@@ -3169,18 +3244,24 @@ function RowActionBanner({ ctx, panelId, severity, className, opening }) {
|
|
|
3169
3244
|
severity,
|
|
3170
3245
|
className,
|
|
3171
3246
|
message: bannerMessage(opening, actions),
|
|
3172
|
-
actions: actions.length === 0 ? void 0 : actions.map((action) =>
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3247
|
+
actions: actions.length === 0 ? void 0 : actions.map((action) => {
|
|
3248
|
+
const state = actionState(action, ctx, runner.busy(action, ctx, {}));
|
|
3249
|
+
return /* @__PURE__ */ jsx17(
|
|
3250
|
+
Button2,
|
|
3251
|
+
{
|
|
3252
|
+
rung: true,
|
|
3253
|
+
size: "sm",
|
|
3254
|
+
variant: "secondary",
|
|
3255
|
+
className: `${className}__${action.id}`,
|
|
3256
|
+
disabled: state.disabledReason !== void 0,
|
|
3257
|
+
loading: state.busyLabel !== void 0,
|
|
3258
|
+
tooltip: state.disabledReason,
|
|
3259
|
+
onClick: () => void runner.run(action, ctx, {}, envExtras),
|
|
3260
|
+
children: action.label
|
|
3261
|
+
},
|
|
3262
|
+
action.id
|
|
3263
|
+
);
|
|
3264
|
+
})
|
|
3184
3265
|
}
|
|
3185
3266
|
);
|
|
3186
3267
|
}
|
|
@@ -3258,18 +3339,24 @@ function DiagnosticsPanel({ ctx }) {
|
|
|
3258
3339
|
}
|
|
3259
3340
|
),
|
|
3260
3341
|
d.code !== void 0 && /* @__PURE__ */ jsx20(Identifier, { className: "lace-diagnostics-panel__code", text: d.code }),
|
|
3261
|
-
actions.map((action) =>
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3342
|
+
actions.map((action) => {
|
|
3343
|
+
const state = actionState(action, ctx, runner.busy(action, ctx, target));
|
|
3344
|
+
return /* @__PURE__ */ jsx20(
|
|
3345
|
+
Button3,
|
|
3346
|
+
{
|
|
3347
|
+
rung: true,
|
|
3348
|
+
size: "sm",
|
|
3349
|
+
variant: "ghost",
|
|
3350
|
+
className: "lace-diagnostics-panel__action",
|
|
3351
|
+
disabled: state.disabledReason !== void 0,
|
|
3352
|
+
loading: state.busyLabel !== void 0,
|
|
3353
|
+
tooltip: state.disabledReason,
|
|
3354
|
+
onClick: () => void runner.run(action, ctx, target, envExtras),
|
|
3355
|
+
children: action.label
|
|
3356
|
+
},
|
|
3357
|
+
action.id
|
|
3358
|
+
);
|
|
3359
|
+
})
|
|
3273
3360
|
] })
|
|
3274
3361
|
]
|
|
3275
3362
|
},
|
|
@@ -3352,7 +3439,6 @@ function EdgeInspectorPanel2({ ctx }) {
|
|
|
3352
3439
|
const envExtras = useEditorEnvExtras();
|
|
3353
3440
|
const edge = ctx.selection.edge;
|
|
3354
3441
|
if (!edge) return null;
|
|
3355
|
-
const close = () => setSelection({ nodes: [], edge: null });
|
|
3356
3442
|
const disconnect = rowActionsFor(ctx, "edge-inspector").find((a) => a.id === "disconnect");
|
|
3357
3443
|
return createElement(EdgeInspectorPanel, {
|
|
3358
3444
|
source: edge.source,
|
|
@@ -3362,12 +3448,10 @@ function EdgeInspectorPanel2({ ctx }) {
|
|
|
3362
3448
|
// The delete button exists exactly when `disconnect` resolved.
|
|
3363
3449
|
...disconnect ? {
|
|
3364
3450
|
onDelete: () => {
|
|
3365
|
-
void runner.run(disconnect, ctx, {}, envExtras)
|
|
3366
|
-
if (result?.success) close();
|
|
3367
|
-
});
|
|
3451
|
+
void runner.run(disconnect, ctx, {}, envExtras);
|
|
3368
3452
|
}
|
|
3369
3453
|
} : {},
|
|
3370
|
-
onClose:
|
|
3454
|
+
onClose: () => setSelection({ nodes: [], edge: null })
|
|
3371
3455
|
});
|
|
3372
3456
|
}
|
|
3373
3457
|
var edgeInspectorPanel = {
|
|
@@ -3413,7 +3497,7 @@ import { createElement as createElement2 } from "react";
|
|
|
3413
3497
|
// src/components/panels/ModuleConfigPanel.tsx
|
|
3414
3498
|
import { deriveNodeConfig, instanceAddress as instanceAddress6 } from "@lace-cloud/proto";
|
|
3415
3499
|
import { Button as Button12, IconButton as IconButton9, Input as Input8, ModeToggle, Panel as Panel6, Textarea as Textarea3 } from "@lace-cloud/ui";
|
|
3416
|
-
import { useCallback as
|
|
3500
|
+
import { useCallback as useCallback14, useEffect as useEffect10, useMemo as useMemo8, useState as useState21 } from "react";
|
|
3417
3501
|
|
|
3418
3502
|
// src/exhaustive.ts
|
|
3419
3503
|
function assertNever(value) {
|
|
@@ -3421,15 +3505,15 @@ function assertNever(value) {
|
|
|
3421
3505
|
}
|
|
3422
3506
|
|
|
3423
3507
|
// src/hooks/useUpdateState.ts
|
|
3424
|
-
import { useCallback as
|
|
3508
|
+
import { useCallback as useCallback8, useEffect as useEffect9, useRef as useRef10, useState as useState12 } from "react";
|
|
3425
3509
|
function useUpdateState(updateFn) {
|
|
3426
3510
|
const [status, setStatus] = useState12("idle");
|
|
3427
|
-
const mountedRef =
|
|
3428
|
-
const resetTimerRef =
|
|
3429
|
-
const safeSetStatus =
|
|
3511
|
+
const mountedRef = useRef10(true);
|
|
3512
|
+
const resetTimerRef = useRef10(null);
|
|
3513
|
+
const safeSetStatus = useCallback8((next) => {
|
|
3430
3514
|
if (mountedRef.current) setStatus(next);
|
|
3431
3515
|
}, []);
|
|
3432
|
-
const scheduleReset =
|
|
3516
|
+
const scheduleReset = useCallback8(
|
|
3433
3517
|
(delay) => {
|
|
3434
3518
|
if (resetTimerRef.current !== null) clearTimeout(resetTimerRef.current);
|
|
3435
3519
|
resetTimerRef.current = setTimeout(() => {
|
|
@@ -3439,7 +3523,7 @@ function useUpdateState(updateFn) {
|
|
|
3439
3523
|
},
|
|
3440
3524
|
[safeSetStatus]
|
|
3441
3525
|
);
|
|
3442
|
-
const handleUpdate =
|
|
3526
|
+
const handleUpdate = useCallback8(async () => {
|
|
3443
3527
|
safeSetStatus("updating");
|
|
3444
3528
|
try {
|
|
3445
3529
|
await updateFn();
|
|
@@ -3703,7 +3787,7 @@ function BlockCard({ block, editable, onChange, onRemove }) {
|
|
|
3703
3787
|
|
|
3704
3788
|
// src/components/panels/LocalsPanel.tsx
|
|
3705
3789
|
import { Button as Button7, IconButton as IconButton4, Input as Input2, Panel as Panel2, Textarea } from "@lace-cloud/ui";
|
|
3706
|
-
import { useCallback as
|
|
3790
|
+
import { useCallback as useCallback9, useState as useState15 } from "react";
|
|
3707
3791
|
|
|
3708
3792
|
// src/utils/duplicates.ts
|
|
3709
3793
|
function findDuplicateIndices(items, keyFn) {
|
|
@@ -3733,19 +3817,19 @@ function fromRows(rows) {
|
|
|
3733
3817
|
function LocalsContent({ locals, onSave }) {
|
|
3734
3818
|
const { editable } = useCanvas();
|
|
3735
3819
|
const [rows, setRows] = useState15(() => toRows(locals));
|
|
3736
|
-
const addLocal =
|
|
3820
|
+
const addLocal = useCallback9(() => {
|
|
3737
3821
|
setRows((prev) => [...prev, { id: crypto.randomUUID(), name: "", value: "" }]);
|
|
3738
3822
|
}, []);
|
|
3739
|
-
const removeLocal =
|
|
3823
|
+
const removeLocal = useCallback9((index) => {
|
|
3740
3824
|
setRows((prev) => prev.filter((_, i) => i !== index));
|
|
3741
3825
|
}, []);
|
|
3742
|
-
const updateRow =
|
|
3826
|
+
const updateRow = useCallback9((index, field, value) => {
|
|
3743
3827
|
setRows((prev) => prev.map((r, i) => i === index ? { ...r, [field]: value } : r));
|
|
3744
3828
|
}, []);
|
|
3745
3829
|
const nameDupes = findDuplicateIndices(rows, (r) => r.name);
|
|
3746
3830
|
const hasErrors = nameDupes.size > 0;
|
|
3747
3831
|
const { status: updateStatus, handleUpdate } = useUpdateState(
|
|
3748
|
-
|
|
3832
|
+
useCallback9(async () => {
|
|
3749
3833
|
if (hasErrors) return;
|
|
3750
3834
|
await onSave(fromRows(rows));
|
|
3751
3835
|
}, [onSave, rows, hasErrors])
|
|
@@ -3813,7 +3897,7 @@ function LocalsPanel({ locals, onSave, onClose }) {
|
|
|
3813
3897
|
|
|
3814
3898
|
// src/components/panels/ModuleInterfacePanel.tsx
|
|
3815
3899
|
import { Button as Button8, IconButton as IconButton5, Input as Input3, Panel as Panel3, Select, Textarea as Textarea2 } from "@lace-cloud/ui";
|
|
3816
|
-
import { useCallback as
|
|
3900
|
+
import { useCallback as useCallback10, useState as useState16 } from "react";
|
|
3817
3901
|
import "./panels-shared-5JFNYXQ7.css";
|
|
3818
3902
|
import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3819
3903
|
function variablesToRows(variables) {
|
|
@@ -3857,13 +3941,13 @@ function ModuleInterfaceContent({ settings, onSave }) {
|
|
|
3857
3941
|
() => variablesToRows(settings.variables)
|
|
3858
3942
|
);
|
|
3859
3943
|
const [outputs, setOutputs2] = useState16(() => outputsToRows(settings.outputs));
|
|
3860
|
-
const updateVariable =
|
|
3944
|
+
const updateVariable = useCallback10(
|
|
3861
3945
|
(index, field, value) => {
|
|
3862
3946
|
setVariables2((prev) => prev.map((v, i) => i === index ? { ...v, [field]: value } : v));
|
|
3863
3947
|
},
|
|
3864
3948
|
[]
|
|
3865
3949
|
);
|
|
3866
|
-
const addVariable =
|
|
3950
|
+
const addVariable = useCallback10(() => {
|
|
3867
3951
|
setVariables2((prev) => [
|
|
3868
3952
|
...prev,
|
|
3869
3953
|
{
|
|
@@ -3881,7 +3965,7 @@ function ModuleInterfaceContent({ settings, onSave }) {
|
|
|
3881
3965
|
}
|
|
3882
3966
|
]);
|
|
3883
3967
|
}, []);
|
|
3884
|
-
const addValidation =
|
|
3968
|
+
const addValidation = useCallback10((index) => {
|
|
3885
3969
|
setVariables2(
|
|
3886
3970
|
(prev) => prev.map(
|
|
3887
3971
|
(v, i) => i === index ? {
|
|
@@ -3894,14 +3978,14 @@ function ModuleInterfaceContent({ settings, onSave }) {
|
|
|
3894
3978
|
)
|
|
3895
3979
|
);
|
|
3896
3980
|
}, []);
|
|
3897
|
-
const removeValidation =
|
|
3981
|
+
const removeValidation = useCallback10((index, vIndex) => {
|
|
3898
3982
|
setVariables2(
|
|
3899
3983
|
(prev) => prev.map(
|
|
3900
3984
|
(v, i) => i === index ? { ...v, validation: v.validation.filter((_, j) => j !== vIndex) } : v
|
|
3901
3985
|
)
|
|
3902
3986
|
);
|
|
3903
3987
|
}, []);
|
|
3904
|
-
const updateValidation =
|
|
3988
|
+
const updateValidation = useCallback10(
|
|
3905
3989
|
(index, vIndex, field, value) => {
|
|
3906
3990
|
setVariables2(
|
|
3907
3991
|
(prev) => prev.map(
|
|
@@ -3916,19 +4000,19 @@ function ModuleInterfaceContent({ settings, onSave }) {
|
|
|
3916
4000
|
},
|
|
3917
4001
|
[]
|
|
3918
4002
|
);
|
|
3919
|
-
const updateOutput =
|
|
4003
|
+
const updateOutput = useCallback10(
|
|
3920
4004
|
(index, field, value) => {
|
|
3921
4005
|
setOutputs2((prev) => prev.map((o, i) => i === index ? { ...o, [field]: value } : o));
|
|
3922
4006
|
},
|
|
3923
4007
|
[]
|
|
3924
4008
|
);
|
|
3925
|
-
const addOutput =
|
|
4009
|
+
const addOutput = useCallback10((name, value) => {
|
|
3926
4010
|
setOutputs2((prev) => [
|
|
3927
4011
|
...prev,
|
|
3928
4012
|
{ id: crypto.randomUUID(), name, value, description: "", sensitive: false, depends_on: [] }
|
|
3929
4013
|
]);
|
|
3930
4014
|
}, []);
|
|
3931
|
-
const toggleDependsOn =
|
|
4015
|
+
const toggleDependsOn = useCallback10((index, dep) => {
|
|
3932
4016
|
setOutputs2(
|
|
3933
4017
|
(prev) => prev.map((o, i) => {
|
|
3934
4018
|
if (i !== index) return o;
|
|
@@ -3945,7 +4029,7 @@ function ModuleInterfaceContent({ settings, onSave }) {
|
|
|
3945
4029
|
const unnamedOutput = outputs.some((o) => !o.name.trim() || !o.value.trim());
|
|
3946
4030
|
const hasErrors = variableDupes.size > 0 || outputDupes.size > 0 || unnamedOutput;
|
|
3947
4031
|
const { status: updateStatus, handleUpdate } = useUpdateState(
|
|
3948
|
-
|
|
4032
|
+
useCallback10(async () => {
|
|
3949
4033
|
if (hasErrors) return;
|
|
3950
4034
|
const variableDefs = variables.filter((v) => v.name.trim()).map((v) => {
|
|
3951
4035
|
const validation = v.validation.map((b) => ({ condition: b.condition.trim(), error_message: b.error_message.trim() })).filter((b) => b.condition || b.error_message);
|
|
@@ -4352,7 +4436,7 @@ import "./panels-shared-5JFNYXQ7.css";
|
|
|
4352
4436
|
|
|
4353
4437
|
// src/components/panels/ProvidersPanel.tsx
|
|
4354
4438
|
import { Button as Button9, IconButton as IconButton6, Input as Input4, Panel as Panel4 } from "@lace-cloud/ui";
|
|
4355
|
-
import { useCallback as
|
|
4439
|
+
import { useCallback as useCallback11, useState as useState17 } from "react";
|
|
4356
4440
|
import "./panels-shared-5JFNYXQ7.css";
|
|
4357
4441
|
import { Fragment as Fragment9, jsx as jsx28, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4358
4442
|
function toRows2(providers) {
|
|
@@ -4383,7 +4467,7 @@ function fromRows2(rows) {
|
|
|
4383
4467
|
function ProvidersContent({ providers, onSave }) {
|
|
4384
4468
|
const { editable } = useCanvas();
|
|
4385
4469
|
const [rows, setRows] = useState17(() => toRows2(providers));
|
|
4386
|
-
const addProvider =
|
|
4470
|
+
const addProvider = useCallback11(() => {
|
|
4387
4471
|
setRows((prev) => [
|
|
4388
4472
|
...prev,
|
|
4389
4473
|
{
|
|
@@ -4395,16 +4479,16 @@ function ProvidersContent({ providers, onSave }) {
|
|
|
4395
4479
|
}
|
|
4396
4480
|
]);
|
|
4397
4481
|
}, []);
|
|
4398
|
-
const removeProvider =
|
|
4482
|
+
const removeProvider = useCallback11((index) => {
|
|
4399
4483
|
setRows((prev) => prev.filter((_, i) => i !== index));
|
|
4400
4484
|
}, []);
|
|
4401
|
-
const updateField =
|
|
4485
|
+
const updateField = useCallback11((index, field, value) => {
|
|
4402
4486
|
setRows((prev) => prev.map((r, i) => i === index ? { ...r, [field]: value } : r));
|
|
4403
4487
|
}, []);
|
|
4404
|
-
const updateBlocks =
|
|
4488
|
+
const updateBlocks = useCallback11((index, blocks) => {
|
|
4405
4489
|
setRows((prev) => prev.map((r, i) => i === index ? { ...r, blocks } : r));
|
|
4406
4490
|
}, []);
|
|
4407
|
-
const addConfigEntry =
|
|
4491
|
+
const addConfigEntry = useCallback11((providerIndex) => {
|
|
4408
4492
|
setRows(
|
|
4409
4493
|
(prev) => prev.map(
|
|
4410
4494
|
(r, i) => i === providerIndex ? {
|
|
@@ -4414,14 +4498,14 @@ function ProvidersContent({ providers, onSave }) {
|
|
|
4414
4498
|
)
|
|
4415
4499
|
);
|
|
4416
4500
|
}, []);
|
|
4417
|
-
const removeConfigEntry =
|
|
4501
|
+
const removeConfigEntry = useCallback11((providerIndex, entryIndex) => {
|
|
4418
4502
|
setRows(
|
|
4419
4503
|
(prev) => prev.map(
|
|
4420
4504
|
(r, i) => i === providerIndex ? { ...r, configEntries: r.configEntries.filter((_, ei) => ei !== entryIndex) } : r
|
|
4421
4505
|
)
|
|
4422
4506
|
);
|
|
4423
4507
|
}, []);
|
|
4424
|
-
const updateConfigEntry =
|
|
4508
|
+
const updateConfigEntry = useCallback11(
|
|
4425
4509
|
(providerIndex, entryIndex, field, value) => {
|
|
4426
4510
|
setRows(
|
|
4427
4511
|
(prev) => prev.map(
|
|
@@ -4437,7 +4521,7 @@ function ProvidersContent({ providers, onSave }) {
|
|
|
4437
4521
|
[]
|
|
4438
4522
|
);
|
|
4439
4523
|
const { status: updateStatus, handleUpdate } = useUpdateState(
|
|
4440
|
-
|
|
4524
|
+
useCallback11(async () => {
|
|
4441
4525
|
await onSave(fromRows2(rows));
|
|
4442
4526
|
}, [onSave, rows])
|
|
4443
4527
|
);
|
|
@@ -4533,7 +4617,7 @@ function ProvidersPanel({ providers, onSave, onClose }) {
|
|
|
4533
4617
|
|
|
4534
4618
|
// src/components/panels/ResourcesPanel.tsx
|
|
4535
4619
|
import { Badge as Badge2, Button as Button10, IconButton as IconButton7, Input as Input5, Select as Select2 } from "@lace-cloud/ui";
|
|
4536
|
-
import { useCallback as
|
|
4620
|
+
import { useCallback as useCallback12, useState as useState18 } from "react";
|
|
4537
4621
|
import "./panels-shared-5JFNYXQ7.css";
|
|
4538
4622
|
import { Fragment as Fragment10, jsx as jsx29, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4539
4623
|
function ResourcesContent({
|
|
@@ -4625,7 +4709,7 @@ function NewResourceRow({
|
|
|
4625
4709
|
}
|
|
4626
4710
|
function ResourceCard({ resource, dependencyOptions, editable, onUpdate, onRemove }) {
|
|
4627
4711
|
const [draft, setDraft] = useState18(resource);
|
|
4628
|
-
const set =
|
|
4712
|
+
const set = useCallback12(
|
|
4629
4713
|
(field, value) => setDraft((prev) => ({ ...prev, [field]: value })),
|
|
4630
4714
|
[]
|
|
4631
4715
|
);
|
|
@@ -4636,7 +4720,7 @@ function ResourceCard({ resource, dependencyOptions, editable, onUpdate, onRemov
|
|
|
4636
4720
|
const argumentDupes = findDuplicateIndices(draft.arguments, (a) => a.name);
|
|
4637
4721
|
const hasErrors = argumentDupes.size > 0 || draft.arguments.some((a) => !a.name.trim());
|
|
4638
4722
|
const { status, handleUpdate } = useUpdateState(
|
|
4639
|
-
|
|
4723
|
+
useCallback12(async () => {
|
|
4640
4724
|
if (hasErrors) return;
|
|
4641
4725
|
await onUpdate(resource, draft);
|
|
4642
4726
|
}, [onUpdate, resource, draft, hasErrors])
|
|
@@ -4775,7 +4859,7 @@ function ResourceCard({ resource, dependencyOptions, editable, onUpdate, onRemov
|
|
|
4775
4859
|
|
|
4776
4860
|
// src/components/panels/TerraformConfigPanel.tsx
|
|
4777
4861
|
import { Button as Button11, IconButton as IconButton8, Input as Input6, Panel as Panel5 } from "@lace-cloud/ui";
|
|
4778
|
-
import { useCallback as
|
|
4862
|
+
import { useCallback as useCallback13, useState as useState19 } from "react";
|
|
4779
4863
|
import "./panels-shared-5JFNYXQ7.css";
|
|
4780
4864
|
import { Fragment as Fragment11, jsx as jsx30, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4781
4865
|
function TerraformConfigContent({ terraform, onSave }) {
|
|
@@ -4791,23 +4875,23 @@ function TerraformConfigContent({ terraform, onSave }) {
|
|
|
4791
4875
|
aliases: (req.configuration_aliases ?? []).join(", ")
|
|
4792
4876
|
}));
|
|
4793
4877
|
});
|
|
4794
|
-
const addProvider =
|
|
4878
|
+
const addProvider = useCallback13(() => {
|
|
4795
4879
|
setProviders2((prev) => [
|
|
4796
4880
|
...prev,
|
|
4797
4881
|
{ id: crypto.randomUUID(), name: "", source: "", version: "", aliases: "" }
|
|
4798
4882
|
]);
|
|
4799
4883
|
}, []);
|
|
4800
|
-
const removeProvider =
|
|
4884
|
+
const removeProvider = useCallback13((index) => {
|
|
4801
4885
|
setProviders2((prev) => prev.filter((_, i) => i !== index));
|
|
4802
4886
|
}, []);
|
|
4803
|
-
const updateProvider =
|
|
4887
|
+
const updateProvider = useCallback13(
|
|
4804
4888
|
(index, field, value) => {
|
|
4805
4889
|
setProviders2((prev) => prev.map((p, i) => i === index ? { ...p, [field]: value } : p));
|
|
4806
4890
|
},
|
|
4807
4891
|
[]
|
|
4808
4892
|
);
|
|
4809
4893
|
const { status: updateStatus, handleUpdate } = useUpdateState(
|
|
4810
|
-
|
|
4894
|
+
useCallback13(async () => {
|
|
4811
4895
|
const block = {
|
|
4812
4896
|
required_version: requiredVersion.trim() || "",
|
|
4813
4897
|
required_providers: providers.filter((p) => p.name.trim()).map((p) => ({
|
|
@@ -5078,19 +5162,19 @@ function ModuleConfigPanel({ instance_id, onClose, onModified }) {
|
|
|
5078
5162
|
variables: localVariables,
|
|
5079
5163
|
expressions: localExpressions
|
|
5080
5164
|
} = inputState;
|
|
5081
|
-
const setLocalModes =
|
|
5165
|
+
const setLocalModes = useCallback14(
|
|
5082
5166
|
(fn) => setInputState((s) => ({ ...s, modes: fn(s.modes) })),
|
|
5083
5167
|
[]
|
|
5084
5168
|
);
|
|
5085
|
-
const setLocalValues =
|
|
5169
|
+
const setLocalValues = useCallback14(
|
|
5086
5170
|
(fn) => setInputState((s) => ({ ...s, values: fn(s.values) })),
|
|
5087
5171
|
[]
|
|
5088
5172
|
);
|
|
5089
|
-
const setLocalVariables =
|
|
5173
|
+
const setLocalVariables = useCallback14(
|
|
5090
5174
|
(fn) => setInputState((s) => ({ ...s, variables: fn(s.variables) })),
|
|
5091
5175
|
[]
|
|
5092
5176
|
);
|
|
5093
|
-
const setLocalExpressions =
|
|
5177
|
+
const setLocalExpressions = useCallback14(
|
|
5094
5178
|
(fn) => setInputState((s) => ({ ...s, expressions: fn(s.expressions) })),
|
|
5095
5179
|
[]
|
|
5096
5180
|
);
|
|
@@ -5116,7 +5200,7 @@ function ModuleConfigPanel({ instance_id, onClose, onModified }) {
|
|
|
5116
5200
|
);
|
|
5117
5201
|
setLocalRepetition({ count: config.count, for_each: config.for_each });
|
|
5118
5202
|
}, [config]);
|
|
5119
|
-
const switchMode =
|
|
5203
|
+
const switchMode = useCallback14(
|
|
5120
5204
|
(name, mode, input) => {
|
|
5121
5205
|
setLocalModes((prev) => ({ ...prev, [name]: mode }));
|
|
5122
5206
|
switch (mode) {
|
|
@@ -5673,8 +5757,8 @@ function OverlayRunner({
|
|
|
5673
5757
|
tick,
|
|
5674
5758
|
onDecorations
|
|
5675
5759
|
}) {
|
|
5676
|
-
const lastErrorRef =
|
|
5677
|
-
const onReadError =
|
|
5760
|
+
const lastErrorRef = useRef11(/* @__PURE__ */ new Map());
|
|
5761
|
+
const onReadError = useCallback15(
|
|
5678
5762
|
(path, error) => {
|
|
5679
5763
|
const next = error?.message ?? null;
|
|
5680
5764
|
if (lastErrorRef.current.get(path) === next) return;
|
|
@@ -5698,7 +5782,7 @@ function OverlayDecorations({
|
|
|
5698
5782
|
}
|
|
5699
5783
|
function PanelSlot({ panel, ctx, tick }) {
|
|
5700
5784
|
const [readErrors, setReadErrors] = useState22(/* @__PURE__ */ new Map());
|
|
5701
|
-
const onReadError =
|
|
5785
|
+
const onReadError = useCallback15((path, error) => {
|
|
5702
5786
|
setReadErrors((prev) => {
|
|
5703
5787
|
if (error === null) {
|
|
5704
5788
|
if (!prev.has(path)) return prev;
|
|
@@ -5765,7 +5849,7 @@ function App({
|
|
|
5765
5849
|
results: hostResults
|
|
5766
5850
|
}) {
|
|
5767
5851
|
const results = useMemo9(() => hostResults ?? createResultStore(), [hostResults]);
|
|
5768
|
-
const writeReport =
|
|
5852
|
+
const writeReport = useCallback15(
|
|
5769
5853
|
(result, session2) => {
|
|
5770
5854
|
try {
|
|
5771
5855
|
results.write("report", session2, result, { stack: void 0 });
|
|
@@ -5776,7 +5860,7 @@ function App({
|
|
|
5776
5860
|
},
|
|
5777
5861
|
[results, ports.presenter]
|
|
5778
5862
|
);
|
|
5779
|
-
const dropReport =
|
|
5863
|
+
const dropReport = useCallback15((session2) => results.detach("report", session2), [results]);
|
|
5780
5864
|
const { source, end, session } = useCanvasSource(ports.source, writeReport, dropReport);
|
|
5781
5865
|
const [arrangement, setArrangement] = useState22(() => ports.viewState.load());
|
|
5782
5866
|
const stack = ports.context.stack;
|
|
@@ -5784,13 +5868,13 @@ function App({
|
|
|
5784
5868
|
NO_SELECTION
|
|
5785
5869
|
);
|
|
5786
5870
|
const [settingsOpen, setSettingsOpen] = useState22(false);
|
|
5787
|
-
const select =
|
|
5871
|
+
const select = useCallback15((next) => {
|
|
5788
5872
|
setSelection(next);
|
|
5789
5873
|
if (next.nodes.length > 0 || next.edge !== null) setSettingsOpen(false);
|
|
5790
5874
|
}, []);
|
|
5791
5875
|
const [pendingForm, setPendingForm] = useState22(null);
|
|
5792
5876
|
const [overlayDecorations, setOverlayDecorations] = useState22({});
|
|
5793
|
-
const layoutRef =
|
|
5877
|
+
const layoutRef = useRef11({ panIntoView: () => {
|
|
5794
5878
|
} });
|
|
5795
5879
|
const { commands, presenter, editor } = ports;
|
|
5796
5880
|
const runner = useMemo9(
|
|
@@ -5805,14 +5889,14 @@ function App({
|
|
|
5805
5889
|
};
|
|
5806
5890
|
}, [runner]);
|
|
5807
5891
|
const tick = useSyncExternalStore(results.subscribe, results.getTick);
|
|
5808
|
-
const updateArrangement =
|
|
5892
|
+
const updateArrangement = useCallback15(
|
|
5809
5893
|
(next) => {
|
|
5810
5894
|
setArrangement(next);
|
|
5811
5895
|
ports.viewState.save(next);
|
|
5812
5896
|
},
|
|
5813
5897
|
[ports.viewState]
|
|
5814
5898
|
);
|
|
5815
|
-
const gcSeenBundle =
|
|
5899
|
+
const gcSeenBundle = useRef11(null);
|
|
5816
5900
|
if (source && gcSeenBundle.current !== source.bundle) {
|
|
5817
5901
|
gcSeenBundle.current = source.bundle;
|
|
5818
5902
|
const gced = gcArrangement(source.bundle, arrangement);
|
|
@@ -5827,6 +5911,12 @@ function App({
|
|
|
5827
5911
|
() => source ? projectFrame(source, arrangement) : null,
|
|
5828
5912
|
[source, arrangement]
|
|
5829
5913
|
);
|
|
5914
|
+
const reconciledFrame = useRef11(null);
|
|
5915
|
+
useLayoutEffect3(() => {
|
|
5916
|
+
if (!source || !view || reconciledFrame.current === source) return;
|
|
5917
|
+
reconciledFrame.current = source;
|
|
5918
|
+
setSelection((current) => reconcileSelection(view, current));
|
|
5919
|
+
}, [source, view]);
|
|
5830
5920
|
const editable = ports.editor !== void 0 && !source?.sourceRefused;
|
|
5831
5921
|
const merged = useMemo9(
|
|
5832
5922
|
() => ({
|
|
@@ -5867,7 +5957,7 @@ function App({
|
|
|
5867
5957
|
if (!ctx) return EMPTY_CONTRIBUTIONS;
|
|
5868
5958
|
return resolveContributions(merged, ports, ctx, NO_TARGET);
|
|
5869
5959
|
}, [merged, ports, ctx]);
|
|
5870
|
-
const setOverlayDecoration =
|
|
5960
|
+
const setOverlayDecoration = useCallback15((id, next) => {
|
|
5871
5961
|
setOverlayDecorations((prev) => prev[id] === next ? prev : { ...prev, [id]: next });
|
|
5872
5962
|
}, []);
|
|
5873
5963
|
const decorations = useMemo9(() => {
|
|
@@ -5886,7 +5976,7 @@ function App({
|
|
|
5886
5976
|
resolved.actions.filter((action) => action.placement === "toolbar"),
|
|
5887
5977
|
resolved.panels.filter((panel) => panel.slot === "toolbar")
|
|
5888
5978
|
);
|
|
5889
|
-
const rootRef =
|
|
5979
|
+
const rootRef = useRef11(null);
|
|
5890
5980
|
useEffect11(() => {
|
|
5891
5981
|
if (!ctx) return;
|
|
5892
5982
|
registerKeyTarget(ctx, "app", rootRef.current);
|
|
@@ -5931,20 +6021,20 @@ function App({
|
|
|
5931
6021
|
toolbar.sections.map((section, index) => /* @__PURE__ */ jsxs23(Fragment14, { children: [
|
|
5932
6022
|
index > 0 ? /* @__PURE__ */ jsx35("span", { className: "lace-app__toolbar-separator", "aria-hidden": "true" }) : null,
|
|
5933
6023
|
/* @__PURE__ */ jsxs23("div", { className: "lace-app__toolbar-section", children: [
|
|
5934
|
-
section.actions.map((action) =>
|
|
5935
|
-
|
|
5936
|
-
|
|
6024
|
+
section.actions.map((action) => (
|
|
6025
|
+
// `runner.busy` reads the store, whose every write
|
|
6026
|
+
// re-renders App (`resultSlots`).
|
|
6027
|
+
/* @__PURE__ */ jsx35(
|
|
5937
6028
|
ToolbarAction,
|
|
5938
6029
|
{
|
|
5939
6030
|
action,
|
|
5940
|
-
|
|
6031
|
+
...actionState(action, ctx, runner.busy(action, ctx, NO_TARGET)),
|
|
5941
6032
|
emphasized: isEmphasized(action, ctx),
|
|
5942
|
-
busyLabel: busyLabelOf(action, ctx, commandBusy),
|
|
5943
6033
|
onRun: () => void runner.run(action, ctx, NO_TARGET, envExtras)
|
|
5944
6034
|
},
|
|
5945
6035
|
action.id
|
|
5946
|
-
)
|
|
5947
|
-
|
|
6036
|
+
)
|
|
6037
|
+
)),
|
|
5948
6038
|
section.panels.map((panel) => /* @__PURE__ */ jsx35(PanelSlot, { panel, ctx, tick }, panel.id))
|
|
5949
6039
|
] })
|
|
5950
6040
|
] }, section.key ?? "")),
|
|
@@ -6054,6 +6144,7 @@ export {
|
|
|
6054
6144
|
UngeneratedMarker,
|
|
6055
6145
|
UnifiedSettingsPanel,
|
|
6056
6146
|
UnsavedMarker,
|
|
6147
|
+
answering,
|
|
6057
6148
|
bridgeCaller,
|
|
6058
6149
|
carriesFailure,
|
|
6059
6150
|
conflictPanel,
|