@sentropic/diagram-canvas 0.2.5 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/diagram-anatomy.v2.json +645 -0
- package/dist/layout/cache.js +1 -0
- package/dist/layout/measured.js +105 -27
- 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 +312 -4
- package/dist/presentation/diagramCardModel.js +178 -41
- package/dist/presentation/diagramSceneModel.d.ts +22 -7
- package/dist/presentation/diagramSceneModel.js +114 -20
- package/dist/presentation/diagramSceneTypes.d.ts +4 -0
- package/dist/presentation/renderCardSvg.js +10 -5
- package/dist/presentation/renderSceneSvg.js +1 -1
- package/dist/presentation/renderZoneSvg.js +9 -4
- 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);
|
|
@@ -844,36 +878,41 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
844
878
|
packedRuns.set(run.key, { run, rows, shelves, boxes, positions: seated.positions, alongBase, acrossBase });
|
|
845
879
|
return { width: seated.width, height: seated.height };
|
|
846
880
|
};
|
|
881
|
+
const legendKeyCardWidth = (id) => {
|
|
882
|
+
const parent = graph.nodes.get(id)?.parent;
|
|
883
|
+
return parent !== undefined ? cardWidthOf(representativeOf(parent)) : cardWidthOf(representativeOf(id));
|
|
884
|
+
};
|
|
847
885
|
const sizeBox = (id) => {
|
|
848
886
|
const kind = kinds.get(id);
|
|
849
887
|
if (kind === "leaf" || kind === "container-collapsed" || kind === "legend-collapsed") {
|
|
850
|
-
outerWidths.set(id, FIXED_CARD_WIDTH);
|
|
851
888
|
const entry = presentation.entities[representativeOf(id)];
|
|
852
889
|
const measured = entry === undefined ? { width: FIXED_CARD_WIDTH, height: FIXED_CARD_HEIGHT }
|
|
853
|
-
: sceneBoxAt(representativeOf(id),
|
|
890
|
+
: sceneBoxAt(representativeOf(id), cardWidthOf(representativeOf(id)), kind !== "leaf");
|
|
891
|
+
outerWidths.set(id, measured.width);
|
|
854
892
|
const size = { width: measured.width, height: measured.height };
|
|
855
893
|
packedSizes.set(id, size);
|
|
856
894
|
return size;
|
|
857
895
|
}
|
|
858
896
|
if (kind === "legend-key")
|
|
859
|
-
return { width: innerWidthOf(
|
|
897
|
+
return { width: innerWidthOf(legendKeyCardWidth(id)), height: LEGEND_KEY_HEIGHT };
|
|
898
|
+
const zoneGeo = anatomyZoneGeometry(occurrenceAnatomy(representativeOf(id)));
|
|
860
899
|
const hasIcon = presentation.entities[representativeOf(id)]?.icon !== "none";
|
|
861
|
-
const headerReserve =
|
|
900
|
+
const headerReserve = zoneGeo.headerTextInset - (hasIcon ? 0 : zoneGeo.iconSize + zoneGeo.iconTextGap);
|
|
862
901
|
const headerDriven = unwrappedHeaderWidth(id) + headerReserve;
|
|
863
|
-
const floor = Math.max(
|
|
902
|
+
const floor = Math.max(zoneGeo.collapsedWidth, headerDriven);
|
|
864
903
|
const ordered = orderedChildrenOf(id);
|
|
865
904
|
const headerHeight = headerHeightOf(id, floor);
|
|
866
905
|
if (kind === "legend-expanded") {
|
|
867
906
|
// A legend stays a single-column list of keys (DLR-341): exempt from packing.
|
|
868
907
|
outerWidths.set(id, floor);
|
|
869
908
|
const keys = ordered.length * LEGEND_KEY_HEIGHT + Math.max(0, ordered.length - 1) * gaps.cardGapY;
|
|
870
|
-
const size = { width: floor, height:
|
|
909
|
+
const size = { width: floor, height: zoneGeo.headerInset + headerHeight + contentInset + keys + contentInset };
|
|
871
910
|
packedSizes.set(id, size);
|
|
872
911
|
return size;
|
|
873
912
|
}
|
|
874
913
|
const run = buildLevelRun(id, ordered);
|
|
875
914
|
levelRuns.set(id, run);
|
|
876
|
-
const level = sizeRun(run, 2 * contentInset,
|
|
915
|
+
const level = sizeRun(run, 2 * contentInset, zoneGeo.headerInset + headerHeight + contentInset + contentInset);
|
|
877
916
|
// BF-6: reserve measured U-channel headroom for labelled edges on one
|
|
878
917
|
// shelf, including wrapped labels and parallel channels. This is
|
|
879
918
|
// container content below its children; sibling gutters keep their cap.
|
|
@@ -905,7 +944,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
905
944
|
outerWidths.set(id, outer);
|
|
906
945
|
const size = {
|
|
907
946
|
width: outer,
|
|
908
|
-
height:
|
|
947
|
+
height: zoneGeo.headerInset + headerHeight + contentInset + levelHeight + contentInset
|
|
909
948
|
+ sceneBoxAt(representativeOf(id), outer, false).footerReserve,
|
|
910
949
|
};
|
|
911
950
|
packedSizes.set(id, size);
|
|
@@ -927,7 +966,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
927
966
|
for (const id of headerIds) {
|
|
928
967
|
const kind = kinds.get(id);
|
|
929
968
|
const folded = kind === "container-collapsed" || kind === "legend-collapsed";
|
|
930
|
-
headerAt(id, folded ? innerWidthOf(
|
|
969
|
+
headerAt(id, folded ? innerWidthOf(packedSizes.get(id)?.width ?? cardWidthOf(representativeOf(id))) : innerWidthOf(outerWidths.get(id) ?? cardWidthOf(representativeOf(id))));
|
|
931
970
|
}
|
|
932
971
|
};
|
|
933
972
|
sizeAll();
|
|
@@ -943,11 +982,21 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
943
982
|
const occurrence = representativeOf(id);
|
|
944
983
|
if (presentation.entities[occurrence] !== undefined && size !== undefined) {
|
|
945
984
|
for (const diagnostic of sceneBoxAt(occurrence, size.width, isCollapsed(id)).diagnostics) {
|
|
946
|
-
if (diagnostic.reason !== "truncated")
|
|
985
|
+
if (diagnostic.reason !== "truncated" && diagnostic.reason !== "fallback-v1")
|
|
947
986
|
continue;
|
|
987
|
+
const isFallback = diagnostic.reason === "fallback-v1";
|
|
948
988
|
warnings.push({ code: kinds.get(id) === "leaf" ? "card-overflow" : "zone-overflow", severity: "info",
|
|
949
|
-
refs: [occurrence, diagnostic.slot],
|
|
950
|
-
|
|
989
|
+
refs: [occurrence, diagnostic.slot],
|
|
990
|
+
message: isFallback
|
|
991
|
+
? "compact anatomy overflow on " + diagnostic.slot + ": fell back to v1 frozen box"
|
|
992
|
+
: "truncated " + diagnostic.slot + ": " + diagnostic.hiddenLength + " hidden characters; full text in title/aria",
|
|
993
|
+
details: {
|
|
994
|
+
slot: diagnostic.slot,
|
|
995
|
+
reason: diagnostic.reason,
|
|
996
|
+
...(diagnostic.hiddenLength === undefined ? {} : { hiddenLength: diagnostic.hiddenLength }),
|
|
997
|
+
neededHeight: diagnostic.neededPx,
|
|
998
|
+
allocatedHeight: diagnostic.allocatedPx,
|
|
999
|
+
} });
|
|
951
1000
|
}
|
|
952
1001
|
}
|
|
953
1002
|
else
|
|
@@ -955,6 +1004,34 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
955
1004
|
warnOverflow(overflow, kinds.get(id) !== "leaf");
|
|
956
1005
|
}
|
|
957
1006
|
}
|
|
1007
|
+
if (options.reportSurfaceSame === true) {
|
|
1008
|
+
for (const id of headerIds) {
|
|
1009
|
+
const kind = kinds.get(id);
|
|
1010
|
+
if (kind !== "container-expanded" && kind !== "legend-expanded")
|
|
1011
|
+
continue;
|
|
1012
|
+
const zoneOcc = representativeOf(id);
|
|
1013
|
+
const zoneEntry = presentation.entities[zoneOcc];
|
|
1014
|
+
const zoneDepth = zoneEntry?.depth ?? graph.nodes.get(id)?.depth ?? 0;
|
|
1015
|
+
const surface = zoneDepthSurface(zoneDepth, zoneEntry?.depthParityStart);
|
|
1016
|
+
if (surface !== "surface1")
|
|
1017
|
+
continue;
|
|
1018
|
+
for (const childId of orderedChildrenOf(id)) {
|
|
1019
|
+
if (kinds.get(childId) !== "leaf")
|
|
1020
|
+
continue;
|
|
1021
|
+
const childOcc = representativeOf(childId);
|
|
1022
|
+
const childEntry = presentation.entities[childOcc];
|
|
1023
|
+
if (childEntry?.categoryRef !== undefined)
|
|
1024
|
+
continue;
|
|
1025
|
+
warnings.push({
|
|
1026
|
+
code: "zone-surface-same",
|
|
1027
|
+
severity: "info",
|
|
1028
|
+
refs: [zoneOcc, childOcc],
|
|
1029
|
+
message: `white leaf card ${childOcc} sits on same-colour surface1 zone ${zoneOcc}`,
|
|
1030
|
+
details: { zone: zoneOcc, card: childOcc, surface },
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
958
1035
|
// Seating: every run at its packed positions. The root is one more run
|
|
959
1036
|
// with zero chrome and the same token gaps — never `rankGap` (§3.5).
|
|
960
1037
|
const rects = new Map();
|
|
@@ -985,23 +1062,24 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
985
1062
|
return;
|
|
986
1063
|
}
|
|
987
1064
|
if (kind === "legend-key") {
|
|
988
|
-
rects.set(id, { x, y, width: innerWidthOf(
|
|
1065
|
+
rects.set(id, { x, y, width: innerWidthOf(legendKeyCardWidth(id)), height: LEGEND_KEY_HEIGHT });
|
|
989
1066
|
return;
|
|
990
1067
|
}
|
|
991
1068
|
const size = packedSizes.get(id);
|
|
992
1069
|
const header = headers.get(id);
|
|
1070
|
+
const zoneGeo = anatomyZoneGeometry(occurrenceAnatomy(representativeOf(id)));
|
|
993
1071
|
const inner = innerWidthOf(size.width);
|
|
994
1072
|
rects.set(id, { x, y, width: size.width, height: size.height });
|
|
995
|
-
const ruleClearance = (
|
|
996
|
-
titleBands.set(id, { x, y, width: size.width, height:
|
|
1073
|
+
const ruleClearance = (zoneGeo.ruleHeight / 2 + 1) / DEFAULT_MIN_READABLE_SCALE;
|
|
1074
|
+
titleBands.set(id, { x, y, width: size.width, height: zoneGeo.headerInset + header.height });
|
|
997
1075
|
const footerReserve = sceneBoxAt(representativeOf(id), size.width, false).footerReserve;
|
|
998
1076
|
if (footerReserve > 0)
|
|
999
1077
|
footerBands.set(id, {
|
|
1000
|
-
x, y: y + size.height - footerReserve -
|
|
1001
|
-
width: size.width, height: footerReserve +
|
|
1078
|
+
x, y: y + size.height - footerReserve - zoneGeo.borderWidth - ruleClearance,
|
|
1079
|
+
width: size.width, height: footerReserve + zoneGeo.borderWidth + ruleClearance,
|
|
1002
1080
|
});
|
|
1003
1081
|
const contentX = x + contentInset;
|
|
1004
|
-
const contentY = y +
|
|
1082
|
+
const contentY = y + zoneGeo.headerInset + header.height + contentInset;
|
|
1005
1083
|
if (kind === "legend-expanded") {
|
|
1006
1084
|
legendInner.set(id, inner);
|
|
1007
1085
|
orderedChildrenOf(id).forEach((key, index) => {
|
|
@@ -1055,7 +1133,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
1055
1133
|
const text = slotTexts(document, presentation, occurrence, id);
|
|
1056
1134
|
if (kind === "legend-key") {
|
|
1057
1135
|
const parent = graph.nodes.get(id)?.parent;
|
|
1058
|
-
const inner = parent !== undefined && legendInner.has(parent) ? legendInner.get(parent) : innerWidthOf(
|
|
1136
|
+
const inner = parent !== undefined && legendInner.has(parent) ? legendInner.get(parent) : innerWidthOf(legendKeyCardWidth(id));
|
|
1059
1137
|
recordSlot(occurrence, "legend-label", measure({
|
|
1060
1138
|
text: text.title ?? "",
|
|
1061
1139
|
role: "legend-label",
|
|
@@ -1066,7 +1144,7 @@ function layoutMeasuredPass(document, options, sourceView, forced) {
|
|
|
1066
1144
|
continue;
|
|
1067
1145
|
}
|
|
1068
1146
|
const expanded = kind === "container-expanded" || kind === "legend-expanded";
|
|
1069
|
-
const inner = expanded ? innerWidthOf(outerWidths.get(id) ??
|
|
1147
|
+
const inner = expanded ? innerWidthOf(outerWidths.get(id) ?? cardWidthOf(occurrence)) : innerWidthOf(cardWidthOf(occurrence));
|
|
1070
1148
|
const rendered = sceneBoxAt(occurrence, rects.get(id).width, !expanded && kind !== "leaf");
|
|
1071
1149
|
for (const role of ["body", "detail", "footer"]) {
|
|
1072
1150
|
if (text[role] === undefined)
|
|
@@ -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;
|