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