@mx-sose-front/mx-sose-graph 1.1.6 → 1.1.7

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.esm.js CHANGED
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { ref, shallowReactive, computed, shallowRef, nextTick, triggerRef, defineComponent, openBlock, createElementBlock, normalizeStyle, withDirectives, createElementVNode, Fragment, renderList, unref, normalizeClass, withModifiers, vShow, watch, createCommentVNode, withKeys, vModelText, onMounted, onUnmounted, resolveComponent, createBlock, Teleport, createVNode, withCtx, useCssVars, resolveDynamicComponent, toDisplayString, onBeforeUnmount, isMemoSame } from "vue";
7
+ import { ref, shallowReactive, computed, nextTick, defineComponent, openBlock, createElementBlock, normalizeStyle, withDirectives, createElementVNode, Fragment, renderList, unref, normalizeClass, withModifiers, vShow, watch, createCommentVNode, withKeys, vModelText, onMounted, onUnmounted, resolveComponent, createBlock, Teleport, createVNode, withCtx, useCssVars, resolveDynamicComponent, toDisplayString, onBeforeUnmount, isMemoSame } from "vue";
8
8
  import { defineStore, storeToRefs, setActivePinia } from "pinia";
9
9
  import ElementPlus, { ElMessage } from "element-plus";
10
10
  var v = false, o, f, s, u, d, N, l, p, m, w, D, x, E, M, F;
@@ -6435,13 +6435,11 @@ const resolveParentAfterDrag = (shapes, s2, finalRect, draggingIds, diagramId, u
6435
6435
  };
6436
6436
  const pointInRect = (pt, r, margin = 0) => pt.x >= r.x + margin && pt.x <= r.x + r.width - margin && pt.y >= r.y + margin && pt.y <= r.y + r.height - margin;
6437
6437
  const depthOf = (shapes, id) => {
6438
- const graphStore = useGraphStore();
6439
- const byId = graphStore.shapeMap;
6440
6438
  let d2 = 0;
6441
- let p2 = byId.get(id)?.parenShapeId ?? null;
6439
+ let p2 = shapes.find((s2) => s2.id === id)?.parenShapeId ?? null;
6442
6440
  while (p2) {
6443
6441
  d2++;
6444
- p2 = byId.get(p2)?.parenShapeId ?? null;
6442
+ p2 = shapes.find((s2) => s2.id === p2)?.parenShapeId ?? null;
6445
6443
  }
6446
6444
  return d2;
6447
6445
  };
@@ -6603,11 +6601,9 @@ function normalizeZOrder(shapes, diagramId, updateShape, baseZ = 1, step = 1) {
6603
6601
  }
6604
6602
  }
6605
6603
  const buildDragSnapshot = (shapes, ids) => {
6606
- const graphStore = useGraphStore();
6607
- const byId = graphStore.shapeMap;
6608
6604
  const dragBase = {};
6609
6605
  ids.forEach((id) => {
6610
- const s2 = byId.get(id);
6606
+ const s2 = shapes.find((x2) => x2.id === id);
6611
6607
  if (!s2)
6612
6608
  return;
6613
6609
  const b2 = getBounds(s2);
@@ -6625,8 +6621,7 @@ const buildDragSnapshot = (shapes, ids) => {
6625
6621
  return { dragBase, groupBaseBox };
6626
6622
  };
6627
6623
  const stepSingleDrag = (shapes, id, pointer, dragOffset, dragBase, diagramId, constrainEdges, hitPointer) => {
6628
- const graphStore = useGraphStore();
6629
- const s2 = graphStore.shapeMap.get(id);
6624
+ const s2 = shapes.find((x2) => x2.id === id);
6630
6625
  if (!s2)
6631
6626
  return { ghost: {}, hover: null };
6632
6627
  const base = dragBase[id];
@@ -6654,8 +6649,6 @@ const stepSingleDrag = (shapes, id, pointer, dragOffset, dragBase, diagramId, co
6654
6649
  };
6655
6650
  };
6656
6651
  const stepGroupDrag = (shapes, draggingIds, primaryId, pointer, dragAnchor, groupBaseBox) => {
6657
- const graphStore = useGraphStore();
6658
- const byId = graphStore.shapeMap;
6659
6652
  const diagramRect = getDiagramRect(shapes);
6660
6653
  const dxRaw = pointer.x - dragAnchor.x;
6661
6654
  const dyRaw = pointer.y - dragAnchor.y;
@@ -6669,13 +6662,13 @@ const stepGroupDrag = (shapes, draggingIds, primaryId, pointer, dragAnchor, grou
6669
6662
  const dy = gy - groupBaseBox.y;
6670
6663
  const ghost = {};
6671
6664
  for (const id of draggingIds) {
6672
- const s2 = byId.get(id);
6665
+ const s2 = shapes.find((x2) => x2.id === id);
6673
6666
  if (!s2)
6674
6667
  continue;
6675
6668
  const b2 = getBounds(s2);
6676
6669
  ghost[id] = { x: b2.x + dx, y: b2.y + dy, width: b2.width, height: b2.height };
6677
6670
  }
6678
- const priShape = byId.get(primaryId);
6671
+ const priShape = shapes.find((x2) => x2.id === primaryId);
6679
6672
  const diagramId = priShape?.diagramId || "";
6680
6673
  const hoverShape = pickContainerByPointerTopmost(
6681
6674
  shapes,
@@ -6689,18 +6682,7 @@ const stepGroupDrag = (shapes, draggingIds, primaryId, pointer, dragAnchor, grou
6689
6682
  return { ghost, hover };
6690
6683
  };
6691
6684
  const commitDrag = (shapes, draggingIds, ghost, _currentDiagramId, updateShape, baseMap) => {
6692
- const graphStore = useGraphStore();
6693
- const parentChildMap = graphStore.parentChildMap;
6694
6685
  const changedIds = /* @__PURE__ */ new Set();
6695
- const collectAllDescendants = (parentId) => {
6696
- const result = [];
6697
- const children = parentChildMap.get(parentId) || [];
6698
- for (const childId of children) {
6699
- result.push(childId);
6700
- result.push(...collectAllDescendants(childId));
6701
- }
6702
- return result;
6703
- };
6704
6686
  for (const id of draggingIds) {
6705
6687
  const s2 = shapes.find((x2) => x2.id === id);
6706
6688
  const r = ghost[id];
@@ -6713,32 +6695,10 @@ const commitDrag = (shapes, draggingIds, ghost, _currentDiagramId, updateShape,
6713
6695
  height: Math.round(r.height)
6714
6696
  };
6715
6697
  const pb = baseMap?.[id] ?? s2.bounds;
6716
- const dx = nb.x - pb.x;
6717
- const dy = nb.y - pb.y;
6718
- const same = dx === 0 && dy === 0 && nb.width === pb.width && nb.height === pb.height;
6698
+ const same = pb.x === nb.x && pb.y === nb.y && pb.width === nb.width && pb.height === nb.height;
6719
6699
  if (!same) {
6720
6700
  updateShape(id, { bounds: nb });
6721
6701
  changedIds.add(id);
6722
- if (dx !== 0 || dy !== 0) {
6723
- const descendants = collectAllDescendants(id);
6724
- for (const descId of descendants) {
6725
- if (draggingIds.includes(descId))
6726
- continue;
6727
- const descShape = shapes.find((x2) => x2.id === descId);
6728
- if (!descShape?.bounds)
6729
- continue;
6730
- const descBounds = descShape.bounds;
6731
- updateShape(descId, {
6732
- bounds: {
6733
- x: Math.round(descBounds.x + dx),
6734
- y: Math.round(descBounds.y + dy),
6735
- width: descBounds.width,
6736
- height: descBounds.height
6737
- }
6738
- });
6739
- changedIds.add(descId);
6740
- }
6741
- }
6742
6702
  }
6743
6703
  }
6744
6704
  return Array.from(changedIds);
@@ -8513,11 +8473,10 @@ function createShapeOperator() {
8513
8473
  const removeByIdFast = (list, id) => {
8514
8474
  const idx = indexMap.get(id);
8515
8475
  if (idx == null)
8516
- return null;
8476
+ return false;
8517
8477
  const lastIdx = list.length - 1;
8518
8478
  if (lastIdx < 0)
8519
- return null;
8520
- const removed = list[idx];
8479
+ return false;
8521
8480
  if (idx !== lastIdx) {
8522
8481
  const moved = list[lastIdx];
8523
8482
  list[idx] = moved;
@@ -8525,52 +8484,46 @@ function createShapeOperator() {
8525
8484
  }
8526
8485
  list.pop();
8527
8486
  indexMap.delete(id);
8528
- return removed;
8487
+ return true;
8529
8488
  };
8530
8489
  const upsertOne = (list, incoming) => {
8531
8490
  const id = incoming?.id;
8532
8491
  if (id == null)
8533
- return { changed: false, isAdd: false };
8492
+ return false;
8534
8493
  const idx = indexMap.get(id);
8535
8494
  if (idx == null) {
8536
8495
  list.push(incoming);
8537
8496
  indexMap.set(id, list.length - 1);
8538
- return { changed: true, isAdd: true };
8539
8497
  } else {
8540
- const oldShape = list[idx];
8541
8498
  list[idx] = incoming;
8542
- return { changed: true, isAdd: false, oldShape };
8543
8499
  }
8500
+ return true;
8544
8501
  };
8545
8502
  const updateOne = (list, incoming) => {
8546
8503
  const id = incoming?.id;
8547
8504
  if (id == null)
8548
- return { changed: false };
8505
+ return false;
8549
8506
  const idx = indexMap.get(id);
8550
8507
  if (idx == null)
8551
- return { changed: false };
8552
- const oldShape = list[idx];
8508
+ return false;
8553
8509
  list[idx] = incoming;
8554
- return { changed: true, oldShape };
8510
+ return true;
8555
8511
  };
8556
8512
  const addOne = (list, incoming) => {
8557
8513
  const id = incoming?.id;
8558
8514
  if (id == null)
8559
- return { changed: false, isAdd: false };
8515
+ return false;
8560
8516
  const idx = indexMap.get(id);
8561
8517
  if (idx == null) {
8562
8518
  list.push(incoming);
8563
8519
  indexMap.set(id, list.length - 1);
8564
- return { changed: true, isAdd: true };
8565
8520
  } else {
8566
- const oldShape = list[idx];
8567
8521
  list[idx] = incoming;
8568
- return { changed: true, isAdd: false, oldShape };
8569
8522
  }
8523
+ return true;
8570
8524
  };
8571
8525
  const applyShapeOp = (args) => {
8572
8526
  const { list, payload, op } = args;
8573
- const changeDetails = [];
8574
8527
  if (op === "replace") {
8575
8528
  const incomingShapes2 = payload;
8576
8529
  list.length = 0;
@@ -8583,57 +8536,33 @@ function createShapeOperator() {
8583
8536
  for (let i = 0; i < list.length; i++) {
8584
8537
  indexMap.set(list[i].id, i);
8585
8538
  }
8586
- return { changedShapes: incomingShapes2, changeDetails: [] };
8539
+ return { changedShapes: incomingShapes2 };
8587
8540
  }
8588
8541
  ensureIndex(list);
8589
8542
  const changedShapes = [];
8590
8543
  if (op === "delete") {
8591
8544
  const ids = extractIds(payload);
8592
8545
  for (const id of ids) {
8593
- const removed = removeByIdFast(list, id);
8594
- if (removed) {
8595
- changeDetails.push({ type: "delete", shape: removed });
8596
- }
8546
+ removeByIdFast(list, id);
8597
8547
  }
8598
- return { changedShapes, changeDetails };
8548
+ return { changedShapes };
8599
8549
  }
8600
8550
  const incomingShapes = payload;
8601
8551
  for (const incoming of incomingShapes) {
8602
8552
  if (!incoming)
8603
8553
  continue;
8604
8554
  if (op === "upsert") {
8605
- const result = upsertOne(list, incoming);
8606
- if (result.changed) {
8555
+ if (upsertOne(list, incoming))
8607
8556
  changedShapes.push(incoming);
8608
- changeDetails.push({
8609
- type: result.isAdd ? "add" : "update",
8610
- shape: incoming,
8611
- oldShape: result.oldShape
8612
- });
8613
- }
8614
8557
  } else if (op === "update") {
8615
- const result = updateOne(list, incoming);
8616
- if (result.changed) {
8558
+ if (updateOne(list, incoming))
8617
8559
  changedShapes.push(incoming);
8618
- changeDetails.push({
8619
- type: "update",
8620
- shape: incoming,
8621
- oldShape: result.oldShape
8622
- });
8623
- }
8624
8560
  } else if (op === "add") {
8625
- const result = addOne(list, incoming);
8626
- if (result.changed) {
8561
+ if (addOne(list, incoming))
8627
8562
  changedShapes.push(incoming);
8628
- changeDetails.push({
8629
- type: result.isAdd ? "add" : "update",
8630
- shape: incoming,
8631
- oldShape: result.oldShape
8632
- });
8633
- }
8634
8563
  }
8635
8564
  }
8636
- return { changedShapes, changeDetails };
8565
+ return { changedShapes };
8637
8566
  };
8638
8567
  return {
8639
8568
  applyShapeOp
@@ -8670,95 +8599,27 @@ const useGraphStore = defineStore(
8670
8599
  const externalCreatingId = ref(null);
8671
8600
  const cutShapeIds = ref(/* @__PURE__ */ new Set());
8672
8601
  const copiedShapesCount = ref(0);
8673
- const dragDescendantsSnapshot = ref(/* @__PURE__ */ new Map());
8674
8602
  const shapeCount = computed(() => shapes.value.length);
8675
8603
  const hasSelectedShape = computed(() => selectedShape.value !== null);
8676
- const _shapeMapRef = shallowRef(/* @__PURE__ */ new Map());
8677
- const shapeMap = computed(() => _shapeMapRef.value);
8678
- const _parentChildMapRef = shallowRef(/* @__PURE__ */ new Map());
8679
- const parentChildMap = computed(() => _parentChildMapRef.value);
8680
- function _indexAdd(shape) {
8681
- _shapeMapRef.value.set(shape.id, shape);
8682
- if (shape.parenShapeId) {
8683
- const children = _parentChildMapRef.value.get(shape.parenShapeId);
8684
- if (children) {
8685
- if (!children.includes(shape.id)) {
8686
- children.push(shape.id);
8687
- }
8688
- } else {
8689
- _parentChildMapRef.value.set(shape.parenShapeId, [shape.id]);
8690
- }
8691
- }
8692
- }
8693
- function _indexRemove(shapeId) {
8694
- const shape = _shapeMapRef.value.get(shapeId);
8695
- if (!shape)
8696
- return;
8697
- _shapeMapRef.value.delete(shapeId);
8698
- if (shape.parenShapeId) {
8699
- const children = _parentChildMapRef.value.get(shape.parenShapeId);
8700
- if (children) {
8701
- const idx = children.indexOf(shapeId);
8702
- if (idx !== -1)
8703
- children.splice(idx, 1);
8704
- if (children.length === 0) {
8705
- _parentChildMapRef.value.delete(shape.parenShapeId);
8706
- }
8707
- }
8708
- }
8709
- _parentChildMapRef.value.delete(shapeId);
8710
- }
8711
- function _indexUpdate(shape, oldParentId) {
8712
- _shapeMapRef.value.set(shape.id, shape);
8713
- const newParentId = shape.parenShapeId ?? null;
8714
- const normalizedOldParent = oldParentId ?? null;
8715
- if (normalizedOldParent !== newParentId) {
8716
- if (normalizedOldParent) {
8717
- const oldChildren = _parentChildMapRef.value.get(normalizedOldParent);
8718
- if (oldChildren) {
8719
- const idx = oldChildren.indexOf(shape.id);
8720
- if (idx !== -1)
8721
- oldChildren.splice(idx, 1);
8722
- if (oldChildren.length === 0) {
8723
- _parentChildMapRef.value.delete(normalizedOldParent);
8724
- }
8725
- }
8726
- }
8727
- if (newParentId) {
8728
- const newChildren = _parentChildMapRef.value.get(newParentId);
8729
- if (newChildren) {
8730
- if (!newChildren.includes(shape.id)) {
8731
- newChildren.push(shape.id);
8732
- }
8733
- } else {
8734
- _parentChildMapRef.value.set(newParentId, [shape.id]);
8735
- }
8736
- }
8737
- }
8738
- }
8739
- function _rebuildIndex() {
8740
- const newShapeMap = /* @__PURE__ */ new Map();
8741
- const newParentChildMap = /* @__PURE__ */ new Map();
8604
+ const parentChildMap = computed(() => {
8605
+ const map = /* @__PURE__ */ new Map();
8742
8606
  shapes.value.forEach((shape) => {
8743
- newShapeMap.set(shape.id, shape);
8744
8607
  if (shape.parenShapeId) {
8745
- const children = newParentChildMap.get(shape.parenShapeId);
8746
- if (children) {
8747
- children.push(shape.id);
8748
- } else {
8749
- newParentChildMap.set(shape.parenShapeId, [shape.id]);
8608
+ if (!map.has(shape.parenShapeId)) {
8609
+ map.set(shape.parenShapeId, []);
8750
8610
  }
8611
+ map.get(shape.parenShapeId).push(shape.id);
8751
8612
  }
8752
8613
  });
8753
- _shapeMapRef.value = newShapeMap;
8754
- _parentChildMapRef.value = newParentChildMap;
8755
- triggerRef(_shapeMapRef);
8756
- triggerRef(_parentChildMapRef);
8757
- }
8758
- function _triggerIndexUpdate() {
8759
- triggerRef(_shapeMapRef);
8760
- triggerRef(_parentChildMapRef);
8761
- }
8614
+ return map;
8615
+ });
8616
+ const shapeMap = computed(() => {
8617
+ const map = /* @__PURE__ */ new Map();
8618
+ shapes.value.forEach((shape) => {
8619
+ map.set(shape.id, shape);
8620
+ });
8621
+ return map;
8622
+ });
8762
8623
  const taggedValueLabels = ref([]);
8763
8624
  const packagesTypes = ref([]);
8764
8625
  const classMetaTypes = ref([]);
@@ -8778,8 +8639,6 @@ const useGraphStore = defineStore(
8778
8639
  }
8779
8640
  }
8780
8641
  shapes.value.push(shape);
8781
- _indexAdd(shape);
8782
- _triggerIndexUpdate();
8783
8642
  const shouldAutoExpand = options?.autoExpandParent !== false;
8784
8643
  if (shouldAutoExpand && shape.parenShapeId && shape.bounds) {
8785
8644
  nextTick(() => {
@@ -8790,9 +8649,6 @@ const useGraphStore = defineStore(
8790
8649
  const removeShape = (shapeId) => {
8791
8650
  const index = shapes.value.findIndex((s2) => s2.id == shapeId);
8792
8651
  if (index > -1) {
8793
- _indexRemove(shapeId);
8794
- shapes.value.splice(index, 1);
8795
- _triggerIndexUpdate();
8796
8652
  if (selectedShape.value?.id === shapeId) {
8797
8653
  selectedShape.value = null;
8798
8654
  eventBus.emit("shape-deselected");
@@ -8817,7 +8673,6 @@ const useGraphStore = defineStore(
8817
8673
  const updateShapeRaw = (shapeId, updates, id = "id") => {
8818
8674
  const shape = shapes.value.find((s2) => s2[id] === shapeId);
8819
8675
  if (shape) {
8820
- const oldParentId = shape.parenShapeId;
8821
8676
  if (shape.shapeType === "pin" && "parenShapeId" in updates) {
8822
8677
  const v2 = updates.parenShapeId;
8823
8678
  if (v2 == null || v2 === "") {
@@ -8831,8 +8686,6 @@ const useGraphStore = defineStore(
8831
8686
  const nextBounds = updates.bounds ? { ...shape.bounds, ...updates.bounds } : shape.bounds;
8832
8687
  const nextStyle = updates.style ? { ...shape.style || {}, ...updates.style } : shape.style;
8833
8688
  Object.assign(shape, updates, { bounds: nextBounds, style: nextStyle });
8834
- _indexUpdate(shape, oldParentId);
8835
- _triggerIndexUpdate();
8836
8689
  eventBus.emit("shape-updated", shape, updates);
8837
8690
  }
8838
8691
  };
@@ -8861,37 +8714,25 @@ const useGraphStore = defineStore(
8861
8714
  eventBus.emit("shape-selected", shape);
8862
8715
  };
8863
8716
  const marqueeShapes = computed(() => {
8717
+ const byId2 = (id) => shapes.value.find((s2) => s2.id === id);
8718
+ const isShape2 = (x2) => !!x2;
8864
8719
  const pending = new Set(pendingNestedIds.value);
8865
- const result = [];
8866
- for (const id of selectedIds.value) {
8867
- if (pending.has(id))
8868
- continue;
8869
- const shape = shapeMap.value.get(id);
8870
- if (shape)
8871
- result.push(shape);
8872
- }
8873
- return result;
8720
+ return selectedIds.value.map(byId2).filter(isShape2).filter((s2) => !pending.has(s2.id));
8874
8721
  });
8875
8722
  const ghostShadow = computed(() => {
8876
- if (!isDragging.value || draggingIds.value.length === 0)
8877
- return [];
8878
8723
  const out = [];
8879
8724
  const pendingList = Array.isArray(pendingNestedIds.value) ? pendingNestedIds.value : [];
8880
8725
  const pendingSet = new Set(pendingList);
8881
- const directDragSet = new Set(dragSelectionSnapshot.value.length > 0 ? dragSelectionSnapshot.value : draggingIds.value.slice(0, 1));
8882
8726
  const map = shapeMap.value;
8883
- for (const id of directDragSet) {
8727
+ for (const id in dragGhost) {
8884
8728
  if (pendingSet.has(id))
8885
8729
  continue;
8886
- const ghostRect = dragGhost[id];
8887
- if (!ghostRect)
8888
- continue;
8889
8730
  const orig = map.get(id);
8890
8731
  if (!orig)
8891
8732
  continue;
8892
8733
  out.push({
8893
8734
  ...orig,
8894
- bounds: { ...ghostRect },
8735
+ bounds: { ...dragGhost[id] },
8895
8736
  meta: { ...orig.meta, isGhost: true }
8896
8737
  });
8897
8738
  }
@@ -8899,16 +8740,11 @@ const useGraphStore = defineStore(
8899
8740
  });
8900
8741
  const selectMany = (ids) => {
8901
8742
  selectedIds.value = Array.from(new Set(ids));
8902
- selectedShape.value = ids.length ? shapeMap.value.get(ids[0]) ?? null : null;
8743
+ selectedShape.value = ids.length ? shapes.value.find((s2) => s2.id === ids[0]) ?? null : null;
8903
8744
  };
8904
8745
  const clearSelection = () => selectShape(null);
8905
8746
  const selectAll = () => {
8906
- const allShapeIds = [];
8907
- for (const shape of shapes.value) {
8908
- if (shape.shapeType?.toLowerCase() !== "diagram") {
8909
- allShapeIds.push(shape.id);
8910
- }
8911
- }
8747
+ const allShapeIds = shapes.value.filter((shape) => shape.shapeType?.toLowerCase() !== "diagram").map((shape) => shape.id);
8912
8748
  selectMany(allShapeIds);
8913
8749
  };
8914
8750
  const setTitle = (title) => {
@@ -8916,40 +8752,12 @@ const useGraphStore = defineStore(
8916
8752
  eventBus.emit("title-changed", title);
8917
8753
  };
8918
8754
  const updateShapes = (payload, op = "upsert", options) => {
8919
- const { changedShapes, changeDetails } = applyShapeOp({
8755
+ const { changedShapes } = applyShapeOp({
8920
8756
  list: shapes.value,
8921
8757
  payload,
8922
8758
  // delete 时是 id[],其余是 Shape[]
8923
8759
  op
8924
8760
  });
8925
- if (op === "replace" || changeDetails.length === 0) {
8926
- _rebuildIndex();
8927
- } else {
8928
- for (const detail of changeDetails) {
8929
- if (detail.type === "add") {
8930
- _indexAdd(detail.shape);
8931
- } else if (detail.type === "delete") {
8932
- _shapeMapRef.value.delete(detail.shape.id);
8933
- const parentId = detail.shape.parenShapeId;
8934
- if (parentId) {
8935
- const children = _parentChildMapRef.value.get(parentId);
8936
- if (children) {
8937
- const idx = children.indexOf(detail.shape.id);
8938
- if (idx !== -1)
8939
- children.splice(idx, 1);
8940
- if (children.length === 0) {
8941
- _parentChildMapRef.value.delete(parentId);
8942
- }
8943
- }
8944
- }
8945
- _parentChildMapRef.value.delete(detail.shape.id);
8946
- } else if (detail.type === "update") {
8947
- const oldParentId = detail.oldShape?.parenShapeId;
8948
- _indexUpdate(detail.shape, oldParentId);
8949
- }
8950
- }
8951
- _triggerIndexUpdate();
8952
- }
8953
8761
  pendingNestedIds.value = [];
8954
8762
  const shouldAutoExpand = options?.autoExpandParents !== false;
8955
8763
  if (shouldAutoExpand && changedShapes.length > 0) {
@@ -8963,10 +8771,6 @@ const useGraphStore = defineStore(
8963
8771
  };
8964
8772
  const clearAll = () => {
8965
8773
  shapes.value = [];
8966
- _shapeMapRef.value = /* @__PURE__ */ new Map();
8967
- _parentChildMapRef.value = /* @__PURE__ */ new Map();
8968
- triggerRef(_shapeMapRef);
8969
- triggerRef(_parentChildMapRef);
8970
8774
  diagrams.value = [];
8971
8775
  selectedShape.value = null;
8972
8776
  pendingNestedIds.value = [];
@@ -8979,7 +8783,12 @@ const useGraphStore = defineStore(
8979
8783
  const startDrag = (ids, pointer) => {
8980
8784
  dragSelectionSnapshot.value = selectedIds.value.length ? [...selectedIds.value] : [ids[0]];
8981
8785
  primaryDragId.value = ids[0] || null;
8982
- const validIds = ids.filter((id) => {
8786
+ const expanded = [];
8787
+ ids.forEach((id) => {
8788
+ expanded.push(id);
8789
+ collectDescendantIds(shapes.value, id).forEach((cid) => expanded.push(cid));
8790
+ });
8791
+ const validIds = Array.from(new Set(expanded)).filter((id) => {
8983
8792
  const s2 = byId(id);
8984
8793
  return s2 && getPolicy(s2).draggable;
8985
8794
  });
@@ -8994,29 +8803,6 @@ const useGraphStore = defineStore(
8994
8803
  dragGhost[k] = snap.dragBase[k];
8995
8804
  draggingIds.value = validIds;
8996
8805
  dragAnchor.value = { x: pointer.x, y: pointer.y };
8997
- const newSnapshot = /* @__PURE__ */ new Map();
8998
- for (const parentId of validIds) {
8999
- const descendants = [];
9000
- const collectDescendants = (pid) => {
9001
- const childIds = _parentChildMapRef.value.get(pid) || [];
9002
- for (const childId of childIds) {
9003
- const childShape = _shapeMapRef.value.get(childId);
9004
- if (childShape?.bounds) {
9005
- descendants.push({
9006
- id: childId,
9007
- x: childShape.bounds.x ?? 0,
9008
- y: childShape.bounds.y ?? 0,
9009
- width: childShape.bounds.width ?? 0,
9010
- height: childShape.bounds.height ?? 0
9011
- });
9012
- }
9013
- collectDescendants(childId);
9014
- }
9015
- };
9016
- collectDescendants(parentId);
9017
- newSnapshot.set(parentId, descendants);
9018
- }
9019
- dragDescendantsSnapshot.value = newSnapshot;
9020
8806
  const currentDiagram = shapes.value.find((s2) => s2.shapeType === "diagram");
9021
8807
  if (currentDiagram) {
9022
8808
  dragBaseCanvasSize.value = {
@@ -9242,7 +9028,7 @@ const useGraphStore = defineStore(
9242
9028
  );
9243
9029
  const shapeId = ownerPayload?.shapeId;
9244
9030
  if (shapeId != null) {
9245
- const child = shapes.value.find((s2) => s2.id == shapeId);
9031
+ const child = shapes.value.find((s2) => s2.id === shapeId);
9246
9032
  if (child) {
9247
9033
  expandParentByChild({
9248
9034
  shapes: shapes.value,
@@ -9319,7 +9105,6 @@ const useGraphStore = defineStore(
9319
9105
  dragSelectionSnapshot.value = [];
9320
9106
  primaryDragId.value = null;
9321
9107
  dragBaseCanvasSize.value = null;
9322
- dragDescendantsSnapshot.value = /* @__PURE__ */ new Map();
9323
9108
  for (const k in dragGhost)
9324
9109
  delete dragGhost[k];
9325
9110
  };
@@ -9438,10 +9223,6 @@ const useGraphStore = defineStore(
9438
9223
  // 图元ID索引映射 (性能优化)
9439
9224
  marqueeShapes,
9440
9225
  ghostShadow,
9441
- dragDescendantsSnapshot,
9442
- // 拖动时的后代坐标快照
9443
- dragBase,
9444
- // 拖动开始时的坐标快照
9445
9226
  scales,
9446
9227
  activeDiagramId,
9447
9228
  // 当前活动画布的缩放比例
@@ -12313,10 +12094,9 @@ let keyboardMovingShapeIds = /* @__PURE__ */ new Set();
12313
12094
  const KEYBOARD_MOVE_DEBOUNCE_DELAY = 1e3;
12314
12095
  const collectAffectedShapeIds = (graphStore, movedIds) => {
12315
12096
  const affectedIds = /* @__PURE__ */ new Set();
12316
- const shapeMap = graphStore.shapeMap;
12317
12097
  movedIds.forEach((id) => {
12318
12098
  affectedIds.add(id);
12319
- const shape = shapeMap.get(id);
12099
+ const shape = graphStore.shapes.find((s2) => s2.id === id);
12320
12100
  if (!shape)
12321
12101
  return;
12322
12102
  if (shape.parenShapeId) {
@@ -12334,7 +12114,7 @@ const collectAffectedShapeIds = (graphStore, movedIds) => {
12334
12114
  let guard = 0;
12335
12115
  while (currentParentId && guard++ < 100) {
12336
12116
  affectedIds.add(currentParentId);
12337
- const parent = shapeMap.get(currentParentId);
12117
+ const parent = graphStore.shapes.find((s2) => s2.id === currentParentId);
12338
12118
  currentParentId = parent?.parenShapeId;
12339
12119
  }
12340
12120
  });
@@ -12344,8 +12124,7 @@ const emitKeyboardMoveEnd = (graphStore) => {
12344
12124
  if (keyboardMovingShapeIds.size === 0)
12345
12125
  return;
12346
12126
  const affectedIds = collectAffectedShapeIds(graphStore, keyboardMovingShapeIds);
12347
- const shapeMap = graphStore.shapeMap;
12348
- const payloads = Array.from(affectedIds).map((id) => shapeMap.get(id)).filter(Boolean).map((s2) => _.cloneDeep(s2));
12127
+ const payloads = Array.from(affectedIds).map((id) => graphStore.shapes.find((s2) => s2.id === id)).filter(Boolean).map((s2) => _.cloneDeep(s2));
12349
12128
  if (payloads.length > 0) {
12350
12129
  eventBus.emit("shape-drag-end", payloads);
12351
12130
  }
@@ -12482,13 +12261,7 @@ const createKeyboardHandler = (config) => {
12482
12261
  }
12483
12262
  e.preventDefault();
12484
12263
  const step = 1;
12485
- let canvas = null;
12486
- for (const shape of graphStore.shapes) {
12487
- if (shape.shapeType === "diagram") {
12488
- canvas = shape;
12489
- break;
12490
- }
12491
- }
12264
+ const canvas = graphStore.shapes.find((shape) => shape.shapeType === "diagram");
12492
12265
  const canvasX = canvas?.bounds?.x || 0;
12493
12266
  const canvasY = canvas?.bounds?.y || 0;
12494
12267
  const canvasWidth = canvas?.bounds?.width || 300;
@@ -12497,13 +12270,7 @@ const createKeyboardHandler = (config) => {
12497
12270
  const canvasMinY = canvasY;
12498
12271
  const canvasMaxX = canvasWidth + canvasX;
12499
12272
  const canvasMaxY = canvasHeight + canvasY;
12500
- const shapeMap = graphStore.shapeMap;
12501
- const selectedShapes = [];
12502
- for (const id of graphStore.selectedIds) {
12503
- const shape = shapeMap.get(id);
12504
- if (shape)
12505
- selectedShapes.push(shape);
12506
- }
12273
+ const selectedShapes = graphStore.selectedIds.map((id) => graphStore.shapes.find((s2) => s2.id === id)).filter((shape) => shape != null);
12507
12274
  selectedShapes.forEach((shape) => {
12508
12275
  if (!keyboardMoveInitialBounds.has(shape.id)) {
12509
12276
  keyboardMoveInitialBounds.set(shape.id, { ...shape.bounds });
@@ -12547,7 +12314,7 @@ const createKeyboardHandler = (config) => {
12547
12314
  });
12548
12315
  const childIds = graphStore.parentChildMap.get(shape.id) || [];
12549
12316
  childIds.forEach((childId) => {
12550
- const child = shapeMap.get(childId);
12317
+ const child = graphStore.shapes.find((s2) => s2.id === childId);
12551
12318
  if (child && child.bounds) {
12552
12319
  if (graphStore.selectedIds.includes(child.id)) {
12553
12320
  return;
@@ -12997,7 +12764,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
12997
12764
  emits: InteractionLayerEmits,
12998
12765
  setup(__props, { expose: __expose, emit: __emit }) {
12999
12766
  useCssVars((_ctx) => ({
13000
- "c994dcd8": unref(graphStore).currentScale
12767
+ "65f24407": unref(graphStore).currentScale
13001
12768
  }));
13002
12769
  const props = __props;
13003
12770
  const emit = __emit;
@@ -13029,56 +12796,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
13029
12796
  const b2 = getBounds(s2);
13030
12797
  return { x: b2.x, y: b2.y, width: b2.width, height: b2.height };
13031
12798
  });
13032
- const dragGhostRects = computed(() => {
13033
- if (!graphStore.isDragging || isExternalCreateDragging.value)
13034
- return [];
13035
- const rects = [];
13036
- const dragBase = graphStore.dragBase;
13037
- const descendantsSnapshot = graphStore.dragDescendantsSnapshot;
13038
- for (const ghost of graphStore.ghostShadow) {
13039
- if (!ghost.bounds)
13040
- continue;
13041
- const baseBounds = dragBase[ghost.id];
13042
- if (!baseBounds)
13043
- continue;
13044
- const dx = (ghost.bounds.x ?? 0) - baseBounds.x;
13045
- const dy = (ghost.bounds.y ?? 0) - baseBounds.y;
13046
- rects.push({
13047
- id: ghost.id,
13048
- x: ghost.bounds.x ?? 0,
13049
- y: ghost.bounds.y ?? 0,
13050
- width: ghost.bounds.width ?? 0,
13051
- height: ghost.bounds.height ?? 0
13052
- });
13053
- const cachedDescendants = descendantsSnapshot.get(ghost.id);
13054
- if (cachedDescendants && cachedDescendants.length > 0) {
13055
- for (const desc of cachedDescendants) {
13056
- rects.push({
13057
- id: desc.id,
13058
- x: desc.x + dx,
13059
- y: desc.y + dy,
13060
- width: desc.width,
13061
- height: desc.height
13062
- });
13063
- }
13064
- }
13065
- }
13066
- return rects;
13067
- });
13068
- const resizeGhosts = computed(() => resizeGhostShadow.value);
13069
- const highlightedGhost = computed(() => {
13070
- if (!highlightedShape.value)
13071
- return null;
13072
- return {
13073
- ...highlightedShape.value,
13074
- meta: {
13075
- ...highlightedShape.value.meta,
13076
- isHighlighted: true,
13077
- isGhost: true
13078
- }
13079
- };
13080
- });
13081
- computed(() => {
12799
+ const allGhosts = computed(() => {
13082
12800
  const byId = /* @__PURE__ */ new Map();
13083
12801
  if (!isExternalCreateDragging.value) {
13084
12802
  graphStore.ghostShadow.forEach((g) => byId.set(g.id, g));
@@ -14219,19 +13937,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
14219
13937
  }, null, 4), [
14220
13938
  [vShow, marqueeRect.value]
14221
13939
  ]),
14222
- (openBlock(true), createElementBlock(Fragment, null, renderList(dragGhostRects.value, (g) => {
14223
- return openBlock(), createElementBlock("div", {
14224
- key: g.id,
14225
- class: "ghost-outline",
14226
- style: normalizeStyle({
14227
- left: g.x + "px",
14228
- top: g.y + "px",
14229
- width: g.width + "px",
14230
- height: g.height + "px"
14231
- })
14232
- }, null, 4);
14233
- }), 128)),
14234
- (openBlock(true), createElementBlock(Fragment, null, renderList(resizeGhosts.value, (g) => {
13940
+ (openBlock(true), createElementBlock(Fragment, null, renderList(allGhosts.value, (g) => {
14235
13941
  return openBlock(), createBlock(resolveDynamicComponent(unref(getShapeComponent)(g)), {
14236
13942
  key: g.id,
14237
13943
  class: "ghost-shape",
@@ -14239,12 +13945,6 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
14239
13945
  style: normalizeStyle(getGhostShapeStyle(g))
14240
13946
  }, null, 8, ["shape", "style"]);
14241
13947
  }), 128)),
14242
- highlightedGhost.value ? (openBlock(), createBlock(resolveDynamicComponent(unref(getShapeComponent)(highlightedGhost.value)), {
14243
- key: highlightedGhost.value.id,
14244
- class: "ghost-shape",
14245
- shape: highlightedGhost.value,
14246
- style: normalizeStyle(getGhostShapeStyle(highlightedGhost.value))
14247
- }, null, 8, ["shape", "style"])) : createCommentVNode("", true),
14248
13948
  createVNode(NameEditor, {
14249
13949
  "selected-shape": unref(graphStore).selectedShape,
14250
13950
  "can-edit": !unref(graphStore).pendingNestedIds.includes(
@@ -14255,7 +13955,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
14255
13955
  "name-edit-manager": unref(nameEditManager)
14256
13956
  }, null, 8, ["selected-shape", "can-edit", "is-editing-name", "editing-name", "name-edit-manager"]),
14257
13957
  unref(selectedShape) && !isMultiSelected.value ? (openBlock(), createBlock(ContextMenu, {
14258
- key: 3,
13958
+ key: 2,
14259
13959
  visible: showContextMenu.value,
14260
13960
  "selected-shape": unref(selectedShape),
14261
13961
  position: contextMenuPosition.value,
@@ -14263,7 +13963,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
14263
13963
  onShowPropertyPanel: _cache[1] || (_cache[1] = ($event) => onLayerDblClick(true))
14264
13964
  }, null, 8, ["visible", "selected-shape", "position"])) : createCommentVNode("", true),
14265
13965
  _ctx.connectShapeData && _ctx.diagramBounds ? (openBlock(), createElementBlock("div", {
14266
- key: 4,
13966
+ key: 3,
14267
13967
  class: "connect-layer",
14268
13968
  style: normalizeStyle(layerStyle.value)
14269
13969
  }, [
@@ -14283,7 +13983,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
14283
13983
  ])
14284
13984
  ], 4)) : createCommentVNode("", true),
14285
13985
  unref(highlightOverlayBounds) ? (openBlock(), createElementBlock("div", {
14286
- key: 5,
13986
+ key: 4,
14287
13987
  class: normalizeClass(["highlight-overlay", unref(highlightOverlayColor)]),
14288
13988
  style: normalizeStyle({
14289
13989
  left: unref(highlightOverlayBounds).x + "px",
@@ -14296,8 +13996,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
14296
13996
  };
14297
13997
  }
14298
13998
  });
14299
- const InteractionLayer_vue_vue_type_style_index_0_scoped_a7475c72_lang = "";
14300
- const InteractionLayer = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-a7475c72"]]);
13999
+ const InteractionLayer_vue_vue_type_style_index_0_scoped_24a22c8c_lang = "";
14000
+ const InteractionLayer = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-24a22c8c"]]);
14301
14001
  const _hoisted_1$d = { class: "diagram-header" };
14302
14002
  const _hoisted_2$d = { class: "diagram-title" };
14303
14003
  const _sfc_main$d = /* @__PURE__ */ defineComponent({
@@ -17104,7 +16804,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17104
16804
  emits: ["shapes-property", "shapes-edit-name", "connect-end", "object-flow-connect-end", "action-button-click", "diagramDoubleClick", "model-type-property-id-button-click", "action-button-add", "scale-changed"],
17105
16805
  setup(__props, { expose: __expose, emit: __emit }) {
17106
16806
  useCssVars((_ctx) => ({
17107
- "478247fa": currentScale.value
16807
+ "18ea7fc8": currentScale.value
17108
16808
  }));
17109
16809
  registerShapes({
17110
16810
  StrategicTaxonomyDiagram,
@@ -17275,7 +16975,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17275
16975
  return 0;
17276
16976
  });
17277
16977
  clearEdgeStyleCache();
17278
- graphStore.clearAll();
16978
+ graphStore.shapes = [];
17279
16979
  graphStore.updateShapes(shapes2, "replace");
17280
16980
  nextTick(() => {
17281
16981
  graphStore.initializeAllEdgeEndpoints();
@@ -17298,7 +16998,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17298
16998
  let removed = 0;
17299
16999
  for (let i = arr.length - 1; i >= 0; i--) {
17300
17000
  if ("inert" in arr[i]) {
17301
- graphStore.removeShape(arr[i].id);
17001
+ arr.splice(i, 1);
17302
17002
  removed++;
17303
17003
  }
17304
17004
  }
@@ -17484,8 +17184,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17484
17184
  };
17485
17185
  }
17486
17186
  });
17487
- const graph_vue_vue_type_style_index_0_scoped_f90f1704_lang = "";
17488
- const GraphView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f90f1704"]]);
17187
+ const graph_vue_vue_type_style_index_0_scoped_d4982c78_lang = "";
17188
+ const GraphView = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d4982c78"]]);
17489
17189
  const MxSoseGraphPlugin = {
17490
17190
  install(app, options) {
17491
17191
  const externalPinia = options?.pinia || // 优先使用显式传入的