import { DiagramController, type DiagramActionResult, type DiagramControllerOptions, type DiagramState, type EditOp, type DiagramEditorDocument, type MermaidDocument } from '@pixerate/editor/diagram'; import type { EditorDocument } from '@pixerate/editor/persistence'; import { type DiagramLayout, type DiagramDrag, type DiagramLayoutOptions, type DiagramScene, type DiagramSceneTheme, type MermaidFlowEdge, type MermaidFlowNode } from '@pixerate/editor/canvas'; export interface CreateMermaidDiagramOptions extends DiagramControllerOptions { /** Layout spacing and node measuring for new nodes (stored positions always win). */ layoutOptions?: DiagramLayoutOptions; /** Colours for families drawn as scenes (default: the page's CSS colour variables). */ sceneTheme?: Partial; } type Placed = { id: string; position: { x: number; y: number; }; parentId?: string; }; export interface SvelteMermaidDiagram { readonly controller: DiagramController; /** * The save / load / undo contract for this diagram: pass it to `createEditorAutosave` * (`@pixerate/editor-svelte/persistence`) or `createDocumentToolProvider`. */ readonly editorDocument: EditorDocument; /** The controller's state (reactive). */ readonly state: DiagramState; readonly document: MermaidDocument; /** The Mermaid text (with the `%% @pixerate` layout comment). */ readonly source: string; /** Canvas nodes (groups first, children relative to their group) and edges (reactive). */ readonly nodes: MermaidFlowNode[]; readonly edges: MermaidFlowEdge[]; readonly layout: DiagramLayout; /** * The family's own picture (pie, Gantt, sequence, XY, radar…) with the selection marked; * null for families drawn as nodes and edges (flowchart, state, class, ER) and text-only * ones. Render it with `MermaidFamilyScene` (reactive). When editable, its draggable marks * carry `drag` (and a selected Gantt task its grips): pass `drop` as `ondragend`. */ readonly scene: DiagramScene | null; apply(ops: EditOp | EditOp[], label?: string): DiagramActionResult; /** Replaces the source; `clearHistory` when opening a different diagram. */ load(source: string, options?: { clearHistory?: boolean; }): DiagramActionResult; /** Stores where dragged nodes ended up (pass every canvas node as `all` so groups carry their contents). */ moveNodes(moved: readonly Placed[], all?: readonly Placed[]): DiagramActionResult | null; connect(source: string, target: string, label?: string): DiagramActionResult; /** Removes nodes / groups (with their edges) and edges by id, as one undo step. */ remove(ids: readonly string[]): DiagramActionResult; rename(id: string, label: string): DiagramActionResult; /** Renames what a scene mark targets: the title (`::title`), a group, an edge or a node. */ renameTarget(target: string, label: string): DiagramActionResult | null; /** Applies a finished drag on the scene (`planDiagramDrag`) as one undo step; null when it changes nothing. */ drop(drag: DiagramDrag): DiagramActionResult | null; select(ids: readonly string[]): void; undo(): void; redo(): void; /** Stops listening to the controller. */ destroy(): void; } /** * Svelte 5 rune: a Mermaid diagram on a Svelte Flow canvas. Subscribes to a * `DiagramController` (or creates one from options), lays it out and exposes canvas * nodes and edges reactively with bound edits. Parity with React's `useMermaidDiagram`. */ export declare function createMermaidDiagram(controllerOrOptions?: DiagramController | CreateMermaidDiagramOptions, /** Layout and scene colours when passing a controller (options carry them otherwise). */ view?: Pick): SvelteMermaidDiagram; export interface CreateMermaidStreamOptions extends DiagramLayoutOptions { /** Glide duration between layouts in ms (default 300; 0 jumps). */ duration?: number; } export interface SvelteMermaidStream { readonly document: MermaidDocument | null; readonly nodes: MermaidFlowNode[]; readonly edges: MermaidFlowEdge[]; /** The layout being shown (mid-glide while `settled` is false). */ readonly layout: DiagramLayout | null; readonly settled: boolean; /** Feeds the source so far; `complete` once nothing more will arrive. */ update(source: string, complete?: boolean): void; /** Starts over for a new source. */ reset(): void; destroy(): void; } /** * Svelte 5 rune: draws Mermaid that is still being written (e.g. a model's reply). Nodes * appear once an edge places them and glide to their new places as the layout grows. * Parity with React's `useMermaidStream`. */ export declare function createMermaidStream(options?: CreateMermaidStreamOptions): SvelteMermaidStream; export {};