@sentropic/design-system-svelte 0.44.0 → 0.45.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.
@@ -25,16 +25,16 @@ sources à l'amont installé : il ne peut pas se désynchroniser en silence.
25
25
 
26
26
  **Ce qui est copié.** Des chaînes de tracé SVG (attribut `d`) identiques octet pour octet aux données d'icônes lucide, écrites directement dans nos fichiers source et compilées dans le `dist/` publié.
27
27
 
28
- **Étendue mesurée.** 21 chaîne(s) de tracé distincte(s),
29
- 24 occurrence(s), dans 2 fichier(s) source de ce paquet :
28
+ **Étendue mesurée.** 29 chaîne(s) de tracé distincte(s),
29
+ 32 occurrence(s), dans 2 fichier(s) source de ce paquet :
30
30
 
31
31
  | Fichier source | Occurrences |
32
32
  |---|---|
33
33
  | `src/lib/cellDecoration.ts` | 21 |
34
- | `src/lib/flow-fixtures/before.html` | 3 |
34
+ | `src/lib/flow-fixtures/before.html` | 11 |
35
35
 
36
36
  Glyphes amont concernés (une chaîne partagée par plusieurs glyphes les nomme tous) :
37
- `arrow-down`, `arrow-right`, `arrow-up`, `badge-percent`, `barcode`, `check`, `circle-check-big`, `circle-percent`, `circle-question-mark`, `circle-x`, `cloud-snow`, `file-exclamation-point`, `file-question-mark`, `flame`, `house-wifi`, `info`, `message-circle-question-mark`, `message-circle-x`, `minus`, `octagon-x`, `plus`, `shield-question-mark`, `square-check-big`, `square-percent`, `square-x`, `ticket-percent`, `trending-down`, `trending-up`, `triangle-alert`, `x`.
37
+ `arrow-down`, `arrow-right`, `arrow-up`, `badge-percent`, `barcode`, `check`, `circle-check-big`, `circle-percent`, `circle-question-mark`, `circle-x`, `cloud-snow`, `external-link`, `file-exclamation-point`, `file-question-mark`, `flame`, `focus`, `fullscreen`, `house-wifi`, `info`, `maximize-2`, `message-circle-question-mark`, `message-circle-x`, `minimize-2`, `minus`, `octagon-x`, `plus`, `scan`, `scan-barcode`, `scan-eye`, `scan-face`, `scan-heart`, `scan-line`, `scan-qr-code`, `scan-search`, `scan-text`, `shield-question-mark`, `square-arrow-out-down-left`, `square-arrow-out-up-right`, `square-check-big`, `square-percent`, `square-x`, `ticket-percent`, `trending-down`, `trending-up`, `triangle-alert`, `x`.
38
38
 
39
39
  **Pourquoi c'est une redistribution.** Le jeu d'icônes du design system est lucide : `packages/components-angular/src/Icon.ts` le dit explicitement (« the same lucide (stroke-24) path data the other frameworks wrap — the single visual source of truth »). Inliner les données plutôt que dépendre du paquet ne supprime pas l'obligation : cela la déplace du `node_modules` du consommateur vers notre propre tarball. Le port Angular ne déclare aucune dépendance lucide et n'embarque que des copies ; les ports React, Vue et Svelte dépendent du paquet lucide ET en recopient une partie.
40
40
 
@@ -1,11 +1,12 @@
1
1
  <script lang="ts">
2
2
  import { getDiagramGlyph } from "./diagram-icons/registry.js";
3
3
  import { tick, untrack } from "svelte";
4
- import { Minus, Plus } from "@lucide/svelte";
4
+ import { Maximize2, Minimize2, Minus, Plus, Scan } from "@lucide/svelte";
5
5
  import {
6
6
  renderErdCardSvg, renderErdTable,
7
7
  clampZoom,
8
8
  createLayoutCache,
9
+ DEFAULT_MIN_READABLE_SCALE,
9
10
  FIT_ASPECT,
10
11
  isR7ConnectorPresentation,
11
12
  zoomReadout,
@@ -21,7 +22,7 @@
21
22
  import DiagramCard from "./DiagramCard.svelte";
22
23
  import DiagramZone from "./DiagramZone.svelte";
23
24
  import IconButton from "./IconButton.svelte";
24
- import { measureRenderedBounds, shouldRefitRenderedBounds } from "./diagramRenderedBounds.js";
25
+ import { committedWorldScale, measureRenderedBounds, shouldRefitRenderedBounds } from "./diagramRenderedBounds.js";
25
26
  import { measureRenderedSceneFont } from "./diagramFontMeasure.js";
26
27
  import Select from "./Select.svelte";
27
28
  import { DEFAULT_FLOW_TOKENS, type FlowTokens } from "@sentropic/diagram-canvas";
@@ -130,6 +131,10 @@
130
131
  zoomOut: string;
131
132
  /** Visible text of the fit / reset control (« Ajuster »). */
132
133
  fit: string;
134
+ /** Visible text of the whole-scene fit control (« Tout voir »). */
135
+ viewAll?: string;
136
+ /** Accessible name of the fullscreen control (« Plein écran »). */
137
+ fullscreen?: string;
133
138
  /** Accessible name of the readout, e.g. « Zoom 85 % ». */
134
139
  zoomLevel: (percent: number) => string;
135
140
  /** Accessible name of the scrollable drawing region. */
@@ -212,7 +217,7 @@
212
217
  onSizeChange?: (size: DiagramSceneSize) => void;
213
218
  }
214
219
 
215
- const DEFAULT_LABELS: DiagramSceneFigureLabels = DEFAULT_SCENE_LABELS;
220
+ const DEFAULT_LABELS = DEFAULT_SCENE_LABELS;
216
221
 
217
222
  const TOKEN_MAX_DISPLAY_SCALE = "--st-component-diagramScene-maxDisplayScale";
218
223
  const TOKEN_MIN_READABLE_SCALE = "--st-component-diagramScene-minReadableScale";
@@ -360,6 +365,9 @@
360
365
  measureLines: lineMeasurer,
361
366
  collapsed: collapsedNow,
362
367
  ...(hints === undefined ? {} : { hints }),
368
+ ...(legend === undefined ? {} : { legend }),
369
+ ...(strings.legend === undefined ? {} : { legendTitle: strings.legend }),
370
+ ...(legendLabels === undefined ? {} : { legendLabels }),
363
371
  metrics: effectiveMetrics,
364
372
  ...(rowPack === undefined ? {} : { rowPack }),
365
373
  ...(targetWidth === undefined ? {} : { targetWidth }),
@@ -373,14 +381,34 @@
373
381
 
374
382
  let viewWidth = $state<number>();
375
383
  let windowHeight = $state<number>();
384
+ let measuredFrameHeight = $state<number>();
385
+ let controlsHeight = $state(0);
376
386
  let scrollbarHeight = $state(0);
377
387
  let maxDisplayScale = $state<number>();
378
388
  let minReadableScale = $state<number>();
389
+ let viewAll = $state(false);
390
+ let nativeFullscreen = $state(false);
391
+ let fallbackFullscreen = $state(false);
392
+ const fullscreen = $derived(nativeFullscreen || fallbackFullscreen);
393
+ const fullscreenMode = $derived<"native" | "fallback" | undefined>(
394
+ nativeFullscreen ? "native" : fallbackFullscreen ? "fallback" : undefined,
395
+ );
396
+ const fullscreenViewHeight = $derived(
397
+ fullscreen
398
+ ? measuredFrameHeight !== undefined && measuredFrameHeight > 0
399
+ ? measuredFrameHeight
400
+ : windowHeight !== undefined
401
+ ? Math.max(0, windowHeight - controlsHeight)
402
+ : undefined
403
+ : undefined,
404
+ );
379
405
  const sceneFitInput = $derived({
380
406
  // Before the frame is measured (server render, hidden mount) the fit
381
407
  // box is the nominal 16:9 box of the layout target width.
382
408
  viewWidth: frameWidth ?? targetWidth ?? DEFAULT_SCENE_TARGET_WIDTH,
383
409
  windowHeight: windowHeight ?? Number.POSITIVE_INFINITY,
410
+ ...(fullscreenViewHeight === undefined ? {} : { viewHeight: fullscreenViewHeight }),
411
+ ...(viewAll ? { unconstrained: true } : {}),
384
412
  ...(maxDisplayScale === undefined ? {} : { maxDisplayScale }),
385
413
  ...(minReadableScale === undefined ? {} : { minReadableScale }),
386
414
  ...(fitToWindow ? { fitToWindow: true } : {}),
@@ -579,6 +607,8 @@
579
607
 
580
608
  /* ── measured frame and tokens (client only) ───────────────────── */
581
609
 
610
+ let figureEl = $state<HTMLElement>();
611
+ let controlsEl = $state<HTMLElement>();
582
612
  let frameEl = $state<HTMLElement>();
583
613
  let viewportEl = $state<HTMLElement>();
584
614
  $effect(() => {
@@ -588,22 +618,25 @@
588
618
  if (select !== undefined && select !== null) select.value = filter === undefined ? "all" : `scenario:${filter}`;
589
619
  }
590
620
  });
591
- let renderedBounds = $state.raw<{ scene: SceneModel; bounds: Rect }>();
621
+ let renderedBounds = $state.raw<{ scene: SceneModel; bounds: Rect; scale: number }>();
592
622
  const cameraBounds = $derived(renderedBounds?.scene === scene ? renderedBounds?.bounds : scene?.bounds);
593
623
  // `zoom` is the scale the world is painted at: the fit is quantised once,
594
624
  // in `sceneFit`, and printed as it is, so painted rects divide back by it.
595
625
  // The first read of a scene fits; a later one refits only when it differs
596
- // from that read by more than the measurement granularity. A read that
597
- // comes back as the model bounds is a read like any other: it replaces an
598
- // earlier, larger one, and the next one is compared to it.
599
- // A fold transition paints interpolated rectangles and fading layers: no
600
- // read happens while it runs, one happens when it settles.
626
+ // from that read by more than the measurement granularity at the minimum
627
+ // scale of the two reads. A read that comes back as the model bounds is a
628
+ // read like any other: it replaces an earlier, larger one, and the next one
629
+ // is compared to it. A fold transition paints interpolated rectangles and
630
+ // fading layers: no read happens while it runs, one happens when it settles.
601
631
  function readRenderedBounds(): void {
602
632
  if (frameEl === undefined || scene === undefined || animating) return;
603
- const bounds = measureRenderedBounds(frameEl, scene.bounds, zoom);
604
- const previous = renderedBounds?.scene === scene ? renderedBounds.bounds : undefined;
605
- if (bounds === undefined || !shouldRefitRenderedBounds(previous, bounds)) return;
606
- renderedBounds = { scene, bounds };
633
+ const readScale = committedWorldScale(frameEl, zoom);
634
+ const strokeFloor = Math.min(DEFAULT_MIN_READABLE_SCALE, fit.minZoom, readScale);
635
+ const bounds = measureRenderedBounds(frameEl, scene.bounds, zoom, strokeFloor);
636
+ const previous = renderedBounds?.scene === scene ? renderedBounds : undefined;
637
+ const toleranceScale = previous === undefined ? readScale : Math.min(previous.scale, readScale);
638
+ if (bounds === undefined || !shouldRefitRenderedBounds(previous?.bounds, bounds, toleranceScale)) return;
639
+ renderedBounds = { scene, bounds, scale: readScale };
607
640
  }
608
641
  $effect(() => {
609
642
  const current = scene;
@@ -622,21 +655,27 @@
622
655
  return () => { active = false; };
623
656
  });
624
657
 
625
- function tokenValue(name: string): string | undefined {
658
+ function tokenValue(name: string, style?: CSSStyleDeclaration): string | undefined {
626
659
  if (frameEl === undefined) return undefined;
627
- const value = getComputedStyle(frameEl).getPropertyValue(name).trim();
660
+ const value = (style ?? getComputedStyle(frameEl)).getPropertyValue(name).trim();
628
661
  return value === "" ? undefined : value;
629
662
  }
630
663
 
631
- function lengthTokenValue(name: string): number | undefined {
664
+ function lengthTokenValue(
665
+ name: string,
666
+ style?: CSSStyleDeclaration,
667
+ context?: { readonly rootFontSize?: number; readonly elementFontSize?: number },
668
+ ): number | undefined {
632
669
  if (frameEl === undefined) return undefined;
633
- const raw = tokenValue(name);
670
+ const raw = tokenValue(name, style);
634
671
  if (raw === undefined) return undefined;
635
- const docEl = frameEl.ownerDocument?.documentElement;
636
- const rootFontSize = docEl ? parseFloat(getComputedStyle(docEl).fontSize) : Number.NaN;
637
- const elementFontSize = parseFloat(getComputedStyle(frameEl).fontSize);
638
- const context = { rootFontSize, elementFontSize };
639
- const parsed = parseCssLengthPx(raw, context);
672
+ const resolvedContext = context ?? (() => {
673
+ const docEl = frameEl.ownerDocument?.documentElement;
674
+ const rootFontSize = docEl ? parseFloat(getComputedStyle(docEl).fontSize) : Number.NaN;
675
+ const elementFontSize = parseFloat((style ?? getComputedStyle(frameEl)).fontSize);
676
+ return { rootFontSize, elementFontSize };
677
+ })();
678
+ const parsed = parseCssLengthPx(raw, resolvedContext);
640
679
  if (parsed !== undefined || !/^(calc|min|max|clamp)\(/i.test(raw)) return parsed;
641
680
  const probe = frameEl.ownerDocument.createElement("span");
642
681
  probe.style.cssText = "position:absolute;visibility:hidden;pointer-events:none";
@@ -644,7 +683,7 @@
644
683
  if (probe.style.fontSize === "") return undefined;
645
684
  frameEl.appendChild(probe);
646
685
  try {
647
- return parseCssLengthPx(getComputedStyle(probe).fontSize, context);
686
+ return parseCssLengthPx(getComputedStyle(probe).fontSize, resolvedContext);
648
687
  } finally {
649
688
  probe.remove();
650
689
  }
@@ -683,23 +722,28 @@
683
722
  // m3: camera tokens are re-read on every measure and before every camera
684
723
  // input, so a post-mount theme change applies without waiting for a resize.
685
724
  function readCameraTokens(): void {
725
+ const style = frameEl === undefined ? undefined : getComputedStyle(frameEl);
686
726
  const values: Record<string, number> = {};
687
727
  const baseKeys = ["gapMin","gapMinBlock","gapBase","gapBaseBlock","trackSpacing","trackSpacingBlock","labelBand","gapMax","bundleLabelMaxWidth","containerPadding"];
688
728
  const r7Keys = ["zoneGutter","routeSpacing","routeBorderClearance","edgeCornerRadius","linkStrokeWidth","linkRelatedStrokeWidth","linkEmphasisStrokeWidth"];
689
729
  for (const key of baseKeys) {
690
- const value = parseFloat(tokenValue("--st-component-diagramScene-" + key) ?? "");
730
+ const value = parseFloat(tokenValue("--st-component-diagramScene-" + key, style) ?? "");
691
731
  if (Number.isFinite(value)) values[key] = value;
692
732
  }
693
- const labelMargin = parseFloat(tokenValue("--st-component-diagramScene-labelPadding") ?? "");
733
+ const labelMargin = parseFloat(tokenValue("--st-component-diagramScene-labelPadding", style) ?? "");
694
734
  if (Number.isFinite(labelMargin)) values.labelMargin = labelMargin;
695
- if (r7Mode) {
735
+ if (r7Mode && frameEl !== undefined) {
736
+ const docEl = frameEl.ownerDocument?.documentElement;
737
+ const rootFontSize = docEl ? parseFloat(getComputedStyle(docEl).fontSize) : Number.NaN;
738
+ const elementFontSize = parseFloat((style ?? getComputedStyle(frameEl)).fontSize);
739
+ const lengthContext = { rootFontSize, elementFontSize };
696
740
  for (const key of r7Keys) {
697
- const value = lengthTokenValue("--st-component-diagramScene-" + key);
741
+ const value = lengthTokenValue("--st-component-diagramScene-" + key, style, lengthContext);
698
742
  if (value !== undefined && Number.isFinite(value)) values[key] = value;
699
743
  }
700
744
  const edgeLabelSize = resolveEdgeLabelSizeToken(
701
- lengthTokenValue("--st-component-diagramScene-edgeLabelSize"),
702
- lengthTokenValue("--st-component-diagramScene-edgeLabelFontSize"),
745
+ lengthTokenValue("--st-component-diagramScene-edgeLabelSize", style, lengthContext),
746
+ lengthTokenValue("--st-component-diagramScene-edgeLabelFontSize", style, lengthContext),
703
747
  );
704
748
  if (edgeLabelSize !== undefined) values.edgeLabelSize = edgeLabelSize;
705
749
  }
@@ -710,13 +754,13 @@
710
754
  }
711
755
  const nextTokens = { ...DEFAULT_FLOW_TOKENS };
712
756
  for (const name of Object.keys(nextTokens) as (keyof FlowTokens)[]) {
713
- const value = tokenValue(`--st-component-diagramScene-${name}`);
757
+ const value = tokenValue(`--st-component-diagramScene-${name}`, style);
714
758
  if (name === "flowArrowPath") { if (value?.trim()) nextTokens.flowArrowPath = value.trim(); }
715
759
  else { const number = parseScale(value); if (number !== undefined) (nextTokens as unknown as Record<string, number>)[name] = number; }
716
760
  }
717
761
  if (JSON.stringify(nextTokens) !== JSON.stringify(flowTokens)) flowTokens = nextTokens;
718
- maxDisplayScale = parseScale(tokenValue(TOKEN_MAX_DISPLAY_SCALE));
719
- minReadableScale = parseScale(tokenValue(TOKEN_MIN_READABLE_SCALE));
762
+ maxDisplayScale = parseScale(tokenValue(TOKEN_MAX_DISPLAY_SCALE, style));
763
+ minReadableScale = parseScale(tokenValue(TOKEN_MIN_READABLE_SCALE, style));
720
764
  }
721
765
 
722
766
  $effect(() => {
@@ -729,7 +773,12 @@
729
773
 
730
774
  function measureFrame(resize = false): void {
731
775
  if (frameEl === undefined) return;
732
- const width = frameEl.clientWidth || undefined;
776
+ const rawWidth = frameEl.clientWidth;
777
+ const width = rawWidth > 0
778
+ ? rawWidth
779
+ : fullscreen && window.innerWidth > 0
780
+ ? window.innerWidth
781
+ : undefined;
733
782
  const frameHeight = frameEl.clientHeight;
734
783
  const viewportOuterHeight = viewportEl?.offsetHeight ?? 0;
735
784
  // The frame can grow with its viewport when a scrollbar appears.
@@ -742,6 +791,8 @@
742
791
  const height = window.innerHeight > 0 ? window.innerHeight : undefined;
743
792
  const refit = resize || width !== frameWidth || frameHeightChanged || height !== windowHeight;
744
793
  frameWidth = width;
794
+ measuredFrameHeight = frameHeight > 0 ? frameHeight : undefined;
795
+ controlsHeight = controlsEl?.offsetHeight ?? 0;
745
796
  viewWidth = viewportEl?.clientWidth || width;
746
797
  scrollbarHeight = viewportOuterHeight - (viewportEl?.clientHeight ?? 0);
747
798
  windowHeight = height;
@@ -756,17 +807,32 @@
756
807
  const element = frameEl;
757
808
  if (element === undefined) return;
758
809
  untrack(() => measureFrame());
810
+ const doc = element.ownerDocument;
759
811
  const onResize = (): void => measureFrame(true);
760
- const fonts = document.fonts;
812
+ const onFullscreenChange = (): void => {
813
+ const active = figureEl !== undefined && doc.fullscreenElement === figureEl;
814
+ if (active !== nativeFullscreen) {
815
+ if (renderedBounds !== undefined && renderedBounds.scale < DEFAULT_MIN_READABLE_SCALE) renderedBounds = undefined;
816
+ nativeFullscreen = active;
817
+ if (active) fallbackFullscreen = false;
818
+ void tick().then(() => measureFrame(true));
819
+ }
820
+ };
821
+ const fonts = doc.fonts;
761
822
  window.addEventListener("resize", onResize);
823
+ doc.addEventListener("fullscreenchange", onFullscreenChange);
762
824
  fonts?.addEventListener?.("loadingdone", refitForFonts);
763
825
  const observer = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(() => measureFrame());
764
826
  observer?.observe(element);
765
827
  if (viewportEl !== undefined) observer?.observe(viewportEl);
766
828
  return () => {
767
829
  window.removeEventListener("resize", onResize);
830
+ doc.removeEventListener("fullscreenchange", onFullscreenChange);
768
831
  fonts?.removeEventListener?.("loadingdone", refitForFonts);
769
832
  observer?.disconnect();
833
+ if (figureEl !== undefined && doc.fullscreenElement === figureEl && typeof doc.exitFullscreen === "function") {
834
+ try { void doc.exitFullscreen()?.catch?.(() => undefined); } catch { /* ignore */ }
835
+ }
770
836
  };
771
837
  });
772
838
 
@@ -797,7 +863,11 @@
797
863
  $effect.pre(() => {
798
864
  const id = semanticDocument.documentId;
799
865
  if (cameraDocument !== undefined && cameraDocument !== id) {
800
- untrack(resetToFit);
866
+ untrack(() => {
867
+ viewAll = false;
868
+ if (fullscreen) exitFullscreen();
869
+ resetToFit();
870
+ });
801
871
  fittedFonts = undefined;
802
872
  browserMeasure = undefined;
803
873
  renderedBounds = undefined;
@@ -885,6 +955,113 @@
885
955
  resetToFit();
886
956
  }
887
957
 
958
+ function enterFullscreen(): void {
959
+ const target = figureEl;
960
+ if (target === undefined) return;
961
+ if (renderedBounds !== undefined && renderedBounds.scale < DEFAULT_MIN_READABLE_SCALE) renderedBounds = undefined;
962
+ const doc = target.ownerDocument;
963
+ const canNative = typeof target.requestFullscreen === "function" && doc.fullscreenEnabled !== false;
964
+ if (canNative) {
965
+ try {
966
+ const pending = target.requestFullscreen();
967
+ if (pending !== undefined && typeof pending.then === "function") {
968
+ void pending.then(
969
+ () => {
970
+ if (doc.fullscreenElement === target) {
971
+ nativeFullscreen = true;
972
+ fallbackFullscreen = false;
973
+ } else {
974
+ nativeFullscreen = false;
975
+ fallbackFullscreen = true;
976
+ }
977
+ void tick().then(() => measureFrame(true));
978
+ },
979
+ () => {
980
+ nativeFullscreen = false;
981
+ fallbackFullscreen = true;
982
+ void tick().then(() => measureFrame(true));
983
+ },
984
+ );
985
+ return;
986
+ }
987
+ if (doc.fullscreenElement === target) {
988
+ nativeFullscreen = true;
989
+ fallbackFullscreen = false;
990
+ void tick().then(() => measureFrame(true));
991
+ return;
992
+ }
993
+ } catch {
994
+ // Fall through to the fixed-position overlay fallback.
995
+ }
996
+ }
997
+ nativeFullscreen = false;
998
+ fallbackFullscreen = true;
999
+ void tick().then(() => measureFrame(true));
1000
+ }
1001
+
1002
+ function exitFullscreen(): void {
1003
+ const target = figureEl;
1004
+ const doc = target?.ownerDocument;
1005
+ const wasActive = nativeFullscreen || fallbackFullscreen;
1006
+ if (wasActive && renderedBounds !== undefined && renderedBounds.scale < DEFAULT_MIN_READABLE_SCALE) renderedBounds = undefined;
1007
+ fallbackFullscreen = false;
1008
+ if (doc !== undefined && doc.fullscreenElement === target && typeof doc.exitFullscreen === "function") {
1009
+ try {
1010
+ const pending = doc.exitFullscreen();
1011
+ if (pending !== undefined && typeof pending.then === "function") {
1012
+ void pending.then(
1013
+ () => {
1014
+ nativeFullscreen = doc.fullscreenElement === target;
1015
+ void tick().then(() => measureFrame(true));
1016
+ },
1017
+ () => {
1018
+ nativeFullscreen = false;
1019
+ void tick().then(() => measureFrame(true));
1020
+ },
1021
+ );
1022
+ return;
1023
+ }
1024
+ } catch {
1025
+ // Clear local state below.
1026
+ }
1027
+ }
1028
+ nativeFullscreen = false;
1029
+ if (wasActive) {
1030
+ void tick().then(() => measureFrame(true));
1031
+ }
1032
+ }
1033
+
1034
+ /** Toggle fullscreen using the Fullscreen API when available, with a fixed overlay fallback. */
1035
+ export function toggleFullscreen(): void {
1036
+ readCameraTokens();
1037
+ if (renderedBounds !== undefined && renderedBounds.scale < DEFAULT_MIN_READABLE_SCALE) renderedBounds = undefined;
1038
+ if (fullscreen) exitFullscreen();
1039
+ else enterFullscreen();
1040
+ }
1041
+
1042
+ /** Enable or leave « Tout voir » mode (whole scene, no readability floor, no scroll). */
1043
+ export function setViewAll(enabled: boolean): void {
1044
+ const next = Boolean(enabled);
1045
+ if (next === viewAll) return;
1046
+ if (animating) settle();
1047
+ readCameraTokens();
1048
+ const exitingFullscreen = !next && fullscreen;
1049
+ renderedBounds = undefined;
1050
+ viewAll = next;
1051
+ if (exitingFullscreen) exitFullscreen();
1052
+ resetToFit();
1053
+ if (!exitingFullscreen) {
1054
+ const targetScene = scene;
1055
+ void tick().then(() => {
1056
+ if (scene === targetScene && viewAll === next) readRenderedBounds();
1057
+ });
1058
+ }
1059
+ }
1060
+
1061
+ export function toggleViewAll(): void {
1062
+ setViewAll(!viewAll);
1063
+ }
1064
+
888
1065
  export function getCamera(): DiagramSceneCamera {
889
1066
  return {
890
1067
  zoom,
@@ -896,6 +1073,19 @@
896
1073
  };
897
1074
  }
898
1075
 
1076
+ function onFigureKeydown(event: KeyboardEvent): void {
1077
+ if (event.key !== "Escape" || event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
1078
+ if (fallbackFullscreen) {
1079
+ exitFullscreen();
1080
+ event.preventDefault();
1081
+ return;
1082
+ }
1083
+ if (viewAll && !fullscreen) {
1084
+ setViewAll(false);
1085
+ event.preventDefault();
1086
+ }
1087
+ }
1088
+
899
1089
  function onKeydown(event: KeyboardEvent): void {
900
1090
  if (event.ctrlKey || event.metaKey || event.altKey) return;
901
1091
  // m5: shortcuts work from non-input descendants (card buttons, nodes);
@@ -905,8 +1095,18 @@
905
1095
  const tag = target.tagName;
906
1096
  if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || target.isContentEditable || target.closest("[contenteditable]")) return;
907
1097
  }
1098
+ if (!event.shiftKey && event.key === "Escape" && fallbackFullscreen) {
1099
+ exitFullscreen();
1100
+ event.preventDefault();
1101
+ return;
1102
+ }
908
1103
  if (!event.shiftKey && roveFlow(event)) return;
909
1104
  if (!event.shiftKey && flowSteps.length > 0 && ["]", "[", "Escape"].includes(event.key)) {
1105
+ if (event.key === "Escape" && flowState.selection === null && viewAll && !fullscreen) {
1106
+ setViewAll(false);
1107
+ event.preventDefault();
1108
+ return;
1109
+ }
910
1110
  dispatchFlow({ type: event.key === "]" ? "next" : event.key === "[" ? "previous" : "escape" }); event.preventDefault(); return;
911
1111
  }
912
1112
  if (event.key === "+" || event.key === "=") zoomIn();
@@ -1110,25 +1310,30 @@
1110
1310
  return `;--st-diagram-overview-edge-label-size:${size}px;--st-diagram-overview-edge-label-line-height:${lineHeight}px`;
1111
1311
  });
1112
1312
  const viewportStyle = $derived(
1113
- `height:${viewportHeight}px;${fitToWindow ? "max-height:calc(100vh - 24px);max-width:100%;margin-inline:auto;" : `aspect-ratio:${FIT_ASPECT};`}overflow-x:${placement.overflowX ? 'auto' : 'hidden'};overflow-y:${placement.overflowY ? 'auto' : 'hidden'};--st-diagram-zoom:${zoom};--st-diagram-label-line-height:${edgeLabelLineHeight}px${metricPaintVars}${overviewLabelPaintVars}${flowSteps.length > 0 ? `;--st-diagramSceneFigure-flowHit:${flowHitSize(zoom, flowTokens)}px` : ""}`,
1313
+ `height:${viewportHeight}px;${fullscreen ? "" : fitToWindow ? "max-height:calc(100vh - 24px);max-width:100%;margin-inline:auto;" : `aspect-ratio:${FIT_ASPECT};`}overflow-x:${placement.overflowX ? 'auto' : 'hidden'};overflow-y:${placement.overflowY ? 'auto' : 'hidden'};--st-diagram-zoom:${zoom};--st-diagram-label-line-height:${edgeLabelLineHeight}px${metricPaintVars}${overviewLabelPaintVars}${flowSteps.length > 0 ? `;--st-diagramSceneFigure-flowHit:${flowHitSize(zoom, flowTokens)}px` : ""}`,
1114
1314
  );
1115
1315
  const worldStyle = $derived(
1116
1316
  `transform:translate(${placement.translateX}px,${placement.translateY}px) scale(${zoom})`,
1117
1317
  );
1118
1318
  </script>
1119
1319
 
1320
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
1120
1321
  <figure
1121
- class="st-diagramSceneFigure{compact ? " st-diagramSceneFigure--compact" : ""}{fitToWindow ? " st-diagramSceneFigure--fitToWindow" : ""}"
1322
+ bind:this={figureEl}
1323
+ class={`st-diagramSceneFigure${compact ? " st-diagramSceneFigure--compact" : ""}${fitToWindow ? " st-diagramSceneFigure--fitToWindow" : ""}${fullscreen ? " st-diagramSceneFigure--fullscreen" : ""}${fallbackFullscreen ? " st-diagramSceneFigure--fullscreenFallback" : ""}`}
1122
1324
  aria-label={label ?? title}
1123
1325
  data-zoom={zoom}
1124
1326
  data-zoom-readout={readout}
1125
1327
  data-fit-to-window={fitToWindow ? "true" : undefined}
1328
+ data-view-all={viewAll ? "true" : undefined}
1329
+ data-fullscreen={fullscreenMode}
1126
1330
  data-scene-refused={layoutResult.status === "refused" ? layoutResult.refusals[0]?.code : undefined}
1331
+ onkeydown={onFigureKeydown}
1127
1332
  >
1128
1333
  {#if title !== undefined}
1129
1334
  <figcaption class="st-diagramSceneFigure-title">{title}</figcaption>
1130
1335
  {/if}
1131
- <div class="st-diagramSceneFigure-controls" role="group" aria-label={strings.controls}>
1336
+ <div class="st-diagramSceneFigure-controls" bind:this={controlsEl} role="group" aria-label={strings.controls}>
1132
1337
  <IconButton size="sm" variant="secondary" aria-label={strings.zoomOut} disabled={!canZoomOut} onclick={zoomOut}>
1133
1338
  <Minus size="var(--st-component-button-anatomy-density-sm-fontSize)" aria-hidden="true" />
1134
1339
  </IconButton>
@@ -1139,6 +1344,17 @@
1139
1344
  <Plus size="var(--st-component-button-anatomy-density-sm-fontSize)" aria-hidden="true" />
1140
1345
  </IconButton>
1141
1346
  <Button size="sm" variant="secondary" onclick={fitToFrame}>{strings.fit}</Button>
1347
+ <Button size="sm" variant="secondary" class="st-diagramSceneFigure-viewAll" aria-pressed={viewAll} onclick={toggleViewAll}>
1348
+ <Scan size="var(--st-component-diagramScene-controlIconSize, var(--st-component-button-anatomy-density-sm-fontSize))" aria-hidden="true" />
1349
+ <span>{strings.viewAll}</span>
1350
+ </Button>
1351
+ <IconButton size="sm" variant="secondary" class="st-diagramSceneFigure-fullscreen" aria-label={strings.fullscreen} aria-pressed={fullscreen} onclick={toggleFullscreen}>
1352
+ {#if fullscreen}
1353
+ <Minimize2 size="var(--st-component-diagramScene-controlIconSize, var(--st-component-button-anatomy-density-sm-fontSize))" aria-hidden="true" />
1354
+ {:else}
1355
+ <Maximize2 size="var(--st-component-diagramScene-controlIconSize, var(--st-component-button-anatomy-density-sm-fontSize))" aria-hidden="true" />
1356
+ {/if}
1357
+ </IconButton>
1142
1358
  </div>
1143
1359
  {#if flowSteps.length > 0}
1144
1360
  <div class="st-diagramSceneFigure-flowNavigator" role="group" aria-label={strings.navigator}>
@@ -1407,8 +1623,55 @@
1407
1623
  .st-diagramSceneFigure-controls {
1408
1624
  align-items: center;
1409
1625
  display: inline-flex;
1626
+ flex-wrap: wrap;
1410
1627
  gap: var(--st-spacing-1, 0.25rem);
1411
1628
  grid-column: 2;
1629
+ justify-content: flex-end;
1630
+ }
1631
+ .st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-viewAll) {
1632
+ gap: var(--st-component-diagramScene-controlGap, var(--st-spacing-1, 0.25rem));
1633
+ }
1634
+ .st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-viewAll[aria-pressed="true"]),
1635
+ .st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-fullscreen[aria-pressed="true"]),
1636
+ .st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-viewAll[aria-pressed="true"]:not(:disabled):hover),
1637
+ .st-diagramSceneFigure-controls :global(.st-diagramSceneFigure-fullscreen[aria-pressed="true"]:not(:disabled):hover) {
1638
+ background: var(--st-component-diagramScene-controlActiveBackground, var(--st-semantic-action-primary));
1639
+ border-color: var(--st-component-diagramScene-controlActiveBorder, var(--st-semantic-action-primary));
1640
+ color: var(--st-component-diagramScene-controlActiveText, var(--st-semantic-action-primaryText));
1641
+ }
1642
+ .st-diagramSceneFigure--fullscreen,
1643
+ .st-diagramSceneFigure:fullscreen {
1644
+ align-content: stretch;
1645
+ background: var(--st-component-diagramScene-fullscreenBackground, var(--st-semantic-surface-default));
1646
+ box-sizing: border-box;
1647
+ grid-template-rows: auto minmax(0, 1fr);
1648
+ height: 100vh;
1649
+ height: 100dvh;
1650
+ inset: 0;
1651
+ padding: var(--st-component-diagramScene-fullscreenPadding, var(--st-spacing-4, 1rem));
1652
+ width: 100vw;
1653
+ }
1654
+ .st-diagramSceneFigure--fullscreen:has(.st-diagramSceneFigure-flowNavigator),
1655
+ .st-diagramSceneFigure:fullscreen:has(.st-diagramSceneFigure-flowNavigator) {
1656
+ grid-template-rows: auto auto minmax(0, 1fr);
1657
+ }
1658
+ .st-diagramSceneFigure--fullscreenFallback {
1659
+ position: fixed;
1660
+ z-index: var(--st-component-diagramScene-fullscreenZIndex, var(--st-component-overlay-zIndex, 90));
1661
+ }
1662
+ .st-diagramSceneFigure--fullscreen .st-diagramSceneFigure-frame,
1663
+ .st-diagramSceneFigure:fullscreen .st-diagramSceneFigure-frame {
1664
+ height: 100%;
1665
+ min-height: 0;
1666
+ }
1667
+ .st-diagramSceneFigure--fullscreen .st-diagramSceneFigure-viewport,
1668
+ .st-diagramSceneFigure:fullscreen .st-diagramSceneFigure-viewport {
1669
+ max-height: none;
1670
+ }
1671
+ @media (prefers-reduced-motion: reduce) {
1672
+ .st-diagramSceneFigure-controls :global(button) {
1673
+ transition: none;
1674
+ }
1412
1675
  }
1413
1676
  .st-diagramSceneFigure-readout {
1414
1677
  color: var(--st-semantic-text-secondary);
@@ -51,6 +51,10 @@ export interface DiagramSceneFigureLabels {
51
51
  zoomOut: string;
52
52
  /** Visible text of the fit / reset control (« Ajuster »). */
53
53
  fit: string;
54
+ /** Visible text of the whole-scene fit control (« Tout voir »). */
55
+ viewAll?: string;
56
+ /** Accessible name of the fullscreen control (« Plein écran »). */
57
+ fullscreen?: string;
54
58
  /** Accessible name of the readout, e.g. « Zoom 85 % ». */
55
59
  zoomLevel: (percent: number) => string;
56
60
  /** Accessible name of the scrollable drawing region. */
@@ -139,6 +143,9 @@ declare const DiagramSceneFigure: import("svelte").Component<DiagramSceneFigureP
139
143
  zoomIn: () => void;
140
144
  zoomOut: () => void;
141
145
  fitToFrame: () => void;
146
+ toggleFullscreen: () => void;
147
+ setViewAll: (enabled: boolean) => void;
148
+ toggleViewAll: () => void;
142
149
  getCamera: () => DiagramSceneCamera;
143
150
  }, "contentSize">;
144
151
  type DiagramSceneFigure = ReturnType<typeof DiagramSceneFigure>;
@@ -1 +1 @@
1
- {"version":3,"file":"DiagramSceneFigure.svelte.d.ts","sourceRoot":"","sources":["../src/lib/DiagramSceneFigure.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,EAOH,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AASrC,OAAO,EAA+L,KAAK,UAAU,EAAE,KAAK,eAAe,EAAoB,MAAM,qCAAqC,CAAC;AAC3S,OAAO,EAMH,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AACjC,OAAO,EAaH,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAsBrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAGlB,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,6CAA6C,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,K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AAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjD,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACtD,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACjD;AAuwCH,QAAA,MAAM,kBAAkB;oBA7jBE,MAAM,KAAG,IAAI;kBAyBjB,IAAI;mBAIH,IAAI;sBAKD,IAAI;4BAwFE,IAAI;0BAQJ,OAAO,KAAG,IAAI;yBAkBjB,IAAI;qBAIR,kBAAkB;iBAqaqB,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
@@ -13,33 +13,41 @@ export declare const RENDERED_BOUNDS_GRID_STEPS = 64;
13
13
  * - a painted edge is read as `(edge − origin) / zoom`, both operands on the
14
14
  * LayoutUnit grid, so a read places it within one LayoutUnit of screen
15
15
  * space: `1 / (64 × zoom)` world unit;
16
- * - no read happens under the readability floor (the camera never applies
17
- * a smaller zoom), where that step is at its widest: `1 / (64 × 0.30)`;
16
+ * - on the default path, no read happens under the readability floor (0.30),
17
+ * where that step is at its widest: `1 / (64 × 0.30)`;
18
+ * - in unconstrained (« Tout voir ») or `fitToWindow` mode, zoom can drop
19
+ * below 0.30, widening that step to `1 / (64 × zoom)`;
18
20
  * - the edge is then rounded outward to the 1/64 world-unit grid, which
19
21
  * moves it by less than one more step;
20
22
  * - a stroke is added to its edge in world units, at one width for every
21
- * zoom and interaction state (see `measureRenderedBounds`): it shifts
22
- * both reads alike.
23
+ * zoom and interaction state within the current fit mode (see
24
+ * `measureRenderedBounds`): it shifts both reads alike.
23
25
  *
24
- * Two reads of an unchanged edge, through any two transforms, therefore
25
- * differ by less than `(2 / 0.30 + 1) / 64` ≈ 0.120 world unit. On screen
26
- * that is more than `(1 + zoom) / 64` CSS px at every zoom the camera
27
- * applies: one LayoutUnit step read back through the outward rounding,
28
- * which spans up to `ceil(1 / zoom) / 64` world unit (2/64 at 0.62, 4/64 at
29
- * 0.30). A bare 1/64 CSS px is under that step: it refits on a flip of the
30
- * last grid step, and a fit then alternates between two transforms. At the
31
- * 0.62 cap the tolerance is 0.075 CSS px, far under the 1 CSS px paint
32
- * inset, so it cannot hide a real overflow.
26
+ * Two reads of an unchanged edge, through any two transforms at or above
27
+ * `scale`, therefore differ by less than `(2 / min(0.30, scale) + 1) / 64`
28
+ * world units (`≈ 0.120` at the 0.30 floor, `≈ 0.151` at 0.23, `≈ 0.276` at
29
+ * 0.12). On screen at that scale this stays near `(2 + scale) / 64` CSS px
30
+ * (`≈ 0.035` CSS px), far under the 1 CSS px paint inset, so it cannot hide
31
+ * a real overflow while preventing LayoutUnit flip oscillation.
33
32
  */
34
33
  export declare const RENDERED_BOUNDS_REFIT_TOLERANCE: number;
34
+ /**
35
+ * Scale-aware refit tolerance, world units. Equals
36
+ * `RENDERED_BOUNDS_REFIT_TOLERANCE` for scales at or above
37
+ * `DEFAULT_MIN_READABLE_SCALE` (0.30), and widens proportionally below 0.30
38
+ * to match the 1/64 CSS px LayoutUnit quantisation at sub-floor scales.
39
+ */
40
+ export declare function renderedBoundsRefitTolerance(scale?: number): number;
41
+ /** Scale committed on the world element's transform, falling back to `hostZoom`. */
42
+ export declare function committedWorldScale(frame: HTMLElement, hostZoom: number): number;
35
43
  /**
36
44
  * Whether a painted-bounds read differs enough from the previous read of
37
45
  * the same scene to refit. The first read (`previous` absent) always fits:
38
46
  * the tolerance bounds the distance between two reads, not between a read
39
- * and the model geometry. From then on a fit is a fixed point: reading the
40
- * same paint again, through any transform, never moves it.
47
+ * and the model geometry. Pass the minimum painted scale of the two reads
48
+ * when comparing sub-0.30 fits so a fit remains a fixed point.
41
49
  */
42
- export declare function shouldRefitRenderedBounds(previous: Rect | undefined, next: Rect): boolean;
50
+ export declare function shouldRefitRenderedBounds(previous: Rect | undefined, next: Rect, scale?: number): boolean;
43
51
  /**
44
52
  * Painted bounds in world units, after font/layout settling. DOM-free scene
45
53
  * geometry remains the SSR fallback. Include text ink and SVG strokes:
@@ -53,14 +61,14 @@ export declare function shouldRefitRenderedBounds(previous: Rect | undefined, ne
53
61
  *
54
62
  * - a stroke that scales with the world has a constant world width;
55
63
  * - a `non-scaling-stroke` has a constant screen width, so its world width
56
- * is `width / zoom`. It is framed at its widest, the one it has at the
57
- * readability floor (`DEFAULT_MIN_READABLE_SCALE`, under which the camera
58
- * never paints), at every zoom, and at its resting width;
64
+ * is `width / zoom`. It is framed at its widest within the active fit mode
65
+ * (`min(DEFAULT_MIN_READABLE_SCALE, minScale, zoom)`), at every zoom, and
66
+ * at its resting width;
59
67
  * - geometry that paints nothing is left out: flow hit targets
60
68
  * (`[data-flow-hit]`, a transparent 16 px stroke), flow focus targets
61
69
  * (`[data-flow-node]`, hidden at rest and sized in screen px), transparent
62
70
  * strokes and text, shapes with neither stroke nor fill, and hidden or
63
71
  * clipped subtrees. What a fold transition is fading in stays in.
64
72
  */
65
- export declare function measureRenderedBounds(frame: HTMLElement, fallback: Rect | undefined, hostZoom: number): Rect | undefined;
73
+ export declare function measureRenderedBounds(frame: HTMLElement, fallback: Rect | undefined, hostZoom: number, minScale?: number): Rect | undefined;
66
74
  //# sourceMappingURL=diagramRenderedBounds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagramRenderedBounds.d.ts","sourceRoot":"","sources":["../src/lib/diagramRenderedBounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAG7C;;;;;;;;;;;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GRID_STEPS;
14
14
  * - a painted edge is read as `(edge − origin) / zoom`, both operands on the
15
15
  * LayoutUnit grid, so a read places it within one LayoutUnit of screen
16
16
  * space: `1 / (64 × zoom)` world unit;
17
- * - no read happens under the readability floor (the camera never applies
18
- * a smaller zoom), where that step is at its widest: `1 / (64 × 0.30)`;
17
+ * - on the default path, no read happens under the readability floor (0.30),
18
+ * where that step is at its widest: `1 / (64 × 0.30)`;
19
+ * - in unconstrained (« Tout voir ») or `fitToWindow` mode, zoom can drop
20
+ * below 0.30, widening that step to `1 / (64 × zoom)`;
19
21
  * - the edge is then rounded outward to the 1/64 world-unit grid, which
20
22
  * moves it by less than one more step;
21
23
  * - a stroke is added to its edge in world units, at one width for every
22
- * zoom and interaction state (see `measureRenderedBounds`): it shifts
23
- * both reads alike.
24
+ * zoom and interaction state within the current fit mode (see
25
+ * `measureRenderedBounds`): it shifts both reads alike.
24
26
  *
25
- * Two reads of an unchanged edge, through any two transforms, therefore
26
- * differ by less than `(2 / 0.30 + 1) / 64` ≈ 0.120 world unit. On screen
27
- * that is more than `(1 + zoom) / 64` CSS px at every zoom the camera
28
- * applies: one LayoutUnit step read back through the outward rounding,
29
- * which spans up to `ceil(1 / zoom) / 64` world unit (2/64 at 0.62, 4/64 at
30
- * 0.30). A bare 1/64 CSS px is under that step: it refits on a flip of the
31
- * last grid step, and a fit then alternates between two transforms. At the
32
- * 0.62 cap the tolerance is 0.075 CSS px, far under the 1 CSS px paint
33
- * inset, so it cannot hide a real overflow.
27
+ * Two reads of an unchanged edge, through any two transforms at or above
28
+ * `scale`, therefore differ by less than `(2 / min(0.30, scale) + 1) / 64`
29
+ * world units (`≈ 0.120` at the 0.30 floor, `≈ 0.151` at 0.23, `≈ 0.276` at
30
+ * 0.12). On screen at that scale this stays near `(2 + scale) / 64` CSS px
31
+ * (`≈ 0.035` CSS px), far under the 1 CSS px paint inset, so it cannot hide
32
+ * a real overflow while preventing LayoutUnit flip oscillation.
34
33
  */
35
34
  export const RENDERED_BOUNDS_REFIT_TOLERANCE = (2 / DEFAULT_MIN_READABLE_SCALE + 1) / GRID;
35
+ /**
36
+ * Scale-aware refit tolerance, world units. Equals
37
+ * `RENDERED_BOUNDS_REFIT_TOLERANCE` for scales at or above
38
+ * `DEFAULT_MIN_READABLE_SCALE` (0.30), and widens proportionally below 0.30
39
+ * to match the 1/64 CSS px LayoutUnit quantisation at sub-floor scales.
40
+ */
41
+ export function renderedBoundsRefitTolerance(scale = DEFAULT_MIN_READABLE_SCALE) {
42
+ const floor = Number.isFinite(scale) && scale > 0
43
+ ? Math.min(DEFAULT_MIN_READABLE_SCALE, scale)
44
+ : DEFAULT_MIN_READABLE_SCALE;
45
+ return (2 / floor + 1) / GRID;
46
+ }
47
+ /** Scale committed on the world element's transform, falling back to `hostZoom`. */
48
+ export function committedWorldScale(frame, hostZoom) {
49
+ const world = frame.querySelector('.st-diagramSceneFigure-world');
50
+ if (!world)
51
+ return hostZoom;
52
+ const committed = Number(/\bscale\(\s*([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)\s*\)/i.exec(world.style.transform)?.[1]);
53
+ return committed > 0 ? committed : hostZoom;
54
+ }
36
55
  /**
37
56
  * Whether a painted-bounds read differs enough from the previous read of
38
57
  * the same scene to refit. The first read (`previous` absent) always fits:
39
58
  * the tolerance bounds the distance between two reads, not between a read
40
- * and the model geometry. From then on a fit is a fixed point: reading the
41
- * same paint again, through any transform, never moves it.
59
+ * and the model geometry. Pass the minimum painted scale of the two reads
60
+ * when comparing sub-0.30 fits so a fit remains a fixed point.
42
61
  */
43
- export function shouldRefitRenderedBounds(previous, next) {
62
+ export function shouldRefitRenderedBounds(previous, next, scale) {
44
63
  if (previous === undefined)
45
64
  return true;
46
65
  const delta = Math.max(Math.abs(next.x - previous.x), Math.abs(next.y - previous.y), Math.abs(next.x + next.width - previous.x - previous.width), Math.abs(next.y + next.height - previous.y - previous.height));
47
- return delta > RENDERED_BOUNDS_REFIT_TOLERANCE;
66
+ return delta > renderedBoundsRefitTolerance(scale);
48
67
  }
49
68
  /** Token default of a resting numbered-flow stroke, CSS px (DC-2c). */
50
69
  const RESTING_FLOW_STROKE_WIDTH = 1.5;
@@ -124,16 +143,16 @@ function restingStrokeWidth(element, style) {
124
143
  *
125
144
  * - a stroke that scales with the world has a constant world width;
126
145
  * - a `non-scaling-stroke` has a constant screen width, so its world width
127
- * is `width / zoom`. It is framed at its widest, the one it has at the
128
- * readability floor (`DEFAULT_MIN_READABLE_SCALE`, under which the camera
129
- * never paints), at every zoom, and at its resting width;
146
+ * is `width / zoom`. It is framed at its widest within the active fit mode
147
+ * (`min(DEFAULT_MIN_READABLE_SCALE, minScale, zoom)`), at every zoom, and
148
+ * at its resting width;
130
149
  * - geometry that paints nothing is left out: flow hit targets
131
150
  * (`[data-flow-hit]`, a transparent 16 px stroke), flow focus targets
132
151
  * (`[data-flow-node]`, hidden at rest and sized in screen px), transparent
133
152
  * strokes and text, shapes with neither stroke nor fill, and hidden or
134
153
  * clipped subtrees. What a fold transition is fading in stays in.
135
154
  */
136
- export function measureRenderedBounds(frame, fallback, hostZoom) {
155
+ export function measureRenderedBounds(frame, fallback, hostZoom, minScale = DEFAULT_MIN_READABLE_SCALE) {
137
156
  const world = frame.querySelector('.st-diagramSceneFigure-world');
138
157
  if (!world)
139
158
  return fallback;
@@ -141,6 +160,7 @@ export function measureRenderedBounds(frame, fallback, hostZoom) {
141
160
  const zoom = committed > 0 ? committed : hostZoom;
142
161
  if (!(zoom > 0))
143
162
  return fallback;
163
+ const strokeScale = Math.min(DEFAULT_MIN_READABLE_SCALE, zoom, Number.isFinite(minScale) && minScale > 0 ? minScale : DEFAULT_MIN_READABLE_SCALE);
144
164
  const first = world.querySelector('[data-scene-occurrence],[data-scene-label]')?.getBoundingClientRect();
145
165
  if (!first || first.width === 0 && first.height === 0)
146
166
  return fallback;
@@ -191,7 +211,7 @@ export function measureRenderedBounds(frame, fallback, hostZoom) {
191
211
  continue;
192
212
  if (stroked) {
193
213
  if (style.vectorEffect === 'non-scaling-stroke')
194
- pad = restingStrokeWidth(element, style) / 2 / DEFAULT_MIN_READABLE_SCALE;
214
+ pad = restingStrokeWidth(element, style) / 2 / strokeScale;
195
215
  else {
196
216
  const matrix = element.getScreenCTM?.();
197
217
  const scale = matrix ? Math.max(Math.hypot(matrix.a, matrix.b), Math.hypot(matrix.c, matrix.d)) : zoom;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentropic/design-system-svelte",
3
- "version": "0.44.0",
3
+ "version": "0.45.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -65,8 +65,8 @@
65
65
  "@lucide/svelte": "^0.562.0",
66
66
  "@sentropic/design-system-review-core": "0.1.0",
67
67
  "@sentropic/design-system-rich-text": "0.1.1",
68
- "@sentropic/design-system-themes": "0.16.0",
69
- "@sentropic/diagram-canvas": "0.4.0",
68
+ "@sentropic/design-system-themes": "0.16.1",
69
+ "@sentropic/diagram-canvas": "0.5.0",
70
70
  "@sentropic/graph": "0.3.1"
71
71
  },
72
72
  "peerDependencies": {
@@ -98,7 +98,7 @@
98
98
  },
99
99
  "devDependencies": {
100
100
  "@sentropic/design-system-theme-dsfr": "0.2.2",
101
- "@sentropic/design-system-themes": "0.16.0",
101
+ "@sentropic/design-system-themes": "0.16.1",
102
102
  "@sveltejs/package": "^2.5.0",
103
103
  "@sveltejs/vite-plugin-svelte": "^7.1.2",
104
104
  "@testing-library/svelte": "^5.2.8",