@sentropic/diagram-canvas 0.2.4 → 0.3.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/contracts/diagram-anatomy.v1.json +26 -7
- package/contracts/diagram-anatomy.v2.json +645 -0
- package/dist/layout/cache.js +1 -0
- package/dist/layout/measured.js +97 -23
- package/dist/layout/sceneMeasure.d.ts +2 -1
- package/dist/layout/sceneMeasure.js +10 -8
- package/dist/layout/types.d.ts +15 -4
- package/dist/presentation/diagramCardModel.d.ts +310 -11
- package/dist/presentation/diagramCardModel.js +167 -49
- package/dist/presentation/diagramSceneModel.d.ts +20 -7
- package/dist/presentation/diagramSceneModel.js +108 -20
- package/dist/presentation/diagramSceneTypes.d.ts +4 -0
- package/dist/presentation/renderCardSvg.js +9 -4
- package/dist/presentation/renderSceneSvg.js +1 -1
- package/dist/presentation/renderZoneSvg.js +8 -3
- package/dist/visibility.d.ts +1 -1
- package/dist/visibility.js +25 -3
- package/package.json +3 -2
package/dist/layout/measured.js
CHANGED
|
@@ -30,14 +30,14 @@ import { DEFAULT_MIN_READABLE_SCALE } from "../camera.js";
|
|
|
30
30
|
* with one `docking-overflow` per occurrence. No slot is ever truncated,
|
|
31
31
|
* clipped or ellipsised.
|
|
32
32
|
*/
|
|
33
|
-
import { collapsedOf, createTypeResolver, foldGroupId, GENERIC_PROFILE_ID, hasErrors, localIdOf, occurrenceRef, parentOccurrenceOf, projectView, validateDocument, validateView, viewRef, } from "@sentropic/diagram-core";
|
|
33
|
+
import { collapsedOf, createTypeResolver, foldGroupId, GENERIC_PROFILE_ID, hasErrors, isPresentationContractV2Pin, localIdOf, occurrenceRef, parentOccurrenceOf, projectView, validateDocument, validateView, viewRef, } from "@sentropic/diagram-core";
|
|
34
34
|
import { dockEdges } from "./dock.js";
|
|
35
35
|
import { isAncestor } from "./graph.js";
|
|
36
36
|
import { effectiveStretch, groupLeaves, isLayoutGroup, resolveGaps, resolveOrder, resolveRowGaps, validateHints, } from "./hints.js";
|
|
37
37
|
import { measureSceneBox } from "./sceneMeasure.js";
|
|
38
|
-
import { ZONE_GEOMETRY } from "../presentation/diagramCardModel.js";
|
|
38
|
+
import { anatomyCardGeometry, anatomyZoneGeometry, ZONE_GEOMETRY, zoneDepthSurface } from "../presentation/diagramCardModel.js";
|
|
39
39
|
import { placePackedLabel } from "./labels.js";
|
|
40
|
-
import { DEFAULT_ALLOCATED_LINES, FIXED_CARD_HEIGHT, FIXED_CARD_WIDTH, headerAvailableWidth, headerOverflows, innerWidthOf, LEGEND_KEY_HEIGHT, measureHeader, SWATCH_ALLOCATION, TOGGLE_ALLOCATION, UNWRAPPED_PROBE_WIDTH, } from "./measure.js";
|
|
40
|
+
import { CONTENT_INSET, DEFAULT_ALLOCATED_LINES, FIXED_CARD_HEIGHT, FIXED_CARD_WIDTH, headerAvailableWidth, headerOverflows, innerWidthOf, LEGEND_KEY_HEIGHT, measureHeader, SWATCH_ALLOCATION, TOGGLE_ALLOCATION, UNWRAPPED_PROBE_WIDTH, } from "./measure.js";
|
|
41
41
|
import { measureBundleLabel } from "./bundleLabel.js";
|
|
42
42
|
import { channelGap, channelMetrics } from "./channels.js";
|
|
43
43
|
import { chooseOrientation, packColumns, packRows, seatShelves } from "./pack.js";
|
|
@@ -56,6 +56,29 @@ function semanticName(document, entity) {
|
|
|
56
56
|
function formOf(presentation, occurrence) {
|
|
57
57
|
return presentation.entities[occurrence]?.form;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Strip transient canvas-only stamps (`anatomy`, `depth`, `depthParityStart`,
|
|
61
|
+
* and `align` under `@1`) before persisting `presentation.diagram` on the
|
|
62
|
+
* emitted `ViewDocument`, so every laid-out view passes `validateView`.
|
|
63
|
+
*/
|
|
64
|
+
function persistableDiagramPresentation(presentation) {
|
|
65
|
+
const allowsAlign = presentation.contractPin !== undefined &&
|
|
66
|
+
isPresentationContractV2Pin(presentation.contractPin);
|
|
67
|
+
const entities = {};
|
|
68
|
+
for (const [key, entry] of Object.entries(presentation.entities)) {
|
|
69
|
+
const record = entry;
|
|
70
|
+
const cleanEntry = {};
|
|
71
|
+
for (const [field, value] of Object.entries(record)) {
|
|
72
|
+
if (field === "anatomy" || field === "depth" || field === "depthParityStart")
|
|
73
|
+
continue;
|
|
74
|
+
if (field === "align" && !allowsAlign)
|
|
75
|
+
continue;
|
|
76
|
+
cleanEntry[field] = value;
|
|
77
|
+
}
|
|
78
|
+
entities[key] = cleanEntry;
|
|
79
|
+
}
|
|
80
|
+
return { ...presentation, entities };
|
|
81
|
+
}
|
|
59
82
|
/** Slot text for one occurrence: typed presentation slots, else the semantic name as title. */
|
|
60
83
|
function slotTexts(document, presentation, occurrence, entity) {
|
|
61
84
|
const text = presentation.entities[occurrence]
|
|
@@ -183,6 +206,15 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
183
206
|
diagnostics: [],
|
|
184
207
|
};
|
|
185
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Per-occurrence pinned anatomy (DE-1): the presentation entry selects
|
|
211
|
+
* `diagram-anatomy/v1 | v2`, falling back to `sourceView.presentation.anatomy`;
|
|
212
|
+
* absent everywhere means `"v1"` so existing views keep the frozen `460 × 200`
|
|
213
|
+
* footprint by construction.
|
|
214
|
+
*/
|
|
215
|
+
const viewAnatomy = sourceView?.presentation?.anatomy;
|
|
216
|
+
const occurrenceAnatomy = (occurrence) => presentation.entities[occurrence]?.anatomy ?? viewAnatomy ?? "v1";
|
|
217
|
+
const cardWidthOf = (occurrence) => anatomyCardGeometry(occurrenceAnatomy(occurrence)).width;
|
|
186
218
|
if (options.measureLines === undefined) {
|
|
187
219
|
return {
|
|
188
220
|
status: "refused",
|
|
@@ -202,7 +234,9 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
202
234
|
const key = `${id}|${width}|${collapsed}`;
|
|
203
235
|
let box = sceneBoxCache.get(key);
|
|
204
236
|
if (box === undefined) {
|
|
205
|
-
const
|
|
237
|
+
const rawEntry = presentation.entities[id];
|
|
238
|
+
const entry = rawEntry === undefined ? undefined
|
|
239
|
+
: rawEntry.anatomy === undefined && viewAnatomy !== undefined ? { ...rawEntry, anatomy: viewAnatomy } : rawEntry;
|
|
206
240
|
const kind = kinds.get(projected.entityOccurrences[id]?.entity);
|
|
207
241
|
const expanded = kind === "container-expanded" || kind === "legend-expanded";
|
|
208
242
|
box = measureSceneBox(expanded && entry?.form === "card" ? { ...entry, form: "container" } : entry, id, width, collapsed, measure, metrics.containerPadding);
|
|
@@ -351,7 +385,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
351
385
|
portOccurrences,
|
|
352
386
|
groups: synthesizedGroups,
|
|
353
387
|
filters: [],
|
|
354
|
-
presentation: { camera: { x: 0, y: 0, zoom: 1 }, diagram: presentation },
|
|
388
|
+
presentation: { camera: { x: 0, y: 0, zoom: 1 }, diagram: persistableDiagramPresentation(presentation) },
|
|
355
389
|
};
|
|
356
390
|
};
|
|
357
391
|
let projected;
|
|
@@ -413,7 +447,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
413
447
|
const foldMetadata = {
|
|
414
448
|
groups: projected.groups,
|
|
415
449
|
filters: [...projected.filters],
|
|
416
|
-
presentationState: { ...projected.presentation, diagram: presentation },
|
|
450
|
+
presentationState: { ...projected.presentation, diagram: persistableDiagramPresentation(presentation) },
|
|
417
451
|
summaryLabels: projected.summaryLabels,
|
|
418
452
|
projected,
|
|
419
453
|
representativeOf,
|
|
@@ -763,7 +797,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
763
797
|
};
|
|
764
798
|
const entry = presentation.entities[representativeOf(id)];
|
|
765
799
|
const header = entry === undefined ? measureHeader(input, measure)
|
|
766
|
-
: sceneBoxAt(representativeOf(id), inner + 2 *
|
|
800
|
+
: sceneBoxAt(representativeOf(id), inner + 2 * CONTENT_INSET, input.folded).header;
|
|
767
801
|
headers.set(id, header);
|
|
768
802
|
headerInputs.set(id, input);
|
|
769
803
|
headerWidths.set(id, inner);
|
|
@@ -847,33 +881,34 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
847
881
|
const sizeBox = (id) => {
|
|
848
882
|
const kind = kinds.get(id);
|
|
849
883
|
if (kind === "leaf" || kind === "container-collapsed" || kind === "legend-collapsed") {
|
|
850
|
-
outerWidths.set(id, FIXED_CARD_WIDTH);
|
|
851
884
|
const entry = presentation.entities[representativeOf(id)];
|
|
852
885
|
const measured = entry === undefined ? { width: FIXED_CARD_WIDTH, height: FIXED_CARD_HEIGHT }
|
|
853
|
-
: sceneBoxAt(representativeOf(id),
|
|
886
|
+
: sceneBoxAt(representativeOf(id), cardWidthOf(representativeOf(id)), kind !== "leaf");
|
|
887
|
+
outerWidths.set(id, measured.width);
|
|
854
888
|
const size = { width: measured.width, height: measured.height };
|
|
855
889
|
packedSizes.set(id, size);
|
|
856
890
|
return size;
|
|
857
891
|
}
|
|
858
892
|
if (kind === "legend-key")
|
|
859
893
|
return { width: innerWidthOf(FIXED_CARD_WIDTH), height: LEGEND_KEY_HEIGHT };
|
|
894
|
+
const zoneGeo = anatomyZoneGeometry(occurrenceAnatomy(representativeOf(id)));
|
|
860
895
|
const hasIcon = presentation.entities[representativeOf(id)]?.icon !== "none";
|
|
861
|
-
const headerReserve =
|
|
896
|
+
const headerReserve = zoneGeo.headerTextInset - (hasIcon ? 0 : zoneGeo.iconSize + zoneGeo.iconTextGap);
|
|
862
897
|
const headerDriven = unwrappedHeaderWidth(id) + headerReserve;
|
|
863
|
-
const floor = Math.max(
|
|
898
|
+
const floor = Math.max(zoneGeo.collapsedWidth, headerDriven);
|
|
864
899
|
const ordered = orderedChildrenOf(id);
|
|
865
900
|
const headerHeight = headerHeightOf(id, floor);
|
|
866
901
|
if (kind === "legend-expanded") {
|
|
867
902
|
// A legend stays a single-column list of keys (DLR-341): exempt from packing.
|
|
868
903
|
outerWidths.set(id, floor);
|
|
869
904
|
const keys = ordered.length * LEGEND_KEY_HEIGHT + Math.max(0, ordered.length - 1) * gaps.cardGapY;
|
|
870
|
-
const size = { width: floor, height:
|
|
905
|
+
const size = { width: floor, height: zoneGeo.headerInset + headerHeight + contentInset + keys + contentInset };
|
|
871
906
|
packedSizes.set(id, size);
|
|
872
907
|
return size;
|
|
873
908
|
}
|
|
874
909
|
const run = buildLevelRun(id, ordered);
|
|
875
910
|
levelRuns.set(id, run);
|
|
876
|
-
const level = sizeRun(run, 2 * contentInset,
|
|
911
|
+
const level = sizeRun(run, 2 * contentInset, zoneGeo.headerInset + headerHeight + contentInset + contentInset);
|
|
877
912
|
// BF-6: reserve measured U-channel headroom for labelled edges on one
|
|
878
913
|
// shelf, including wrapped labels and parallel channels. This is
|
|
879
914
|
// container content below its children; sibling gutters keep their cap.
|
|
@@ -905,7 +940,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
905
940
|
outerWidths.set(id, outer);
|
|
906
941
|
const size = {
|
|
907
942
|
width: outer,
|
|
908
|
-
height:
|
|
943
|
+
height: zoneGeo.headerInset + headerHeight + contentInset + levelHeight + contentInset
|
|
909
944
|
+ sceneBoxAt(representativeOf(id), outer, false).footerReserve,
|
|
910
945
|
};
|
|
911
946
|
packedSizes.set(id, size);
|
|
@@ -927,7 +962,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
927
962
|
for (const id of headerIds) {
|
|
928
963
|
const kind = kinds.get(id);
|
|
929
964
|
const folded = kind === "container-collapsed" || kind === "legend-collapsed";
|
|
930
|
-
headerAt(id, folded ? innerWidthOf(
|
|
965
|
+
headerAt(id, folded ? innerWidthOf(packedSizes.get(id)?.width ?? cardWidthOf(representativeOf(id))) : innerWidthOf(outerWidths.get(id) ?? cardWidthOf(representativeOf(id))));
|
|
931
966
|
}
|
|
932
967
|
};
|
|
933
968
|
sizeAll();
|
|
@@ -943,11 +978,21 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
943
978
|
const occurrence = representativeOf(id);
|
|
944
979
|
if (presentation.entities[occurrence] !== undefined && size !== undefined) {
|
|
945
980
|
for (const diagnostic of sceneBoxAt(occurrence, size.width, isCollapsed(id)).diagnostics) {
|
|
946
|
-
if (diagnostic.reason !== "truncated")
|
|
981
|
+
if (diagnostic.reason !== "truncated" && diagnostic.reason !== "fallback-v1")
|
|
947
982
|
continue;
|
|
983
|
+
const isFallback = diagnostic.reason === "fallback-v1";
|
|
948
984
|
warnings.push({ code: kinds.get(id) === "leaf" ? "card-overflow" : "zone-overflow", severity: "info",
|
|
949
|
-
refs: [occurrence, diagnostic.slot],
|
|
950
|
-
|
|
985
|
+
refs: [occurrence, diagnostic.slot],
|
|
986
|
+
message: isFallback
|
|
987
|
+
? "compact anatomy overflow on " + diagnostic.slot + ": fell back to v1 frozen box"
|
|
988
|
+
: "truncated " + diagnostic.slot + ": " + diagnostic.hiddenLength + " hidden characters; full text in title/aria",
|
|
989
|
+
details: {
|
|
990
|
+
slot: diagnostic.slot,
|
|
991
|
+
reason: diagnostic.reason,
|
|
992
|
+
...(diagnostic.hiddenLength === undefined ? {} : { hiddenLength: diagnostic.hiddenLength }),
|
|
993
|
+
neededHeight: diagnostic.neededPx,
|
|
994
|
+
allocatedHeight: diagnostic.allocatedPx,
|
|
995
|
+
} });
|
|
951
996
|
}
|
|
952
997
|
}
|
|
953
998
|
else
|
|
@@ -955,6 +1000,34 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
955
1000
|
warnOverflow(overflow, kinds.get(id) !== "leaf");
|
|
956
1001
|
}
|
|
957
1002
|
}
|
|
1003
|
+
if (options.reportSurfaceSame === true) {
|
|
1004
|
+
for (const id of headerIds) {
|
|
1005
|
+
const kind = kinds.get(id);
|
|
1006
|
+
if (kind !== "container-expanded" && kind !== "legend-expanded")
|
|
1007
|
+
continue;
|
|
1008
|
+
const zoneOcc = representativeOf(id);
|
|
1009
|
+
const zoneEntry = presentation.entities[zoneOcc];
|
|
1010
|
+
const zoneDepth = zoneEntry?.depth ?? graph.nodes.get(id)?.depth ?? 0;
|
|
1011
|
+
const surface = zoneDepthSurface(zoneDepth, zoneEntry?.depthParityStart);
|
|
1012
|
+
if (surface !== "surface1")
|
|
1013
|
+
continue;
|
|
1014
|
+
for (const childId of orderedChildrenOf(id)) {
|
|
1015
|
+
if (kinds.get(childId) !== "leaf")
|
|
1016
|
+
continue;
|
|
1017
|
+
const childOcc = representativeOf(childId);
|
|
1018
|
+
const childEntry = presentation.entities[childOcc];
|
|
1019
|
+
if (childEntry?.categoryRef !== undefined)
|
|
1020
|
+
continue;
|
|
1021
|
+
warnings.push({
|
|
1022
|
+
code: "zone-surface-same",
|
|
1023
|
+
severity: "info",
|
|
1024
|
+
refs: [zoneOcc, childOcc],
|
|
1025
|
+
message: `white leaf card ${childOcc} sits on same-colour surface1 zone ${zoneOcc}`,
|
|
1026
|
+
details: { zone: zoneOcc, card: childOcc, surface },
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
958
1031
|
// Seating: every run at its packed positions. The root is one more run
|
|
959
1032
|
// with zero chrome and the same token gaps — never `rankGap` (§3.5).
|
|
960
1033
|
const rects = new Map();
|
|
@@ -990,18 +1063,19 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
990
1063
|
}
|
|
991
1064
|
const size = packedSizes.get(id);
|
|
992
1065
|
const header = headers.get(id);
|
|
1066
|
+
const zoneGeo = anatomyZoneGeometry(occurrenceAnatomy(representativeOf(id)));
|
|
993
1067
|
const inner = innerWidthOf(size.width);
|
|
994
1068
|
rects.set(id, { x, y, width: size.width, height: size.height });
|
|
995
|
-
const ruleClearance = (
|
|
996
|
-
titleBands.set(id, { x, y, width: size.width, height:
|
|
1069
|
+
const ruleClearance = (zoneGeo.ruleHeight / 2 + 1) / DEFAULT_MIN_READABLE_SCALE;
|
|
1070
|
+
titleBands.set(id, { x, y, width: size.width, height: zoneGeo.headerInset + header.height });
|
|
997
1071
|
const footerReserve = sceneBoxAt(representativeOf(id), size.width, false).footerReserve;
|
|
998
1072
|
if (footerReserve > 0)
|
|
999
1073
|
footerBands.set(id, {
|
|
1000
|
-
x, y: y + size.height - footerReserve -
|
|
1001
|
-
width: size.width, height: footerReserve +
|
|
1074
|
+
x, y: y + size.height - footerReserve - zoneGeo.borderWidth - ruleClearance,
|
|
1075
|
+
width: size.width, height: footerReserve + zoneGeo.borderWidth + ruleClearance,
|
|
1002
1076
|
});
|
|
1003
1077
|
const contentX = x + contentInset;
|
|
1004
|
-
const contentY = y +
|
|
1078
|
+
const contentY = y + zoneGeo.headerInset + header.height + contentInset;
|
|
1005
1079
|
if (kind === "legend-expanded") {
|
|
1006
1080
|
legendInner.set(id, inner);
|
|
1007
1081
|
orderedChildrenOf(id).forEach((key, index) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** The scene engine and both renderers share the same card/zone chrome. */
|
|
2
2
|
import type { EntityPresentation, OccurrenceRef } from "@sentropic/diagram-core";
|
|
3
|
+
import { type AlignPinned, type AnatomyPinned, type DepthPinned } from "../presentation/diagramCardModel.js";
|
|
3
4
|
import { type HeaderMeasurement, type LineMeasurer } from "./measure.js";
|
|
4
|
-
export declare function measureSceneBox(presentation: EntityPresentation | undefined, occurrence: OccurrenceRef, width: number, collapsed: boolean, measure: LineMeasurer, containerPadding?: number): {
|
|
5
|
+
export declare function measureSceneBox(presentation: (EntityPresentation & AnatomyPinned & AlignPinned & DepthPinned) | undefined, occurrence: OccurrenceRef, width: number, collapsed: boolean, measure: LineMeasurer, containerPadding?: number): {
|
|
5
6
|
width: number;
|
|
6
7
|
height: number;
|
|
7
8
|
header: HeaderMeasurement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { layoutCard, layoutZone, projectCardProps, projectZoneProps, lineBoxHeight, CARD_GEOMETRY,
|
|
1
|
+
import { anatomyCardGeometry, anatomyZoneGeometry, layoutCard, layoutZone, projectCardProps, projectZoneProps, lineBoxHeight, CARD_GEOMETRY, } from "../presentation/diagramCardModel.js";
|
|
2
2
|
import { DEFAULT_ALLOCATED_LINES } from "./measure.js";
|
|
3
3
|
export function measureSceneBox(presentation, occurrence, width, collapsed, measure, containerPadding) {
|
|
4
4
|
const zone = presentation?.form === "container" || presentation?.form === "legend";
|
|
@@ -27,6 +27,8 @@ export function measureSceneBox(presentation, occurrence, width, collapsed, meas
|
|
|
27
27
|
? layoutZone({ ...projected.props, autoSize: true }, adapter)
|
|
28
28
|
: layoutCard({ ...props, autoSize: true }, adapter);
|
|
29
29
|
const card = "collapsed" in layout ? layout.card : layout;
|
|
30
|
+
const effectiveCardGeometry = anatomyCardGeometry(card?.anatomyFallback ?? presentation?.anatomy);
|
|
31
|
+
const zoneGeo = anatomyZoneGeometry(presentation?.anatomy);
|
|
30
32
|
const header = "collapsed" in layout ? layout.header : undefined;
|
|
31
33
|
const textWidth = card?.headerTextWidth ?? header.headerTextWidth;
|
|
32
34
|
const rawKicker = presentation?.text.kicker === undefined ? undefined : at(presentation.text.kicker, "kicker", textWidth);
|
|
@@ -37,9 +39,9 @@ export function measureSceneBox(presentation, occurrence, width, collapsed, meas
|
|
|
37
39
|
const kicker = bounded(rawKicker, card?.kicker ?? header?.kicker, CARD_GEOMETRY.kicker.size);
|
|
38
40
|
const title = bounded(rawTitle, card?.title ?? header?.title, CARD_GEOMETRY.title.size);
|
|
39
41
|
const subtitle = bounded(rawSubtitle, header?.subtitle, CARD_GEOMETRY.body.size);
|
|
40
|
-
const blockHeight = Math.max(projected.kind === "label" || presentation?.icon === "none" ? 0 :
|
|
41
|
-
const height = header === undefined ? blockHeight : blockHeight +
|
|
42
|
-
+ (subtitle === undefined || subtitle.lines.length === 0 ? 0 :
|
|
42
|
+
const blockHeight = Math.max(projected.kind === "label" || presentation?.icon === "none" ? 0 : effectiveCardGeometry.iconSize, (kicker?.height ?? 0) + title.height);
|
|
43
|
+
const height = header === undefined ? blockHeight : blockHeight + zoneGeo.headerRuleGap
|
|
44
|
+
+ (subtitle === undefined || subtitle.lines.length === 0 ? 0 : zoneGeo.subtitleGap + subtitle.height);
|
|
43
45
|
const measuredHeader = {
|
|
44
46
|
occurrence,
|
|
45
47
|
...(kicker === undefined ? {} : { kicker }), title,
|
|
@@ -47,11 +49,11 @@ export function measureSceneBox(presentation, occurrence, width, collapsed, meas
|
|
|
47
49
|
overflow: (kicker?.overflow ?? false) || title.overflow || (subtitle?.overflow ?? false),
|
|
48
50
|
};
|
|
49
51
|
const footerReserve = header === undefined || header.footer.length === 0 ? 0
|
|
50
|
-
: header.footer.length * lineBoxHeight(
|
|
51
|
-
+
|
|
52
|
+
: header.footer.length * lineBoxHeight(zoneGeo.footer.size)
|
|
53
|
+
+ zoneGeo.ruleHeight + 2 * zoneGeo.ruleMargin + zoneGeo.footerBottomInset;
|
|
52
54
|
return { width: layout.box.width, height: layout.box.height, header: measuredHeader,
|
|
53
|
-
bodyWidth: card?.bodyWidth ?? width - 2 * (containerPadding ??
|
|
54
|
-
footerWidth: card === undefined ? width - 2 * (containerPadding ??
|
|
55
|
+
bodyWidth: card?.bodyWidth ?? width - 2 * (containerPadding ?? zoneGeo.contentInsetInline),
|
|
56
|
+
footerWidth: card === undefined ? width - 2 * (containerPadding ?? zoneGeo.contentInsetInline) : card.box.width - effectiveCardGeometry.borderWidth - effectiveCardGeometry.padding - effectiveCardGeometry.headerInset,
|
|
55
57
|
footerReserve, diagnostics: layout.diagnostics };
|
|
56
58
|
}
|
|
57
59
|
//# sourceMappingURL=sceneMeasure.js.map
|
package/dist/layout/types.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
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, ExecutorProfileBindings, OccurrenceRef, ProfileRegistry, ViewDocument, ViewRef } from "@sentropic/diagram-core";
|
|
8
|
+
import type { Diagnostic, DiagramPresentation, EntityPresentation, ExecutorProfileBindings, OccurrenceRef, ProfileRegistry, ViewDocument, ViewRef } from "@sentropic/diagram-core";
|
|
9
|
+
import type { AlignPinned, AnatomyPinned, DepthPinned } from "../presentation/diagramCardModel.js";
|
|
9
10
|
import type { LayoutHints } from "./hints.js";
|
|
10
11
|
import type { LineMeasurer } from "./measure.js";
|
|
11
12
|
/** L-R5: the only two flows the engine draws. */
|
|
@@ -114,9 +115,13 @@ export interface LayoutOptions {
|
|
|
114
115
|
* Typed synthesis presentation (M3 §3.2/§5.6). Absent means the
|
|
115
116
|
* compatibility path: the pinned existing behaviour, byte-identical (§4.8).
|
|
116
117
|
* Present selects the card/container/legend/legend-key synthesis forms and
|
|
117
|
-
* the fixed-footprint measurement rules of §4.6.
|
|
118
|
+
* the fixed-footprint measurement rules of §4.6. Entities may carry the
|
|
119
|
+
* additive DE-1 pins (`AnatomyPinned`, `AlignPinned`, `DepthPinned`);
|
|
120
|
+
* absent pins keep the frozen behaviour.
|
|
118
121
|
*/
|
|
119
|
-
readonly presentation?: DiagramPresentation
|
|
122
|
+
readonly presentation?: DiagramPresentation & {
|
|
123
|
+
readonly entities: Readonly<Record<string, EntityPresentation & AnatomyPinned & AlignPinned & DepthPinned>>;
|
|
124
|
+
};
|
|
120
125
|
/** Injected shared line measurer for measured views (M3 §4.6.2/§5.6). */
|
|
121
126
|
readonly measureLines?: LineMeasurer;
|
|
122
127
|
/** Verified executor bindings for @2 profiles (M3 §5.3.1); required for generic@2. */
|
|
@@ -156,6 +161,12 @@ export interface LayoutOptions {
|
|
|
156
161
|
* the previous orientation of a level is kept (O-4).
|
|
157
162
|
*/
|
|
158
163
|
readonly previousOrientation?: Readonly<Record<string, LevelOrientation>>;
|
|
164
|
+
/**
|
|
165
|
+
* Opt-in informational diagnostic (owner addendum 1): when true, report
|
|
166
|
+
* `zone-surface-same` for untinted leaf cards sitting directly on a
|
|
167
|
+
* `surface1` expanded zone.
|
|
168
|
+
*/
|
|
169
|
+
readonly reportSurfaceSame?: boolean;
|
|
159
170
|
}
|
|
160
171
|
/** The outcome of the L-R5 / L-R7 decision for one call. Derived, never persisted. */
|
|
161
172
|
export interface LayoutFit {
|
|
@@ -171,7 +182,7 @@ export interface LayoutFit {
|
|
|
171
182
|
readonly phone: boolean;
|
|
172
183
|
}
|
|
173
184
|
/** A rule the engine could not fully satisfy on this input, reported instead of dropped. */
|
|
174
|
-
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" | "docking-overflow";
|
|
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";
|
|
175
186
|
export interface LayoutWarning {
|
|
176
187
|
readonly severity?: "info";
|
|
177
188
|
readonly code: LayoutWarningCode;
|