@sentropic/diagram-canvas 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/camera.d.ts +24 -3
- package/dist/camera.js +31 -8
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/layout/cache.js +12 -2
- package/dist/layout/channels.d.ts +10 -0
- package/dist/layout/channels.js +13 -0
- package/dist/layout/conventions.d.ts +117 -0
- package/dist/layout/conventions.js +185 -0
- package/dist/layout/dock.d.ts +2 -0
- package/dist/layout/dock.js +5 -1
- package/dist/layout/fingerprint.d.ts +4 -2
- package/dist/layout/fingerprint.js +26 -2
- package/dist/layout/hints.d.ts +1 -1
- package/dist/layout/hints.js +10 -3
- package/dist/layout/index.d.ts +5 -3
- package/dist/layout/index.js +5 -3
- package/dist/layout/measure.d.ts +6 -0
- package/dist/layout/measure.js +28 -0
- package/dist/layout/measured.js +1047 -95
- package/dist/layout/route.d.ts +27 -1
- package/dist/layout/route.js +640 -32
- package/dist/layout/routeSpacing.d.ts +84 -0
- package/dist/layout/routeSpacing.js +472 -0
- package/dist/layout/spacing.generated.d.ts +10 -1
- package/dist/layout/spacing.generated.js +10 -1
- package/dist/layout/types.d.ts +33 -2
- package/dist/layout/types.js +2 -0
- package/dist/presentation/connectorPath.d.ts +32 -0
- package/dist/presentation/connectorPath.js +213 -0
- package/dist/presentation/connectorStyle.d.ts +70 -0
- package/dist/presentation/connectorStyle.js +99 -0
- package/dist/presentation/diagramSceneModel.d.ts +56 -4
- package/dist/presentation/diagramSceneModel.js +222 -31
- package/dist/presentation/diagramSceneTypes.d.ts +9 -0
- package/dist/presentation/index.d.ts +4 -0
- package/dist/presentation/index.js +4 -0
- package/dist/presentation/linkLegend.d.ts +132 -0
- package/dist/presentation/linkLegend.js +231 -0
- package/dist/presentation/renderSceneSvg.d.ts +3 -1
- package/dist/presentation/renderSceneSvg.js +81 -11
- package/dist/presentation/sceneLabelClearance.d.ts +1 -1
- package/dist/presentation/sceneLabelClearance.js +19 -3
- package/dist/r7Mode.d.ts +13 -0
- package/dist/r7Mode.js +67 -0
- package/dist/visibility.d.ts +1 -1
- package/dist/visibility.js +3 -2
- package/package.json +2 -2
package/dist/layout/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `ViewDocument`; everything below is either a call option or the outcome of
|
|
6
6
|
* one call (direction chosen, zoom, warnings), never persisted content.
|
|
7
7
|
*/
|
|
8
|
-
import type { Diagnostic, DiagramPresentation, EntityPresentation, ExecutorProfileBindings, OccurrenceRef, ProfileRegistry, ViewDocument, ViewRef } from "@sentropic/diagram-core";
|
|
8
|
+
import type { Diagnostic, DiagramPresentation, EntityPresentation, ExecutorProfileBindings, OccurrenceRef, ProfileRegistry, RelationPresentation, ViewDocument, ViewRef } from "@sentropic/diagram-core";
|
|
9
9
|
import type { AlignPinned, AnatomyPinned, DepthPinned } from "../presentation/diagramCardModel.js";
|
|
10
10
|
import type { LayoutHints } from "./hints.js";
|
|
11
11
|
import type { LineMeasurer } from "./measure.js";
|
|
@@ -38,6 +38,8 @@ export type TextMeasurer = ((text: string, role: TextRole | LegacyTextRole) => T
|
|
|
38
38
|
};
|
|
39
39
|
/** World units (CSS px at zoom 1). Every field has a default; see {@link DEFAULT_LAYOUT_METRICS}. */
|
|
40
40
|
export interface LayoutMetrics {
|
|
41
|
+
/** Single fixed gutter token between sibling zones on both axes (DE-2 ask 3, default 96). */
|
|
42
|
+
readonly zoneGutter?: number;
|
|
41
43
|
readonly gapMin?: number;
|
|
42
44
|
readonly gapMinBlock?: number;
|
|
43
45
|
readonly gapBase?: number;
|
|
@@ -47,6 +49,20 @@ export interface LayoutMetrics {
|
|
|
47
49
|
readonly labelBand?: number;
|
|
48
50
|
readonly gapMax?: number;
|
|
49
51
|
readonly bundleLabelMaxWidth?: number;
|
|
52
|
+
/** Minimum spacing between parallel segments, neighbouring elbows, ports and arrowheads (DE-2, default 24). */
|
|
53
|
+
readonly routeSpacing?: number;
|
|
54
|
+
/** Minimum clearance from a routed link segment to non-endpoint borders (DE-2, default 15). */
|
|
55
|
+
readonly routeBorderClearance?: number;
|
|
56
|
+
/** World-unit corner radius for rounded-elbow connectors (DE-2, default 12). */
|
|
57
|
+
readonly edgeCornerRadius?: number;
|
|
58
|
+
/** Dedicated resting connector stroke width, CSS px (token `diagramScene.linkStrokeWidth`, DE-2, default 2.5). */
|
|
59
|
+
readonly linkStrokeWidth?: number;
|
|
60
|
+
/** Stroke width for undirected related links on the r7 path. */
|
|
61
|
+
readonly linkRelatedStrokeWidth?: number;
|
|
62
|
+
/** Emphasized connector stroke width, CSS px (token `diagramScene.linkEmphasisStrokeWidth`, DE-2, default 3.5). */
|
|
63
|
+
readonly linkEmphasisStrokeWidth?: number;
|
|
64
|
+
/** Edge label font size, world px (token `diagramScene.edgeLabelSize`, DE-2, default 18). */
|
|
65
|
+
readonly edgeLabelSize?: number;
|
|
50
66
|
readonly nodePaddingX: number;
|
|
51
67
|
readonly nodePaddingY: number;
|
|
52
68
|
readonly nodeMinWidth: number;
|
|
@@ -93,6 +109,8 @@ export declare const DEFAULT_ROW_PACK: ResolvedRowPack;
|
|
|
93
109
|
/** Row-pack spacing defaults, mirroring the DS tokens (asserted by tests/layout/dc2a/tokens.test.ts). */
|
|
94
110
|
export declare const DEFAULT_ROW_GAP: 96;
|
|
95
111
|
export declare const DEFAULT_ROW_GAP_MAX: 240;
|
|
112
|
+
/** Fixed gutter between sibling zones on both axes (DE-2 ask 3, ≥ 96 world units). */
|
|
113
|
+
export declare const DEFAULT_ZONE_GUTTER: 96;
|
|
96
114
|
/** Orientation of one packed level (§4.1): shelves run as rows or as columns. */
|
|
97
115
|
export type LevelOrientation = "rows" | "columns";
|
|
98
116
|
/** Level key of the root level in orientation records (§4.1). */
|
|
@@ -121,6 +139,11 @@ export interface LayoutOptions {
|
|
|
121
139
|
*/
|
|
122
140
|
readonly presentation?: DiagramPresentation & {
|
|
123
141
|
readonly entities: Readonly<Record<string, EntityPresentation & AnatomyPinned & AlignPinned & DepthPinned>>;
|
|
142
|
+
/**
|
|
143
|
+
* Word-addressed connector styles keyed by relation occurrence id or
|
|
144
|
+
* semantic relation id (DE-2). Closed registry words only, never raw geometry.
|
|
145
|
+
*/
|
|
146
|
+
readonly relations?: Readonly<Record<string, RelationPresentation>>;
|
|
124
147
|
};
|
|
125
148
|
/** Injected shared line measurer for measured views (M3 §4.6.2/§5.6). */
|
|
126
149
|
readonly measureLines?: LineMeasurer;
|
|
@@ -167,6 +190,12 @@ export interface LayoutOptions {
|
|
|
167
190
|
* `surface1` expanded zone.
|
|
168
191
|
*/
|
|
169
192
|
readonly reportSurfaceSame?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Opt-in non-blocking convention lints (DE-2 asks 5 & 6): arrow direction
|
|
195
|
+
* (`source` = initiator, when initiator metadata is declared) and opaque
|
|
196
|
+
* acronym zone tags (with `DLR-315` product kicker allowlist). Off by default.
|
|
197
|
+
*/
|
|
198
|
+
readonly conventions?: import("./conventions.js").DiagramConventionLintOptions;
|
|
170
199
|
}
|
|
171
200
|
/** The outcome of the L-R5 / L-R7 decision for one call. Derived, never persisted. */
|
|
172
201
|
export interface LayoutFit {
|
|
@@ -182,7 +211,7 @@ export interface LayoutFit {
|
|
|
182
211
|
readonly phone: boolean;
|
|
183
212
|
}
|
|
184
213
|
/** A rule the engine could not fully satisfy on this input, reported instead of dropped. */
|
|
185
|
-
export type LayoutWarningCode = "channel-unresolved" | "card-icon-missing" | "flow-bundled" | "badge-unplaced" | "flow-layout-unsupported" | "label-unplaced" | "label-budget-exhausted" | "route-obstructed" | "row-fill-partial" | "card-overflow" | "card-grown" | "zone-overflow" | "zone-surface-same" | "docking-overflow";
|
|
214
|
+
export type LayoutWarningCode = "channel-unresolved" | "card-icon-missing" | "flow-bundled" | "badge-unplaced" | "flow-layout-unsupported" | "label-unplaced" | "label-budget-exhausted" | "route-obstructed" | "route-spacing-conflict" | "channel-capacity-exceeded" | "row-fill-partial" | "card-overflow" | "card-grown" | "zone-overflow" | "zone-surface-same" | "arrow-direction-convention" | "zone-tag-opaque-acronym" | "docking-overflow";
|
|
186
215
|
export interface LayoutWarning {
|
|
187
216
|
readonly severity?: "info";
|
|
188
217
|
readonly code: LayoutWarningCode;
|
|
@@ -227,6 +256,8 @@ export type LayoutResult = {
|
|
|
227
256
|
* bounds (DEC-5, BF-7).
|
|
228
257
|
*/
|
|
229
258
|
readonly channels?: readonly import("./channels.js").LayoutChannel[];
|
|
259
|
+
/** Built-in geometric route-spacing audit report (DE-2 ask 2). */
|
|
260
|
+
readonly routeSpacing?: import("./routeSpacing.js").RouteSpacingReport;
|
|
230
261
|
readonly labelBoxes?: Readonly<Record<string, {
|
|
231
262
|
readonly x: number;
|
|
232
263
|
readonly y: number;
|
package/dist/layout/types.js
CHANGED
|
@@ -8,6 +8,8 @@ export const DEFAULT_ROW_PACK = {
|
|
|
8
8
|
/** Row-pack spacing defaults, mirroring the DS tokens (asserted by tests/layout/dc2a/tokens.test.ts). */
|
|
9
9
|
export const DEFAULT_ROW_GAP = spacing.gapMin;
|
|
10
10
|
export const DEFAULT_ROW_GAP_MAX = spacing.gapMax;
|
|
11
|
+
/** Fixed gutter between sibling zones on both axes (DE-2 ask 3, ≥ 96 world units). */
|
|
12
|
+
export const DEFAULT_ZONE_GUTTER = spacing.zoneGutter;
|
|
11
13
|
/** Level key of the root level in orientation records (§4.1). */
|
|
12
14
|
export const ROOT_LEVEL_KEY = "root";
|
|
13
15
|
/** One place where row-pack defaults resolve (§6.1), so cache keys see numbers only. */
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Rect, Vec2 } from "../transform.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default corner radius for rounded-elbow connectors, world units (DE-2).
|
|
4
|
+
* Mirrors the `--st-component-diagramScene-edgeCornerRadius` token (`12px`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_EDGE_CORNER_RADIUS = 12;
|
|
7
|
+
/**
|
|
8
|
+
* Shared SVG `<path d="...">` builder for connectors with rounded elbows (DE-2).
|
|
9
|
+
*
|
|
10
|
+
* Replaces sharp polyline corners with quadratic Bézier curves (`Q`) whose
|
|
11
|
+
* radius is `cornerRadius` (default `12` world units) capped at half the
|
|
12
|
+
* shorter adjoining leg (`min(radius, lenIn / 2, lenOut / 2)`). Adjacent bends
|
|
13
|
+
* sharing a leg therefore never overlap, and the path always begins on the
|
|
14
|
+
* exact start dock (`M x0 y0`) and finishes on the exact end dock (`L xn yn`)
|
|
15
|
+
* with a non-zero arrival segment for `marker-end` orientation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function connectorPath(points: readonly Vec2[], cornerRadius?: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Tight axis-aligned bounding boxes covering the two quadratic Bézier halves
|
|
20
|
+
* (`[enter, mid]` and `[mid, exit]`) of every rounded bend emitted by
|
|
21
|
+
* `connectorPath`. Because the Bézier curve and its midpoint chords stay
|
|
22
|
+
* inside these two rectangles, clearing them guarantees label clearance
|
|
23
|
+
* around rounded elbows as well as straight legs.
|
|
24
|
+
*/
|
|
25
|
+
export declare function connectorCornerBounds(points: readonly Vec2[], cornerRadius?: number): Rect[];
|
|
26
|
+
/**
|
|
27
|
+
* Parse a `connectorPath` SVG `d` string (`M`, `L`, `Q`) into ordered sampled
|
|
28
|
+
* points along the rendered curve: the first point is always the exact start
|
|
29
|
+
* dock and the last point is always the exact end dock.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseConnectorPath(d: string): readonly Vec2[];
|
|
32
|
+
//# sourceMappingURL=connectorPath.d.ts.map
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default corner radius for rounded-elbow connectors, world units (DE-2).
|
|
3
|
+
* Mirrors the `--st-component-diagramScene-edgeCornerRadius` token (`12px`).
|
|
4
|
+
*/
|
|
5
|
+
export const DEFAULT_EDGE_CORNER_RADIUS = 12;
|
|
6
|
+
const EPSILON = 1e-6;
|
|
7
|
+
function formatCoord(value) {
|
|
8
|
+
const cleaned = Number(value.toPrecision(12));
|
|
9
|
+
return String(cleaned === 0 ? 0 : cleaned);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Remove consecutive duplicate points and redundant forward-collinear interior
|
|
13
|
+
* points while preserving the exact first and last dock coordinates.
|
|
14
|
+
*/
|
|
15
|
+
function simplifyElbowPoints(points) {
|
|
16
|
+
if (points.length <= 1)
|
|
17
|
+
return points.map((p) => ({ x: p.x, y: p.y }));
|
|
18
|
+
const dedup = [{ x: points[0].x, y: points[0].y }];
|
|
19
|
+
for (let i = 1; i < points.length; i += 1) {
|
|
20
|
+
const point = points[i];
|
|
21
|
+
const prev = dedup[dedup.length - 1];
|
|
22
|
+
if (Math.hypot(point.x - prev.x, point.y - prev.y) > EPSILON) {
|
|
23
|
+
dedup.push({ x: point.x, y: point.y });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (dedup.length === 1) {
|
|
27
|
+
// All input points coincided: preserve degenerate 2-point dock contact.
|
|
28
|
+
const last = points[points.length - 1];
|
|
29
|
+
dedup.push({ x: last.x, y: last.y });
|
|
30
|
+
return dedup;
|
|
31
|
+
}
|
|
32
|
+
// Keep exact terminal dock point even when the final step was sub-epsilon.
|
|
33
|
+
const end = points[points.length - 1];
|
|
34
|
+
dedup[dedup.length - 1] = { x: end.x, y: end.y };
|
|
35
|
+
if (dedup.length <= 2)
|
|
36
|
+
return dedup;
|
|
37
|
+
const simplified = [dedup[0]];
|
|
38
|
+
for (let i = 1; i < dedup.length - 1; i += 1) {
|
|
39
|
+
const prev = simplified[simplified.length - 1];
|
|
40
|
+
const curr = dedup[i];
|
|
41
|
+
const next = dedup[i + 1];
|
|
42
|
+
const dx1 = curr.x - prev.x;
|
|
43
|
+
const dy1 = curr.y - prev.y;
|
|
44
|
+
const dx2 = next.x - curr.x;
|
|
45
|
+
const dy2 = next.y - curr.y;
|
|
46
|
+
const len1 = Math.hypot(dx1, dy1);
|
|
47
|
+
const len2 = Math.hypot(dx2, dy2);
|
|
48
|
+
if (len1 <= EPSILON || len2 <= EPSILON)
|
|
49
|
+
continue;
|
|
50
|
+
const cross = (dx1 * dy2 - dy1 * dx2) / (len1 * len2);
|
|
51
|
+
const dot = (dx1 * dx2 + dy1 * dy2) / (len1 * len2);
|
|
52
|
+
// Drop forward-collinear interior points so they never cap an adjacent bend.
|
|
53
|
+
if (Math.abs(cross) <= EPSILON && dot > 0)
|
|
54
|
+
continue;
|
|
55
|
+
simplified.push(curr);
|
|
56
|
+
}
|
|
57
|
+
simplified.push(dedup[dedup.length - 1]);
|
|
58
|
+
return simplified;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Shared SVG `<path d="...">` builder for connectors with rounded elbows (DE-2).
|
|
62
|
+
*
|
|
63
|
+
* Replaces sharp polyline corners with quadratic Bézier curves (`Q`) whose
|
|
64
|
+
* radius is `cornerRadius` (default `12` world units) capped at half the
|
|
65
|
+
* shorter adjoining leg (`min(radius, lenIn / 2, lenOut / 2)`). Adjacent bends
|
|
66
|
+
* sharing a leg therefore never overlap, and the path always begins on the
|
|
67
|
+
* exact start dock (`M x0 y0`) and finishes on the exact end dock (`L xn yn`)
|
|
68
|
+
* with a non-zero arrival segment for `marker-end` orientation.
|
|
69
|
+
*/
|
|
70
|
+
export function connectorPath(points, cornerRadius = DEFAULT_EDGE_CORNER_RADIUS) {
|
|
71
|
+
if (points.length < 2)
|
|
72
|
+
return "";
|
|
73
|
+
const simplified = simplifyElbowPoints(points);
|
|
74
|
+
const safeRadius = Number.isFinite(cornerRadius) && cornerRadius > 0 ? cornerRadius : 0;
|
|
75
|
+
const start = simplified[0];
|
|
76
|
+
const parts = [`M${formatCoord(start.x)} ${formatCoord(start.y)}`];
|
|
77
|
+
let cursorX = start.x;
|
|
78
|
+
let cursorY = start.y;
|
|
79
|
+
for (let i = 1; i < simplified.length - 1; i += 1) {
|
|
80
|
+
const prev = simplified[i - 1];
|
|
81
|
+
const corner = simplified[i];
|
|
82
|
+
const next = simplified[i + 1];
|
|
83
|
+
const inX = corner.x - prev.x;
|
|
84
|
+
const inY = corner.y - prev.y;
|
|
85
|
+
const outX = next.x - corner.x;
|
|
86
|
+
const outY = next.y - corner.y;
|
|
87
|
+
const inLen = Math.hypot(inX, inY);
|
|
88
|
+
const outLen = Math.hypot(outX, outY);
|
|
89
|
+
const r = Math.min(safeRadius, inLen / 2, outLen / 2);
|
|
90
|
+
const cross = inLen > EPSILON && outLen > EPSILON ? (inX * outY - inY * outX) / (inLen * outLen) : 0;
|
|
91
|
+
if (r <= EPSILON || Math.abs(cross) <= EPSILON) {
|
|
92
|
+
parts.push(`L${formatCoord(corner.x)} ${formatCoord(corner.y)}`);
|
|
93
|
+
cursorX = corner.x;
|
|
94
|
+
cursorY = corner.y;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const enterX = corner.x - (inX / inLen) * r;
|
|
98
|
+
const enterY = corner.y - (inY / inLen) * r;
|
|
99
|
+
const exitX = corner.x + (outX / outLen) * r;
|
|
100
|
+
const exitY = corner.y + (outY / outLen) * r;
|
|
101
|
+
if (Math.hypot(enterX - cursorX, enterY - cursorY) > EPSILON) {
|
|
102
|
+
parts.push(`L${formatCoord(enterX)} ${formatCoord(enterY)}`);
|
|
103
|
+
}
|
|
104
|
+
parts.push(`Q${formatCoord(corner.x)} ${formatCoord(corner.y)} ${formatCoord(exitX)} ${formatCoord(exitY)}`);
|
|
105
|
+
cursorX = exitX;
|
|
106
|
+
cursorY = exitY;
|
|
107
|
+
}
|
|
108
|
+
const end = simplified[simplified.length - 1];
|
|
109
|
+
parts.push(`L${formatCoord(end.x)} ${formatCoord(end.y)}`);
|
|
110
|
+
return parts.join(" ");
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Tight axis-aligned bounding boxes covering the two quadratic Bézier halves
|
|
114
|
+
* (`[enter, mid]` and `[mid, exit]`) of every rounded bend emitted by
|
|
115
|
+
* `connectorPath`. Because the Bézier curve and its midpoint chords stay
|
|
116
|
+
* inside these two rectangles, clearing them guarantees label clearance
|
|
117
|
+
* around rounded elbows as well as straight legs.
|
|
118
|
+
*/
|
|
119
|
+
export function connectorCornerBounds(points, cornerRadius = DEFAULT_EDGE_CORNER_RADIUS) {
|
|
120
|
+
if (points.length < 3 || !Number.isFinite(cornerRadius) || cornerRadius <= 0)
|
|
121
|
+
return [];
|
|
122
|
+
const simplified = simplifyElbowPoints(points);
|
|
123
|
+
const boxes = [];
|
|
124
|
+
for (let i = 1; i < simplified.length - 1; i += 1) {
|
|
125
|
+
const prev = simplified[i - 1];
|
|
126
|
+
const corner = simplified[i];
|
|
127
|
+
const next = simplified[i + 1];
|
|
128
|
+
const inX = corner.x - prev.x;
|
|
129
|
+
const inY = corner.y - prev.y;
|
|
130
|
+
const outX = next.x - corner.x;
|
|
131
|
+
const outY = next.y - corner.y;
|
|
132
|
+
const inLen = Math.hypot(inX, inY);
|
|
133
|
+
const outLen = Math.hypot(outX, outY);
|
|
134
|
+
const r = Math.min(cornerRadius, inLen / 2, outLen / 2);
|
|
135
|
+
const cross = inLen > EPSILON && outLen > EPSILON ? (inX * outY - inY * outX) / (inLen * outLen) : 0;
|
|
136
|
+
if (r <= EPSILON || Math.abs(cross) <= EPSILON)
|
|
137
|
+
continue;
|
|
138
|
+
const enterX = corner.x - (inX / inLen) * r;
|
|
139
|
+
const enterY = corner.y - (inY / inLen) * r;
|
|
140
|
+
const exitX = corner.x + (outX / outLen) * r;
|
|
141
|
+
const exitY = corner.y + (outY / outLen) * r;
|
|
142
|
+
const midX = 0.25 * enterX + 0.5 * corner.x + 0.25 * exitX;
|
|
143
|
+
const midY = 0.25 * enterY + 0.5 * corner.y + 0.25 * exitY;
|
|
144
|
+
boxes.push({
|
|
145
|
+
x: Math.min(enterX, midX),
|
|
146
|
+
y: Math.min(enterY, midY),
|
|
147
|
+
width: Math.abs(enterX - midX),
|
|
148
|
+
height: Math.abs(enterY - midY),
|
|
149
|
+
}, {
|
|
150
|
+
x: Math.min(midX, exitX),
|
|
151
|
+
y: Math.min(midY, exitY),
|
|
152
|
+
width: Math.abs(midX - exitX),
|
|
153
|
+
height: Math.abs(midY - exitY),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return boxes;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Parse a `connectorPath` SVG `d` string (`M`, `L`, `Q`) into ordered sampled
|
|
160
|
+
* points along the rendered curve: the first point is always the exact start
|
|
161
|
+
* dock and the last point is always the exact end dock.
|
|
162
|
+
*/
|
|
163
|
+
export function parseConnectorPath(d) {
|
|
164
|
+
const tokens = d.match(/[MLQ]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi);
|
|
165
|
+
if (tokens === null)
|
|
166
|
+
return [];
|
|
167
|
+
const out = [];
|
|
168
|
+
let index = 0;
|
|
169
|
+
let command = "";
|
|
170
|
+
let current;
|
|
171
|
+
while (index < tokens.length) {
|
|
172
|
+
const token = tokens[index];
|
|
173
|
+
if (/^[MLQ]$/i.test(token)) {
|
|
174
|
+
command = token.toUpperCase();
|
|
175
|
+
index += 1;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (command === "M" || command === "L") {
|
|
179
|
+
const x = Number(tokens[index]);
|
|
180
|
+
const y = Number(tokens[index + 1]);
|
|
181
|
+
index += 2;
|
|
182
|
+
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
183
|
+
return [];
|
|
184
|
+
current = { x, y };
|
|
185
|
+
out.push(current);
|
|
186
|
+
if (command === "M")
|
|
187
|
+
command = "L";
|
|
188
|
+
}
|
|
189
|
+
else if (command === "Q") {
|
|
190
|
+
const cx = Number(tokens[index]);
|
|
191
|
+
const cy = Number(tokens[index + 1]);
|
|
192
|
+
const ex = Number(tokens[index + 2]);
|
|
193
|
+
const ey = Number(tokens[index + 3]);
|
|
194
|
+
index += 4;
|
|
195
|
+
if (!Number.isFinite(cx) || !Number.isFinite(cy) || !Number.isFinite(ex) || !Number.isFinite(ey))
|
|
196
|
+
return [];
|
|
197
|
+
if (current !== undefined) {
|
|
198
|
+
// Quadratic Bézier midpoint at t = 0.5 lies on the rounded elbow.
|
|
199
|
+
out.push({
|
|
200
|
+
x: 0.25 * current.x + 0.5 * cx + 0.25 * ex,
|
|
201
|
+
y: 0.25 * current.y + 0.5 * cy + 0.25 * ey,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
current = { x: ex, y: ey };
|
|
205
|
+
out.push(current);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=connectorPath.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type ArrowheadKind, type CanonicalArrowheadKind, type LinkEmphasis, type StrokeStyle } from "@sentropic/diagram-core";
|
|
2
|
+
import type { LayoutMetrics } from "../layout/types.js";
|
|
3
|
+
export interface ConnectorMarkerIds {
|
|
4
|
+
readonly filled: string;
|
|
5
|
+
readonly filledEmphasis: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ConnectorMarkerSpec {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly kind: "arrow";
|
|
10
|
+
readonly emphasis: LinkEmphasis;
|
|
11
|
+
readonly viewBox: string;
|
|
12
|
+
readonly refX: number;
|
|
13
|
+
readonly refY: number;
|
|
14
|
+
readonly markerUnits: "userSpaceOnUse";
|
|
15
|
+
readonly markerWidth: number;
|
|
16
|
+
readonly markerHeight: number;
|
|
17
|
+
readonly orient: "auto-start-reverse";
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly fill: string;
|
|
20
|
+
readonly stroke?: string;
|
|
21
|
+
readonly strokeWidth?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Closed marker geometry table for the `@4` arrowhead registry (`arrow | none`, DE-2).
|
|
25
|
+
* Uses `markerUnits="userSpaceOnUse"` at `10.5 × 10.5` world units so raising
|
|
26
|
+
* `linkStrokeWidth` (`1.5 → 2.5/3.5px`) preserves the pre-DE-2 arrowhead size
|
|
27
|
+
* (`7 × 1.5 = 10.5`). Additional heads (hollow triangles, diamonds) are reserved for N2.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ARROWHEAD_MARKER_GEOMETRY: Readonly<{
|
|
30
|
+
arrow: Readonly<{
|
|
31
|
+
viewBox: "0 0 10 10";
|
|
32
|
+
refX: 9;
|
|
33
|
+
refY: 5;
|
|
34
|
+
markerUnits: "userSpaceOnUse";
|
|
35
|
+
markerWidth: 10.5;
|
|
36
|
+
markerHeight: 10.5;
|
|
37
|
+
orient: "auto-start-reverse";
|
|
38
|
+
path: "M0 0L10 5L0 10Z";
|
|
39
|
+
}>;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Single emphasis-stroke token expression shared across Svelte, Vue and SVG
|
|
43
|
+
* targets (`--st-component-diagramScene-linkEmphasisStroke`, falling back to
|
|
44
|
+
* `--st-semantic-border-interactive` and the light core-theme value `#001f33`).
|
|
45
|
+
*/
|
|
46
|
+
export declare const LINK_EMPHASIS_STROKE_FALLBACK = "#001f33";
|
|
47
|
+
export declare const LINK_EMPHASIS_STROKE = "var(--st-component-diagramScene-linkEmphasisStroke, var(--st-semantic-border-interactive, #001f33))";
|
|
48
|
+
/** Derive deterministic per-host marker ids keeping the default arrow id first. */
|
|
49
|
+
export declare function connectorMarkerIds(baseArrowId: string): ConnectorMarkerIds;
|
|
50
|
+
/** Map a closed `StrokeStyle` registry word to its SVG `stroke-dasharray` value (absent for solid). */
|
|
51
|
+
export declare function connectorDashArray(strokeStyle: StrokeStyle | undefined): string | undefined;
|
|
52
|
+
/** Let themed shafts and swatches share the same dash token in every renderer. */
|
|
53
|
+
export declare function connectorDashPaint(strokeStyle: StrokeStyle | undefined): string | undefined;
|
|
54
|
+
export declare function connectorStrokeWidth(edge: Pick<ConnectorMarkerEdgeInput, "emphasis" | "arrowhead">, widths?: Pick<LayoutMetrics, "linkStrokeWidth" | "linkRelatedStrokeWidth" | "linkEmphasisStrokeWidth">): number;
|
|
55
|
+
/** Normalize a closed `ArrowheadKind` word (`arrow | none`). */
|
|
56
|
+
export declare function connectorMarkerKind(arrowhead: ArrowheadKind | undefined): CanonicalArrowheadKind;
|
|
57
|
+
export interface ConnectorMarkerEdgeInput {
|
|
58
|
+
readonly markers?: string;
|
|
59
|
+
readonly directed?: boolean;
|
|
60
|
+
readonly arrowhead?: ArrowheadKind;
|
|
61
|
+
readonly emphasis?: LinkEmphasis;
|
|
62
|
+
}
|
|
63
|
+
/** Resolve the `marker-end` URL reference for one scene edge, or `undefined` when suppressed (`none`, ERD, flow). */
|
|
64
|
+
export declare function connectorMarkerRef(edge: ConnectorMarkerEdgeInput, ids: ConnectorMarkerIds): string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Additional `<marker>` definitions required by the scene beyond the default
|
|
67
|
+
* arrow marker (which hosts always emit first in `<defs>`).
|
|
68
|
+
*/
|
|
69
|
+
export declare function extraConnectorMarkers(edges: readonly ConnectorMarkerEdgeInput[], ids: ConnectorMarkerIds): readonly ConnectorMarkerSpec[];
|
|
70
|
+
//# sourceMappingURL=connectorStyle.d.ts.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { resolveArrowhead, resolveDashPattern, } from "@sentropic/diagram-core";
|
|
2
|
+
import { DEFAULT_LINK_EMPHASIS_STROKE_WIDTH, DEFAULT_LINK_RELATED_STROKE_WIDTH, DEFAULT_LINK_STROKE_WIDTH } from "../camera.js";
|
|
3
|
+
/**
|
|
4
|
+
* Closed marker geometry table for the `@4` arrowhead registry (`arrow | none`, DE-2).
|
|
5
|
+
* Uses `markerUnits="userSpaceOnUse"` at `10.5 × 10.5` world units so raising
|
|
6
|
+
* `linkStrokeWidth` (`1.5 → 2.5/3.5px`) preserves the pre-DE-2 arrowhead size
|
|
7
|
+
* (`7 × 1.5 = 10.5`). Additional heads (hollow triangles, diamonds) are reserved for N2.
|
|
8
|
+
*/
|
|
9
|
+
export const ARROWHEAD_MARKER_GEOMETRY = Object.freeze({
|
|
10
|
+
arrow: Object.freeze({
|
|
11
|
+
viewBox: "0 0 10 10",
|
|
12
|
+
refX: 9,
|
|
13
|
+
refY: 5,
|
|
14
|
+
markerUnits: "userSpaceOnUse",
|
|
15
|
+
markerWidth: 10.5,
|
|
16
|
+
markerHeight: 10.5,
|
|
17
|
+
orient: "auto-start-reverse",
|
|
18
|
+
path: "M0 0L10 5L0 10Z",
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Single emphasis-stroke token expression shared across Svelte, Vue and SVG
|
|
23
|
+
* targets (`--st-component-diagramScene-linkEmphasisStroke`, falling back to
|
|
24
|
+
* `--st-semantic-border-interactive` and the light core-theme value `#001f33`).
|
|
25
|
+
*/
|
|
26
|
+
export const LINK_EMPHASIS_STROKE_FALLBACK = "#001f33";
|
|
27
|
+
export const LINK_EMPHASIS_STROKE = `var(--st-component-diagramScene-linkEmphasisStroke, var(--st-semantic-border-interactive, ${LINK_EMPHASIS_STROKE_FALLBACK}))`;
|
|
28
|
+
/** Derive deterministic per-host marker ids keeping the default arrow id first. */
|
|
29
|
+
export function connectorMarkerIds(baseArrowId) {
|
|
30
|
+
return {
|
|
31
|
+
filled: baseArrowId,
|
|
32
|
+
filledEmphasis: `${baseArrowId}-emphasis`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Map a closed `StrokeStyle` registry word to its SVG `stroke-dasharray` value (absent for solid). */
|
|
36
|
+
export function connectorDashArray(strokeStyle) {
|
|
37
|
+
const descriptor = resolveDashPattern(strokeStyle);
|
|
38
|
+
if (descriptor === undefined || descriptor.dashArray.length === 0)
|
|
39
|
+
return undefined;
|
|
40
|
+
return descriptor.dashArray.join(" ");
|
|
41
|
+
}
|
|
42
|
+
/** Let themed shafts and swatches share the same dash token in every renderer. */
|
|
43
|
+
export function connectorDashPaint(strokeStyle) {
|
|
44
|
+
const fallback = connectorDashArray(strokeStyle);
|
|
45
|
+
if (fallback === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
const token = strokeStyle === "dashed" ? "linkDashDashed" : "linkDashDotted";
|
|
48
|
+
return `stroke-dasharray:var(--st-component-diagramScene-${token}, ${fallback})`;
|
|
49
|
+
}
|
|
50
|
+
export function connectorStrokeWidth(edge, widths) {
|
|
51
|
+
if (edge.emphasis === "emphasis")
|
|
52
|
+
return widths?.linkEmphasisStrokeWidth ?? DEFAULT_LINK_EMPHASIS_STROKE_WIDTH;
|
|
53
|
+
if (edge.arrowhead === "none")
|
|
54
|
+
return widths?.linkRelatedStrokeWidth ?? DEFAULT_LINK_RELATED_STROKE_WIDTH;
|
|
55
|
+
return widths?.linkStrokeWidth ?? DEFAULT_LINK_STROKE_WIDTH;
|
|
56
|
+
}
|
|
57
|
+
/** Normalize a closed `ArrowheadKind` word (`arrow | none`). */
|
|
58
|
+
export function connectorMarkerKind(arrowhead) {
|
|
59
|
+
return resolveArrowhead(arrowhead)?.canonicalKind ?? "arrow";
|
|
60
|
+
}
|
|
61
|
+
/** Resolve the `marker-end` URL reference for one scene edge, or `undefined` when suppressed (`none`, ERD, flow). */
|
|
62
|
+
export function connectorMarkerRef(edge, ids) {
|
|
63
|
+
if (edge.markers !== undefined || edge.directed === true)
|
|
64
|
+
return undefined;
|
|
65
|
+
const kind = connectorMarkerKind(edge.arrowhead);
|
|
66
|
+
if (kind === "none")
|
|
67
|
+
return undefined;
|
|
68
|
+
const emphasized = edge.emphasis === "emphasis";
|
|
69
|
+
return `url(#${emphasized ? ids.filledEmphasis : ids.filled})`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Additional `<marker>` definitions required by the scene beyond the default
|
|
73
|
+
* arrow marker (which hosts always emit first in `<defs>`).
|
|
74
|
+
*/
|
|
75
|
+
export function extraConnectorMarkers(edges, ids) {
|
|
76
|
+
let needFilledEmphasis = false;
|
|
77
|
+
for (const edge of edges) {
|
|
78
|
+
if (edge.markers !== undefined || edge.directed === true)
|
|
79
|
+
continue;
|
|
80
|
+
const kind = connectorMarkerKind(edge.arrowhead);
|
|
81
|
+
if (kind === "none")
|
|
82
|
+
continue;
|
|
83
|
+
if (edge.emphasis === "emphasis") {
|
|
84
|
+
needFilledEmphasis = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const specs = [];
|
|
88
|
+
if (needFilledEmphasis) {
|
|
89
|
+
specs.push({
|
|
90
|
+
id: ids.filledEmphasis,
|
|
91
|
+
kind: "arrow",
|
|
92
|
+
emphasis: "emphasis",
|
|
93
|
+
...ARROWHEAD_MARKER_GEOMETRY.arrow,
|
|
94
|
+
fill: LINK_EMPHASIS_STROKE,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return specs;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=connectorStyle.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FlowIndex, type FlowStep } from "@sentropic/diagram-core";
|
|
1
|
+
import { type ArrowheadKind, type FlowIndex, type FlowStep, type LinkEmphasis, type StrokeStyle } from "@sentropic/diagram-core";
|
|
2
2
|
import type { FlowArrow, FlowBundle, FlowVisibleTarget } from "../layout/flows.js";
|
|
3
3
|
import { type Visible } from "./flowModel.js";
|
|
4
4
|
import type { DiagramSceneFigureLabels } from "./diagramSceneTypes.js";
|
|
@@ -16,10 +16,15 @@ import { type ErdCard } from "./erd.js";
|
|
|
16
16
|
* (layout, scene, camera). The semantic-document and view types are read
|
|
17
17
|
* off the layout signature, so this package names no other diagram layer.
|
|
18
18
|
*/
|
|
19
|
-
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 { DEFAULT_EDGE_LABEL_SIZE, DEFAULT_LINK_PRIMARY_STROKE_WIDTH, DEFAULT_LINK_RELATED_STROKE_WIDTH, DEFAULT_LINK_STROKE_WIDTH, DEFAULT_LINK_EMPHASIS_STROKE_WIDTH, isR7ConnectorPresentation, layoutMeasured, scaleEdgeLabelMeasurer, 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";
|
|
20
20
|
import { type BundleLabelGroup } from "../layout/bundleLabel.js";
|
|
21
|
+
import { type LinkLegendAnchor, type SceneLinkLegend } from "./linkLegend.js";
|
|
21
22
|
import type { EntityPresentation } from "@sentropic/diagram-core";
|
|
22
23
|
import type { AlignPinned, AnatomyPinned, DepthPinned } from "./diagramCardModel.js";
|
|
24
|
+
export { connectorPath, parseConnectorPath, DEFAULT_EDGE_CORNER_RADIUS } from "./connectorPath.js";
|
|
25
|
+
export { ARROWHEAD_MARKER_GEOMETRY, connectorDashArray, connectorDashPaint, connectorMarkerIds, connectorMarkerKind, connectorMarkerRef, extraConnectorMarkers, type ConnectorMarkerEdgeInput, type ConnectorMarkerIds, type ConnectorMarkerSpec, } from "./connectorStyle.js";
|
|
26
|
+
export { buildSceneLinkLegend, collectLinkLegendStyles, defaultLinkStyleLabel, LINK_LEGEND_ARROWHEAD_ORDER, LINK_LEGEND_EMPHASIS_ORDER, LINK_LEGEND_FONT_SIZE, LINK_LEGEND_GAP, LINK_LEGEND_HEADER_GAP, LINK_LEGEND_HEADER_HEIGHT, LINK_LEGEND_MIN_WIDTH, LINK_LEGEND_PADDING, LINK_LEGEND_ROW_GAP, LINK_LEGEND_ROW_HEIGHT, LINK_LEGEND_STROKE_ORDER, LINK_LEGEND_SWATCH_GAP, LINK_LEGEND_SWATCH_HEIGHT, LINK_LEGEND_SWATCH_WIDTH, linkLegendBoxStyle, linkLegendSwatchGeometry, linkStyleKey, type BuildSceneLinkLegendInput, type LinkLegendAnchor, type LinkLegendEdgeInput, type LinkLegendEntry, type LinkLegendStyleKey, type LinkLegendSwatchGeometry, type SceneLinkLegend, } from "./linkLegend.js";
|
|
27
|
+
export { DEFAULT_EDGE_LABEL_SIZE, DEFAULT_LINK_STROKE_WIDTH, DEFAULT_LINK_RELATED_STROKE_WIDTH, DEFAULT_LINK_PRIMARY_STROKE_WIDTH, DEFAULT_LINK_EMPHASIS_STROKE_WIDTH, isR7ConnectorPresentation, };
|
|
23
28
|
/** The semantic document the layout engine reads. */
|
|
24
29
|
export type SceneDocument = Parameters<typeof layoutMeasured>[0];
|
|
25
30
|
/** A view document: the optional retained source view, and the emitted view. */
|
|
@@ -78,6 +83,7 @@ export declare function resolveScenePresentation(document: SceneDocument, presen
|
|
|
78
83
|
contractPin: import("@sentropic/diagram-core").PresentationPin;
|
|
79
84
|
legends: Readonly<Record<string, import("@sentropic/diagram-core").LegendPresentation>>;
|
|
80
85
|
categoryTokens: readonly import("@sentropic/diagram-core").CategoryTokenBinding[];
|
|
86
|
+
relations?: Readonly<Record<string, import("@sentropic/diagram-core").RelationPresentation>>;
|
|
81
87
|
};
|
|
82
88
|
missing: string[];
|
|
83
89
|
};
|
|
@@ -91,6 +97,14 @@ export interface SceneLayoutInput {
|
|
|
91
97
|
readonly depthParityStart?: 0 | 1;
|
|
92
98
|
/** Opt-in informational `zone-surface-same` diagnostic on untinted leaf cards inside `surface1` zones. */
|
|
93
99
|
readonly reportSurfaceSame?: boolean;
|
|
100
|
+
/** Opt-in non-blocking convention lints (DE-2 asks 5 & 6). Off by default. */
|
|
101
|
+
readonly conventions?: LayoutOptions["conventions"];
|
|
102
|
+
/** Automatic link-style legend anchor (`"right"` default; `"none"` suppresses). */
|
|
103
|
+
readonly legend?: LinkLegendAnchor;
|
|
104
|
+
/** Heading for the automatic link-style legend strip (defaults to `"Legend"`). */
|
|
105
|
+
readonly legendTitle?: string;
|
|
106
|
+
/** Optional custom labels for automatic link-style legend entries, keyed by `linkStyleKey(...)`. */
|
|
107
|
+
readonly legendLabels?: Readonly<Record<string, string>>;
|
|
94
108
|
readonly resolveGlyph?: (name: string) => import("./diagramCardModel.js").DiagramGlyphPaths | undefined;
|
|
95
109
|
readonly cache?: SceneLayoutCache;
|
|
96
110
|
readonly document: SceneDocument;
|
|
@@ -181,6 +195,14 @@ export interface SceneEdgeModel {
|
|
|
181
195
|
readonly occurrence: SceneOccurrenceRef;
|
|
182
196
|
readonly points: readonly Vec2[];
|
|
183
197
|
readonly markers?: string;
|
|
198
|
+
/** True when this edge uses the r7 rounded-elbow / dedicated link-token connector path (REQ-R7-11..17). */
|
|
199
|
+
readonly r7?: true;
|
|
200
|
+
/** Closed dash-pattern word from the view/presentation (`solid | dashed | dotted`). */
|
|
201
|
+
readonly strokeStyle?: StrokeStyle;
|
|
202
|
+
/** Closed arrowhead word from the view/presentation (`arrow | none`). */
|
|
203
|
+
readonly arrowhead?: ArrowheadKind;
|
|
204
|
+
/** Closed link-emphasis word from the view/presentation (`default | emphasis`). */
|
|
205
|
+
readonly emphasis?: LinkEmphasis;
|
|
184
206
|
}
|
|
185
207
|
export interface SceneLabelModel {
|
|
186
208
|
readonly occurrence: SceneOccurrenceRef;
|
|
@@ -203,6 +225,8 @@ export interface SceneBadgeModel {
|
|
|
203
225
|
readonly target: Visible;
|
|
204
226
|
}
|
|
205
227
|
export interface SceneModel {
|
|
228
|
+
/** World font size for an edge label in a fitted overview, when enlarged for readability. */
|
|
229
|
+
readonly overviewEdgeLabelSize?: number;
|
|
206
230
|
readonly badges: readonly SceneBadgeModel[];
|
|
207
231
|
readonly flows: FlowIndex;
|
|
208
232
|
readonly flowTargets: Readonly<Record<string, FlowVisibleTarget>>;
|
|
@@ -223,6 +247,8 @@ export interface SceneModel {
|
|
|
223
247
|
readonly nodes: readonly SceneNodeModel[];
|
|
224
248
|
readonly edges: readonly SceneEdgeModel[];
|
|
225
249
|
readonly labels: readonly SceneLabelModel[];
|
|
250
|
+
/** True when the scene uses the r7 connector path (`REQ-R7-11..17`); false for existing v1, ERD, and flow scenes (`REQ-R7-28`). */
|
|
251
|
+
readonly r7Connectors: boolean;
|
|
226
252
|
/**
|
|
227
253
|
* Footer text box of every expanded zone, grown by the label clearance: the
|
|
228
254
|
* one text a frame paints where routes run. A route may cross a zone footer
|
|
@@ -233,12 +259,19 @@ export interface SceneModel {
|
|
|
233
259
|
*/
|
|
234
260
|
readonly connectorCutouts: readonly Rect[];
|
|
235
261
|
/**
|
|
236
|
-
*
|
|
262
|
+
* Automatic legend of the visible link styles actually used in this fold
|
|
263
|
+
* state, anchored on an edge strip outside the functional zones (`undefined`
|
|
264
|
+
* when fewer than two distinct styles are visible or `legend: "none"`).
|
|
265
|
+
*/
|
|
266
|
+
readonly linkLegend?: SceneLinkLegend;
|
|
267
|
+
/**
|
|
268
|
+
* Fit bbox (BF-7): `rectUnion(scene.bounds, placed label boxes, linkLegend.rect)`.
|
|
237
269
|
* `undefined` for an empty scene.
|
|
238
270
|
*/
|
|
239
271
|
readonly bounds?: Rect;
|
|
240
272
|
readonly orientations: SceneOrientations;
|
|
241
273
|
}
|
|
274
|
+
type SceneResolveInput = Pick<SceneLayoutInput, "document" | "presentation" | "measureLines" | "metrics" | "iconBindings" | "strictIcons" | "view" | "resolveGlyph" | "flows" | "depthParityStart" | "legend" | "legendTitle" | "legendLabels">;
|
|
242
275
|
/**
|
|
243
276
|
* The drawable scene of one laid-out result: nodes at emitted geometry,
|
|
244
277
|
* routes, and the emitted edge-label boxes and measured lines. Older results
|
|
@@ -247,7 +280,7 @@ export interface SceneModel {
|
|
|
247
280
|
* collapsed boxes and the title band of each expanded zone — an expanded
|
|
248
281
|
* zone's interior is not a blocker on the row-pack path).
|
|
249
282
|
*/
|
|
250
|
-
export declare function resolveScene(result: SceneLaidOut, input:
|
|
283
|
+
export declare function resolveScene(result: SceneLaidOut, input: SceneResolveInput, viewport?: Omit<SceneCameraInput, "bounds">): SceneModel;
|
|
251
284
|
/** Default labels for `DiagramSceneFigure`, including the DE-1b containment fallback label. */
|
|
252
285
|
export declare const DEFAULT_SCENE_LABELS: DiagramSceneFigureLabels & {
|
|
253
286
|
readonly contains: string;
|
|
@@ -261,6 +294,8 @@ export interface SceneCameraInput {
|
|
|
261
294
|
readonly scrollbarHeight?: number;
|
|
262
295
|
readonly maxDisplayScale?: number;
|
|
263
296
|
readonly minReadableScale?: number;
|
|
297
|
+
/** Opt-in fit-to-window framing (`calc(100vh - 24px)`, DE-2 ask 9). Default `false`. */
|
|
298
|
+
readonly fitToWindow?: boolean;
|
|
264
299
|
}
|
|
265
300
|
/**
|
|
266
301
|
* Quantum of the applied fit zoom, scale units. `sceneFit` floors every fit
|
|
@@ -299,6 +334,22 @@ export declare function scenePlacement(bounds: Rect | undefined, zoom: number, f
|
|
|
299
334
|
export declare function parseDurationMs(value: string | undefined): number;
|
|
300
335
|
/** A unitless number token value; `undefined` when absent or unreadable. */
|
|
301
336
|
export declare function parseScale(value: string | undefined): number | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* Parse a CSS length token (`px`, unitless, `rem`, `em`, `pt`, `pc`, `in`, `cm`, `mm`, `q`)
|
|
339
|
+
* into CSS px / world units. Resolves `rem` against `rootFontSize` (default 16) and `em`
|
|
340
|
+
* against `elementFontSize` (default `rootFontSize`, 16).
|
|
341
|
+
*/
|
|
342
|
+
export declare function parseCssLengthPx(value: string | undefined, context?: {
|
|
343
|
+
readonly rootFontSize?: number;
|
|
344
|
+
readonly elementFontSize?: number;
|
|
345
|
+
}): number | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Resolve the effective edge-label font size from both the DE-2 `edgeLabelSize`
|
|
348
|
+
* token and the legacy `edgeLabelFontSize` token. Core themes define both at
|
|
349
|
+
* `18px`, so r7 also honours consumer overrides on `edgeLabelFontSize`
|
|
350
|
+
* when `edgeLabelSize` has its default value.
|
|
351
|
+
*/
|
|
352
|
+
export declare function resolveEdgeLabelSizeToken(edgeLabelSize: number | undefined, edgeLabelFontSize: number | undefined): number | undefined;
|
|
302
353
|
export type Easing = (progress: number) => number;
|
|
303
354
|
/**
|
|
304
355
|
* The easing of a CSS `cubic-bezier(x1, y1, x2, y2)` token value. Any other
|
|
@@ -317,5 +368,6 @@ export declare function displayedRects(from: ReadonlyMap<string, Rect>, to: Read
|
|
|
317
368
|
export declare function rectsOf(scene: SceneModel): ReadonlyMap<string, Rect>;
|
|
318
369
|
/** Whether two rectangle sets are the same drawing: same ids, same numbers. */
|
|
319
370
|
export declare function sameRects(left: ReadonlyMap<string, Rect>, right: ReadonlyMap<string, Rect>): boolean;
|
|
371
|
+
export { scaleEdgeLabelMeasurer };
|
|
320
372
|
export type { DiagramSceneFigureProps, DiagramSceneFigureLabels, DiagramSceneCamera } from "./diagramSceneTypes.js";
|
|
321
373
|
//# sourceMappingURL=diagramSceneModel.d.ts.map
|