@sentropic/diagram-canvas 0.2.5 → 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.
@@ -23,6 +23,14 @@
23
23
  * 22 px kicker and the 32 px title at their own size (cf. the frozen SVG:
24
24
  * kicker baseline `headerY + 16 + 22`, title `+ 32`, subtitle `+ 22`).
25
25
  */
26
+ /**
27
+ * Versioned card anatomy (DE-1). `"v1"` is the frozen `460 × 200` box every
28
+ * existing view keeps; `"v2"` is the compact `352 × 154` default new views
29
+ * pin. A view pins one anatomy; geometry is selected per box, never patched
30
+ * in place. The engine default stays `"v1"` so unpinned views do not move;
31
+ * `createView` pins `"v2"` for genuinely new views.
32
+ */
33
+ export type DiagramAnatomy = "v1" | "v2";
26
34
  /** Frozen card geometry, in card pixels (spec §5.3, Appendix A). */
27
35
  export declare const CARD_GEOMETRY: {
28
36
  readonly width: 460;
@@ -100,6 +108,102 @@ export declare const CARD_GEOMETRY: {
100
108
  readonly footer: 1;
101
109
  };
102
110
  };
111
+ /**
112
+ * Compact card geometry (`diagram-anatomy/v2`): `352 × 154` with padding
113
+ * `6`, header inset `12`, accent `6`, icon `52` / gap `4`. Type scale is
114
+ * unchanged (`22 / 32 / 24`). Unlisted leaves keep their v1 values. Title is
115
+ * one line first (owner addendum 8): over-long titles report `card-overflow`
116
+ * instead of growing the box. The folded header width is derived, not
117
+ * pinned: `352 − border 2 − padding 6 − toggle 66 − headerText 68 = 210`.
118
+ */
119
+ export declare const CARD_GEOMETRY_V2: {
120
+ readonly width: 352;
121
+ readonly height: 154;
122
+ readonly padding: 6;
123
+ readonly accentWidth: 6;
124
+ readonly headerInset: 12;
125
+ readonly iconSize: 52;
126
+ readonly iconTextGap: 4;
127
+ readonly foldedHeaderTextWidth: 210;
128
+ /** Title on one line first (addendum 8); v1 keeps two lines. */
129
+ readonly allocatedLines: {
130
+ readonly kicker: 1;
131
+ readonly title: 1;
132
+ readonly body: 2;
133
+ readonly footer: 1;
134
+ };
135
+ readonly borderWidth: 2;
136
+ readonly kicker: {
137
+ readonly size: 22;
138
+ readonly weight: 400;
139
+ readonly lineHeight: 1.3;
140
+ readonly letterSpacingEm: 0.04;
141
+ };
142
+ readonly title: {
143
+ readonly size: 32;
144
+ readonly weight: 700;
145
+ readonly lineHeight: 1.3;
146
+ };
147
+ /** Header row → body block. */
148
+ readonly gap: 6;
149
+ readonly body: {
150
+ readonly size: 24;
151
+ readonly weight: 400;
152
+ readonly lineHeight: 1.3;
153
+ };
154
+ /**
155
+ * Edge-label text (BF-6): 18px so one line plus margins fits the 32px
156
+ * gutter cap (22 + 2 × 4 = 30 ≤ 32). Mirrors the
157
+ * `diagramScene.edgeLabelFontSize` / `edgeLabelLineHeight` tokens;
158
+ * additive, frozen card sizes unchanged.
159
+ */
160
+ readonly edgeLabel: {
161
+ readonly size: 18;
162
+ readonly weight: 400;
163
+ readonly lineHeight: number;
164
+ };
165
+ /** Accent-bar left edge → first body glyph. */
166
+ readonly bodyInsetFromBar: 14;
167
+ readonly ruleHeight: 1;
168
+ readonly ruleMargin: 4;
169
+ readonly ruleInsetStart: 16;
170
+ readonly ruleInsetEnd: 10;
171
+ readonly footer: {
172
+ readonly size: 24;
173
+ readonly weight: 700;
174
+ readonly lineHeight: 1.3;
175
+ };
176
+ /** Footer text-box bottom → inner edge of the bottom border. */
177
+ readonly footerBottomInset: 9.25;
178
+ /**
179
+ * Title/kicker width reservation when the toggle slot is present
180
+ * (hrpn tints.css `header { padding-right: 66px }`: the 66 px the +/−
181
+ * control needs in the header's inline-end).
182
+ */
183
+ readonly toggleAllocation: 66;
184
+ /** The toggle slot box itself: the 32 px DS IconButton (sm) square. */
185
+ readonly toggleBoxSize: 32;
186
+ readonly toggleInset: 8;
187
+ };
188
+ /** Select the card geometry for a pinned anatomy (default `"v1"`). */
189
+ export declare function anatomyCardGeometry(anatomy: DiagramAnatomy | undefined): typeof CARD_GEOMETRY | typeof CARD_GEOMETRY_V2;
190
+ /**
191
+ * Additive per-entity pin carried alongside a governed `EntityPresentation`
192
+ * (structural, never persisted in the governed fragment): the pinned
193
+ * `diagram-anatomy/v1 | v2` for this box. Absent means `"v1"`.
194
+ */
195
+ export interface AnatomyPinned {
196
+ readonly anatomy?: DiagramAnatomy;
197
+ }
198
+ /**
199
+ * Additive alignment pin (DE-1 step 2), same carrying pattern as
200
+ * `AnatomyPinned`: structural, never persisted in the governed fragment.
201
+ * `"left"` keeps the frozen behaviour; `"center"` centres title and body
202
+ * on both axes. Absent means `"left"`.
203
+ */
204
+ export interface AlignPinned {
205
+ readonly align?: "left" | "center";
206
+ }
103
207
  /**
104
208
  * Edge label typography (DC-2a, tokens `diagramScene.edgeLabelFontSize` /
105
209
  * `diagramScene.edgeLabelLineHeight`): 18 px on a 22 px line box. One line
@@ -139,6 +243,16 @@ export interface CardPresentationInput {
139
243
  readonly categoryRef?: string;
140
244
  /** Neutral status prop: drawn as a dashed border, independent of tint. */
141
245
  readonly proposed?: boolean;
246
+ /**
247
+ * Pinned card anatomy (`diagram-anatomy/v1 | v2`). Absent means `"v1"`;
248
+ * a view pins `"v2"` for the compact box.
249
+ */
250
+ readonly anatomy?: DiagramAnatomy;
251
+ /**
252
+ * Additive alignment pin (DE-1 step 2, `AnatomyPinned` pattern):
253
+ * `"center"` centres title and body on both axes. Absent means `"left"`.
254
+ */
255
+ readonly align?: "left" | "center";
142
256
  }
143
257
  /** Resolved glyph path data (structural twin of the `diagram-icons`
144
258
  * registry record — no import so the barrel never resolves that graph). */
@@ -148,7 +262,7 @@ export interface DiagramGlyphPaths {
148
262
  readonly darkLine?: true;
149
263
  readonly text?: string;
150
264
  readonly severity?: "info";
151
- readonly reason?: "truncated";
265
+ readonly reason?: "truncated" | "fallback-v1";
152
266
  readonly hiddenLength?: number;
153
267
  }
154
268
  export interface DiagramCardToggle {
@@ -197,6 +311,17 @@ export interface DiagramCardProps {
197
311
  * area (§6.2.1).
198
312
  */
199
313
  readonly bodyMode?: "leaf" | "subtitle";
314
+ /**
315
+ * Pinned card anatomy (`diagram-anatomy/v1 | v2`). Absent means `"v1"`;
316
+ * `"v2"` selects the compact `352 × 154` box.
317
+ */
318
+ readonly anatomy?: DiagramAnatomy;
319
+ /**
320
+ * Zone depth surface, set only for zone-collapsed cards (a folded zone
321
+ * keeps its depth background). Leaf cards never set it: their semantic
322
+ * tints are unchanged. Hosts paint the matching zone surface token.
323
+ */
324
+ readonly surface?: ZoneDepthSurface;
200
325
  }
201
326
  export type CardResolveResult = {
202
327
  readonly kind: "card";
@@ -208,6 +333,16 @@ export interface ProjectCardOptions {
208
333
  readonly entityId: string;
209
334
  readonly toggle?: DiagramCardToggle;
210
335
  readonly resolveGlyph?: (name: string) => DiagramGlyphPaths | undefined;
336
+ /**
337
+ * Fallback anatomy when the presentation pins none. Absent means `"v1"`;
338
+ * scene entry points for new views pass `"v2"`.
339
+ */
340
+ readonly anatomy?: DiagramAnatomy;
341
+ /**
342
+ * Fallback alignment when the presentation pins none. Absent means
343
+ * `"left"`; centred scenes pass `"center"`.
344
+ */
345
+ readonly align?: "left" | "center";
211
346
  }
212
347
  /**
213
348
  * Shared `EntityPresentation` → props projection (§4.2), consumed by both
@@ -311,7 +446,7 @@ export interface CardDiagnostic {
311
446
  */
312
447
  readonly text?: string;
313
448
  readonly severity?: "info";
314
- readonly reason?: "truncated";
449
+ readonly reason?: "truncated" | "fallback-v1";
315
450
  readonly hiddenLength?: number;
316
451
  }
317
452
  /** First content diagnostic, for reporting only; renderers retain every slot. */
@@ -344,6 +479,8 @@ export declare function headerSlotGeometry(opts: {
344
479
  readonly hasIcon: boolean;
345
480
  readonly kickerLines: number;
346
481
  readonly titleLines: number;
482
+ /** Icon floor for the block height; defaults to the v1 `70`. */
483
+ readonly iconSize?: number;
347
484
  }): HeaderSlotGeometry;
348
485
  /** Fixed-slot truncation shared by cards and zones (owner A14). */
349
486
  export declare function truncateSlot(text: string, role: "kicker" | "title" | "body" | "footer", width: number, budget: number, measure: CardLineMeasure, report: (diagnostic: {
@@ -414,12 +551,16 @@ export interface CardLayout {
414
551
  readonly y: number;
415
552
  readonly size: number;
416
553
  };
554
+ /** Present when a `v2` compact card overflowed and fell back per box to frozen `v1` (`460 × 200`). */
555
+ readonly anatomyFallback?: "v1";
417
556
  readonly diagnostics: readonly CardDiagnostic[];
418
557
  }
419
558
  /**
420
559
  * Lay out fixed card slots with measured ellipses and a pinned footer.
421
560
  * Informational diagnostics retain the original text and hidden length.
422
561
  * Missing glyphs use the visible unknown icon (owner A2/A11).
562
+ * Compact `v2` cards default to `"center"` alignment and fall back per box
563
+ * to frozen `v1` (`460 × 200`) on overflow instead of dropping slots.
423
564
  */
424
565
  export declare function layoutCard(props: DiagramCardProps, measure: CardLineMeasure): CardLayout;
425
566
  /**
@@ -496,6 +637,90 @@ export declare const ZONE_GEOMETRY: {
496
637
  readonly footer: 1;
497
638
  };
498
639
  };
640
+ /**
641
+ * Compact zone geometry (`diagram-anatomy/v2`): the collapsed zone IS the
642
+ * compact card (`352 × 154`, collapsed subtitle measure `352 − 2 × 32`);
643
+ * expanded chrome follows the compact insets (header `12`, icon `52`,
644
+ * gap `4`). Unlisted leaves keep v1 values; type scale unchanged.
645
+ */
646
+ export declare const ZONE_GEOMETRY_V2: {
647
+ readonly headerInset: 12;
648
+ readonly iconSize: 52;
649
+ readonly iconTextGap: 4;
650
+ /**
651
+ * Expanded header text inset for v2: `12 + 52 + 4 + 86 = 154` so the
652
+ * inline-end toggle reserve stays `86 px` (matching v1) instead of
653
+ * growing to `110 px`.
654
+ */
655
+ readonly headerTextInset: 154;
656
+ readonly collapsedWidth: 352;
657
+ readonly collapsedHeight: 154;
658
+ readonly allocatedLines: {
659
+ readonly kicker: 1;
660
+ readonly title: 1;
661
+ readonly subtitle: 2;
662
+ readonly footer: 1;
663
+ };
664
+ readonly radius: 0;
665
+ readonly borderWidth: 1.5;
666
+ readonly kicker: {
667
+ readonly size: 22;
668
+ readonly weight: 400;
669
+ readonly lineHeight: 1.3;
670
+ readonly letterSpacingEm: 0.04;
671
+ };
672
+ readonly title: {
673
+ readonly size: 32;
674
+ readonly weight: 700;
675
+ readonly lineHeight: 1.3;
676
+ };
677
+ readonly subtitle: {
678
+ readonly size: 24;
679
+ readonly weight: 400;
680
+ readonly lineHeight: 1.3;
681
+ };
682
+ /** Rendered title → subtitle gap: alias of the card `gap` (§6.4). */
683
+ readonly subtitleGap: 6;
684
+ readonly headerRuleGap: 4;
685
+ readonly contentInsetTop: 16;
686
+ readonly contentInsetBottom: 16;
687
+ readonly contentInsetInline: 16;
688
+ readonly ruleHeight: 1;
689
+ readonly ruleMargin: 4;
690
+ readonly ruleInsetStart: 16;
691
+ readonly ruleInsetEnd: 10;
692
+ readonly footer: {
693
+ readonly size: 24;
694
+ readonly weight: 700;
695
+ readonly lineHeight: 1.3;
696
+ };
697
+ readonly footerBottomInset: 9.25;
698
+ readonly toggleAllocation: 66;
699
+ readonly toggleBoxSize: 32;
700
+ /**
701
+ * Expanded toggle top inset: the frozen SVG places every zone toggle at
702
+ * `y + 10` (flush under the frame's top edge), while the header band
703
+ * starts at `y + 16`.
704
+ */
705
+ readonly toggleTopInset: 8;
706
+ readonly toggleInset: 8;
707
+ readonly collapsedInset: 16;
708
+ readonly collapsedSubtitleMarginInline: 16;
709
+ };
710
+ /** Select the zone geometry for a pinned anatomy (default `"v1"`). */
711
+ export declare function anatomyZoneGeometry(anatomy: DiagramAnatomy | undefined): typeof ZONE_GEOMETRY | typeof ZONE_GEOMETRY_V2;
712
+ /**
713
+ * Owner addendum 1 — one engine rule for alternating zone backgrounds by
714
+ * nesting depth. Even depths (top level first) paint `surface1`, odd depths
715
+ * paint `surface2`; `startParity` is selectable per scene and flips which
716
+ * parity the top level takes. Depth normalises to a non-negative integer;
717
+ * card semantic tints are untouched (leaf cards never read this rule).
718
+ */
719
+ export type ZoneDepthSurface = "surface1" | "surface2";
720
+ /** Nesting depth of a zone: `0` is the top level. */
721
+ export declare function normalizeZoneDepth(depth: number | undefined): number;
722
+ /** Resolve the depth surface for a zone (default start parity `0`). */
723
+ export declare function zoneDepthSurface(depth: number | undefined, startParity?: 0 | 1): ZoneDepthSurface;
499
724
  /** Centred collapsed-subtitle measure (§6.2.1): 460 − 2 × (16 + 16). */
500
725
  export declare const COLLAPSED_SUBTITLE_MEASURE: number;
501
726
  export interface DiagramZoneToggle {
@@ -506,6 +731,11 @@ export interface DiagramZoneToggle {
506
731
  export interface DiagramZoneProps {
507
732
  readonly containerPadding?: number;
508
733
  readonly autoSize?: boolean;
734
+ /**
735
+ * Pinned zone anatomy (`diagram-anatomy/v1 | v2`). Absent means `"v1"`;
736
+ * `"v2"` selects the compact collapsed `352 × 154` box.
737
+ */
738
+ readonly anatomy?: DiagramAnatomy;
509
739
  readonly entityId: string;
510
740
  readonly kicker?: string;
511
741
  readonly title: string;
@@ -524,6 +754,23 @@ export interface DiagramZoneProps {
524
754
  readonly toggleLabel?: string;
525
755
  /** Owner variant: `"center"` centres every text slot, both states. */
526
756
  readonly align?: "left" | "center";
757
+ /**
758
+ * Nesting depth of the zone (owner addendum 1): `0` is the top level.
759
+ * The frame — and the folded card — paint the depth surface from the
760
+ * engine rule. Absent means `0`.
761
+ */
762
+ readonly depth?: number;
763
+ /**
764
+ * Opt-in informational diagnostic (owner addendum 1): when true, a leaf
765
+ * card on a same-colour zone surface reports `zone-surface-same`. Off by
766
+ * default — a fitting child renders with no diagnostics.
767
+ */
768
+ readonly reportSurfaceSame?: boolean;
769
+ /**
770
+ * Selectable start parity for the depth rule: `1` flips which parity the
771
+ * top level takes. Scene-global; absent means `0`.
772
+ */
773
+ readonly depthParityStart?: 0 | 1;
527
774
  /**
528
775
  * Occurrence box supplied by the host layout (§6.1: the component paints
529
776
  * around the box it is given). Collapsed, the box is the frozen
@@ -546,8 +793,11 @@ export interface ZoneDiagnostic {
546
793
  * `zone-overflow` / `zone-icon-unknown` are the zone's own; a descendant
547
794
  * card or nested zone keeps its own `card-overflow` / `card-icon-unknown`
548
795
  * code with its own `entityId` when `renderZoneSvg` aggregates them.
796
+ * `zone-surface-same` is informational and opt-in (owner addendum 1):
797
+ * a leaf card on a same-colour zone, reported only for explicitly
798
+ * composed children when the zone sets `reportSurfaceSame`.
549
799
  */
550
- readonly code: "zone-overflow" | "zone-icon-unknown" | "card-icon-missing" | "zone-grown" | "card-overflow" | "card-icon-unknown" | "card-grown";
800
+ readonly code: "zone-overflow" | "zone-icon-unknown" | "card-icon-missing" | "zone-grown" | "card-overflow" | "card-icon-unknown" | "card-grown" | "zone-surface-same";
551
801
  readonly slot: string;
552
802
  readonly entityId: string;
553
803
  readonly neededPx: number;
@@ -555,7 +805,7 @@ export interface ZoneDiagnostic {
555
805
  /** Original, unwrapped slot text retained with the diagnostic. */
556
806
  readonly text?: string;
557
807
  readonly severity?: "info";
558
- readonly reason?: "truncated";
808
+ readonly reason?: "truncated" | "fallback-v1";
559
809
  readonly hiddenLength?: number;
560
810
  }
561
811
  export interface ZoneChildSpec {
@@ -578,6 +828,14 @@ export interface ZoneLayout {
578
828
  readonly height: number;
579
829
  };
580
830
  readonly collapsed: boolean;
831
+ /**
832
+ * Owner addendum 1: resolved depth surface (`surface1` at even depths,
833
+ * top level first) and normalised depth. Present only when depth pins
834
+ * are threaded (absent means `surface1` / `0`); hosts paint the matching
835
+ * zone surface token on the frame and on the folded card.
836
+ */
837
+ readonly surface?: ZoneDepthSurface;
838
+ readonly depth?: number;
581
839
  /** Collapsed: the card layout of the folded card (same geometry source). */
582
840
  readonly card?: CardLayout;
583
841
  /** Expanded: header + rule + footer geometry inside the frame. */
@@ -636,6 +894,32 @@ export interface ZonePresentationInput {
636
894
  readonly categoryRef?: string;
637
895
  /** Neutral status prop: drawn as a dashed border, independent of tint. */
638
896
  readonly proposed?: boolean;
897
+ /**
898
+ * Pinned zone anatomy (`diagram-anatomy/v1 | v2`). Absent means `"v1"`.
899
+ */
900
+ readonly anatomy?: DiagramAnatomy;
901
+ /**
902
+ * Additive alignment pin (DE-1 step 2, `AnatomyPinned` pattern):
903
+ * `"center"` centres title and body on both axes. Absent means `"left"`.
904
+ */
905
+ readonly align?: "left" | "center";
906
+ /**
907
+ * Additive depth pins (owner addendum 1, `AnatomyPinned` pattern):
908
+ * nesting depth (`0` top) and selectable start parity. Absent means
909
+ * `0` / `0`; the scene stamps depth from the view groups.
910
+ */
911
+ readonly depth?: number;
912
+ readonly depthParityStart?: 0 | 1;
913
+ }
914
+ /**
915
+ * Additive depth pins (owner addendum 1), same carrying pattern as
916
+ * `AnatomyPinned`: structural, never persisted in the governed fragment.
917
+ * The scene stamps `depth` from the view groups; `depthParityStart`
918
+ * selects which parity the top level takes.
919
+ */
920
+ export interface DepthPinned {
921
+ readonly depth?: number;
922
+ readonly depthParityStart?: 0 | 1;
639
923
  }
640
924
  export type ZoneResolveResult = {
641
925
  readonly kind: "zone";
@@ -645,10 +929,21 @@ export type ZoneResolveResult = {
645
929
  };
646
930
  export interface ProjectZoneOptions {
647
931
  readonly containerPadding?: number;
932
+ /**
933
+ * Fallback anatomy when the presentation pins none. Absent means `"v1"`;
934
+ * scene entry points for new views pass `"v2"`.
935
+ */
936
+ readonly anatomy?: DiagramAnatomy;
648
937
  readonly entityId: string;
649
938
  readonly collapsed: boolean;
650
939
  readonly toggleLabel?: string;
651
940
  readonly align?: "left" | "center";
941
+ /**
942
+ * Fallback depth pins when the presentation pins none. Absent means
943
+ * `0` / `0`; the scene stamps them from the view groups.
944
+ */
945
+ readonly depth?: number;
946
+ readonly depthParityStart?: 0 | 1;
652
947
  readonly x?: number;
653
948
  readonly y?: number;
654
949
  readonly width?: number;