# Interfaces

Import these from `@grafloria/engine`.

## Interfaces

### `ArchitectureGrid`

A container laid out as an explicit grid (Mermaid block-beta): cells in reading order.

```ts
interface ArchitectureGrid
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `columns?` | `number` |  | Cells to a row; absent = all in one row. |
| `cells` | `Array<{ id?: string; span?: number }>` |  | A block (node or zone id) or a hole (no id), each `span` cells wide. |

### `ArchitectureLayoutOptions`

```ts
interface ArchitectureLayoutOptions
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `direction?` | `string` |  | 'LR' (default: the diagram's own direction, else LR) or 'TB'. |
| `measureText?` | `MeasureText` |  | Measures a line of text; the default estimates (the engine has no canvas). |
| `margin?` | `number` |  | Space around the whole drawing. |
| `compact?` | `boolean` |  | Smaller boxes, tighter gaps — a block diagram's grid. Default: the diagram's `metadata.layoutCompact`. |

### `ArchitectureLayoutResult`

```ts
interface ArchitectureLayoutResult
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `nodePositions` | `Map<string, { x: number; y: number }>` |  |  |
| `bounds` | `{ x: number; y: number; width: number; height: number }` |  |  |

### `BulkSelectionOptions`

Also has every member of `SelectionOptions`, listed on its own entry.

Options for bulk selection

```ts
interface BulkSelectionOptions extends SelectionOptions
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `entityTypes?` | `('node' \| 'link' \| 'group')[]` |  | Entity types to include |

### `ClipboardData`

Clipboard data format for diagram entities

```ts
interface ClipboardData
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `nodes` | `SerializedNode[]` |  |  |
| `links` | `SerializedLink[]` |  |  |
| `groups` | `SerializedGroup[]` |  |  |
| `timestamp` | `number` |  |  |
| `sourceDiagramId?` | `string` |  |  |
| `sourceDigramId?` | `string` |  |  |

### `ComponentAdapterWithMetadata`

Also has every member of `ComponentAdapter`, listed on its own entry.

Extended adapter interface with metadata support

Optional extension for adapters that support component metadata

```ts
interface ComponentAdapterWithMetadata extends ComponentAdapter
```

**Members**

- `registerComponentWithMetadata( nodeType: string, component: any, metadata: ComponentMetadata ): void` — Register component with metadata
- `getComponentMetadata(nodeType: string): ComponentMetadata | undefined` — Get metadata for registered component
- `getAllComponentMetadata(): Map<string, ComponentMetadata>` — Get all components with their metadata

### `ComponentMetadata`

Metadata for component registration

Optional metadata that can be associated with registered components

```ts
interface ComponentMetadata
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `displayName?` | `string` |  | Display name for component palette |
| `category?` | `string` |  | Category for grouping in palette (e.g., 'ERD', 'BPMN', 'Flowchart') |
| `icon?` | `string` |  | Icon identifier for palette |
| `description?` | `string` |  | Brief description of component |
| `tags?` | `string[]` |  | Tags for search/filtering |
| `defaultSize?` | `{ width: number; height: number }` |  | Default size for new nodes |
| `resizable?` | `boolean` |  | Whether component can be resized |
| `supportsPorts?` | `boolean` |  | Whether component supports ports |

### `ConnectedSelectionOptions`

Also has every member of `SelectionOptions`, listed on its own entry.

Options for connected node selection

```ts
interface ConnectedSelectionOptions extends SelectionOptions
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `direction?` | `'incoming' \| 'outgoing' \| 'both'` |  | Direction to follow links |
| `includeSelf?` | `boolean` |  | Whether to include the starting node |

### `DrawioImportResult`

```ts
interface DrawioImportResult
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `diagram?` | `DiagramModel` |  | The imported diagram (page 1 of a multi-page file) — absent when `error` is set. |
| `warnings` | `string[]` |  | Every construct the import dropped or approximated, one NAMED entry each. Empty means the file mapped cleanly. For a multi-page file: page 1's warnings plus the file-level ones (including any later page's failure). |
| `error?` | `string` |  | Fatal: the text is not a readable .drawio document. Never thrown. |
| `pages?` | `DrawioPage[]` |  | Present ONLY when the file carries more than one `<diagram>` page. `diagram === pages[0].diagram`; every page imports independently. |

### `EventLogEntry`

```ts
interface EventLogEntry
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `timestamp` | `number` |  |  |
| `event` | `string` |  |  |
| `data` | `any` |  |  |
| `namespace` | `string` |  |  |
| `action` | `string` |  |  |

### `FilterSelectionOptions`

Also has every member of `SelectionOptions`, listed on its own entry.

Options for filter-based selection

```ts
interface FilterSelectionOptions extends SelectionOptions
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `entityTypes?` | `('node' \| 'link' \| 'group')[]` |  | Entity types to filter |

### `LemonadeRenderResult`

LemonadeJS render result with DOM element

```ts
interface LemonadeRenderResult
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | `'template' \| 'component'` |  | Rendering mode used |
| `element?` | `HTMLElement` |  | Rendered DOM element (LemonadeJS element) |
| `html?` | `string` |  | Rendered HTML string (for compatibility) |
| `componentRef?` | `string` |  | Component reference (for component mode) |
| `className?` | `string` |  | CSS class names |
| `style?` | `Record<string, any>` |  | Inline styles |
| `eventHandlers` | `Record<string, (event: any) => void>` |  | Event handlers bound to EventBus |
| `bindings` | `Record<string, any>` |  | Data bindings (reactive with LemonadeJS) |
| `self?` | `any` |  | LemonadeJS self object (for reactivity) |
| `zIndex?` | `number` |  | Z-index for HTML layer |
| `pointerEvents` | `boolean` |  | Pointer events enabled |
| `nodeId` | `string` |  | Node ID |
| `nodeUuid` | `string` |  | Node UUID |

### `MobilePerformanceConfig`

```ts
interface MobilePerformanceConfig
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `enableThrottling` | `boolean` |  |  |
| `touchMoveThrottle` | `number` |  |  |
| `reducedRendering` | `boolean` |  |  |
| `maxVisibleNodes` | `number` |  |  |
| `lowPowerMode` | `boolean` |  |  |

### `ParsedEvent`

```ts
interface ParsedEvent
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `namespace` | `string` |  |  |
| `action` | `string` |  |  |
| `full` | `string` |  |  |

### `PerformanceConfig`

```ts
interface PerformanceConfig
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `enableMonitoring?` | `boolean` |  |  |
| `enableProfiling?` | `boolean` |  |  |
| `warnThreshold?` | `number` |  |  |

### `PerformanceMetric`

```ts
interface PerformanceMetric
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `count` | `number` |  |  |
| `totalTime` | `number` |  |  |
| `averageTime` | `number` |  |  |
| `minTime` | `number` |  |  |
| `maxTime` | `number` |  |  |

### `PerformanceReport`

```ts
interface PerformanceReport
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `metrics` | `Record<string, PerformanceMetric>` |  |  |
| `summary` | `{ totalOperations: number; averageTime: number; slowestOperation: string; fastestOperation: string; }` |  |  |

### `PluginManagerConfig`

```ts
interface PluginManagerConfig
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `autoActivate?` | `boolean` |  |  |
| `strict?` | `boolean` |  |  |

### `PluginState`

```ts
interface PluginState
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `plugin` | `Plugin` |  |  |
| `installed` | `boolean` |  |  |
| `active` | `boolean` |  |  |
| `config` | `Record<string, any>` |  |  |
| `error?` | `Error` |  |  |

### `RectSelectionOptions`

Also has every member of `SelectionOptions`, listed on its own entry.

Options for rectangle selection

```ts
interface RectSelectionOptions extends SelectionOptions
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `intersectionMode?` | `'intersect' \| 'contain'` |  | Intersection mode: 'intersect' or 'contain' |

### `RenderResult`

Render result containing rendered HTML and metadata

```ts
interface RenderResult
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | `'template' \| 'component'` |  | Rendering mode used |
| `html?` | `string` |  | Rendered HTML string (for template mode) |
| `componentRef?` | `string` |  | Component reference (for component mode) |
| `className?` | `string` |  | CSS class names |
| `style?` | `Record<string, any>` |  | Inline styles |
| `eventHandlers` | `Record<string, (event: any) => void>` |  | Event handlers bound to EventBus Maps event names to handler functions |
| `bindings` | `Record<string, any>` |  | Data bindings resolved from node data |
| `zIndex?` | `number` |  | Z-index for HTML layer |
| `pointerEvents` | `boolean` |  | Pointer events enabled |
| `nodeId` | `string` |  | Node ID (for event context) |
| `nodeUuid` | `string` |  | Node UUID (for event context) |

### `SelectionOptions`

Selection options for controlling selection behavior

```ts
interface SelectionOptions
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `mode?` | `'replace' \| 'add' \| 'subtract' \| 'toggle'` |  | Mode for combining with existing selection |
| `silent?` | `boolean` |  | Whether to emit selection events |
| `maxDepth?` | `number` |  | Maximum depth for recursive operations (-1 = unlimited) |

### `TextFont`

How wide a run of text will draw — for a layout that sizes boxes to their
words. The engine has no canvas, so the default is an ESTIMATE from per-glyph
widths of a UI sans face, deliberately a little wide: a box a few pixels too
roomy looks fine, a box a few pixels too tight cuts its name to "…". A host
that can measure (the renderer, with a canvas) passes its own `measureText`.

```ts
interface TextFont
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `number` |  | px |
| `weight?` | `string \| number` |  |  |
| `family?` | `string` |  |  |
| `letterSpacing?` | `number` |  | px added after every character (CSS letter-spacing) |

### `TypeSelectionOptions`

Also has every member of `SelectionOptions`, listed on its own entry.

Options for type-based selection

```ts
interface TypeSelectionOptions extends SelectionOptions
```

**Properties**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `exact?` | `boolean` |  | Whether to match exact type or allow subtypes |
