Import these from @grafloria/engine.
Classes
ClipboardManager
ClipboardManager handles copy/paste operations for diagram entities
Features:
- Serializes selected entities to clipboard format
- Handles relationship preservation (links between copied nodes)
- Supports cross-diagram paste (ID remapping)
- Maintains clipboard history
tsclass ClipboardManager
Methods
copy(data: { nodes: NodeModel[]; links: LinkModel[]; groups: GroupModel[]; sourceDiagramId?: string; }): void— Copy entities to clipboardget(): ClipboardData | null— Get clipboard dataclaimPasteSlot(): number— Claim the next paste slot for the CURRENT clipboard payload (1-based).hasData(): boolean— Check if clipboard has dataclear(): void— Clear clipboardgetHistory(): ClipboardData[]— Get clipboard historyisFromDiagram(diagramId: string): boolean— Check if clipboard contains nodes from a specific diagramgetStats(): { nodeCount: number; linkCount: number; groupCount: number; timestamp: number | null; }— Get clipboard statistics
EventBus
tsclass EventBus
Methods
constructor()emit(event: string, data?: any): void— Emit an eventon(pattern: string, handler: Function): () => void— Subscribe to eventsonce(pattern: string, handler: Function): void— Subscribe onceoff(pattern: string, handler: Function): void— Unsubscribe from eventsremoveAllListeners(pattern?: string): void— Remove all listenersonFiltered( event: string, filter: (data: any) => boolean, handler: Function ): () => void— Filtered subscriptiononMapped<T, R>( event: string, mapper: (data: T) => R, handler: (data: R) => void ): () => void— Mapped subscriptiononDebounced( event: string, delay: number, handler: Function ): () => void— Debounced subscriptiononThrottled( event: string, delay: number, handler: Function ): () => void— Throttled subscriptionbatch(fn: () => void): void— Batch eventssuspend(): void— Suspend event emissionresume(): void— Resume event emissionstartRecording(): void— Start recording eventsstopRecording(): EventLogEntry[]— Stop recordinggetEventLog(): ReadonlyArray<EventLogEntry>— Get event logclearEventLog(): void— Clear event logreplay(events: EventLogEntry[]): void— Replay eventslistenerCount(event: string): number— Get listener counteventNames(): string[]— Get all event names
ForceDirectedLayoutAlgorithm
Also has every member of BaseLayoutAlgorithm, listed on its own entry.
ForceDirectedLayoutAlgorithm
Physics-based layout where:
- Nodes repel each other (like magnets with same poles)
- Connected nodes attract each other (like springs)
- System settles into equilibrium over iterations
Best for:
- Network diagrams
- Social graphs
- Relationship visualizations
- Organic, natural-looking layouts
tsclass ForceDirectedLayoutAlgorithm extends BaseLayoutAlgorithm implements ILayoutAlgorithm
Methods
constructor(options?: ForceDirectedOptions)getName(): string— Get the name of the layout algorithmgetType(): 'force-directed'— Get the type of the layout algorithmoverride configure(config: LayoutConfiguration): void— Configure the layout algorithmoverride getConfiguration(): LayoutConfiguration— Get current configurationoverride canApply(diagram: DiagramModel): { valid: boolean; reason?: string }— Validate if this algorithm can be applied to the given diagramcalculatePlacement(options: PlacementOptions): PlacementResult— Calculate position for a single new nodereLayout(diagram: DiagramModel, config?: LayoutConfiguration): Map<string, Point>— Re-layout all nodes in the diagramonActivate(): void— Called when the algorithm is activated Use this to initialize any state or cachesonDeactivate(): void— Called when the algorithm is deactivated Use this to clean up state or caches
GridLayoutAlgorithm
Also has every member of BaseLayoutAlgorithm, listed on its own entry.
tsclass GridLayoutAlgorithm extends BaseLayoutAlgorithm
Methods
constructor(config?: LayoutConfiguration)getName(): string— Get the name of the layout algorithmgetType(): 'grid'— Get the type of the layout algorithmcalculatePlacement(options: PlacementOptions): PlacementResult— Calculate placement for a single new nodereLayout(diagram: DiagramModel, config?: LayoutConfiguration): Map<string, Point>— Re-layout all nodes in grid patternoverride configure(config: LayoutConfiguration): void— Configure grid-specific optionsoverride canApply(diagram: DiagramModel): { valid: boolean; reason?: string }— Grid layout can always be applied
HierarchicalLayoutAlgorithm
Also has every member of BaseLayoutAlgorithm, listed on its own entry.
tsclass HierarchicalLayoutAlgorithm extends BaseLayoutAlgorithm
Methods
constructor(config?: LayoutConfiguration)getName(): string— Get the name of the layout algorithmgetType(): 'hierarchical'— Get the type of the layout algorithmcalculatePlacement(options: PlacementOptions): PlacementResult— Calculate placement for a single new node For hierarchical layout, we'll place it near connected nodesreLayout(diagram: DiagramModel, config?: LayoutConfiguration): Map<string, Point>— Re-layout all nodes using Dagreoverride configure(config: LayoutConfiguration): void— Configure hierarchical-specific optionsoverride canApply(diagram: DiagramModel): { valid: boolean; reason?: string }— Hierarchical layout works best on DAGs but can handle any graph
HtmlTemplateRenderer
HTML Template Renderer Framework-agnostic HTML template rendering with EventBus integration
Features:
- LemonadeJS template rendering
- Data binding from NodeModel.data
- Event handlers connected to EventBus
- Component mode support (pass-through for framework-specific rendering)
- Proper resource cleanup to prevent memory leaks
tsclass HtmlTemplateRenderer
Methods
constructor(private eventBus: EventBus)render(config: HtmlConfig, node: NodeModel): RenderResult— Render HTML configuration to resultdisposeNode(nodeUuid: string): void— Dispose resources for a specific nodedispose(): void— Cleanup all renderer resources
HybridLayoutAlgorithm
Also has every member of BaseLayoutAlgorithm, listed on its own entry.
HybridLayoutAlgorithm
Intelligent layout algorithm that:
- Analyzes the diagram structure
- Detects patterns (grid, tree, network, sparse)
- Automatically selects the best algorithm
- Delegates to the chosen algorithm
Pattern Detection:
- Grid: Few or no edges, uniform structure
- Tree/Hierarchy: Acyclic, directional flow
- Network: Dense connections, cycles
- Sparse: Few nodes, simple connections
Best for:
- Dynamic diagrams where structure changes
- Mixed diagram types
- When user doesn't want to choose algorithm
tsclass HybridLayoutAlgorithm extends BaseLayoutAlgorithm implements ILayoutAlgorithm
Methods
constructor(options?: HybridOptions)getName(): string— Get the name of the layout algorithmgetType(): 'hybrid'— Get the type of the layout algorithmoverride configure(config: LayoutConfiguration): void— Configure the layout algorithmoverride getConfiguration(): LayoutConfiguration— Get current configurationoverride canApply(diagram: DiagramModel): { valid: boolean; reason?: string }— Validate if this algorithm can be applied to the given diagramcalculatePlacement(options: PlacementOptions): PlacementResult— Calculate position for a single new nodereLayout(diagram: DiagramModel, config?: LayoutConfiguration): Map<string, Point>— Re-layout all nodes in the diagramonActivate(): void— Called when the algorithm is activated Use this to initialize any state or cachesonDeactivate(): void— Called when the algorithm is deactivated Use this to clean up state or cachesgetLastDetectedPattern(): DetectedPattern | undefined— Get the last detected pattern (useful for debugging/UI)
LemonadeJSRenderer
LemonadeJS Enhanced Renderer Full LemonadeJS runtime with two-way binding
Features:
- Real LemonadeJS template rendering
- Two-way data binding ()
- Reactive updates (automatic re-rendering on data changes)
- Event handlers (, , etc.)
- EventBus integration (all events flow through engine)
- Component mode support
tsclass LemonadeJSRenderer
Methods
constructor(private eventBus: EventBus)render(config: HtmlConfig, node: NodeModel): LemonadeRenderResult— Render HTML configuration to LemonadeJS elementdisposeNode(nodeUuid: string): void— Dispose resources for a specific nodedispose(): void— Cleanup all renderer resources
MobilePerformanceService
tsclass MobilePerformanceService
Methods
static isMobileDevice(): boolean(static) — Detect if running on mobile devicestatic isLowPowerDevice(): boolean(static) — Detect if low-power deviceinitialize(customConfig?: Partial<MobilePerformanceConfig>)— Initialize with auto-detectionthrottle<T extends (...args: any[]) => any>( key: string, fn: T, wait: number = this.config.touchMoveThrottle ): (...args: Parameters<T>) => void— Throttle function executiongetRenderQuality(): 'high' | 'medium' | 'low'— Get recommended render quality based on deviceshouldSkipRender(nodeCount: number): boolean— Should skip rendering based on performance configgetConfig(): MobilePerformanceConfig— Get configurationupdateConfig(config: Partial<MobilePerformanceConfig>)— Update configuration
PerformanceMonitor
tsclass PerformanceMonitor
Methods
constructor(config: PerformanceConfig = {})measure<T>(name: string, fn: () => T | Promise<T>): T | Promise<T>— Measure operation performancesetWarnThreshold(threshold: number): void— Set warning thresholdgetReport(): PerformanceReport— Get performance reportclear(): void— Clear all metrics
PluginManager
tsclass PluginManager
Methods
constructor( engine: any, eventBus: any, config: PluginManagerConfig = {} )register(plugin: Plugin, config: Record<string, any> = {}): void— Register a plugin (without installing)async install(pluginName: string): Promise<void>— Install a pluginasync uninstall(pluginName: string): Promise<void>— Uninstall a pluginasync activate(pluginName: string): Promise<void>— Activate a pluginasync deactivate(pluginName: string): Promise<void>— Deactivate a pluginget(pluginName: string): Plugin | undefined— Get plugin by namehas(pluginName: string): boolean— Check if plugin is registeredisInstalled(pluginName: string): boolean— Check if plugin is installedisActive(pluginName: string): boolean— Check if plugin is activegetState(pluginName: string): PluginState | undefined— Get plugin statelist(): PluginMetadata[]— List all registered pluginslistInstalled(): PluginMetadata[]— List installed pluginslistActive(): PluginMetadata[]— List active pluginsasync unregister(pluginName: string): Promise<void>— Unregister a plugin (removes from registry)async installAll(): Promise<void>— Install all registered pluginsasync uninstallAll(): Promise<void>— Uninstall all pluginsasync clear(): Promise<void>— Clear all plugins (uninstall and unregister)
Was this page helpful?