diagram-contracts 0.1.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/LICENSE +21 -0
- package/README.md +360 -0
- package/dist/cli.mjs +5170 -0
- package/dist/diagram-contracts.browser.mjs +232404 -0
- package/dist/index.d.ts +1002 -0
- package/dist/index.mjs +4970 -0
- package/package.json +88 -0
- package/tokens/theme.yaml +35 -0
- package/tokens/tokens.yaml +35 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1002 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* diagram-contracts Schema — SSoT Catalogs
|
|
5
|
+
*
|
|
6
|
+
* Faithfully transcribed from docs/diagram-vocabulary.md.
|
|
7
|
+
* TOKEN_CATALOG, PROPERTY_CATALOG, ELEMENT_CATALOG are the single
|
|
8
|
+
* source of truth for validation, documentation, and code generation.
|
|
9
|
+
*/
|
|
10
|
+
declare const TOKEN_CATALOG: {
|
|
11
|
+
readonly widthSize: readonly ["wrap", "fill"];
|
|
12
|
+
readonly heightSize: readonly ["wrap", "fill"];
|
|
13
|
+
readonly align: readonly ["start", "center", "end", "stretch"];
|
|
14
|
+
readonly justify: readonly ["start", "center", "end", "spaceBetween", "spaceAround", "spaceEvenly"];
|
|
15
|
+
readonly contentAlign: readonly ["topStart", "top", "topEnd", "start", "center", "end", "bottomStart", "bottom", "bottomEnd"];
|
|
16
|
+
readonly axis: readonly ["vertical", "horizontal"];
|
|
17
|
+
readonly shape: readonly ["rect", "roundedRect", "circle", "ellipse", "diamond", "parallelogram", "capsule", "cylinder", "hexagon", "triangle"];
|
|
18
|
+
readonly anchorPosition: readonly ["topLeft", "top", "topRight", "left", "center", "right", "bottomLeft", "bottom", "bottomRight", "auto"];
|
|
19
|
+
readonly routeStyle: readonly ["orthogonal", "straight", "curved"];
|
|
20
|
+
readonly arrowHead: readonly ["none", "arrow", "filledArrow", "diamond", "filledDiamond", "circle", "filledCircle"];
|
|
21
|
+
readonly strokeStyle: readonly ["solid", "dashed", "dotted"];
|
|
22
|
+
readonly constraintStrength: readonly ["required", "strong", "normal", "weak"];
|
|
23
|
+
readonly textPosition: readonly ["inside", "above", "below", "start", "end"];
|
|
24
|
+
readonly textOverflow: readonly ["clip", "ellipsis"];
|
|
25
|
+
readonly fontWeight: readonly ["regular", "medium", "bold"];
|
|
26
|
+
readonly imageFit: readonly ["contain", "cover", "fill", "none"];
|
|
27
|
+
readonly cellHAlign: readonly ["left", "center", "right"];
|
|
28
|
+
readonly cellVAlign: readonly ["top", "center", "bottom"];
|
|
29
|
+
readonly geometryRole: readonly ["layout", "align", "connect", "hit", "measure"];
|
|
30
|
+
readonly geometryTarget: readonly ["self", "icon"];
|
|
31
|
+
};
|
|
32
|
+
type Shape = (typeof TOKEN_CATALOG.shape)[number];
|
|
33
|
+
type AnchorPosition = (typeof TOKEN_CATALOG.anchorPosition)[number];
|
|
34
|
+
type RouteStyle = (typeof TOKEN_CATALOG.routeStyle)[number];
|
|
35
|
+
type ArrowHead = (typeof TOKEN_CATALOG.arrowHead)[number];
|
|
36
|
+
type StrokeStyle = (typeof TOKEN_CATALOG.strokeStyle)[number];
|
|
37
|
+
type ConstraintStrength = (typeof TOKEN_CATALOG.constraintStrength)[number];
|
|
38
|
+
type TextPosition = (typeof TOKEN_CATALOG.textPosition)[number];
|
|
39
|
+
type TextOverflow = (typeof TOKEN_CATALOG.textOverflow)[number];
|
|
40
|
+
type FontWeight = (typeof TOKEN_CATALOG.fontWeight)[number];
|
|
41
|
+
type ImageFit = (typeof TOKEN_CATALOG.imageFit)[number];
|
|
42
|
+
type Align = (typeof TOKEN_CATALOG.align)[number];
|
|
43
|
+
type Justify = (typeof TOKEN_CATALOG.justify)[number];
|
|
44
|
+
type ContentAlign = (typeof TOKEN_CATALOG.contentAlign)[number];
|
|
45
|
+
type Axis = (typeof TOKEN_CATALOG.axis)[number];
|
|
46
|
+
type GeometryRole = (typeof TOKEN_CATALOG.geometryRole)[number];
|
|
47
|
+
type GeometryTarget = (typeof TOKEN_CATALOG.geometryTarget)[number];
|
|
48
|
+
interface PropertyDef {
|
|
49
|
+
readonly type: string;
|
|
50
|
+
readonly category: string;
|
|
51
|
+
readonly lowering?: string;
|
|
52
|
+
readonly enum?: string;
|
|
53
|
+
readonly description?: string;
|
|
54
|
+
readonly notes?: string;
|
|
55
|
+
}
|
|
56
|
+
declare const PROPERTY_CATALOG: {
|
|
57
|
+
readonly id: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
readonly category: "identity";
|
|
60
|
+
readonly description: "Stable identifier for node/group. Used by constraints, diff, diagnostics";
|
|
61
|
+
};
|
|
62
|
+
readonly width: {
|
|
63
|
+
readonly type: "string | number";
|
|
64
|
+
readonly category: "size";
|
|
65
|
+
readonly description: "wrap / fill / fixed value";
|
|
66
|
+
};
|
|
67
|
+
readonly height: {
|
|
68
|
+
readonly type: "string | number";
|
|
69
|
+
readonly category: "size";
|
|
70
|
+
readonly description: "wrap / fill / fixed value";
|
|
71
|
+
};
|
|
72
|
+
readonly minWidth: {
|
|
73
|
+
readonly type: "number";
|
|
74
|
+
readonly category: "size";
|
|
75
|
+
};
|
|
76
|
+
readonly maxWidth: {
|
|
77
|
+
readonly type: "number | string";
|
|
78
|
+
readonly category: "size";
|
|
79
|
+
readonly notes: "fill allowed";
|
|
80
|
+
};
|
|
81
|
+
readonly minHeight: {
|
|
82
|
+
readonly type: "number";
|
|
83
|
+
readonly category: "size";
|
|
84
|
+
};
|
|
85
|
+
readonly maxHeight: {
|
|
86
|
+
readonly type: "number | string";
|
|
87
|
+
readonly category: "size";
|
|
88
|
+
readonly notes: "fill allowed";
|
|
89
|
+
};
|
|
90
|
+
readonly aspectRatio: {
|
|
91
|
+
readonly type: "number";
|
|
92
|
+
readonly category: "size";
|
|
93
|
+
readonly description: "width / height ratio";
|
|
94
|
+
};
|
|
95
|
+
readonly weight: {
|
|
96
|
+
readonly type: "number";
|
|
97
|
+
readonly category: "size";
|
|
98
|
+
readonly description: "Flex ratio in HStack / VStack";
|
|
99
|
+
};
|
|
100
|
+
readonly padding: {
|
|
101
|
+
readonly type: "string | number";
|
|
102
|
+
readonly category: "spacing";
|
|
103
|
+
readonly description: "Inner padding. Token or per-side";
|
|
104
|
+
};
|
|
105
|
+
readonly gap: {
|
|
106
|
+
readonly type: "string | number";
|
|
107
|
+
readonly category: "spacing";
|
|
108
|
+
readonly description: "Gap between children";
|
|
109
|
+
};
|
|
110
|
+
readonly align: {
|
|
111
|
+
readonly type: "string";
|
|
112
|
+
readonly category: "alignment";
|
|
113
|
+
readonly enum: "align";
|
|
114
|
+
readonly description: "Cross-axis alignment";
|
|
115
|
+
};
|
|
116
|
+
readonly justify: {
|
|
117
|
+
readonly type: "string";
|
|
118
|
+
readonly category: "alignment";
|
|
119
|
+
readonly enum: "justify";
|
|
120
|
+
readonly description: "Main-axis alignment";
|
|
121
|
+
};
|
|
122
|
+
readonly selfAlign: {
|
|
123
|
+
readonly type: "string";
|
|
124
|
+
readonly category: "alignment";
|
|
125
|
+
readonly enum: "align";
|
|
126
|
+
readonly description: "Self alignment override";
|
|
127
|
+
};
|
|
128
|
+
readonly contentAlign: {
|
|
129
|
+
readonly type: "string";
|
|
130
|
+
readonly category: "alignment";
|
|
131
|
+
readonly enum: "contentAlign";
|
|
132
|
+
readonly description: "Child content alignment (Box / Overlay)";
|
|
133
|
+
};
|
|
134
|
+
readonly axis: {
|
|
135
|
+
readonly type: "string";
|
|
136
|
+
readonly category: "alignment";
|
|
137
|
+
readonly enum: "axis";
|
|
138
|
+
readonly description: "Orientation axis";
|
|
139
|
+
};
|
|
140
|
+
readonly background: {
|
|
141
|
+
readonly type: "string";
|
|
142
|
+
readonly category: "visual";
|
|
143
|
+
readonly description: "Container background color token";
|
|
144
|
+
};
|
|
145
|
+
readonly foreground: {
|
|
146
|
+
readonly type: "string";
|
|
147
|
+
readonly category: "visual";
|
|
148
|
+
readonly description: "Foreground color token (text / icon propagation)";
|
|
149
|
+
};
|
|
150
|
+
readonly opacity: {
|
|
151
|
+
readonly type: "number";
|
|
152
|
+
readonly category: "visual";
|
|
153
|
+
readonly description: "Opacity 0..1";
|
|
154
|
+
};
|
|
155
|
+
readonly variant: {
|
|
156
|
+
readonly type: "string";
|
|
157
|
+
readonly category: "visual";
|
|
158
|
+
readonly description: "Theme variant";
|
|
159
|
+
};
|
|
160
|
+
readonly visible: {
|
|
161
|
+
readonly type: "boolean";
|
|
162
|
+
readonly category: "visual";
|
|
163
|
+
readonly description: "Visibility";
|
|
164
|
+
};
|
|
165
|
+
readonly shape: {
|
|
166
|
+
readonly type: "string";
|
|
167
|
+
readonly category: "shape-visual";
|
|
168
|
+
readonly lowering: "attribute";
|
|
169
|
+
readonly enum: "shape";
|
|
170
|
+
readonly description: "Visual shape. Layout always uses bounding rect";
|
|
171
|
+
};
|
|
172
|
+
readonly radius: {
|
|
173
|
+
readonly type: "string | number";
|
|
174
|
+
readonly category: "shape-visual";
|
|
175
|
+
readonly description: "Corner radius. Effective with shape: rect / roundedRect";
|
|
176
|
+
};
|
|
177
|
+
readonly fill: {
|
|
178
|
+
readonly type: "string";
|
|
179
|
+
readonly category: "shape-visual";
|
|
180
|
+
readonly lowering: "attribute";
|
|
181
|
+
readonly notes: "color token";
|
|
182
|
+
};
|
|
183
|
+
readonly stroke: {
|
|
184
|
+
readonly type: "string";
|
|
185
|
+
readonly category: "shape-visual";
|
|
186
|
+
readonly lowering: "attribute";
|
|
187
|
+
readonly notes: "color token";
|
|
188
|
+
};
|
|
189
|
+
readonly strokeWidth: {
|
|
190
|
+
readonly type: "number";
|
|
191
|
+
readonly category: "shape-visual";
|
|
192
|
+
readonly lowering: "attribute";
|
|
193
|
+
};
|
|
194
|
+
readonly strokeStyle: {
|
|
195
|
+
readonly type: "string";
|
|
196
|
+
readonly category: "shape-visual";
|
|
197
|
+
readonly lowering: "attribute";
|
|
198
|
+
readonly enum: "strokeStyle";
|
|
199
|
+
};
|
|
200
|
+
readonly shadow: {
|
|
201
|
+
readonly type: "string";
|
|
202
|
+
readonly category: "shape-visual";
|
|
203
|
+
readonly description: "Shadow token";
|
|
204
|
+
};
|
|
205
|
+
readonly text: {
|
|
206
|
+
readonly type: "string";
|
|
207
|
+
readonly category: "text";
|
|
208
|
+
readonly description: "Text content (normalized from child text nodes in IR)";
|
|
209
|
+
};
|
|
210
|
+
readonly textStyle: {
|
|
211
|
+
readonly type: "string";
|
|
212
|
+
readonly category: "text";
|
|
213
|
+
readonly description: "Typography token";
|
|
214
|
+
};
|
|
215
|
+
readonly textAlign: {
|
|
216
|
+
readonly type: "string";
|
|
217
|
+
readonly category: "text";
|
|
218
|
+
readonly description: "Text alignment (start / center / end)";
|
|
219
|
+
};
|
|
220
|
+
readonly fontSize: {
|
|
221
|
+
readonly type: "string | number";
|
|
222
|
+
readonly category: "text";
|
|
223
|
+
readonly description: "Font size";
|
|
224
|
+
};
|
|
225
|
+
readonly fontWeight: {
|
|
226
|
+
readonly type: "string";
|
|
227
|
+
readonly category: "text";
|
|
228
|
+
readonly enum: "fontWeight";
|
|
229
|
+
};
|
|
230
|
+
readonly lineLimit: {
|
|
231
|
+
readonly type: "number | string";
|
|
232
|
+
readonly category: "text";
|
|
233
|
+
readonly description: "Max lines. 'none' for unlimited";
|
|
234
|
+
};
|
|
235
|
+
readonly textOverflow: {
|
|
236
|
+
readonly type: "string";
|
|
237
|
+
readonly category: "text";
|
|
238
|
+
readonly enum: "textOverflow";
|
|
239
|
+
};
|
|
240
|
+
readonly textPosition: {
|
|
241
|
+
readonly type: "string";
|
|
242
|
+
readonly category: "text";
|
|
243
|
+
readonly lowering: "attribute";
|
|
244
|
+
readonly enum: "textPosition";
|
|
245
|
+
readonly description: "Label position on connector";
|
|
246
|
+
};
|
|
247
|
+
readonly geometry: {
|
|
248
|
+
readonly type: "object";
|
|
249
|
+
readonly category: "geometry";
|
|
250
|
+
readonly description: "Geometry role mapping: { layout, align, connect, hit, measure } → target (self | icon | child id)";
|
|
251
|
+
};
|
|
252
|
+
readonly anchor: {
|
|
253
|
+
readonly type: "string";
|
|
254
|
+
readonly category: "constraint";
|
|
255
|
+
readonly lowering: "none";
|
|
256
|
+
readonly description: "Reference target for alignment; other targets become movers";
|
|
257
|
+
};
|
|
258
|
+
readonly from: {
|
|
259
|
+
readonly type: "string";
|
|
260
|
+
readonly category: "connector";
|
|
261
|
+
readonly lowering: "attribute";
|
|
262
|
+
readonly description: "Source node id or nodeId:role reference";
|
|
263
|
+
};
|
|
264
|
+
readonly to: {
|
|
265
|
+
readonly type: "string";
|
|
266
|
+
readonly category: "connector";
|
|
267
|
+
readonly lowering: "attribute";
|
|
268
|
+
readonly description: "Target node id or nodeId:role reference";
|
|
269
|
+
};
|
|
270
|
+
readonly fromAnchor: {
|
|
271
|
+
readonly type: "string";
|
|
272
|
+
readonly category: "connector";
|
|
273
|
+
readonly lowering: "attribute";
|
|
274
|
+
readonly enum: "anchorPosition";
|
|
275
|
+
};
|
|
276
|
+
readonly toAnchor: {
|
|
277
|
+
readonly type: "string";
|
|
278
|
+
readonly category: "connector";
|
|
279
|
+
readonly lowering: "attribute";
|
|
280
|
+
readonly enum: "anchorPosition";
|
|
281
|
+
};
|
|
282
|
+
readonly route: {
|
|
283
|
+
readonly type: "string";
|
|
284
|
+
readonly category: "connector";
|
|
285
|
+
readonly lowering: "attribute";
|
|
286
|
+
readonly enum: "routeStyle";
|
|
287
|
+
};
|
|
288
|
+
readonly cornerRadius: {
|
|
289
|
+
readonly type: "number";
|
|
290
|
+
readonly category: "connector";
|
|
291
|
+
readonly lowering: "attribute";
|
|
292
|
+
readonly description: "Corner rounding for orthogonal routing";
|
|
293
|
+
};
|
|
294
|
+
readonly curvature: {
|
|
295
|
+
readonly type: "number";
|
|
296
|
+
readonly category: "connector";
|
|
297
|
+
readonly lowering: "attribute";
|
|
298
|
+
readonly description: "Control point distance ratio for curved routing (0.1..1.0, default 0.33)";
|
|
299
|
+
};
|
|
300
|
+
readonly startArrow: {
|
|
301
|
+
readonly type: "string";
|
|
302
|
+
readonly category: "connector";
|
|
303
|
+
readonly lowering: "attribute";
|
|
304
|
+
readonly enum: "arrowHead";
|
|
305
|
+
};
|
|
306
|
+
readonly endArrow: {
|
|
307
|
+
readonly type: "string";
|
|
308
|
+
readonly category: "connector";
|
|
309
|
+
readonly lowering: "attribute";
|
|
310
|
+
readonly enum: "arrowHead";
|
|
311
|
+
};
|
|
312
|
+
readonly arrowSize: {
|
|
313
|
+
readonly type: "number";
|
|
314
|
+
readonly category: "connector";
|
|
315
|
+
readonly lowering: "attribute";
|
|
316
|
+
readonly description: "Arrow marker scale factor (default 1)";
|
|
317
|
+
};
|
|
318
|
+
readonly strokeDasharray: {
|
|
319
|
+
readonly type: "string";
|
|
320
|
+
readonly category: "shape-visual";
|
|
321
|
+
readonly lowering: "attribute";
|
|
322
|
+
readonly description: "Custom SVG stroke-dasharray. Overrides strokeStyle";
|
|
323
|
+
};
|
|
324
|
+
readonly targets: {
|
|
325
|
+
readonly type: "array";
|
|
326
|
+
readonly category: "constraint";
|
|
327
|
+
readonly lowering: "none";
|
|
328
|
+
readonly notes: "array<string>. Supports nodeId:role syntax for geometry role references";
|
|
329
|
+
};
|
|
330
|
+
readonly mover: {
|
|
331
|
+
readonly type: "string";
|
|
332
|
+
readonly category: "constraint";
|
|
333
|
+
readonly lowering: "none";
|
|
334
|
+
};
|
|
335
|
+
readonly strength: {
|
|
336
|
+
readonly type: "string";
|
|
337
|
+
readonly category: "constraint";
|
|
338
|
+
readonly lowering: "none";
|
|
339
|
+
readonly enum: "constraintStrength";
|
|
340
|
+
};
|
|
341
|
+
readonly strategy: {
|
|
342
|
+
readonly type: "string";
|
|
343
|
+
readonly category: "constraint";
|
|
344
|
+
readonly lowering: "none";
|
|
345
|
+
readonly description: "Size equalization strategy: max | min | first";
|
|
346
|
+
};
|
|
347
|
+
readonly colAlign: {
|
|
348
|
+
readonly type: "string";
|
|
349
|
+
readonly category: "alignment";
|
|
350
|
+
readonly enum: "cellHAlign";
|
|
351
|
+
readonly description: "Cell horizontal alignment (left / center / right)";
|
|
352
|
+
};
|
|
353
|
+
readonly rowAlign: {
|
|
354
|
+
readonly type: "string";
|
|
355
|
+
readonly category: "alignment";
|
|
356
|
+
readonly enum: "cellVAlign";
|
|
357
|
+
readonly description: "Cell vertical alignment (top / center / bottom)";
|
|
358
|
+
};
|
|
359
|
+
readonly headerRows: {
|
|
360
|
+
readonly type: "number";
|
|
361
|
+
readonly category: "structure";
|
|
362
|
+
readonly description: "Number of header rows (visual distinction)";
|
|
363
|
+
};
|
|
364
|
+
readonly src: {
|
|
365
|
+
readonly type: "string";
|
|
366
|
+
readonly category: "asset";
|
|
367
|
+
readonly description: "Image / SVG source reference";
|
|
368
|
+
};
|
|
369
|
+
readonly fit: {
|
|
370
|
+
readonly type: "string";
|
|
371
|
+
readonly category: "asset";
|
|
372
|
+
readonly enum: "imageFit";
|
|
373
|
+
readonly description: "Fit method";
|
|
374
|
+
};
|
|
375
|
+
readonly name: {
|
|
376
|
+
readonly type: "string";
|
|
377
|
+
readonly category: "asset";
|
|
378
|
+
readonly lowering: "attribute";
|
|
379
|
+
readonly description: "Icon token or asset name";
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
type PropertyName = keyof typeof PROPERTY_CATALOG;
|
|
383
|
+
interface ElementDef {
|
|
384
|
+
readonly tier: "core" | "optional" | "extension";
|
|
385
|
+
readonly category: string;
|
|
386
|
+
readonly properties: readonly string[];
|
|
387
|
+
readonly children: {
|
|
388
|
+
readonly kind: "list";
|
|
389
|
+
readonly items: readonly string[];
|
|
390
|
+
} | {
|
|
391
|
+
readonly kind: "any";
|
|
392
|
+
} | {
|
|
393
|
+
readonly kind: "none";
|
|
394
|
+
} | {
|
|
395
|
+
readonly kind: "text";
|
|
396
|
+
};
|
|
397
|
+
readonly notes?: string;
|
|
398
|
+
}
|
|
399
|
+
declare const ELEMENT_CATALOG: {
|
|
400
|
+
readonly document: {
|
|
401
|
+
readonly tier: "core";
|
|
402
|
+
readonly category: "structure";
|
|
403
|
+
readonly properties: readonly ["id", "width", "height", "padding", "background", "variant"];
|
|
404
|
+
readonly children: {
|
|
405
|
+
readonly kind: "list";
|
|
406
|
+
readonly items: readonly ["hstack", "vstack", "overlay", "grid", "flow", "absolute", "box", "group", "table", "connector", "alignConstraint", "equalizeWidth", "equalizeHeight", "minGap", "keepInsideConstraint", "orderConstraint"];
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
readonly group: {
|
|
410
|
+
readonly tier: "core";
|
|
411
|
+
readonly category: "structure";
|
|
412
|
+
readonly properties: readonly ["id", "visible", "padding", "gap", "background", "opacity", "geometry", "variant"];
|
|
413
|
+
readonly children: {
|
|
414
|
+
readonly kind: "any";
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
readonly box: {
|
|
418
|
+
readonly tier: "core";
|
|
419
|
+
readonly category: "layout";
|
|
420
|
+
readonly properties: readonly ["id", "visible", "width", "height", "minWidth", "maxWidth", "minHeight", "maxHeight", "padding", "gap", "contentAlign", "foreground", "fill", "stroke", "strokeWidth", "strokeStyle", "radius", "shadow", "opacity", "shape", "selfAlign", "geometry", "variant"];
|
|
421
|
+
readonly children: {
|
|
422
|
+
readonly kind: "any";
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
readonly hstack: {
|
|
426
|
+
readonly tier: "core";
|
|
427
|
+
readonly category: "layout";
|
|
428
|
+
readonly properties: readonly ["id", "visible", "gap", "align", "justify", "padding", "width", "height", "minWidth", "maxWidth", "minHeight", "maxHeight", "geometry", "variant"];
|
|
429
|
+
readonly children: {
|
|
430
|
+
readonly kind: "any";
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
readonly vstack: {
|
|
434
|
+
readonly tier: "core";
|
|
435
|
+
readonly category: "layout";
|
|
436
|
+
readonly properties: readonly ["id", "visible", "gap", "align", "justify", "padding", "width", "height", "minWidth", "maxWidth", "minHeight", "maxHeight", "geometry", "variant"];
|
|
437
|
+
readonly children: {
|
|
438
|
+
readonly kind: "any";
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
readonly overlay: {
|
|
442
|
+
readonly tier: "core";
|
|
443
|
+
readonly category: "layout";
|
|
444
|
+
readonly properties: readonly ["id", "visible", "gap", "contentAlign", "padding", "width", "height", "background", "variant"];
|
|
445
|
+
readonly children: {
|
|
446
|
+
readonly kind: "any";
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
readonly grid: {
|
|
450
|
+
readonly tier: "core";
|
|
451
|
+
readonly category: "layout";
|
|
452
|
+
readonly properties: readonly ["id", "visible", "gap", "align", "justify", "padding", "width", "height", "minWidth", "maxWidth", "minHeight", "maxHeight", "variant"];
|
|
453
|
+
readonly children: {
|
|
454
|
+
readonly kind: "any";
|
|
455
|
+
};
|
|
456
|
+
readonly notes: "Track definitions normalized as graph fragments. v1 starts with even tracks";
|
|
457
|
+
};
|
|
458
|
+
readonly flow: {
|
|
459
|
+
readonly tier: "core";
|
|
460
|
+
readonly category: "layout";
|
|
461
|
+
readonly properties: readonly ["id", "visible", "gap", "padding", "width", "height", "minWidth", "maxWidth", "align", "variant"];
|
|
462
|
+
readonly children: {
|
|
463
|
+
readonly kind: "any";
|
|
464
|
+
};
|
|
465
|
+
};
|
|
466
|
+
readonly absolute: {
|
|
467
|
+
readonly tier: "optional";
|
|
468
|
+
readonly category: "layout";
|
|
469
|
+
readonly properties: readonly ["id", "visible", "padding", "width", "height", "variant"];
|
|
470
|
+
readonly children: {
|
|
471
|
+
readonly kind: "any";
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
readonly spacer: {
|
|
475
|
+
readonly tier: "core";
|
|
476
|
+
readonly category: "layout";
|
|
477
|
+
readonly properties: readonly ["id", "width", "height", "weight"];
|
|
478
|
+
readonly children: {
|
|
479
|
+
readonly kind: "none";
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
readonly divider: {
|
|
483
|
+
readonly tier: "core";
|
|
484
|
+
readonly category: "layout";
|
|
485
|
+
readonly properties: readonly ["id", "axis", "stroke", "strokeWidth", "strokeStyle"];
|
|
486
|
+
readonly children: {
|
|
487
|
+
readonly kind: "none";
|
|
488
|
+
};
|
|
489
|
+
};
|
|
490
|
+
readonly text: {
|
|
491
|
+
readonly tier: "core";
|
|
492
|
+
readonly category: "text";
|
|
493
|
+
readonly properties: readonly ["id", "text", "visible", "textStyle", "textAlign", "fontSize", "fontWeight", "lineLimit", "textOverflow", "foreground", "background", "opacity", "padding", "variant"];
|
|
494
|
+
readonly children: {
|
|
495
|
+
readonly kind: "text";
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
readonly label: {
|
|
499
|
+
readonly tier: "core";
|
|
500
|
+
readonly category: "text";
|
|
501
|
+
readonly properties: readonly ["id", "text", "visible", "textStyle", "textAlign", "fontSize", "fontWeight", "textPosition", "foreground", "background", "opacity", "padding", "radius", "variant"];
|
|
502
|
+
readonly children: {
|
|
503
|
+
readonly kind: "text";
|
|
504
|
+
};
|
|
505
|
+
};
|
|
506
|
+
readonly image: {
|
|
507
|
+
readonly tier: "core";
|
|
508
|
+
readonly category: "media";
|
|
509
|
+
readonly properties: readonly ["id", "visible", "src", "fit", "width", "height", "aspectRatio", "radius", "opacity", "variant"];
|
|
510
|
+
readonly children: {
|
|
511
|
+
readonly kind: "none";
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
readonly icon: {
|
|
515
|
+
readonly tier: "core";
|
|
516
|
+
readonly category: "media";
|
|
517
|
+
readonly properties: readonly ["id", "visible", "name", "foreground", "opacity", "variant"];
|
|
518
|
+
readonly children: {
|
|
519
|
+
readonly kind: "none";
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
readonly svgAsset: {
|
|
523
|
+
readonly tier: "core";
|
|
524
|
+
readonly category: "media";
|
|
525
|
+
readonly properties: readonly ["id", "visible", "src", "width", "height", "opacity", "variant"];
|
|
526
|
+
readonly children: {
|
|
527
|
+
readonly kind: "none";
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
readonly table: {
|
|
531
|
+
readonly tier: "core";
|
|
532
|
+
readonly category: "layout";
|
|
533
|
+
readonly properties: readonly ["id", "visible", "width", "height", "padding", "gap", "headerRows", "fill", "stroke", "strokeWidth", "variant"];
|
|
534
|
+
readonly children: {
|
|
535
|
+
readonly kind: "list";
|
|
536
|
+
readonly items: readonly ["row"];
|
|
537
|
+
};
|
|
538
|
+
readonly notes: "Table layout. Column widths equalized via columnWidthResolve (max of cell intrinsic widths). Row heights equalized via rowHeightResolve. No special table algorithm.";
|
|
539
|
+
};
|
|
540
|
+
readonly row: {
|
|
541
|
+
readonly tier: "core";
|
|
542
|
+
readonly category: "layout";
|
|
543
|
+
readonly properties: readonly ["id", "visible", "fill", "variant"];
|
|
544
|
+
readonly children: {
|
|
545
|
+
readonly kind: "list";
|
|
546
|
+
readonly items: readonly ["cell"];
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
readonly cell: {
|
|
550
|
+
readonly tier: "core";
|
|
551
|
+
readonly category: "layout";
|
|
552
|
+
readonly properties: readonly ["id", "visible", "width", "height", "padding", "colAlign", "rowAlign", "fill", "stroke", "strokeWidth", "foreground", "variant"];
|
|
553
|
+
readonly children: {
|
|
554
|
+
readonly kind: "any";
|
|
555
|
+
};
|
|
556
|
+
readonly notes: "Table cell. colAlign (left/center/right) and rowAlign (top/center/bottom) control content positioning within the cell";
|
|
557
|
+
};
|
|
558
|
+
readonly connector: {
|
|
559
|
+
readonly tier: "core";
|
|
560
|
+
readonly category: "connector";
|
|
561
|
+
readonly properties: readonly ["id", "visible", "from", "to", "fromAnchor", "toAnchor", "route", "cornerRadius", "curvature", "startArrow", "endArrow", "arrowSize", "stroke", "strokeWidth", "strokeStyle", "strokeDasharray", "opacity", "variant"];
|
|
562
|
+
readonly children: {
|
|
563
|
+
readonly kind: "list";
|
|
564
|
+
readonly items: readonly ["label"];
|
|
565
|
+
};
|
|
566
|
+
readonly notes: "Child Labels are annotation text on the connector. Label.textPosition specifies position";
|
|
567
|
+
};
|
|
568
|
+
readonly alignConstraint: {
|
|
569
|
+
readonly tier: "core";
|
|
570
|
+
readonly category: "constraint";
|
|
571
|
+
readonly properties: readonly ["id", "targets", "axis", "align", "anchor", "mover", "strength"];
|
|
572
|
+
readonly children: {
|
|
573
|
+
readonly kind: "none";
|
|
574
|
+
};
|
|
575
|
+
readonly notes: "axis: vertical + align: center = centerX alignment. axis: horizontal + align: center = centerY alignment";
|
|
576
|
+
};
|
|
577
|
+
readonly equalizeWidth: {
|
|
578
|
+
readonly tier: "core";
|
|
579
|
+
readonly category: "constraint";
|
|
580
|
+
readonly properties: readonly ["id", "targets", "strategy", "strength"];
|
|
581
|
+
readonly children: {
|
|
582
|
+
readonly kind: "none";
|
|
583
|
+
};
|
|
584
|
+
readonly notes: "Equalize widths of all targets. strategy: max (default) | min | first";
|
|
585
|
+
};
|
|
586
|
+
readonly equalizeHeight: {
|
|
587
|
+
readonly tier: "core";
|
|
588
|
+
readonly category: "constraint";
|
|
589
|
+
readonly properties: readonly ["id", "targets", "strategy", "strength"];
|
|
590
|
+
readonly children: {
|
|
591
|
+
readonly kind: "none";
|
|
592
|
+
};
|
|
593
|
+
readonly notes: "Equalize heights of all targets. strategy: max (default) | min | first";
|
|
594
|
+
};
|
|
595
|
+
readonly minGap: {
|
|
596
|
+
readonly tier: "optional";
|
|
597
|
+
readonly category: "constraint";
|
|
598
|
+
readonly properties: readonly ["id", "targets", "gap", "axis", "strength"];
|
|
599
|
+
readonly children: {
|
|
600
|
+
readonly kind: "none";
|
|
601
|
+
};
|
|
602
|
+
};
|
|
603
|
+
readonly keepInsideConstraint: {
|
|
604
|
+
readonly tier: "optional";
|
|
605
|
+
readonly category: "constraint";
|
|
606
|
+
readonly properties: readonly ["id", "targets", "strength"];
|
|
607
|
+
readonly children: {
|
|
608
|
+
readonly kind: "none";
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
readonly orderConstraint: {
|
|
612
|
+
readonly tier: "core";
|
|
613
|
+
readonly category: "constraint";
|
|
614
|
+
readonly properties: readonly ["id", "targets", "axis", "strength"];
|
|
615
|
+
readonly children: {
|
|
616
|
+
readonly kind: "none";
|
|
617
|
+
};
|
|
618
|
+
readonly notes: "targets array order is source order. axis: vertical = top-to-bottom, horizontal = left-to-right";
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
type IrKind = keyof typeof ELEMENT_CATALOG;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Layout IR — Intermediate Representation types and parser
|
|
625
|
+
*
|
|
626
|
+
* Layout IR is the JSON-based intermediate representation that all input
|
|
627
|
+
* formats (Draw Text, Draw TSX, direct JSON) converge to. See docs/diagram-contracts.md §4.2.
|
|
628
|
+
*/
|
|
629
|
+
|
|
630
|
+
interface IrNode {
|
|
631
|
+
kind: IrKind;
|
|
632
|
+
id?: string;
|
|
633
|
+
props: Record<string, unknown>;
|
|
634
|
+
children?: IrNode[];
|
|
635
|
+
}
|
|
636
|
+
declare const IrNodeSchema: z.ZodType<any>;
|
|
637
|
+
declare function parseIr(json: unknown): IrNode;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Theme / Token Parser
|
|
641
|
+
*
|
|
642
|
+
* Parses tokens.yaml and theme.yaml into typed IR structures.
|
|
643
|
+
* See docs/diagram-vocabulary.md §Theme & Token Configuration.
|
|
644
|
+
*/
|
|
645
|
+
interface TokenEntry {
|
|
646
|
+
$type: "color" | "dimension" | "fontFamily" | "fontWeight" | "number" | "shadow" | "string";
|
|
647
|
+
$value: string;
|
|
648
|
+
}
|
|
649
|
+
type TokenIR = {
|
|
650
|
+
[key: string]: TokenEntry | TokenIR;
|
|
651
|
+
};
|
|
652
|
+
interface ThemeIR {
|
|
653
|
+
defaults: Record<string, Record<string, unknown>>;
|
|
654
|
+
variants: Record<string, Record<string, Record<string, unknown>>>;
|
|
655
|
+
}
|
|
656
|
+
declare function parseTokens(yaml: string): TokenIR;
|
|
657
|
+
declare function parseTheme(yaml: string): ThemeIR;
|
|
658
|
+
declare function resolveTokenRef(ref: string, tokens: TokenIR): string;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* IR Normalizer — Phase 2
|
|
662
|
+
*
|
|
663
|
+
* Takes raw Layout IR + ThemeIR + TokenIR and produces a normalized IR
|
|
664
|
+
* ready for the constraint graph. See docs/diagram-contracts.md §4.3.
|
|
665
|
+
*/
|
|
666
|
+
|
|
667
|
+
interface NormalizeOptions {
|
|
668
|
+
tokens: TokenIR;
|
|
669
|
+
theme: ThemeIR;
|
|
670
|
+
}
|
|
671
|
+
type GeometryRoleMap = Record<string, string>;
|
|
672
|
+
interface NormalizeResult {
|
|
673
|
+
ir: IrNode;
|
|
674
|
+
diagnostics: Diagnostic[];
|
|
675
|
+
geometryRegistry: Map<string, GeometryRoleMap>;
|
|
676
|
+
}
|
|
677
|
+
interface Diagnostic {
|
|
678
|
+
level: "error" | "warning";
|
|
679
|
+
message: string;
|
|
680
|
+
path: string;
|
|
681
|
+
}
|
|
682
|
+
declare function kindToPascal(kind: string): string;
|
|
683
|
+
declare function normalize(ir: IrNode, options: NormalizeOptions): NormalizeResult;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Draw Text Parser — converts tokenized Draw Text into Layout IR (IrNode tree).
|
|
687
|
+
*
|
|
688
|
+
* Handles direction declarations, node definitions, edges (visible + invisible),
|
|
689
|
+
* subgraph nesting, chain edges, classDef, and @ directives.
|
|
690
|
+
*/
|
|
691
|
+
|
|
692
|
+
interface ParseResult {
|
|
693
|
+
ir: IrNode;
|
|
694
|
+
diagnostics: Diagnostic[];
|
|
695
|
+
}
|
|
696
|
+
declare function parseDrawText(source: string): ParseResult;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Draw TSX Compiler
|
|
700
|
+
*
|
|
701
|
+
* Statically analyses `.draw.tsx` source using the TypeScript compiler API
|
|
702
|
+
* and produces Layout IR (IrNode). No JSX runtime is involved.
|
|
703
|
+
*
|
|
704
|
+
* Supports component definitions (exported functions returning JSX) that are
|
|
705
|
+
* expanded at compile time into primitive IR nodes.
|
|
706
|
+
*/
|
|
707
|
+
|
|
708
|
+
interface CompileResult {
|
|
709
|
+
ir: IrNode;
|
|
710
|
+
diagnostics: Diagnostic[];
|
|
711
|
+
}
|
|
712
|
+
interface CompileOptions {
|
|
713
|
+
/** Resolve an import specifier to source code string. fromFile is the importing file's specifier for nested resolution. */
|
|
714
|
+
resolveImport?: (specifier: string, fromFile?: string) => string | undefined;
|
|
715
|
+
/** Pre-registered component definitions. */
|
|
716
|
+
components?: Map<string, ComponentDef>;
|
|
717
|
+
}
|
|
718
|
+
interface ComponentDef {
|
|
719
|
+
name: string;
|
|
720
|
+
paramNames: Set<string>;
|
|
721
|
+
template: IrNode;
|
|
722
|
+
}
|
|
723
|
+
declare function compileDrawTsx(source: string, options?: CompileOptions): CompileResult;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Default Tokens & Theme — bundled as embedded YAML strings
|
|
727
|
+
*
|
|
728
|
+
* Provides default values so that CLI and convenience functions
|
|
729
|
+
* produce styled output even without explicit --tokens/--theme flags.
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
declare function defaultTokens(): TokenIR;
|
|
733
|
+
declare function defaultTheme(): ThemeIR;
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Resolved Layout Artifact Types
|
|
737
|
+
*
|
|
738
|
+
* Output of the layout engine after graph evaluation.
|
|
739
|
+
* See docs/diagram-contracts.md §12.1.
|
|
740
|
+
*/
|
|
741
|
+
|
|
742
|
+
interface Rect {
|
|
743
|
+
x: number;
|
|
744
|
+
y: number;
|
|
745
|
+
width: number;
|
|
746
|
+
height: number;
|
|
747
|
+
}
|
|
748
|
+
interface ResolvedNode {
|
|
749
|
+
id: string;
|
|
750
|
+
kind: IrKind;
|
|
751
|
+
rect: Rect;
|
|
752
|
+
worldRect: Rect;
|
|
753
|
+
styles: Record<string, string | number>;
|
|
754
|
+
textLines?: string[];
|
|
755
|
+
textBaseline?: number;
|
|
756
|
+
textX?: number;
|
|
757
|
+
textAnchor?: "start" | "middle" | "end";
|
|
758
|
+
connectorPath?: string;
|
|
759
|
+
children?: ResolvedNode[];
|
|
760
|
+
}
|
|
761
|
+
interface ResolvedArtifact {
|
|
762
|
+
viewBox: Rect;
|
|
763
|
+
nodes: ResolvedNode[];
|
|
764
|
+
background?: string;
|
|
765
|
+
fontFamily?: string;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Shape Renderers — SVG element generation for each shape enum value
|
|
770
|
+
*
|
|
771
|
+
* All shapes fit within the given bounding Rect.
|
|
772
|
+
* See docs/diagram-vocabulary.md §shape enum reference.
|
|
773
|
+
*/
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Render an SVG shape element fitting within the given Rect.
|
|
777
|
+
* Falls back to `rect` for unknown shape values.
|
|
778
|
+
*/
|
|
779
|
+
declare function renderShape(shape: string, rect: Rect, styles: Record<string, string | number>): string;
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Connector Path Renderer — SVG path/line for connectors + arrow markers
|
|
783
|
+
*
|
|
784
|
+
* See docs/diagram-vocabulary.md §connector / §arrowHead.
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Generate empty `<defs>` block (markers are now created dynamically per color).
|
|
789
|
+
*/
|
|
790
|
+
declare function renderArrowMarkers(): string;
|
|
791
|
+
/**
|
|
792
|
+
* Render a connector as an SVG `<path>` with optional marker references.
|
|
793
|
+
*/
|
|
794
|
+
declare function renderConnector(node: ResolvedNode): string;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Text Renderer — SVG `<text>` with `<tspan>` per line
|
|
798
|
+
*
|
|
799
|
+
* Reads fully resolved text layout from the artifact.
|
|
800
|
+
*/
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Render text lines as an SVG `<text>` element with `<tspan>` children.
|
|
804
|
+
*/
|
|
805
|
+
declare function renderText(node: ResolvedNode): string;
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Icon Registry types — provider-based icon resolution.
|
|
809
|
+
*/
|
|
810
|
+
interface IconPack {
|
|
811
|
+
readonly provider: string;
|
|
812
|
+
resolve(name: string): string | undefined;
|
|
813
|
+
list(): string[];
|
|
814
|
+
}
|
|
815
|
+
interface IconRegistry {
|
|
816
|
+
register(pack: IconPack): void;
|
|
817
|
+
resolve(provider: string, name: string): string | undefined;
|
|
818
|
+
resolveQualified(qualifiedName: string): string | undefined;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* SvgComposer — main SVG renderer
|
|
823
|
+
*
|
|
824
|
+
* Composes ResolvedArtifact into a complete SVG string.
|
|
825
|
+
* Pure string generation — no DOM dependency.
|
|
826
|
+
* See docs/diagram-contracts.md §12.
|
|
827
|
+
*/
|
|
828
|
+
|
|
829
|
+
interface RenderOptions {
|
|
830
|
+
iconRegistry?: IconRegistry;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Render a ResolvedArtifact to a complete SVG string.
|
|
834
|
+
*/
|
|
835
|
+
declare function renderSvg(artifact: ResolvedArtifact, options?: RenderOptions): string;
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* IconRegistry — provider-based icon resolution.
|
|
839
|
+
*
|
|
840
|
+
* Resolves qualified names like "aws:lambda" by splitting on ":"
|
|
841
|
+
* and delegating to the registered IconPack for that provider.
|
|
842
|
+
*/
|
|
843
|
+
|
|
844
|
+
declare function createIconRegistry(): IconRegistry;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* AWS Icon Pack — resolves AWS service short names to SVG content
|
|
848
|
+
* using the `aws-icons` npm package.
|
|
849
|
+
*
|
|
850
|
+
* `aws-icons` is an optional peer dependency. If not installed,
|
|
851
|
+
* resolve() returns undefined (graceful degradation).
|
|
852
|
+
*/
|
|
853
|
+
|
|
854
|
+
declare function createAwsIconPack(): IconPack;
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Graph Primitives — Constraint Dependency Graph types
|
|
858
|
+
*
|
|
859
|
+
* See docs/diagram-contracts.md §5.
|
|
860
|
+
*/
|
|
861
|
+
type SlotKind = "intrinsicWidth" | "intrinsicHeight" | "availableWidth" | "availableHeight" | "resolvedWidth" | "resolvedHeight" | "localX" | "localY" | "baseLocalX" | "baseLocalY" | "worldX" | "worldY" | "contentWidth" | "contentHeight" | "anchorX" | "anchorY" | "textBaseline" | "textX" | "textAnchor" | "connectorPath";
|
|
862
|
+
interface ValueSlot {
|
|
863
|
+
id: string;
|
|
864
|
+
value?: number;
|
|
865
|
+
nodeId: string;
|
|
866
|
+
slotKind: SlotKind;
|
|
867
|
+
}
|
|
868
|
+
type OpKind = "sum" | "max" | "clamp" | "resolveSize" | "measureText" | "stackPosition" | "stackCompose" | "suffixShiftDelta" | "alignDelta" | "anchorPoint" | "connectorPath" | "identity" | "subtract" | "add" | "constant" | "copy" | "crossAlign" | "columnWidthResolve" | "columnFill" | "rowHeightResolve";
|
|
869
|
+
interface OperationNode {
|
|
870
|
+
id: string;
|
|
871
|
+
op: OpKind;
|
|
872
|
+
inputs: string[];
|
|
873
|
+
outputs: string[];
|
|
874
|
+
compute: (inputs: number[]) => number[];
|
|
875
|
+
}
|
|
876
|
+
type Priority = "required" | "strong" | "normal" | "weak";
|
|
877
|
+
interface CandidateEdge {
|
|
878
|
+
targetSlotId: string;
|
|
879
|
+
value?: number;
|
|
880
|
+
source: string;
|
|
881
|
+
priority: Priority;
|
|
882
|
+
operationId?: string;
|
|
883
|
+
}
|
|
884
|
+
type ResolverPolicy = "requiredAllEqual" | "highestPriority" | "max" | "sum";
|
|
885
|
+
interface SlotResolverNode {
|
|
886
|
+
slotId: string;
|
|
887
|
+
policy: ResolverPolicy;
|
|
888
|
+
}
|
|
889
|
+
interface DependencyEdge {
|
|
890
|
+
fromSlotId: string;
|
|
891
|
+
toOperationId: string;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* Graph Evaluator — builds and evaluates the constraint dependency graph
|
|
896
|
+
*
|
|
897
|
+
* See docs/diagram-contracts.md §10.
|
|
898
|
+
*/
|
|
899
|
+
|
|
900
|
+
interface LayoutGraph {
|
|
901
|
+
slots: Map<string, ValueSlot>;
|
|
902
|
+
operations: Map<string, OperationNode>;
|
|
903
|
+
candidates: CandidateEdge[];
|
|
904
|
+
candidatesBySlot: Map<string, CandidateEdge[]>;
|
|
905
|
+
candidatesByOperation: Map<string, CandidateEdge[]>;
|
|
906
|
+
resolvers: Map<string, SlotResolverNode>;
|
|
907
|
+
dependencies: DependencyEdge[];
|
|
908
|
+
parentMap: Map<string, string>;
|
|
909
|
+
nodeKindMap: Map<string, string>;
|
|
910
|
+
childrenOrderMap: Map<string, string[]>;
|
|
911
|
+
diagnostics: {
|
|
912
|
+
level: "error" | "warning";
|
|
913
|
+
message: string;
|
|
914
|
+
path: string;
|
|
915
|
+
}[];
|
|
916
|
+
}
|
|
917
|
+
interface EvaluateResult {
|
|
918
|
+
artifact: ResolvedArtifact;
|
|
919
|
+
diagnostics: Diagnostic[];
|
|
920
|
+
}
|
|
921
|
+
declare function createGraph(): LayoutGraph;
|
|
922
|
+
declare function evaluate(graph: LayoutGraph, ir: IrNode): EvaluateResult;
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Slot Resolver — resolves multiple candidate values for a single slot
|
|
926
|
+
*
|
|
927
|
+
* See docs/diagram-contracts.md §5.5.
|
|
928
|
+
*/
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* Resolve a set of candidates for a slot according to the given policy.
|
|
932
|
+
* Returns undefined if no candidates are present.
|
|
933
|
+
*/
|
|
934
|
+
declare function resolveSlot(candidates: CandidateEdge[], policy: ResolverPolicy): number | undefined;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Fragment Factories — IR kind → Graph fragment mapping
|
|
938
|
+
*
|
|
939
|
+
* Delegates to rule-engine.ts for all fragment generation.
|
|
940
|
+
* See docs/diagram-contracts.md §6.
|
|
941
|
+
*/
|
|
942
|
+
|
|
943
|
+
type FragmentFactory = (node: IrNode, graph: LayoutGraph, parentId?: string) => void;
|
|
944
|
+
|
|
945
|
+
declare const FRAGMENT_MAP: Record<string, FragmentFactory>;
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Pure Operation Functions
|
|
949
|
+
*
|
|
950
|
+
* Stateless numeric computations used by OperationNodes.
|
|
951
|
+
* See docs/diagram-contracts.md §5.3.
|
|
952
|
+
*/
|
|
953
|
+
declare function opSum(inputs: number[]): number[];
|
|
954
|
+
declare function opMax(inputs: number[]): number[];
|
|
955
|
+
declare function opClamp(value: number, min: number, max: number): number;
|
|
956
|
+
declare function opConstant(value: number): () => number[];
|
|
957
|
+
interface TextMeasurer {
|
|
958
|
+
measure(text: string, fontSize: number, maxWidth?: number, fontWeight?: string | number): {
|
|
959
|
+
width: number;
|
|
960
|
+
height: number;
|
|
961
|
+
lines: string[];
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* SimpleTextMeasurer — approximation-based text measurement (fallback).
|
|
966
|
+
*/
|
|
967
|
+
declare class SimpleTextMeasurer implements TextMeasurer {
|
|
968
|
+
measure(text: string, fontSize: number, maxWidth?: number): {
|
|
969
|
+
width: number;
|
|
970
|
+
height: number;
|
|
971
|
+
lines: string[];
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* diagram-contracts — Public API barrel
|
|
977
|
+
*/
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Full layout pipeline: normalize → build graph from fragments → evaluate.
|
|
981
|
+
*/
|
|
982
|
+
declare function layout(ir: IrNode, options: NormalizeOptions): EvaluateResult;
|
|
983
|
+
/**
|
|
984
|
+
* Full end-to-end pipeline: IR → layout → SVG string.
|
|
985
|
+
*/
|
|
986
|
+
declare function renderToSvg(ir: IrNode, options: NormalizeOptions & {
|
|
987
|
+
iconRegistry?: IconRegistry;
|
|
988
|
+
}): string;
|
|
989
|
+
/**
|
|
990
|
+
* Full end-to-end pipeline: Draw Text source → SVG string.
|
|
991
|
+
*/
|
|
992
|
+
declare function renderDrawTextToSvg(source: string, options?: Partial<NormalizeOptions> & {
|
|
993
|
+
iconRegistry?: IconRegistry;
|
|
994
|
+
}): string;
|
|
995
|
+
/**
|
|
996
|
+
* Full end-to-end pipeline: Draw TSX source → SVG string.
|
|
997
|
+
*/
|
|
998
|
+
declare function renderDrawTsxToSvg(source: string, options?: Partial<NormalizeOptions> & CompileOptions & {
|
|
999
|
+
iconRegistry?: IconRegistry;
|
|
1000
|
+
}): string;
|
|
1001
|
+
|
|
1002
|
+
export { type Align, type AnchorPosition, type ArrowHead, type Axis, type CandidateEdge, type CompileOptions, type CompileResult, type ComponentDef, type ConstraintStrength, type ContentAlign, type DependencyEdge, type Diagnostic, ELEMENT_CATALOG, type ElementDef, type EvaluateResult, FRAGMENT_MAP, type FontWeight, type FragmentFactory, type GeometryRole, type GeometryRoleMap, type GeometryTarget, type IconPack, type IconRegistry, type ImageFit, type IrKind, type IrNode, IrNodeSchema, type Justify, type LayoutGraph, type NormalizeOptions, type NormalizeResult, type OpKind, type OperationNode, PROPERTY_CATALOG, type ParseResult, type Priority, type PropertyDef, type PropertyName, type Rect, type RenderOptions, type ResolvedArtifact, type ResolvedNode, type ResolverPolicy, type RouteStyle, type Shape, SimpleTextMeasurer, type SlotKind, type SlotResolverNode, type StrokeStyle, TOKEN_CATALOG, type TextMeasurer, type TextOverflow, type TextPosition, type ThemeIR, type TokenEntry, type TokenIR, type ValueSlot, compileDrawTsx, createAwsIconPack, createGraph, createIconRegistry, defaultTheme, defaultTokens, evaluate, kindToPascal, layout, normalize, opClamp, opConstant, opMax, opSum, parseDrawText, parseIr, parseTheme, parseTokens, renderArrowMarkers, renderConnector, renderDrawTextToSvg, renderDrawTsxToSvg, renderShape, renderSvg, renderText, renderToSvg, resolveSlot, resolveTokenRef };
|