Classes
Import these from @grafloria/engine.
Classes
ASTTransformer
tsclass ASTTransformer
Methods
transform(ast: DiagramNode, options: TransformOptions = {}): DiagramModel— Transform AST into DiagramModelresetAutoPosition(startPosition: { x: number; y: number }): void— Reset auto-positioning state
BidirectionalSync
tsclass BidirectionalSync
Methods
constructor(options: SyncOptions = {})initialize(diagram: DiagramModel, initialText?: string): void— Initialize sync with diagram and initial textonTextChange(newText: string): void— Update text (called when user edits text)markVisualEdit(): void— Mark next changes as from visual editormarkTextEdit(): void— Mark next changes as from text editorgetCurrentText(): string— Get current textgetDiagram(): DiagramModel | undefined— Get current diagramgetState(): Readonly<SyncState>— Get sync stateonSync(callback: SyncCallback): () => void— Add sync callbackpause(): void— Pause syncresume(): void— Resume syncforceSync(direction: 'text-to-visual' | 'visual-to-text'): void— Force sync in specific directiondispose(): void— Dispose and cleanup
DiagramAnalyzer
tsclass DiagramAnalyzer
Methods
analyze(diagram: DiagramModel): DiagramAnalysis— Analyze diagram structure
DSLFormatter
tsclass DSLFormatter
Methods
constructor(options: FormatterOptions = {})format(text: string): string— Format DSL textwrapLongLines(text: string): string— Wrap long linesnormalizeWhitespace(text: string): string— Normalize whitespaceremoveComments(text: string): string— Remove commentsaddSectionHeaders(text: string): string— Add section headersprettyPrint(text: string, addHeaders: boolean = false): string— Pretty print with all formatting optionsminify(text: string): string— Minify (remove all formatting)
DSLGenerator
tsclass DSLGenerator
Methods
constructor()generate(diagram: DiagramModel, options: GeneratorOptions = {}): string— Generate DSL text from diagram
IntegratedSyncManager
tsclass IntegratedSyncManager
Methods
constructor(options: IntegratedSyncOptions = {})initialize(diagram: DiagramModel, initialText?: string): void— Initialize with diagram and optional initial textonTextEdit(newText: string): void— Handle text editor changesonVisualEdit(): void— Handle visual editor changesgetText(): string— Get current textgetDiagram(): DiagramModel | undefined— Get current diagramgetStatus(): SyncStatus— Get sync statusgetMetrics(): SyncMetrics— Get sync metricsasync applyLayout(presetId?: string): Promise<void>— Apply layout to current diagramsuggestLayout(): LayoutSuggestion | null— Get layout suggestiononTextChange(callback: TextChangeCallback): () => void— Subscribe to text changesonDiagramChange(callback: DiagramChangeCallback): () => void— Subscribe to diagram changesonStatusChange(callback: StatusCallback): () => void— Subscribe to status changespause(): void— Pause syncresume(): void— Resume syncforceSync(direction: 'text-to-visual' | 'visual-to-text'): void— Force sync in specific directionresetMetrics(): void— Reset metricsgetFormattedStatus(): string— Get formatted status stringgetMetricsSummary(): string— Get metrics summarydispose(): void— Dispose and cleanup
LayoutDetector
tsclass LayoutDetector
Methods
detect(diagram: DiagramModel, ast?: DiagramNode): LayoutSuggestion— Detect optimal layout for a diagram
Lexer
tsclass Lexer
Methods
constructor(input: string)tokenize(): Token[]— Tokenize the entire input
ParseError
tsclass ParseError extends Error
Properties
| Name | Type | Default | Description |
|---|---|---|---|
name | string | ||
message | string | ||
stack? | string |
Methods
constructor( message: string, public token: Token, public line: number, public column: number )
Parser
tsclass Parser
Methods
parse(tokens: Token[]): DiagramNode— Parse tokens into an AST
SyncStateManager
tsclass SyncStateManager
Methods
startSync(direction: SyncDirection): void— Mark sync as startedcompleteSync(direction: SyncDirection, duration: number): void— Mark sync as completedfailSync(error: string): void— Mark sync as failedrecordConflict( sources: [SyncDirection, SyncDirection], resolution: ConflictInfo['resolution'] ): void— Record a conflictgetStatus(): Readonly<SyncStatus>— Get current statusgetMetrics(): Readonly<SyncMetrics>— Get metricsgetConflicts(limit: number = 10): ConflictInfo[]— Get recent conflictsonStatusChange(callback: StatusChangeCallback): () => void— Subscribe to status changesresetMetrics(): void— Reset metricsgetFormattedStatus(): string— Get formatted status for displaygetMetricsSummary(): string— Get metrics summary
Was this page helpful?