@likec4/diagram 1.27.0 → 1.27.2

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.
Files changed (151) hide show
  1. package/bundle/index.js +2343 -6880
  2. package/dist/LikeC4Diagram.js +3 -9
  3. package/dist/LikeC4Diagram.props.d.ts +5 -3
  4. package/dist/StaticLikeC4Diagram.js +1 -1
  5. package/dist/_virtual/set.js +5 -0
  6. package/dist/_virtual/set2.js +3 -0
  7. package/dist/base/BaseXYFlow.d.ts +2 -1
  8. package/dist/base/primitives/compound/CompoundNodeContainer.d.ts +1 -1
  9. package/dist/base/primitives/compound/CompoundNodeContainer.js +1 -2
  10. package/dist/base/primitives/edge/EdgeLabel.css.js +1 -4
  11. package/dist/base/primitives/edge/EdgeLabelContainer.js +1 -1
  12. package/dist/base/primitives/edge/EdgePath.js +0 -3
  13. package/dist/base/primitives/edge/edge.css.js +2 -0
  14. package/dist/base/primitives/element/ElementActionButtons.js +5 -10
  15. package/dist/base/primitives/element/ElementNodeContainer.css.js +5 -4
  16. package/dist/base/primitives/element/ElementShape.css.js +1 -12
  17. package/dist/base/primitives/element/ElementTitle.css.js +3 -2
  18. package/dist/base/types.js +2 -2
  19. package/dist/base/updateEdges.js +1 -9
  20. package/dist/base/updateNodes.js +1 -12
  21. package/dist/bundle/LikeC4View.js +2 -2
  22. package/dist/bundle/LikeC4View.props.d.ts +7 -7
  23. package/dist/components/Link.js +1 -1
  24. package/dist/hooks/useCurrentViewId.js +8 -2
  25. package/dist/hooks/useDiagram.d.ts +2659 -1996
  26. package/dist/hooks/useDiagram.js +16 -8
  27. package/dist/likec4diagram/DiagramXYFlow.js +10 -9
  28. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +30 -41
  29. package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +1 -1
  30. package/dist/likec4diagram/custom/nodes/toolbar/styles.css.js +6 -1
  31. package/dist/likec4diagram/ui/controls/LayoutDriftNotification.js +13 -5
  32. package/dist/likec4diagram/ui/notation/NotationPanel.css.js +3 -3
  33. package/dist/likec4diagram/ui/notation/NotationPanel.js +10 -4
  34. package/dist/likec4diagram/useLayoutConstraints.d.ts +11 -10
  35. package/dist/likec4diagram/useLayoutConstraints.js +64 -61
  36. package/dist/node_modules/.pnpm/mnemonist@0.40.3_patch_hash_5c12abb43fcff6fd81e53021b89075d53249640d165a2556cc1e58d71201a13a/node_modules/mnemonist/set.js +369 -0
  37. package/dist/overlays/Overlays.js +5 -3
  38. package/dist/overlays/element-details/actor.d.ts +2769 -173
  39. package/dist/overlays/overlay/Overlay.css.d.ts +26 -2
  40. package/dist/overlays/overlay/Overlay.css.js +83 -16
  41. package/dist/overlays/overlay/Overlay.d.ts +7 -6
  42. package/dist/overlays/overlay/Overlay.js +39 -32
  43. package/dist/overlays/overlaysActor.js +2 -2
  44. package/dist/overlays/relationship-details/RelationshipDetails.js +113 -70
  45. package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
  46. package/dist/overlays/relationship-details/SelectEdge.js +15 -9
  47. package/dist/overlays/relationship-details/_types.d.ts +4 -1
  48. package/dist/overlays/relationship-details/actor.d.ts +415 -128
  49. package/dist/overlays/relationship-details/actor.js +162 -53
  50. package/dist/overlays/relationship-details/compute.d.ts +12 -0
  51. package/dist/overlays/relationship-details/compute.js +139 -0
  52. package/dist/overlays/relationship-details/custom/ElementActions.js +27 -5
  53. package/dist/overlays/relationship-details/custom/edgeTypes.js +1 -1
  54. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +2 -1
  55. package/dist/overlays/relationship-details/hooks.d.ts +336 -6
  56. package/dist/overlays/relationship-details/hooks.js +9 -7
  57. package/dist/overlays/relationship-details/layout-to-xyflow.d.ts +12 -0
  58. package/dist/overlays/relationship-details/layout-to-xyflow.js +149 -0
  59. package/dist/overlays/relationship-details/layout.d.ts +22 -0
  60. package/dist/overlays/relationship-details/layout.js +314 -0
  61. package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +3 -1
  62. package/dist/overlays/relationships-browser/RelationshipsBrowser.js +2 -2
  63. package/dist/overlays/relationships-browser/SelectElement.js +4 -4
  64. package/dist/overlays/relationships-browser/_types.d.ts +2 -0
  65. package/dist/overlays/relationships-browser/actor.d.ts +130 -14
  66. package/dist/overlays/relationships-browser/actor.js +30 -16
  67. package/dist/overlays/relationships-browser/custom/ElementActions.js +5 -3
  68. package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +3 -1
  69. package/dist/overlays/relationships-browser/custom/edgeTypes.js +1 -1
  70. package/dist/overlays/relationships-browser/hooks.d.ts +3 -1
  71. package/dist/overlays/relationships-browser/hooks.js +1 -1
  72. package/dist/overlays/relationships-browser/{-useRelationshipsView.d.ts → layout.d.ts} +2 -0
  73. package/dist/overlays/relationships-browser/{-useRelationshipsView.js → layout.js} +19 -2
  74. package/dist/overlays/relationships-browser/useViewToNodesEdges.d.ts +1 -1
  75. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +3 -1
  76. package/dist/packages/core/src/compute-view/relationships-view/compute.js +1 -1
  77. package/dist/packages/core/src/model/connection/model/ConnectionModel.js +121 -0
  78. package/dist/packages/core/src/model/connection/model/find.js +39 -0
  79. package/dist/packages/core/src/model/connection/ops.js +7 -0
  80. package/dist/packages/core/src/utils/const.js +3 -0
  81. package/dist/packages/core/src/utils/fqn.js +9 -1
  82. package/dist/packages/core/src/utils/iterable/find.js +21 -0
  83. package/dist/packages/core/src/utils/iterable/some.js +21 -0
  84. package/dist/packages/core/src/utils/set.js +48 -0
  85. package/dist/packages/core/src/utils/string-hash.js +13 -0
  86. package/dist/state/DiagramActorProvider.d.ts +4 -2
  87. package/dist/state/DiagramActorProvider.js +30 -37
  88. package/dist/state/assign.js +2 -2
  89. package/dist/state/diagram-machine.d.ts +1731 -1040
  90. package/dist/state/diagram-machine.js +126 -60
  91. package/dist/state/syncManualLayoutActor.d.ts +1 -1
  92. package/dist/styles.css.js +1 -1
  93. package/package.json +11 -11
  94. package/src/LikeC4Diagram.props.ts +7 -3
  95. package/src/LikeC4Diagram.tsx +2 -8
  96. package/src/StaticLikeC4Diagram.tsx +1 -1
  97. package/src/base/BaseXYFlow.tsx +2 -1
  98. package/src/base/primitives/compound/CompoundNodeContainer.tsx +1 -3
  99. package/src/base/primitives/edge/EdgeLabel.css.ts +1 -4
  100. package/src/base/primitives/edge/EdgeLabelContainer.tsx +1 -1
  101. package/src/base/primitives/edge/EdgePath.tsx +0 -3
  102. package/src/base/primitives/edge/edge.css.ts +2 -0
  103. package/src/base/primitives/element/ElementActionButtons.tsx +6 -7
  104. package/src/base/primitives/element/ElementNodeContainer.css.ts +5 -4
  105. package/src/base/primitives/element/ElementShape.css.ts +1 -12
  106. package/src/base/primitives/element/ElementTitle.css.ts +3 -2
  107. package/src/base/types.ts +2 -7
  108. package/src/base/updateEdges.ts +8 -8
  109. package/src/base/updateNodes.ts +11 -11
  110. package/src/bundle/LikeC4View.props.ts +7 -7
  111. package/src/bundle/LikeC4View.tsx +2 -2
  112. package/src/components/Link.tsx +3 -1
  113. package/src/hooks/useCurrentViewId.ts +4 -2
  114. package/src/hooks/useDiagram.ts +18 -9
  115. package/src/likec4diagram/DiagramXYFlow.tsx +11 -9
  116. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +39 -48
  117. package/src/likec4diagram/custom/nodes/toolbar/Toolbar.tsx +2 -2
  118. package/src/likec4diagram/custom/nodes/toolbar/styles.css.ts +5 -0
  119. package/src/likec4diagram/ui/controls/LayoutDriftNotification.tsx +8 -4
  120. package/src/likec4diagram/ui/notation/NotationPanel.css.ts +2 -2
  121. package/src/likec4diagram/ui/notation/NotationPanel.tsx +8 -6
  122. package/src/likec4diagram/useLayoutConstraints.ts +84 -89
  123. package/src/overlays/Overlays.tsx +5 -3
  124. package/src/overlays/overlay/Overlay.css.ts +83 -15
  125. package/src/overlays/overlay/Overlay.tsx +52 -41
  126. package/src/overlays/overlaysActor.ts +1 -1
  127. package/src/overlays/relationship-details/RelationshipDetails.tsx +131 -68
  128. package/src/overlays/relationship-details/SelectEdge.tsx +19 -12
  129. package/src/overlays/relationship-details/_types.ts +3 -1
  130. package/src/overlays/relationship-details/actor.ts +217 -68
  131. package/src/overlays/relationship-details/compute.ts +186 -0
  132. package/src/overlays/relationship-details/custom/ElementActions.tsx +27 -18
  133. package/src/overlays/relationship-details/custom/edgeTypes.tsx +1 -1
  134. package/src/overlays/relationship-details/hooks.ts +10 -8
  135. package/src/overlays/relationship-details/layout-to-xyflow.ts +195 -0
  136. package/src/overlays/relationship-details/layout.ts +470 -0
  137. package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +2 -2
  138. package/src/overlays/relationships-browser/SelectElement.tsx +5 -5
  139. package/src/overlays/relationships-browser/_types.ts +2 -0
  140. package/src/overlays/relationships-browser/actor.ts +39 -14
  141. package/src/overlays/relationships-browser/custom/ElementActions.tsx +5 -3
  142. package/src/overlays/relationships-browser/custom/edgeTypes.tsx +1 -1
  143. package/src/overlays/relationships-browser/hooks.ts +2 -2
  144. package/src/overlays/relationships-browser/{-useRelationshipsView.ts → layout.ts} +23 -13
  145. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +3 -1
  146. package/src/state/DiagramActorProvider.tsx +40 -50
  147. package/src/state/assign.ts +2 -2
  148. package/src/state/diagram-machine.ts +151 -75
  149. package/dist/overlays/relationship-details/useLayoutedDetails.d.ts +0 -19
  150. package/dist/overlays/relationship-details/useLayoutedDetails.js +0 -267
  151. package/src/overlays/relationship-details/useLayoutedDetails.ts +0 -376
@@ -0,0 +1,121 @@
1
+ import { isNot } from 'remeda';
2
+ import { invariant } from '../../../errors/index.js';
3
+ import { customInspectSymbol } from '../../../utils/const.js';
4
+ import { union, difference, intersection, equals } from '../../../utils/set.js';
5
+ import { stringHash } from '../../../utils/string-hash.js';
6
+ import { hasSameSourceTarget } from '../ops.js';
7
+ import { findConnection } from './find.js';
8
+ import { isome } from '../../../utils/iterable/some.js';
9
+ import { ifilter } from '../../../utils/iterable/filter.js';
10
+
11
+ class ConnectionModel {
12
+ constructor(source, target, relations = /* @__PURE__ */ new Set()) {
13
+ this.source = source;
14
+ this.target = target;
15
+ this.relations = relations;
16
+ this.id = stringHash(`model:${source.id}:${target.id}`);
17
+ }
18
+ id;
19
+ _boundary;
20
+ /**
21
+ * Common ancestor of the source and target elements.
22
+ * Represents the boundary of the connection.
23
+ */
24
+ get boundary() {
25
+ return this._boundary ??= this.source.commonAncestor(this.target);
26
+ }
27
+ /**
28
+ * Human readable expression of the connection
29
+ * Mostly used for testing and debugging
30
+ */
31
+ get expression() {
32
+ return `${this.source.id} -> ${this.target.id}`;
33
+ }
34
+ /**
35
+ * Returns true if only includes relations between the source and target elements.
36
+ */
37
+ get isDirect() {
38
+ return this.nonEmpty() && !this.isImplicit;
39
+ }
40
+ /**
41
+ * Returns true if includes relations between nested elements of the source and target elements.
42
+ */
43
+ get isImplicit() {
44
+ return this.nonEmpty() && isome(this.relations, isNot(hasSameSourceTarget(this)));
45
+ }
46
+ get directRelations() {
47
+ return new Set(ifilter(this.relations, hasSameSourceTarget(this)));
48
+ }
49
+ nonEmpty() {
50
+ return this.relations.size > 0;
51
+ }
52
+ mergeWith(other) {
53
+ invariant(this.source.id === other.source.id, "Cannot merge connections with different sources");
54
+ invariant(this.target.id === other.target.id, "Cannot merge connections with different targets");
55
+ return new ConnectionModel(
56
+ this.source,
57
+ this.target,
58
+ union(this.relations, other.relations)
59
+ );
60
+ }
61
+ difference(other) {
62
+ return new ConnectionModel(
63
+ this.source,
64
+ this.target,
65
+ difference(this.relations, other.relations)
66
+ );
67
+ }
68
+ intersect(other) {
69
+ invariant(other instanceof ConnectionModel, "Cannot intersect connection with different type");
70
+ return new ConnectionModel(
71
+ this.source,
72
+ this.target,
73
+ intersection(this.relations, other.relations)
74
+ );
75
+ }
76
+ equals(other) {
77
+ invariant(other instanceof ConnectionModel, "Cannot merge connection with different type");
78
+ return this.id === other.id && this.source.id === other.source.id && this.target.id === other.target.id && equals(this.relations, other.relations);
79
+ }
80
+ /**
81
+ * Returns a new instance with the updated relations.
82
+ *
83
+ * @param relations - A readonly set of `RelationshipModel` instances representing the new relations.
84
+ * @returns A new `ConnectionModel` instance with the updated relations.
85
+ */
86
+ update(relations) {
87
+ return new ConnectionModel(
88
+ this.source,
89
+ this.target,
90
+ relations
91
+ );
92
+ }
93
+ [customInspectSymbol](depth, inspectOptions, inspect) {
94
+ const asString = this.toString();
95
+ Object.defineProperty(asString, "constructor", {
96
+ value: ConnectionModel,
97
+ enumerable: false
98
+ });
99
+ return asString;
100
+ }
101
+ toString() {
102
+ return [
103
+ this.expression,
104
+ this.relations.size ? " relations:" : " relations: [ ]",
105
+ ...[...this.relations].map((c) => " " + c.expression)
106
+ ].join("\n");
107
+ }
108
+ /**
109
+ * Creates a new connection with reversed direction (target becomes source and vice versa)
110
+ * @param search - When true, attempts to find an existing connection between the reversed nodes
111
+ */
112
+ reversed(search = false) {
113
+ if (!search) {
114
+ return new ConnectionModel(this.target, this.source);
115
+ }
116
+ const [found] = findConnection(this.target, this.source, "directed");
117
+ return found ?? new ConnectionModel(this.target, this.source, /* @__PURE__ */ new Set());
118
+ }
119
+ }
120
+
121
+ export { ConnectionModel };
@@ -0,0 +1,39 @@
1
+ import { isSameHierarchy } from '../../../utils/fqn.js';
2
+ import { intersection } from '../../../utils/set.js';
3
+ import { ConnectionModel } from './ConnectionModel.js';
4
+
5
+ function findConnection(source, target, direction = "directed") {
6
+ if (source === target) {
7
+ return [];
8
+ }
9
+ if (isSameHierarchy(source, target)) {
10
+ return [];
11
+ }
12
+ const directedIntersection = intersection(source.allOutgoing, target.allIncoming);
13
+ const directed = directedIntersection.size > 0 ? new ConnectionModel(
14
+ source,
15
+ target,
16
+ directedIntersection
17
+ ) : null;
18
+ if (direction === "directed") {
19
+ return directed ? [directed] : [];
20
+ }
21
+ const reverseIntersection = intersection(source.allIncoming, target.allOutgoing);
22
+ const reverse = reverseIntersection.size > 0 ? new ConnectionModel(
23
+ target,
24
+ source,
25
+ reverseIntersection
26
+ ) : null;
27
+ if (directed && reverse) {
28
+ return [directed, reverse];
29
+ }
30
+ if (directed) {
31
+ return [directed];
32
+ }
33
+ if (reverse) {
34
+ return [reverse];
35
+ }
36
+ return [];
37
+ }
38
+
39
+ export { findConnection };
@@ -0,0 +1,7 @@
1
+ import 'remeda';
2
+
3
+ function hasSameSourceTarget(a, b) {
4
+ return (b2) => a.source === b2.source && a.target === b2.target;
5
+ }
6
+
7
+ export { hasSameSourceTarget };
@@ -0,0 +1,3 @@
1
+ const customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
2
+
3
+ export { customInspectSymbol };
@@ -12,6 +12,14 @@ function isAncestor(arg1, arg2) {
12
12
  return arg1Id.startsWith(ancestorId + ".");
13
13
  };
14
14
  }
15
+ function isSameHierarchy(one, another) {
16
+ if (!another) {
17
+ return (b) => isSameHierarchy(one, b);
18
+ }
19
+ const first = asString(one);
20
+ const second = asString(another);
21
+ return first === second || second.startsWith(first + ".") || first.startsWith(second + ".");
22
+ }
15
23
  function isDescendantOf(descedant, ancestor) {
16
24
  {
17
25
  return (d) => isAncestor(descedant, d);
@@ -40,4 +48,4 @@ function sortParentsFirst(array) {
40
48
  return result;
41
49
  }
42
50
 
43
- export { isAncestor, isDescendantOf, sortParentsFirst };
51
+ export { isAncestor, isDescendantOf, isSameHierarchy, sortParentsFirst };
@@ -0,0 +1,21 @@
1
+ import { isFunction } from 'remeda';
2
+ import { invariant } from '../../errors/index.js';
3
+
4
+ function ifind(arg1, arg2) {
5
+ const pred = arg2 ?? arg1;
6
+ invariant(isFunction(pred));
7
+ function _find(iter) {
8
+ for (const value of iter) {
9
+ if (pred(value)) {
10
+ return value;
11
+ }
12
+ }
13
+ return;
14
+ }
15
+ if (!arg2) {
16
+ return _find;
17
+ }
18
+ return _find(arg1);
19
+ }
20
+
21
+ export { ifind };
@@ -0,0 +1,21 @@
1
+ import { isFunction } from 'remeda';
2
+ import { invariant } from '../../errors/index.js';
3
+
4
+ function isome(arg1, arg2) {
5
+ const pred = arg2 ?? arg1;
6
+ invariant(isFunction(pred));
7
+ function _some(iter) {
8
+ for (const value of iter) {
9
+ if (pred(value)) {
10
+ return true;
11
+ }
12
+ }
13
+ return false;
14
+ }
15
+ if (!arg2) {
16
+ return _some;
17
+ }
18
+ return _some(arg1);
19
+ }
20
+
21
+ export { isome };
@@ -0,0 +1,48 @@
1
+ import { hasAtLeast } from 'remeda';
2
+ import { s as setExports } from '../../../../_virtual/set.js';
3
+
4
+ function union(...sets) {
5
+ let result = /* @__PURE__ */ new Set();
6
+ for (const set of sets) {
7
+ for (const value of set) {
8
+ result.add(value);
9
+ }
10
+ }
11
+ return result;
12
+ }
13
+ function intersection(first, ...sets) {
14
+ let result = /* @__PURE__ */ new Set();
15
+ if (first.size === 0) {
16
+ return result;
17
+ }
18
+ let other = hasAtLeast(sets, 2) ? setExports.intersection(...sets) : sets[0];
19
+ if (other.size === 0) {
20
+ return result;
21
+ }
22
+ for (const value of first) {
23
+ if (other.has(value)) {
24
+ result.add(value);
25
+ }
26
+ }
27
+ return result;
28
+ }
29
+ function difference(a, b) {
30
+ if (a.size === 0) {
31
+ return /* @__PURE__ */ new Set();
32
+ }
33
+ if (b.size === 0) {
34
+ return new Set(a);
35
+ }
36
+ let result = /* @__PURE__ */ new Set();
37
+ for (const value of a) {
38
+ if (!b.has(value)) {
39
+ result.add(value);
40
+ }
41
+ }
42
+ return result;
43
+ }
44
+ function equals(a, b) {
45
+ return a.size === b.size && [...a].every((value) => b.has(value));
46
+ }
47
+
48
+ export { difference, equals, intersection, union };
@@ -0,0 +1,13 @@
1
+ import { invariant } from '../errors/index.js';
2
+
3
+ function stringHash(str) {
4
+ let hash = 5381;
5
+ const len = str.length;
6
+ invariant(len > 0, "stringHash: empty string");
7
+ for (let i = 0; i < len; i++) {
8
+ hash = hash * 33 ^ str.charCodeAt(i);
9
+ }
10
+ return (hash >>> 0).toString(36);
11
+ }
12
+
13
+ export { stringHash };
@@ -1,7 +1,9 @@
1
+ import { WhereOperator } from '@likec4/core';
1
2
  import { PropsWithChildren } from 'react';
2
3
  import { Input } from './diagram-machine';
3
- type ActorContextInput = Omit<Input, 'xystore' | 'features'>;
4
- export declare function DiagramActorProvider({ input, children }: PropsWithChildren<{
4
+ type ActorContextInput = Omit<Input, 'xystore' | 'xynodes' | 'xyedges'>;
5
+ export declare function DiagramActorProvider({ input: { view, ...inputs }, where, children, }: PropsWithChildren<{
5
6
  input: ActorContextInput;
7
+ where?: WhereOperator<string, string> | undefined;
6
8
  }>): import("react/jsx-runtime").JSX.Element;
7
9
  export {};
@@ -1,20 +1,30 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useDeepCompareEffect } from '@react-hookz/web';
2
3
  import { useActorRef, useSelector } from '@xstate/react';
3
4
  import { useStoreApi } from '@xyflow/react';
4
5
  import { shallowEqual } from 'fast-equals';
5
- import { useMemo, useEffect, useRef } from 'react';
6
+ import { useEffect } from 'react';
6
7
  import { useDiagramEventHandlersRef } from '../context/DiagramEventHandlers.js';
7
8
  import { useEnabledFeatures, DiagramFeatures } from '../context/DiagramFeatures.js';
8
9
  import { DiagramActorSafeContext } from '../hooks/safeContext.js';
9
10
  import { useUpdateEffect } from '../hooks/useUpdateEffect.js';
11
+ import { useViewToNodesEdges } from '../likec4diagram/useViewToNodesEdges.js';
10
12
  import { diagramMachine } from './diagram-machine.js';
11
13
  import { syncManualLayoutActorLogic } from './syncManualLayoutActor.js';
12
14
 
13
- function DiagramActorProvider({ input, children }) {
15
+ const selectToggledFeatures = (state) => state.context.toggledFeatures;
16
+ function DiagramActorProvider({
17
+ input: {
18
+ view,
19
+ ...inputs
20
+ },
21
+ where,
22
+ children
23
+ }) {
14
24
  const handlersRef = useDiagramEventHandlersRef();
15
25
  const xystore = useStoreApi();
16
- const logic = useMemo(() => {
17
- return diagramMachine.provide({
26
+ const actorRef = useActorRef(
27
+ diagramMachine.provide({
18
28
  actions: {
19
29
  "trigger:NavigateTo": (_, { viewId }) => {
20
30
  handlersRef.current.onNavigateTo?.(viewId);
@@ -35,52 +45,35 @@ function DiagramActorProvider({ input, children }) {
35
45
  }
36
46
  })
37
47
  }
38
- });
39
- }, [handlersRef]);
40
- const actorRef = useActorRef(
41
- logic,
48
+ }),
42
49
  {
43
- id: `diagram:${input.view.id}`,
50
+ id: `diagram:${view.id}`,
44
51
  systemId: "diagram",
45
52
  // ...inspector,
46
53
  input: {
47
54
  xystore,
48
- ...input
55
+ view,
56
+ ...inputs
49
57
  }
50
58
  }
51
59
  );
52
- return /* @__PURE__ */ jsxs(DiagramActorSafeContext, { value: actorRef, children: [
53
- /* @__PURE__ */ jsx(SyncStore, { input, actorRef }),
54
- /* @__PURE__ */ jsx(DiagramActorToggledFeatures, { actorRef, children })
55
- ] });
56
- }
57
- const SyncStore = ({ input: { view, xyedges, xynodes, ...inputs }, actorRef }) => {
58
60
  const features = useEnabledFeatures();
59
61
  useUpdateEffect(() => {
60
62
  actorRef.send({ type: "update.inputs", inputs });
61
- }, [actorRef, inputs]);
63
+ }, [inputs]);
62
64
  useEffect(() => {
63
65
  actorRef.send({ type: "update.features", features });
64
- }, [actorRef, features]);
65
- const frameReq = useRef(null);
66
- useUpdateEffect(() => {
67
- frameReq.current = requestAnimationFrame(() => {
68
- frameReq.current = null;
69
- actorRef.send({ type: "update.view", view, xyedges, xynodes });
70
- });
71
- return () => {
72
- if (frameReq.current != null) {
73
- cancelAnimationFrame(frameReq.current);
74
- }
75
- frameReq.current = null;
76
- };
77
- }, [actorRef, view, xyedges, xynodes]);
78
- return null;
79
- };
80
- const selectToggledFeatures = (state) => state.context.toggledFeatures;
81
- function DiagramActorToggledFeatures({ children, actorRef }) {
66
+ }, [features]);
67
+ const { xyedges, xynodes } = useViewToNodesEdges({
68
+ view,
69
+ where,
70
+ nodesSelectable: inputs.nodesSelectable
71
+ });
72
+ useDeepCompareEffect(() => {
73
+ actorRef.send({ type: "update.view", view, xyedges, xynodes });
74
+ }, [view, xyedges, xynodes]);
82
75
  const toggledFeatures = useSelector(actorRef, selectToggledFeatures, shallowEqual);
83
- return /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children });
76
+ return /* @__PURE__ */ jsx(DiagramActorSafeContext, { value: actorRef, children: /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children }) });
84
77
  }
85
78
 
86
79
  export { DiagramActorProvider };
@@ -338,8 +338,8 @@ function updateActiveWalkthrough({ context }) {
338
338
  });
339
339
  }),
340
340
  xynodes: context.xynodes.map((node) => {
341
- const active = step.source === node.id || step.target === node.id;
342
- return Base.setDimmed(node, !active);
341
+ const dimmed = step.source !== node.id && step.target !== node.id;
342
+ return Base.setDimmed(node, dimmed);
343
343
  })
344
344
  };
345
345
  }