@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 @@
|
|
|
1
|
+
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../../src/scene.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,KAAK,sKAchB,CAAC;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC;AAErD,eAAO,MAAM,IAAI,wDAAgD,CAAC;AAClE,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnD,eAAO,MAAM,MAAM,oEAA4D,CAAC;AAChF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,MAAM,iDAAyC,CAAC;AAC7D,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,KAAK;;;EAGhB,CAAC;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI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ources":["../../../src/scene.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ContentHandler } from './content.ts';
|
|
2
|
+
/** Discriminates the base `Drawing.Canvas` as SVG-rendered scene content. */
|
|
3
|
+
export declare const SVG_SCHEMA = "dxos.org/svg/1";
|
|
4
|
+
export declare const SvgHandler: ContentHandler;
|
|
5
|
+
//# sourceMappingURL=svg-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-handler.d.ts","sourceRoot":"","sources":["../../../src/svg-handler.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,cAAc,EAAyC,MAAM,cAAc,CAAC;AAG1F,6EAA6E;AAC7E,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAgC3C,eAAO,MAAM,UAAU,EAAE,cAuExB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-handler.test.d.ts","sourceRoot":"","sources":["../../../src/svg-handler.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal layout discussion piece: three packages with three types each — an inheritance fan-in
|
|
3
|
+
* (B, C extend A), a chain with a has-many (X ⇒ Y → Z), and a fan-in (P, R → Q), plus two
|
|
4
|
+
* cross-package references (Y → A, Q → X) so routes must leave and enter frames. Small enough to
|
|
5
|
+
* reason about every placement and route by eye. Relationship kinds are carried by the edge
|
|
6
|
+
* tokens (UML end markers), not labels.
|
|
7
|
+
*/
|
|
8
|
+
export declare 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";
|
|
9
|
+
/** Exercises class blocks, a stereotype, generics, cardinalities, and every relation kind. */
|
|
10
|
+
export declare 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";
|
|
11
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/testing.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,qTAyBjB,CAAC;AAEF,8FAA8F;AAC9F,eAAO,MAAM,aAAa,2cA4BzB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type * as Schema from 'effect/Schema';
|
|
2
|
+
import type * as Scene from './scene.ts';
|
|
3
|
+
export type ControlKind = 'input' | 'switch' | 'checkbox' | 'select';
|
|
4
|
+
export type Control = {
|
|
5
|
+
kind: 'control';
|
|
6
|
+
control: ControlKind;
|
|
7
|
+
label: string;
|
|
8
|
+
/** Dotted schema path; doubles as the element id so drawn controls stay addressable. */
|
|
9
|
+
path: string;
|
|
10
|
+
};
|
|
11
|
+
/** Nested object: a labeled group of fields. */
|
|
12
|
+
export type Group = {
|
|
13
|
+
kind: 'group';
|
|
14
|
+
label: string;
|
|
15
|
+
path: string;
|
|
16
|
+
children: FormChild[];
|
|
17
|
+
};
|
|
18
|
+
/** Array: a labeled repetition of one item template. */
|
|
19
|
+
export type ArrayGroup = {
|
|
20
|
+
kind: 'array';
|
|
21
|
+
label: string;
|
|
22
|
+
path: string;
|
|
23
|
+
/** The element template, rendered once with a trailing "+" affordance. */
|
|
24
|
+
item: FormChild;
|
|
25
|
+
};
|
|
26
|
+
export type FormChild = Control | Group | ArrayGroup;
|
|
27
|
+
/** A form has no title of its own — the schema title belongs to the enclosing container. */
|
|
28
|
+
export type Form = {
|
|
29
|
+
kind: 'form';
|
|
30
|
+
children: FormChild[];
|
|
31
|
+
};
|
|
32
|
+
export type Panel = {
|
|
33
|
+
kind: 'panel';
|
|
34
|
+
label?: string;
|
|
35
|
+
child: Form;
|
|
36
|
+
};
|
|
37
|
+
export type Plank = {
|
|
38
|
+
kind: 'plank';
|
|
39
|
+
label?: string;
|
|
40
|
+
child: Panel;
|
|
41
|
+
};
|
|
42
|
+
export type Deck = {
|
|
43
|
+
kind: 'deck';
|
|
44
|
+
planks: Plank[];
|
|
45
|
+
};
|
|
46
|
+
export type UiNode = Deck | Plank | Panel | Form | FormChild;
|
|
47
|
+
export type FromSchemaOptions = {
|
|
48
|
+
/** Recursion guard for self-referential schemas. */
|
|
49
|
+
maxDepth?: number;
|
|
50
|
+
};
|
|
51
|
+
/** Convert a schema into a form drawing: the phase-1 slice of the app model. */
|
|
52
|
+
export declare const fromSchema: (schema: Schema.Top, options?: FromSchemaOptions) => Form;
|
|
53
|
+
/** The schema's title annotation — container chrome, not form content. */
|
|
54
|
+
export declare const schemaTitle: (schema: Schema.Top) => string | undefined;
|
|
55
|
+
/** Wrap a form in the app-ontology containers for a full schematic. */
|
|
56
|
+
export declare const deckOf: (form: Form, title?: string) => Deck;
|
|
57
|
+
export type CompileOptions = {
|
|
58
|
+
/** Canvas position of the schematic's top-left, in canvas px. */
|
|
59
|
+
origin?: Scene.Point;
|
|
60
|
+
/** Canvas px per scene unit. */
|
|
61
|
+
scale?: number;
|
|
62
|
+
};
|
|
63
|
+
/** Compile a UI drawing into scene commands (frames first, controls above them). */
|
|
64
|
+
export declare const compile: (node: UiNode, options?: CompileOptions) => Scene.Command[];
|
|
65
|
+
/** Render a UI drawing as ASCII art. */
|
|
66
|
+
export declare const renderAscii: (node: UiNode) => string;
|
|
67
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
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AC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AACpE,MAAM,MAAM,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,CAAC;AAErD,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAQ7D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAiEF,gFAAgF;AAChF,eAAO,MAAM,UAAU,WAAY,MAAM,CAAC,GAAG,YAAW,iBAAiB,KAAQ,IAMhF,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,WAAW,WAAY,MAAM,CAAC,GAAG,KAAG,MAAM,GAAG,SAAgC,CAAC;AAE3F,uEAAuE;AACvE,eAAO,MAAM,MAAM,SAAU,IAAI,UAAU,MAAM,KAAG,IAGlD,CAAC;AA0KH,MAAM,MAAM,cAAc,GAAG;IAC3B,iEAAiE;IACjE,MAAM,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;IACrB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,OAAO,SAAU,MAAM,YAAW,cAAc,KAAQ,KAAK,CAAC,OAAO,EAmBjF,CAAC;AA+CF,wCAAwC;AACxC,eAAO,MAAM,WAAW,SAAU,MAAM,KAAG,MAAqC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.test.d.ts","sourceRoot":"","sources":["../../../src/ui.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as Scene from './scene.ts';
|
|
2
|
+
import { type CompileOptions as GridCompileOptions } from './uml-grid.ts';
|
|
3
|
+
export type Engine = 'dagre' | 'elk';
|
|
4
|
+
export type CompileOptions = Omit<GridCompileOptions, 'route'> & {
|
|
5
|
+
/** Placement engine (default 'elk'). */
|
|
6
|
+
engine?: Engine;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Compile a mermaid class diagram with engine-backed placement; identical output structure to
|
|
10
|
+
* `UmlGrid.compile` (equal-size grid cells, orthogonal Z-routed connectors), but node positions
|
|
11
|
+
* come from dagre/ELK. Async because ELK is.
|
|
12
|
+
*/
|
|
13
|
+
export declare const compile: (source: string, options?: CompileOptions) => Promise<Scene.Command[]>;
|
|
14
|
+
//# sourceMappingURL=uml-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml-engine.d.ts","sourceRoot":"","sources":["../../../src/uml-engine.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,EAGL,KAAK,cAAc,IAAI,kBAAkB,EAI1C,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAErC,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG;IAC/D,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAkGF;;;;GAIG;AACH,eAAO,MAAM,OAAO,WAAkB,MAAM,YAAW,cAAc,KAAQ,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,CAYnG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml-engine.test.d.ts","sourceRoot":"","sources":["../../../src/uml-engine.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as Layout from './layout.ts';
|
|
2
|
+
import type * as Scene from './scene.ts';
|
|
3
|
+
import { type UmlModel } from './uml.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Snap unit for cells, gaps, and positions, chosen so node edges land on the grid lines tldraw
|
|
6
|
+
* renders at working zoom (it draws lines at power-of-two multiples of its document gridSize).
|
|
7
|
+
*/
|
|
8
|
+
export declare const GRID = 32;
|
|
9
|
+
/** Node rect in scene units. */
|
|
10
|
+
export type Rect = {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
w: number;
|
|
14
|
+
h: number;
|
|
15
|
+
};
|
|
16
|
+
export type RoutedRelation = {
|
|
17
|
+
/** The edge being routed; routers read only its endpoints, so any dialect's edge type fits. */
|
|
18
|
+
relation: Layout.LayoutEdge;
|
|
19
|
+
from: Rect;
|
|
20
|
+
to: Rect;
|
|
21
|
+
/** True when the diagram flows LR/RL, so ranks stack along x. */
|
|
22
|
+
horizontal: boolean;
|
|
23
|
+
/** Channel slot among relations sharing a gutter, centered on it (shift = offset × GRID_FINE). */
|
|
24
|
+
offset: number;
|
|
25
|
+
/** Terminal cross-axis coordinates (port positions); node-edge centers when omitted. */
|
|
26
|
+
ports?: {
|
|
27
|
+
start?: number;
|
|
28
|
+
end?: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Produces the connector waypoints for one relation, in scene units. The returned polyline is
|
|
33
|
+
* rendered verbatim (last segment carries the arrowhead), so a router fully controls the path.
|
|
34
|
+
*/
|
|
35
|
+
export type Router = (edge: RoutedRelation) => Scene.Point[];
|
|
36
|
+
/**
|
|
37
|
+
* Default router: an orthogonal Z along the flow axis — rank-crossing edges route through the
|
|
38
|
+
* inter-rank gutter (channel shifted per parallel edge); same-rank edges route out the side.
|
|
39
|
+
*/
|
|
40
|
+
export declare const zRouter: Router;
|
|
41
|
+
/** Fixed cell size, in scene units; omitted dimensions are measured from content. */
|
|
42
|
+
export type CellSize = {
|
|
43
|
+
w?: number;
|
|
44
|
+
h?: number;
|
|
45
|
+
};
|
|
46
|
+
export type Cell = {
|
|
47
|
+
w: number;
|
|
48
|
+
h: number;
|
|
49
|
+
titleH: number;
|
|
50
|
+
};
|
|
51
|
+
export type MeasureOptions = {
|
|
52
|
+
maxWidth: number;
|
|
53
|
+
cell?: CellSize;
|
|
54
|
+
titleHeight?: number;
|
|
55
|
+
};
|
|
56
|
+
/** One cell fits the largest class: widest line (wrapped at maxWidth) and tallest member list. */
|
|
57
|
+
export declare const measureCell: (model: UmlModel, { maxWidth, cell: override, titleHeight }: MeasureOptions) => Cell;
|
|
58
|
+
export type CompileOptions = {
|
|
59
|
+
/** Canvas position of the diagram's top-left, in canvas px. */
|
|
60
|
+
origin?: Scene.Point;
|
|
61
|
+
/** Canvas px per scene unit. */
|
|
62
|
+
scale?: number;
|
|
63
|
+
/** Gap between ranks along the flow direction, in scene units (default GRID × 4, snapped). */
|
|
64
|
+
gapMain?: number;
|
|
65
|
+
/** Gap between classes within a rank, in scene units (default GRID × 4, snapped). */
|
|
66
|
+
gapCross?: number;
|
|
67
|
+
/** Maximum cell width, in scene units (default GRID × 6); longer lines wrap. */
|
|
68
|
+
maxWidth?: number;
|
|
69
|
+
/** Fixed cell size (snapped to GRID); overrides measurement per dimension. */
|
|
70
|
+
cell?: CellSize;
|
|
71
|
+
/** Fixed header height, in scene units (snapped to the fine grid); measured when unset. */
|
|
72
|
+
titleHeight?: number;
|
|
73
|
+
/** Connector routing (default `zRouter`). */
|
|
74
|
+
route?: Router;
|
|
75
|
+
};
|
|
76
|
+
/** A placed diagram: the parsed model plus per-class node rects (scene units). */
|
|
77
|
+
export type Placement = {
|
|
78
|
+
model: UmlModel;
|
|
79
|
+
cell: Cell;
|
|
80
|
+
rects: Map<string, Rect>;
|
|
81
|
+
ranks: Map<string, number>;
|
|
82
|
+
};
|
|
83
|
+
export type EmitOptions = {
|
|
84
|
+
origin?: Scene.Point;
|
|
85
|
+
scale?: number;
|
|
86
|
+
route?: Router;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Compile a mermaid class diagram into scene commands with equal-size grid-aligned nodes: per
|
|
90
|
+
* class a `title` bar plus a `body` compartment filling the cell, and an `edges` object holding
|
|
91
|
+
* orthogonal connector paths (polyline waypoints, an arrowhead segment, and a floating label).
|
|
92
|
+
*/
|
|
93
|
+
export declare const compile: (source: string, options?: CompileOptions) => Scene.Command[];
|
|
94
|
+
/**
|
|
95
|
+
* Emit scene commands from a placed model — the shared back half of `compile`, also used by the
|
|
96
|
+
* engine-backed dialects (`uml-engine.ts`) which supply their own placement.
|
|
97
|
+
*/
|
|
98
|
+
export declare const emit: ({ model, cell, rects, ranks }: Placement, { origin, scale, route }?: EmitOptions) => Scene.Command[];
|
|
99
|
+
//# sourceMappingURL=uml-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml-grid.d.ts","sourceRoot":"","sources":["../../../src/uml-grid.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,KAAK,QAAQ,EAAuE,MAAM,UAAU,CAAC;AAE9G;;;GAGG;AACH,eAAO,MAAM,IAAI,KAAK,CAAC;AA0BvB,gCAAgC;AAChC,MAAM,MAAM,IAAI,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,+FAA+F;IAC/F,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,EAAE,EAAE,IAAI,CAAC;IACT,iEAAiE;IACjE,UAAU,EAAE,OAAO,CAAC;IACpB,kGAAkG;IAClG,MAAM,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,MAAM,G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EAAE,IAAI,CAAC,CAAC;IACzB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,WAAY,MAAM,YAAW,cAAc,KAAQ,KAAK,CAAC,OAAO,EAmCnF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,IAAI,kCACgB,SAAS,6BACO,WAAW,KACzD,KAAK,CAAC,OAAO,EAiPf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml-grid.test.d.ts","sourceRoot":"","sources":["../../../src/uml-grid.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type * as Scene from './scene.ts';
|
|
2
|
+
import { type Cell, type CompileOptions as GridCompileOptions, type Rect } from './uml-grid.ts';
|
|
3
|
+
import { type UmlModel } from './uml.ts';
|
|
4
|
+
/** A laid-out group: member rects in group-local coordinates plus the packed bounds. */
|
|
5
|
+
export type Group = {
|
|
6
|
+
id: string;
|
|
7
|
+
/** Rule that claimed the group (frame label; singletons carry none). */
|
|
8
|
+
rule?: string;
|
|
9
|
+
rects: Map<string, Rect>;
|
|
10
|
+
w: number;
|
|
11
|
+
h: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A layout rule: claims disjoint groups from the still-unclaimed nodes and lays each out
|
|
15
|
+
* internally. Rules run in priority order; unclaimed nodes fall through to singleton groups.
|
|
16
|
+
*/
|
|
17
|
+
export type GroupRule = {
|
|
18
|
+
id: string;
|
|
19
|
+
apply: (model: UmlModel, unclaimed: Set<string>, cell: Cell) => Group[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Inheritance trees: each supertype with claimable subtypes forms a group — the hierarchy stacks
|
|
23
|
+
* vertically (root on top, arrows up) and peers share a horizontal axis, packed as a tidy tree
|
|
24
|
+
* (each parent centered over its subtree).
|
|
25
|
+
*/
|
|
26
|
+
export declare const inheritanceTreeRule: GroupRule;
|
|
27
|
+
/**
|
|
28
|
+
* Longest linear chain: the longest path through the still-unclaimed up-oriented relation graph
|
|
29
|
+
* renders left to right (each target directly right of its source).
|
|
30
|
+
*/
|
|
31
|
+
export declare const linearChainRule: GroupRule;
|
|
32
|
+
export type CompileOptions = Omit<GridCompileOptions, 'route'> & {
|
|
33
|
+
/** Grouping rules, highest priority first. */
|
|
34
|
+
rules?: GroupRule[];
|
|
35
|
+
};
|
|
36
|
+
/** Run the rules over the model; leftovers become singleton groups. */
|
|
37
|
+
export declare const buildGroups: (model: UmlModel, cell: Cell, rules: GroupRule[]) => Group[];
|
|
38
|
+
/**
|
|
39
|
+
* Pack groups as super-nodes: rank by up-oriented cross-group edges (target group above), then
|
|
40
|
+
* lay ranks out as rows, bottom rank last — mirroring the node-level convention.
|
|
41
|
+
*/
|
|
42
|
+
export declare const packGroups: (model: UmlModel, groups: Group[]) => Map<string, Scene.Point>;
|
|
43
|
+
/** Absolute node rects for a (possibly partial) group placement. */
|
|
44
|
+
export declare const resolveRects: (groups: Group[], origins: Map<string, Scene.Point>) => Map<string, Rect>;
|
|
45
|
+
/** Dashed frames behind multi-node groups. */
|
|
46
|
+
export declare const frameCommands: (groups: Group[], origins: Map<string, Scene.Point>, { origin, scale }?: {
|
|
47
|
+
origin?: Scene.Point;
|
|
48
|
+
scale?: number;
|
|
49
|
+
}) => Scene.Command[];
|
|
50
|
+
/**
|
|
51
|
+
* Compile with rule-based grouping: rules claim groups, leftovers become singletons, groups pack
|
|
52
|
+
* as super-nodes ranked by their cross-group edges (lanes advance vertically; no borders overlap
|
|
53
|
+
* by construction), and multi-node groups render a dashed frame behind their members.
|
|
54
|
+
*/
|
|
55
|
+
export declare const compile: (source: string, options?: CompileOptions) => Scene.Command[];
|
|
56
|
+
//# sourceMappingURL=uml-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml-rules.d.ts","sourceRoot":"","sources":["../../../src/uml-rules.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,KAAK,IAAI,EAET,KAAK,cAAc,IAAI,kBAAkB,EACzC,KAAK,IAAI,EAGV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,QAAQ,EAAwB,MAAM,UAAU,CAAC;AAQ/D,wFAAwF;AACxF,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,KAAK,KAAK,EAAE,CAAC;CACzE,CAAC;AAUF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAuEjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,SAmD7B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG;IAC/D,8CAA8C;IAC9C,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;CACrB,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,WAAW,UAAW,QAAQ,QAAQ,IAAI,SAAS,SAAS,EAAE,KAAG,KAAK,EAelF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,UAAW,QAAQ,UAAU,KAAK,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAiCpF,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,YAAY,WAAY,KAAK,EAAE,WAAW,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,KAAG,GAAG,CAAC,MAAM,EAAE,IAAI,CAYjG,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,aAAa,WAChB,KAAK,EAAE,WACN,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,sBACO;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,KAC/E,KAAK,CAAC,OAAO,EAyBV,CAAC;AAEP;;;;GAIG;AACH,eAAO,MAAM,OAAO,WAAY,MAAM,YAAW,cAAc,KAAQ,KAAK,CAAC,OAAO,EAYnF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml-rules.test.d.ts","sourceRoot":"","sources":["../../../src/uml-rules.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as Scene from './scene.ts';
|
|
2
|
+
import { type CompileOptions as GridCompileOptions, type Rect } from './uml-grid.ts';
|
|
3
|
+
import { type Group, type GroupRule } from './uml-rules.ts';
|
|
4
|
+
import { type UmlModel } from './uml.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Layout score over the placed subset: +1 per straight or single-bend (L) route, −1 per crossing
|
|
7
|
+
* pair. Routes come from the cheap Z-router — the score ranks candidates, the A* router draws
|
|
8
|
+
* the final picture.
|
|
9
|
+
*/
|
|
10
|
+
export declare const scoreLayout: (model: UmlModel, rects: Map<string, Rect>) => number;
|
|
11
|
+
/**
|
|
12
|
+
* Greedy tree search: place the chain (or largest) group first, then repeatedly place the
|
|
13
|
+
* unplaced group connected to the earliest-placed node, trying axis-aligned candidates around
|
|
14
|
+
* the anchor (below and above preferred, then right/left, sliding off collisions) and keeping
|
|
15
|
+
* the best-scoring one.
|
|
16
|
+
*/
|
|
17
|
+
export declare const searchPlacement: (model: UmlModel, groups: Group[]) => Map<string, Scene.Point>;
|
|
18
|
+
export type CompileOptions = Omit<GridCompileOptions, 'route'> & {
|
|
19
|
+
rules?: GroupRule[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Compile via the scored search, falling back to whichever of {search, rank packing} scores
|
|
23
|
+
* higher — the search is greedy, so the packing occasionally beats it.
|
|
24
|
+
*/
|
|
25
|
+
export declare const compile: (source: string, options?: CompileOptions) => Scene.Command[];
|
|
26
|
+
//# sourceMappingURL=uml-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml-search.d.ts","sourceRoot":"","sources":["../../../src/uml-search.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AACzC,OAAO,EAAQ,KAAK,cAAc,IAAI,kBAAkB,EAAE,KAAK,IAAI,EAA8B,MAAM,eAAe,CAAC;AACvH,OAAO,EACL,KAAK,KAAK,EACV,KAAK,SAAS,EAOf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,QAAQ,EAAwB,MAAM,UAAU,CAAC;AA+C/D;;;;GAIG;AACH,eAAO,MAAM,WAAW,UAAW,QAAQ,SAAS,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAG,MA6BvE,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,QAAQ,UAAU,KAAK,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAkHzF,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG;IAC/D,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,WAAY,MAAM,YAAW,cAAc,KAAQ,KAAK,CAAC,OAAO,EAkBnF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml-search.test.d.ts","sourceRoot":"","sources":["../../../src/uml-search.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type * as Scene from './scene.ts';
|
|
2
|
+
export type Direction = 'TB' | 'BT' | 'LR' | 'RL';
|
|
3
|
+
export type UmlClass = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** e.g. "interface", "abstract", "enumeration". */
|
|
7
|
+
stereotype?: string;
|
|
8
|
+
attributes: string[];
|
|
9
|
+
methods: string[];
|
|
10
|
+
};
|
|
11
|
+
export type RelationKind = 'inheritance' | 'realization' | 'composition' | 'aggregation' | 'association' | 'dependency';
|
|
12
|
+
/** Rendered arrow direction: subtype → supertype, whole → part, source → target. */
|
|
13
|
+
export type UmlRelation = {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
kind: RelationKind;
|
|
17
|
+
label?: string;
|
|
18
|
+
fromCardinality?: string;
|
|
19
|
+
toCardinality?: string;
|
|
20
|
+
};
|
|
21
|
+
export type UmlModel = {
|
|
22
|
+
direction: Direction;
|
|
23
|
+
classes: UmlClass[];
|
|
24
|
+
relations: UmlRelation[];
|
|
25
|
+
};
|
|
26
|
+
/** Parse a mermaid class diagram into a neutral model. Unrecognised lines are ignored. */
|
|
27
|
+
export declare const parse: (source: string) => UmlModel;
|
|
28
|
+
/** Arrow styling per relation kind; dependency and realization render dashed, as in UML. */
|
|
29
|
+
export declare const relationStyle: (kind: RelationKind) => {
|
|
30
|
+
stroke?: Scene.Stroke;
|
|
31
|
+
};
|
|
32
|
+
/** Mid-arrow label: cardinalities and the diamond glyph UML puts at the whole end. */
|
|
33
|
+
export declare const relationText: (relation: UmlRelation) => string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Rank so arrows read upward where UML convention points at abstractions — inheritance,
|
|
36
|
+
* realization, and dependency targets sit above their sources; containment and association
|
|
37
|
+
* flow downward (whole/source above part/target).
|
|
38
|
+
*/
|
|
39
|
+
export declare const relationRanks: (model: UmlModel) => Map<string, number>;
|
|
40
|
+
export type CompileOptions = {
|
|
41
|
+
/** Canvas position of the diagram's top-left, in canvas px. */
|
|
42
|
+
origin?: Scene.Point;
|
|
43
|
+
/** Canvas px per scene unit. */
|
|
44
|
+
scale?: number;
|
|
45
|
+
/** Gap between ranks along the flow direction, in scene units (default 90). */
|
|
46
|
+
gapMain?: number;
|
|
47
|
+
/** Gap between classes within a rank, in scene units (default 60). */
|
|
48
|
+
gapCross?: number;
|
|
49
|
+
/** Maximum class-box width, in scene units (default 400); longer lines wrap. */
|
|
50
|
+
maxWidth?: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Compile a mermaid class diagram into scene commands: one world object per class (compartment
|
|
54
|
+
* rects `title`/`attributes`/`methods`) and an `edges` object holding the relations as bound
|
|
55
|
+
* arrows. Supertypes rank above subtypes, so inheritance reads downward.
|
|
56
|
+
*/
|
|
57
|
+
export declare const compile: (source: string, options?: CompileOptions) => Scene.Command[];
|
|
58
|
+
/** True when the mermaid source declares a class diagram rather than a flowchart. */
|
|
59
|
+
export declare const isClassDiagram: (source: string) => boolean;
|
|
60
|
+
//# sourceMappingURL=uml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uml.d.ts","sourceRoot":"","sources":["../../../src/uml.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM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