This commit is contained in:
nik
2025-10-03 22:27:28 +03:00
parent 829fad0e17
commit 871cf7e792
16520 changed files with 2967597 additions and 3 deletions

View File

@@ -0,0 +1,53 @@
import cytoscape from 'cytoscape';
import type { LayoutData, Node, Edge } from '../../types.js';
import type { PositionedNode, PositionedEdge } from './types.js';
/**
* Declare module augmentation for cytoscape edge types
*/
declare module 'cytoscape' {
interface EdgeSingular {
_private: {
bodyBounds: unknown;
rscratch: {
startX: number;
startY: number;
midX: number;
midY: number;
endX: number;
endY: number;
};
};
}
}
/**
* Add nodes to cytoscape instance from provided node array
* This function processes only the nodes provided in the data structure
* @param nodes - Array of nodes to add
* @param cy - The cytoscape instance
*/
export declare function addNodes(nodes: Node[], cy: cytoscape.Core): void;
/**
* Add edges to cytoscape instance from provided edge array
* This function processes only the edges provided in the data structure
* @param edges - Array of edges to add
* @param cy - The cytoscape instance
*/
export declare function addEdges(edges: Edge[], cy: cytoscape.Core): void;
/**
* Create and configure cytoscape instance
* @param data - Layout data containing nodes and edges
* @returns Promise resolving to configured cytoscape instance
*/
export declare function createCytoscapeInstance(data: LayoutData): Promise<cytoscape.Core>;
/**
* Extract positioned nodes from cytoscape instance
* @param cy - The cytoscape instance after layout
* @returns Array of positioned nodes
*/
export declare function extractPositionedNodes(cy: cytoscape.Core): PositionedNode[];
/**
* Extract positioned edges from cytoscape instance
* @param cy - The cytoscape instance after layout
* @returns Array of positioned edges
*/
export declare function extractPositionedEdges(cy: cytoscape.Core): PositionedEdge[];

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,22 @@
/**
* Cose-Bilkent Layout Algorithm for Generic Diagrams
*
* This module provides a layout algorithm implementation using Cytoscape
* with the cose-bilkent algorithm for positioning nodes and edges.
*
* The algorithm follows the unified rendering pattern and can be used
* by any diagram type that provides compatible LayoutData.
*/
/**
* Render function for the cose-bilkent layout algorithm
*
* This function follows the unified rendering pattern used by all layout algorithms.
* It takes LayoutData, inserts nodes into DOM, runs the cose-bilkent layout algorithm,
* and renders the positioned elements to the SVG.
*
* @param layoutData - Layout data containing nodes, edges, and configuration
* @param svg - SVG element to render to
* @param helpers - Internal helper functions for rendering
* @param options - Rendering options
*/
export declare const render: (data4Layout: import("../../types.js").LayoutData, svg: import("../../../mermaid.js").SVG, { insertCluster, insertEdge, insertEdgeLabel, insertMarkers, insertNode, log, positionEdgeLabel, }: import("../../../internals.js").InternalHelpers, { algorithm: _algorithm }: import("../../render.js").RenderOptions) => Promise<void>;

View File

@@ -0,0 +1,20 @@
import type { MermaidConfig } from '../../../config.type.js';
import type { LayoutData } from '../../types.js';
import type { LayoutResult } from './types.js';
/**
* Execute the cose-bilkent layout algorithm on generic layout data
*
* This function takes layout data and uses Cytoscape with the cose-bilkent
* algorithm to calculate optimal node positions and edge paths.
*
* @param data - The layout data containing nodes, edges, and configuration
* @param config - Mermaid configuration object
* @returns Promise resolving to layout result with positioned nodes and edges
*/
export declare function executeCoseBilkentLayout(data: LayoutData, _config: MermaidConfig): Promise<LayoutResult>;
/**
* Validate layout data structure
* @param data - The data to validate
* @returns True if data is valid, throws error otherwise
*/
export declare function validateLayoutData(data: LayoutData): boolean;

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,10 @@
import type { InternalHelpers, LayoutData, RenderOptions, SVG } from 'mermaid';
/**
* Render function for cose-bilkent layout algorithm
*
* This follows the same pattern as ELK and dagre renderers:
* 1. Insert nodes into DOM to get their actual dimensions
* 2. Run the layout algorithm to calculate positions
* 3. Position the nodes and edges based on layout results
*/
export declare const render: (data4Layout: LayoutData, svg: SVG, { insertCluster, insertEdge, insertEdgeLabel, insertMarkers, insertNode, log, positionEdgeLabel, }: InternalHelpers, { algorithm: _algorithm }: RenderOptions) => Promise<void>;

View File

@@ -0,0 +1,40 @@
/**
* Positioned node after layout calculation
*/
export interface PositionedNode {
id: string;
x: number;
y: number;
[key: string]: unknown;
}
/**
* Positioned edge after layout calculation
*/
export interface PositionedEdge {
id: string;
source: string;
target: string;
startX: number;
startY: number;
midX: number;
midY: number;
endX: number;
endY: number;
[key: string]: unknown;
}
/**
* Result of layout algorithm execution
*/
export interface LayoutResult {
nodes: PositionedNode[];
edges: PositionedEdge[];
}
/**
* Cytoscape layout configuration
*/
export interface CytoscapeLayoutConfig {
name: 'cose-bilkent';
quality: 'proof';
styleEnabled: boolean;
animate: boolean;
}

View File

@@ -0,0 +1 @@
export function render(data4Layout: any, svg: any): Promise<void>;

View File

@@ -0,0 +1,8 @@
export let clusterDb: Map<any, any>;
export function clear(): void;
export function extractDescendants(id: any, graph: any): any[];
export function validate(graph: any): boolean;
export function findNonClusterChild(id: any, graph: any, clusterId: any): any;
export function adjustClustersAndEdges(graph: any, depth: any): void;
export function extractor(graph: any, depth: any): void;
export function sortNodesByHierarchy(graph: any): any;