@pixerate/editor 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.cjs +37 -29
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +4 -3
- package/dist/agent/index.d.ts +4 -3
- package/dist/agent/index.js +16 -8
- package/dist/agent/index.js.map +1 -1
- package/dist/animation/index.cjs +15 -1
- package/dist/animation/index.cjs.map +1 -1
- package/dist/animation/index.d.cts +3 -226
- package/dist/animation/index.d.ts +3 -226
- package/dist/animation/index.js +14 -0
- package/dist/bridge/cli.cjs +36 -0
- package/dist/bridge/cli.cjs.map +1 -0
- package/dist/bridge/cli.d.cts +1 -0
- package/dist/bridge/cli.d.ts +1 -0
- package/dist/bridge/cli.js +36 -0
- package/dist/bridge/cli.js.map +1 -0
- package/dist/bridge/index.cjs +16 -0
- package/dist/bridge/index.cjs.map +1 -0
- package/dist/bridge/index.d.cts +65 -0
- package/dist/bridge/index.d.ts +65 -0
- package/dist/bridge/index.js +16 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge-client-C5OziCRK.d.cts +148 -0
- package/dist/bridge-client-C5dRjrz5.d.ts +148 -0
- package/dist/canvas/index.cjs +1308 -528
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +309 -5
- package/dist/canvas/index.d.ts +309 -5
- package/dist/canvas/index.js +1295 -515
- package/dist/canvas/index.js.map +1 -1
- package/dist/chart/index.cjs +193 -192
- package/dist/chart/index.cjs.map +1 -1
- package/dist/chart/index.d.cts +77 -59
- package/dist/chart/index.d.ts +77 -59
- package/dist/chart/index.js +87 -86
- package/dist/chart/index.js.map +1 -1
- package/dist/{chunk-UAW5FEMD.js → chunk-3S72F46R.js} +66 -8
- package/dist/chunk-3S72F46R.js.map +1 -0
- package/dist/{chunk-5TWIN7ZJ.js → chunk-47WWV3LI.js} +34 -4
- package/dist/chunk-47WWV3LI.js.map +1 -0
- package/dist/{chunk-OV7UAKIY.js → chunk-633QC34G.js} +172 -1
- package/dist/chunk-633QC34G.js.map +1 -0
- package/dist/chunk-AWKPSOSX.js +401 -0
- package/dist/chunk-AWKPSOSX.js.map +1 -0
- package/dist/chunk-B6DSIEXA.js +96 -0
- package/dist/chunk-B6DSIEXA.js.map +1 -0
- package/dist/{chunk-5N6AQCVB.js → chunk-BQQZ6MOI.js} +3 -3
- package/dist/{chunk-M5Z77GFH.cjs → chunk-C3JHII3M.cjs} +53 -53
- package/dist/{chunk-M5Z77GFH.cjs.map → chunk-C3JHII3M.cjs.map} +1 -1
- package/dist/{chunk-JOX6MJW4.cjs → chunk-CKRNELPO.cjs} +176 -5
- package/dist/chunk-CKRNELPO.cjs.map +1 -0
- package/dist/{chunk-TGBCBQFV.cjs → chunk-DK6QBGCS.cjs} +45 -15
- package/dist/chunk-DK6QBGCS.cjs.map +1 -0
- package/dist/chunk-EGFUVXKK.cjs +96 -0
- package/dist/chunk-EGFUVXKK.cjs.map +1 -0
- package/dist/{chunk-AMWXSYCI.js → chunk-GPWNYQ7R.js} +2 -370
- package/dist/chunk-GPWNYQ7R.js.map +1 -0
- package/dist/chunk-H5K77C7Y.cjs +3848 -0
- package/dist/chunk-H5K77C7Y.cjs.map +1 -0
- package/dist/chunk-K73CKYUM.cjs +458 -0
- package/dist/chunk-K73CKYUM.cjs.map +1 -0
- package/dist/{chunk-GTZXF4BI.cjs → chunk-NK3WL5TJ.cjs} +298 -133
- package/dist/chunk-NK3WL5TJ.cjs.map +1 -0
- package/dist/{chunk-3ZBAXET6.cjs → chunk-NN3JGUSX.cjs} +80 -22
- package/dist/chunk-NN3JGUSX.cjs.map +1 -0
- package/dist/chunk-NV22EMOZ.cjs +401 -0
- package/dist/chunk-NV22EMOZ.cjs.map +1 -0
- package/dist/{chunk-YMKPMXZ4.js → chunk-OIKYP7XC.js} +4 -4
- package/dist/{chunk-FEMIVHN3.cjs → chunk-P43HUQRX.cjs} +16 -16
- package/dist/{chunk-FEMIVHN3.cjs.map → chunk-P43HUQRX.cjs.map} +1 -1
- package/dist/chunk-PTMIGXZ2.js +467 -0
- package/dist/chunk-PTMIGXZ2.js.map +1 -0
- package/dist/chunk-QIWFEEWG.cjs +467 -0
- package/dist/chunk-QIWFEEWG.cjs.map +1 -0
- package/dist/{chunk-QFTVLEVN.js → chunk-RIXTW3C4.js} +3 -3
- package/dist/{chunk-WBOAXDKD.js → chunk-VODBAO32.js} +222 -57
- package/dist/chunk-VODBAO32.js.map +1 -0
- package/dist/chunk-WWJNC7SX.js +3848 -0
- package/dist/chunk-WWJNC7SX.js.map +1 -0
- package/dist/{chunk-2DEBI6KU.cjs → chunk-YZZMX6V7.cjs} +10 -10
- package/dist/{chunk-2DEBI6KU.cjs.map → chunk-YZZMX6V7.cjs.map} +1 -1
- package/dist/commands/index.d.cts +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/{controller-DS3drIvy.d.cts → controller-CX0QfSv0.d.cts} +53 -2
- package/dist/{controller-BdKzaxs2.d.ts → controller-DscWQbjO.d.ts} +53 -2
- package/dist/diagram/index.cjs +1146 -0
- package/dist/diagram/index.cjs.map +1 -0
- package/dist/diagram/index.d.cts +787 -0
- package/dist/diagram/index.d.ts +787 -0
- package/dist/diagram/index.js +1146 -0
- package/dist/diagram/index.js.map +1 -0
- package/dist/{easing-DTmX99QG.d.cts → easing-CNGk-W6d.d.cts} +1 -1
- package/dist/{easing-DTmX99QG.d.ts → easing-CNGk-W6d.d.ts} +1 -1
- package/dist/export/index.cjs +4 -4
- package/dist/export/index.js +3 -3
- package/dist/extensions/index.cjs +6 -6
- package/dist/extensions/index.d.cts +2 -2
- package/dist/extensions/index.d.ts +2 -2
- package/dist/extensions/index.js +5 -5
- package/dist/generation/index.d.cts +2 -2
- package/dist/generation/index.d.ts +2 -2
- package/dist/image-editor/index.d.cts +1 -1
- package/dist/image-editor/index.d.ts +1 -1
- package/dist/{index-Dt9lzydb.d.ts → index-CALDD35B.d.ts} +1 -1
- package/dist/{index-DOy9HzfC.d.cts → index-DIWB6xMf.d.cts} +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -6
- package/dist/parameters/index.d.cts +1 -1
- package/dist/parameters/index.d.ts +1 -1
- package/dist/player-DSMjdgQ9.d.cts +225 -0
- package/dist/player-DdfVrKWq.d.ts +225 -0
- package/dist/presence-Cb6WhcrQ.d.cts +77 -0
- package/dist/presence-Cb6WhcrQ.d.ts +77 -0
- package/dist/{registry-CSlH4iUn.d.ts → registry-7AZFuand.d.ts} +1 -1
- package/dist/{registry-B4l-lYts.d.cts → registry-DIpIaCkH.d.cts} +1 -1
- package/dist/tools/index.cjs +10 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +3 -74
- package/dist/tools/index.d.ts +3 -74
- package/dist/tools/index.js +12 -4
- package/dist/types-BULrFyuQ.d.cts +316 -0
- package/dist/types-BULrFyuQ.d.ts +316 -0
- package/dist/vector/index.d.cts +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/package.json +14 -1
- package/dist/chunk-3ZBAXET6.cjs.map +0 -1
- package/dist/chunk-5TWIN7ZJ.js.map +0 -1
- package/dist/chunk-AMWXSYCI.js.map +0 -1
- package/dist/chunk-GTZXF4BI.cjs.map +0 -1
- package/dist/chunk-JOX6MJW4.cjs.map +0 -1
- package/dist/chunk-OV7UAKIY.js.map +0 -1
- package/dist/chunk-TGBCBQFV.cjs.map +0 -1
- package/dist/chunk-UAW5FEMD.js.map +0 -1
- package/dist/chunk-WBOAXDKD.js.map +0 -1
- package/dist/chunk-XFYUFVAX.cjs +0 -826
- package/dist/chunk-XFYUFVAX.cjs.map +0 -1
- /package/dist/{chunk-5N6AQCVB.js.map → chunk-BQQZ6MOI.js.map} +0 -0
- /package/dist/{chunk-YMKPMXZ4.js.map → chunk-OIKYP7XC.js.map} +0 -0
- /package/dist/{chunk-QFTVLEVN.js.map → chunk-RIXTW3C4.js.map} +0 -0
|
@@ -0,0 +1,787 @@
|
|
|
1
|
+
import { M as MetaCarrier, a as MermaidDocument, E as EditOp, D as DiagramFamily, b as DiagramAdapter, S as SupportTier, P as Preamble, c as DiagramMeta, d as EdgePattern, A as ArrowHead, G as GraphEdge, e as Point, f as DiagramGraph } from '../types-BULrFyuQ.cjs';
|
|
2
|
+
export { g as AdapterParseContext, h as DIRECTIONS, i as Diagnostic, j as Direction, k as GraphGroup, l as GraphNode } from '../types-BULrFyuQ.cjs';
|
|
3
|
+
import { H as HistoryManager } from '../HistoryManager-DeQQMBCj.cjs';
|
|
4
|
+
import { A as AgentToolProvider } from '../registry-DIpIaCkH.cjs';
|
|
5
|
+
import { g as PresenceStore, e as PresenceClock, d as PresenceActorInfo } from '../presence-Cb6WhcrQ.cjs';
|
|
6
|
+
export { P as PRESENCE_COLORS, a as PerformanceQueue, c as PresenceActor, f as PresenceState, h as createInstantPresenceClock, r as realPresenceClock } from '../presence-Cb6WhcrQ.cjs';
|
|
7
|
+
import '../types-DsiXGmjo.cjs';
|
|
8
|
+
import '../schema-Di0CS6Pe.cjs';
|
|
9
|
+
|
|
10
|
+
interface ParseOptions {
|
|
11
|
+
/** Force where metadata is written. Defaults per family. */
|
|
12
|
+
metaCarrier?: MetaCarrier;
|
|
13
|
+
}
|
|
14
|
+
/** Detects the diagram family of a Mermaid source without fully parsing it. */
|
|
15
|
+
declare function detectFamily(source: string): DiagramFamily;
|
|
16
|
+
/**
|
|
17
|
+
* Parses Mermaid text into a {@link MermaidDocument}.
|
|
18
|
+
*
|
|
19
|
+
* Never throws: unknown or malformed input yields a `render-only` document
|
|
20
|
+
* with diagnostics, so hosts can always show the source editor.
|
|
21
|
+
*/
|
|
22
|
+
declare function parseMermaid(source: string, options?: ParseOptions): MermaidDocument;
|
|
23
|
+
/** Serialises a document back to Mermaid text. */
|
|
24
|
+
declare function serializeMermaid(doc: MermaidDocument): string;
|
|
25
|
+
/**
|
|
26
|
+
* Applies an edit and returns a new document whose `source` is the updated
|
|
27
|
+
* text. Documents are immutable; keep the returned value.
|
|
28
|
+
*/
|
|
29
|
+
declare function applyEdit(doc: MermaidDocument, op: EditOp): MermaidDocument;
|
|
30
|
+
/** Applies several edits in order. */
|
|
31
|
+
declare function applyEdits(doc: MermaidDocument, ops: EditOp[]): MermaidDocument;
|
|
32
|
+
|
|
33
|
+
/** Registers (or replaces) the adapter for a family. */
|
|
34
|
+
declare function registerDiagramAdapter(adapter: DiagramAdapter<unknown>): void;
|
|
35
|
+
declare function getDiagramAdapter(family: DiagramFamily): DiagramAdapter<unknown>;
|
|
36
|
+
/** `editable` for flowchart, state, class and ER diagrams; `render-only` otherwise. */
|
|
37
|
+
declare function supportTierOf(family: DiagramFamily): SupportTier;
|
|
38
|
+
|
|
39
|
+
interface SplitSource {
|
|
40
|
+
eol: "\n" | "\r\n";
|
|
41
|
+
preamble: Preamble;
|
|
42
|
+
/** Header line without EOL; empty string if none was found. */
|
|
43
|
+
header: string;
|
|
44
|
+
/** 0-based index of the header line in the original line array. */
|
|
45
|
+
headerIndex: number;
|
|
46
|
+
bodyLines: string[];
|
|
47
|
+
trailing: string;
|
|
48
|
+
}
|
|
49
|
+
/** Detects the diagram family of a header line (or whole source). */
|
|
50
|
+
declare function detectFamilyFromHeader(header: string): DiagramFamily;
|
|
51
|
+
/**
|
|
52
|
+
* Splits a Mermaid source into preamble, header, body and trailing whitespace.
|
|
53
|
+
*
|
|
54
|
+
* The preamble is everything before the header: an optional YAML frontmatter
|
|
55
|
+
* block (which must start on the first line), directives, comments and blank
|
|
56
|
+
* lines. All of it is kept verbatim.
|
|
57
|
+
*/
|
|
58
|
+
declare function splitSource(source: string): SplitSource;
|
|
59
|
+
/**
|
|
60
|
+
* Splits a single line into `;`-separated statements, ignoring separators
|
|
61
|
+
* inside quotes or brackets. Mermaid allows `A --> B; B --> C` on one line.
|
|
62
|
+
*/
|
|
63
|
+
declare function splitStatements(line: string): string[];
|
|
64
|
+
|
|
65
|
+
/** A Mermaid diagram found in some text by {@link findMermaidSources}. */
|
|
66
|
+
interface FoundMermaid {
|
|
67
|
+
/** The diagram's Mermaid text, without any surrounding code fence. */
|
|
68
|
+
source: string;
|
|
69
|
+
/** Its family (never `"unknown"`). */
|
|
70
|
+
family: DiagramFamily;
|
|
71
|
+
/** The frontmatter `title`, else the Markdown heading above its code fence. */
|
|
72
|
+
title?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Finds the Mermaid diagrams in a piece of text: a `.mmd` file, a Markdown
|
|
76
|
+
* document with ```` ```mermaid ```` blocks (GitHub, Notion and most AI
|
|
77
|
+
* chats write them like this), or a diagram pasted with or without its fence.
|
|
78
|
+
*
|
|
79
|
+
* Fenced blocks are used when there are any: those marked `mermaid` / `mmd`,
|
|
80
|
+
* and unmarked ones whose first line is a Mermaid header. Otherwise the whole
|
|
81
|
+
* text is one diagram if it starts with one. Unmarked text must spell the
|
|
82
|
+
* keyword as Mermaid does (`timeline`, not `Timeline`). Text that holds no
|
|
83
|
+
* diagram of a known family returns `[]`.
|
|
84
|
+
*/
|
|
85
|
+
declare function findMermaidSources(text: string): FoundMermaid[];
|
|
86
|
+
|
|
87
|
+
/** Prefix of the metadata comment line. */
|
|
88
|
+
declare const META_COMMENT_PREFIX = "%% @pixerate ";
|
|
89
|
+
/** Frontmatter key used when comments are not safe for a family. */
|
|
90
|
+
declare const META_FRONTMATTER_KEY = "pixerate";
|
|
91
|
+
declare function emptyMeta(): DiagramMeta;
|
|
92
|
+
declare function mergeMeta(a: DiagramMeta, b: DiagramMeta): DiagramMeta;
|
|
93
|
+
/** True when there is nothing worth writing. */
|
|
94
|
+
declare function isMetaEmpty(meta: DiagramMeta): boolean;
|
|
95
|
+
/** Compact, deterministic JSON so diffs stay small. Positions are rounded. */
|
|
96
|
+
declare function serializeMeta(meta: DiagramMeta): string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Statement-level model of a flowchart body. Every line of the source maps
|
|
100
|
+
* to exactly one statement (multi-line `@{ … }` blocks and `;`-joined
|
|
101
|
+
* statements are normalised during tokenisation). Statements remember their
|
|
102
|
+
* raw text and are re-emitted verbatim unless marked `dirty`.
|
|
103
|
+
*
|
|
104
|
+
* @module
|
|
105
|
+
*/
|
|
106
|
+
interface NodeRef {
|
|
107
|
+
id: string;
|
|
108
|
+
/** Shape when declared on this occurrence (bracket or data syntax). */
|
|
109
|
+
shape?: string;
|
|
110
|
+
/** How the shape was expressed: classic brackets or `@{ … }`. */
|
|
111
|
+
form?: "bracket" | "data";
|
|
112
|
+
label?: string;
|
|
113
|
+
labelQuoted?: boolean;
|
|
114
|
+
/** Parsed `@{ … }` entries (shape/label removed). Values keep their raw text. */
|
|
115
|
+
data?: Record<string, string>;
|
|
116
|
+
classes: string[];
|
|
117
|
+
}
|
|
118
|
+
interface LinkRef {
|
|
119
|
+
id?: string;
|
|
120
|
+
pattern: EdgePattern;
|
|
121
|
+
arrowStart: ArrowHead;
|
|
122
|
+
arrowEnd: ArrowHead;
|
|
123
|
+
length: number;
|
|
124
|
+
label?: string;
|
|
125
|
+
labelStyle?: "inline" | "pipe";
|
|
126
|
+
}
|
|
127
|
+
interface Chain {
|
|
128
|
+
/** `groups[i]` are the nodes joined by `&`; `links[i]` connects group i → i+1. */
|
|
129
|
+
groups: NodeRef[][];
|
|
130
|
+
links: LinkRef[];
|
|
131
|
+
}
|
|
132
|
+
type FlowStatement = {
|
|
133
|
+
kind: "raw";
|
|
134
|
+
raw: string;
|
|
135
|
+
} | {
|
|
136
|
+
kind: "chain";
|
|
137
|
+
raw: string;
|
|
138
|
+
indent: string;
|
|
139
|
+
chain: Chain;
|
|
140
|
+
dirty?: boolean;
|
|
141
|
+
} | {
|
|
142
|
+
kind: "subgraph";
|
|
143
|
+
raw: string;
|
|
144
|
+
indent: string;
|
|
145
|
+
id: string;
|
|
146
|
+
title?: string;
|
|
147
|
+
/** `subgraph id [title]` vs `subgraph "title"` */
|
|
148
|
+
titleForm: "bracket" | "bare" | "none";
|
|
149
|
+
dirty?: boolean;
|
|
150
|
+
} | {
|
|
151
|
+
kind: "end";
|
|
152
|
+
raw: string;
|
|
153
|
+
indent: string;
|
|
154
|
+
} | {
|
|
155
|
+
kind: "direction";
|
|
156
|
+
raw: string;
|
|
157
|
+
indent: string;
|
|
158
|
+
direction: string;
|
|
159
|
+
dirty?: boolean;
|
|
160
|
+
} | {
|
|
161
|
+
kind: "classDef";
|
|
162
|
+
raw: string;
|
|
163
|
+
indent: string;
|
|
164
|
+
names: string[];
|
|
165
|
+
styles: string[];
|
|
166
|
+
dirty?: boolean;
|
|
167
|
+
} | {
|
|
168
|
+
kind: "class";
|
|
169
|
+
raw: string;
|
|
170
|
+
indent: string;
|
|
171
|
+
ids: string[];
|
|
172
|
+
className: string;
|
|
173
|
+
dirty?: boolean;
|
|
174
|
+
} | {
|
|
175
|
+
kind: "style";
|
|
176
|
+
raw: string;
|
|
177
|
+
indent: string;
|
|
178
|
+
id: string;
|
|
179
|
+
styles: string[];
|
|
180
|
+
dirty?: boolean;
|
|
181
|
+
} | {
|
|
182
|
+
kind: "linkStyle";
|
|
183
|
+
raw: string;
|
|
184
|
+
indent: string;
|
|
185
|
+
targets: number[] | "default";
|
|
186
|
+
styles: string[];
|
|
187
|
+
dirty?: boolean;
|
|
188
|
+
} | {
|
|
189
|
+
kind: "click";
|
|
190
|
+
raw: string;
|
|
191
|
+
indent: string;
|
|
192
|
+
id: string;
|
|
193
|
+
rest: string;
|
|
194
|
+
dirty?: boolean;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Parses a chain statement (`A[x] --> B & C -- t --> D:::k`).
|
|
198
|
+
* Returns `null` if the text is not a chain.
|
|
199
|
+
*/
|
|
200
|
+
declare function parseChain(text: string): Chain | null;
|
|
201
|
+
/** Classifies a single logical statement line. */
|
|
202
|
+
declare function parseStatement(line: string): FlowStatement;
|
|
203
|
+
declare function formatNode(node: NodeRef): string;
|
|
204
|
+
declare function formatChain(chain: Chain): string;
|
|
205
|
+
|
|
206
|
+
/** Body model of a flowchart document. */
|
|
207
|
+
interface FlowchartBody {
|
|
208
|
+
statements: FlowStatement[];
|
|
209
|
+
}
|
|
210
|
+
type FlowchartDocument = MermaidDocument<FlowchartBody>;
|
|
211
|
+
|
|
212
|
+
type Doc = MermaidDocument<FlowchartBody>;
|
|
213
|
+
/** Full parse of a flowchart source, used after edits. */
|
|
214
|
+
declare function parseFlowchartSource(source: string, carrier?: Doc["metaCarrier"]): Doc;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Flowchart shape vocabulary.
|
|
218
|
+
*
|
|
219
|
+
* Mermaid has two ways to express a shape: classic bracket syntax (`A[text]`)
|
|
220
|
+
* and the `@{ shape: … }` data syntax introduced in v11. the diagram module normalises
|
|
221
|
+
* both to the *short name* used by the data syntax (`rect`, `diam`, `cyl`…),
|
|
222
|
+
* which is also what Mermaid's `getData()` reports for data-syntax nodes.
|
|
223
|
+
*
|
|
224
|
+
* @module
|
|
225
|
+
*/
|
|
226
|
+
interface BracketForm {
|
|
227
|
+
open: string;
|
|
228
|
+
close: string;
|
|
229
|
+
}
|
|
230
|
+
interface ShapeDef {
|
|
231
|
+
/** Canonical short name (what `@{ shape: … }` expects). */
|
|
232
|
+
name: string;
|
|
233
|
+
/** Human-readable name for UIs. */
|
|
234
|
+
title: string;
|
|
235
|
+
/** Alternative names accepted by Mermaid's data syntax. */
|
|
236
|
+
aliases: string[];
|
|
237
|
+
/** Classic bracket syntax when one exists. */
|
|
238
|
+
bracket?: BracketForm;
|
|
239
|
+
/** Broad visual category, handy for toolbars. */
|
|
240
|
+
category: "basic" | "process" | "data" | "control" | "misc";
|
|
241
|
+
}
|
|
242
|
+
declare const FLOWCHART_SHAPES: ShapeDef[];
|
|
243
|
+
/** Resolves any accepted shape name/alias (or Mermaid `getData()` id) to its definition. */
|
|
244
|
+
declare function resolveShape(name: string | undefined): ShapeDef | undefined;
|
|
245
|
+
/** Canonical short name for any alias; unknown names pass through unchanged. */
|
|
246
|
+
declare function canonicalShape(name: string | undefined): string;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Flowchart link syntax.
|
|
250
|
+
*
|
|
251
|
+
* Grammar (informal):
|
|
252
|
+
*
|
|
253
|
+
* link := [edgeId '@'] (plainLink | textLink) [ '|' label '|' ]
|
|
254
|
+
* plainLink := [head] body [head]
|
|
255
|
+
* textLink := [head] open ws label ws close [head]
|
|
256
|
+
* body := '--'+ | '=='+ | '-' '.'+ '-' | '~~~'+
|
|
257
|
+
* head := '>' | 'x' | 'o' | '<' (start only)
|
|
258
|
+
*
|
|
259
|
+
* @module
|
|
260
|
+
*/
|
|
261
|
+
interface ParsedLink {
|
|
262
|
+
/** User-defined edge id (`A e1@--> B`). */
|
|
263
|
+
id?: string;
|
|
264
|
+
pattern: EdgePattern;
|
|
265
|
+
arrowStart: ArrowHead;
|
|
266
|
+
arrowEnd: ArrowHead;
|
|
267
|
+
length: number;
|
|
268
|
+
label?: string;
|
|
269
|
+
/** How the label was written, so regeneration keeps the author's style. */
|
|
270
|
+
labelStyle?: "inline" | "pipe";
|
|
271
|
+
/** Characters consumed from the input. */
|
|
272
|
+
consumed: number;
|
|
273
|
+
raw: string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Attempts to parse a link at the start of `input`. Returns `null` when the
|
|
277
|
+
* input does not begin with a link.
|
|
278
|
+
*/
|
|
279
|
+
declare function parseLink(input: string): ParsedLink | null;
|
|
280
|
+
declare function quoteLabelIfNeeded(label: string): string;
|
|
281
|
+
interface LinkSpec {
|
|
282
|
+
id?: string;
|
|
283
|
+
pattern: EdgePattern;
|
|
284
|
+
arrowStart: ArrowHead;
|
|
285
|
+
arrowEnd: ArrowHead;
|
|
286
|
+
length: number;
|
|
287
|
+
label?: string;
|
|
288
|
+
labelStyle?: "inline" | "pipe";
|
|
289
|
+
}
|
|
290
|
+
/** Serialises a link back to Mermaid syntax. */
|
|
291
|
+
declare function formatLink(spec: LinkSpec): string;
|
|
292
|
+
|
|
293
|
+
declare const flowchartAdapter: DiagramAdapter<FlowchartBody>;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* A small engine for "one statement per line" Mermaid grammars
|
|
297
|
+
* (stateDiagram, classDiagram, erDiagram). A grammar classifies each logical
|
|
298
|
+
* line into a typed statement; the engine builds the graph, applies edits and
|
|
299
|
+
* re-emits untouched statements verbatim.
|
|
300
|
+
*
|
|
301
|
+
* @module
|
|
302
|
+
*/
|
|
303
|
+
interface NodeDecl {
|
|
304
|
+
id: string;
|
|
305
|
+
label?: string;
|
|
306
|
+
shape?: string;
|
|
307
|
+
classes: string[];
|
|
308
|
+
/** Family-specific data (members, attributes, descriptions…). */
|
|
309
|
+
data?: Record<string, unknown>;
|
|
310
|
+
}
|
|
311
|
+
type LineStatement = {
|
|
312
|
+
kind: "raw";
|
|
313
|
+
raw: string;
|
|
314
|
+
indent: string;
|
|
315
|
+
} | {
|
|
316
|
+
kind: "node";
|
|
317
|
+
raw: string;
|
|
318
|
+
indent: string;
|
|
319
|
+
decl: NodeDecl;
|
|
320
|
+
/** Multi-line body `{ … }` kept verbatim. */ body?: string[];
|
|
321
|
+
dirty?: boolean;
|
|
322
|
+
} | {
|
|
323
|
+
kind: "edge";
|
|
324
|
+
raw: string;
|
|
325
|
+
indent: string;
|
|
326
|
+
source: NodeDecl;
|
|
327
|
+
target: NodeDecl;
|
|
328
|
+
label?: string;
|
|
329
|
+
arrowStart: ArrowHead;
|
|
330
|
+
arrowEnd: ArrowHead;
|
|
331
|
+
pattern: GraphEdge["pattern"];
|
|
332
|
+
/** Family-specific data (cardinalities…). */
|
|
333
|
+
data?: Record<string, unknown>;
|
|
334
|
+
dirty?: boolean;
|
|
335
|
+
} | {
|
|
336
|
+
kind: "groupOpen";
|
|
337
|
+
raw: string;
|
|
338
|
+
indent: string;
|
|
339
|
+
id: string;
|
|
340
|
+
label?: string;
|
|
341
|
+
dirty?: boolean;
|
|
342
|
+
} | {
|
|
343
|
+
kind: "groupClose";
|
|
344
|
+
raw: string;
|
|
345
|
+
indent: string;
|
|
346
|
+
} | {
|
|
347
|
+
kind: "direction";
|
|
348
|
+
raw: string;
|
|
349
|
+
indent: string;
|
|
350
|
+
direction: string;
|
|
351
|
+
dirty?: boolean;
|
|
352
|
+
} | {
|
|
353
|
+
kind: "classDef";
|
|
354
|
+
raw: string;
|
|
355
|
+
indent: string;
|
|
356
|
+
names: string[];
|
|
357
|
+
styles: string[];
|
|
358
|
+
dirty?: boolean;
|
|
359
|
+
} | {
|
|
360
|
+
kind: "class";
|
|
361
|
+
raw: string;
|
|
362
|
+
indent: string;
|
|
363
|
+
ids: string[];
|
|
364
|
+
className: string;
|
|
365
|
+
dirty?: boolean;
|
|
366
|
+
} | {
|
|
367
|
+
kind: "style";
|
|
368
|
+
raw: string;
|
|
369
|
+
indent: string;
|
|
370
|
+
id: string;
|
|
371
|
+
styles: string[];
|
|
372
|
+
dirty?: boolean;
|
|
373
|
+
};
|
|
374
|
+
interface EdgeSpec {
|
|
375
|
+
label?: string;
|
|
376
|
+
arrowStart: ArrowHead;
|
|
377
|
+
arrowEnd: ArrowHead;
|
|
378
|
+
pattern: GraphEdge["pattern"];
|
|
379
|
+
data?: Record<string, unknown>;
|
|
380
|
+
}
|
|
381
|
+
interface LineGrammar {
|
|
382
|
+
family: DiagramFamily;
|
|
383
|
+
defaultShape: string;
|
|
384
|
+
/** Groups logical statements from physical lines (brace blocks, `end note`, …). */
|
|
385
|
+
joinLines(lines: string[]): string[];
|
|
386
|
+
parseLine(line: string): LineStatement;
|
|
387
|
+
formatStatement(stmt: LineStatement): string;
|
|
388
|
+
/** Builds a node statement for a new node. */
|
|
389
|
+
nodeStatement(decl: NodeDecl, indent: string): LineStatement;
|
|
390
|
+
/** Builds an edge statement. */
|
|
391
|
+
edgeStatement(source: string, target: string, spec: EdgeSpec, indent: string): LineStatement;
|
|
392
|
+
/** Builds the open/close statements of a group. */
|
|
393
|
+
groupStatements(id: string, label: string | undefined, indent: string): {
|
|
394
|
+
open: LineStatement;
|
|
395
|
+
close: LineStatement;
|
|
396
|
+
};
|
|
397
|
+
/** Reads the header direction. */
|
|
398
|
+
headerDirection(header: string, statements: LineStatement[]): string;
|
|
399
|
+
/** Optional: pseudo-node ids such as `[*]` that need special graph handling. */
|
|
400
|
+
resolveEndpoint?(id: string, groupStack: string[], role: "source" | "target"): {
|
|
401
|
+
id: string;
|
|
402
|
+
shape: string;
|
|
403
|
+
label: string;
|
|
404
|
+
synthetic: true;
|
|
405
|
+
} | null;
|
|
406
|
+
/** Default edge spec when the UI connects two nodes. */
|
|
407
|
+
defaultEdge: EdgeSpec;
|
|
408
|
+
/** Whether `setDirection` writes a `direction` statement (true) or the header. */
|
|
409
|
+
directionAsStatement: boolean;
|
|
410
|
+
/** False when the family has no grouping construct (ER). Group ops become no-ops. */
|
|
411
|
+
supportsGroups?: boolean;
|
|
412
|
+
}
|
|
413
|
+
interface LineBody {
|
|
414
|
+
statements: LineStatement[];
|
|
415
|
+
}
|
|
416
|
+
type LineDocument = MermaidDocument<LineBody>;
|
|
417
|
+
/** Creates a full adapter from a grammar. */
|
|
418
|
+
declare function createLineAdapter(grammar: LineGrammar): DiagramAdapter<LineBody>;
|
|
419
|
+
|
|
420
|
+
declare const STATE_SHAPES: readonly [{
|
|
421
|
+
readonly name: "rect";
|
|
422
|
+
readonly title: "State";
|
|
423
|
+
}, {
|
|
424
|
+
readonly name: "fork";
|
|
425
|
+
readonly title: "Fork";
|
|
426
|
+
}, {
|
|
427
|
+
readonly name: "join";
|
|
428
|
+
readonly title: "Join";
|
|
429
|
+
}, {
|
|
430
|
+
readonly name: "choice";
|
|
431
|
+
readonly title: "Choice";
|
|
432
|
+
}];
|
|
433
|
+
declare const stateGrammar: LineGrammar;
|
|
434
|
+
|
|
435
|
+
/** Relation syntax → arrow heads. Order matters: longer tokens first. */
|
|
436
|
+
interface ClassRelation {
|
|
437
|
+
token: string;
|
|
438
|
+
arrowStart: ArrowHead;
|
|
439
|
+
arrowEnd: ArrowHead;
|
|
440
|
+
pattern: EdgePattern;
|
|
441
|
+
title: string;
|
|
442
|
+
}
|
|
443
|
+
declare const CLASS_RELATIONS: ClassRelation[];
|
|
444
|
+
declare function relationFor(arrowStart: ArrowHead, arrowEnd: ArrowHead, pattern: EdgePattern): ClassRelation;
|
|
445
|
+
interface ClassMember {
|
|
446
|
+
raw: string;
|
|
447
|
+
visibility?: "+" | "-" | "#" | "~";
|
|
448
|
+
kind: "attribute" | "method";
|
|
449
|
+
}
|
|
450
|
+
declare function parseMembers(bodyLines: string[]): ClassMember[];
|
|
451
|
+
declare const classGrammar: LineGrammar;
|
|
452
|
+
|
|
453
|
+
declare const ER_CARDINALITIES: {
|
|
454
|
+
token: string;
|
|
455
|
+
head: ArrowHead;
|
|
456
|
+
side: "left" | "right";
|
|
457
|
+
title: string;
|
|
458
|
+
}[];
|
|
459
|
+
interface ErAttribute {
|
|
460
|
+
raw: string;
|
|
461
|
+
type: string;
|
|
462
|
+
name: string;
|
|
463
|
+
keys: string[];
|
|
464
|
+
comment?: string;
|
|
465
|
+
}
|
|
466
|
+
declare function parseAttributes(bodyLines: string[]): ErAttribute[];
|
|
467
|
+
declare const erGrammar: LineGrammar;
|
|
468
|
+
declare const ER_PATTERNS: {
|
|
469
|
+
pattern: EdgePattern;
|
|
470
|
+
title: string;
|
|
471
|
+
}[];
|
|
472
|
+
|
|
473
|
+
/** Body of a render-only document: the raw body lines. */
|
|
474
|
+
interface PassthroughBody {
|
|
475
|
+
lines: string[];
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Adapter for families the diagram module cannot edit on a canvas. The text is preserved
|
|
479
|
+
* verbatim; only `replaceSource`, `setTitle` and metadata edits apply.
|
|
480
|
+
*/
|
|
481
|
+
declare function createPassthroughAdapter(family: DiagramFamily, tier?: SupportTier): DiagramAdapter<PassthroughBody>;
|
|
482
|
+
|
|
483
|
+
/** Families that can be edited on the canvas; every other family is kept as text. */
|
|
484
|
+
declare const EDITABLE_DIAGRAM_FAMILIES: readonly ["flowchart", "state", "class", "er"];
|
|
485
|
+
/** The shapes a node of `family` can take (`setNodeShape`), as canonical names. */
|
|
486
|
+
declare function diagramShapes(family: DiagramFamily): string[];
|
|
487
|
+
/** Whether the family has groups (subgraphs, composite states, namespaces). ER diagrams do not. */
|
|
488
|
+
declare function diagramSupportsGroups(family: DiagramFamily): boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Checks an edit against the document before it is applied. Returns a sentence saying
|
|
491
|
+
* what is wrong and how to fix it, or `null` when the edit is valid. Ids are checked
|
|
492
|
+
* against nodes, groups and edges; shapes against {@link diagramShapes}.
|
|
493
|
+
*/
|
|
494
|
+
declare function validateDiagramEdit(doc: MermaidDocument, op: EditOp): string | null;
|
|
495
|
+
interface DiagramControllerOptions {
|
|
496
|
+
/** Starting Mermaid source (default: an empty `flowchart TD`). */
|
|
497
|
+
source?: string;
|
|
498
|
+
/** History to record into, e.g. one shared with the rest of the app (default: a new one). */
|
|
499
|
+
history?: HistoryManager;
|
|
500
|
+
/** Refuse edits (read tools still work). */
|
|
501
|
+
readOnly?: boolean;
|
|
502
|
+
/** Called after the source changes (edit, undo, redo, load). */
|
|
503
|
+
onChange?: (source: string, document: MermaidDocument) => void;
|
|
504
|
+
}
|
|
505
|
+
/** A snapshot of the controller. The same object is returned until something changes. */
|
|
506
|
+
interface DiagramState {
|
|
507
|
+
document: MermaidDocument;
|
|
508
|
+
/** The Mermaid text, always in step with `document`. */
|
|
509
|
+
source: string;
|
|
510
|
+
family: DiagramFamily;
|
|
511
|
+
/** True for flowchart, state, class and ER diagrams that are not read-only. */
|
|
512
|
+
editable: boolean;
|
|
513
|
+
readOnly: boolean;
|
|
514
|
+
/** Selected node, group or edge ids. */
|
|
515
|
+
selection: readonly string[];
|
|
516
|
+
/** The problem with the last rejected edit, if any. */
|
|
517
|
+
issue: string | null;
|
|
518
|
+
canUndo: boolean;
|
|
519
|
+
canRedo: boolean;
|
|
520
|
+
undoLabel: string;
|
|
521
|
+
redoLabel: string;
|
|
522
|
+
/** Bumped on every change. */
|
|
523
|
+
revision: number;
|
|
524
|
+
}
|
|
525
|
+
type DiagramActionResult = {
|
|
526
|
+
ok: true;
|
|
527
|
+
document: MermaidDocument;
|
|
528
|
+
} | {
|
|
529
|
+
ok: false;
|
|
530
|
+
message: string;
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* Headless state for a Mermaid diagram editor: the parsed document, a selection and
|
|
534
|
+
* undoable statement-level edits. Every `apply` is one undo step and only rewrites the
|
|
535
|
+
* statements it touches, so untouched text (comments, directives, formatting) survives.
|
|
536
|
+
* Canvas positions go into the `%% @pixerate {…}` comment. Drags merge into one undo
|
|
537
|
+
* step between `beginGesture` and `endGesture`. `getState()` returns the same object
|
|
538
|
+
* until something changes, so it works with `useSyncExternalStore` and Svelte runes.
|
|
539
|
+
*/
|
|
540
|
+
declare class DiagramController {
|
|
541
|
+
readonly history: HistoryManager;
|
|
542
|
+
private doc;
|
|
543
|
+
private selection;
|
|
544
|
+
private issue;
|
|
545
|
+
private readOnly;
|
|
546
|
+
private revision;
|
|
547
|
+
private applying;
|
|
548
|
+
private gestureKey;
|
|
549
|
+
private gestureCount;
|
|
550
|
+
private readonly onChange?;
|
|
551
|
+
private readonly listeners;
|
|
552
|
+
private unsubscribeHistory?;
|
|
553
|
+
private state;
|
|
554
|
+
constructor(options?: DiagramControllerOptions);
|
|
555
|
+
private connect;
|
|
556
|
+
/** Stops listening to the history (subscribing again reconnects). */
|
|
557
|
+
destroy(): void;
|
|
558
|
+
/** The current snapshot (stable until the next change). */
|
|
559
|
+
getState: () => DiagramState;
|
|
560
|
+
/** Calls `listener` after every change. Returns an unsubscribe function. */
|
|
561
|
+
subscribe: (listener: (state: DiagramState) => void) => (() => void);
|
|
562
|
+
/** The current document (immutable; edit through the controller). */
|
|
563
|
+
getDocument(): MermaidDocument;
|
|
564
|
+
getSource(): string;
|
|
565
|
+
private computeState;
|
|
566
|
+
private notify;
|
|
567
|
+
private setDocument;
|
|
568
|
+
private commit;
|
|
569
|
+
private reject;
|
|
570
|
+
/**
|
|
571
|
+
* Applies edits as one undo step. All-or-nothing: every edit is checked against the
|
|
572
|
+
* document as it stands after the edits before it, and nothing changes when one fails.
|
|
573
|
+
*/
|
|
574
|
+
apply(ops: EditOp | EditOp[], label?: string): DiagramActionResult;
|
|
575
|
+
/**
|
|
576
|
+
* Replaces the whole source. `clearHistory` drops the undo stack (opening a file);
|
|
577
|
+
* otherwise the replacement is one undo step.
|
|
578
|
+
*/
|
|
579
|
+
load(source: string, options?: {
|
|
580
|
+
clearHistory?: boolean;
|
|
581
|
+
}): DiagramActionResult;
|
|
582
|
+
setReadOnly(readOnly: boolean): void;
|
|
583
|
+
/** Selects node, group or edge ids (unknown ids are dropped). */
|
|
584
|
+
select(ids: readonly string[]): void;
|
|
585
|
+
/** Edits until `endGesture` (e.g. the moves of one drag) fold into one undo step. */
|
|
586
|
+
beginGesture(key: string): void;
|
|
587
|
+
endGesture(): void;
|
|
588
|
+
undo(): boolean;
|
|
589
|
+
redo(): boolean;
|
|
590
|
+
/** A node id not used by any node or group: `prefix` followed by the next free number. */
|
|
591
|
+
nextId(prefix?: string): string;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/** Where things are drawn on the canvas (absolute top-left and size), e.g. `mermaidToCanvas(...).layout`. */
|
|
595
|
+
interface DiagramPlacement {
|
|
596
|
+
positions: Readonly<Record<string, Point>>;
|
|
597
|
+
sizes: Readonly<Record<string, {
|
|
598
|
+
width: number;
|
|
599
|
+
height: number;
|
|
600
|
+
}>>;
|
|
601
|
+
}
|
|
602
|
+
type DiagramPerformanceStep = {
|
|
603
|
+
type: 'move';
|
|
604
|
+
to: {
|
|
605
|
+
x: number;
|
|
606
|
+
y: number;
|
|
607
|
+
};
|
|
608
|
+
ms: number;
|
|
609
|
+
} | {
|
|
610
|
+
type: 'say';
|
|
611
|
+
text: string;
|
|
612
|
+
ms: number;
|
|
613
|
+
} | {
|
|
614
|
+
type: 'type';
|
|
615
|
+
text: string;
|
|
616
|
+
ms: number;
|
|
617
|
+
} | {
|
|
618
|
+
type: 'press';
|
|
619
|
+
} | {
|
|
620
|
+
type: 'release';
|
|
621
|
+
}
|
|
622
|
+
/** Drag a node (and the cursor) so its top-left ends at `to`; the node follows live. */
|
|
623
|
+
| {
|
|
624
|
+
type: 'drag';
|
|
625
|
+
id: string;
|
|
626
|
+
to: {
|
|
627
|
+
x: number;
|
|
628
|
+
y: number;
|
|
629
|
+
};
|
|
630
|
+
position: Point;
|
|
631
|
+
ms: number;
|
|
632
|
+
} | {
|
|
633
|
+
type: 'commit';
|
|
634
|
+
};
|
|
635
|
+
/**
|
|
636
|
+
* Plans how an agent acts out one edit on the canvas: where the cursor goes, what it
|
|
637
|
+
* clicks, drags or types, and when the edit commits. Pure: the same document, placement
|
|
638
|
+
* and edit give the same steps. `next` is the edit that follows in the same call (a new
|
|
639
|
+
* node is placed beside the node an edge will connect it from).
|
|
640
|
+
*/
|
|
641
|
+
declare function planDiagramEdit(doc: MermaidDocument, place: DiagramPlacement, op: EditOp, speed?: number, next?: EditOp): DiagramPerformanceStep[];
|
|
642
|
+
interface DiagramDirectorOptions {
|
|
643
|
+
/** Where nodes are drawn now, e.g. `() => mermaidToCanvas(controller.getDocument()).layout`. */
|
|
644
|
+
placement: () => DiagramPlacement;
|
|
645
|
+
clock?: PresenceClock;
|
|
646
|
+
/** 1 = natural speed; 2 = twice as fast. */
|
|
647
|
+
speed?: number;
|
|
648
|
+
/** Hide each actor's cursor this long after its last call (ms, default 1500; 0 keeps it). */
|
|
649
|
+
linger?: number;
|
|
650
|
+
/** Most frames when a whole-diagram write is drawn statement by statement (default 40). */
|
|
651
|
+
maxDraftFrames?: number;
|
|
652
|
+
}
|
|
653
|
+
type DiagramPerformanceResult = {
|
|
654
|
+
ok: true;
|
|
655
|
+
document: MermaidDocument;
|
|
656
|
+
} | {
|
|
657
|
+
ok: false;
|
|
658
|
+
message: string;
|
|
659
|
+
};
|
|
660
|
+
/**
|
|
661
|
+
* Acts out agent edits on a Mermaid diagram: each actor's cursor moves to the node or edge,
|
|
662
|
+
* clicks, drags, connects and types, the edit lands, and everything one call changes is one
|
|
663
|
+
* undo step, while the user keeps editing. Calls queue per actor. A batch is checked against
|
|
664
|
+
* the diagram before the cursor moves; if the diagram changed underneath and an edit no
|
|
665
|
+
* longer applies, the call's earlier edits are rolled back and the call fails with a sentence.
|
|
666
|
+
* A whole-diagram write (`playSource`) is drawn statement by statement.
|
|
667
|
+
*/
|
|
668
|
+
declare class DiagramDirector {
|
|
669
|
+
private readonly controller;
|
|
670
|
+
private readonly options;
|
|
671
|
+
readonly presence: PresenceStore;
|
|
672
|
+
private readonly clock;
|
|
673
|
+
private readonly queue;
|
|
674
|
+
constructor(controller: DiagramController, presence: PresenceStore, options: DiagramDirectorOptions);
|
|
675
|
+
/** Acts out `ops` in order for `actor` as one undo step. */
|
|
676
|
+
perform(actor: PresenceActorInfo, ops: readonly EditOp[], label?: string): Promise<DiagramPerformanceResult>;
|
|
677
|
+
/**
|
|
678
|
+
* Replaces the diagram with `source`, drawing it statement by statement when it extends
|
|
679
|
+
* what is there (Ursula's draft playback): each frame lands, the cursor points at what
|
|
680
|
+
* appeared, and the whole write is one undo step. Otherwise it lands at once.
|
|
681
|
+
*/
|
|
682
|
+
playSource(actor: PresenceActorInfo, source: string, label?: string): Promise<DiagramPerformanceResult>;
|
|
683
|
+
/** Stores the drawn position of every node and group that has none yet. */
|
|
684
|
+
private pin;
|
|
685
|
+
/** Runs one step; returns a problem sentence when the edit can no longer be applied. */
|
|
686
|
+
private act;
|
|
687
|
+
}
|
|
688
|
+
/** Reads a document for planning without a controller (tests, previews). */
|
|
689
|
+
declare function planDiagramEdits(source: string, place: DiagramPlacement, ops: readonly EditOp[], speed?: number): DiagramPerformanceStep[][];
|
|
690
|
+
|
|
691
|
+
interface DiagramToolProviderOptions {
|
|
692
|
+
/** Provider id (unique per registry). Default `diagram`. */
|
|
693
|
+
id?: string;
|
|
694
|
+
/** Always prefix tool names with `<namespace>__`. */
|
|
695
|
+
namespace?: string;
|
|
696
|
+
/**
|
|
697
|
+
* The diagram cannot be edited: write tools are hidden and `get_diagram` says why. A
|
|
698
|
+
* string is the reason ("The report is locked"). The controller's own `readOnly` counts too.
|
|
699
|
+
*/
|
|
700
|
+
readOnly?: boolean | string | (() => boolean | string);
|
|
701
|
+
/**
|
|
702
|
+
* Where the canvas shows each node now (absolute top-left), e.g. `() => canvas.layout.positions`.
|
|
703
|
+
* When given, a move pins every node that has no stored position yet, so moving one
|
|
704
|
+
* node of an auto-laid diagram does not shift the others.
|
|
705
|
+
*/
|
|
706
|
+
getPositions?: () => Readonly<Record<string, Point>>;
|
|
707
|
+
/**
|
|
708
|
+
* Acts out every write with a visible cursor (see `DiagramDirector`): it moves to the node,
|
|
709
|
+
* clicks, drags, connects and types, and a whole-diagram load is drawn statement by
|
|
710
|
+
* statement. Each call is still one undo step. Without it, edits apply at once.
|
|
711
|
+
*/
|
|
712
|
+
director?: DiagramDirector;
|
|
713
|
+
/** Who the cursor belongs to (default `{ id: 'agent', name: 'Agent' }`). */
|
|
714
|
+
actor?: PresenceActorInfo;
|
|
715
|
+
}
|
|
716
|
+
/** What an agent needs to know about a document: ids, labels, shapes, structure. */
|
|
717
|
+
declare function describeDiagram(doc: MermaidDocument): {
|
|
718
|
+
diagnostics?: {
|
|
719
|
+
line?: number | undefined;
|
|
720
|
+
severity: "info" | "error" | "warning";
|
|
721
|
+
message: string;
|
|
722
|
+
}[] | undefined;
|
|
723
|
+
nodes: {
|
|
724
|
+
synthetic?: boolean | undefined;
|
|
725
|
+
styles?: string[] | undefined;
|
|
726
|
+
classes?: string[] | undefined;
|
|
727
|
+
parentId?: string | undefined;
|
|
728
|
+
id: string;
|
|
729
|
+
label: string;
|
|
730
|
+
shape: string;
|
|
731
|
+
}[];
|
|
732
|
+
edges: {
|
|
733
|
+
pattern: EdgePattern;
|
|
734
|
+
arrowEnd: ArrowHead;
|
|
735
|
+
label?: string | undefined;
|
|
736
|
+
id: string;
|
|
737
|
+
source: string;
|
|
738
|
+
target: string;
|
|
739
|
+
}[];
|
|
740
|
+
groups: {
|
|
741
|
+
direction?: string | undefined;
|
|
742
|
+
parentId?: string | undefined;
|
|
743
|
+
id: string;
|
|
744
|
+
label: string;
|
|
745
|
+
}[];
|
|
746
|
+
shapes: string[];
|
|
747
|
+
positions: {
|
|
748
|
+
[k: string]: {
|
|
749
|
+
x: number;
|
|
750
|
+
y: number;
|
|
751
|
+
};
|
|
752
|
+
};
|
|
753
|
+
title?: string | undefined;
|
|
754
|
+
family: DiagramFamily;
|
|
755
|
+
editable: boolean;
|
|
756
|
+
direction: string;
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* Agent tools for a Mermaid diagram (`DiagramController`), for a `ToolRegistry`: one
|
|
760
|
+
* tool per operation with strict schemas. Reads (`get_diagram`, `export_diagram_mermaid`,
|
|
761
|
+
* `find_mermaid_diagrams`) are always there; writes are hidden while the diagram is
|
|
762
|
+
* read-only. Every write is checked against the current diagram first (unknown ids,
|
|
763
|
+
* taken ids, shapes the family does not have), applies as one undo step, and returns
|
|
764
|
+
* what it created or changed. Untouched Mermaid statements are kept byte for byte.
|
|
765
|
+
*/
|
|
766
|
+
declare function createDiagramToolProvider(controller: DiagramController, options?: DiagramToolProviderOptions): AgentToolProvider;
|
|
767
|
+
|
|
768
|
+
interface DraftOptions {
|
|
769
|
+
/** Most frames to play; longer drafts are sampled evenly (default 40). */
|
|
770
|
+
maxFrames?: number;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Splits writing `target` over `current` into frames that grow the diagram
|
|
774
|
+
* statement by statement, so a whole-diagram write can be played as the
|
|
775
|
+
* diagram being drawn. Each frame is a valid prefix of `target` (it parses
|
|
776
|
+
* as the same family without diagnostics) that shows something new; the last
|
|
777
|
+
* frame is `target` itself.
|
|
778
|
+
*
|
|
779
|
+
* Returns null when `target` does not extend `current` (some existing line
|
|
780
|
+
* changes), when the family changes, or when there is nothing to grow: the
|
|
781
|
+
* write is then committed in one step.
|
|
782
|
+
*/
|
|
783
|
+
declare function draftFrames(current: string, target: string, options?: DraftOptions): string[] | null;
|
|
784
|
+
/** Ids of nodes and groups in `after` that are new or changed since `before`. */
|
|
785
|
+
declare function changedItems(before: DiagramGraph, after: DiagramGraph): string[];
|
|
786
|
+
|
|
787
|
+
export { ArrowHead, CLASS_RELATIONS, type Chain, type ClassMember, type ClassRelation, type DiagramActionResult, DiagramAdapter, DiagramController, type DiagramControllerOptions, DiagramDirector, type DiagramDirectorOptions, DiagramFamily, DiagramGraph, DiagramMeta, type DiagramPerformanceResult, type DiagramPerformanceStep, type DiagramPlacement, type DiagramState, type DiagramToolProviderOptions, type DraftOptions, EDITABLE_DIAGRAM_FAMILIES, ER_CARDINALITIES, ER_PATTERNS, EdgePattern, type EdgeSpec, EditOp, type ErAttribute, FLOWCHART_SHAPES, type FlowStatement, type FlowchartBody, type FlowchartDocument, type FoundMermaid, GraphEdge, type LineBody, type LineDocument, type LineGrammar, type LineStatement, type LinkRef, type LinkSpec, META_COMMENT_PREFIX, META_FRONTMATTER_KEY, MermaidDocument, MetaCarrier, type NodeDecl, type NodeRef, type ParseOptions, type PassthroughBody, Point, Preamble, PresenceActorInfo, PresenceClock, PresenceStore, STATE_SHAPES, type ShapeDef, type SplitSource, SupportTier, applyEdit, applyEdits, canonicalShape, changedItems, classGrammar, createDiagramToolProvider, createLineAdapter, createPassthroughAdapter, describeDiagram, detectFamily, detectFamilyFromHeader, diagramShapes, diagramSupportsGroups, draftFrames, emptyMeta, erGrammar, findMermaidSources, flowchartAdapter, formatChain, formatLink, formatNode, getDiagramAdapter, isMetaEmpty, mergeMeta, parseAttributes, parseChain, parseFlowchartSource, parseLink, parseMembers, parseMermaid, parseStatement, planDiagramEdit, planDiagramEdits, quoteLabelIfNeeded, registerDiagramAdapter, relationFor, resolveShape, serializeMermaid, serializeMeta, splitSource, splitStatements, stateGrammar, supportTierOf, validateDiagramEdit };
|