@lace-cloud/canvas 0.14.0 → 0.15.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/dist/index.mjs CHANGED
@@ -272,8 +272,8 @@ var CanvasContext = createContext({
272
272
  },
273
273
  engine: null,
274
274
  readOnly: false,
275
- localGroupCollapseOverrides: {},
276
- toggleLocalGroupCollapse: () => {
275
+ arrangement: {},
276
+ updateArrangement: () => {
277
277
  }
278
278
  });
279
279
  function useCanvas() {
@@ -285,6 +285,113 @@ function useEngine() {
285
285
  return engine;
286
286
  }
287
287
 
288
+ // src/utils/arrangement.ts
289
+ import { resolveScopePath } from "@lace-cloud/proto";
290
+ function splitCanvasPath(canvasPath) {
291
+ const lastDot = canvasPath.lastIndexOf(".");
292
+ if (lastDot === -1) return { parentPath: "", localId: canvasPath };
293
+ return { parentPath: canvasPath.slice(0, lastDot), localId: canvasPath.slice(lastDot + 1) };
294
+ }
295
+ function scopeKeyForCanvasPath(bundle, canvasPath) {
296
+ const { parentPath } = splitCanvasPath(canvasPath);
297
+ return resolveScopePath(bundle, parentPath);
298
+ }
299
+ function cloneArrangement(arrangement) {
300
+ const next = {};
301
+ for (const [scope, entry] of Object.entries(arrangement)) {
302
+ next[scope] = {
303
+ nodes: entry.nodes ? { ...entry.nodes } : void 0,
304
+ groups: entry.groups ? { ...entry.groups } : void 0
305
+ };
306
+ }
307
+ return next;
308
+ }
309
+ function withNodePosition(bundle, arrangement, canvasPath, position) {
310
+ const scopeKey = scopeKeyForCanvasPath(bundle, canvasPath);
311
+ if (!scopeKey) return arrangement;
312
+ const { localId } = splitCanvasPath(canvasPath);
313
+ const next = cloneArrangement(arrangement);
314
+ const scopeEntry = next[scopeKey] ?? {};
315
+ next[scopeKey] = { ...scopeEntry, nodes: { ...scopeEntry.nodes, [localId]: position } };
316
+ return next;
317
+ }
318
+ function withNodePositions(bundle, arrangement, positions) {
319
+ let next = arrangement;
320
+ for (const [canvasPath, position] of Object.entries(positions)) {
321
+ next = withNodePosition(bundle, next, canvasPath, position);
322
+ }
323
+ return next;
324
+ }
325
+ function withGroupArrangement(bundle, arrangement, canvasPath, patch) {
326
+ const scopeKey = scopeKeyForCanvasPath(bundle, canvasPath);
327
+ if (!scopeKey) return arrangement;
328
+ const { localId } = splitCanvasPath(canvasPath);
329
+ const next = cloneArrangement(arrangement);
330
+ const scopeEntry = next[scopeKey] ?? {};
331
+ const existing = scopeEntry.groups?.[localId];
332
+ next[scopeKey] = {
333
+ ...scopeEntry,
334
+ groups: {
335
+ ...scopeEntry.groups,
336
+ [localId]: {
337
+ collapsed: patch.collapsed ?? existing?.collapsed ?? true,
338
+ label: patch.label ?? existing?.label
339
+ }
340
+ }
341
+ };
342
+ return next;
343
+ }
344
+ function setScopeEntry(arrangement, scopeKey, entry) {
345
+ const next = cloneArrangement(arrangement);
346
+ next[scopeKey] = entry;
347
+ return next;
348
+ }
349
+ function migrateUngroup(bundle, arrangement, groupCanvasPath, groupModuleKey, promoted = []) {
350
+ const parentScopeKey = scopeKeyForCanvasPath(bundle, groupCanvasPath);
351
+ const groupEntry = arrangement[groupModuleKey];
352
+ if (!parentScopeKey || !groupEntry) return arrangement;
353
+ const { localId } = splitCanvasPath(groupCanvasPath);
354
+ const parentEntry = arrangement[parentScopeKey] ?? {};
355
+ const remainingGroups = parentEntry.groups ? { ...parentEntry.groups } : void 0;
356
+ if (remainingGroups) delete remainingGroups[localId];
357
+ const renameMap = new Map(
358
+ promoted.filter((ref) => ref.scope === parentScopeKey && ref.sourceId).map((ref) => [ref.sourceId, ref.id])
359
+ );
360
+ const rename = (id) => renameMap.get(id) ?? id;
361
+ const migratedNodes = groupEntry.nodes ? Object.fromEntries(Object.entries(groupEntry.nodes).map(([id, pos]) => [rename(id), pos])) : void 0;
362
+ const migratedGroups = groupEntry.groups ? Object.fromEntries(Object.entries(groupEntry.groups).map(([id, g]) => [rename(id), g])) : void 0;
363
+ const groups = remainingGroups || migratedGroups ? { ...remainingGroups, ...migratedGroups } : void 0;
364
+ return setScopeEntry(arrangement, parentScopeKey, {
365
+ nodes: { ...parentEntry.nodes, ...migratedNodes },
366
+ groups
367
+ });
368
+ }
369
+ function gcArrangement(bundle, arrangement) {
370
+ const next = {};
371
+ let changed = false;
372
+ for (const [scopeKey, entry] of Object.entries(arrangement)) {
373
+ const mod = bundle.modules[scopeKey];
374
+ if (!mod) {
375
+ changed = true;
376
+ continue;
377
+ }
378
+ const liveIds = new Set((mod.modules ?? []).map((u) => u.id));
379
+ const nodeEntries = entry.nodes ? Object.entries(entry.nodes) : [];
380
+ const liveNodeEntries = nodeEntries.filter(([id]) => liveIds.has(id));
381
+ const groupEntries = entry.groups ? Object.entries(entry.groups) : [];
382
+ const liveGroupEntries = groupEntries.filter(([id]) => liveIds.has(id));
383
+ if (liveNodeEntries.length !== nodeEntries.length || liveGroupEntries.length !== groupEntries.length) {
384
+ changed = true;
385
+ }
386
+ const nodes = entry.nodes ? Object.fromEntries(liveNodeEntries) : void 0;
387
+ const groups = entry.groups ? Object.fromEntries(liveGroupEntries) : void 0;
388
+ if (nodes && Object.keys(nodes).length > 0 || groups && Object.keys(groups).length > 0) {
389
+ next[scopeKey] = { nodes, groups };
390
+ }
391
+ }
392
+ return changed ? next : arrangement;
393
+ }
394
+
288
395
  // src/components/nodes/GroupNode.tsx
289
396
  import "./GroupNode-EY63N53G.css";
290
397
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
@@ -409,7 +516,7 @@ var AggregatedPinRow = ({ pin, top }) => {
409
516
  };
410
517
  var GroupNode = ({ data }) => {
411
518
  const engine = useEngine();
412
- const { readOnly, toggleLocalGroupCollapse } = useCanvas();
519
+ const { readOnly, arrangement, updateArrangement } = useCanvas();
413
520
  const [editing, setEditing] = useState(false);
414
521
  const [editValue, setEditValue] = useState(data.label);
415
522
  const [hovered, setHovered] = useState(false);
@@ -430,17 +537,16 @@ var GroupNode = ({ data }) => {
430
537
  },
431
538
  [data.label, readOnly]
432
539
  );
433
- const commitRename = useCallback(async () => {
540
+ const commitRename = useCallback(() => {
434
541
  setEditing(false);
435
542
  const trimmed = editValue.trim();
436
- if (trimmed && trimmed !== data.label) {
437
- try {
438
- await engine.updateGroup(data.groupId, { label: trimmed });
439
- } catch (err) {
440
- console.error("[GroupNode] rename failed:", err);
441
- }
543
+ const bundle = engine.getCurrentBundle();
544
+ if (trimmed && trimmed !== data.label && bundle) {
545
+ updateArrangement(
546
+ withGroupArrangement(bundle, arrangement, data.groupId, { label: trimmed })
547
+ );
442
548
  }
443
- }, [editValue, data.label, data.groupId, engine]);
549
+ }, [editValue, data.label, data.groupId, engine, arrangement, updateArrangement]);
444
550
  const onKeyDown = useCallback(
445
551
  (e) => {
446
552
  e.stopPropagation();
@@ -450,30 +556,32 @@ var GroupNode = ({ data }) => {
450
556
  [commitRename]
451
557
  );
452
558
  const toggleCollapsed = useCallback(
453
- async (e) => {
559
+ (e) => {
454
560
  e.stopPropagation();
455
- if (readOnly) {
456
- toggleLocalGroupCollapse(data.groupId, data.collapsed);
457
- return;
458
- }
459
- try {
460
- await engine.updateGroup(data.groupId, { collapsed: !data.collapsed });
461
- } catch (err) {
462
- console.error("[GroupNode] toggle collapsed failed:", err);
463
- }
561
+ const bundle = engine.getCurrentBundle();
562
+ if (!bundle) return;
563
+ updateArrangement(
564
+ withGroupArrangement(bundle, arrangement, data.groupId, { collapsed: !data.collapsed })
565
+ );
464
566
  },
465
- [engine, data.groupId, data.collapsed, readOnly, toggleLocalGroupCollapse]
567
+ [engine, data.groupId, data.collapsed, arrangement, updateArrangement]
466
568
  );
467
569
  const onUngroup = useCallback(
468
570
  async (e) => {
469
571
  e.stopPropagation();
572
+ const bundle = engine.getCurrentBundle();
470
573
  try {
471
- await engine.deleteGroup(data.groupId);
574
+ const result = await engine.ungroup(data.groupId);
575
+ if (result.success && bundle) {
576
+ updateArrangement(
577
+ migrateUngroup(bundle, arrangement, data.groupId, data.moduleKey, result.created)
578
+ );
579
+ }
472
580
  } catch (err) {
473
581
  console.error("[GroupNode] ungroup failed:", err);
474
582
  }
475
583
  },
476
- [engine, data.groupId]
584
+ [engine, data.groupId, data.moduleKey, arrangement, updateArrangement]
477
585
  );
478
586
  const headerProps = {
479
587
  label: data.label,
@@ -1651,6 +1759,7 @@ function PredicateRow({ predicate }) {
1651
1759
  }
1652
1760
 
1653
1761
  // src/components/panels/RegistryBrowser.tsx
1762
+ import { resolveScopePositions } from "@lace-cloud/proto";
1654
1763
  import { Button as Button2, Input as Input2, Panel as Panel5, Spinner } from "@lace-cloud/ui";
1655
1764
  import { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo3, useState as useState6 } from "react";
1656
1765
  import "./RegistryBrowser-3G22I4EO.css";
@@ -1662,7 +1771,7 @@ function RegistryBrowser({
1662
1771
  showToast,
1663
1772
  onClose
1664
1773
  }) {
1665
- const { readOnly } = useCanvas();
1774
+ const { readOnly, arrangement, updateArrangement } = useCanvas();
1666
1775
  const [modules, setModules] = useState6([]);
1667
1776
  const [loading, setLoading] = useState6(true);
1668
1777
  const [error, setError] = useState6(null);
@@ -1727,6 +1836,23 @@ function RegistryBrowser({
1727
1836
  if (!result.success) {
1728
1837
  showToast(result.errors[0]?.message ?? "Failed to place module", "error");
1729
1838
  } else {
1839
+ const created = result.created[0];
1840
+ const bundle = engine.getCurrentBundle();
1841
+ if (created && bundle) {
1842
+ const scopeEntry = arrangement[created.scope] ?? {};
1843
+ const existingIds = Object.keys(scopeEntry.nodes ?? {});
1844
+ const slot = resolveScopePositions([...existingIds, created.id], scopeEntry.nodes).get(
1845
+ created.id
1846
+ );
1847
+ if (slot) {
1848
+ updateArrangement(
1849
+ setScopeEntry(arrangement, created.scope, {
1850
+ ...scopeEntry,
1851
+ nodes: { ...scopeEntry.nodes, [created.id]: slot }
1852
+ })
1853
+ );
1854
+ }
1855
+ }
1730
1856
  onClose();
1731
1857
  }
1732
1858
  } catch (err) {
@@ -1735,7 +1861,7 @@ function RegistryBrowser({
1735
1861
  setPlacing(null);
1736
1862
  }
1737
1863
  },
1738
- [engine, onClose, readOnly, showToast]
1864
+ [engine, arrangement, updateArrangement, onClose, readOnly, showToast]
1739
1865
  );
1740
1866
  return /* @__PURE__ */ jsx10(Panel5, { title: "Registry", width: 380, onClose, scrollable: true, children: /* @__PURE__ */ jsxs10("div", { className: "lace-registry-browser", children: [
1741
1867
  /* @__PURE__ */ jsx10("div", { className: "lace-registry-browser__search", children: /* @__PURE__ */ jsx10(
@@ -3480,8 +3606,47 @@ function extractNodeId(d, nodeIds) {
3480
3606
  }
3481
3607
 
3482
3608
  // src/hooks/useClipboard.ts
3609
+ import { resolveScopePositions as resolveScopePositions2 } from "@lace-cloud/proto";
3483
3610
  import { useCallback as useCallback12, useEffect as useEffect10, useRef as useRef5 } from "react";
3484
- function useClipboard(engine, view, showToast, getSelectedIds, selectNodes, getContextMenuNodeId, dismissContextMenu, readOnly) {
3611
+ function placeCreatedClones(arrangement, sourceIds, created) {
3612
+ const parentPath = sourceIds.length > 0 ? splitCanvasPath(sourceIds[0]).parentPath : "";
3613
+ const byScope = /* @__PURE__ */ new Map();
3614
+ for (const ref of created) {
3615
+ if (!ref.sourceId) continue;
3616
+ const list = byScope.get(ref.scope) ?? [];
3617
+ list.push(ref);
3618
+ byScope.set(ref.scope, list);
3619
+ }
3620
+ let next = arrangement;
3621
+ const clonePaths = [];
3622
+ for (const [scopeKey, refs] of byScope) {
3623
+ const scopeEntry = next[scopeKey] ?? {};
3624
+ const sourcePositions = /* @__PURE__ */ new Map();
3625
+ for (const ref of refs) {
3626
+ const pos = scopeEntry.nodes?.[ref.sourceId];
3627
+ if (pos) sourcePositions.set(ref.sourceId, pos);
3628
+ }
3629
+ const xs = [...sourcePositions.values()].map((p) => p.x);
3630
+ const ys = [...sourcePositions.values()].map((p) => p.y);
3631
+ const minX = xs.length > 0 ? Math.min(...xs) : 0;
3632
+ const minY = ys.length > 0 ? Math.min(...ys) : 0;
3633
+ const existingIds = Object.keys(scopeEntry.nodes ?? {});
3634
+ const anchorMap = resolveScopePositions2([...existingIds, "__paste_anchor__"], scopeEntry.nodes);
3635
+ const anchor = anchorMap.get("__paste_anchor__") ?? { x: 0, y: 0 };
3636
+ const newNodes = {};
3637
+ for (const ref of refs) {
3638
+ const src = sourcePositions.get(ref.sourceId) ?? { x: minX, y: minY };
3639
+ newNodes[ref.id] = { x: anchor.x + (src.x - minX), y: anchor.y + (src.y - minY) };
3640
+ clonePaths.push(parentPath ? `${parentPath}.${ref.id}` : ref.id);
3641
+ }
3642
+ next = setScopeEntry(next, scopeKey, {
3643
+ ...scopeEntry,
3644
+ nodes: { ...scopeEntry.nodes, ...newNodes }
3645
+ });
3646
+ }
3647
+ return { arrangement: next, clonePaths };
3648
+ }
3649
+ function useClipboard(engine, arrangement, updateArrangement, showToast, getSelectedIds, selectNodes, getContextMenuNodeId, dismissContextMenu, readOnly) {
3485
3650
  const clipboardRef = useRef5([]);
3486
3651
  const isCutRef = useRef5(false);
3487
3652
  const onCopy = useCallback12(() => {
@@ -3520,18 +3685,20 @@ function useClipboard(engine, view, showToast, getSelectedIds, selectNodes, getC
3520
3685
  }
3521
3686
  const ids = clipboardRef.current;
3522
3687
  try {
3523
- const prevIds = new Set((view?.nodes ?? []).map((n) => n.id));
3524
3688
  const result = await engine.copyInstances(ids);
3525
3689
  if (!result.success) {
3526
3690
  showToast(result.errors[0]?.message ?? "Paste failed", "error");
3527
3691
  return;
3528
3692
  }
3529
- const current = engine.getCurrentView();
3530
- const newIds = (current?.nodes ?? []).filter((n) => !prevIds.has(n.id) && !ids.includes(n.id)).map((n) => n.id);
3531
- if (newIds.length > 0) {
3532
- selectNodes(newIds);
3533
- } else if (!isCutRef.current) {
3534
- showToast("Paste produced no new nodes \u2014 nothing pasted", "error");
3693
+ const created = result.created.filter((c) => c.sourceId);
3694
+ if (created.length === 0) {
3695
+ if (!isCutRef.current) {
3696
+ showToast("Paste produced no new nodes \u2014 nothing pasted", "error");
3697
+ }
3698
+ } else {
3699
+ const { arrangement: next, clonePaths } = placeCreatedClones(arrangement, ids, created);
3700
+ updateArrangement(next);
3701
+ selectNodes(clonePaths);
3535
3702
  }
3536
3703
  if (isCutRef.current) {
3537
3704
  for (const id of ids) {
@@ -3548,7 +3715,7 @@ function useClipboard(engine, view, showToast, getSelectedIds, selectNodes, getC
3548
3715
  console.error("[Canvas] paste failed:", err);
3549
3716
  showToast("Paste failed \u2014 try again", "error");
3550
3717
  }
3551
- }, [engine, view, showToast, selectNodes, dismissContextMenu]);
3718
+ }, [engine, arrangement, updateArrangement, showToast, selectNodes, dismissContextMenu]);
3552
3719
  useEffect10(() => {
3553
3720
  if (readOnly) return;
3554
3721
  window.__canvasCopy = onCopy;
@@ -3801,6 +3968,7 @@ function useGroupLogic(nodes, edges, groups, newNodeIds, erroredNodeIds) {
3801
3968
  hidden: hiddenByAncestor,
3802
3969
  data: {
3803
3970
  groupId: group.id,
3971
+ moduleKey: group.module_key ?? "",
3804
3972
  label: group.label,
3805
3973
  memberCount: memberNodes.length,
3806
3974
  collapsed: true,
@@ -3832,6 +4000,7 @@ function useGroupLogic(nodes, edges, groups, newNodeIds, erroredNodeIds) {
3832
4000
  },
3833
4001
  data: {
3834
4002
  groupId: group.id,
4003
+ moduleKey: group.module_key ?? "",
3835
4004
  label: group.label,
3836
4005
  memberCount: memberNodes.length,
3837
4006
  collapsed: false,
@@ -4115,15 +4284,6 @@ function parseHandleId(handleId, prefix) {
4115
4284
  return name.length > 0 ? name : null;
4116
4285
  }
4117
4286
 
4118
- // src/utils/view-state.ts
4119
- function applyLocalGroupCollapseOverrides(view, overrides, readOnly) {
4120
- if (!readOnly || Object.keys(overrides).length === 0) return view;
4121
- return {
4122
- ...view,
4123
- groups: view.groups.map((g) => g.id in overrides ? { ...g, collapsed: overrides[g.id] } : g)
4124
- };
4125
- }
4126
-
4127
4287
  // src/Canvas.tsx
4128
4288
  import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
4129
4289
  var nodeTypes = {
@@ -4401,7 +4561,7 @@ function CompositeEditor({
4401
4561
  );
4402
4562
  }
4403
4563
  function Canvas({ height, registryBaseUrl, apiToken }) {
4404
- const { state, readOnly, localGroupCollapseOverrides } = useCanvas();
4564
+ const { state, readOnly, arrangement, updateArrangement } = useCanvas();
4405
4565
  const engine = useEngine();
4406
4566
  const viewRef = useRef8(state.view);
4407
4567
  viewRef.current = state.view;
@@ -4439,7 +4599,8 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4439
4599
  }, []);
4440
4600
  const { onCopy, onCut, onPaste } = useClipboard(
4441
4601
  engine,
4442
- state.view,
4602
+ arrangement,
4603
+ updateArrangement,
4443
4604
  showToast,
4444
4605
  useCallback20(() => getSelectedIdsRef.current?.() ?? [], []),
4445
4606
  useCallback20((ids) => selectNodesRef.current?.(ids), []),
@@ -4476,11 +4637,12 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4476
4637
  };
4477
4638
  }, [onUndo, readOnly]);
4478
4639
  const onDragStop = useCallback20(
4479
- async (positions) => {
4480
- if (!engine || readOnly) return;
4481
- await engine.syncLayout(positions);
4640
+ (positions) => {
4641
+ const bundle = engine.getCurrentBundle();
4642
+ if (!bundle) return;
4643
+ updateArrangement(withNodePositions(bundle, arrangement, positions));
4482
4644
  },
4483
- [engine, readOnly]
4645
+ [engine, arrangement, updateArrangement]
4484
4646
  );
4485
4647
  const onConnect = useCallback20(
4486
4648
  async (conn) => {
@@ -4542,20 +4704,91 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4542
4704
  },
4543
4705
  [engine, showToast]
4544
4706
  );
4707
+ const onGroupSelected = useCallback20(async () => {
4708
+ const ids = getSelectedIdsRef.current?.() ?? [];
4709
+ const bundle = engine.getCurrentBundle();
4710
+ if (ids.length < 2 || !bundle) return;
4711
+ try {
4712
+ const label = `Group ${ids.length}`;
4713
+ const result = await engine.createGroup(ids);
4714
+ if (!result.success) {
4715
+ showToast(result.errors[0]?.message ?? "Failed to create group", "error");
4716
+ return;
4717
+ }
4718
+ const created = result.created[0];
4719
+ if (created?.moduleKey) {
4720
+ const migratedNodes = {};
4721
+ const memberPositions = [];
4722
+ for (const id of ids) {
4723
+ const scopeKey = scopeKeyForCanvasPath(bundle, id);
4724
+ const { localId } = splitCanvasPath(id);
4725
+ const position = scopeKey ? arrangement[scopeKey]?.nodes?.[localId] : void 0;
4726
+ if (position) {
4727
+ migratedNodes[localId] = position;
4728
+ memberPositions.push(position);
4729
+ }
4730
+ }
4731
+ let next = setScopeEntry(arrangement, created.moduleKey, { nodes: migratedNodes });
4732
+ const parentEntry = next[created.scope] ?? {};
4733
+ next = setScopeEntry(next, created.scope, {
4734
+ ...parentEntry,
4735
+ groups: { ...parentEntry.groups, [created.id]: { label, collapsed: true } }
4736
+ });
4737
+ if (memberPositions.length > 0) {
4738
+ const centroid = {
4739
+ x: memberPositions.reduce((sum, p) => sum + p.x, 0) / memberPositions.length,
4740
+ y: memberPositions.reduce((sum, p) => sum + p.y, 0) / memberPositions.length
4741
+ };
4742
+ const parentEntryWithGroup = next[created.scope] ?? {};
4743
+ next = setScopeEntry(next, created.scope, {
4744
+ ...parentEntryWithGroup,
4745
+ nodes: { ...parentEntryWithGroup.nodes, [created.id]: centroid }
4746
+ });
4747
+ }
4748
+ updateArrangement(next);
4749
+ }
4750
+ dismissContextMenu();
4751
+ } catch (err) {
4752
+ showToast(`Failed to create group: ${err.message}`, "error");
4753
+ }
4754
+ }, [engine, arrangement, updateArrangement, dismissContextMenu, showToast]);
4755
+ const performUngroup = useCallback20(
4756
+ async (groupId) => {
4757
+ const bundle = engine.getCurrentBundle();
4758
+ const group = state.view?.groups.find((g) => g.id === groupId);
4759
+ try {
4760
+ const result = await engine.ungroup(groupId);
4761
+ if (!result.success) {
4762
+ showToast(result.errors[0]?.message ?? "Failed to ungroup", "error");
4763
+ return;
4764
+ }
4765
+ if (bundle && group?.module_key) {
4766
+ updateArrangement(
4767
+ migrateUngroup(bundle, arrangement, groupId, group.module_key, result.created)
4768
+ );
4769
+ }
4770
+ dismissContextMenu();
4771
+ } catch (err) {
4772
+ showToast(`Failed to ungroup: ${err.message}`, "error");
4773
+ }
4774
+ },
4775
+ [engine, arrangement, updateArrangement, state.view, dismissContextMenu, showToast]
4776
+ );
4545
4777
  const onNodesDelete = useCallback20(
4546
4778
  async (nodes) => {
4547
4779
  if (!engine) return;
4548
4780
  for (const node of nodes) {
4549
- const result = node.type === "groupNode" ? (
4550
- // Delete on a group node → ungroup (remove container, keep instances)
4551
- await engine.deleteGroup(node.id)
4552
- ) : await engine.deleteInstance(node.id);
4781
+ if (node.type === "groupNode") {
4782
+ await performUngroup(node.id);
4783
+ continue;
4784
+ }
4785
+ const result = await engine.deleteInstance(node.id);
4553
4786
  if (!result.success) {
4554
4787
  showToast(result.errors[0]?.message ?? "Delete failed", "error");
4555
4788
  }
4556
4789
  }
4557
4790
  },
4558
- [engine, showToast]
4791
+ [engine, performUngroup, showToast]
4559
4792
  );
4560
4793
  const onClearGraph = useCallback20(async () => {
4561
4794
  if (!engine || !state.view) return;
@@ -4574,37 +4807,6 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4574
4807
  const onOpenPolicy = useCallback20(() => {
4575
4808
  setPolicyOpen(true);
4576
4809
  }, []);
4577
- const onGroupSelected = useCallback20(async () => {
4578
- const ids = getSelectedIdsRef.current?.() ?? [];
4579
- if (ids.length < 2 || !engine) return;
4580
- try {
4581
- const label = `Group ${ids.length}`;
4582
- const result = await engine.createGroup(label, ids);
4583
- if (!result.success) {
4584
- showToast(result.errors[0]?.message ?? "Failed to create group", "error");
4585
- return;
4586
- }
4587
- dismissContextMenu();
4588
- } catch (err) {
4589
- showToast(`Failed to create group: ${err.message}`, "error");
4590
- }
4591
- }, [engine, dismissContextMenu, showToast]);
4592
- const onUngroup = useCallback20(
4593
- async (groupId) => {
4594
- if (!engine) return;
4595
- try {
4596
- const result = await engine.deleteGroup(groupId);
4597
- if (!result.success) {
4598
- showToast(result.errors[0]?.message ?? "Failed to ungroup", "error");
4599
- return;
4600
- }
4601
- dismissContextMenu();
4602
- } catch (err) {
4603
- showToast(`Failed to ungroup: ${err.message}`, "error");
4604
- }
4605
- },
4606
- [engine, dismissContextMenu, showToast]
4607
- );
4608
4810
  if (state.loadError) {
4609
4811
  return /* @__PURE__ */ jsx21(ErrorState, { message: state.loadError });
4610
4812
  }
@@ -4624,11 +4826,7 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4624
4826
  }
4625
4827
  );
4626
4828
  }
4627
- const view = applyLocalGroupCollapseOverrides(
4628
- state.view,
4629
- localGroupCollapseOverrides,
4630
- readOnly
4631
- );
4829
+ const view = state.view;
4632
4830
  return /* @__PURE__ */ jsxs19("div", { style: { position: "relative", display: "flex", flexDirection: "column", height }, children: [
4633
4831
  /* @__PURE__ */ jsx21(Toast, { toast }),
4634
4832
  /* @__PURE__ */ jsx21(
@@ -4639,7 +4837,7 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4639
4837
  onCut,
4640
4838
  onPaste,
4641
4839
  onGroupSelected,
4642
- onUngroup,
4840
+ onUngroup: performUngroup,
4643
4841
  onDismiss: dismissContextMenu
4644
4842
  }
4645
4843
  ),
@@ -4762,7 +4960,9 @@ function App({
4762
4960
  height = "100vh",
4763
4961
  readOnly = false,
4764
4962
  registryBaseUrl,
4765
- apiToken
4963
+ apiToken,
4964
+ arrangement: initialArrangement,
4965
+ onArrangementChange
4766
4966
  }) {
4767
4967
  const [state, setState] = useState24({
4768
4968
  view: null,
@@ -4772,10 +4972,18 @@ function App({
4772
4972
  viewportIntentSeq: 0,
4773
4973
  loadError: null
4774
4974
  });
4775
- const [localGroupCollapseOverrides, setLocalGroupCollapseOverrides] = useState24({});
4776
- const toggleLocalGroupCollapse = useCallback21((groupId, currentCollapsed) => {
4777
- setLocalGroupCollapseOverrides((prev) => ({ ...prev, [groupId]: !currentCollapsed }));
4778
- }, []);
4975
+ const [arrangement, setArrangementState] = useState24(initialArrangement ?? {});
4976
+ const updateArrangement = useCallback21(
4977
+ (next) => {
4978
+ setArrangementState(next);
4979
+ engine.setArrangement(next);
4980
+ onArrangementChange?.(next);
4981
+ },
4982
+ [engine, onArrangementChange]
4983
+ );
4984
+ useEffect17(() => {
4985
+ engine.setArrangement(arrangement);
4986
+ }, [engine]);
4779
4987
  const refitOnNextStateRef = useRef10(true);
4780
4988
  useEffect17(() => {
4781
4989
  refitOnNextStateRef.current = true;
@@ -4792,11 +5000,20 @@ function App({
4792
5000
  viewportIntentSeq: prev.viewportIntentSeq + (viewportIntent ? 1 : 0),
4793
5001
  loadError: null
4794
5002
  }));
5003
+ const bundle = engine.getCurrentBundle();
5004
+ if (bundle) {
5005
+ setArrangementState((prev) => {
5006
+ const gced = gcArrangement(bundle, prev);
5007
+ if (gced === prev) return prev;
5008
+ onArrangementChange?.(gced);
5009
+ return gced;
5010
+ });
5011
+ }
4795
5012
  } else if (event.type === "loadError") {
4796
5013
  setState((prev) => ({ ...prev, loading: false, loadError: event.message }));
4797
5014
  }
4798
5015
  });
4799
- }, [engine]);
5016
+ }, [engine, onArrangementChange]);
4800
5017
  const isDirty = state.view?.is_dirty;
4801
5018
  useEffect17(() => {
4802
5019
  if (isDirty === void 0) return;
@@ -4821,8 +5038,8 @@ function App({
4821
5038
  state,
4822
5039
  engine,
4823
5040
  readOnly,
4824
- localGroupCollapseOverrides,
4825
- toggleLocalGroupCollapse
5041
+ arrangement,
5042
+ updateArrangement
4826
5043
  },
4827
5044
  children: /* @__PURE__ */ jsx22(ReactFlowProvider, { children: /* @__PURE__ */ jsx22(Canvas, { height, registryBaseUrl, apiToken }) })
4828
5045
  }
@@ -8368,23 +8585,46 @@ var ProviderConfig_ConfigEntry = {
8368
8585
  return message;
8369
8586
  }
8370
8587
  };
8371
- function createBaseGraphLayout() {
8372
- return { nodes: {}, groups: {} };
8588
+ function createBasePolicyResolution() {
8589
+ return {
8590
+ mode: "",
8591
+ policy_id: "",
8592
+ rules_fired: [],
8593
+ reason: "",
8594
+ approval_mode: "",
8595
+ condition_trace: [],
8596
+ is_authoring_time_preview: false
8597
+ };
8373
8598
  }
8374
- var GraphLayout = {
8599
+ var PolicyResolution = {
8375
8600
  encode(message, writer = new BinaryWriter3()) {
8376
- globalThis.Object.entries(message.nodes).forEach(([key, value]) => {
8377
- GraphLayout_NodesEntry.encode({ key, value }, writer.uint32(10).fork()).join();
8378
- });
8379
- globalThis.Object.entries(message.groups).forEach(([key, value]) => {
8380
- GraphLayout_GroupsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
8381
- });
8601
+ if (message.mode !== "") {
8602
+ writer.uint32(10).string(message.mode);
8603
+ }
8604
+ if (message.policy_id !== "") {
8605
+ writer.uint32(26).string(message.policy_id);
8606
+ }
8607
+ for (const v of message.rules_fired) {
8608
+ writer.uint32(34).string(v);
8609
+ }
8610
+ if (message.reason !== "") {
8611
+ writer.uint32(42).string(message.reason);
8612
+ }
8613
+ if (message.approval_mode !== "") {
8614
+ writer.uint32(50).string(message.approval_mode);
8615
+ }
8616
+ for (const v of message.condition_trace) {
8617
+ PolicyConditionTrace.encode(v, writer.uint32(58).fork()).join();
8618
+ }
8619
+ if (message.is_authoring_time_preview !== false) {
8620
+ writer.uint32(64).bool(message.is_authoring_time_preview);
8621
+ }
8382
8622
  return writer;
8383
8623
  },
8384
8624
  decode(input, length) {
8385
8625
  const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
8386
8626
  const end = length === void 0 ? reader.len : reader.pos + length;
8387
- const message = createBaseGraphLayout();
8627
+ const message = createBasePolicyResolution();
8388
8628
  while (reader.pos < end) {
8389
8629
  const tag = reader.uint32();
8390
8630
  switch (tag >>> 3) {
@@ -8392,20 +8632,49 @@ var GraphLayout = {
8392
8632
  if (tag !== 10) {
8393
8633
  break;
8394
8634
  }
8395
- const entry1 = GraphLayout_NodesEntry.decode(reader, reader.uint32());
8396
- if (entry1.value !== void 0) {
8397
- message.nodes[entry1.key] = entry1.value;
8635
+ message.mode = reader.string();
8636
+ continue;
8637
+ }
8638
+ case 3: {
8639
+ if (tag !== 26) {
8640
+ break;
8398
8641
  }
8642
+ message.policy_id = reader.string();
8399
8643
  continue;
8400
8644
  }
8401
- case 2: {
8402
- if (tag !== 18) {
8645
+ case 4: {
8646
+ if (tag !== 34) {
8403
8647
  break;
8404
8648
  }
8405
- const entry2 = GraphLayout_GroupsEntry.decode(reader, reader.uint32());
8406
- if (entry2.value !== void 0) {
8407
- message.groups[entry2.key] = entry2.value;
8649
+ message.rules_fired.push(reader.string());
8650
+ continue;
8651
+ }
8652
+ case 5: {
8653
+ if (tag !== 42) {
8654
+ break;
8655
+ }
8656
+ message.reason = reader.string();
8657
+ continue;
8658
+ }
8659
+ case 6: {
8660
+ if (tag !== 50) {
8661
+ break;
8662
+ }
8663
+ message.approval_mode = reader.string();
8664
+ continue;
8665
+ }
8666
+ case 7: {
8667
+ if (tag !== 58) {
8668
+ break;
8669
+ }
8670
+ message.condition_trace.push(PolicyConditionTrace.decode(reader, reader.uint32()));
8671
+ continue;
8672
+ }
8673
+ case 8: {
8674
+ if (tag !== 64) {
8675
+ break;
8408
8676
  }
8677
+ message.is_authoring_time_preview = reader.bool();
8409
8678
  continue;
8410
8679
  }
8411
8680
  }
@@ -8418,705 +8687,42 @@ var GraphLayout = {
8418
8687
  },
8419
8688
  fromJSON(object) {
8420
8689
  return {
8421
- nodes: isObject2(object.nodes) ? globalThis.Object.entries(object.nodes).reduce(
8422
- (acc, [key, value]) => {
8423
- acc[key] = NodeLayout.fromJSON(value);
8424
- return acc;
8425
- },
8426
- {}
8427
- ) : {},
8428
- groups: isObject2(object.groups) ? globalThis.Object.entries(object.groups).reduce(
8429
- (acc, [key, value]) => {
8430
- acc[key] = NodeGroup.fromJSON(value);
8431
- return acc;
8432
- },
8433
- {}
8434
- ) : {}
8690
+ mode: isSet2(object.mode) ? globalThis.String(object.mode) : "",
8691
+ policy_id: isSet2(object.policyId) ? globalThis.String(object.policyId) : isSet2(object.policy_id) ? globalThis.String(object.policy_id) : "",
8692
+ rules_fired: globalThis.Array.isArray(object?.rulesFired) ? object.rulesFired.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.rules_fired) ? object.rules_fired.map((e) => globalThis.String(e)) : [],
8693
+ reason: isSet2(object.reason) ? globalThis.String(object.reason) : "",
8694
+ approval_mode: isSet2(object.approvalMode) ? globalThis.String(object.approvalMode) : isSet2(object.approval_mode) ? globalThis.String(object.approval_mode) : "",
8695
+ condition_trace: globalThis.Array.isArray(object?.conditionTrace) ? object.conditionTrace.map((e) => PolicyConditionTrace.fromJSON(e)) : globalThis.Array.isArray(object?.condition_trace) ? object.condition_trace.map((e) => PolicyConditionTrace.fromJSON(e)) : [],
8696
+ is_authoring_time_preview: isSet2(object.isAuthoringTimePreview) ? globalThis.Boolean(object.isAuthoringTimePreview) : isSet2(object.is_authoring_time_preview) ? globalThis.Boolean(object.is_authoring_time_preview) : false
8435
8697
  };
8436
8698
  },
8437
8699
  toJSON(message) {
8438
8700
  const obj = {};
8439
- if (message.nodes) {
8440
- const entries = globalThis.Object.entries(message.nodes);
8441
- if (entries.length > 0) {
8442
- obj.nodes = {};
8443
- entries.forEach(([k, v]) => {
8444
- obj.nodes[k] = NodeLayout.toJSON(v);
8445
- });
8446
- }
8701
+ if (message.mode !== "") {
8702
+ obj.mode = message.mode;
8447
8703
  }
8448
- if (message.groups) {
8449
- const entries = globalThis.Object.entries(message.groups);
8450
- if (entries.length > 0) {
8451
- obj.groups = {};
8452
- entries.forEach(([k, v]) => {
8453
- obj.groups[k] = NodeGroup.toJSON(v);
8454
- });
8455
- }
8704
+ if (message.policy_id !== "") {
8705
+ obj.policyId = message.policy_id;
8706
+ }
8707
+ if (message.rules_fired?.length) {
8708
+ obj.rulesFired = message.rules_fired;
8709
+ }
8710
+ if (message.reason !== "") {
8711
+ obj.reason = message.reason;
8712
+ }
8713
+ if (message.approval_mode !== "") {
8714
+ obj.approvalMode = message.approval_mode;
8715
+ }
8716
+ if (message.condition_trace?.length) {
8717
+ obj.conditionTrace = message.condition_trace.map((e) => PolicyConditionTrace.toJSON(e));
8718
+ }
8719
+ if (message.is_authoring_time_preview !== false) {
8720
+ obj.isAuthoringTimePreview = message.is_authoring_time_preview;
8456
8721
  }
8457
8722
  return obj;
8458
8723
  },
8459
8724
  create(base) {
8460
- return GraphLayout.fromPartial(base ?? {});
8461
- },
8462
- fromPartial(object) {
8463
- const message = createBaseGraphLayout();
8464
- message.nodes = globalThis.Object.entries(object.nodes ?? {}).reduce(
8465
- (acc, [key, value]) => {
8466
- if (value !== void 0) {
8467
- acc[key] = NodeLayout.fromPartial(value);
8468
- }
8469
- return acc;
8470
- },
8471
- {}
8472
- );
8473
- message.groups = globalThis.Object.entries(object.groups ?? {}).reduce(
8474
- (acc, [key, value]) => {
8475
- if (value !== void 0) {
8476
- acc[key] = NodeGroup.fromPartial(value);
8477
- }
8478
- return acc;
8479
- },
8480
- {}
8481
- );
8482
- return message;
8483
- }
8484
- };
8485
- function createBaseGraphLayout_NodesEntry() {
8486
- return { key: "", value: void 0 };
8487
- }
8488
- var GraphLayout_NodesEntry = {
8489
- encode(message, writer = new BinaryWriter3()) {
8490
- if (message.key !== "") {
8491
- writer.uint32(10).string(message.key);
8492
- }
8493
- if (message.value !== void 0) {
8494
- NodeLayout.encode(message.value, writer.uint32(18).fork()).join();
8495
- }
8496
- return writer;
8497
- },
8498
- decode(input, length) {
8499
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
8500
- const end = length === void 0 ? reader.len : reader.pos + length;
8501
- const message = createBaseGraphLayout_NodesEntry();
8502
- while (reader.pos < end) {
8503
- const tag = reader.uint32();
8504
- switch (tag >>> 3) {
8505
- case 1: {
8506
- if (tag !== 10) {
8507
- break;
8508
- }
8509
- message.key = reader.string();
8510
- continue;
8511
- }
8512
- case 2: {
8513
- if (tag !== 18) {
8514
- break;
8515
- }
8516
- message.value = NodeLayout.decode(reader, reader.uint32());
8517
- continue;
8518
- }
8519
- }
8520
- if ((tag & 7) === 4 || tag === 0) {
8521
- break;
8522
- }
8523
- reader.skip(tag & 7);
8524
- }
8525
- return message;
8526
- },
8527
- fromJSON(object) {
8528
- return {
8529
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
8530
- value: isSet2(object.value) ? NodeLayout.fromJSON(object.value) : void 0
8531
- };
8532
- },
8533
- toJSON(message) {
8534
- const obj = {};
8535
- if (message.key !== "") {
8536
- obj.key = message.key;
8537
- }
8538
- if (message.value !== void 0) {
8539
- obj.value = NodeLayout.toJSON(message.value);
8540
- }
8541
- return obj;
8542
- },
8543
- create(base) {
8544
- return GraphLayout_NodesEntry.fromPartial(base ?? {});
8545
- },
8546
- fromPartial(object) {
8547
- const message = createBaseGraphLayout_NodesEntry();
8548
- message.key = object.key ?? "";
8549
- message.value = object.value !== void 0 && object.value !== null ? NodeLayout.fromPartial(object.value) : void 0;
8550
- return message;
8551
- }
8552
- };
8553
- function createBaseGraphLayout_GroupsEntry() {
8554
- return { key: "", value: void 0 };
8555
- }
8556
- var GraphLayout_GroupsEntry = {
8557
- encode(message, writer = new BinaryWriter3()) {
8558
- if (message.key !== "") {
8559
- writer.uint32(10).string(message.key);
8560
- }
8561
- if (message.value !== void 0) {
8562
- NodeGroup.encode(message.value, writer.uint32(18).fork()).join();
8563
- }
8564
- return writer;
8565
- },
8566
- decode(input, length) {
8567
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
8568
- const end = length === void 0 ? reader.len : reader.pos + length;
8569
- const message = createBaseGraphLayout_GroupsEntry();
8570
- while (reader.pos < end) {
8571
- const tag = reader.uint32();
8572
- switch (tag >>> 3) {
8573
- case 1: {
8574
- if (tag !== 10) {
8575
- break;
8576
- }
8577
- message.key = reader.string();
8578
- continue;
8579
- }
8580
- case 2: {
8581
- if (tag !== 18) {
8582
- break;
8583
- }
8584
- message.value = NodeGroup.decode(reader, reader.uint32());
8585
- continue;
8586
- }
8587
- }
8588
- if ((tag & 7) === 4 || tag === 0) {
8589
- break;
8590
- }
8591
- reader.skip(tag & 7);
8592
- }
8593
- return message;
8594
- },
8595
- fromJSON(object) {
8596
- return {
8597
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
8598
- value: isSet2(object.value) ? NodeGroup.fromJSON(object.value) : void 0
8599
- };
8600
- },
8601
- toJSON(message) {
8602
- const obj = {};
8603
- if (message.key !== "") {
8604
- obj.key = message.key;
8605
- }
8606
- if (message.value !== void 0) {
8607
- obj.value = NodeGroup.toJSON(message.value);
8608
- }
8609
- return obj;
8610
- },
8611
- create(base) {
8612
- return GraphLayout_GroupsEntry.fromPartial(base ?? {});
8613
- },
8614
- fromPartial(object) {
8615
- const message = createBaseGraphLayout_GroupsEntry();
8616
- message.key = object.key ?? "";
8617
- message.value = object.value !== void 0 && object.value !== null ? NodeGroup.fromPartial(object.value) : void 0;
8618
- return message;
8619
- }
8620
- };
8621
- function createBaseNodeGroup() {
8622
- return { id: "", label: "", node_ids: [], collapsed: false };
8623
- }
8624
- var NodeGroup = {
8625
- encode(message, writer = new BinaryWriter3()) {
8626
- if (message.id !== "") {
8627
- writer.uint32(10).string(message.id);
8628
- }
8629
- if (message.label !== "") {
8630
- writer.uint32(18).string(message.label);
8631
- }
8632
- for (const v of message.node_ids) {
8633
- writer.uint32(26).string(v);
8634
- }
8635
- if (message.collapsed !== false) {
8636
- writer.uint32(32).bool(message.collapsed);
8637
- }
8638
- return writer;
8639
- },
8640
- decode(input, length) {
8641
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
8642
- const end = length === void 0 ? reader.len : reader.pos + length;
8643
- const message = createBaseNodeGroup();
8644
- while (reader.pos < end) {
8645
- const tag = reader.uint32();
8646
- switch (tag >>> 3) {
8647
- case 1: {
8648
- if (tag !== 10) {
8649
- break;
8650
- }
8651
- message.id = reader.string();
8652
- continue;
8653
- }
8654
- case 2: {
8655
- if (tag !== 18) {
8656
- break;
8657
- }
8658
- message.label = reader.string();
8659
- continue;
8660
- }
8661
- case 3: {
8662
- if (tag !== 26) {
8663
- break;
8664
- }
8665
- message.node_ids.push(reader.string());
8666
- continue;
8667
- }
8668
- case 4: {
8669
- if (tag !== 32) {
8670
- break;
8671
- }
8672
- message.collapsed = reader.bool();
8673
- continue;
8674
- }
8675
- }
8676
- if ((tag & 7) === 4 || tag === 0) {
8677
- break;
8678
- }
8679
- reader.skip(tag & 7);
8680
- }
8681
- return message;
8682
- },
8683
- fromJSON(object) {
8684
- return {
8685
- id: isSet2(object.id) ? globalThis.String(object.id) : "",
8686
- label: isSet2(object.label) ? globalThis.String(object.label) : "",
8687
- node_ids: globalThis.Array.isArray(object?.nodeIds) ? object.nodeIds.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.node_ids) ? object.node_ids.map((e) => globalThis.String(e)) : [],
8688
- collapsed: isSet2(object.collapsed) ? globalThis.Boolean(object.collapsed) : false
8689
- };
8690
- },
8691
- toJSON(message) {
8692
- const obj = {};
8693
- if (message.id !== "") {
8694
- obj.id = message.id;
8695
- }
8696
- if (message.label !== "") {
8697
- obj.label = message.label;
8698
- }
8699
- if (message.node_ids?.length) {
8700
- obj.nodeIds = message.node_ids;
8701
- }
8702
- if (message.collapsed !== false) {
8703
- obj.collapsed = message.collapsed;
8704
- }
8705
- return obj;
8706
- },
8707
- create(base) {
8708
- return NodeGroup.fromPartial(base ?? {});
8709
- },
8710
- fromPartial(object) {
8711
- const message = createBaseNodeGroup();
8712
- message.id = object.id ?? "";
8713
- message.label = object.label ?? "";
8714
- message.node_ids = object.node_ids?.map((e) => e) || [];
8715
- message.collapsed = object.collapsed ?? false;
8716
- return message;
8717
- }
8718
- };
8719
- function createBaseNodeLayout() {
8720
- return { position: void 0 };
8721
- }
8722
- var NodeLayout = {
8723
- encode(message, writer = new BinaryWriter3()) {
8724
- if (message.position !== void 0) {
8725
- Position3.encode(message.position, writer.uint32(10).fork()).join();
8726
- }
8727
- return writer;
8728
- },
8729
- decode(input, length) {
8730
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
8731
- const end = length === void 0 ? reader.len : reader.pos + length;
8732
- const message = createBaseNodeLayout();
8733
- while (reader.pos < end) {
8734
- const tag = reader.uint32();
8735
- switch (tag >>> 3) {
8736
- case 1: {
8737
- if (tag !== 10) {
8738
- break;
8739
- }
8740
- message.position = Position3.decode(reader, reader.uint32());
8741
- continue;
8742
- }
8743
- }
8744
- if ((tag & 7) === 4 || tag === 0) {
8745
- break;
8746
- }
8747
- reader.skip(tag & 7);
8748
- }
8749
- return message;
8750
- },
8751
- fromJSON(object) {
8752
- return { position: isSet2(object.position) ? Position3.fromJSON(object.position) : void 0 };
8753
- },
8754
- toJSON(message) {
8755
- const obj = {};
8756
- if (message.position !== void 0) {
8757
- obj.position = Position3.toJSON(message.position);
8758
- }
8759
- return obj;
8760
- },
8761
- create(base) {
8762
- return NodeLayout.fromPartial(base ?? {});
8763
- },
8764
- fromPartial(object) {
8765
- const message = createBaseNodeLayout();
8766
- message.position = object.position !== void 0 && object.position !== null ? Position3.fromPartial(object.position) : void 0;
8767
- return message;
8768
- }
8769
- };
8770
- function createBasePosition() {
8771
- return { x: 0, y: 0 };
8772
- }
8773
- var Position3 = {
8774
- encode(message, writer = new BinaryWriter3()) {
8775
- if (message.x !== 0) {
8776
- writer.uint32(9).double(message.x);
8777
- }
8778
- if (message.y !== 0) {
8779
- writer.uint32(17).double(message.y);
8780
- }
8781
- return writer;
8782
- },
8783
- decode(input, length) {
8784
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
8785
- const end = length === void 0 ? reader.len : reader.pos + length;
8786
- const message = createBasePosition();
8787
- while (reader.pos < end) {
8788
- const tag = reader.uint32();
8789
- switch (tag >>> 3) {
8790
- case 1: {
8791
- if (tag !== 9) {
8792
- break;
8793
- }
8794
- message.x = reader.double();
8795
- continue;
8796
- }
8797
- case 2: {
8798
- if (tag !== 17) {
8799
- break;
8800
- }
8801
- message.y = reader.double();
8802
- continue;
8803
- }
8804
- }
8805
- if ((tag & 7) === 4 || tag === 0) {
8806
- break;
8807
- }
8808
- reader.skip(tag & 7);
8809
- }
8810
- return message;
8811
- },
8812
- fromJSON(object) {
8813
- return {
8814
- x: isSet2(object.x) ? globalThis.Number(object.x) : 0,
8815
- y: isSet2(object.y) ? globalThis.Number(object.y) : 0
8816
- };
8817
- },
8818
- toJSON(message) {
8819
- const obj = {};
8820
- if (message.x !== 0) {
8821
- obj.x = message.x;
8822
- }
8823
- if (message.y !== 0) {
8824
- obj.y = message.y;
8825
- }
8826
- return obj;
8827
- },
8828
- create(base) {
8829
- return Position3.fromPartial(base ?? {});
8830
- },
8831
- fromPartial(object) {
8832
- const message = createBasePosition();
8833
- message.x = object.x ?? 0;
8834
- message.y = object.y ?? 0;
8835
- return message;
8836
- }
8837
- };
8838
- function createBaseLayoutsMap() {
8839
- return { layouts: {} };
8840
- }
8841
- var LayoutsMap = {
8842
- encode(message, writer = new BinaryWriter3()) {
8843
- globalThis.Object.entries(message.layouts).forEach(([key, value]) => {
8844
- LayoutsMap_LayoutsEntry.encode({ key, value }, writer.uint32(10).fork()).join();
8845
- });
8846
- return writer;
8847
- },
8848
- decode(input, length) {
8849
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
8850
- const end = length === void 0 ? reader.len : reader.pos + length;
8851
- const message = createBaseLayoutsMap();
8852
- while (reader.pos < end) {
8853
- const tag = reader.uint32();
8854
- switch (tag >>> 3) {
8855
- case 1: {
8856
- if (tag !== 10) {
8857
- break;
8858
- }
8859
- const entry1 = LayoutsMap_LayoutsEntry.decode(reader, reader.uint32());
8860
- if (entry1.value !== void 0) {
8861
- message.layouts[entry1.key] = entry1.value;
8862
- }
8863
- continue;
8864
- }
8865
- }
8866
- if ((tag & 7) === 4 || tag === 0) {
8867
- break;
8868
- }
8869
- reader.skip(tag & 7);
8870
- }
8871
- return message;
8872
- },
8873
- fromJSON(object) {
8874
- return {
8875
- layouts: isObject2(object.layouts) ? globalThis.Object.entries(object.layouts).reduce(
8876
- (acc, [key, value]) => {
8877
- acc[key] = GraphLayout.fromJSON(value);
8878
- return acc;
8879
- },
8880
- {}
8881
- ) : {}
8882
- };
8883
- },
8884
- toJSON(message) {
8885
- const obj = {};
8886
- if (message.layouts) {
8887
- const entries = globalThis.Object.entries(message.layouts);
8888
- if (entries.length > 0) {
8889
- obj.layouts = {};
8890
- entries.forEach(([k, v]) => {
8891
- obj.layouts[k] = GraphLayout.toJSON(v);
8892
- });
8893
- }
8894
- }
8895
- return obj;
8896
- },
8897
- create(base) {
8898
- return LayoutsMap.fromPartial(base ?? {});
8899
- },
8900
- fromPartial(object) {
8901
- const message = createBaseLayoutsMap();
8902
- message.layouts = globalThis.Object.entries(object.layouts ?? {}).reduce(
8903
- (acc, [key, value]) => {
8904
- if (value !== void 0) {
8905
- acc[key] = GraphLayout.fromPartial(value);
8906
- }
8907
- return acc;
8908
- },
8909
- {}
8910
- );
8911
- return message;
8912
- }
8913
- };
8914
- function createBaseLayoutsMap_LayoutsEntry() {
8915
- return { key: "", value: void 0 };
8916
- }
8917
- var LayoutsMap_LayoutsEntry = {
8918
- encode(message, writer = new BinaryWriter3()) {
8919
- if (message.key !== "") {
8920
- writer.uint32(10).string(message.key);
8921
- }
8922
- if (message.value !== void 0) {
8923
- GraphLayout.encode(message.value, writer.uint32(18).fork()).join();
8924
- }
8925
- return writer;
8926
- },
8927
- decode(input, length) {
8928
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
8929
- const end = length === void 0 ? reader.len : reader.pos + length;
8930
- const message = createBaseLayoutsMap_LayoutsEntry();
8931
- while (reader.pos < end) {
8932
- const tag = reader.uint32();
8933
- switch (tag >>> 3) {
8934
- case 1: {
8935
- if (tag !== 10) {
8936
- break;
8937
- }
8938
- message.key = reader.string();
8939
- continue;
8940
- }
8941
- case 2: {
8942
- if (tag !== 18) {
8943
- break;
8944
- }
8945
- message.value = GraphLayout.decode(reader, reader.uint32());
8946
- continue;
8947
- }
8948
- }
8949
- if ((tag & 7) === 4 || tag === 0) {
8950
- break;
8951
- }
8952
- reader.skip(tag & 7);
8953
- }
8954
- return message;
8955
- },
8956
- fromJSON(object) {
8957
- return {
8958
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
8959
- value: isSet2(object.value) ? GraphLayout.fromJSON(object.value) : void 0
8960
- };
8961
- },
8962
- toJSON(message) {
8963
- const obj = {};
8964
- if (message.key !== "") {
8965
- obj.key = message.key;
8966
- }
8967
- if (message.value !== void 0) {
8968
- obj.value = GraphLayout.toJSON(message.value);
8969
- }
8970
- return obj;
8971
- },
8972
- create(base) {
8973
- return LayoutsMap_LayoutsEntry.fromPartial(base ?? {});
8974
- },
8975
- fromPartial(object) {
8976
- const message = createBaseLayoutsMap_LayoutsEntry();
8977
- message.key = object.key ?? "";
8978
- message.value = object.value !== void 0 && object.value !== null ? GraphLayout.fromPartial(object.value) : void 0;
8979
- return message;
8980
- }
8981
- };
8982
- function createBasePolicyResolution() {
8983
- return {
8984
- mode: "",
8985
- policy_id: "",
8986
- rules_fired: [],
8987
- reason: "",
8988
- approval_mode: "",
8989
- condition_trace: [],
8990
- is_authoring_time_preview: false
8991
- };
8992
- }
8993
- var PolicyResolution = {
8994
- encode(message, writer = new BinaryWriter3()) {
8995
- if (message.mode !== "") {
8996
- writer.uint32(10).string(message.mode);
8997
- }
8998
- if (message.policy_id !== "") {
8999
- writer.uint32(26).string(message.policy_id);
9000
- }
9001
- for (const v of message.rules_fired) {
9002
- writer.uint32(34).string(v);
9003
- }
9004
- if (message.reason !== "") {
9005
- writer.uint32(42).string(message.reason);
9006
- }
9007
- if (message.approval_mode !== "") {
9008
- writer.uint32(50).string(message.approval_mode);
9009
- }
9010
- for (const v of message.condition_trace) {
9011
- PolicyConditionTrace.encode(v, writer.uint32(58).fork()).join();
9012
- }
9013
- if (message.is_authoring_time_preview !== false) {
9014
- writer.uint32(64).bool(message.is_authoring_time_preview);
9015
- }
9016
- return writer;
9017
- },
9018
- decode(input, length) {
9019
- const reader = input instanceof BinaryReader3 ? input : new BinaryReader3(input);
9020
- const end = length === void 0 ? reader.len : reader.pos + length;
9021
- const message = createBasePolicyResolution();
9022
- while (reader.pos < end) {
9023
- const tag = reader.uint32();
9024
- switch (tag >>> 3) {
9025
- case 1: {
9026
- if (tag !== 10) {
9027
- break;
9028
- }
9029
- message.mode = reader.string();
9030
- continue;
9031
- }
9032
- case 3: {
9033
- if (tag !== 26) {
9034
- break;
9035
- }
9036
- message.policy_id = reader.string();
9037
- continue;
9038
- }
9039
- case 4: {
9040
- if (tag !== 34) {
9041
- break;
9042
- }
9043
- message.rules_fired.push(reader.string());
9044
- continue;
9045
- }
9046
- case 5: {
9047
- if (tag !== 42) {
9048
- break;
9049
- }
9050
- message.reason = reader.string();
9051
- continue;
9052
- }
9053
- case 6: {
9054
- if (tag !== 50) {
9055
- break;
9056
- }
9057
- message.approval_mode = reader.string();
9058
- continue;
9059
- }
9060
- case 7: {
9061
- if (tag !== 58) {
9062
- break;
9063
- }
9064
- message.condition_trace.push(PolicyConditionTrace.decode(reader, reader.uint32()));
9065
- continue;
9066
- }
9067
- case 8: {
9068
- if (tag !== 64) {
9069
- break;
9070
- }
9071
- message.is_authoring_time_preview = reader.bool();
9072
- continue;
9073
- }
9074
- }
9075
- if ((tag & 7) === 4 || tag === 0) {
9076
- break;
9077
- }
9078
- reader.skip(tag & 7);
9079
- }
9080
- return message;
9081
- },
9082
- fromJSON(object) {
9083
- return {
9084
- mode: isSet2(object.mode) ? globalThis.String(object.mode) : "",
9085
- policy_id: isSet2(object.policyId) ? globalThis.String(object.policyId) : isSet2(object.policy_id) ? globalThis.String(object.policy_id) : "",
9086
- rules_fired: globalThis.Array.isArray(object?.rulesFired) ? object.rulesFired.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.rules_fired) ? object.rules_fired.map((e) => globalThis.String(e)) : [],
9087
- reason: isSet2(object.reason) ? globalThis.String(object.reason) : "",
9088
- approval_mode: isSet2(object.approvalMode) ? globalThis.String(object.approvalMode) : isSet2(object.approval_mode) ? globalThis.String(object.approval_mode) : "",
9089
- condition_trace: globalThis.Array.isArray(object?.conditionTrace) ? object.conditionTrace.map((e) => PolicyConditionTrace.fromJSON(e)) : globalThis.Array.isArray(object?.condition_trace) ? object.condition_trace.map((e) => PolicyConditionTrace.fromJSON(e)) : [],
9090
- is_authoring_time_preview: isSet2(object.isAuthoringTimePreview) ? globalThis.Boolean(object.isAuthoringTimePreview) : isSet2(object.is_authoring_time_preview) ? globalThis.Boolean(object.is_authoring_time_preview) : false
9091
- };
9092
- },
9093
- toJSON(message) {
9094
- const obj = {};
9095
- if (message.mode !== "") {
9096
- obj.mode = message.mode;
9097
- }
9098
- if (message.policy_id !== "") {
9099
- obj.policyId = message.policy_id;
9100
- }
9101
- if (message.rules_fired?.length) {
9102
- obj.rulesFired = message.rules_fired;
9103
- }
9104
- if (message.reason !== "") {
9105
- obj.reason = message.reason;
9106
- }
9107
- if (message.approval_mode !== "") {
9108
- obj.approvalMode = message.approval_mode;
9109
- }
9110
- if (message.condition_trace?.length) {
9111
- obj.conditionTrace = message.condition_trace.map((e) => PolicyConditionTrace.toJSON(e));
9112
- }
9113
- if (message.is_authoring_time_preview !== false) {
9114
- obj.isAuthoringTimePreview = message.is_authoring_time_preview;
9115
- }
9116
- return obj;
9117
- },
9118
- create(base) {
9119
- return PolicyResolution.fromPartial(base ?? {});
8725
+ return PolicyResolution.fromPartial(base ?? {});
9120
8726
  },
9121
8727
  fromPartial(object) {
9122
8728
  const message = createBasePolicyResolution();
@@ -11525,339 +11131,29 @@ var CopyInstancesAction = {
11525
11131
  },
11526
11132
  fromPartial(object) {
11527
11133
  const message = createBaseCopyInstancesAction();
11528
- message.instance_ids = object.instance_ids?.map((e) => e) || [];
11529
- return message;
11530
- }
11531
- };
11532
- function createBaseSyncLayoutAction() {
11533
- return { positions: {} };
11534
- }
11535
- var SyncLayoutAction = {
11536
- encode(message, writer = new BinaryWriter4()) {
11537
- globalThis.Object.entries(message.positions).forEach(([key, value]) => {
11538
- SyncLayoutAction_PositionsEntry.encode({ key, value }, writer.uint32(10).fork()).join();
11539
- });
11540
- return writer;
11541
- },
11542
- decode(input, length) {
11543
- const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
11544
- const end = length === void 0 ? reader.len : reader.pos + length;
11545
- const message = createBaseSyncLayoutAction();
11546
- while (reader.pos < end) {
11547
- const tag = reader.uint32();
11548
- switch (tag >>> 3) {
11549
- case 1: {
11550
- if (tag !== 10) {
11551
- break;
11552
- }
11553
- const entry1 = SyncLayoutAction_PositionsEntry.decode(reader, reader.uint32());
11554
- if (entry1.value !== void 0) {
11555
- message.positions[entry1.key] = entry1.value;
11556
- }
11557
- continue;
11558
- }
11559
- }
11560
- if ((tag & 7) === 4 || tag === 0) {
11561
- break;
11562
- }
11563
- reader.skip(tag & 7);
11564
- }
11565
- return message;
11566
- },
11567
- fromJSON(object) {
11568
- return {
11569
- positions: isObject3(object.positions) ? globalThis.Object.entries(object.positions).reduce(
11570
- (acc, [key, value]) => {
11571
- acc[key] = Position4.fromJSON(value);
11572
- return acc;
11573
- },
11574
- {}
11575
- ) : {}
11576
- };
11577
- },
11578
- toJSON(message) {
11579
- const obj = {};
11580
- if (message.positions) {
11581
- const entries = globalThis.Object.entries(message.positions);
11582
- if (entries.length > 0) {
11583
- obj.positions = {};
11584
- entries.forEach(([k, v]) => {
11585
- obj.positions[k] = Position4.toJSON(v);
11586
- });
11587
- }
11588
- }
11589
- return obj;
11590
- },
11591
- create(base) {
11592
- return SyncLayoutAction.fromPartial(base ?? {});
11593
- },
11594
- fromPartial(object) {
11595
- const message = createBaseSyncLayoutAction();
11596
- message.positions = globalThis.Object.entries(object.positions ?? {}).reduce(
11597
- (acc, [key, value]) => {
11598
- if (value !== void 0) {
11599
- acc[key] = Position4.fromPartial(value);
11600
- }
11601
- return acc;
11602
- },
11603
- {}
11604
- );
11605
- return message;
11606
- }
11607
- };
11608
- function createBaseSyncLayoutAction_PositionsEntry() {
11609
- return { key: "", value: void 0 };
11610
- }
11611
- var SyncLayoutAction_PositionsEntry = {
11612
- encode(message, writer = new BinaryWriter4()) {
11613
- if (message.key !== "") {
11614
- writer.uint32(10).string(message.key);
11615
- }
11616
- if (message.value !== void 0) {
11617
- Position4.encode(message.value, writer.uint32(18).fork()).join();
11618
- }
11619
- return writer;
11620
- },
11621
- decode(input, length) {
11622
- const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
11623
- const end = length === void 0 ? reader.len : reader.pos + length;
11624
- const message = createBaseSyncLayoutAction_PositionsEntry();
11625
- while (reader.pos < end) {
11626
- const tag = reader.uint32();
11627
- switch (tag >>> 3) {
11628
- case 1: {
11629
- if (tag !== 10) {
11630
- break;
11631
- }
11632
- message.key = reader.string();
11633
- continue;
11634
- }
11635
- case 2: {
11636
- if (tag !== 18) {
11637
- break;
11638
- }
11639
- message.value = Position4.decode(reader, reader.uint32());
11640
- continue;
11641
- }
11642
- }
11643
- if ((tag & 7) === 4 || tag === 0) {
11644
- break;
11645
- }
11646
- reader.skip(tag & 7);
11647
- }
11648
- return message;
11649
- },
11650
- fromJSON(object) {
11651
- return {
11652
- key: isSet3(object.key) ? globalThis.String(object.key) : "",
11653
- value: isSet3(object.value) ? Position4.fromJSON(object.value) : void 0
11654
- };
11655
- },
11656
- toJSON(message) {
11657
- const obj = {};
11658
- if (message.key !== "") {
11659
- obj.key = message.key;
11660
- }
11661
- if (message.value !== void 0) {
11662
- obj.value = Position4.toJSON(message.value);
11663
- }
11664
- return obj;
11665
- },
11666
- create(base) {
11667
- return SyncLayoutAction_PositionsEntry.fromPartial(base ?? {});
11668
- },
11669
- fromPartial(object) {
11670
- const message = createBaseSyncLayoutAction_PositionsEntry();
11671
- message.key = object.key ?? "";
11672
- message.value = object.value !== void 0 && object.value !== null ? Position4.fromPartial(object.value) : void 0;
11673
- return message;
11674
- }
11675
- };
11676
- function createBaseCreateGroupAction() {
11677
- return { label: "", node_ids: [] };
11678
- }
11679
- var CreateGroupAction = {
11680
- encode(message, writer = new BinaryWriter4()) {
11681
- if (message.label !== "") {
11682
- writer.uint32(10).string(message.label);
11683
- }
11684
- for (const v of message.node_ids) {
11685
- writer.uint32(18).string(v);
11686
- }
11687
- return writer;
11688
- },
11689
- decode(input, length) {
11690
- const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
11691
- const end = length === void 0 ? reader.len : reader.pos + length;
11692
- const message = createBaseCreateGroupAction();
11693
- while (reader.pos < end) {
11694
- const tag = reader.uint32();
11695
- switch (tag >>> 3) {
11696
- case 1: {
11697
- if (tag !== 10) {
11698
- break;
11699
- }
11700
- message.label = reader.string();
11701
- continue;
11702
- }
11703
- case 2: {
11704
- if (tag !== 18) {
11705
- break;
11706
- }
11707
- message.node_ids.push(reader.string());
11708
- continue;
11709
- }
11710
- }
11711
- if ((tag & 7) === 4 || tag === 0) {
11712
- break;
11713
- }
11714
- reader.skip(tag & 7);
11715
- }
11716
- return message;
11717
- },
11718
- fromJSON(object) {
11719
- return {
11720
- label: isSet3(object.label) ? globalThis.String(object.label) : "",
11721
- node_ids: globalThis.Array.isArray(object?.nodeIds) ? object.nodeIds.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.node_ids) ? object.node_ids.map((e) => globalThis.String(e)) : []
11722
- };
11723
- },
11724
- toJSON(message) {
11725
- const obj = {};
11726
- if (message.label !== "") {
11727
- obj.label = message.label;
11728
- }
11729
- if (message.node_ids?.length) {
11730
- obj.nodeIds = message.node_ids;
11731
- }
11732
- return obj;
11733
- },
11734
- create(base) {
11735
- return CreateGroupAction.fromPartial(base ?? {});
11736
- },
11737
- fromPartial(object) {
11738
- const message = createBaseCreateGroupAction();
11739
- message.label = object.label ?? "";
11740
- message.node_ids = object.node_ids?.map((e) => e) || [];
11741
- return message;
11742
- }
11743
- };
11744
- function createBaseUpdateGroupAction() {
11745
- return { group_id: "", label: void 0, collapsed: void 0, node_ids: void 0 };
11746
- }
11747
- var UpdateGroupAction = {
11748
- encode(message, writer = new BinaryWriter4()) {
11749
- if (message.group_id !== "") {
11750
- writer.uint32(10).string(message.group_id);
11751
- }
11752
- if (message.label !== void 0) {
11753
- writer.uint32(18).string(message.label);
11754
- }
11755
- if (message.collapsed !== void 0) {
11756
- writer.uint32(24).bool(message.collapsed);
11757
- }
11758
- if (message.node_ids !== void 0) {
11759
- UpdateGroupNodeIds.encode(message.node_ids, writer.uint32(34).fork()).join();
11760
- }
11761
- return writer;
11762
- },
11763
- decode(input, length) {
11764
- const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
11765
- const end = length === void 0 ? reader.len : reader.pos + length;
11766
- const message = createBaseUpdateGroupAction();
11767
- while (reader.pos < end) {
11768
- const tag = reader.uint32();
11769
- switch (tag >>> 3) {
11770
- case 1: {
11771
- if (tag !== 10) {
11772
- break;
11773
- }
11774
- message.group_id = reader.string();
11775
- continue;
11776
- }
11777
- case 2: {
11778
- if (tag !== 18) {
11779
- break;
11780
- }
11781
- message.label = reader.string();
11782
- continue;
11783
- }
11784
- case 3: {
11785
- if (tag !== 24) {
11786
- break;
11787
- }
11788
- message.collapsed = reader.bool();
11789
- continue;
11790
- }
11791
- case 4: {
11792
- if (tag !== 34) {
11793
- break;
11794
- }
11795
- message.node_ids = UpdateGroupNodeIds.decode(reader, reader.uint32());
11796
- continue;
11797
- }
11798
- }
11799
- if ((tag & 7) === 4 || tag === 0) {
11800
- break;
11801
- }
11802
- reader.skip(tag & 7);
11803
- }
11804
- return message;
11805
- },
11806
- fromJSON(object) {
11807
- return {
11808
- group_id: isSet3(object.groupId) ? globalThis.String(object.groupId) : isSet3(object.group_id) ? globalThis.String(object.group_id) : "",
11809
- label: isSet3(object.label) ? globalThis.String(object.label) : void 0,
11810
- collapsed: isSet3(object.collapsed) ? globalThis.Boolean(object.collapsed) : void 0,
11811
- node_ids: isSet3(object.nodeIds) ? UpdateGroupNodeIds.fromJSON(object.nodeIds) : isSet3(object.node_ids) ? UpdateGroupNodeIds.fromJSON(object.node_ids) : void 0
11812
- };
11813
- },
11814
- toJSON(message) {
11815
- const obj = {};
11816
- if (message.group_id !== "") {
11817
- obj.groupId = message.group_id;
11818
- }
11819
- if (message.label !== void 0) {
11820
- obj.label = message.label;
11821
- }
11822
- if (message.collapsed !== void 0) {
11823
- obj.collapsed = message.collapsed;
11824
- }
11825
- if (message.node_ids !== void 0) {
11826
- obj.nodeIds = UpdateGroupNodeIds.toJSON(message.node_ids);
11827
- }
11828
- return obj;
11829
- },
11830
- create(base) {
11831
- return UpdateGroupAction.fromPartial(base ?? {});
11832
- },
11833
- fromPartial(object) {
11834
- const message = createBaseUpdateGroupAction();
11835
- message.group_id = object.group_id ?? "";
11836
- message.label = object.label ?? void 0;
11837
- message.collapsed = object.collapsed ?? void 0;
11838
- message.node_ids = object.node_ids !== void 0 && object.node_ids !== null ? UpdateGroupNodeIds.fromPartial(object.node_ids) : void 0;
11134
+ message.instance_ids = object.instance_ids?.map((e) => e) || [];
11839
11135
  return message;
11840
11136
  }
11841
11137
  };
11842
- function createBaseUpdateGroupNodeIds() {
11138
+ function createBaseCreateGroupAction() {
11843
11139
  return { node_ids: [] };
11844
11140
  }
11845
- var UpdateGroupNodeIds = {
11141
+ var CreateGroupAction = {
11846
11142
  encode(message, writer = new BinaryWriter4()) {
11847
11143
  for (const v of message.node_ids) {
11848
- writer.uint32(10).string(v);
11144
+ writer.uint32(18).string(v);
11849
11145
  }
11850
11146
  return writer;
11851
11147
  },
11852
11148
  decode(input, length) {
11853
11149
  const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
11854
11150
  const end = length === void 0 ? reader.len : reader.pos + length;
11855
- const message = createBaseUpdateGroupNodeIds();
11151
+ const message = createBaseCreateGroupAction();
11856
11152
  while (reader.pos < end) {
11857
11153
  const tag = reader.uint32();
11858
11154
  switch (tag >>> 3) {
11859
- case 1: {
11860
- if (tag !== 10) {
11155
+ case 2: {
11156
+ if (tag !== 18) {
11861
11157
  break;
11862
11158
  }
11863
11159
  message.node_ids.push(reader.string());
@@ -11884,18 +11180,18 @@ var UpdateGroupNodeIds = {
11884
11180
  return obj;
11885
11181
  },
11886
11182
  create(base) {
11887
- return UpdateGroupNodeIds.fromPartial(base ?? {});
11183
+ return CreateGroupAction.fromPartial(base ?? {});
11888
11184
  },
11889
11185
  fromPartial(object) {
11890
- const message = createBaseUpdateGroupNodeIds();
11186
+ const message = createBaseCreateGroupAction();
11891
11187
  message.node_ids = object.node_ids?.map((e) => e) || [];
11892
11188
  return message;
11893
11189
  }
11894
11190
  };
11895
- function createBaseDeleteGroupAction() {
11191
+ function createBaseUngroupAction() {
11896
11192
  return { group_id: "" };
11897
11193
  }
11898
- var DeleteGroupAction = {
11194
+ var UngroupAction = {
11899
11195
  encode(message, writer = new BinaryWriter4()) {
11900
11196
  if (message.group_id !== "") {
11901
11197
  writer.uint32(10).string(message.group_id);
@@ -11905,7 +11201,7 @@ var DeleteGroupAction = {
11905
11201
  decode(input, length) {
11906
11202
  const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
11907
11203
  const end = length === void 0 ? reader.len : reader.pos + length;
11908
- const message = createBaseDeleteGroupAction();
11204
+ const message = createBaseUngroupAction();
11909
11205
  while (reader.pos < end) {
11910
11206
  const tag = reader.uint32();
11911
11207
  switch (tag >>> 3) {
@@ -11937,10 +11233,10 @@ var DeleteGroupAction = {
11937
11233
  return obj;
11938
11234
  },
11939
11235
  create(base) {
11940
- return DeleteGroupAction.fromPartial(base ?? {});
11236
+ return UngroupAction.fromPartial(base ?? {});
11941
11237
  },
11942
11238
  fromPartial(object) {
11943
- const message = createBaseDeleteGroupAction();
11239
+ const message = createBaseUngroupAction();
11944
11240
  message.group_id = object.group_id ?? "";
11945
11241
  return message;
11946
11242
  }
@@ -13013,7 +12309,7 @@ var RedoAction = {
13013
12309
  }
13014
12310
  };
13015
12311
  function createBasePlaceModuleAction() {
13016
- return { name: "", system: "", version: "", organization: "", position: void 0 };
12312
+ return { name: "", system: "", version: "", organization: "" };
13017
12313
  }
13018
12314
  var PlaceModuleAction = {
13019
12315
  encode(message, writer = new BinaryWriter4()) {
@@ -13029,9 +12325,6 @@ var PlaceModuleAction = {
13029
12325
  if (message.organization !== "") {
13030
12326
  writer.uint32(34).string(message.organization);
13031
12327
  }
13032
- if (message.position !== void 0) {
13033
- Position4.encode(message.position, writer.uint32(42).fork()).join();
13034
- }
13035
12328
  return writer;
13036
12329
  },
13037
12330
  decode(input, length) {
@@ -13069,13 +12362,6 @@ var PlaceModuleAction = {
13069
12362
  message.organization = reader.string();
13070
12363
  continue;
13071
12364
  }
13072
- case 5: {
13073
- if (tag !== 42) {
13074
- break;
13075
- }
13076
- message.position = Position4.decode(reader, reader.uint32());
13077
- continue;
13078
- }
13079
12365
  }
13080
12366
  if ((tag & 7) === 4 || tag === 0) {
13081
12367
  break;
@@ -13089,8 +12375,7 @@ var PlaceModuleAction = {
13089
12375
  name: isSet3(object.name) ? globalThis.String(object.name) : "",
13090
12376
  system: isSet3(object.system) ? globalThis.String(object.system) : "",
13091
12377
  version: isSet3(object.version) ? globalThis.String(object.version) : "",
13092
- organization: isSet3(object.organization) ? globalThis.String(object.organization) : "",
13093
- position: isSet3(object.position) ? Position4.fromJSON(object.position) : void 0
12378
+ organization: isSet3(object.organization) ? globalThis.String(object.organization) : ""
13094
12379
  };
13095
12380
  },
13096
12381
  toJSON(message) {
@@ -13107,9 +12392,6 @@ var PlaceModuleAction = {
13107
12392
  if (message.organization !== "") {
13108
12393
  obj.organization = message.organization;
13109
12394
  }
13110
- if (message.position !== void 0) {
13111
- obj.position = Position4.toJSON(message.position);
13112
- }
13113
12395
  return obj;
13114
12396
  },
13115
12397
  create(base) {
@@ -13121,7 +12403,6 @@ var PlaceModuleAction = {
13121
12403
  message.system = object.system ?? "";
13122
12404
  message.version = object.version ?? "";
13123
12405
  message.organization = object.organization ?? "";
13124
- message.position = object.position !== void 0 && object.position !== null ? Position4.fromPartial(object.position) : void 0;
13125
12406
  return message;
13126
12407
  }
13127
12408
  };
@@ -13135,10 +12416,7 @@ function createBaseAction() {
13135
12416
  rename_instance: void 0,
13136
12417
  delete_instance: void 0,
13137
12418
  copy_instances: void 0,
13138
- sync_layout: void 0,
13139
12419
  create_group: void 0,
13140
- update_group: void 0,
13141
- delete_group: void 0,
13142
12420
  set_variables: void 0,
13143
12421
  set_exports: void 0,
13144
12422
  set_terraform: void 0,
@@ -13149,7 +12427,8 @@ function createBaseAction() {
13149
12427
  undo: void 0,
13150
12428
  redo: void 0,
13151
12429
  place_module: void 0,
13152
- set_use_providers: void 0
12430
+ set_use_providers: void 0,
12431
+ ungroup: void 0
13153
12432
  };
13154
12433
  }
13155
12434
  var Action = {
@@ -13178,18 +12457,9 @@ var Action = {
13178
12457
  if (message.copy_instances !== void 0) {
13179
12458
  CopyInstancesAction.encode(message.copy_instances, writer.uint32(66).fork()).join();
13180
12459
  }
13181
- if (message.sync_layout !== void 0) {
13182
- SyncLayoutAction.encode(message.sync_layout, writer.uint32(74).fork()).join();
13183
- }
13184
12460
  if (message.create_group !== void 0) {
13185
12461
  CreateGroupAction.encode(message.create_group, writer.uint32(82).fork()).join();
13186
12462
  }
13187
- if (message.update_group !== void 0) {
13188
- UpdateGroupAction.encode(message.update_group, writer.uint32(90).fork()).join();
13189
- }
13190
- if (message.delete_group !== void 0) {
13191
- DeleteGroupAction.encode(message.delete_group, writer.uint32(98).fork()).join();
13192
- }
13193
12463
  if (message.set_variables !== void 0) {
13194
12464
  SetVariablesAction.encode(message.set_variables, writer.uint32(106).fork()).join();
13195
12465
  }
@@ -13223,6 +12493,9 @@ var Action = {
13223
12493
  if (message.set_use_providers !== void 0) {
13224
12494
  SetUseProvidersAction.encode(message.set_use_providers, writer.uint32(186).fork()).join();
13225
12495
  }
12496
+ if (message.ungroup !== void 0) {
12497
+ UngroupAction.encode(message.ungroup, writer.uint32(194).fork()).join();
12498
+ }
13226
12499
  return writer;
13227
12500
  },
13228
12501
  decode(input, length) {
@@ -13288,13 +12561,6 @@ var Action = {
13288
12561
  message.copy_instances = CopyInstancesAction.decode(reader, reader.uint32());
13289
12562
  continue;
13290
12563
  }
13291
- case 9: {
13292
- if (tag !== 74) {
13293
- break;
13294
- }
13295
- message.sync_layout = SyncLayoutAction.decode(reader, reader.uint32());
13296
- continue;
13297
- }
13298
12564
  case 10: {
13299
12565
  if (tag !== 82) {
13300
12566
  break;
@@ -13302,20 +12568,6 @@ var Action = {
13302
12568
  message.create_group = CreateGroupAction.decode(reader, reader.uint32());
13303
12569
  continue;
13304
12570
  }
13305
- case 11: {
13306
- if (tag !== 90) {
13307
- break;
13308
- }
13309
- message.update_group = UpdateGroupAction.decode(reader, reader.uint32());
13310
- continue;
13311
- }
13312
- case 12: {
13313
- if (tag !== 98) {
13314
- break;
13315
- }
13316
- message.delete_group = DeleteGroupAction.decode(reader, reader.uint32());
13317
- continue;
13318
- }
13319
12571
  case 13: {
13320
12572
  if (tag !== 106) {
13321
12573
  break;
@@ -13393,6 +12645,13 @@ var Action = {
13393
12645
  message.set_use_providers = SetUseProvidersAction.decode(reader, reader.uint32());
13394
12646
  continue;
13395
12647
  }
12648
+ case 24: {
12649
+ if (tag !== 194) {
12650
+ break;
12651
+ }
12652
+ message.ungroup = UngroupAction.decode(reader, reader.uint32());
12653
+ continue;
12654
+ }
13396
12655
  }
13397
12656
  if ((tag & 7) === 4 || tag === 0) {
13398
12657
  break;
@@ -13411,10 +12670,7 @@ var Action = {
13411
12670
  rename_instance: isSet3(object.renameInstance) ? RenameInstanceAction.fromJSON(object.renameInstance) : isSet3(object.rename_instance) ? RenameInstanceAction.fromJSON(object.rename_instance) : void 0,
13412
12671
  delete_instance: isSet3(object.deleteInstance) ? DeleteInstanceAction.fromJSON(object.deleteInstance) : isSet3(object.delete_instance) ? DeleteInstanceAction.fromJSON(object.delete_instance) : void 0,
13413
12672
  copy_instances: isSet3(object.copyInstances) ? CopyInstancesAction.fromJSON(object.copyInstances) : isSet3(object.copy_instances) ? CopyInstancesAction.fromJSON(object.copy_instances) : void 0,
13414
- sync_layout: isSet3(object.syncLayout) ? SyncLayoutAction.fromJSON(object.syncLayout) : isSet3(object.sync_layout) ? SyncLayoutAction.fromJSON(object.sync_layout) : void 0,
13415
12673
  create_group: isSet3(object.createGroup) ? CreateGroupAction.fromJSON(object.createGroup) : isSet3(object.create_group) ? CreateGroupAction.fromJSON(object.create_group) : void 0,
13416
- update_group: isSet3(object.updateGroup) ? UpdateGroupAction.fromJSON(object.updateGroup) : isSet3(object.update_group) ? UpdateGroupAction.fromJSON(object.update_group) : void 0,
13417
- delete_group: isSet3(object.deleteGroup) ? DeleteGroupAction.fromJSON(object.deleteGroup) : isSet3(object.delete_group) ? DeleteGroupAction.fromJSON(object.delete_group) : void 0,
13418
12674
  set_variables: isSet3(object.setVariables) ? SetVariablesAction.fromJSON(object.setVariables) : isSet3(object.set_variables) ? SetVariablesAction.fromJSON(object.set_variables) : void 0,
13419
12675
  set_exports: isSet3(object.setExports) ? SetExportsAction.fromJSON(object.setExports) : isSet3(object.set_exports) ? SetExportsAction.fromJSON(object.set_exports) : void 0,
13420
12676
  set_terraform: isSet3(object.setTerraform) ? SetTerraformAction.fromJSON(object.setTerraform) : isSet3(object.set_terraform) ? SetTerraformAction.fromJSON(object.set_terraform) : void 0,
@@ -13425,7 +12681,8 @@ var Action = {
13425
12681
  undo: isSet3(object.undo) ? UndoAction.fromJSON(object.undo) : void 0,
13426
12682
  redo: isSet3(object.redo) ? RedoAction.fromJSON(object.redo) : void 0,
13427
12683
  place_module: isSet3(object.placeModule) ? PlaceModuleAction.fromJSON(object.placeModule) : isSet3(object.place_module) ? PlaceModuleAction.fromJSON(object.place_module) : void 0,
13428
- set_use_providers: isSet3(object.setUseProviders) ? SetUseProvidersAction.fromJSON(object.setUseProviders) : isSet3(object.set_use_providers) ? SetUseProvidersAction.fromJSON(object.set_use_providers) : void 0
12684
+ set_use_providers: isSet3(object.setUseProviders) ? SetUseProvidersAction.fromJSON(object.setUseProviders) : isSet3(object.set_use_providers) ? SetUseProvidersAction.fromJSON(object.set_use_providers) : void 0,
12685
+ ungroup: isSet3(object.ungroup) ? UngroupAction.fromJSON(object.ungroup) : void 0
13429
12686
  };
13430
12687
  },
13431
12688
  toJSON(message) {
@@ -13454,18 +12711,9 @@ var Action = {
13454
12711
  if (message.copy_instances !== void 0) {
13455
12712
  obj.copyInstances = CopyInstancesAction.toJSON(message.copy_instances);
13456
12713
  }
13457
- if (message.sync_layout !== void 0) {
13458
- obj.syncLayout = SyncLayoutAction.toJSON(message.sync_layout);
13459
- }
13460
12714
  if (message.create_group !== void 0) {
13461
12715
  obj.createGroup = CreateGroupAction.toJSON(message.create_group);
13462
12716
  }
13463
- if (message.update_group !== void 0) {
13464
- obj.updateGroup = UpdateGroupAction.toJSON(message.update_group);
13465
- }
13466
- if (message.delete_group !== void 0) {
13467
- obj.deleteGroup = DeleteGroupAction.toJSON(message.delete_group);
13468
- }
13469
12717
  if (message.set_variables !== void 0) {
13470
12718
  obj.setVariables = SetVariablesAction.toJSON(message.set_variables);
13471
12719
  }
@@ -13499,6 +12747,9 @@ var Action = {
13499
12747
  if (message.set_use_providers !== void 0) {
13500
12748
  obj.setUseProviders = SetUseProvidersAction.toJSON(message.set_use_providers);
13501
12749
  }
12750
+ if (message.ungroup !== void 0) {
12751
+ obj.ungroup = UngroupAction.toJSON(message.ungroup);
12752
+ }
13502
12753
  return obj;
13503
12754
  },
13504
12755
  create(base) {
@@ -13514,10 +12765,7 @@ var Action = {
13514
12765
  message.rename_instance = object.rename_instance !== void 0 && object.rename_instance !== null ? RenameInstanceAction.fromPartial(object.rename_instance) : void 0;
13515
12766
  message.delete_instance = object.delete_instance !== void 0 && object.delete_instance !== null ? DeleteInstanceAction.fromPartial(object.delete_instance) : void 0;
13516
12767
  message.copy_instances = object.copy_instances !== void 0 && object.copy_instances !== null ? CopyInstancesAction.fromPartial(object.copy_instances) : void 0;
13517
- message.sync_layout = object.sync_layout !== void 0 && object.sync_layout !== null ? SyncLayoutAction.fromPartial(object.sync_layout) : void 0;
13518
12768
  message.create_group = object.create_group !== void 0 && object.create_group !== null ? CreateGroupAction.fromPartial(object.create_group) : void 0;
13519
- message.update_group = object.update_group !== void 0 && object.update_group !== null ? UpdateGroupAction.fromPartial(object.update_group) : void 0;
13520
- message.delete_group = object.delete_group !== void 0 && object.delete_group !== null ? DeleteGroupAction.fromPartial(object.delete_group) : void 0;
13521
12769
  message.set_variables = object.set_variables !== void 0 && object.set_variables !== null ? SetVariablesAction.fromPartial(object.set_variables) : void 0;
13522
12770
  message.set_exports = object.set_exports !== void 0 && object.set_exports !== null ? SetExportsAction.fromPartial(object.set_exports) : void 0;
13523
12771
  message.set_terraform = object.set_terraform !== void 0 && object.set_terraform !== null ? SetTerraformAction.fromPartial(object.set_terraform) : void 0;
@@ -13529,6 +12777,7 @@ var Action = {
13529
12777
  message.redo = object.redo !== void 0 && object.redo !== null ? RedoAction.fromPartial(object.redo) : void 0;
13530
12778
  message.place_module = object.place_module !== void 0 && object.place_module !== null ? PlaceModuleAction.fromPartial(object.place_module) : void 0;
13531
12779
  message.set_use_providers = object.set_use_providers !== void 0 && object.set_use_providers !== null ? SetUseProvidersAction.fromPartial(object.set_use_providers) : void 0;
12780
+ message.ungroup = object.ungroup !== void 0 && object.ungroup !== null ? UngroupAction.fromPartial(object.ungroup) : void 0;
13532
12781
  return message;
13533
12782
  }
13534
12783
  };
@@ -14603,16 +13852,13 @@ var BundleStateEvent = {
14603
13852
  }
14604
13853
  };
14605
13854
  function createBaseBundleState() {
14606
- return { bundle: void 0, layouts: {}, can_undo: false, can_redo: false, is_dirty: false };
13855
+ return { bundle: void 0, can_undo: false, can_redo: false, is_dirty: false };
14607
13856
  }
14608
13857
  var BundleState = {
14609
13858
  encode(message, writer = new BinaryWriter4()) {
14610
13859
  if (message.bundle !== void 0) {
14611
13860
  Bundle.encode(message.bundle, writer.uint32(10).fork()).join();
14612
13861
  }
14613
- globalThis.Object.entries(message.layouts).forEach(([key, value]) => {
14614
- BundleState_LayoutsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
14615
- });
14616
13862
  if (message.can_undo !== false) {
14617
13863
  writer.uint32(24).bool(message.can_undo);
14618
13864
  }
@@ -14638,16 +13884,6 @@ var BundleState = {
14638
13884
  message.bundle = Bundle.decode(reader, reader.uint32());
14639
13885
  continue;
14640
13886
  }
14641
- case 2: {
14642
- if (tag !== 18) {
14643
- break;
14644
- }
14645
- const entry2 = BundleState_LayoutsEntry.decode(reader, reader.uint32());
14646
- if (entry2.value !== void 0) {
14647
- message.layouts[entry2.key] = entry2.value;
14648
- }
14649
- continue;
14650
- }
14651
13887
  case 3: {
14652
13888
  if (tag !== 24) {
14653
13889
  break;
@@ -14680,13 +13916,6 @@ var BundleState = {
14680
13916
  fromJSON(object) {
14681
13917
  return {
14682
13918
  bundle: isSet3(object.bundle) ? Bundle.fromJSON(object.bundle) : void 0,
14683
- layouts: isObject3(object.layouts) ? globalThis.Object.entries(object.layouts).reduce(
14684
- (acc, [key, value]) => {
14685
- acc[key] = GraphLayout.fromJSON(value);
14686
- return acc;
14687
- },
14688
- {}
14689
- ) : {},
14690
13919
  can_undo: isSet3(object.canUndo) ? globalThis.Boolean(object.canUndo) : isSet3(object.can_undo) ? globalThis.Boolean(object.can_undo) : false,
14691
13920
  can_redo: isSet3(object.canRedo) ? globalThis.Boolean(object.canRedo) : isSet3(object.can_redo) ? globalThis.Boolean(object.can_redo) : false,
14692
13921
  is_dirty: isSet3(object.isDirty) ? globalThis.Boolean(object.isDirty) : isSet3(object.is_dirty) ? globalThis.Boolean(object.is_dirty) : false
@@ -14697,15 +13926,6 @@ var BundleState = {
14697
13926
  if (message.bundle !== void 0) {
14698
13927
  obj.bundle = Bundle.toJSON(message.bundle);
14699
13928
  }
14700
- if (message.layouts) {
14701
- const entries = globalThis.Object.entries(message.layouts);
14702
- if (entries.length > 0) {
14703
- obj.layouts = {};
14704
- entries.forEach(([k, v]) => {
14705
- obj.layouts[k] = GraphLayout.toJSON(v);
14706
- });
14707
- }
14708
- }
14709
13929
  if (message.can_undo !== false) {
14710
13930
  obj.canUndo = message.can_undo;
14711
13931
  }
@@ -14723,53 +13943,54 @@ var BundleState = {
14723
13943
  fromPartial(object) {
14724
13944
  const message = createBaseBundleState();
14725
13945
  message.bundle = object.bundle !== void 0 && object.bundle !== null ? Bundle.fromPartial(object.bundle) : void 0;
14726
- message.layouts = globalThis.Object.entries(object.layouts ?? {}).reduce(
14727
- (acc, [key, value]) => {
14728
- if (value !== void 0) {
14729
- acc[key] = GraphLayout.fromPartial(value);
14730
- }
14731
- return acc;
14732
- },
14733
- {}
14734
- );
14735
13946
  message.can_undo = object.can_undo ?? false;
14736
13947
  message.can_redo = object.can_redo ?? false;
14737
13948
  message.is_dirty = object.is_dirty ?? false;
14738
13949
  return message;
14739
13950
  }
14740
13951
  };
14741
- function createBaseBundleState_LayoutsEntry() {
14742
- return { key: "", value: void 0 };
13952
+ function createBaseBundleApplyResult() {
13953
+ return { success: false, errors: [], created: [] };
14743
13954
  }
14744
- var BundleState_LayoutsEntry = {
13955
+ var BundleApplyResult = {
14745
13956
  encode(message, writer = new BinaryWriter4()) {
14746
- if (message.key !== "") {
14747
- writer.uint32(10).string(message.key);
13957
+ if (message.success !== false) {
13958
+ writer.uint32(8).bool(message.success);
14748
13959
  }
14749
- if (message.value !== void 0) {
14750
- GraphLayout.encode(message.value, writer.uint32(18).fork()).join();
13960
+ for (const v of message.errors) {
13961
+ GraphError.encode(v, writer.uint32(18).fork()).join();
13962
+ }
13963
+ for (const v of message.created) {
13964
+ CreatedRef.encode(v, writer.uint32(26).fork()).join();
14751
13965
  }
14752
13966
  return writer;
14753
13967
  },
14754
13968
  decode(input, length) {
14755
13969
  const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
14756
13970
  const end = length === void 0 ? reader.len : reader.pos + length;
14757
- const message = createBaseBundleState_LayoutsEntry();
13971
+ const message = createBaseBundleApplyResult();
14758
13972
  while (reader.pos < end) {
14759
13973
  const tag = reader.uint32();
14760
13974
  switch (tag >>> 3) {
14761
13975
  case 1: {
14762
- if (tag !== 10) {
13976
+ if (tag !== 8) {
14763
13977
  break;
14764
13978
  }
14765
- message.key = reader.string();
13979
+ message.success = reader.bool();
14766
13980
  continue;
14767
13981
  }
14768
13982
  case 2: {
14769
13983
  if (tag !== 18) {
14770
13984
  break;
14771
13985
  }
14772
- message.value = GraphLayout.decode(reader, reader.uint32());
13986
+ message.errors.push(GraphError.decode(reader, reader.uint32()));
13987
+ continue;
13988
+ }
13989
+ case 3: {
13990
+ if (tag !== 26) {
13991
+ break;
13992
+ }
13993
+ message.created.push(CreatedRef.decode(reader, reader.uint32()));
14773
13994
  continue;
14774
13995
  }
14775
13996
  }
@@ -14782,62 +14003,87 @@ var BundleState_LayoutsEntry = {
14782
14003
  },
14783
14004
  fromJSON(object) {
14784
14005
  return {
14785
- key: isSet3(object.key) ? globalThis.String(object.key) : "",
14786
- value: isSet3(object.value) ? GraphLayout.fromJSON(object.value) : void 0
14006
+ success: isSet3(object.success) ? globalThis.Boolean(object.success) : false,
14007
+ errors: globalThis.Array.isArray(object?.errors) ? object.errors.map((e) => GraphError.fromJSON(e)) : [],
14008
+ created: globalThis.Array.isArray(object?.created) ? object.created.map((e) => CreatedRef.fromJSON(e)) : []
14787
14009
  };
14788
14010
  },
14789
14011
  toJSON(message) {
14790
14012
  const obj = {};
14791
- if (message.key !== "") {
14792
- obj.key = message.key;
14013
+ if (message.success !== false) {
14014
+ obj.success = message.success;
14793
14015
  }
14794
- if (message.value !== void 0) {
14795
- obj.value = GraphLayout.toJSON(message.value);
14016
+ if (message.errors?.length) {
14017
+ obj.errors = message.errors.map((e) => GraphError.toJSON(e));
14018
+ }
14019
+ if (message.created?.length) {
14020
+ obj.created = message.created.map((e) => CreatedRef.toJSON(e));
14796
14021
  }
14797
14022
  return obj;
14798
14023
  },
14799
14024
  create(base) {
14800
- return BundleState_LayoutsEntry.fromPartial(base ?? {});
14025
+ return BundleApplyResult.fromPartial(base ?? {});
14801
14026
  },
14802
14027
  fromPartial(object) {
14803
- const message = createBaseBundleState_LayoutsEntry();
14804
- message.key = object.key ?? "";
14805
- message.value = object.value !== void 0 && object.value !== null ? GraphLayout.fromPartial(object.value) : void 0;
14028
+ const message = createBaseBundleApplyResult();
14029
+ message.success = object.success ?? false;
14030
+ message.errors = object.errors?.map((e) => GraphError.fromPartial(e)) || [];
14031
+ message.created = object.created?.map((e) => CreatedRef.fromPartial(e)) || [];
14806
14032
  return message;
14807
14033
  }
14808
14034
  };
14809
- function createBaseBundleApplyResult() {
14810
- return { success: false, errors: [] };
14035
+ function createBaseCreatedRef() {
14036
+ return { scope: "", id: "", module_key: "", source_id: "" };
14811
14037
  }
14812
- var BundleApplyResult = {
14038
+ var CreatedRef = {
14813
14039
  encode(message, writer = new BinaryWriter4()) {
14814
- if (message.success !== false) {
14815
- writer.uint32(8).bool(message.success);
14040
+ if (message.scope !== "") {
14041
+ writer.uint32(10).string(message.scope);
14816
14042
  }
14817
- for (const v of message.errors) {
14818
- GraphError.encode(v, writer.uint32(18).fork()).join();
14043
+ if (message.id !== "") {
14044
+ writer.uint32(18).string(message.id);
14045
+ }
14046
+ if (message.module_key !== "") {
14047
+ writer.uint32(26).string(message.module_key);
14048
+ }
14049
+ if (message.source_id !== "") {
14050
+ writer.uint32(34).string(message.source_id);
14819
14051
  }
14820
14052
  return writer;
14821
14053
  },
14822
14054
  decode(input, length) {
14823
14055
  const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
14824
14056
  const end = length === void 0 ? reader.len : reader.pos + length;
14825
- const message = createBaseBundleApplyResult();
14057
+ const message = createBaseCreatedRef();
14826
14058
  while (reader.pos < end) {
14827
14059
  const tag = reader.uint32();
14828
14060
  switch (tag >>> 3) {
14829
14061
  case 1: {
14830
- if (tag !== 8) {
14062
+ if (tag !== 10) {
14831
14063
  break;
14832
14064
  }
14833
- message.success = reader.bool();
14065
+ message.scope = reader.string();
14834
14066
  continue;
14835
14067
  }
14836
14068
  case 2: {
14837
14069
  if (tag !== 18) {
14838
14070
  break;
14839
14071
  }
14840
- message.errors.push(GraphError.decode(reader, reader.uint32()));
14072
+ message.id = reader.string();
14073
+ continue;
14074
+ }
14075
+ case 3: {
14076
+ if (tag !== 26) {
14077
+ break;
14078
+ }
14079
+ message.module_key = reader.string();
14080
+ continue;
14081
+ }
14082
+ case 4: {
14083
+ if (tag !== 34) {
14084
+ break;
14085
+ }
14086
+ message.source_id = reader.string();
14841
14087
  continue;
14842
14088
  }
14843
14089
  }
@@ -14850,27 +14096,37 @@ var BundleApplyResult = {
14850
14096
  },
14851
14097
  fromJSON(object) {
14852
14098
  return {
14853
- success: isSet3(object.success) ? globalThis.Boolean(object.success) : false,
14854
- errors: globalThis.Array.isArray(object?.errors) ? object.errors.map((e) => GraphError.fromJSON(e)) : []
14099
+ scope: isSet3(object.scope) ? globalThis.String(object.scope) : "",
14100
+ id: isSet3(object.id) ? globalThis.String(object.id) : "",
14101
+ module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
14102
+ source_id: isSet3(object.sourceId) ? globalThis.String(object.sourceId) : isSet3(object.source_id) ? globalThis.String(object.source_id) : ""
14855
14103
  };
14856
14104
  },
14857
14105
  toJSON(message) {
14858
14106
  const obj = {};
14859
- if (message.success !== false) {
14860
- obj.success = message.success;
14107
+ if (message.scope !== "") {
14108
+ obj.scope = message.scope;
14861
14109
  }
14862
- if (message.errors?.length) {
14863
- obj.errors = message.errors.map((e) => GraphError.toJSON(e));
14110
+ if (message.id !== "") {
14111
+ obj.id = message.id;
14112
+ }
14113
+ if (message.module_key !== "") {
14114
+ obj.moduleKey = message.module_key;
14115
+ }
14116
+ if (message.source_id !== "") {
14117
+ obj.sourceId = message.source_id;
14864
14118
  }
14865
14119
  return obj;
14866
14120
  },
14867
14121
  create(base) {
14868
- return BundleApplyResult.fromPartial(base ?? {});
14122
+ return CreatedRef.fromPartial(base ?? {});
14869
14123
  },
14870
14124
  fromPartial(object) {
14871
- const message = createBaseBundleApplyResult();
14872
- message.success = object.success ?? false;
14873
- message.errors = object.errors?.map((e) => GraphError.fromPartial(e)) || [];
14125
+ const message = createBaseCreatedRef();
14126
+ message.scope = object.scope ?? "";
14127
+ message.id = object.id ?? "";
14128
+ message.module_key = object.module_key ?? "";
14129
+ message.source_id = object.source_id ?? "";
14874
14130
  return message;
14875
14131
  }
14876
14132
  };
@@ -16749,74 +16005,6 @@ var RenderError = {
16749
16005
  return message;
16750
16006
  }
16751
16007
  };
16752
- function createBasePosition2() {
16753
- return { x: 0, y: 0 };
16754
- }
16755
- var Position4 = {
16756
- encode(message, writer = new BinaryWriter4()) {
16757
- if (message.x !== 0) {
16758
- writer.uint32(9).double(message.x);
16759
- }
16760
- if (message.y !== 0) {
16761
- writer.uint32(17).double(message.y);
16762
- }
16763
- return writer;
16764
- },
16765
- decode(input, length) {
16766
- const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
16767
- const end = length === void 0 ? reader.len : reader.pos + length;
16768
- const message = createBasePosition2();
16769
- while (reader.pos < end) {
16770
- const tag = reader.uint32();
16771
- switch (tag >>> 3) {
16772
- case 1: {
16773
- if (tag !== 9) {
16774
- break;
16775
- }
16776
- message.x = reader.double();
16777
- continue;
16778
- }
16779
- case 2: {
16780
- if (tag !== 17) {
16781
- break;
16782
- }
16783
- message.y = reader.double();
16784
- continue;
16785
- }
16786
- }
16787
- if ((tag & 7) === 4 || tag === 0) {
16788
- break;
16789
- }
16790
- reader.skip(tag & 7);
16791
- }
16792
- return message;
16793
- },
16794
- fromJSON(object) {
16795
- return {
16796
- x: isSet3(object.x) ? globalThis.Number(object.x) : 0,
16797
- y: isSet3(object.y) ? globalThis.Number(object.y) : 0
16798
- };
16799
- },
16800
- toJSON(message) {
16801
- const obj = {};
16802
- if (message.x !== 0) {
16803
- obj.x = message.x;
16804
- }
16805
- if (message.y !== 0) {
16806
- obj.y = message.y;
16807
- }
16808
- return obj;
16809
- },
16810
- create(base) {
16811
- return Position4.fromPartial(base ?? {});
16812
- },
16813
- fromPartial(object) {
16814
- const message = createBasePosition2();
16815
- message.x = object.x ?? 0;
16816
- message.y = object.y ?? 0;
16817
- return message;
16818
- }
16819
- };
16820
16008
  function createBaseInputDef2() {
16821
16009
  return {
16822
16010
  name: "",
@@ -17202,7 +16390,7 @@ var ConnectWebEngine = class {
17202
16390
  this.subscribeAbort = null;
17203
16391
  this.listeners = /* @__PURE__ */ new Set();
17204
16392
  this.currentBundle = null;
17205
- this.currentLayouts = {};
16393
+ this.currentArrangement = {};
17206
16394
  this.currentCanUndo = false;
17207
16395
  this.currentCanRedo = false;
17208
16396
  this.currentIsDirty = false;
@@ -17228,6 +16416,18 @@ var ConnectWebEngine = class {
17228
16416
  getCurrentView() {
17229
16417
  return this.currentView;
17230
16418
  }
16419
+ getCurrentBundle() {
16420
+ return this.currentBundle;
16421
+ }
16422
+ /**
16423
+ * Replace the consumer-owned arrangement and re-project immediately —
16424
+ * a local view refresh, not a mutation, so it never carries a viewport
16425
+ * intent.
16426
+ */
16427
+ setArrangement(arrangement) {
16428
+ this.currentArrangement = arrangement;
16429
+ this.reproject();
16430
+ }
17231
16431
  requireSessionId() {
17232
16432
  if (!this._sessionId) throw new Error("No active session \u2014 call sessionOpen first");
17233
16433
  return this._sessionId;
@@ -17261,7 +16461,6 @@ var ConnectWebEngine = class {
17261
16461
  adoptState(state) {
17262
16462
  if (!state.bundle) return;
17263
16463
  this.currentBundle = state.bundle;
17264
- this.currentLayouts = state.layouts ?? {};
17265
16464
  this.currentCanUndo = state.can_undo;
17266
16465
  this.currentCanRedo = state.can_redo;
17267
16466
  this.currentIsDirty = state.is_dirty;
@@ -17271,7 +16470,7 @@ var ConnectWebEngine = class {
17271
16470
  reproject() {
17272
16471
  if (!this.currentBundle) return;
17273
16472
  const { id: moduleName } = parseModuleKey(this.currentBundle.entry);
17274
- const view = projectCanvasView(this.currentBundle, this.currentLayouts, {
16473
+ const view = projectCanvasView(this.currentBundle, this.currentArrangement, {
17275
16474
  moduleName,
17276
16475
  canUndo: this.currentCanUndo,
17277
16476
  canRedo: this.currentCanRedo,
@@ -17391,7 +16590,7 @@ var ConnectWebEngine = class {
17391
16590
  this._sessionId = null;
17392
16591
  this.stopSubscribe();
17393
16592
  this.currentBundle = null;
17394
- this.currentLayouts = {};
16593
+ this.currentArrangement = {};
17395
16594
  this.currentView = null;
17396
16595
  return { status: res.status };
17397
16596
  }
@@ -17438,7 +16637,7 @@ var ConnectWebEngine = class {
17438
16637
  if (res.success) {
17439
16638
  await stateUpdated;
17440
16639
  }
17441
- return { success: res.success, errors };
16640
+ return { success: res.success, errors, created: res.created.map(convertCreatedRef) };
17442
16641
  }
17443
16642
  connect(source, target, sourceOutput, targetInput) {
17444
16643
  return this.applyAction({
@@ -17486,9 +16685,6 @@ var ConnectWebEngine = class {
17486
16685
  copyInstances(instanceIds) {
17487
16686
  return this.applyAction({ copy_instances: { instance_ids: instanceIds } });
17488
16687
  }
17489
- syncLayout(positions) {
17490
- return this.applyAction({ sync_layout: { positions } });
17491
- }
17492
16688
  setVariables(variables) {
17493
16689
  return this.applyAction({
17494
16690
  set_variables: {
@@ -17585,21 +16781,11 @@ var ConnectWebEngine = class {
17585
16781
  return this.applyAction({ redo: {} });
17586
16782
  }
17587
16783
  // ── Groups ──
17588
- createGroup(label, nodeIds) {
17589
- return this.applyAction({ create_group: { label, node_ids: nodeIds } });
17590
- }
17591
- updateGroup(groupId, updates) {
17592
- return this.applyAction({
17593
- update_group: {
17594
- group_id: groupId,
17595
- label: updates.label,
17596
- collapsed: updates.collapsed,
17597
- node_ids: updates.node_ids ? { node_ids: updates.node_ids } : void 0
17598
- }
17599
- });
16784
+ createGroup(nodeIds) {
16785
+ return this.applyAction({ create_group: { node_ids: nodeIds } });
17600
16786
  }
17601
- deleteGroup(groupId) {
17602
- return this.applyAction({ delete_group: { group_id: groupId } });
16787
+ ungroup(groupId) {
16788
+ return this.applyAction({ ungroup: { group_id: groupId } });
17603
16789
  }
17604
16790
  // ── Queries ──
17605
16791
  async queryNodeConfig(instanceId) {
@@ -17691,8 +16877,7 @@ var ConnectWebEngine = class {
17691
16877
  name: params.name,
17692
16878
  system: params.system,
17693
16879
  version: params.version,
17694
- organization: params.organization ?? "",
17695
- position: params.position
16880
+ organization: params.organization ?? ""
17696
16881
  }
17697
16882
  });
17698
16883
  }
@@ -17847,6 +17032,9 @@ function convertGraphError(e) {
17847
17032
  message: e.message
17848
17033
  };
17849
17034
  }
17035
+ function convertCreatedRef(r) {
17036
+ return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
17037
+ }
17850
17038
  function protoModuleMetadataToCanvas(p) {
17851
17039
  return {
17852
17040
  id: p.id,
@@ -17958,7 +17146,7 @@ var PostMessageEngine = class {
17958
17146
  this.pending = /* @__PURE__ */ new Map();
17959
17147
  this.listeners = /* @__PURE__ */ new Set();
17960
17148
  this.currentBundle = null;
17961
- this.currentLayouts = {};
17149
+ this.currentArrangement = {};
17962
17150
  this.currentCanUndo = false;
17963
17151
  this.currentCanRedo = false;
17964
17152
  this.currentIsDirty = false;
@@ -18020,18 +17208,43 @@ var PostMessageEngine = class {
18020
17208
  getCurrentView() {
18021
17209
  return this.currentView;
18022
17210
  }
17211
+ getCurrentBundle() {
17212
+ return this.currentBundle;
17213
+ }
17214
+ /**
17215
+ * Replace the consumer-owned arrangement and re-project immediately —
17216
+ * this is a local view refresh, not a mutation, so it never waits on a
17217
+ * round-trip and never carries a viewport intent (the consumer's camera
17218
+ * position is unaffected by a drag/collapse/rename it already applied
17219
+ * optimistically).
17220
+ */
17221
+ setArrangement(arrangement) {
17222
+ this.currentArrangement = arrangement;
17223
+ this.reproject();
17224
+ }
18023
17225
  emit(event) {
18024
17226
  for (const listener of this.listeners) listener(event);
18025
17227
  }
17228
+ reproject() {
17229
+ if (!this.currentBundle) return;
17230
+ const { id: moduleName } = parseModuleKey2(this.currentBundle.entry);
17231
+ const view = projectCanvasView2(this.currentBundle, this.currentArrangement, {
17232
+ moduleName,
17233
+ canUndo: this.currentCanUndo,
17234
+ canRedo: this.currentCanRedo,
17235
+ isDirty: this.currentIsDirty
17236
+ });
17237
+ this.currentView = view;
17238
+ this.emit({ type: "stateUpdated", view });
17239
+ }
18026
17240
  adoptState(state, viewportIntent) {
18027
17241
  if (!state.bundle) return;
18028
17242
  this.currentBundle = state.bundle;
18029
- this.currentLayouts = state.layouts ?? {};
18030
17243
  this.currentCanUndo = state.can_undo;
18031
17244
  this.currentCanRedo = state.can_redo;
18032
17245
  this.currentIsDirty = state.is_dirty;
18033
17246
  const { id: moduleName } = parseModuleKey2(this.currentBundle.entry);
18034
- const view = projectCanvasView2(this.currentBundle, this.currentLayouts, {
17247
+ const view = projectCanvasView2(this.currentBundle, this.currentArrangement, {
18035
17248
  moduleName,
18036
17249
  canUndo: this.currentCanUndo,
18037
17250
  canRedo: this.currentCanRedo,
@@ -18091,13 +17304,15 @@ var PostMessageEngine = class {
18091
17304
  // `loadState` message the host emits after subscribing to the CLI.
18092
17305
  async applyAction(action) {
18093
17306
  const stateUpdated = this.nextStateUpdate();
18094
- const res = await this.call("action/apply", {
18095
- action
18096
- });
17307
+ const res = await this.call("action/apply", { action });
18097
17308
  if (res.success) {
18098
17309
  await stateUpdated;
18099
17310
  }
18100
- return { success: res.success, errors: res.errors };
17311
+ return {
17312
+ success: res.success,
17313
+ errors: res.errors,
17314
+ created: (res.created ?? []).map(convertCreatedRef2)
17315
+ };
18101
17316
  }
18102
17317
  // ── Session ──
18103
17318
  async sessionOpen(filePath, workspaceName) {
@@ -18166,9 +17381,6 @@ var PostMessageEngine = class {
18166
17381
  copyInstances(instanceIds) {
18167
17382
  return this.applyAction({ copy_instances: { instance_ids: instanceIds } });
18168
17383
  }
18169
- syncLayout(positions) {
18170
- return this.applyAction({ sync_layout: { positions } });
18171
- }
18172
17384
  setVariables(variables) {
18173
17385
  return this.applyAction({
18174
17386
  set_variables: {
@@ -18270,27 +17482,16 @@ var PostMessageEngine = class {
18270
17482
  name: params.name,
18271
17483
  system: params.system,
18272
17484
  version: params.version,
18273
- organization: params.organization ?? "",
18274
- position: params.position
17485
+ organization: params.organization ?? ""
18275
17486
  }
18276
17487
  });
18277
17488
  }
18278
17489
  // ── Groups ──
18279
- createGroup(label, nodeIds) {
18280
- return this.applyAction({ create_group: { label, node_ids: nodeIds } });
18281
- }
18282
- updateGroup(groupId, updates) {
18283
- return this.applyAction({
18284
- update_group: {
18285
- group_id: groupId,
18286
- label: updates.label,
18287
- collapsed: updates.collapsed,
18288
- node_ids: updates.node_ids ? { node_ids: updates.node_ids } : void 0
18289
- }
18290
- });
17490
+ createGroup(nodeIds) {
17491
+ return this.applyAction({ create_group: { node_ids: nodeIds } });
18291
17492
  }
18292
- deleteGroup(groupId) {
18293
- return this.applyAction({ delete_group: { group_id: groupId } });
17493
+ ungroup(groupId) {
17494
+ return this.applyAction({ ungroup: { group_id: groupId } });
18294
17495
  }
18295
17496
  // ── Queries ──
18296
17497
  queryNodeConfig(instanceId) {
@@ -18353,6 +17554,9 @@ var PostMessageEngine = class {
18353
17554
  });
18354
17555
  }
18355
17556
  };
17557
+ function convertCreatedRef2(r) {
17558
+ return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
17559
+ }
18356
17560
  function convertPolicyResolution2(p) {
18357
17561
  return {
18358
17562
  mode: p.mode,
@@ -18398,7 +17602,8 @@ import { parseModuleKey as parseModuleKey3, projectCanvasView as projectCanvasVi
18398
17602
  var READ_ONLY_ERROR_MESSAGE = "SnapshotCanvasEngine is read-only";
18399
17603
  var READ_ONLY_RESULT = {
18400
17604
  success: false,
18401
- errors: [{ moduleKey: "", instanceId: "", inputName: "", message: READ_ONLY_ERROR_MESSAGE }]
17605
+ errors: [{ moduleKey: "", instanceId: "", inputName: "", message: READ_ONLY_ERROR_MESSAGE }],
17606
+ created: []
18402
17607
  };
18403
17608
  var EMPTY_NODE_CONFIG = {
18404
17609
  instance_id: "",
@@ -18428,16 +17633,20 @@ var SnapshotCanvasEngine = class {
18428
17633
  constructor(input) {
18429
17634
  this.loadPromise = null;
18430
17635
  this.view = null;
17636
+ this.bundle = null;
17637
+ this.listeners = /* @__PURE__ */ new Set();
18431
17638
  this.input = input;
18432
17639
  const injected = "bundleUrl" in input ? input.fetch : void 0;
18433
17640
  this.fetchImpl = injected ?? globalThis.fetch.bind(globalThis);
17641
+ this.meta = input.meta ?? {};
18434
17642
  if ("bundle" in input) {
18435
- this.view = this.projectInput(input.bundle, input.layouts ?? {}, input.meta ?? {});
17643
+ this.bundle = input.bundle;
17644
+ this.view = this.projectInput(input.bundle, input.arrangement, this.meta);
18436
17645
  }
18437
17646
  }
18438
- projectInput(bundle, layouts, meta) {
17647
+ projectInput(bundle, arrangement, meta) {
18439
17648
  const { id: moduleName } = parseModuleKey3(bundle.entry);
18440
- return projectCanvasView3(bundle, layouts, {
17649
+ return projectCanvasView3(bundle, arrangement, {
18441
17650
  moduleName: meta.moduleName ?? moduleName,
18442
17651
  canUndo: meta.canUndo ?? false,
18443
17652
  canRedo: meta.canRedo ?? false,
@@ -18449,15 +17658,13 @@ var SnapshotCanvasEngine = class {
18449
17658
  if (!this.loadPromise) {
18450
17659
  const input = this.input;
18451
17660
  if (!("bundleUrl" in input)) {
18452
- throw new Error("SnapshotCanvasEngine: no view and no URLs to fetch");
17661
+ throw new Error("SnapshotCanvasEngine: no view and no URL to fetch");
18453
17662
  }
18454
17663
  this.loadPromise = (async () => {
18455
- const [bundleBytes, layouts] = await Promise.all([
18456
- this.fetchBytes(input.bundleUrl, "bundle", input.headers),
18457
- this.fetchLayouts(input.layoutsUrl, input.headers)
18458
- ]);
17664
+ const bundleBytes = await this.fetchBytes(input.bundleUrl, "bundle", input.headers);
18459
17665
  const bundle = Bundle.decode(bundleBytes);
18460
- const view = this.projectInput(bundle, layouts, input.meta ?? {});
17666
+ this.bundle = bundle;
17667
+ const view = this.projectInput(bundle, input.arrangement, this.meta);
18461
17668
  this.view = view;
18462
17669
  return view;
18463
17670
  })();
@@ -18478,25 +17685,23 @@ var SnapshotCanvasEngine = class {
18478
17685
  }
18479
17686
  return new Uint8Array(await res.arrayBuffer());
18480
17687
  }
18481
- // Layouts are an optional overlay, not IR — see the comment at the
18482
- // `Promise.all` call site. A FETCH failure here (most commonly a Run
18483
- // with no layoutsR2Key, 404) is not an engine-load failure; it degrades
18484
- // to the same empty layouts map the in-process constructor accepts. A
18485
- // DECODE failure is different — corrupt or truncated bytes are real
18486
- // breakage, not an absent-layouts 404 — so `decode` stays outside the
18487
- // catch and still surfaces as `loadError`.
18488
- async fetchLayouts(url, headers) {
18489
- let bytes;
18490
- try {
18491
- bytes = await this.fetchBytes(url, "layouts", headers);
18492
- } catch {
18493
- return {};
18494
- }
18495
- return LayoutsMap.decode(bytes).layouts ?? {};
18496
- }
18497
17688
  getCurrentView() {
18498
17689
  return this.view;
18499
17690
  }
17691
+ getCurrentBundle() {
17692
+ return this.bundle;
17693
+ }
17694
+ // Re-projecting from a new arrangement is a pure local recompute, not an
17695
+ // IR mutation — a read-only mount (portal's control-plane dashboard)
17696
+ // still lets users expand/collapse groups and drag nodes as view-only
17697
+ // operations, and this is the single projection site those operations
17698
+ // route through, same as the mutating engines.
17699
+ setArrangement(arrangement) {
17700
+ if (!this.bundle) return;
17701
+ const view = this.projectInput(this.bundle, arrangement, this.meta);
17702
+ this.view = view;
17703
+ for (const listener of this.listeners) listener({ type: "stateUpdated", view });
17704
+ }
18500
17705
  // ── Session ──────────────────────────────────────────────────────────
18501
17706
  async sessionOpen() {
18502
17707
  return this.loadView();
@@ -18542,9 +17747,6 @@ var SnapshotCanvasEngine = class {
18542
17747
  async copyInstances(_instanceIds) {
18543
17748
  return READ_ONLY_RESULT;
18544
17749
  }
18545
- async syncLayout(_positions) {
18546
- return READ_ONLY_RESULT;
18547
- }
18548
17750
  async setVariables(_variables) {
18549
17751
  return READ_ONLY_RESULT;
18550
17752
  }
@@ -18578,13 +17780,10 @@ var SnapshotCanvasEngine = class {
18578
17780
  async placeModule(_params) {
18579
17781
  return READ_ONLY_RESULT;
18580
17782
  }
18581
- async createGroup(_label, _nodeIds) {
17783
+ async createGroup(_nodeIds) {
18582
17784
  return READ_ONLY_RESULT;
18583
17785
  }
18584
- async updateGroup(_groupId, _updates) {
18585
- return READ_ONLY_RESULT;
18586
- }
18587
- async deleteGroup(_groupId) {
17786
+ async ungroup(_groupId) {
18588
17787
  return READ_ONLY_RESULT;
18589
17788
  }
18590
17789
  // ── Queries (best-effort / empty) ────────────────────────────────────
@@ -18635,6 +17834,7 @@ var SnapshotCanvasEngine = class {
18635
17834
  // ── Events ───────────────────────────────────────────────────────────
18636
17835
  onEvent(listener) {
18637
17836
  let cancelled = false;
17837
+ this.listeners.add(listener);
18638
17838
  const deliver = (view) => {
18639
17839
  if (cancelled) return;
18640
17840
  const event = { type: "stateUpdated", view };
@@ -18654,6 +17854,7 @@ var SnapshotCanvasEngine = class {
18654
17854
  }
18655
17855
  return () => {
18656
17856
  cancelled = true;
17857
+ this.listeners.delete(listener);
18657
17858
  };
18658
17859
  }
18659
17860
  };