likec4 1.55.0 → 1.55.1

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.
@@ -20790,11 +20790,13 @@ function getPoints({ source, sourcePosition = Position.Bottom, target, targetPos
20790
20790
  const sourceGapPoint = { x: sourceGapped.x + sourceGapOffset.x, y: sourceGapped.y + sourceGapOffset.y }, targetGapPoint = { x: targetGapped.x + targetGapOffset.x, y: targetGapped.y + targetGapOffset.y }, maxXDistance = Math.max(Math.abs(sourceGapPoint.x - points[0].x), Math.abs(targetGapPoint.x - points[0].x)), maxYDistance = Math.max(Math.abs(sourceGapPoint.y - points[0].y), Math.abs(targetGapPoint.y - points[0].y));
20791
20791
  maxXDistance >= maxYDistance ? (centerX = (sourceGapPoint.x + targetGapPoint.x) / 2, centerY = points[0].y) : (centerX = points[0].x, centerY = (sourceGapPoint.y + targetGapPoint.y) / 2);
20792
20792
  }
20793
+ const gappedSource = { x: sourceGapped.x + sourceGapOffset.x, y: sourceGapped.y + sourceGapOffset.y }, gappedTarget = { x: targetGapped.x + targetGapOffset.x, y: targetGapped.y + targetGapOffset.y };
20793
20794
  return [[
20794
20795
  source,
20795
- { x: sourceGapped.x + sourceGapOffset.x, y: sourceGapped.y + sourceGapOffset.y },
20796
+ // we only want to add the gapped source/target if they are different from the first/last point to avoid duplicates which can cause issues with the bends
20797
+ ...gappedSource.x !== points[0].x || gappedSource.y !== points[0].y ? [gappedSource] : [],
20796
20798
  ...points,
20797
- { x: targetGapped.x + targetGapOffset.x, y: targetGapped.y + targetGapOffset.y },
20799
+ ...gappedTarget.x !== points[points.length - 1].x || gappedTarget.y !== points[points.length - 1].y ? [gappedTarget] : [],
20798
20800
  target
20799
20801
  ], centerX, centerY, defaultOffsetX, defaultOffsetY];
20800
20802
  }
@@ -20819,10 +20821,10 @@ function getSmoothStepPath({ sourceX, sourceY, sourcePosition = Position.Bottom,
20819
20821
  offset: offset2,
20820
20822
  stepPosition
20821
20823
  });
20822
- return [points.reduce((res, p, i2) => {
20823
- let segment = "";
20824
- return i2 > 0 && i2 < points.length - 1 ? segment = getBend(points[i2 - 1], p, points[i2 + 1], borderRadius) : segment = `${i2 === 0 ? "M" : "L"}${p.x} ${p.y}`, res += segment, res;
20825
- }, ""), labelX, labelY, offsetX, offsetY];
20824
+ let path = `M${points[0].x} ${points[0].y}`;
20825
+ for (let i2 = 1; i2 < points.length - 1; i2++)
20826
+ path += getBend(points[i2 - 1], points[i2], points[i2 + 1], borderRadius);
20827
+ return path += `L${points[points.length - 1].x} ${points[points.length - 1].y}`, [path, labelX, labelY, offsetX, offsetY];
20826
20828
  }
20827
20829
  function isNodeInitialized(node) {
20828
20830
  return node && !!(node.internals.handleBounds || node.handles?.length) && !!(node.measured.width || node.width || node.initialWidth);
@@ -20972,7 +20974,7 @@ function isManualZIndexMode(zIndexMode) {
20972
20974
  }
20973
20975
  function adoptUserNodes(nodes, nodeLookup, parentLookup, options = {}) {
20974
20976
  const _options = mergeObjects(adoptUserNodesDefaultOptions, options), rootParentIndex = { i: 0 }, tmpLookup = new Map(nodeLookup), selectedNodeZ = _options?.elevateNodesOnSelect && !isManualZIndexMode(_options.zIndexMode) ? SELECTED_NODE_Z : 0;
20975
- let nodesInitialized = nodes.length > 0;
20977
+ let nodesInitialized = nodes.length > 0, hasSelectedNodes = !1;
20976
20978
  nodeLookup.clear(), parentLookup.clear();
20977
20979
  for (const userNode of nodes) {
20978
20980
  let internalNode = tmpLookup.get(userNode.id);
@@ -20996,9 +20998,9 @@ function adoptUserNodes(nodes, nodeLookup, parentLookup, options = {}) {
20996
20998
  }
20997
20999
  }, nodeLookup.set(userNode.id, internalNode);
20998
21000
  }
20999
- (internalNode.measured === void 0 || internalNode.measured.width === void 0 || internalNode.measured.height === void 0) && !internalNode.hidden && (nodesInitialized = !1), userNode.parentId && updateChildNode(internalNode, nodeLookup, parentLookup, options, rootParentIndex);
21001
+ (internalNode.measured === void 0 || internalNode.measured.width === void 0 || internalNode.measured.height === void 0) && !internalNode.hidden && (nodesInitialized = !1), userNode.parentId && updateChildNode(internalNode, nodeLookup, parentLookup, options, rootParentIndex), hasSelectedNodes ||= userNode.selected ?? !1;
21000
21002
  }
21001
- return nodesInitialized;
21003
+ return { nodesInitialized, hasSelectedNodes };
21002
21004
  }
21003
21005
  function updateParentLookup(node, parentLookup) {
21004
21006
  if (!node.parentId)
@@ -21635,7 +21637,7 @@ function createPanZoomEndHandler({ zoomPanValues, panOnDrag, panOnScroll, onDrag
21635
21637
  () => {
21636
21638
  onPanZoomEnd?.(event.sourceEvent, viewport);
21637
21639
  },
21638
- // we need a setTimeout for panOnScroll to supress multiple end events fired during scroll
21640
+ // we need a setTimeout for panOnScroll to suppress multiple end events fired during scroll
21639
21641
  panOnScroll ? 150 : 0
21640
21642
  );
21641
21643
  }
@@ -22119,7 +22121,7 @@ function SelectionListener({ onSelectionChange }) {
22119
22121
  const storeHasSelectionChangeHandlers = useStore$1(changeSelector);
22120
22122
  return onSelectionChange || storeHasSelectionChangeHandlers ? jsx(SelectionListenerInner, { onSelectionChange }) : null;
22121
22123
  }
22122
- const defaultNodeOrigin = [0, 0], defaultViewport = { x: 0, y: 0, zoom: 1 }, reactFlowFieldsToTrack = [
22124
+ const useIsomorphicLayoutEffect$1 = typeof window < "u" ? useLayoutEffect$1 : useEffect, defaultNodeOrigin = [0, 0], defaultViewport = { x: 0, y: 0, zoom: 1 }, reactFlowFieldsToTrack = [
22123
22125
  "nodes",
22124
22126
  "edges",
22125
22127
  "defaultNodes",
@@ -22203,11 +22205,11 @@ const defaultNodeOrigin = [0, 0], defaultViewport = { x: 0, y: 0, zoom: 1 }, rea
22203
22205
  };
22204
22206
  function StoreUpdater(props) {
22205
22207
  const { setNodes, setEdges, setMinZoom, setMaxZoom, setTranslateExtent, setNodeExtent, reset, setDefaultNodesAndEdges } = useStore$1(selector$l, shallow$1), store = useStoreApi();
22206
- useEffect(() => (setDefaultNodesAndEdges(props.defaultNodes, props.defaultEdges), () => {
22208
+ useIsomorphicLayoutEffect$1(() => (setDefaultNodesAndEdges(props.defaultNodes, props.defaultEdges), () => {
22207
22209
  previousFields.current = initPrevValues, reset();
22208
22210
  }), []);
22209
22211
  const previousFields = useRef(initPrevValues);
22210
- return useEffect(
22212
+ return useIsomorphicLayoutEffect$1(
22211
22213
  () => {
22212
22214
  for (const fieldName of fieldsToTrack) {
22213
22215
  const fieldValue = props[fieldName], previousFieldValue = previousFields.current[fieldName];
@@ -22283,15 +22285,15 @@ const useViewportHelper = () => {
22283
22285
  return useMemo(() => ({
22284
22286
  zoomIn: (options) => {
22285
22287
  const { panZoom } = store.getState();
22286
- return panZoom ? panZoom.scaleBy(1.2, { duration: options?.duration }) : Promise.resolve(!1);
22288
+ return panZoom ? panZoom.scaleBy(1.2, options) : Promise.resolve(!1);
22287
22289
  },
22288
22290
  zoomOut: (options) => {
22289
22291
  const { panZoom } = store.getState();
22290
- return panZoom ? panZoom.scaleBy(1 / 1.2, { duration: options?.duration }) : Promise.resolve(!1);
22292
+ return panZoom ? panZoom.scaleBy(1 / 1.2, options) : Promise.resolve(!1);
22291
22293
  },
22292
22294
  zoomTo: (zoomLevel, options) => {
22293
22295
  const { panZoom } = store.getState();
22294
- return panZoom ? panZoom.scaleTo(zoomLevel, { duration: options?.duration }) : Promise.resolve(!1);
22296
+ return panZoom ? panZoom.scaleTo(zoomLevel, options) : Promise.resolve(!1);
22295
22297
  },
22296
22298
  getZoom: () => store.getState().transform[2],
22297
22299
  setViewport: async (viewport, options) => {
@@ -22429,7 +22431,6 @@ const isNode$1 = (element) => isNodeBase(element), isEdge = (element) => isEdgeB
22429
22431
  function fixedForwardRef(render) {
22430
22432
  return forwardRef(render);
22431
22433
  }
22432
- const useIsomorphicLayoutEffect$1 = typeof window < "u" ? useLayoutEffect$1 : useEffect;
22433
22434
  function useQueue(runQueue) {
22434
22435
  const [serial, setSerial] = useState(BigInt(0)), [queue] = useState(() => createQueue(() => setSerial((n2) => n2 + BigInt(1))));
22435
22436
  return useIsomorphicLayoutEffect$1(() => {
@@ -23674,7 +23675,7 @@ GraphViewComponent.displayName = "GraphView";
23674
23675
  const GraphView = memo$2(GraphViewComponent), getInitialState = ({ nodes, edges, defaultNodes, defaultEdges, width, height, fitView, fitViewOptions, minZoom = 0.5, maxZoom = 2, nodeOrigin, nodeExtent, zIndexMode = "basic" } = {}) => {
23675
23676
  const nodeLookup = /* @__PURE__ */ new Map(), parentLookup = /* @__PURE__ */ new Map(), connectionLookup = /* @__PURE__ */ new Map(), edgeLookup = /* @__PURE__ */ new Map(), storeEdges = defaultEdges ?? edges ?? [], storeNodes = defaultNodes ?? nodes ?? [], storeNodeOrigin = nodeOrigin ?? [0, 0], storeNodeExtent = nodeExtent ?? infiniteExtent;
23676
23677
  updateConnectionLookup(connectionLookup, edgeLookup, storeEdges);
23677
- const nodesInitialized = adoptUserNodes(storeNodes, nodeLookup, parentLookup, {
23678
+ const { nodesInitialized } = adoptUserNodes(storeNodes, nodeLookup, parentLookup, {
23678
23679
  nodeOrigin: storeNodeOrigin,
23679
23680
  nodeExtent: storeNodeExtent,
23680
23681
  zIndexMode
@@ -23780,14 +23781,20 @@ const GraphView = memo$2(GraphViewComponent), getInitialState = ({ nodes, edges,
23780
23781
  zIndexMode
23781
23782
  }),
23782
23783
  setNodes: (nodes2) => {
23783
- const { nodeLookup, parentLookup, nodeOrigin: nodeOrigin2, elevateNodesOnSelect, fitViewQueued, zIndexMode: zIndexMode2 } = get2(), nodesInitialized = adoptUserNodes(nodes2, nodeLookup, parentLookup, {
23784
+ const { nodeLookup, parentLookup, nodeOrigin: nodeOrigin2, elevateNodesOnSelect, fitViewQueued, zIndexMode: zIndexMode2, nodesSelectionActive } = get2(), { nodesInitialized, hasSelectedNodes } = adoptUserNodes(nodes2, nodeLookup, parentLookup, {
23784
23785
  nodeOrigin: nodeOrigin2,
23785
23786
  nodeExtent,
23786
23787
  elevateNodesOnSelect,
23787
23788
  checkEquality: !0,
23788
23789
  zIndexMode: zIndexMode2
23789
- });
23790
- fitViewQueued && nodesInitialized ? (resolveFitView(), set2({ nodes: nodes2, nodesInitialized, fitViewQueued: !1, fitViewOptions: void 0 })) : set2({ nodes: nodes2, nodesInitialized });
23790
+ }), nextNodesSelectionActive = nodesSelectionActive && hasSelectedNodes;
23791
+ fitViewQueued && nodesInitialized ? (resolveFitView(), set2({
23792
+ nodes: nodes2,
23793
+ nodesInitialized,
23794
+ fitViewQueued: !1,
23795
+ fitViewOptions: void 0,
23796
+ nodesSelectionActive: nextNodesSelectionActive
23797
+ })) : set2({ nodes: nodes2, nodesInitialized, nodesSelectionActive: nextNodesSelectionActive });
23791
23798
  },
23792
23799
  setEdges: (edges2) => {
23793
23800
  const { connectionLookup, edgeLookup } = get2();
@@ -23804,7 +23811,7 @@ const GraphView = memo$2(GraphViewComponent), getInitialState = ({ nodes, edges,
23804
23811
  }
23805
23812
  },
23806
23813
  /*
23807
- * Every node gets registerd at a ResizeObserver. Whenever a node
23814
+ * Every node gets registered at a ResizeObserver. Whenever a node
23808
23815
  * changes its dimensions, this function is called to measure the
23809
23816
  * new dimensions and update the nodes.
23810
23817
  */
@@ -23985,7 +23992,7 @@ function ReactFlow({ nodes, edges, defaultNodes, defaultEdges, className, nodeTy
23985
23992
  const rfId = id2 || "1", colorModeClassName = useColorModeClass(colorMode), wrapperOnScroll = useCallback((e2) => {
23986
23993
  e2.currentTarget.scrollTo({ top: 0, left: 0, behavior: "instant" }), onScroll?.(e2);
23987
23994
  }, [onScroll]);
23988
- return jsx("div", { "data-testid": "rf__wrapper", ...rest, onScroll: wrapperOnScroll, style: { ...style2, ...wrapperStyle }, ref, className: cc(["react-flow", className, colorModeClassName]), id: id2, role: "application", children: jsxs(Wrapper, { nodes, edges, width, height, fitView, fitViewOptions, minZoom, maxZoom, nodeOrigin, nodeExtent, zIndexMode, children: [jsx(GraphView, { onInit, onNodeClick, onEdgeClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onNodeDoubleClick, nodeTypes, edgeTypes, connectionLineType, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, selectionKeyCode, selectionOnDrag, selectionMode, deleteKeyCode, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, onlyRenderVisibleElements, defaultViewport: defaultViewport$1, translateExtent, minZoom, maxZoom, preventScrolling, zoomOnScroll, zoomOnPinch, zoomOnDoubleClick, panOnScroll, panOnScrollSpeed, panOnScrollMode, panOnDrag, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance, nodeClickDistance, onSelectionContextMenu, onSelectionStart, onSelectionEnd, onReconnect, onReconnectStart, onReconnectEnd, onEdgeContextMenu, onEdgeDoubleClick, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, defaultMarkerColor, noDragClassName, noWheelClassName, noPanClassName, rfId, disableKeyboardA11y, nodeExtent, viewport, onViewportChange }), jsx(StoreUpdater, { nodes, edges, defaultNodes, defaultEdges, onConnect, onConnectStart, onConnectEnd, onClickConnectStart, onClickConnectEnd, nodesDraggable, autoPanOnNodeFocus, nodesConnectable, nodesFocusable, edgesFocusable, edgesReconnectable, elementsSelectable, elevateNodesOnSelect, elevateEdgesOnSelect, minZoom, maxZoom, nodeExtent, onNodesChange, onEdgesChange, snapToGrid, snapGrid, connectionMode, translateExtent, connectOnClick, defaultEdgeOptions, fitView, fitViewOptions, onNodesDelete, onEdgesDelete, onDelete, onNodeDragStart, onNodeDrag, onNodeDragStop, onSelectionDrag, onSelectionDragStart, onSelectionDragStop, onMove, onMoveStart, onMoveEnd, noPanClassName, nodeOrigin, rfId, autoPanOnConnect, autoPanOnNodeDrag, autoPanSpeed, onError, connectionRadius, isValidConnection, selectNodesOnDrag, nodeDragThreshold, connectionDragThreshold, onBeforeDelete, debug: debug2, ariaLabelConfig, zIndexMode }), jsx(SelectionListener, { onSelectionChange }), children2, jsx(Attribution, { proOptions, position: attributionPosition }), jsx(A11yDescriptions, { rfId, disableKeyboardA11y })] }) });
23995
+ return jsx("div", { "data-testid": "rf__wrapper", ...rest, onScroll: wrapperOnScroll, style: { ...style2, ...wrapperStyle }, ref, className: cc(["react-flow", className, colorModeClassName]), id: id2, role: "application", children: jsxs(Wrapper, { nodes, edges, width, height, fitView, fitViewOptions, minZoom, maxZoom, nodeOrigin, nodeExtent, zIndexMode, children: [jsx(StoreUpdater, { nodes, edges, defaultNodes, defaultEdges, onConnect, onConnectStart, onConnectEnd, onClickConnectStart, onClickConnectEnd, nodesDraggable, autoPanOnNodeFocus, nodesConnectable, nodesFocusable, edgesFocusable, edgesReconnectable, elementsSelectable, elevateNodesOnSelect, elevateEdgesOnSelect, minZoom, maxZoom, nodeExtent, onNodesChange, onEdgesChange, snapToGrid, snapGrid, connectionMode, translateExtent, connectOnClick, defaultEdgeOptions, fitView, fitViewOptions, onNodesDelete, onEdgesDelete, onDelete, onNodeDragStart, onNodeDrag, onNodeDragStop, onSelectionDrag, onSelectionDragStart, onSelectionDragStop, onMove, onMoveStart, onMoveEnd, noPanClassName, nodeOrigin, rfId, autoPanOnConnect, autoPanOnNodeDrag, autoPanSpeed, onError, connectionRadius, isValidConnection, selectNodesOnDrag, nodeDragThreshold, connectionDragThreshold, onBeforeDelete, debug: debug2, ariaLabelConfig, zIndexMode }), jsx(GraphView, { onInit, onNodeClick, onEdgeClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onNodeDoubleClick, nodeTypes, edgeTypes, connectionLineType, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, selectionKeyCode, selectionOnDrag, selectionMode, deleteKeyCode, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, onlyRenderVisibleElements, defaultViewport: defaultViewport$1, translateExtent, minZoom, maxZoom, preventScrolling, zoomOnScroll, zoomOnPinch, zoomOnDoubleClick, panOnScroll, panOnScrollSpeed, panOnScrollMode, panOnDrag, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance, nodeClickDistance, onSelectionContextMenu, onSelectionStart, onSelectionEnd, onReconnect, onReconnectStart, onReconnectEnd, onEdgeContextMenu, onEdgeDoubleClick, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, defaultMarkerColor, noDragClassName, noWheelClassName, noPanClassName, rfId, disableKeyboardA11y, nodeExtent, viewport, onViewportChange }), jsx(SelectionListener, { onSelectionChange }), children2, jsx(Attribution, { proOptions, position: attributionPosition }), jsx(A11yDescriptions, { rfId, disableKeyboardA11y })] }) });
23989
23996
  }
23990
23997
  var index$2 = fixedForwardRef(ReactFlow);
23991
23998
  const selector$6 = (s) => s.domNode?.querySelector(".react-flow__edgelabel-renderer");
@@ -50371,6 +50378,9 @@ async function toCanvas(node, options = {}) {
50371
50378
  const { width, height } = getImageSize(node, options), svg = await toSvg(node, options), img = await createImage(svg), canvas = document.createElement("canvas"), context = canvas.getContext("2d"), ratio = options.pixelRatio || getPixelRatio(), canvasWidth = options.canvasWidth || width, canvasHeight = options.canvasHeight || height;
50372
50379
  return canvas.width = canvasWidth * ratio, canvas.height = canvasHeight * ratio, options.skipAutoScale || checkCanvasDimensions(canvas), canvas.style.width = `${canvasWidth}`, canvas.style.height = `${canvasHeight}`, options.backgroundColor && (context.fillStyle = options.backgroundColor, context.fillRect(0, 0, canvas.width, canvas.height)), context.drawImage(img, 0, 0, canvas.width, canvas.height), canvas;
50373
50380
  }
50381
+ async function toJpeg(node, options = {}) {
50382
+ return (await toCanvas(node, options)).toDataURL("image/jpeg", options.quality || 1);
50383
+ }
50374
50384
  async function toBlob(node, options = {}) {
50375
50385
  const canvas = await toCanvas(node, options);
50376
50386
  return await canvasToBlob(canvas);
@@ -52610,18 +52620,19 @@ export {
52610
52620
  useRouter as d8,
52611
52621
  useParams as d9,
52612
52622
  LoadingOverlay as dA,
52613
- toBlob as dB,
52614
- useAsync as dC,
52615
- Ut as dD,
52616
- qt as dE,
52617
- Zt as dF,
52618
- notFound as dG,
52619
- Navigate as dH,
52620
- object as dI,
52621
- literal as dJ,
52622
- stringbool as dK,
52623
- string$1 as dL,
52624
- formatError as dM,
52623
+ toJpeg as dB,
52624
+ toBlob as dC,
52625
+ useAsync as dD,
52626
+ Ut as dE,
52627
+ qt as dF,
52628
+ Zt as dG,
52629
+ notFound as dH,
52630
+ Navigate as dI,
52631
+ object as dJ,
52632
+ literal as dK,
52633
+ stringbool as dL,
52634
+ string$1 as dM,
52635
+ formatError as dN,
52625
52636
  isNotFound as da,
52626
52637
  Container as db,
52627
52638
  Code as dc,
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { LikeC4View as LikeC4View$1 } from "likec4:react";
3
3
  import { createRoot } from "react-dom/client";
4
4
  import { ComponentName } from "./const.js";
5
- import { dI as object, dJ as literal, dK as stringbool, dL as string, dM as formatError } from "./vendors.js";
5
+ import { dJ as object, dK as literal, dL as stringbool, dM as string, dN as formatError } from "./vendors.js";
6
6
  const propsSchema = object({
7
7
  viewId: string().default("index"),
8
8
  browser: stringbool().default(!0),
@@ -700,7 +700,7 @@ type FqnReferenceable = Element | ExtendDeployment | ExtendElement | Referenceab
700
700
  declare const FqnReferenceable = "FqnReferenceable";
701
701
  type IconId = string;
702
702
  type IconPositionValue = 'bottom' | 'left' | 'right' | 'top';
703
- type Id = 'deployment' | 'element' | 'group' | 'instance' | 'model' | 'node' | ArrowType | DynamicViewDisplayVariantValue | ElementShape | IconPositionValue | LineOptions | Participant | RankValue | SizeValue | ThemeColor | string;
703
+ type Id = 'deployment' | 'element' | 'group' | 'instance' | 'model' | 'node' | 'relationship' | ArrowType | DynamicViewDisplayVariantValue | ElementShape | IconPositionValue | LineOptions | Participant | RankValue | SizeValue | ThemeColor | string;
704
704
  type LikeC4View = DeploymentView | DynamicView | ElementView;
705
705
  declare const LikeC4View = "LikeC4View";
706
706
  type LineOptions = 'dashed' | 'dotted' | 'solid';