@dxos/diagram 0.11.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 +105 -0
- package/README.md +10 -0
- package/dist/lib/index.mjs +3975 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/testing.mjs +68 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/types/src/content.d.ts +60 -0
- package/dist/types/src/content.d.ts.map +1 -0
- package/dist/types/src/diagnostics.d.ts +56 -0
- package/dist/types/src/diagnostics.d.ts.map +1 -0
- package/dist/types/src/diagnostics.test.d.ts +2 -0
- package/dist/types/src/diagnostics.test.d.ts.map +1 -0
- package/dist/types/src/dialect.d.ts +19 -0
- package/dist/types/src/dialect.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +16 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/layout.d.ts +26 -0
- package/dist/types/src/layout.d.ts.map +1 -0
- package/dist/types/src/mermaid-engine.d.ts +83 -0
- package/dist/types/src/mermaid-engine.d.ts.map +1 -0
- package/dist/types/src/mermaid-engine.test.d.ts +2 -0
- package/dist/types/src/mermaid-engine.test.d.ts.map +1 -0
- package/dist/types/src/mermaid.d.ts +56 -0
- package/dist/types/src/mermaid.d.ts.map +1 -0
- package/dist/types/src/mermaid.test.d.ts +3 -0
- package/dist/types/src/mermaid.test.d.ts.map +1 -0
- package/dist/types/src/objective.d.ts +75 -0
- package/dist/types/src/objective.d.ts.map +1 -0
- package/dist/types/src/objective.test.d.ts +2 -0
- package/dist/types/src/objective.test.d.ts.map +1 -0
- package/dist/types/src/ortho-router.d.ts +13 -0
- package/dist/types/src/ortho-router.d.ts.map +1 -0
- package/dist/types/src/scene.d.ts +1006 -0
- package/dist/types/src/scene.d.ts.map +1 -0
- package/dist/types/src/scene.test.d.ts +2 -0
- package/dist/types/src/scene.test.d.ts.map +1 -0
- package/dist/types/src/svg-handler.d.ts +5 -0
- package/dist/types/src/svg-handler.d.ts.map +1 -0
- package/dist/types/src/svg-handler.test.d.ts +2 -0
- package/dist/types/src/svg-handler.test.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +11 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/ui.d.ts +67 -0
- package/dist/types/src/ui.d.ts.map +1 -0
- package/dist/types/src/ui.test.d.ts +2 -0
- package/dist/types/src/ui.test.d.ts.map +1 -0
- package/dist/types/src/uml-engine.d.ts +14 -0
- package/dist/types/src/uml-engine.d.ts.map +1 -0
- package/dist/types/src/uml-engine.test.d.ts +2 -0
- package/dist/types/src/uml-engine.test.d.ts.map +1 -0
- package/dist/types/src/uml-grid.d.ts +99 -0
- package/dist/types/src/uml-grid.d.ts.map +1 -0
- package/dist/types/src/uml-grid.test.d.ts +2 -0
- package/dist/types/src/uml-grid.test.d.ts.map +1 -0
- package/dist/types/src/uml-rules.d.ts +56 -0
- package/dist/types/src/uml-rules.d.ts.map +1 -0
- package/dist/types/src/uml-rules.test.d.ts +2 -0
- package/dist/types/src/uml-rules.test.d.ts.map +1 -0
- package/dist/types/src/uml-search.d.ts +26 -0
- package/dist/types/src/uml-search.d.ts.map +1 -0
- package/dist/types/src/uml-search.test.d.ts +2 -0
- package/dist/types/src/uml-search.test.d.ts.map +1 -0
- package/dist/types/src/uml.d.ts +60 -0
- package/dist/types/src/uml.d.ts.map +1 -0
- package/dist/types/src/uml.test.d.ts +2 -0
- package/dist/types/src/uml.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -0
- package/src/__snapshots__/diagnostics.test.ts.snap +36 -0
- package/src/__snapshots__/mermaid-engine.test.ts.snap +22 -0
- package/src/content.ts +180 -0
- package/src/diagnostics.test.ts +173 -0
- package/src/diagnostics.ts +393 -0
- package/src/dialect.ts +53 -0
- package/src/index.ts +19 -0
- package/src/layout.ts +99 -0
- package/src/mermaid-engine.test.ts +244 -0
- package/src/mermaid-engine.ts +863 -0
- package/src/mermaid.test.ts +138 -0
- package/src/mermaid.ts +326 -0
- package/src/objective.test.ts +82 -0
- package/src/objective.ts +157 -0
- package/src/ortho-router.ts +372 -0
- package/src/scene.test.ts +36 -0
- package/src/scene.ts +281 -0
- package/src/svg-handler.test.ts +75 -0
- package/src/svg-handler.ts +119 -0
- package/src/testing.ts +68 -0
- package/src/ui.test.ts +183 -0
- package/src/ui.ts +398 -0
- package/src/uml-engine.test.ts +63 -0
- package/src/uml-engine.ts +146 -0
- package/src/uml-grid.test.ts +175 -0
- package/src/uml-grid.ts +559 -0
- package/src/uml-rules.test.ts +109 -0
- package/src/uml-rules.ts +319 -0
- package/src/uml-search.test.ts +108 -0
- package/src/uml-search.ts +266 -0
- package/src/uml.test.ts +172 -0
- package/src/uml.ts +390 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/testing.ts
|
|
2
|
+
/**
|
|
3
|
+
* Minimal layout discussion piece: three packages with three types each — an inheritance fan-in
|
|
4
|
+
* (B, C extend A), a chain with a has-many (X ⇒ Y → Z), and a fan-in (P, R → Q), plus two
|
|
5
|
+
* cross-package references (Y → A, Q → X) so routes must leave and enter frames. Small enough to
|
|
6
|
+
* reason about every placement and route by eye. Relationship kinds are carried by the edge
|
|
7
|
+
* tokens (UML end markers), not labels.
|
|
8
|
+
*/
|
|
9
|
+
var BASIC = `
|
|
10
|
+
flowchart TB
|
|
11
|
+
subgraph pkgA [Package A]
|
|
12
|
+
A[A]
|
|
13
|
+
B[B]
|
|
14
|
+
C[C]
|
|
15
|
+
end
|
|
16
|
+
subgraph pkgX [Package X]
|
|
17
|
+
X[X]
|
|
18
|
+
Y[Y]
|
|
19
|
+
Z[Z]
|
|
20
|
+
end
|
|
21
|
+
subgraph pkgP [Package P]
|
|
22
|
+
P[P]
|
|
23
|
+
Q[Q]
|
|
24
|
+
R[R]
|
|
25
|
+
end
|
|
26
|
+
B --|> A
|
|
27
|
+
C --|> A
|
|
28
|
+
X --{ Y
|
|
29
|
+
Y --> Z
|
|
30
|
+
P --> Q
|
|
31
|
+
R --> Q
|
|
32
|
+
Y --> A
|
|
33
|
+
Q --> X
|
|
34
|
+
`;
|
|
35
|
+
/** Exercises class blocks, a stereotype, generics, cardinalities, and every relation kind. */
|
|
36
|
+
var CLASS_DIAGRAM = `
|
|
37
|
+
classDiagram
|
|
38
|
+
direction TB
|
|
39
|
+
|
|
40
|
+
class Animal {
|
|
41
|
+
<<abstract>>
|
|
42
|
+
+name: string
|
|
43
|
+
+move() void
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class Dog {
|
|
47
|
+
+breed: string
|
|
48
|
+
+bark() void
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class Serializable {
|
|
52
|
+
<<interface>>
|
|
53
|
+
+serialize() string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class Leg
|
|
57
|
+
class Owner
|
|
58
|
+
|
|
59
|
+
Animal <|-- Dog
|
|
60
|
+
Serializable <|.. Dog
|
|
61
|
+
Dog *-- Leg
|
|
62
|
+
Owner "1" o-- "*" Dog : owns
|
|
63
|
+
Dog ..> Bone : chews
|
|
64
|
+
`;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { BASIC, CLASS_DIAGRAM };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.mjs","names":[],"sources":["../../src/testing.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n/**\n * Minimal layout discussion piece: three packages with three types each — an inheritance fan-in\n * (B, C extend A), a chain with a has-many (X ⇒ Y → Z), and a fan-in (P, R → Q), plus two\n * cross-package references (Y → A, Q → X) so routes must leave and enter frames. Small enough to\n * reason about every placement and route by eye. Relationship kinds are carried by the edge\n * tokens (UML end markers), not labels.\n */\nexport const BASIC = `\nflowchart TB\n subgraph pkgA [Package A]\n A[A]\n B[B]\n C[C]\n end\n subgraph pkgX [Package X]\n X[X]\n Y[Y]\n Z[Z]\n end\n subgraph pkgP [Package P]\n P[P]\n Q[Q]\n R[R]\n end\n B --|> A\n C --|> A\n X --{ Y\n Y --> Z\n P --> Q\n R --> Q\n Y --> A\n Q --> X\n`;\n\n/** Exercises class blocks, a stereotype, generics, cardinalities, and every relation kind. */\nexport const CLASS_DIAGRAM = `\nclassDiagram\n direction TB\n\n class Animal {\n <<abstract>>\n +name: string\n +move() void\n }\n\n class Dog {\n +breed: string\n +bark() void\n }\n\n class Serializable {\n <<interface>>\n +serialize() string\n }\n\n class Leg\n class Owner\n\n Animal <|-- Dog\n Serializable <|.. Dog\n Dog *-- Leg\n Owner \"1\" o-- \"*\" Dog : owns\n Dog ..> Bone : chews\n`;\n"],"mappings":";;;;;;;;AAWA,IAAa,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BrB,IAAa,gBAAgB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type * as Scene from './scene.ts';
|
|
2
|
+
/** Opaque map of record id → renderer record. */
|
|
3
|
+
export type ContentMap = Record<string, any>;
|
|
4
|
+
/** DSL identity stamped onto a managed record. */
|
|
5
|
+
export type Identity = {
|
|
6
|
+
object: string;
|
|
7
|
+
element: string;
|
|
8
|
+
/** Set on companion records that belong to an element rather than being one (e.g. arrow labels). */
|
|
9
|
+
part?: string;
|
|
10
|
+
};
|
|
11
|
+
/** Where an object sits on the canvas: `canvas = origin + local * scale`. */
|
|
12
|
+
export type Placement = {
|
|
13
|
+
origin: Scene.Point;
|
|
14
|
+
scale: number;
|
|
15
|
+
};
|
|
16
|
+
/** An object as accepted by the renderer's compiler; `upsert-elements` supplies only a subset. */
|
|
17
|
+
export type ObjectInput = Scene.WorldObject | {
|
|
18
|
+
id: string;
|
|
19
|
+
elements: readonly Scene.Element[];
|
|
20
|
+
};
|
|
21
|
+
/** A world object as derived from the canvas: placement is always resolved. */
|
|
22
|
+
export type ReadWorldObject = Scene.WorldObject & Placement;
|
|
23
|
+
export type ReadResult = {
|
|
24
|
+
scene: {
|
|
25
|
+
objects: ReadWorldObject[];
|
|
26
|
+
};
|
|
27
|
+
/** Records on the canvas not managed by the DSL (drawn by hand). */
|
|
28
|
+
unmanaged: number;
|
|
29
|
+
};
|
|
30
|
+
export type ApplyResult = {
|
|
31
|
+
/** Object ids created or modified. */
|
|
32
|
+
upserted: string[];
|
|
33
|
+
/** Records removed. */
|
|
34
|
+
removed: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The renderer-specific half of command application: how records carry identity, how objects
|
|
38
|
+
* compile to records, and any bookkeeping the renderer's store requires.
|
|
39
|
+
*/
|
|
40
|
+
export type ContentHandler = {
|
|
41
|
+
/** DSL identity for a record, or undefined when the record isn't managed by the DSL. */
|
|
42
|
+
identify: (record: any) => Identity | undefined;
|
|
43
|
+
/** Compile an object's elements into records keyed by record id. */
|
|
44
|
+
render: (object: ObjectInput, placement: Placement, content: ContentMap) => ContentMap;
|
|
45
|
+
/** Derive the scene from the content map. */
|
|
46
|
+
read: (content: ContentMap) => ReadResult;
|
|
47
|
+
/** Translate an object move into a per-record mutation. */
|
|
48
|
+
translate: (record: any, delta: Scene.Point) => void;
|
|
49
|
+
/** Create any scaffolding the renderer needs before its first record (e.g. a page). */
|
|
50
|
+
scaffold?: (content: ContentMap) => void;
|
|
51
|
+
/** Merge compiled records into the content map; defaults to a plain assign. */
|
|
52
|
+
merge?: (content: ContentMap, records: ContentMap) => void;
|
|
53
|
+
/** Clean up after deletions (e.g. drop bindings left dangling). */
|
|
54
|
+
prune?: (content: ContentMap) => void;
|
|
55
|
+
};
|
|
56
|
+
/** Apply a batch of edit commands to the canvas content (mutates `content`). */
|
|
57
|
+
export declare const applyCommands: (content: ContentMap, commands: readonly Scene.Command[], handler: ContentHandler) => ApplyResult;
|
|
58
|
+
/** Seed a fractional-index counter past any existing `a<n>` indexes. */
|
|
59
|
+
export declare const nextIndex: (content: ContentMap, isCounted?: (record: any) => boolean) => number;
|
|
60
|
+
//# sourceMappingURL=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ACpE,MAAM,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,KAAK,UAAU,CAAC;IACvF,6CAA6C;IAC7C,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,UAAU,CAAC;IAC1C,2DAA2D;IAC3D,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;IACrD,uFAAuF;IACvF,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,+EAA+E;IAC/E,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;IAC3D,mEAAmE;IACnE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,aAAa,YACf,UAAU,YACT,SAAS,KAAK,CAAC,OAAO,EAAE,WACzB,cAAc,KACtB,WAqFF,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,SAAS,YAAa,UAAU,cAAa,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,KAAgB,MAcjG,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as Schema from 'effect/Schema';
|
|
2
|
+
import type * as Scene from './scene.ts';
|
|
3
|
+
export declare const Severity: Schema.Literals<readonly ["error", "warning"]>;
|
|
4
|
+
export type Severity = Schema.Schema.Type<typeof Severity>;
|
|
5
|
+
/**
|
|
6
|
+
* `error` codes are objective defects — the picture is wrong, not merely busy — and gate CI.
|
|
7
|
+
* `warning` codes are quality metrics that trend rather than pass/fail; they are golden-filed so
|
|
8
|
+
* a layout change reads as a reviewable diff instead of a threshold argument.
|
|
9
|
+
*/
|
|
10
|
+
export declare const Code: Schema.Literals<readonly ["node-overlap", "route-through-node", "label-overflow", "edge-crossing", "excessive-bends"]>;
|
|
11
|
+
export type Code = Schema.Schema.Type<typeof Code>;
|
|
12
|
+
export declare const SEVERITY: Record<Code, Severity>;
|
|
13
|
+
/** A schema so operations can return diagnostics to the agent — the repair loop. */
|
|
14
|
+
export declare const Diagnostic: Schema.Struct<{
|
|
15
|
+
readonly code: Schema.Literals<readonly ["node-overlap", "route-through-node", "label-overflow", "edge-crossing", "excessive-bends"]>;
|
|
16
|
+
readonly severity: Schema.Literals<readonly ["error", "warning"]>;
|
|
17
|
+
readonly message: Schema.String;
|
|
18
|
+
readonly refs: Schema.$Array<Schema.String>;
|
|
19
|
+
}>;
|
|
20
|
+
export type Diagnostic = Schema.Schema.Type<typeof Diagnostic>;
|
|
21
|
+
/** Aggregate counts; the soft ones are the score a layout change is reviewed against. */
|
|
22
|
+
export type Metrics = {
|
|
23
|
+
nodes: number;
|
|
24
|
+
connectors: number;
|
|
25
|
+
overlaps: number;
|
|
26
|
+
routesThroughNodes: number;
|
|
27
|
+
labelOverflows: number;
|
|
28
|
+
crossings: number;
|
|
29
|
+
bends: number;
|
|
30
|
+
/** Total connector length in scene units; long edges are hard to follow. */
|
|
31
|
+
length: number;
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
/** Boxes that enclose another object's box (subgraph / group frames). */
|
|
35
|
+
containers: number;
|
|
36
|
+
/** Smallest gap from a container to its nearest container (Infinity with fewer than two). */
|
|
37
|
+
frameGapMin: number;
|
|
38
|
+
/** Spread (max − min) of each container's nearest-neighbour gap; 0 when gutters are uniform. */
|
|
39
|
+
frameGapSpread: number;
|
|
40
|
+
};
|
|
41
|
+
export type Report = {
|
|
42
|
+
diagnostics: readonly Diagnostic[];
|
|
43
|
+
metrics: Metrics;
|
|
44
|
+
};
|
|
45
|
+
export type Options = {
|
|
46
|
+
/** Bends per connector above which `excessive-bends` is reported (default 3). */
|
|
47
|
+
maxBends?: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Analyzes an emitted scene for layout defects and quality metrics. Pure: the same scene always
|
|
51
|
+
* yields the same report, so the soft metrics can be golden-filed and the hard codes asserted.
|
|
52
|
+
*/
|
|
53
|
+
export declare const analyze: (objects: readonly Scene.WorldObject[], { maxBends }?: Options) => Report;
|
|
54
|
+
/** Errors only — the set that gates CI and that an agent must fix before the diagram is usable. */
|
|
55
|
+
export declare const errors: (report: Report) => readonly Diagnostic[];
|
|
56
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/diagnostics.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC,eAAO,MAAM,QAAQ,gDAAwC,CAAC;AAC9D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,IAAI,wHAMf,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAM3C,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,UAAU;;;;;EAOrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,yFAAyF;AACzF,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,WAAW,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IACnC,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAyKF;;;GAGG;AACH,eAAO,MAAM,OAAO,YAAa,SAAS,KAAK,CAAC,WAAW,EAAE,iBAAoB,OAAO,KAAQ,MAsI/F,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,MAAM,WAAY,MAAM,KAAG,SAAS,UAAU,EACQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.test.d.ts","sourceRoot":"","sources":["../../../src/diagnostics.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as Effect from 'effect/Effect';
|
|
2
|
+
import * as Schema from 'effect/Schema';
|
|
3
|
+
import * as Scene from './scene.ts';
|
|
4
|
+
export type Dialect<Input = any> = {
|
|
5
|
+
id: string;
|
|
6
|
+
description: string;
|
|
7
|
+
input: Schema.Codec<Input, any>;
|
|
8
|
+
compile: (input: Input) => Effect.Effect<readonly Scene.Command[]>;
|
|
9
|
+
};
|
|
10
|
+
/** The core dialect: input is already scene edit commands (identity compile). */
|
|
11
|
+
export declare const sceneDialect: Dialect<readonly Scene.Command[]>;
|
|
12
|
+
export declare class DialectRegistry {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(dialects?: Dialect[]);
|
|
15
|
+
register(dialect: Dialect): void;
|
|
16
|
+
get(id: string): Dialect | undefined;
|
|
17
|
+
list(): Dialect[];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=dialect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../../../src/dialect.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,MAAM,MAAM,OAAO,CAAC,KAAK,GAAG,GAAG,IAAI;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;CACpE,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,SAAS,KAAK,CAAC,OAAO,EAAE,CAK1D,CAAC;AAEF,qBAAa,eAAe;;IAG1B,YAAY,QAAQ,GAAE,OAAO,EAAmB,EAE/C;IAED,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAG/B;IAED,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEnC;IAED,IAAI,IAAI,OAAO,EAAE,CAEhB;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './content.ts';
|
|
2
|
+
export * from './dialect.ts';
|
|
3
|
+
export * as Diagnostics from './diagnostics.ts';
|
|
4
|
+
export * as Layout from './layout.ts';
|
|
5
|
+
export * as Mermaid from './mermaid.ts';
|
|
6
|
+
export * as MermaidEngine from './mermaid-engine.ts';
|
|
7
|
+
export * as Objective from './objective.ts';
|
|
8
|
+
export * as Scene from './scene.ts';
|
|
9
|
+
export * from './svg-handler.ts';
|
|
10
|
+
export * as Ui from './ui.ts';
|
|
11
|
+
export * as Uml from './uml.ts';
|
|
12
|
+
export * as UmlEngine from './uml-engine.ts';
|
|
13
|
+
export * as UmlGrid from './uml-grid.ts';
|
|
14
|
+
export * as UmlRules from './uml-rules.ts';
|
|
15
|
+
export * as UmlSearch from './uml-search.ts';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as Scene from './scene.ts';
|
|
2
|
+
export type LayoutEdge = {
|
|
3
|
+
from: string;
|
|
4
|
+
to: string;
|
|
5
|
+
};
|
|
6
|
+
export type FontMetrics = {
|
|
7
|
+
/** Average glyph advance, in scene units at scale 1. */
|
|
8
|
+
charW: number;
|
|
9
|
+
/** Line height, in scene units at scale 1. */
|
|
10
|
+
lineH: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Empirical text metrics per scene weight, calibrated to tldraw's draw font (`size` s/m/l/xl runs
|
|
14
|
+
* ~18/25/38/48 px): charW ≈ 0.6–0.67 em, lineH ≈ 1.35 em. Dialects size boxes from these so text
|
|
15
|
+
* fits without the renderer growing shapes over their neighbours.
|
|
16
|
+
*/
|
|
17
|
+
export declare const FONT_METRICS: Record<Scene.Weight, FontMetrics>;
|
|
18
|
+
/**
|
|
19
|
+
* Edges that close a cycle, found by DFS: an edge into a node still on the stack points backwards.
|
|
20
|
+
* Ranking ignores them, so `C --> Y --> C` ranks C by its forward predecessors alone instead of
|
|
21
|
+
* chasing the loop.
|
|
22
|
+
*/
|
|
23
|
+
export declare const backEdges: <Edge extends LayoutEdge>(nodeIds: readonly string[], edges: readonly Edge[]) => Set<Edge>;
|
|
24
|
+
/** Assign each node a rank one past its deepest forward predecessor. */
|
|
25
|
+
export declare const rank: (nodeIds: readonly string[], edges: readonly LayoutEdge[]) => Map<string, number>;
|
|
26
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/layout.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,CAK1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,IAAI,SAAS,UAAU,WAAW,SAAS,MAAM,EAAE,SAAS,SAAS,IAAI,EAAE,KAAG,GAAG,CAAC,IAAI,CAoC/G,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,IAAI,YAAa,SAAS,MAAM,EAAE,SAAS,SAAS,UAAU,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAkBjG,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as Objective from './objective.ts';
|
|
2
|
+
import type * as Scene from './scene.ts';
|
|
3
|
+
import { type Router } from './uml-grid.ts';
|
|
4
|
+
/** How ELK orders siblings within a layer. */
|
|
5
|
+
export type Order = 'model' | 'free';
|
|
6
|
+
/**
|
|
7
|
+
* How groups relate: `layered` lays the whole hierarchy out in one flow (groups stack along it);
|
|
8
|
+
* `columns` lays each group out in the flow direction and arranges the groups side by side
|
|
9
|
+
* across it, so cross-package edges run sideways instead of stacking packages.
|
|
10
|
+
*/
|
|
11
|
+
export type Arrangement = 'layered' | 'columns';
|
|
12
|
+
/**
|
|
13
|
+
* How a plain reference ranks its ends. Inheritance always ranks the base above, has-many and
|
|
14
|
+
* containment the owner above; a reference has no such convention, so it is a candidate axis:
|
|
15
|
+
* `down` — the referenced sits below, ELK's reading of an arrow; `up` — the referenced sits above,
|
|
16
|
+
* as the abstraction does, so a node many others point at heads its package; `free` — a reference
|
|
17
|
+
* ranks nothing and its ends may share a row. Between packages a reference always orders the packages.
|
|
18
|
+
*/
|
|
19
|
+
export type Layering = 'down' | 'up' | 'free';
|
|
20
|
+
/**
|
|
21
|
+
* How packages sit along the flow in `columns`: `none` keeps ELK's placement; `edges` shifts each
|
|
22
|
+
* package by whole rows to where its cross-package edges meet their partners' rows, so those edges
|
|
23
|
+
* run straight instead of jogging between a short package and a tall one.
|
|
24
|
+
*/
|
|
25
|
+
export type Alignment = 'none' | 'edges';
|
|
26
|
+
export type CompileOptions = {
|
|
27
|
+
/** Canvas position of the diagram's top-left, in canvas px. */
|
|
28
|
+
origin?: Scene.Point;
|
|
29
|
+
/** Canvas px per scene unit. */
|
|
30
|
+
scale?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Pitch of the placement lattice as a multiple of the cell size. Node origins snap to lattice
|
|
33
|
+
* points, so nodes that ELK placed roughly in line share an axis exactly and their connectors
|
|
34
|
+
* run straight; the gutter between neighbours is `(lattice − 1) × cell`. A list names the
|
|
35
|
+
* candidates the objective chooses among (default `[1.5, 2]`); a number fixes it.
|
|
36
|
+
*/
|
|
37
|
+
lattice?: number | readonly number[];
|
|
38
|
+
/** ELK sibling ordering candidates (default both): declaration order, or free to minimize crossings. */
|
|
39
|
+
order?: readonly Order[];
|
|
40
|
+
/** Group arrangement candidates (default both when the graph has two or more groups). */
|
|
41
|
+
arrangement?: readonly Arrangement[];
|
|
42
|
+
/** How references rank their ends (default all three candidates). */
|
|
43
|
+
layering?: readonly Layering[];
|
|
44
|
+
/** Package alignment candidates along the flow, in `columns` (default both). */
|
|
45
|
+
alignment?: readonly Alignment[];
|
|
46
|
+
/**
|
|
47
|
+
* Inheritance bus candidates (default both): with `true`, subtypes on one row that share a base
|
|
48
|
+
* connect through one horizontal bus and a single triangle-headed trunk instead of parallel arrows.
|
|
49
|
+
*/
|
|
50
|
+
bus?: readonly boolean[];
|
|
51
|
+
/** Objective that picks among candidates (default `Objective.DEFAULT`). */
|
|
52
|
+
objective?: Objective.Objective;
|
|
53
|
+
/** Maximum cell width, in scene units (default GRID × 6); longer labels wrap. */
|
|
54
|
+
maxWidth?: number;
|
|
55
|
+
/** Connector router (default: obstacle-avoiding A* with the Z-router as fallback). */
|
|
56
|
+
route?: Router;
|
|
57
|
+
};
|
|
58
|
+
/** One generated layout with the objective's verdict on it. */
|
|
59
|
+
export type Candidate = {
|
|
60
|
+
lattice: number;
|
|
61
|
+
order: Order;
|
|
62
|
+
arrangement: Arrangement;
|
|
63
|
+
layering: Layering;
|
|
64
|
+
alignment: Alignment;
|
|
65
|
+
bus: boolean;
|
|
66
|
+
commands: Scene.Command[];
|
|
67
|
+
layout: Objective.Layout;
|
|
68
|
+
};
|
|
69
|
+
export type Result = {
|
|
70
|
+
commands: Scene.Command[];
|
|
71
|
+
chosen: Objective.Ranked<Candidate>;
|
|
72
|
+
/** Every candidate, best first. */
|
|
73
|
+
ranked: readonly Objective.Ranked<Candidate>[];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Lay out a mermaid flowchart: place once per lattice × ordering, emit with and without the
|
|
77
|
+
* inheritance bus, analyze every candidate, and let the objective choose. All candidates come back
|
|
78
|
+
* ranked so a bench can show what lost and why. Async because ELK is.
|
|
79
|
+
*/
|
|
80
|
+
export declare const layout: (source: string, options?: CompileOptions) => Promise<Result>;
|
|
81
|
+
/** The chosen layout's scene commands; see {@link layout} for the candidates and verdicts. */
|
|
82
|
+
export declare const compile: (source: string, options?: CompileOptions) => Promise<Scene.Command[]>;
|
|
83
|
+
//# sourceMappingURL=mermaid-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid-engine.d.ts","sourceRoot":"","sources":["../../../src/mermaid-engine.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,EAAmB,KAAK,MAAM,EAAW,MAAM,eAAe,CAAC;AAsBtE,8CAA8C;AAC9C,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAWzC,M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AM,CAAC,SAAS,CAAC,EAAE,CAAC;CAChD,CAAC;AAmpBF;;;;GAIG;AACH,eAAO,MAAM,MAAM,WAAkB,MAAM,YAAW,cAAc,KAAQ,OAAO,CAAC,MAAM,CAiEzF,CAAC;AAEF,8FAA8F;AAC9F,eAAO,MAAM,OAAO,WAAkB,MAAM,YAAW,cAAc,KAAQ,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,CAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid-engine.test.d.ts","sourceRoot":"","sources":["../../../src/mermaid-engine.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type * as Scene from './scene.ts';
|
|
2
|
+
export type Direction = 'TB' | 'BT' | 'LR' | 'RL';
|
|
3
|
+
export type MermaidNode = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Enclosing subgraph id, when declared inside one. */
|
|
7
|
+
group?: string;
|
|
8
|
+
/** What the node depicts (DXN or URI), from a `%% ref <id> <target>` directive. */
|
|
9
|
+
ref?: string;
|
|
10
|
+
};
|
|
11
|
+
export type MermaidGroup = {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
children: string[];
|
|
15
|
+
};
|
|
16
|
+
/** Relationship kind, from the edge token; drawn with the UML end markers in `markers`. */
|
|
17
|
+
export type RelationKind = 'reference' | 'inheritance' | 'hasMany' | 'contains';
|
|
18
|
+
export type MermaidEdge = {
|
|
19
|
+
from: string;
|
|
20
|
+
to: string;
|
|
21
|
+
kind: RelationKind;
|
|
22
|
+
label?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Rewrite the UML edge tokens into mermaid-legal labelled arrows, for rendering the source with
|
|
26
|
+
* mermaid.js itself (as a reference beside our layout). Lossy by design: mermaid flowcharts have no
|
|
27
|
+
* triangle or crow's foot, so the kind becomes the label unless the edge already has one; `%% ref`
|
|
28
|
+
* lines are already comments.
|
|
29
|
+
*/
|
|
30
|
+
export declare const toStandard: (source: string) => string;
|
|
31
|
+
/** Scene arrow markers for a relationship kind. */
|
|
32
|
+
export declare const markers: (kind: RelationKind) => Pick<Scene.Arrow, 'head' | 'tail'>;
|
|
33
|
+
export type MermaidGraph = {
|
|
34
|
+
direction: Direction;
|
|
35
|
+
nodes: MermaidNode[];
|
|
36
|
+
groups: MermaidGroup[];
|
|
37
|
+
edges: MermaidEdge[];
|
|
38
|
+
};
|
|
39
|
+
/** Parse a mermaid flowchart into a neutral graph. Unrecognised lines are ignored. */
|
|
40
|
+
export declare const parse: (source: string) => MermaidGraph;
|
|
41
|
+
export type CompileOptions = {
|
|
42
|
+
/** Canvas position of the diagram's top-left, in canvas px. */
|
|
43
|
+
origin?: Scene.Point;
|
|
44
|
+
/** Canvas px per scene unit. */
|
|
45
|
+
scale?: number;
|
|
46
|
+
/** Gap between ranks along the flow direction, in scene units (default 60). */
|
|
47
|
+
gapMain?: number;
|
|
48
|
+
/** Gap between nodes within a rank, in scene units (default 40). */
|
|
49
|
+
gapCross?: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Compile a mermaid flowchart into scene commands: one world object per node (element `box`),
|
|
53
|
+
* one per subgraph frame, and an `edges` object holding the connectors as bound arrows.
|
|
54
|
+
*/
|
|
55
|
+
export declare const compile: (source: string, options?: CompileOptions) => Scene.Command[];
|
|
56
|
+
//# sourceMappingURL=mermaid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../src/mermaid.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CA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GG;AACH,eAAO,MAAM,OAAO,WAAY,MAAM,YAAW,cAAc,KAAQ,KAAK,CAAC,OAAO,EAiGnF,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Exercises node declarations, a labelled-blank subgraph, fan-out, and a `C <-> Y` cycle. */
|
|
2
|
+
export declare const FLOWCHART = "\nflowchart TB\n X[X]\n\n subgraph CORE[\" \"]\n A[A]\n B[B]\n C[C]\n\n A --> B\n A --> C\n end\n\n Y[Y]\n\n X --> A\n X --> B\n X --> C\n C --> Y\n Y --> C\n";
|
|
3
|
+
//# sourceMappingURL=mermaid.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.test.d.ts","sourceRoot":"","sources":["../../../src/mermaid.test.ts"],"names":[],"mappings":"AASA,8FAA8F;AAC9F,eAAO,MAAM,SAAS,iOAoBrB,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type * as Diagnostics from './diagnostics.ts';
|
|
2
|
+
import type * as Scene from './scene.ts';
|
|
3
|
+
/** A candidate layout: the scene plus its analysis. */
|
|
4
|
+
export type Layout = {
|
|
5
|
+
objects: readonly Scene.WorldObject[];
|
|
6
|
+
report: Diagnostics.Report;
|
|
7
|
+
};
|
|
8
|
+
/** Hard requirement; `violations` names each way the layout breaks it, empty when it holds. */
|
|
9
|
+
export type Constraint = {
|
|
10
|
+
id: string;
|
|
11
|
+
description: string;
|
|
12
|
+
violations: (layout: Layout) => readonly string[];
|
|
13
|
+
};
|
|
14
|
+
/** Soft preference; `measure` is in the term's natural unit and `weight` converts it to cost. */
|
|
15
|
+
export type CostTerm = {
|
|
16
|
+
id: string;
|
|
17
|
+
description: string;
|
|
18
|
+
weight: number;
|
|
19
|
+
measure: (layout: Layout) => number;
|
|
20
|
+
};
|
|
21
|
+
export type Objective = {
|
|
22
|
+
constraints: readonly Constraint[];
|
|
23
|
+
costs: readonly CostTerm[];
|
|
24
|
+
};
|
|
25
|
+
export type Evaluation = {
|
|
26
|
+
violations: readonly {
|
|
27
|
+
constraint: string;
|
|
28
|
+
message: string;
|
|
29
|
+
}[];
|
|
30
|
+
/** Weighted sum of the cost terms. */
|
|
31
|
+
cost: number;
|
|
32
|
+
terms: readonly {
|
|
33
|
+
id: string;
|
|
34
|
+
value: number;
|
|
35
|
+
weighted: number;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
export declare const evaluate: (objective: Objective, layout: Layout) => Evaluation;
|
|
39
|
+
export type Ranked<T> = {
|
|
40
|
+
candidate: T;
|
|
41
|
+
evaluation: Evaluation;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Picks the best candidate: fewest constraint violations first (so an infeasible set still yields
|
|
45
|
+
* the least-bad layout rather than nothing), then lowest cost. Stable on ties, so the generator's
|
|
46
|
+
* own order breaks them.
|
|
47
|
+
*/
|
|
48
|
+
export declare const select: <T extends {
|
|
49
|
+
layout: Layout;
|
|
50
|
+
}>(objective: Objective, candidates: readonly T[]) => {
|
|
51
|
+
chosen: Ranked<T>;
|
|
52
|
+
ranked: readonly Ranked<T>[];
|
|
53
|
+
};
|
|
54
|
+
/** Every `error` diagnostic is a violation: overlaps, routes through nodes, labels that do not fit. */
|
|
55
|
+
export declare const noHardDefects: Constraint;
|
|
56
|
+
/** Containers keep at least `gap` between them, so packages read as separate. */
|
|
57
|
+
export declare const framesApart: (gap?: number) => Constraint;
|
|
58
|
+
export declare const crossings: CostTerm;
|
|
59
|
+
export declare const bends: CostTerm;
|
|
60
|
+
/**
|
|
61
|
+
* Uneven gutters between frames, in grid units. Weighted so a whole cell of unevenness costs about
|
|
62
|
+
* half a crossing: on the pipeline corpus diagram a weight of 2 made the objective accept three
|
|
63
|
+
* crossings to even out a 7-unit spread, which no reader would.
|
|
64
|
+
*/
|
|
65
|
+
export declare const unevenFrameGaps: CostTerm;
|
|
66
|
+
/**
|
|
67
|
+
* Total connector length in grid units: a long edge is hard to follow even when it is straight.
|
|
68
|
+
* Weighted so ~100 grid units of extra connector cost one crossing — at 0.1 the objective traded
|
|
69
|
+
* crossings for shorter edges on the compute and edge corpus diagrams.
|
|
70
|
+
*/
|
|
71
|
+
export declare const connectorLength: CostTerm;
|
|
72
|
+
/** Bounding perimeter in grid units; a light preference for the tighter of otherwise-equal layouts. */
|
|
73
|
+
export declare const compactness: CostTerm;
|
|
74
|
+
export declare const DEFAULT: Objective;
|
|
75
|
+
//# sourceMappingURL=objective.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objective.d.ts","sourceRoot":"","sources":["../../../src/objective.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,WAAW,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAGzC,uDAAuD;AACvD,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,EAAE,SAAS,KAAK,CAAC,WAAW,EAAE,CAAC;IACtC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;CAC5B,CAAC;AAEF,+FAA+F;AAC/F,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,MAAM,EAAE,CAAC;CACnD,CAAC;AAEF,iGAAiG;AACjG,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IACnC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,SAAS;QAA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":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Rect, Router } from './uml-grid.ts';
|
|
2
|
+
export type AvoidingRouterOptions = {
|
|
3
|
+
/** Search-cell size (scene px): a fraction of the layout grid, so routes can hug node borders. */
|
|
4
|
+
step: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Creates a router that avoids the given node rects. Stateful across edges: earlier routes
|
|
8
|
+
* penalize (not block) the cells they occupy, spreading parallel runs apart. `fallback` handles
|
|
9
|
+
* the (fenced-in) edges the search cannot reach. The step is passed in rather than derived from
|
|
10
|
+
* `uml-grid`'s `GRID`, which keeps this module free of a value import cycle with the dialects.
|
|
11
|
+
*/
|
|
12
|
+
export declare const makeAvoidingRouter: (obstacles: Rect[], fallback: Router, { step: STEP }: AvoidingRouterOptions) => Router;
|
|
13
|
+
//# sourceMappingURL=ortho-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ortho-router.d.ts","sourceRoot":"","sources":["../../../src/ortho-router.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,EAAE,MAAM,eAAe,CAAC;AAiBlE,MAAM,MAAM,qBAAqB,GAAG;IAClC,kGAAkG;IAClG,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,cAClB,IAAI,EAAE,YACP,MAAM,kBACA,qBAAqB,KACpC,MAuUF,CAAC"}
|