@crazyhappyone/auto-graph 0.0.1
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 +154 -0
- package/README.zh-CN.md +154 -0
- package/dist/cli/index.cjs +2736 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +2734 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +2804 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +514 -0
- package/dist/index.d.ts +514 -0
- package/dist/index.js +2766 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
2
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
3
|
+
interface JsonObject {
|
|
4
|
+
[key: string]: JsonValue;
|
|
5
|
+
}
|
|
6
|
+
type DiagramDirection = "TB" | "LR" | "BT" | "RL";
|
|
7
|
+
interface Point {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
interface Size {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
interface Box extends Point, Size {
|
|
16
|
+
}
|
|
17
|
+
interface Insets {
|
|
18
|
+
top: number;
|
|
19
|
+
right: number;
|
|
20
|
+
bottom: number;
|
|
21
|
+
left: number;
|
|
22
|
+
}
|
|
23
|
+
type AnchorName = "center" | "top" | "right" | "bottom" | "left" | "top-left" | "top-right" | "bottom-right" | "bottom-left";
|
|
24
|
+
interface AnchorPoint {
|
|
25
|
+
name: AnchorName;
|
|
26
|
+
point: Point;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type ConstraintTargetKind = "node" | "group";
|
|
30
|
+
interface ConstraintTarget {
|
|
31
|
+
id: string;
|
|
32
|
+
kind?: ConstraintTargetKind;
|
|
33
|
+
}
|
|
34
|
+
interface ConstraintBase {
|
|
35
|
+
id?: string;
|
|
36
|
+
targetId?: string;
|
|
37
|
+
target?: ConstraintTarget;
|
|
38
|
+
}
|
|
39
|
+
interface ExactPositionConstraint extends ConstraintBase {
|
|
40
|
+
kind: "exact-position";
|
|
41
|
+
position: Point;
|
|
42
|
+
}
|
|
43
|
+
type RelativePositionRelation = "above" | "right-of" | "below" | "left-of";
|
|
44
|
+
interface RelativePositionConstraint extends ConstraintBase {
|
|
45
|
+
kind: "relative-position";
|
|
46
|
+
sourceId: string;
|
|
47
|
+
referenceId: string;
|
|
48
|
+
relation: RelativePositionRelation;
|
|
49
|
+
offset?: Point;
|
|
50
|
+
}
|
|
51
|
+
type AlignmentAxis = "x" | "y" | "center-x" | "center-y" | "top" | "right" | "bottom" | "left";
|
|
52
|
+
interface AlignConstraint extends ConstraintBase {
|
|
53
|
+
kind: "align";
|
|
54
|
+
axis: AlignmentAxis;
|
|
55
|
+
targetIds: string[];
|
|
56
|
+
}
|
|
57
|
+
type DistributionAxis = "horizontal" | "vertical";
|
|
58
|
+
interface DistributeConstraint extends ConstraintBase {
|
|
59
|
+
kind: "distribute";
|
|
60
|
+
axis: DistributionAxis;
|
|
61
|
+
targetIds: string[];
|
|
62
|
+
spacing?: number;
|
|
63
|
+
}
|
|
64
|
+
interface ContainmentConstraint extends ConstraintBase {
|
|
65
|
+
kind: "containment";
|
|
66
|
+
containerId: string;
|
|
67
|
+
childIds: string[];
|
|
68
|
+
padding?: Insets;
|
|
69
|
+
}
|
|
70
|
+
type Constraint = ExactPositionConstraint | RelativePositionConstraint | AlignConstraint | DistributeConstraint | ContainmentConstraint;
|
|
71
|
+
|
|
72
|
+
type DiagnosticSeverity = "info" | "warning" | "error";
|
|
73
|
+
type DiagnosticPathSegment = string | number;
|
|
74
|
+
interface Diagnostic {
|
|
75
|
+
severity: DiagnosticSeverity;
|
|
76
|
+
code: string;
|
|
77
|
+
message: string;
|
|
78
|
+
path?: DiagnosticPathSegment[];
|
|
79
|
+
detail?: JsonObject;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface TextStyleOptions {
|
|
83
|
+
fontFamily: string;
|
|
84
|
+
fontSize: number;
|
|
85
|
+
fontWeight?: number | string;
|
|
86
|
+
fontStyle?: "normal" | "italic";
|
|
87
|
+
lineHeight?: number;
|
|
88
|
+
letterSpacing?: number;
|
|
89
|
+
whiteSpace?: "normal" | "pre-wrap";
|
|
90
|
+
wordBreak?: "normal" | "keep-all";
|
|
91
|
+
}
|
|
92
|
+
type TextMeasurementBackend = "deterministic" | "pretext";
|
|
93
|
+
interface PreparedText {
|
|
94
|
+
text: string;
|
|
95
|
+
font: string;
|
|
96
|
+
style: TextStyleOptions;
|
|
97
|
+
backend: TextMeasurementBackend;
|
|
98
|
+
}
|
|
99
|
+
interface TextCursor {
|
|
100
|
+
segmentIndex: number;
|
|
101
|
+
graphemeIndex: number;
|
|
102
|
+
}
|
|
103
|
+
interface TextLayoutLine {
|
|
104
|
+
text: string;
|
|
105
|
+
width: number;
|
|
106
|
+
start: TextCursor;
|
|
107
|
+
end: TextCursor;
|
|
108
|
+
}
|
|
109
|
+
interface TextLayout {
|
|
110
|
+
width: number;
|
|
111
|
+
height: number;
|
|
112
|
+
lineHeight: number;
|
|
113
|
+
lineCount: number;
|
|
114
|
+
lines: TextLayoutLine[];
|
|
115
|
+
diagnostics: Diagnostic[];
|
|
116
|
+
}
|
|
117
|
+
interface TextMeasurer {
|
|
118
|
+
prepare(text: string, style: TextStyleOptions): PreparedText;
|
|
119
|
+
layout(prepared: PreparedText, maxWidth: number, lineHeight?: number): TextLayout;
|
|
120
|
+
naturalWidth(prepared: PreparedText): number;
|
|
121
|
+
}
|
|
122
|
+
declare function assertFinitePositive(value: number, label: string): void;
|
|
123
|
+
declare function assertFiniteNonNegative(value: number, label: string): void;
|
|
124
|
+
declare function validateTextStyle(style: TextStyleOptions): void;
|
|
125
|
+
declare function resolveLineHeight(style: TextStyleOptions): number;
|
|
126
|
+
declare function toCanvasFont(style: TextStyleOptions): string;
|
|
127
|
+
|
|
128
|
+
declare class DeterministicTextMeasurer implements TextMeasurer {
|
|
129
|
+
prepare(text: string, style: TextStyleOptions): PreparedText;
|
|
130
|
+
layout(prepared: PreparedText, maxWidth: number, lineHeight?: number): TextLayout;
|
|
131
|
+
naturalWidth(prepared: PreparedText): number;
|
|
132
|
+
private wrap;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
declare function isPretextRuntimeAvailable(): boolean;
|
|
136
|
+
declare class PretextTextMeasurer implements TextMeasurer {
|
|
137
|
+
prepare(text: string, style: TextStyleOptions): PreparedText;
|
|
138
|
+
layout(prepared: PreparedText, maxWidth: number, lineHeight?: number): TextLayout;
|
|
139
|
+
naturalWidth(prepared: PreparedText): number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface LabelLineLayout {
|
|
143
|
+
text: string;
|
|
144
|
+
box: Box;
|
|
145
|
+
baselineY: number;
|
|
146
|
+
width: number;
|
|
147
|
+
lineIndex: number;
|
|
148
|
+
sourceStart?: TextCursor;
|
|
149
|
+
sourceEnd?: TextCursor;
|
|
150
|
+
}
|
|
151
|
+
interface LabelLayout {
|
|
152
|
+
text: string;
|
|
153
|
+
box: Box;
|
|
154
|
+
contentBox: Box;
|
|
155
|
+
naturalSize: Size;
|
|
156
|
+
fittedSize: Size;
|
|
157
|
+
padding: Insets;
|
|
158
|
+
font: TextStyleOptions;
|
|
159
|
+
lineHeight: number;
|
|
160
|
+
lines: LabelLineLayout[];
|
|
161
|
+
overflow: {
|
|
162
|
+
horizontal: boolean;
|
|
163
|
+
vertical: boolean;
|
|
164
|
+
truncated: boolean;
|
|
165
|
+
};
|
|
166
|
+
diagnostics: Diagnostic[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type NodeShape = "rectangle" | "rounded-rectangle" | "ellipse" | "diamond" | "parallelogram" | "hexagon" | "cylinder";
|
|
170
|
+
interface Label {
|
|
171
|
+
text: string;
|
|
172
|
+
id?: string;
|
|
173
|
+
maxWidth?: number;
|
|
174
|
+
metadata?: JsonObject;
|
|
175
|
+
}
|
|
176
|
+
interface NodeBase {
|
|
177
|
+
id: string;
|
|
178
|
+
label?: Label;
|
|
179
|
+
shape?: NodeShape;
|
|
180
|
+
metadata?: JsonObject;
|
|
181
|
+
}
|
|
182
|
+
interface IntentNode extends NodeBase {
|
|
183
|
+
parentId?: string;
|
|
184
|
+
position?: Point;
|
|
185
|
+
size?: Size;
|
|
186
|
+
padding?: Insets;
|
|
187
|
+
}
|
|
188
|
+
interface NormalizedNode extends NodeBase {
|
|
189
|
+
shape: NodeShape;
|
|
190
|
+
parentId?: string;
|
|
191
|
+
position?: Point;
|
|
192
|
+
size: Size;
|
|
193
|
+
padding: Insets;
|
|
194
|
+
labelLayout?: LabelLayout;
|
|
195
|
+
}
|
|
196
|
+
interface CoordinatedNode extends NodeBase {
|
|
197
|
+
shape: NodeShape;
|
|
198
|
+
box: Box;
|
|
199
|
+
anchors: AnchorPoint[];
|
|
200
|
+
parentId?: string;
|
|
201
|
+
labelLayout?: LabelLayout;
|
|
202
|
+
}
|
|
203
|
+
interface EdgeEndpoint {
|
|
204
|
+
nodeId: string;
|
|
205
|
+
anchor?: AnchorName;
|
|
206
|
+
}
|
|
207
|
+
interface IntentEdge {
|
|
208
|
+
id?: string;
|
|
209
|
+
sourceId: string;
|
|
210
|
+
targetId: string;
|
|
211
|
+
label?: Label;
|
|
212
|
+
metadata?: JsonObject;
|
|
213
|
+
}
|
|
214
|
+
interface NormalizedEdge {
|
|
215
|
+
id: string;
|
|
216
|
+
source: EdgeEndpoint;
|
|
217
|
+
target: EdgeEndpoint;
|
|
218
|
+
label?: Label;
|
|
219
|
+
metadata?: JsonObject;
|
|
220
|
+
}
|
|
221
|
+
interface CoordinatedEdge extends NormalizedEdge {
|
|
222
|
+
points: Point[];
|
|
223
|
+
labelPosition?: Point;
|
|
224
|
+
}
|
|
225
|
+
interface IntentGroup {
|
|
226
|
+
id: string;
|
|
227
|
+
label?: Label;
|
|
228
|
+
nodeIds?: string[];
|
|
229
|
+
groupIds?: string[];
|
|
230
|
+
padding?: Insets;
|
|
231
|
+
metadata?: JsonObject;
|
|
232
|
+
}
|
|
233
|
+
interface NormalizedGroup {
|
|
234
|
+
id: string;
|
|
235
|
+
label?: Label;
|
|
236
|
+
nodeIds: string[];
|
|
237
|
+
groupIds: string[];
|
|
238
|
+
padding: Insets;
|
|
239
|
+
metadata?: JsonObject;
|
|
240
|
+
labelLayout?: LabelLayout;
|
|
241
|
+
}
|
|
242
|
+
interface CoordinatedGroup extends NormalizedGroup {
|
|
243
|
+
box: Box;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
type LayoutLockSource = "fixed-position" | "exact-position";
|
|
247
|
+
interface LayoutLock {
|
|
248
|
+
nodeId: string;
|
|
249
|
+
source: LayoutLockSource;
|
|
250
|
+
}
|
|
251
|
+
interface ConstraintSolverInput {
|
|
252
|
+
direction: DiagramDirection;
|
|
253
|
+
overlapSpacing?: number;
|
|
254
|
+
boxes: ReadonlyMap<string, Box>;
|
|
255
|
+
nodes: readonly NormalizedNode[];
|
|
256
|
+
groups: readonly NormalizedGroup[];
|
|
257
|
+
constraints: readonly Constraint[];
|
|
258
|
+
}
|
|
259
|
+
interface ConstraintSolverResult {
|
|
260
|
+
boxes: Map<string, Box>;
|
|
261
|
+
locks: Map<string, LayoutLock>;
|
|
262
|
+
diagnostics: Diagnostic[];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
declare function applyLayoutConstraints(input: ConstraintSolverInput): ConstraintSolverResult;
|
|
266
|
+
|
|
267
|
+
type DiagramStage = "intent" | "normalized" | "coordinated";
|
|
268
|
+
type DiagramMetadata = JsonObject;
|
|
269
|
+
interface IntentDiagram {
|
|
270
|
+
id?: string;
|
|
271
|
+
title?: string;
|
|
272
|
+
direction?: DiagramDirection;
|
|
273
|
+
nodes: IntentNode[];
|
|
274
|
+
edges?: IntentEdge[];
|
|
275
|
+
groups?: IntentGroup[];
|
|
276
|
+
constraints?: Constraint[];
|
|
277
|
+
metadata?: DiagramMetadata;
|
|
278
|
+
}
|
|
279
|
+
interface NormalizedDiagram {
|
|
280
|
+
id: string;
|
|
281
|
+
title?: string;
|
|
282
|
+
direction: DiagramDirection;
|
|
283
|
+
nodes: NormalizedNode[];
|
|
284
|
+
edges: NormalizedEdge[];
|
|
285
|
+
groups: NormalizedGroup[];
|
|
286
|
+
constraints: Constraint[];
|
|
287
|
+
diagnostics: Diagnostic[];
|
|
288
|
+
metadata?: DiagramMetadata;
|
|
289
|
+
}
|
|
290
|
+
interface CoordinatedDiagram {
|
|
291
|
+
id: string;
|
|
292
|
+
title?: string;
|
|
293
|
+
direction: DiagramDirection;
|
|
294
|
+
nodes: CoordinatedNode[];
|
|
295
|
+
edges: CoordinatedEdge[];
|
|
296
|
+
groups: CoordinatedGroup[];
|
|
297
|
+
diagnostics: Diagnostic[];
|
|
298
|
+
bounds: Box;
|
|
299
|
+
metadata?: DiagramMetadata;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
type DslDiagnosticLayer = "parse" | "validate" | "solve" | "export" | "io";
|
|
303
|
+
type DslOutputFormat = "svg" | "excalidraw";
|
|
304
|
+
interface DslDiagnostic extends Diagnostic {
|
|
305
|
+
layer: DslDiagnosticLayer;
|
|
306
|
+
hint?: string;
|
|
307
|
+
}
|
|
308
|
+
interface ParseDiagramDslResult {
|
|
309
|
+
value?: unknown;
|
|
310
|
+
diagnostics: DslDiagnostic[];
|
|
311
|
+
}
|
|
312
|
+
interface ParseDiagramDslOptions {
|
|
313
|
+
sourcePath?: string;
|
|
314
|
+
sourceFormat?: "yaml" | "json";
|
|
315
|
+
maxBytes?: number;
|
|
316
|
+
}
|
|
317
|
+
interface NormalizeDiagramDslResult {
|
|
318
|
+
diagram?: NormalizedDiagram;
|
|
319
|
+
diagnostics: DslDiagnostic[];
|
|
320
|
+
output?: {
|
|
321
|
+
format?: DslOutputFormat;
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
interface RenderDiagramDslOptions {
|
|
325
|
+
sourcePath?: string;
|
|
326
|
+
sourceFormat?: "yaml" | "json";
|
|
327
|
+
format?: string;
|
|
328
|
+
textMeasurer?: TextMeasurer;
|
|
329
|
+
}
|
|
330
|
+
interface RenderDiagramDslResult {
|
|
331
|
+
format?: DslOutputFormat;
|
|
332
|
+
content?: string;
|
|
333
|
+
diagnostics: DslDiagnostic[];
|
|
334
|
+
diagram?: CoordinatedDiagram;
|
|
335
|
+
metadata?: JsonObject;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
declare function sortDslDiagnostics(diagnostics: DslDiagnostic[]): DslDiagnostic[];
|
|
339
|
+
|
|
340
|
+
interface ParsedEdgeShorthand {
|
|
341
|
+
sourceId: string;
|
|
342
|
+
targetId: string;
|
|
343
|
+
label?: {
|
|
344
|
+
text: string;
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
declare function parseEdgeShorthand(value: string, path: Array<string | number>): {
|
|
348
|
+
edge?: ParsedEdgeShorthand;
|
|
349
|
+
diagnostics: DslDiagnostic[];
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
interface NormalizeDiagramDslOptions {
|
|
353
|
+
id?: string;
|
|
354
|
+
textMeasurer?: TextMeasurer;
|
|
355
|
+
}
|
|
356
|
+
declare function normalizeDiagramDsl(dslValue: unknown, options?: NormalizeDiagramDslOptions): NormalizeDiagramDslResult;
|
|
357
|
+
|
|
358
|
+
declare const DEFAULT_DSL_MAX_BYTES = 1000000;
|
|
359
|
+
declare function parseDiagramDsl(source: string, options?: ParseDiagramDslOptions): ParseDiagramDslResult;
|
|
360
|
+
|
|
361
|
+
type ExportFormat = "svg" | "excalidraw";
|
|
362
|
+
interface ExportResult {
|
|
363
|
+
format: ExportFormat;
|
|
364
|
+
content: string;
|
|
365
|
+
diagnostics: Diagnostic[];
|
|
366
|
+
}
|
|
367
|
+
interface ExportOptions {
|
|
368
|
+
title?: string;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
declare function resolveOutputFormat(cliFormat?: string, dslFormat?: DslOutputFormat): {
|
|
372
|
+
format?: DslOutputFormat;
|
|
373
|
+
diagnostics: DslDiagnostic[];
|
|
374
|
+
};
|
|
375
|
+
declare function renderDiagramDsl(source: string, options?: RenderDiagramDslOptions): RenderDiagramDslResult;
|
|
376
|
+
|
|
377
|
+
interface Arrowhead {
|
|
378
|
+
tip: Point;
|
|
379
|
+
left: Point;
|
|
380
|
+
right: Point;
|
|
381
|
+
direction: Point;
|
|
382
|
+
}
|
|
383
|
+
declare function computeArrowhead(points: readonly Point[], options?: {
|
|
384
|
+
length?: number;
|
|
385
|
+
width?: number;
|
|
386
|
+
}): Arrowhead;
|
|
387
|
+
|
|
388
|
+
declare function exportExcalidraw(diagram: CoordinatedDiagram, options?: ExportOptions): string;
|
|
389
|
+
|
|
390
|
+
declare function exportSvg(diagram: CoordinatedDiagram, options?: ExportOptions): string;
|
|
391
|
+
|
|
392
|
+
declare function normalizeInsets(input?: Insets | number): Insets;
|
|
393
|
+
declare function validateBox(box: Box, label?: string): void;
|
|
394
|
+
declare function boxCenter(box: Box): Point;
|
|
395
|
+
declare function expandBox(box: Box, margin: number | Insets): Box;
|
|
396
|
+
declare function unionBoxes(boxes: readonly Box[]): Box;
|
|
397
|
+
declare function intersectsAabb(a: Box, b: Box): boolean;
|
|
398
|
+
|
|
399
|
+
interface LabelFitOptions {
|
|
400
|
+
font: TextStyleOptions;
|
|
401
|
+
padding: Insets | number;
|
|
402
|
+
minSize?: Partial<Size>;
|
|
403
|
+
maxWidth?: number;
|
|
404
|
+
overflow?: "allow" | "diagnose" | "truncate";
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
declare function fitLabel(text: string, options: LabelFitOptions, measurer: TextMeasurer): LabelLayout;
|
|
408
|
+
declare class LabelFitter {
|
|
409
|
+
private readonly measurer;
|
|
410
|
+
constructor(measurer: TextMeasurer);
|
|
411
|
+
fit(text: string, options: LabelFitOptions): LabelLayout;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
interface ContainerGeometryInput {
|
|
415
|
+
id: string;
|
|
416
|
+
childBoxes: readonly Box[];
|
|
417
|
+
padding: Insets | number;
|
|
418
|
+
labelLayout?: LabelLayout;
|
|
419
|
+
minSize?: Partial<Size>;
|
|
420
|
+
obstacleMargin?: number | Insets;
|
|
421
|
+
}
|
|
422
|
+
interface ContainerGeometry {
|
|
423
|
+
id: string;
|
|
424
|
+
box: Box;
|
|
425
|
+
contentBox: Box;
|
|
426
|
+
childBounds: Box;
|
|
427
|
+
labelLayout?: LabelLayout;
|
|
428
|
+
anchors: AnchorPoint[];
|
|
429
|
+
obstacleBox: Box;
|
|
430
|
+
diagnostics: Diagnostic[];
|
|
431
|
+
}
|
|
432
|
+
declare function computeContainerGeometry(input: ContainerGeometryInput): ContainerGeometry;
|
|
433
|
+
|
|
434
|
+
interface ShapeGeometryInput {
|
|
435
|
+
shape: NodeShape;
|
|
436
|
+
box: Box;
|
|
437
|
+
obstacleMargin?: number | Insets;
|
|
438
|
+
}
|
|
439
|
+
interface ShapeGeometry {
|
|
440
|
+
shape: NodeShape;
|
|
441
|
+
box: Box;
|
|
442
|
+
center: Point;
|
|
443
|
+
anchors: AnchorPoint[];
|
|
444
|
+
obstacleBox: Box;
|
|
445
|
+
}
|
|
446
|
+
declare function computeShapeGeometry(input: ShapeGeometryInput): ShapeGeometry;
|
|
447
|
+
declare function getEdgePort(geometry: ShapeGeometry, toward: Point, preferredAnchor?: AnchorName): Point;
|
|
448
|
+
|
|
449
|
+
interface DagreLayoutOptions {
|
|
450
|
+
nodesep: number;
|
|
451
|
+
ranksep: number;
|
|
452
|
+
edgesep: number;
|
|
453
|
+
marginx: number;
|
|
454
|
+
marginy: number;
|
|
455
|
+
ranker: "network-simplex" | "tight-tree" | "longest-path";
|
|
456
|
+
}
|
|
457
|
+
interface DagreLayoutNode {
|
|
458
|
+
id: string;
|
|
459
|
+
size: Size;
|
|
460
|
+
}
|
|
461
|
+
interface DagreLayoutEdge {
|
|
462
|
+
id: string;
|
|
463
|
+
sourceId: string;
|
|
464
|
+
targetId: string;
|
|
465
|
+
}
|
|
466
|
+
interface DagreLayoutInput {
|
|
467
|
+
direction: DiagramDirection;
|
|
468
|
+
nodes: readonly DagreLayoutNode[];
|
|
469
|
+
edges: readonly DagreLayoutEdge[];
|
|
470
|
+
options?: Partial<DagreLayoutOptions>;
|
|
471
|
+
}
|
|
472
|
+
interface InitialLayoutResult {
|
|
473
|
+
boxes: Map<string, Box>;
|
|
474
|
+
diagnostics: Diagnostic[];
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
declare function runDagreInitialLayout(input: DagreLayoutInput): InitialLayoutResult;
|
|
478
|
+
|
|
479
|
+
type RouteKind = "orthogonal" | "straight";
|
|
480
|
+
interface RouteEdgeInput {
|
|
481
|
+
kind?: RouteKind;
|
|
482
|
+
direction: DiagramDirection;
|
|
483
|
+
source: ShapeGeometry;
|
|
484
|
+
target: ShapeGeometry;
|
|
485
|
+
sourceAnchor?: AnchorName;
|
|
486
|
+
targetAnchor?: AnchorName;
|
|
487
|
+
obstacles?: readonly Box[];
|
|
488
|
+
}
|
|
489
|
+
interface RouteEdgeResult {
|
|
490
|
+
points: Point[];
|
|
491
|
+
diagnostics: Diagnostic[];
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
declare function routeEdge(input: RouteEdgeInput): RouteEdgeResult;
|
|
495
|
+
declare function simplifyRoute(points: readonly Point[]): Point[];
|
|
496
|
+
|
|
497
|
+
declare const DEFAULT_CANONICAL_PRECISION = 3;
|
|
498
|
+
interface CanonicalizeOptions {
|
|
499
|
+
precision?: number;
|
|
500
|
+
}
|
|
501
|
+
type CanonicalJson = null | boolean | number | string | CanonicalJson[] | {
|
|
502
|
+
[key: string]: CanonicalJson;
|
|
503
|
+
};
|
|
504
|
+
declare function canonicalize(value: unknown, options?: CanonicalizeOptions): CanonicalJson;
|
|
505
|
+
declare function stringifyCanonical(value: unknown, precision?: number): string;
|
|
506
|
+
|
|
507
|
+
interface SolveDiagramOptions {
|
|
508
|
+
routeKind?: RouteKind;
|
|
509
|
+
obstacleMargin?: number | Insets;
|
|
510
|
+
overlapSpacing?: number;
|
|
511
|
+
}
|
|
512
|
+
declare function solveDiagram(diagram: NormalizedDiagram, options?: SolveDiagramOptions): CoordinatedDiagram;
|
|
513
|
+
|
|
514
|
+
export { type AlignConstraint, type AlignmentAxis, type AnchorName, type AnchorPoint, type Arrowhead, type Box, type CanonicalJson, type CanonicalizeOptions, type Constraint, type ConstraintBase, type ConstraintSolverInput, type ConstraintSolverResult, type ConstraintTarget, type ConstraintTargetKind, type ContainerGeometry, type ContainerGeometryInput, type ContainmentConstraint, type CoordinatedDiagram, type CoordinatedEdge, type CoordinatedGroup, type CoordinatedNode, DEFAULT_CANONICAL_PRECISION, DEFAULT_DSL_MAX_BYTES, type DagreLayoutEdge, type DagreLayoutInput, type DagreLayoutNode, type DagreLayoutOptions, DeterministicTextMeasurer, type Diagnostic, type DiagnosticPathSegment, type DiagnosticSeverity, type DiagramDirection, type DiagramMetadata, type DiagramStage, type DistributeConstraint, type DistributionAxis, type DslDiagnostic, type DslDiagnosticLayer, type DslOutputFormat, type EdgeEndpoint, type ExactPositionConstraint, type ExportFormat, type ExportOptions, type ExportResult, type InitialLayoutResult, type Insets, type IntentDiagram, type IntentEdge, type IntentGroup, type IntentNode, type JsonObject, type JsonPrimitive, type JsonValue, type Label, type LabelFitOptions, LabelFitter, type LabelLayout, type LabelLineLayout, type LayoutLock, type LayoutLockSource, type NodeBase, type NodeShape, type NormalizeDiagramDslOptions, type NormalizeDiagramDslResult, type NormalizedDiagram, type NormalizedEdge, type NormalizedGroup, type NormalizedNode, type ParseDiagramDslOptions, type ParseDiagramDslResult, type ParsedEdgeShorthand, type Point, type PreparedText, PretextTextMeasurer, type RelativePositionConstraint, type RelativePositionRelation, type RenderDiagramDslOptions, type RenderDiagramDslResult, type RouteEdgeInput, type RouteEdgeResult, type RouteKind, type ShapeGeometry, type ShapeGeometryInput, type Size, type SolveDiagramOptions, type TextCursor, type TextLayout, type TextLayoutLine, type TextMeasurementBackend, type TextMeasurer, type TextStyleOptions, applyLayoutConstraints, assertFiniteNonNegative, assertFinitePositive, boxCenter, canonicalize, computeArrowhead, computeContainerGeometry, computeShapeGeometry, expandBox, exportExcalidraw, exportSvg, fitLabel, getEdgePort, intersectsAabb, isPretextRuntimeAvailable, normalizeDiagramDsl, normalizeInsets, parseDiagramDsl, parseEdgeShorthand, renderDiagramDsl, resolveLineHeight, resolveOutputFormat, routeEdge, runDagreInitialLayout, simplifyRoute, solveDiagram, sortDslDiagnostics, stringifyCanonical, toCanvasFont, unionBoxes, validateBox, validateTextStyle };
|