@sentropic/diagram-canvas 0.1.0 → 0.2.2
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/README.md +9 -0
- package/contracts/diagram-anatomy.v1.json +2073 -0
- package/dist/camera.d.ts +12 -7
- package/dist/camera.js +18 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/bundleLabel.d.ts +12 -0
- package/dist/layout/bundleLabel.js +16 -0
- package/dist/layout/cache.js +7 -7
- package/dist/layout/channels.d.ts +28 -0
- package/dist/layout/channels.js +14 -0
- package/dist/layout/dock.d.ts +1 -0
- package/dist/layout/dock.js +18 -37
- package/dist/layout/engine.js +4 -4
- package/dist/layout/erd.d.ts +5 -0
- package/dist/layout/erd.js +85 -0
- package/dist/layout/fingerprint.d.ts +2 -2
- package/dist/layout/fingerprint.js +6 -2
- package/dist/layout/flow-order.d.ts +3 -0
- package/dist/layout/flow-order.js +14 -0
- package/dist/layout/flows.d.ts +89 -0
- package/dist/layout/flows.js +120 -0
- package/dist/layout/graph.d.ts +2 -0
- package/dist/layout/graph.js +5 -2
- package/dist/layout/hints.js +7 -6
- package/dist/layout/index.d.ts +3 -0
- package/dist/layout/index.js +3 -0
- package/dist/layout/labels.d.ts +1 -0
- package/dist/layout/labels.js +1 -1
- package/dist/layout/measure.d.ts +3 -3
- package/dist/layout/measure.js +5 -3
- package/dist/layout/measured.js +406 -75
- package/dist/layout/route.d.ts +2 -0
- package/dist/layout/route.js +2 -70
- package/dist/layout/sceneMeasure.d.ts +13 -0
- package/dist/layout/sceneMeasure.js +57 -0
- package/dist/layout/spacing.generated.d.ts +13 -0
- package/dist/layout/spacing.generated.js +8 -0
- package/dist/layout/types.d.ts +33 -4
- package/dist/layout/types.js +4 -10
- package/dist/presentation/diagramCardModel.d.ts +660 -0
- package/dist/presentation/diagramCardModel.js +1150 -0
- package/dist/presentation/diagramSceneModel.d.ts +70 -2
- package/dist/presentation/diagramSceneModel.js +165 -30
- package/dist/presentation/diagramSceneTypes.d.ts +91 -0
- package/dist/presentation/diagramSceneTypes.js +2 -0
- package/dist/presentation/erd.d.ts +81 -0
- package/dist/presentation/erd.js +156 -0
- package/dist/presentation/flowModel.d.ts +82 -0
- package/dist/presentation/flowModel.js +206 -0
- package/dist/presentation/index.d.ts +20 -0
- package/dist/presentation/index.js +14 -0
- package/dist/presentation/registry.d.ts +52 -0
- package/dist/presentation/registry.js +81 -0
- package/dist/presentation/renderCardSvg.d.ts +73 -0
- package/dist/presentation/renderCardSvg.js +144 -0
- package/dist/presentation/renderSceneSvg.d.ts +38 -0
- package/dist/presentation/renderSceneSvg.js +56 -0
- package/dist/presentation/renderZoneSvg.d.ts +79 -0
- package/dist/presentation/renderZoneSvg.js +180 -0
- package/dist/presentation/sceneLabelClearance.d.ts +8 -0
- package/dist/presentation/sceneLabelClearance.js +85 -0
- package/dist/visibility.d.ts +1 -1
- package/dist/visibility.js +5 -4
- package/package.json +31 -5
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { type FlowIndex, type FlowStep } from "@sentropic/diagram-core";
|
|
2
|
+
import type { FlowArrow, FlowBundle, FlowVisibleTarget } from "../layout/flows.js";
|
|
3
|
+
import type { Visible } from "./flowModel.js";
|
|
4
|
+
import { type ErdCard } from "./erd.js";
|
|
1
5
|
/**
|
|
2
6
|
* `DiagramSceneFigure` — the pure half of the scene host (DC-2a lot L4,
|
|
3
7
|
* SPEC_EVOL_DC2A §4.3, §5, §6.7, Appendix D).
|
|
@@ -12,6 +16,7 @@
|
|
|
12
16
|
* off the layout signature, so this package names no other diagram layer.
|
|
13
17
|
*/
|
|
14
18
|
import { layoutMeasured, type CameraFit, type LayoutCacheStats, type LayoutHints, type LayoutMetrics, type LayoutOptions, type LayoutResult, type LevelOrientation, type LineMeasurer, type Rect, type RowPackOptions, type Vec2 } from "../index.js";
|
|
19
|
+
import { type BundleLabelGroup } from "../layout/bundleLabel.js";
|
|
15
20
|
import type { EntityPresentation } from "@sentropic/diagram-core";
|
|
16
21
|
/** The semantic document the layout engine reads. */
|
|
17
22
|
export type SceneDocument = Parameters<typeof layoutMeasured>[0];
|
|
@@ -55,7 +60,28 @@ export interface DiagramSceneSize {
|
|
|
55
60
|
}
|
|
56
61
|
/** Drawing union size at zoom 1, available without measuring rendered elements. */
|
|
57
62
|
export declare function sceneContentSize(result: LayoutResult | undefined): DiagramSceneSize;
|
|
63
|
+
/** Presentation data keyed by profile:type (or type), kept outside semantic profiles. */
|
|
64
|
+
export type SceneIconBindings = Readonly<Record<string, {
|
|
65
|
+
readonly icon?: string;
|
|
66
|
+
readonly role?: string;
|
|
67
|
+
readonly shape?: "component" | "flow" | "erd" | "note";
|
|
68
|
+
}>>;
|
|
69
|
+
export declare const ROLE_ICONS: Readonly<Record<string, string>>;
|
|
70
|
+
export declare function resolveScenePresentation(document: SceneDocument, presentation: ScenePresentation, bindings?: SceneIconBindings, strict?: boolean, view?: SceneView, resolveGlyph?: (name: string) => import("./diagramCardModel.js").DiagramGlyphPaths | undefined): {
|
|
71
|
+
presentation: {
|
|
72
|
+
entities: {
|
|
73
|
+
[k: string]: EntityPresentation;
|
|
74
|
+
};
|
|
75
|
+
contractPin: import("@sentropic/diagram-core").PresentationPin;
|
|
76
|
+
legends: Readonly<Record<string, import("@sentropic/diagram-core").LegendPresentation>>;
|
|
77
|
+
categoryTokens: readonly import("@sentropic/diagram-core").CategoryTokenBinding[];
|
|
78
|
+
};
|
|
79
|
+
missing: string[];
|
|
80
|
+
};
|
|
58
81
|
export interface SceneLayoutInput {
|
|
82
|
+
readonly iconBindings?: SceneIconBindings;
|
|
83
|
+
readonly strictIcons?: boolean;
|
|
84
|
+
readonly resolveGlyph?: (name: string) => import("./diagramCardModel.js").DiagramGlyphPaths | undefined;
|
|
59
85
|
readonly cache?: SceneLayoutCache;
|
|
60
86
|
readonly document: SceneDocument;
|
|
61
87
|
/** Retained source view (authored occurrences, fold groups). Optional: the engine synthesises one. */
|
|
@@ -67,6 +93,8 @@ export interface SceneLayoutInput {
|
|
|
67
93
|
readonly collapsed: readonly SceneOccurrenceRef[];
|
|
68
94
|
readonly hints?: LayoutHints;
|
|
69
95
|
readonly metrics?: Partial<LayoutMetrics>;
|
|
96
|
+
readonly flows?: LayoutOptions["flows"];
|
|
97
|
+
readonly flowTokens?: LayoutOptions["flowTokens"];
|
|
70
98
|
readonly rowPack?: RowPackOptions;
|
|
71
99
|
readonly targetWidth?: number;
|
|
72
100
|
readonly previousOrientation?: SceneOrientations;
|
|
@@ -81,7 +109,7 @@ export interface SceneLayoutInput {
|
|
|
81
109
|
export declare function layoutScene(input: SceneLayoutInput): LayoutResult;
|
|
82
110
|
/** Collapsed occurrence ids recorded by a view's fold groups. */
|
|
83
111
|
export declare function collapsedOccurrencesOf(view: SceneView | undefined): SceneOccurrenceRef[];
|
|
84
|
-
export type SceneNodeKind = "card" | "zone" | "legend-key" | "label";
|
|
112
|
+
export type SceneNodeKind = "card" | "zone" | "legend-key" | "label" | "erd";
|
|
85
113
|
export interface SceneNodeModel {
|
|
86
114
|
readonly occurrence: SceneOccurrenceRef;
|
|
87
115
|
readonly entity: string;
|
|
@@ -92,17 +120,53 @@ export interface SceneNodeModel {
|
|
|
92
120
|
readonly presentation?: EntityPresentation;
|
|
93
121
|
/** Text of a node with no card form (L-R12 label) or of a legend key. */
|
|
94
122
|
readonly text: string;
|
|
123
|
+
readonly erd?: ErdCard;
|
|
95
124
|
}
|
|
96
125
|
export interface SceneEdgeModel {
|
|
126
|
+
readonly directed: boolean;
|
|
127
|
+
readonly arrows: readonly FlowArrow[];
|
|
128
|
+
readonly flow?: FlowStep;
|
|
129
|
+
readonly bundle?: FlowBundle;
|
|
97
130
|
readonly occurrence: SceneOccurrenceRef;
|
|
98
131
|
readonly points: readonly Vec2[];
|
|
132
|
+
readonly markers?: string;
|
|
99
133
|
}
|
|
100
134
|
export interface SceneLabelModel {
|
|
101
135
|
readonly occurrence: SceneOccurrenceRef;
|
|
102
136
|
readonly lines: readonly string[];
|
|
103
137
|
readonly box: Rect;
|
|
138
|
+
readonly title?: string;
|
|
139
|
+
readonly bundle?: {
|
|
140
|
+
readonly header: string;
|
|
141
|
+
readonly groups: readonly BundleLabelGroup[];
|
|
142
|
+
};
|
|
143
|
+
readonly leader?: readonly Vec2[];
|
|
144
|
+
readonly erd?: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface SceneBadgeModel {
|
|
147
|
+
readonly id: string;
|
|
148
|
+
readonly occurrence: SceneOccurrenceRef;
|
|
149
|
+
readonly kind: "step" | "count";
|
|
150
|
+
readonly text: string;
|
|
151
|
+
readonly box: Rect;
|
|
152
|
+
readonly target: Visible;
|
|
104
153
|
}
|
|
105
154
|
export interface SceneModel {
|
|
155
|
+
readonly badges: readonly SceneBadgeModel[];
|
|
156
|
+
readonly flows: FlowIndex;
|
|
157
|
+
readonly flowTargets: Readonly<Record<string, FlowVisibleTarget>>;
|
|
158
|
+
readonly nodeTargets: readonly {
|
|
159
|
+
readonly occurrence: SceneOccurrenceRef;
|
|
160
|
+
readonly entity: string;
|
|
161
|
+
readonly anchor: {
|
|
162
|
+
readonly x: number;
|
|
163
|
+
readonly y: number;
|
|
164
|
+
};
|
|
165
|
+
}[];
|
|
166
|
+
readonly flowRepresentatives: Readonly<Record<string, string>>;
|
|
167
|
+
readonly flowEnds: Readonly<Record<string, readonly string[]>>;
|
|
168
|
+
readonly flowAncestors: Readonly<Record<string, readonly string[]>>;
|
|
169
|
+
readonly flowSummaryLabels: Readonly<Record<string, string>>;
|
|
106
170
|
readonly contentSize: DiagramSceneSize;
|
|
107
171
|
/** Bottom to top, in the scene's paint order. */
|
|
108
172
|
readonly nodes: readonly SceneNodeModel[];
|
|
@@ -123,11 +187,14 @@ export interface SceneModel {
|
|
|
123
187
|
* collapsed boxes and the title band of each expanded zone — an expanded
|
|
124
188
|
* zone's interior is not a blocker on the row-pack path).
|
|
125
189
|
*/
|
|
126
|
-
export declare function resolveScene(result: SceneLaidOut, input: Pick<SceneLayoutInput, "document" | "presentation" | "measureLines" | "metrics">): SceneModel;
|
|
190
|
+
export declare function resolveScene(result: SceneLaidOut, input: Pick<SceneLayoutInput, "document" | "presentation" | "measureLines" | "metrics" | "iconBindings" | "strictIcons" | "view" | "resolveGlyph" | "flows">): SceneModel;
|
|
191
|
+
/** Full presentation text retained alongside the textual relations (A14). */
|
|
192
|
+
export declare function sceneTextRows(scene: SceneModel, document: SceneDocument): readonly string[];
|
|
127
193
|
export interface SceneCameraInput {
|
|
128
194
|
readonly bounds?: Rect;
|
|
129
195
|
readonly viewWidth: number;
|
|
130
196
|
readonly windowHeight: number;
|
|
197
|
+
readonly scrollbarHeight?: number;
|
|
131
198
|
readonly maxDisplayScale?: number;
|
|
132
199
|
readonly minReadableScale?: number;
|
|
133
200
|
}
|
|
@@ -178,4 +245,5 @@ export declare function displayedRects(from: ReadonlyMap<string, Rect>, to: Read
|
|
|
178
245
|
export declare function rectsOf(scene: SceneModel): ReadonlyMap<string, Rect>;
|
|
179
246
|
/** Whether two rectangle sets are the same drawing: same ids, same numbers. */
|
|
180
247
|
export declare function sameRects(left: ReadonlyMap<string, Rect>, right: ReadonlyMap<string, Rect>): boolean;
|
|
248
|
+
export type { DiagramSceneFigureProps, DiagramSceneFigureLabels, DiagramSceneCamera } from "./diagramSceneTypes.js";
|
|
181
249
|
//# sourceMappingURL=diagramSceneModel.d.ts.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { flowIndex, parentOccurrenceOf, representativeOf } from "@sentropic/diagram-core";
|
|
2
|
+
import { measureErdCard, renderErdMarkerSvg, erdText, wrapErdText, placeErdRoleLabels, ERD_GEOMETRY } from "./erd.js";
|
|
1
3
|
/**
|
|
2
4
|
* `DiagramSceneFigure` — the pure half of the scene host (DC-2a lot L4,
|
|
3
5
|
* SPEC_EVOL_DC2A §4.3, §5, §6.7, Appendix D).
|
|
@@ -11,7 +13,11 @@
|
|
|
11
13
|
* (layout, scene, camera). The semantic-document and view types are read
|
|
12
14
|
* off the layout signature, so this package names no other diagram layer.
|
|
13
15
|
*/
|
|
14
|
-
import { buildScene, cameraFit, clampZoom, CONTENT_INSET, DEFAULT_ALLOCATED_LINES, DEFAULT_LAYOUT_METRICS, layoutFolded, layoutMeasured, placeEdgeLabels, rectUnion, relationRoute, sceneNodes, } from "../index.js";
|
|
16
|
+
import { buildScene, cameraFit, clampZoom, CONTENT_INSET, DEFAULT_ALLOCATED_LINES, DEFAULT_LAYOUT_METRICS, DEFAULT_MIN_READABLE_SCALE, FIT_PAINT_INSET, layoutFolded, layoutMeasured, placeEdgeLabels, rectUnion, relationRoute, sceneNodes, sceneEdges, } from "../index.js";
|
|
17
|
+
import { measureBundleLabel } from "../layout/bundleLabel.js";
|
|
18
|
+
import { getDiagramGlyph } from "./registry.js";
|
|
19
|
+
import { lineBoxHeight, ZONE_GEOMETRY } from "./diagramCardModel.js";
|
|
20
|
+
import { clearSceneLabels } from "./sceneLabelClearance.js";
|
|
15
21
|
/**
|
|
16
22
|
* `targetWidth` handed to the engine when the host supplies none. The
|
|
17
23
|
* measured path never re-packs on it (D-3) and the host never reads the
|
|
@@ -32,6 +38,29 @@ export const WHEEL_ZOOM_RATE = 0.0015;
|
|
|
32
38
|
export function sceneContentSize(result) {
|
|
33
39
|
return result?.status === "laid-out" ? { width: result.fit.width, height: result.fit.height } : { width: 0, height: 0 };
|
|
34
40
|
}
|
|
41
|
+
export const ROLE_ICONS = { card: "base", zone: "cluster", store: "db", actor: "user", api: "api", runtime: "server" };
|
|
42
|
+
export function resolveScenePresentation(document, presentation, bindings = {}, strict = true, view, resolveGlyph = getDiagramGlyph) {
|
|
43
|
+
const missing = [];
|
|
44
|
+
const entities = Object.fromEntries(Object.entries(presentation.entities).map(([id, entry]) => {
|
|
45
|
+
if (entry.form !== "card" && entry.form !== "container" && entry.form !== "legend")
|
|
46
|
+
return [id, entry];
|
|
47
|
+
const entityId = view?.entityOccurrences[id]?.entity ?? id.replace(/^occurrence:e\./, "entity:");
|
|
48
|
+
const entity = document.entities[entityId];
|
|
49
|
+
if (entity?.profile === "erd@1")
|
|
50
|
+
return [id, entry];
|
|
51
|
+
const binding = bindings[entity === undefined ? "" : entity.profile + ":" + entity.type] ?? bindings[entity?.type ?? ""];
|
|
52
|
+
if (binding?.shape !== undefined && binding.shape !== "component")
|
|
53
|
+
return [id, { ...entry, icon: entry.icon ?? "none" }];
|
|
54
|
+
const role = binding?.role ?? (entry.form === "card" ? "card" : "zone");
|
|
55
|
+
const icon = entry.icon ?? binding?.icon ?? ROLE_ICONS[role];
|
|
56
|
+
if (icon === undefined || resolveGlyph(icon) === undefined) {
|
|
57
|
+
missing.push(id);
|
|
58
|
+
return [id, { ...entry, icon: strict ? "unknown" : "none" }];
|
|
59
|
+
}
|
|
60
|
+
return [id, { ...entry, icon }];
|
|
61
|
+
}));
|
|
62
|
+
return { presentation: { ...presentation, entities }, missing };
|
|
63
|
+
}
|
|
35
64
|
/**
|
|
36
65
|
* One full layout pass (§6.5: fold → measure → place → route, never patched).
|
|
37
66
|
* Row-pack is always selected: an absent `rowPack` resolves to the DS
|
|
@@ -40,8 +69,11 @@ export function sceneContentSize(result) {
|
|
|
40
69
|
* required field carries no second metric source.
|
|
41
70
|
*/
|
|
42
71
|
export function layoutScene(input) {
|
|
72
|
+
const resolved = resolveScenePresentation(input.document, input.presentation, input.iconBindings, input.strictIcons, input.view, input.resolveGlyph);
|
|
43
73
|
const options = {
|
|
44
74
|
registry: input.registry,
|
|
75
|
+
...(input.flows === undefined ? {} : { flows: input.flows }),
|
|
76
|
+
...(input.flowTokens === undefined ? {} : { flowTokens: input.flowTokens }),
|
|
45
77
|
...(input.bindings === undefined ? {} : { bindings: input.bindings }),
|
|
46
78
|
measureText: (text) => {
|
|
47
79
|
const layout = input.measureLines({
|
|
@@ -53,7 +85,7 @@ export function layoutScene(input) {
|
|
|
53
85
|
});
|
|
54
86
|
return { width: layout.width, height: layout.height };
|
|
55
87
|
},
|
|
56
|
-
presentation:
|
|
88
|
+
presentation: resolved.presentation,
|
|
57
89
|
measureLines: input.measureLines,
|
|
58
90
|
collapsed: input.collapsed,
|
|
59
91
|
...(input.hints === undefined ? {} : { hints: input.hints }),
|
|
@@ -62,14 +94,14 @@ export function layoutScene(input) {
|
|
|
62
94
|
targetWidth: input.targetWidth ?? DEFAULT_SCENE_TARGET_WIDTH,
|
|
63
95
|
...(input.previousOrientation === undefined ? {} : { previousOrientation: input.previousOrientation }),
|
|
64
96
|
};
|
|
65
|
-
|
|
66
|
-
|
|
97
|
+
const result = input.cache !== undefined
|
|
98
|
+
? (input.view === undefined
|
|
67
99
|
? input.cache.layout(input.document, options)
|
|
68
|
-
: input.cache.layoutFolded(input.document, input.view, options)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
100
|
+
: input.cache.layoutFolded(input.document, input.view, options))
|
|
101
|
+
: input.view === undefined
|
|
102
|
+
? layoutMeasured(input.document, options)
|
|
103
|
+
: layoutFolded(input.document, input.view, options);
|
|
104
|
+
return result.status !== "laid-out" || resolved.missing.length === 0 ? result : { ...result, warnings: [...result.warnings, ...resolved.missing.map(id => ({ code: "card-icon-missing", refs: [id], message: "No icon resolves for this component; strict mode displays unknown" }))] };
|
|
73
105
|
}
|
|
74
106
|
/** Collapsed occurrence ids recorded by a view's fold groups. */
|
|
75
107
|
export function collapsedOccurrencesOf(view) {
|
|
@@ -101,13 +133,18 @@ function edgeLabelOf(document, relation) {
|
|
|
101
133
|
*/
|
|
102
134
|
export function resolveScene(result, input) {
|
|
103
135
|
const view = result.view;
|
|
136
|
+
const resolved = resolveScenePresentation(input.document, input.presentation, input.iconBindings, input.strictIcons, input.view, input.resolveGlyph);
|
|
104
137
|
const frame = buildScene({ document: input.document, views: { [view.viewId]: view } }, view.viewId);
|
|
138
|
+
const bundledMembers = new Set(Object.values(result.edgeBundles ?? {}).flatMap(bundle => bundle.members.slice(1)));
|
|
139
|
+
const items = frame.items.filter(item => item.kind !== "edge" || !bundledMembers.has(item.occurrence));
|
|
140
|
+
const visibleEdges = new Set(items.filter(item => item.kind === "edge").map(item => item.occurrence));
|
|
105
141
|
const collapsed = new Set(collapsedOccurrencesOf(view));
|
|
106
142
|
const nodes = sceneNodes(frame).map((node) => {
|
|
107
|
-
const presentation =
|
|
143
|
+
const presentation = resolved.presentation.entities[node.occurrence];
|
|
108
144
|
const form = presentation?.form;
|
|
109
145
|
const titled = presentation?.text.title !== undefined && presentation.text.title !== "";
|
|
110
|
-
const
|
|
146
|
+
const erd = input.document.entities[node.entity]?.profile === "erd@1";
|
|
147
|
+
const kind = erd ? "erd" : form === "legend-key"
|
|
111
148
|
? "legend-key"
|
|
112
149
|
: !titled
|
|
113
150
|
? "label"
|
|
@@ -120,7 +157,8 @@ export function resolveScene(result, input) {
|
|
|
120
157
|
occurrence: node.occurrence,
|
|
121
158
|
entity: node.entity,
|
|
122
159
|
kind,
|
|
123
|
-
collapsed: kind === "zone" && collapsed.has(node.occurrence),
|
|
160
|
+
collapsed: (kind === "zone" || kind === "erd") && collapsed.has(node.occurrence),
|
|
161
|
+
...(erd ? { erd: measureErdCard(input.document, node.entity, collapsed.has(node.occurrence), input.measureLines) } : {}),
|
|
124
162
|
rect: node.rect,
|
|
125
163
|
...(presentation === undefined ? {} : { presentation }),
|
|
126
164
|
text: presentation?.text.title ?? presentation?.text.body ?? "",
|
|
@@ -137,27 +175,77 @@ export function resolveScene(result, input) {
|
|
|
137
175
|
const height = headerHeights.get(node.occurrence);
|
|
138
176
|
if (height === undefined)
|
|
139
177
|
continue;
|
|
178
|
+
const ruleClearance = (ZONE_GEOMETRY.ruleHeight / 2 + 1) / DEFAULT_MIN_READABLE_SCALE;
|
|
140
179
|
blockers.push({
|
|
141
|
-
x: node.rect.x
|
|
142
|
-
y: node.rect.y
|
|
143
|
-
width: node.rect.width
|
|
144
|
-
height,
|
|
180
|
+
x: node.rect.x,
|
|
181
|
+
y: node.rect.y,
|
|
182
|
+
width: node.rect.width,
|
|
183
|
+
height: CONTENT_INSET + height + ZONE_GEOMETRY.ruleHeight / 2 + ruleClearance,
|
|
145
184
|
});
|
|
185
|
+
// A zone footer has one allocated line. Reserve its fixed chrome from
|
|
186
|
+
// the presentation instead of measuring the scene again during replay.
|
|
187
|
+
const reserve = node.presentation?.text.footer?.trim()
|
|
188
|
+
? lineBoxHeight(ZONE_GEOMETRY.footer.size) + ZONE_GEOMETRY.ruleHeight + 2 * ZONE_GEOMETRY.ruleMargin + ZONE_GEOMETRY.footerBottomInset : 0;
|
|
189
|
+
if (reserve > 0)
|
|
190
|
+
blockers.push({ x: node.rect.x, y: node.rect.y + node.rect.height - reserve - ZONE_GEOMETRY.borderWidth - ruleClearance,
|
|
191
|
+
width: node.rect.width, height: reserve + ZONE_GEOMETRY.borderWidth + ruleClearance });
|
|
192
|
+
}
|
|
193
|
+
const allFlows = flowIndex(input.document);
|
|
194
|
+
const flowTargets = result.flowTargets ?? {};
|
|
195
|
+
const flows = {
|
|
196
|
+
scenarios: allFlows.scenarios.map((scenario) => ({ ...scenario, steps: scenario.steps.filter((step) => flowTargets[step.relation] !== undefined) })),
|
|
197
|
+
byRelation: Object.fromEntries(Object.entries(allFlows.byRelation).filter(([id]) => flowTargets[id] !== undefined)),
|
|
198
|
+
byEntity: Object.fromEntries(Object.entries(allFlows.byEntity).map(([id, steps]) => [id, steps.filter((step) => flowTargets[step] !== undefined)])),
|
|
199
|
+
};
|
|
200
|
+
const flowAncestors = {};
|
|
201
|
+
for (const node of nodes) {
|
|
202
|
+
const parents = [];
|
|
203
|
+
for (let parent = parentOccurrenceOf(view, node.occurrence); parent !== undefined; parent = parentOccurrenceOf(view, parent))
|
|
204
|
+
parents.push(parent);
|
|
205
|
+
flowAncestors[node.occurrence] = parents;
|
|
206
|
+
}
|
|
207
|
+
const flowRepresentatives = Object.fromEntries(nodes.map((node) => [node.entity, node.occurrence]));
|
|
208
|
+
for (const occurrence of Object.values(view.entityOccurrences).sort((a, b) => byCodeUnit(a.id, b.id))) {
|
|
209
|
+
const box = representativeOf(view, collapsed, occurrence.id);
|
|
210
|
+
if (flowRepresentatives[occurrence.entity] === undefined && nodes.some((node) => node.occurrence === box))
|
|
211
|
+
flowRepresentatives[occurrence.entity] = box;
|
|
212
|
+
}
|
|
213
|
+
const flowEnds = {};
|
|
214
|
+
for (const [id, target] of Object.entries(flowTargets)) {
|
|
215
|
+
if (target.kind === "internal") {
|
|
216
|
+
flowEnds[id] = [target.box];
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const occurrence = view.relationOccurrences[target.occurrence];
|
|
220
|
+
flowEnds[id] = occurrence?.endpoints.map((end) => view.portOccurrences[end.occurrence]?.ownerOccurrence ?? end.occurrence) ?? [];
|
|
146
221
|
}
|
|
147
222
|
const edges = [];
|
|
148
223
|
const entries = [];
|
|
149
224
|
const labelLines = new Map();
|
|
150
225
|
for (const id of Object.keys(view.relationOccurrences).sort(byCodeUnit)) {
|
|
226
|
+
if (!visibleEdges.has(id))
|
|
227
|
+
continue;
|
|
151
228
|
const occurrence = view.relationOccurrences[id];
|
|
152
|
-
if (occurrence.waypoints === undefined)
|
|
229
|
+
if (occurrence.waypoints === undefined || !visibleEdges.has(id))
|
|
153
230
|
continue;
|
|
154
231
|
const points = relationRoute(view, occurrence.id) ?? [];
|
|
155
232
|
if (points.length < 2)
|
|
156
233
|
continue;
|
|
157
|
-
|
|
234
|
+
const flow = flows.byRelation[occurrence.relation];
|
|
235
|
+
const bundle = result.flowBundles?.find((entry) => entry.carrier === occurrence.id);
|
|
236
|
+
// Preserve both flow presentation and ERD endpoint markers.
|
|
237
|
+
const semantic = input.document.relations[occurrence.relation];
|
|
238
|
+
let markers;
|
|
239
|
+
if (semantic?.profile === 'erd@1') {
|
|
240
|
+
const first = points[0], second = points[1], last = points[points.length - 1], before = points[points.length - 2];
|
|
241
|
+
markers = renderErdMarkerSvg(erdText(semantic.attributes, 'fromCardinality'), first, { x: second.x - first.x, y: second.y - first.y }) + renderErdMarkerSvg(erdText(semantic.attributes, 'toCardinality'), last, { x: before.x - last.x, y: before.y - last.y });
|
|
242
|
+
}
|
|
243
|
+
edges.push({ ...(markers === undefined ? {} : { markers }), occurrence: occurrence.id, points, directed: flow !== undefined, arrows: result.arrowBoxes?.[occurrence.id] ?? [], ...(flow === undefined ? {} : { flow }), ...(bundle === undefined ? {} : { bundle }) });
|
|
158
244
|
if (result.labelBoxes !== undefined && result.labelBoxes[id] === undefined)
|
|
159
245
|
continue;
|
|
160
|
-
const label =
|
|
246
|
+
const label = result.edgeBundles?.[id]?.label ?? (semantic?.profile === 'erd@1'
|
|
247
|
+
? ['fromRole', 'toRole'].map(role => erdText(semantic.attributes, role)).filter(Boolean).join(' / ') || edgeLabelOf(input.document, occurrence.relation)
|
|
248
|
+
: edgeLabelOf(input.document, occurrence.relation));
|
|
161
249
|
if (label === undefined)
|
|
162
250
|
continue;
|
|
163
251
|
const layout = measuredLabels.get(id) ?? input.measureLines({
|
|
@@ -167,36 +255,83 @@ export function resolveScene(result, input) {
|
|
|
167
255
|
allocatedLines: DEFAULT_ALLOCATED_LINES["edge-label"],
|
|
168
256
|
folded: false,
|
|
169
257
|
});
|
|
170
|
-
|
|
171
|
-
|
|
258
|
+
const lines = semantic?.profile === 'erd@1' ? wrapErdText(label, ERD_GEOMETRY.labelWidth, input.measureLines) : layout.lines;
|
|
259
|
+
labelLines.set(id, lines);
|
|
260
|
+
entries.push({ id, route: points, size: semantic?.profile === 'erd@1' ? { width: ERD_GEOMETRY.labelWidth, height: lines.length * ERD_GEOMETRY.lineHeight } : { width: layout.width, height: layout.height } });
|
|
172
261
|
}
|
|
173
262
|
const margin = input.metrics?.labelMargin ?? DEFAULT_LAYOUT_METRICS.labelMargin;
|
|
174
263
|
const labels = [];
|
|
175
|
-
let bounds
|
|
176
|
-
const
|
|
264
|
+
let bounds;
|
|
265
|
+
for (const item of items) {
|
|
266
|
+
const box = item.kind === "edge" ? item.bounds : item.rect;
|
|
267
|
+
bounds = bounds === undefined ? box : rectUnion(bounds, box);
|
|
268
|
+
}
|
|
269
|
+
const erd = input.document.profileRefs.length === 1 && input.document.profileRefs[0] === 'erd@1';
|
|
270
|
+
const placements = erd ? placeErdRoleLabels(entries, blockers, margin) : result.labelBoxes === undefined
|
|
177
271
|
? placeEdgeLabels(entries, blockers, margin)
|
|
178
272
|
: new Map(Object.entries(result.labelBoxes).map(([id, box]) => [id, { box }]));
|
|
179
273
|
for (const [id, placement] of placements) {
|
|
180
274
|
if (placement === undefined)
|
|
181
275
|
continue;
|
|
182
|
-
labels.push({ occurrence: id, lines: labelLines.get(id) ?? [], box: placement.box })
|
|
183
|
-
|
|
276
|
+
labels.push({ occurrence: id, lines: labelLines.get(id) ?? [], box: placement.box, ...(erd ? { erd: true } : {}), ...("leader" in placement ? { leader: placement.leader } : {}),
|
|
277
|
+
...(result.edgeBundles?.[id] === undefined ? {} : { title: result.edgeBundles[id].title }),
|
|
278
|
+
...(result.edgeBundles?.[id]?.relations === undefined ? {} : { bundle: result.edgeBundles[id].chip ?? measureBundleLabel(result.edgeBundles[id].relations, input.measureLines, input.metrics?.bundleLabelMaxWidth) }) });
|
|
279
|
+
}
|
|
280
|
+
const badges = [];
|
|
281
|
+
for (const step of flows.scenarios.flatMap((scenario) => scenario.steps)) {
|
|
282
|
+
const target = flowTargets[step.relation];
|
|
283
|
+
if (target === undefined || target.kind === "internal" || !target.badge || badges.some((badge) => badge.occurrence === target.occurrence))
|
|
284
|
+
continue;
|
|
285
|
+
const box = result.badgeBoxes?.[target.occurrence];
|
|
286
|
+
if (box === undefined)
|
|
287
|
+
continue;
|
|
288
|
+
const bundle = result.flowBundles?.find((entry) => entry.id === (target.kind === "bundle" ? target.id : ""));
|
|
289
|
+
const text = bundle === undefined ? step.badge : (input.flows?.countTemplate ?? "{n}").replaceAll("{n}", String(bundle.members.length));
|
|
290
|
+
badges.push({ id: target.occurrence, occurrence: target.occurrence, kind: bundle === undefined ? "step" : "count", text, box, target: target.kind === "bundle" ? { kind: "bundle", id: target.id } : { kind: "edge", occurrence: target.occurrence } });
|
|
291
|
+
bounds = bounds === undefined ? box : rectUnion(bounds, box);
|
|
292
|
+
}
|
|
293
|
+
for (const arrows of Object.values(result.arrowBoxes ?? {}))
|
|
294
|
+
for (const arrow of arrows)
|
|
295
|
+
bounds = bounds === undefined ? arrow.box : rectUnion(bounds, arrow.box);
|
|
296
|
+
// Non-scaling connector paint is widest in world units at the readability
|
|
297
|
+
// floor. Reserve it as well as the label-padding token supplied by hosts.
|
|
298
|
+
const clearedLabels = clearSceneLabels(labels, edges.map(edge => edge.points), [...blockers, ...badges.map(badge => badge.box), ...edges.flatMap(edge => edge.arrows.map(arrow => arrow.box))], margin + ZONE_GEOMETRY.borderWidth / (2 * DEFAULT_MIN_READABLE_SCALE));
|
|
299
|
+
for (const { box } of clearedLabels) {
|
|
300
|
+
const padded = { x: box.x - margin, y: box.y - margin, width: box.width + 2 * margin, height: box.height + 2 * margin };
|
|
301
|
+
bounds = bounds === undefined ? padded : rectUnion(bounds, padded);
|
|
302
|
+
}
|
|
303
|
+
if (bounds !== undefined) {
|
|
304
|
+
const x = Math.floor(bounds.x * 64) / 64, y = Math.floor(bounds.y * 64) / 64;
|
|
305
|
+
bounds = { x, y, width: Math.ceil((bounds.x + bounds.width) * 64) / 64 - x, height: Math.ceil((bounds.y + bounds.height) * 64) / 64 - y };
|
|
184
306
|
}
|
|
307
|
+
const nodeTargets = nodes.filter((node) => Object.values(flowEnds).some((ends) => ends.some((id) => id === node.occurrence || (flowAncestors[id] ?? []).includes(node.occurrence)))).map((node) => ({ occurrence: node.occurrence, entity: node.entity, anchor: { x: node.rect.x, y: node.rect.y } }));
|
|
185
308
|
return {
|
|
309
|
+
badges, flows, flowTargets, nodeTargets, flowEnds, flowRepresentatives, flowAncestors,
|
|
310
|
+
flowSummaryLabels: Object.fromEntries(Object.entries(view.summaryLabels ?? {}).map(([id, definition]) => [id, definition.label])),
|
|
186
311
|
contentSize: sceneContentSize(result),
|
|
187
312
|
nodes,
|
|
188
313
|
edges,
|
|
189
|
-
labels,
|
|
314
|
+
labels: clearedLabels,
|
|
190
315
|
...(bounds === undefined ? {} : { bounds }),
|
|
191
316
|
orientations: result.orientations ?? {},
|
|
192
317
|
};
|
|
193
318
|
}
|
|
319
|
+
/** Full presentation text retained alongside the textual relations (A14). */
|
|
320
|
+
export function sceneTextRows(scene, document) {
|
|
321
|
+
const rows = scene.nodes.map(node => Object.values(node.presentation?.text ?? {}).filter(Boolean).join(" · "));
|
|
322
|
+
for (const relation of Object.values(document.relations)) {
|
|
323
|
+
const names = relation.endpoints.map(end => { const value = document.entities[end.target]?.attributes["name"]; return value?.kind === "text" ? String(value.value) : end.target; });
|
|
324
|
+
rows.push(names.join(" → ") + " · " + (edgeLabelOf(document, relation.id) ?? relation.type));
|
|
325
|
+
}
|
|
326
|
+
return rows;
|
|
327
|
+
}
|
|
194
328
|
/** §5.1 / BF-2 fit of the scene bounds, as `cameraFit` computes it. */
|
|
195
329
|
export function sceneFit(input) {
|
|
196
330
|
return cameraFit({
|
|
197
331
|
...(input.bounds === undefined ? {} : { bounds: input.bounds }),
|
|
198
332
|
viewWidth: input.viewWidth,
|
|
199
333
|
windowHeight: input.windowHeight,
|
|
334
|
+
...(input.scrollbarHeight === undefined ? {} : { scrollbarHeight: input.scrollbarHeight }),
|
|
200
335
|
...(input.maxDisplayScale === undefined ? {} : { maxDisplayScale: input.maxDisplayScale }),
|
|
201
336
|
...(input.minReadableScale === undefined ? {} : { minReadableScale: input.minReadableScale }),
|
|
202
337
|
});
|
|
@@ -218,13 +353,13 @@ export function scenePlacement(bounds, zoom, fit) {
|
|
|
218
353
|
if (bounds === undefined) {
|
|
219
354
|
return { contentWidth: 0, contentHeight: 0, translateX: 0, translateY: 0, overflowX: false, overflowY: false };
|
|
220
355
|
}
|
|
221
|
-
const contentWidth = bounds.width * zoom;
|
|
222
|
-
const contentHeight = bounds.height * zoom;
|
|
356
|
+
const contentWidth = bounds.width * zoom + 2 * FIT_PAINT_INSET;
|
|
357
|
+
const contentHeight = bounds.height * zoom + 2 * FIT_PAINT_INSET;
|
|
223
358
|
// Half a CSS px of tolerance: a fit computed by division must not scroll.
|
|
224
359
|
const overflowX = contentWidth > fit.fitWidth + 0.5;
|
|
225
360
|
const overflowY = contentHeight > fit.fitHeight + 0.5;
|
|
226
|
-
const startX = overflowX ?
|
|
227
|
-
const startY = overflowY ?
|
|
361
|
+
const startX = overflowX ? FIT_PAINT_INSET : (fit.fitWidth - bounds.width * zoom) / 2;
|
|
362
|
+
const startY = overflowY ? FIT_PAINT_INSET : (fit.fitHeight - bounds.height * zoom) / 2;
|
|
228
363
|
return {
|
|
229
364
|
contentWidth,
|
|
230
365
|
contentHeight,
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { LayoutOptions, LayoutHints, LayoutMetrics, LayoutResult, LineMeasurer, RowPackOptions } from '../index.js';
|
|
2
|
+
import type { CardLineMeasure, DiagramGlyphPaths } from './diagramCardModel.js';
|
|
3
|
+
import type { StepChange, EffectiveTarget } from './flowModel.js';
|
|
4
|
+
import type { SceneDocument, SceneView, ScenePresentation, SceneOccurrenceRef, SceneLayoutCache, DiagramSceneSize } from './diagramSceneModel.js';
|
|
5
|
+
export interface DiagramSceneFigureLabels {
|
|
6
|
+
"navigator": string;
|
|
7
|
+
step: string;
|
|
8
|
+
scenario: string;
|
|
9
|
+
count: string;
|
|
10
|
+
node: string;
|
|
11
|
+
previous: string;
|
|
12
|
+
next: string;
|
|
13
|
+
allScenarios: string;
|
|
14
|
+
/** Accessible name of the camera control group. */
|
|
15
|
+
controls: string;
|
|
16
|
+
zoomIn: string;
|
|
17
|
+
zoomOut: string;
|
|
18
|
+
/** Visible text of the fit / reset control (« Ajuster »). */
|
|
19
|
+
fit: string;
|
|
20
|
+
/** Accessible name of the readout, e.g. « Zoom 85 % ». */
|
|
21
|
+
zoomLevel: (percent: number) => string;
|
|
22
|
+
/** Accessible name of the scrollable drawing region. */
|
|
23
|
+
viewport: string;
|
|
24
|
+
expand: (title: string) => string;
|
|
25
|
+
collapse: (title: string) => string;
|
|
26
|
+
}
|
|
27
|
+
export interface DiagramSceneCamera {
|
|
28
|
+
readonly zoom: number;
|
|
29
|
+
/** `round(zoom / maxDisplayScale × 100)`. */
|
|
30
|
+
readonly readout: number;
|
|
31
|
+
readonly minZoom: number;
|
|
32
|
+
readonly maxZoom: number;
|
|
33
|
+
/** The zoom a fit or reset applies. */
|
|
34
|
+
readonly fitZoom: number;
|
|
35
|
+
readonly pans: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface DiagramSceneFigureProps {
|
|
38
|
+
flows?: {
|
|
39
|
+
fanOutMax?: number;
|
|
40
|
+
};
|
|
41
|
+
scenario?: string | null;
|
|
42
|
+
defaultScenario?: string;
|
|
43
|
+
activeStep?: string | null;
|
|
44
|
+
defaultActiveStep?: string;
|
|
45
|
+
onStepChange?: (change: StepChange | null) => void;
|
|
46
|
+
onScenarioChange?: (scenario: string | null) => void;
|
|
47
|
+
onHighlightChange?: (target: EffectiveTarget | null) => void;
|
|
48
|
+
document: SceneDocument;
|
|
49
|
+
/** Retained source view (occurrences, fold groups). Optional: the engine synthesises one. */
|
|
50
|
+
view?: SceneView;
|
|
51
|
+
registry: LayoutOptions["registry"];
|
|
52
|
+
bindings?: LayoutOptions["bindings"];
|
|
53
|
+
presentation: ScenePresentation;
|
|
54
|
+
/** Declaration order (`rootOrder`, `ordering[parent]`) and the other layout hints. */
|
|
55
|
+
hints?: LayoutHints;
|
|
56
|
+
/** Runtime token numbers for the engine (gaps, caps). */
|
|
57
|
+
metrics?: Partial<LayoutMetrics>;
|
|
58
|
+
rowPack?: RowPackOptions;
|
|
59
|
+
/** L-R7 report width. The measured path never re-packs on it (D-3). */
|
|
60
|
+
targetWidth?: number;
|
|
61
|
+
/** Card text measurer, shared by the cards, the zones and the layout. */
|
|
62
|
+
measure?: CardLineMeasure;
|
|
63
|
+
iconBindings?: import("./diagramSceneModel.js").SceneIconBindings;
|
|
64
|
+
strictIcons?: boolean;
|
|
65
|
+
/** Layout line measurer. Defaults to the bridge over `measure`. */
|
|
66
|
+
measureLines?: LineMeasurer;
|
|
67
|
+
/** Controlled fold state: collapsed occurrence ids. */
|
|
68
|
+
collapsed?: readonly SceneOccurrenceRef[];
|
|
69
|
+
/** Initial collapsed occurrence ids when `collapsed` is not controlled. */
|
|
70
|
+
defaultFolds?: readonly SceneOccurrenceRef[];
|
|
71
|
+
title?: string;
|
|
72
|
+
/** Accessible name of the figure. Defaults to `title`. */
|
|
73
|
+
label?: string;
|
|
74
|
+
compact?: boolean;
|
|
75
|
+
labels?: Partial<DiagramSceneFigureLabels>;
|
|
76
|
+
resolveGlyph?: (name: string) => DiagramGlyphPaths | undefined;
|
|
77
|
+
onFoldChange?: (collapsed: readonly SceneOccurrenceRef[], change: {
|
|
78
|
+
occurrence: SceneOccurrenceRef;
|
|
79
|
+
collapsed: boolean;
|
|
80
|
+
}) => void;
|
|
81
|
+
onSelect?: (event: {
|
|
82
|
+
entityId: string;
|
|
83
|
+
}) => void;
|
|
84
|
+
/** One call per layout pass, with the engine result (warnings, refusals, orientations). */
|
|
85
|
+
onLayout?: (result: LayoutResult) => void;
|
|
86
|
+
onCameraChange?: (camera: DiagramSceneCamera) => void;
|
|
87
|
+
layoutCache?: SceneLayoutCache;
|
|
88
|
+
contentSize?: DiagramSceneSize;
|
|
89
|
+
onSizeChange?: (size: DiagramSceneSize) => void;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=diagramSceneTypes.d.ts.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Rect } from '../transform.js';
|
|
2
|
+
import { type SemanticDocument, type SemanticPort, type EntityRef, type ErdCardinality } from '@sentropic/diagram-core';
|
|
3
|
+
import type { LineMeasurer } from '../layout/measure.js';
|
|
4
|
+
import type { Vec2 } from '../transform.js';
|
|
5
|
+
/** Numeric mirrors of component.diagramErd; verified against the token source. */
|
|
6
|
+
export declare const ERD_GEOMETRY: {
|
|
7
|
+
readonly width: 460;
|
|
8
|
+
readonly headerHeight: 64;
|
|
9
|
+
readonly rowHeight: 32;
|
|
10
|
+
readonly lineHeight: 24;
|
|
11
|
+
readonly padding: 12;
|
|
12
|
+
readonly keyWidth: 56;
|
|
13
|
+
readonly nameWidth: 170;
|
|
14
|
+
readonly typeWidth: 170;
|
|
15
|
+
readonly fontSize: 18;
|
|
16
|
+
readonly titleFontSize: 24;
|
|
17
|
+
readonly markerLength: 24;
|
|
18
|
+
readonly markerHalfWidth: 8;
|
|
19
|
+
readonly markerRadius: 4;
|
|
20
|
+
readonly markerGap: 4;
|
|
21
|
+
readonly strokeWidth: 1.5;
|
|
22
|
+
readonly gapInline: 160;
|
|
23
|
+
readonly gapBlock: 120;
|
|
24
|
+
readonly labelWidth: 240;
|
|
25
|
+
};
|
|
26
|
+
export declare const escapeErdXml: (value: string) => string;
|
|
27
|
+
export declare function erdText(attributes: SemanticPort['attributes'], key: string): string;
|
|
28
|
+
export declare const erdFlag: (p: SemanticPort, key: string) => boolean;
|
|
29
|
+
export declare function erdFields(document: SemanticDocument, entity: string): SemanticPort[];
|
|
30
|
+
export interface ErdRow {
|
|
31
|
+
readonly field: SemanticPort;
|
|
32
|
+
readonly y: number;
|
|
33
|
+
readonly height: number;
|
|
34
|
+
readonly name: readonly string[];
|
|
35
|
+
readonly type: readonly string[];
|
|
36
|
+
readonly fk: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
export interface ErdCard {
|
|
39
|
+
readonly title: string;
|
|
40
|
+
readonly titleLines: readonly string[];
|
|
41
|
+
readonly width: number;
|
|
42
|
+
readonly height: number;
|
|
43
|
+
readonly headerHeight: number;
|
|
44
|
+
readonly rows: readonly ErdRow[];
|
|
45
|
+
readonly collapsed: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Wraps without truncation, breaking at identifier/punctuation boundaries where possible. */
|
|
48
|
+
export declare function wrapErdText(text: string, width: number, measure?: LineMeasurer, fontSize?: number): string[];
|
|
49
|
+
export declare function measureErdCard(document: SemanticDocument, entity: EntityRef, collapsed?: boolean, measure?: LineMeasurer): ErdCard;
|
|
50
|
+
export declare function renderErdCardSvg(card: ErdCard): string;
|
|
51
|
+
export interface ErdMarker {
|
|
52
|
+
readonly lines: readonly (readonly [
|
|
53
|
+
Vec2,
|
|
54
|
+
Vec2
|
|
55
|
+
])[];
|
|
56
|
+
readonly circle?: {
|
|
57
|
+
readonly center: Vec2;
|
|
58
|
+
readonly radius: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** The outward direction follows the edge away from the card; geometry is token driven. */
|
|
62
|
+
export declare function erdMarkerGeometry(cardinality: ErdCardinality, anchor: Vec2, direction: Vec2, tokens?: {
|
|
63
|
+
readonly [K in keyof typeof ERD_GEOMETRY]: number;
|
|
64
|
+
}): ErdMarker;
|
|
65
|
+
export declare function renderErdMarkerSvg(cardinality: ErdCardinality, anchor: Vec2, direction: Vec2): string;
|
|
66
|
+
/** Escaped native HTML shared verbatim by both framework hosts; always includes folded fields. */
|
|
67
|
+
export declare function renderErdTable(document: SemanticDocument): string;
|
|
68
|
+
export interface ErdLabelEntry {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly route: readonly Vec2[];
|
|
71
|
+
readonly size: {
|
|
72
|
+
readonly width: number;
|
|
73
|
+
readonly height: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Keep every role readable: crowded labels move to a free box with a leader instead of disappearing. */
|
|
77
|
+
export declare function placeErdRoleLabels(entries: readonly ErdLabelEntry[], blockers: readonly Rect[], margin: number): Map<string, {
|
|
78
|
+
box: Rect;
|
|
79
|
+
leader?: readonly Vec2[];
|
|
80
|
+
}>;
|
|
81
|
+
//# sourceMappingURL=erd.d.ts.map
|