Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix(viewer): keep navigation dock clear of legends (#101)
sunsunsun-javac784542eecb1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex b5b3c28a..add292bf 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -51,6 +51,12 @@ jobs:env:ARCHIFY_CHROME: ${{ steps.setup-chrome.outputs.chrome-path }}ARCHIFY_CHROME_NO_SANDBOX: '1'+ - name: Verify Viewer chrome stays clear of SVG legends+ run: node --test test/viewer-chrome-layout.test.mjs+ working-directory: archify+ env:+ ARCHIFY_CHROME: ${{ steps.setup-chrome.outputs.chrome-path }}+ ARCHIFY_CHROME_NO_SANDBOX: '1'zip-freshness:runs-on: ubuntu-latestdiff --git a/archify.zip b/archify.zipindex f3f1b4e2..400b619c 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/assets/template.html b/archify/assets/template.htmlindex 20e1b360..80915779 100644--- a/archify/assets/template.html+++ b/archify/assets/template.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10471,6 +10478,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10608,40 +10655,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10669,6 +10687,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10774,6 +10995,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10886,6 +11110,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11243,7 +11470,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13130,7 +13363,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13143,6 +13376,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/archify/bin/visual-check.mjs b/archify/bin/visual-check.mjsindex 28a780b5..5c9183f2 100644--- a/archify/bin/visual-check.mjs+++ b/archify/bin/visual-check.mjs@@ -353,13 +353,25 @@ export class ChromeVisualBrowser {document.documentElement.setAttribute('data-motion', 'still');var panel = document.querySelector('.diagram-container');if (panel) panel.setAttribute('data-detail-level', 'read');- if (window.Archify && window.Archify.readerLayout && typeof window.Archify.readerLayout.whenStable === 'function') {- return window.Archify.readerLayout.whenStable();- }var fontsReady = document.fonts && document.fonts.ready? document.fonts.ready.catch(function () {}): Promise.resolve();return fontsReady.then(function () {+ if (window.Archify && Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function') {+ return Archify.readerLayout.whenStable();+ }+ }).then(function () {+ if (window.Archify && Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.whenStable === 'function') {+ return Archify.viewerChromeLayout.whenStable();+ }+ }).then(function () {+ if (window.Archify && Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function') {+ return Archify.readerLayout.whenStable();+ }+ }).then(function () {+ if (window.Archify && Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.whenStable === 'function') {+ return Archify.viewerChromeLayout.whenStable();+ }return new Promise(function (resolve) {requestAnimationFrame(function () { requestAnimationFrame(resolve); });});@@ -370,6 +382,8 @@ export class ChromeVisualBrowser {var reader = document.querySelector('.container');var diagram = document.querySelector('.diagram-container');var svg = diagram && diagram.querySelector(':scope > svg');+ var legend = svg && svg.querySelector('[data-legend]');+ var navigationDock = diagram && diagram.querySelector('.diagram-nav');var viewBox = svg && svg.viewBox && svg.viewBox.baseVal;var diagramWidth = svg ? svg.getBoundingClientRect().width : 0;var viewBoxWidth = viewBox ? viewBox.width : 0;@@ -394,6 +408,18 @@ export class ChromeVisualBrowser {}});}+ function intersectionArea(a, b) {+ if (!a || !b || !a.width || !a.height || !b.width || !b.height) return 0;+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ var legendRect = legend ? legend.getBoundingClientRect() : null;+ var navigationDockRect = navigationDock ? navigationDock.getBoundingClientRect() : null;+ var viewerChromeReceipt = window.Archify && Archify.viewerChromeLayout+ && typeof Archify.viewerChromeLayout.receipt === 'function'+ ? Archify.viewerChromeLayout.receipt()+ : null;return {innerWidth: window.innerWidth,innerHeight: window.innerHeight,@@ -405,7 +431,12 @@ export class ChromeVisualBrowser {viewBoxWidth: viewBoxWidth,minimumProjectedNodeTextPx: minimum ? minimum.projectedFontPx : null,minimumProjectedNodeText: minimum ? minimum.text : null,- minimumProjectedNodeTextDetail: minimum ? minimum.detail : null+ minimumProjectedNodeTextDetail: minimum ? minimum.detail : null,+ hasLegend: Boolean(legendRect && legendRect.width && legendRect.height),+ hasNavigationDock: Boolean(navigationDockRect && navigationDockRect.width && navigationDockRect.height),+ legendDockIntersectionArea: intersectionArea(legendRect, navigationDockRect),+ viewerChromeReserve: viewerChromeReceipt ? viewerChromeReceipt.reserve : 0,+ viewerChromeActive: viewerChromeReceipt ? viewerChromeReceipt.active : false};})()`);if (!metrics || !Number.isFinite(metrics.scrollWidth) || !Number.isFinite(metrics.scrollHeight)) {@@ -459,6 +490,8 @@ function observation({ width, height, theme, metrics }) {: Number(metrics.minimumProjectedNodeTextPx);const readabilityOk = minimumProjectedNodeTextPx == null|| minimumProjectedNodeTextPx >= MIN_PROJECTED_NODE_TEXT_PX;+ const legendDockIntersectionArea = Number(metrics.legendDockIntersectionArea) || 0;+ const viewerChromeOk = legendDockIntersectionArea <= 0.5;return {width,height,@@ -478,6 +511,12 @@ function observation({ width, height, theme, metrics }) {minimumProjectedNodeTextDetail: metrics.minimumProjectedNodeTextDetail || null,minimumRequiredNodeTextPx: MIN_PROJECTED_NODE_TEXT_PX,readabilityOk,+ hasLegend: Boolean(metrics.hasLegend),+ hasNavigationDock: Boolean(metrics.hasNavigationDock),+ legendDockIntersectionArea,+ viewerChromeReserve: Number(metrics.viewerChromeReserve) || 0,+ viewerChromeActive: Boolean(metrics.viewerChromeActive),+ viewerChromeOk,resolvedTheme: metrics.resolvedTheme || theme,};}@@ -523,6 +562,7 @@ function baseReceipt({ artifactPath, artifact, outputs, chrome }) {chrome,containment: { status: 'fail', viewports: [] },readability: { status: 'fail', minimumProjectedNodeTextPx: MIN_PROJECTED_NODE_TEXT_PX, viewports: [] },+ viewerChrome: { status: 'fail', viewports: [] },captures: { status: 'fail', screenshots: [], contactSheet: null },sidecars: {receipt: path.basename(outputs.receipt),@@ -563,6 +603,7 @@ export async function runVisualCheck({receipt.status = 'skipped';receipt.containment.status = 'skipped';receipt.readability.status = 'skipped';+ receipt.viewerChrome.status = 'skipped';receipt.captures.status = 'skipped';receipt.error = 'Chrome or Chromium is unavailable. Set ARCHIFY_CHROME to its executable path.';persistReceipt(outputs, receipt);@@ -610,6 +651,7 @@ export async function runVisualCheck({observations.get(screenshotKey(width, height, 'light'))));receipt.readability.viewports = receipt.containment.viewports.map((entry) => ({ ...entry }));+ receipt.viewerChrome.viewports = receipt.containment.viewports.map((entry) => ({ ...entry }));receipt.captures.screenshots = outputs.screenshots.map((entry) => ({...observations.get(screenshotKey(entry.width, entry.height, entry.theme)),file: path.basename(entry.path),@@ -617,12 +659,14 @@ export async function runVisualCheck({const allObservations = [...observations.values()];const containmentPass = allObservations.every((entry) => entry.ok);const readabilityPass = receipt.readability.viewports.every((entry) => entry.readabilityOk);+ const viewerChromePass = allObservations.every((entry) => entry.viewerChromeOk);receipt.containment.status = containmentPass ? 'pass' : 'fail';receipt.readability.status = readabilityPass ? 'pass' : 'fail';+ receipt.viewerChrome.status = viewerChromePass ? 'pass' : 'fail';receipt.captures.status = 'pass';receipt.captures.contactSheet = path.basename(outputs.contactSheet);- receipt.status = containmentPass && readabilityPass ? 'pass' : 'fail';- receipt.ok = containmentPass && readabilityPass;+ receipt.status = containmentPass && readabilityPass && viewerChromePass ? 'pass' : 'fail';+ receipt.ok = containmentPass && readabilityPass && viewerChromePass;writeAtomic(outputs.contactSheet, contactSheetHtml({artifactPath: artifact,receipt,@@ -637,6 +681,7 @@ export async function runVisualCheck({receipt.error = error.message;receipt.containment.status = 'fail';receipt.readability.status = 'fail';+ receipt.viewerChrome.status = 'fail';receipt.captures.status = 'fail';receipt.captures.screenshots = [];receipt.captures.contactSheet = null;diff --git a/archify/examples/dataflow-product-analytics.html b/archify/examples/dataflow-product-analytics.htmlindex 57e151b0..2ba52bf5 100644--- a/archify/examples/dataflow-product-analytics.html+++ b/archify/examples/dataflow-product-analytics.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10582,6 +10589,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10719,40 +10766,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10780,6 +10798,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10885,6 +11106,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10997,6 +11221,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11354,7 +11581,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13241,7 +13474,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13254,6 +13487,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/archify/examples/lifecycle-agent-run.html b/archify/examples/lifecycle-agent-run.htmlindex 3200c804..70742acd 100644--- a/archify/examples/lifecycle-agent-run.html+++ b/archify/examples/lifecycle-agent-run.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10531,6 +10538,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10668,40 +10715,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10729,6 +10747,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10834,6 +11055,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10946,6 +11170,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11303,7 +11530,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13190,7 +13423,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13203,6 +13436,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/archify/examples/sequence-cache-miss-request.html b/archify/examples/sequence-cache-miss-request.htmlindex ae9d189f..802dccfd 100644--- a/archify/examples/sequence-cache-miss-request.html+++ b/archify/examples/sequence-cache-miss-request.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10597,6 +10604,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10734,40 +10781,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10795,6 +10813,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10900,6 +11121,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -11012,6 +11236,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11369,7 +11596,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13256,7 +13489,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13269,6 +13502,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/archify/examples/web-app-rendered.html b/archify/examples/web-app-rendered.htmlindex 7bc5a4f8..a1588db3 100644--- a/archify/examples/web-app-rendered.html+++ b/archify/examples/web-app-rendered.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10546,6 +10553,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10683,40 +10730,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10744,6 +10762,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10849,6 +11070,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10961,6 +11185,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11318,7 +11545,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13205,7 +13438,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13218,6 +13451,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/archify/examples/workflow-agent-tool-call-rendered.html b/archify/examples/workflow-agent-tool-call-rendered.htmlindex bc6acb85..41c328fb 100644--- a/archify/examples/workflow-agent-tool-call-rendered.html+++ b/archify/examples/workflow-agent-tool-call-rendered.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10579,6 +10586,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10716,40 +10763,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10777,6 +10795,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10882,6 +11103,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10994,6 +11218,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11351,7 +11578,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13238,7 +13471,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13251,6 +13484,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/archify/test/adaptive-reader-layout.test.mjs b/archify/test/adaptive-reader-layout.test.mjsindex f8e12a01..e9be6359 100644--- a/archify/test/adaptive-reader-layout.test.mjs+++ b/archify/test/adaptive-reader-layout.test.mjs@@ -39,7 +39,7 @@ test('desktop readability budget matches the minimum adaptive reader at 1440 byassert.equal(DESKTOP_READER_HORIZONTAL_CHROME, 30);assert.equal(DESKTOP_READER_DIAGRAM_WIDTH, 930);assert.match(reader, new RegExp(`var MIN_READER_WIDTH = ${DESKTOP_READER_MIN_WIDTH}`));- assert.match(template, /@media \(min-width: 768px\) and \(max-height: 1100px\)[\s\S]*?\.diagram-container \{ padding: 0\.875rem; \}/);+ assert.match(template, /@media \(min-width: 768px\) and \(max-height: 1100px\)[\s\S]*?\.diagram-container \{[\s\S]*?padding: 0\.875rem;[\s\S]*?padding-bottom: calc\(0\.875rem \+ var\(--archify-nav-reserve\)\);/);assert.match(template, /@media \(min-width: 768px\) and \(max-height: 920px\)[\s\S]*?body \{ padding-block: 1\.25rem; \}/);assert.match(template, /\.diagram-container \{[\s\S]*?border: 1px solid var\(--panel-border\)/);});diff --git a/archify/test/semantic-radar.test.mjs b/archify/test/semantic-radar.test.mjsindex 044c3f08..e2347e74 100644--- a/archify/test/semantic-radar.test.mjs+++ b/archify/test/semantic-radar.test.mjs@@ -74,7 +74,7 @@ test('Semantic Radar tracks desktop camera and mobile contained scroll', () => {assert.match(html, /function updateDocking\(\)/);assert.match(html, /chip\.style\.top = Math\.round\(top\) \+ 'px';[\s\S]+Archify\.radar\.sync\(\)/);assert.match(html, /activeRect\.left \+ activeRect\.width \/ 2 > window\.innerWidth \/ 2/);- assert.match(html, /var blockers = \[activeRect, lensRect\]\.filter/);+ assert.match(html, /var blockers = \[activeRect, lensRect, legendRect, navRect\]\.filter/);assert.match(html, /candidates\.push\(rect\.top - 10 - panel\.offsetHeight, rect\.bottom \+ 10\)/);assert.match(html, /return candidate \+ panel\.offsetHeight <= rect\.top - 10 \|\| candidate >= rect\.bottom \+ 10/);assert.match(html, /--archify-radar-top/);diff --git a/archify/test/viewer-chrome-layout.test.mjs b/archify/test/viewer-chrome-layout.test.mjsnew file mode 100644index 00000000..cc35ff4b--- /dev/null+++ b/archify/test/viewer-chrome-layout.test.mjs@@ -0,0 +1,456 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { execFileSync } from 'node:child_process';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { fileURLToPath, pathToFileURL } from 'node:url';++import { ChromeVisualBrowser, findChrome } from '../bin/visual-check.mjs';++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const skillRoot = path.resolve(__dirname, '..');+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-viewer-chrome-layout-'));+const chromePath = process.env.ARCHIFY_CHROME ? findChrome() : null;++const CASES = {+ architecture: 'web-app.architecture.json',+ workflow: 'agent-tool-call.workflow.json',+ sequence: 'cache-miss-request.sequence.json',+ dataflow: 'product-analytics.dataflow.json',+ lifecycle: 'agent-run.lifecycle.json',+};++function render(mode, example) {+ const output = path.join(tmp, `${mode}.html`);+ execFileSync(process.execPath, [+ path.join(skillRoot, 'bin', 'archify.mjs'),+ 'render',+ mode,+ path.join(skillRoot, 'examples', example),+ output,+ ]);+ return output;+}++function canonicalSvg(html) {+ return html.match(/<svg\b[\s\S]*?<\/svg>/)?.[0] || '';+}++async function evaluate(browser, sessionId, expression, awaitPromise = false) {+ const response = await browser.cdp.send('Runtime.evaluate', {+ expression,+ awaitPromise,+ returnByValue: true,+ }, sessionId);+ if (response.exceptionDetails) {+ throw new Error(response.exceptionDetails.exception?.description+ || response.exceptionDetails.text+ || 'Runtime.evaluate failed');+ }+ return response.result?.value;+}++async function waitForLayout(browser, sessionId) {+ return evaluate(browser, sessionId, `(function () {+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function rect(element) {+ if (!element) return 'missing';+ var value = element.getBoundingClientRect();+ return [value.left, value.top, value.right, value.bottom].map(function (entry) {+ return Math.round(entry * 100) / 100;+ }).join(',');+ }+ function sample() {+ sampledFrames += 1;+ var container = document.querySelector('.diagram-container');+ var current = [+ rect(container),+ rect(container && container.querySelector(':scope > svg')),+ rect(document.querySelector('.diagram-nav')),+ rect(document.querySelector('[data-legend]')),+ rect(document.getElementById('semantic-lens')),+ rect(document.getElementById('overview-map')),+ container ? getComputedStyle(container).getPropertyValue('--archify-nav-reserve') : ''+ ].join('|');+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ /* Final-artifact tests cannot inspect private scheduler flags. Eight+ equal frames cover the public three-frame contract plus any+ reader/viewer handoff queued after a ResizeObserver callback. */+ if (stableFrames >= 8) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ if (sampledFrames >= 240) {+ reject(new Error('Final Viewer geometry did not stabilize.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ })()`, true);+}++async function finalGeometry(browser, sessionId) {+ return evaluate(browser, sessionId, `(function () {+ function area(a, b) {+ if (!a || !b || !a.width || !a.height || !b.width || !b.height) return 0;+ return Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left)) *+ Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ }+ var container = document.querySelector('.diagram-container');+ var legend = document.querySelector('[data-legend]');+ var nav = document.querySelector('.diagram-nav');+ var svg = container && container.querySelector(':scope > svg');+ var lens = document.getElementById('semantic-lens');+ var radar = document.getElementById('overview-map');+ var legendRect = legend && getComputedStyle(legend).display !== 'none' ? legend.getBoundingClientRect() : null;+ var navRect = nav && getComputedStyle(nav).display !== 'none' ? nav.getBoundingClientRect() : null;+ var svgRect = svg ? svg.getBoundingClientRect() : null;+ var lensRect = lens && !lens.hidden && getComputedStyle(lens).display !== 'none' ? lens.getBoundingClientRect() : null;+ var radarRect = radar && !radar.hidden && getComputedStyle(radar).display !== 'none' ? radar.getBoundingClientRect() : null;+ return {+ reserve: parseFloat(getComputedStyle(container).getPropertyValue('--archify-nav-reserve')) || 0,+ stageGap: navRect && svgRect ? navRect.top - svgRect.bottom : null,+ legendDockIntersectionArea: area(legendRect, navRect),+ legendLensIntersectionArea: area(legendRect, lensRect),+ navLensIntersectionArea: area(navRect, lensRect),+ legendRadarIntersectionArea: area(legendRect, radarRect),+ navRadarIntersectionArea: area(navRect, radarRect),+ legendRect: legendRect ? { left: legendRect.left, right: legendRect.right, top: legendRect.top, bottom: legendRect.bottom } : null,+ navRect: navRect ? { left: navRect.left, right: navRect.right, top: navRect.top, bottom: navRect.bottom } : null,+ hasLegend: Boolean(legendRect && legendRect.width && legendRect.height)+ };+ })()`);+}++async function load(browser, artifactPath, { width = 1440, height = 900, query = '' } = {}) {+ const sessionId = await browser.sessionPromise;+ await browser.cdp.send('Emulation.setDeviceMetricsOverride', {+ width,+ height,+ deviceScaleFactor: 1,+ mobile: false,+ }, sessionId);+ const loaded = browser.cdp.waitFor('Page.loadEventFired', sessionId);+ const navigation = await browser.cdp.send('Page.navigate', {+ url: pathToFileURL(artifactPath).href + query,+ }, sessionId);+ if (navigation.errorText) throw new Error(`Chrome navigation failed: ${navigation.errorText}`);+ await loaded;+ await evaluate(browser, sessionId, `document.documentElement.setAttribute('data-motion', 'still')`);+ await waitForLayout(browser, sessionId);+ return sessionId;+}++test('the public CLI gives all typed renderers one final Viewer contract', () => {+ for (const [mode, example] of Object.entries(CASES)) {+ const output = render(mode, example);+ const html = fs.readFileSync(output, 'utf8');+ assert.match(html, /class="[^"]*\bdiagram-nav\b[^"]*"/, mode);+ assert.match(html, /data-legend/, mode);+ assert.doesNotMatch(canonicalSvg(html), /nav-safe-rail|archify-nav-reserve|viewerChromeLayout/, mode);+ execFileSync(process.execPath, [path.join(skillRoot, 'bin', 'archify.mjs'), 'check', output]);+ }+});++test('Viewer chrome remains outside the canonical SVG export boundary', () => {+ const html = fs.readFileSync(render('architecture', CASES.architecture), 'utf8');+ const svg = canonicalSvg(html);+ assert.match(svg, /data-legend/);+ assert.doesNotMatch(svg, /diagram-nav|data-nav-safe-rail|viewerChromeLayout/);+});++test('Dock Safe Rail resolves a forced Legend collision across the shared diagram viewer', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const browser = new ChromeVisualBrowser(chromePath);+ try {+ for (const [mode, example] of Object.entries(CASES)) {+ const sessionId = await load(browser, render(mode, example));+ const setup = await evaluate(browser, sessionId, `(function () {+ var nav = document.querySelector('.diagram-nav');+ var legendElement = document.querySelector('[data-legend]');+ if (!legendElement) {+ return { noLegend: true };+ }+ var initialLegend = legendElement.getBoundingClientRect();+ var containerRect = document.querySelector('.diagram-container').getBoundingClientRect();+ nav.style.right = 'auto';+ nav.style.left = Math.max(0, initialLegend.left - containerRect.left) + 'px';+ nav.style.bottom = Math.max(0, containerRect.bottom - initialLegend.bottom) + 'px';+ nav.style.width = Math.max(240, initialLegend.width) + 'px';+ window.dispatchEvent(new Event('resize'));+ return { noLegend: false };+ })()`);++ if (setup.noLegend) {+ const receipt = await finalGeometry(browser, sessionId);+ assert.equal(receipt.reserve, 0, mode);+ continue;+ }+ await waitForLayout(browser, sessionId);+ const receipt = await finalGeometry(browser, sessionId);+ assert.ok(receipt.reserve > 0, `${mode}: ${JSON.stringify(receipt)}`);+ assert.equal(receipt.legendDockIntersectionArea, 0, `${mode}: ${JSON.stringify(receipt)}`);+ assert.ok(receipt.stageGap >= 9, `${mode}: ${JSON.stringify(receipt)}`);+ }+ } finally {+ await browser.close();+ }+});++test('Maka remains collision-free at the reported Retina-equivalent viewport', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const output = path.join(tmp, 'maka-architecture.html');+ execFileSync(process.execPath, [+ path.join(skillRoot, 'bin', 'archify.mjs'),+ 'render',+ 'architecture',+ path.resolve(skillRoot, '..', 'examples', 'maka-architecture.architecture.json'),+ output,+ ]);+ const browser = new ChromeVisualBrowser(chromePath);+ try {+ const sessionId = await load(browser, output, { width: 1484, height: 724 });+ const receipt = await evaluate(browser, sessionId, `(function () {+ var legend = document.querySelector('[data-legend]').getBoundingClientRect();+ var dock = document.querySelector('.diagram-nav').getBoundingClientRect();+ var width = Math.max(0, Math.min(legend.right, dock.right) - Math.max(legend.left, dock.left));+ var height = Math.max(0, Math.min(legend.bottom, dock.bottom) - Math.max(legend.top, dock.top));+ return {+ intersectionArea: width * height,+ scrollWidth: document.documentElement.scrollWidth,+ innerWidth: window.innerWidth+ };+ })()`);++ assert.equal(receipt.intersectionArea, 0, JSON.stringify(receipt));+ assert.ok(receipt.scrollWidth <= receipt.innerWidth, JSON.stringify(receipt));+ } finally {+ await browser.close();+ }+});++test('a real 5px Legend gap keeps the zero-reserve layout unchanged', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const browser = new ChromeVisualBrowser(chromePath);+ try {+ const sessionId = await load(browser, render('architecture', CASES.architecture));+ await evaluate(browser, sessionId, `(function () {+ var container = document.querySelector('.diagram-container');+ var legend = document.querySelector('[data-legend]');+ var nav = document.querySelector('.diagram-nav');+ var legendRect = legend.getBoundingClientRect();+ var containerRect = container.getBoundingClientRect();+ nav.style.right = 'auto';+ nav.style.left = (legendRect.right - containerRect.left + 5) + 'px';+ nav.style.bottom = Math.max(0, containerRect.bottom - legendRect.bottom) + 'px';+ window.dispatchEvent(new Event('resize'));+ })()`);+ await waitForLayout(browser, sessionId);+ const receipt = await finalGeometry(browser, sessionId);++ assert.equal(receipt.legendDockIntersectionArea, 0, JSON.stringify(receipt));+ assert.equal(receipt.reserve, 0, JSON.stringify(receipt));+ } finally {+ await browser.close();+ }+});++test('Presentation keeps its visible Dock clear of a colliding Legend', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const browser = new ChromeVisualBrowser(chromePath);+ try {+ const sessionId = await load(browser, render('architecture', CASES.architecture), { query: '?present=1' });+ await evaluate(browser, sessionId, `(function () {+ var container = document.querySelector('.diagram-container');+ var legend = document.querySelector('[data-legend]');+ var nav = document.querySelector('.diagram-nav');+ var legendRect = legend.getBoundingClientRect();+ var containerRect = container.getBoundingClientRect();+ nav.style.right = 'auto';+ nav.style.left = Math.max(0, legendRect.left - containerRect.left) + 'px';+ nav.style.bottom = Math.max(0, containerRect.bottom - legendRect.bottom) + 'px';+ nav.style.width = Math.max(240, legendRect.width) + 'px';+ window.dispatchEvent(new Event('resize'));+ })()`);+ await waitForLayout(browser, sessionId);+ const receipt = await finalGeometry(browser, sessionId);++ assert.equal(receipt.legendDockIntersectionArea, 0, JSON.stringify(receipt));+ assert.ok(receipt.reserve > 0, JSON.stringify(receipt));+ } finally {+ await browser.close();+ }+});++test('manual zoom and pan reschedules Legend and Dock collision measurement', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const browser = new ChromeVisualBrowser(chromePath);+ try {+ const sessionId = await load(browser, render('architecture', CASES.architecture));+ await evaluate(browser, sessionId, `(function () {+ var container = document.querySelector('.diagram-container');+ var zoomIn = document.querySelector('[data-view="in"]');+ for (var index = 0; index < 8; index += 1) zoomIn.click();+ var svg = container.querySelector(':scope > svg');+ var rect = svg.getBoundingClientRect();+ var pointer = { bubbles: true, pointerId: 7, button: 0 };+ var startX = rect.left + rect.width / 2;+ var startY = rect.top + rect.height / 2;+ container.dispatchEvent(new PointerEvent('pointerdown', Object.assign({ clientX: startX, clientY: startY }, pointer)));+ container.dispatchEvent(new PointerEvent('pointermove', Object.assign({ clientX: startX + 210, clientY: startY - 500 }, pointer)));+ container.dispatchEvent(new PointerEvent('pointerup', Object.assign({ clientX: startX + 210, clientY: startY - 500 }, pointer)));+ })()`);+ await waitForLayout(browser, sessionId);+ const receipt = await finalGeometry(browser, sessionId);++ assert.equal(receipt.legendDockIntersectionArea, 0, JSON.stringify(receipt));+ assert.ok(receipt.reserve > 0, JSON.stringify(receipt));+ } finally {+ await browser.close();+ }+});++test('localized multiline Legends remain clear across themes, presets, and zoom levels', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const browser = new ChromeVisualBrowser(chromePath);+ const cases = [+ { preset: 'classic', theme: 'light', zoom: 1 },+ { preset: 'signal-flow', theme: 'dark', zoom: 1.25 },+ { preset: 'blueprint', theme: 'light', zoom: 2 },+ { preset: 'editorial', theme: 'dark', zoom: 2 },+ ];+ try {+ const sessionId = await load(browser, render('architecture', CASES.architecture), { width: 1920, height: 1080 });+ await evaluate(browser, sessionId, `(function () {+ var text = document.querySelector('[data-legend] text');+ var x = text.getAttribute('x') || '0';+ var namespace = 'http://www.w3.org/2000/svg';+ text.textContent = '';+ var first = document.createElementNS(namespace, 'tspan');+ first.setAttribute('x', x);+ first.textContent = '应用与运行时编排服务(本地化长标签)';+ var second = document.createElementNS(namespace, 'tspan');+ second.setAttribute('x', x);+ second.setAttribute('dy', '14');+ second.textContent = '第二行语义说明';+ text.appendChild(first);+ text.appendChild(second);+ })()`);++ for (const entry of cases) {+ await evaluate(browser, sessionId, `(function () {+ var html = document.documentElement;+ var nav = document.querySelector('.diagram-nav');+ html.setAttribute('data-preset', ${JSON.stringify(entry.preset)});+ html.setAttribute('data-theme', ${JSON.stringify(entry.theme)});+ html.style.fontSize = ${JSON.stringify(`${entry.zoom * 100}%`)};+ document.body.style.zoom = ${JSON.stringify(String(entry.zoom))};+ nav.removeAttribute('style');+ window.dispatchEvent(new Event('resize'));+ })()`);+ await waitForLayout(browser, sessionId);+ let receipt = null;+ for (let attempt = 0; attempt < 3; attempt += 1) {+ await evaluate(browser, sessionId, `(function () {+ var container = document.querySelector('.diagram-container');+ var legend = document.querySelector('[data-legend]').getBoundingClientRect();+ var nav = document.querySelector('.diagram-nav');+ var containerRect = container.getBoundingClientRect();+ var renderedZoom = nav.offsetHeight ? nav.getBoundingClientRect().height / nav.offsetHeight : ${entry.zoom};+ nav.style.right = '0';+ nav.style.left = '0';+ nav.style.bottom = Math.max(0, (containerRect.bottom - legend.bottom) / renderedZoom) + 'px';+ nav.style.width = 'auto';+ window.dispatchEvent(new Event('resize'));+ })()`);+ await waitForLayout(browser, sessionId);+ receipt = await finalGeometry(browser, sessionId);+ if (receipt.reserve > 0) break;+ }+ assert.equal(receipt.legendDockIntersectionArea, 0, JSON.stringify({ ...entry, receipt }));+ assert.ok(receipt.reserve > 0, JSON.stringify({ ...entry, receipt }));+ }+ } finally {+ await browser.close();+ }+});++test('Semantic Lens and Radar protect the final Legend and Dock rectangles', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const browser = new ChromeVisualBrowser(chromePath);+ try {+ const sessionId = await load(browser, render('architecture', CASES.architecture), { width: 1440, height: 900 });+ await evaluate(browser, sessionId, `document.getElementById('btn-semantic-lens').click()`);+ await waitForLayout(browser, sessionId);+ let receipt = await finalGeometry(browser, sessionId);+ assert.equal(receipt.legendLensIntersectionArea, 0, JSON.stringify(receipt));+ assert.equal(receipt.navLensIntersectionArea, 0, JSON.stringify(receipt));++ await evaluate(browser, sessionId, `(function () {+ document.getElementById('btn-semantic-lens').click();+ document.getElementById('btn-overview-map').click();+ })()`);+ await waitForLayout(browser, sessionId);+ receipt = await finalGeometry(browser, sessionId);+ assert.equal(receipt.legendRadarIntersectionArea, 0, JSON.stringify(receipt));+ assert.equal(receipt.navRadarIntersectionArea, 0, JSON.stringify(receipt));+ } finally {+ await browser.close();+ }+});++test('mobile, embed, hidden Legend, and print keep reserve at zero', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const browser = new ChromeVisualBrowser(chromePath);+ try {+ let sessionId = await load(browser, render('architecture', CASES.architecture), { width: 720, height: 900 });+ let receipt = await finalGeometry(browser, sessionId);+ assert.equal(receipt.reserve, 0, `mobile: ${JSON.stringify(receipt)}`);+ assert.equal(receipt.legendDockIntersectionArea, 0, `mobile: ${JSON.stringify(receipt)}`);++ sessionId = await load(browser, render('architecture', CASES.architecture), { query: '?embed=1' });+ receipt = await finalGeometry(browser, sessionId);+ assert.equal(receipt.reserve, 0, `embed: ${JSON.stringify(receipt)}`);++ sessionId = await load(browser, render('architecture', CASES.architecture));+ await evaluate(browser, sessionId, `(function () {+ document.querySelector('[data-legend]').hidden = true;+ window.dispatchEvent(new Event('resize'));+ })()`);+ await waitForLayout(browser, sessionId);+ receipt = await finalGeometry(browser, sessionId);+ assert.equal(receipt.reserve, 0, `hidden: ${JSON.stringify(receipt)}`);++ await browser.cdp.send('Emulation.setEmulatedMedia', { media: 'print' }, sessionId);+ await waitForLayout(browser, sessionId);+ receipt = await finalGeometry(browser, sessionId);+ assert.equal(receipt.reserve, 0, `print: ${JSON.stringify(receipt)}`);+ } finally {+ await browser.close();+ }+});++process.on('exit', () => fs.rmSync(tmp, { recursive: true, force: true }));diff --git a/archify/test/visual-check.test.mjs b/archify/test/visual-check.test.mjsindex 9971a19a..0c531ffe 100644--- a/archify/test/visual-check.test.mjs+++ b/archify/test/visual-check.test.mjs@@ -31,7 +31,7 @@ function sha256(file) {return createHash('sha256').update(fs.readFileSync(file)).digest('hex');}-function fakeBrowser({ overflowAt, unreadableAt, screenshotFailure } = {}) {+function fakeBrowser({ overflowAt, unreadableAt, chromeCollisionAt, screenshotFailure } = {}) {const calls = [];return {calls,@@ -43,6 +43,7 @@ function fakeBrowser({ overflowAt, unreadableAt, screenshotFailure } = {}) {if (screenshotPath) fs.writeFileSync(screenshotPath, png);const overflow = overflowAt?.({ width, height, theme }) || false;const unreadable = unreadableAt?.({ width, height, theme }) || false;+ const chromeCollision = chromeCollisionAt?.({ width, height, theme }) || false;return {innerWidth: width,innerHeight: height,@@ -55,6 +56,11 @@ function fakeBrowser({ overflowAt, unreadableAt, screenshotFailure } = {}) {minimumProjectedNodeTextPx: unreadable ? 5.72 : 6.44,minimumProjectedNodeText: unreadable ? 'Compact node' : 'Readable node',minimumProjectedNodeTextDetail: unreadable ? 'primary' : 'context',+ hasLegend: true,+ hasNavigationDock: true,+ legendDockIntersectionArea: chromeCollision ? 42 : 0,+ viewerChromeReserve: chromeCollision ? 0 : 44,+ viewerChromeActive: !chromeCollision,};},async close() {},@@ -165,6 +171,7 @@ test('visual-check records four containment viewports and four endpoint theme caassert.equal(result.exitCode, 0);assert.equal(result.receipt.status, 'pass');assert.equal(result.receipt.visualReview, 'pending');+ assert.equal(result.receipt.viewerChrome.status, 'pass');assert.equal(result.receipt.containment.viewports.length, VISUAL_CHECK_VIEWPORTS.length);assert.equal(result.receipt.containment.viewports.every((entry) => entry.ok), true);assert.deepEqual(@@ -232,6 +239,28 @@ test('visual-check returns 1 when the real reader projects node text below 6px',assert.equal(desktop?.readabilityOk, false);});+test('visual-check returns 1 when the navigation dock obscures the SVG legend', async () => {+ const input = artifact('viewer-chrome-collision.html');+ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser({+ chromeCollisionAt: ({ width, height, theme }) => (+ width === 1920 && height === 1080 && theme === 'light'+ ),+ }),+ });++ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.status, 'fail');+ assert.equal(result.receipt.viewerChrome.status, 'fail');+ const desktop = result.receipt.viewerChrome.viewports.find(+ (entry) => entry.width === 1920 && entry.height === 1080,+ );+ assert.equal(desktop?.legendDockIntersectionArea, 42);+ assert.equal(desktop?.viewerChromeOk, false);+});+test('visual-check returns 1 and removes misleading capture sidecars on screenshot failure', async () => {const input = artifact('capture-failure.html');const outputs = sidecarPaths(input);@@ -265,6 +294,7 @@ test('visual-check returns 2 with a truthful skipped receipt when Chrome is unavassert.equal(result.exitCode, 2);assert.equal(result.receipt.status, 'skipped');assert.equal(result.receipt.containment.status, 'skipped');+ assert.equal(result.receipt.viewerChrome.status, 'skipped');assert.equal(result.receipt.captures.status, 'skipped');assert.equal(result.receipt.visualReview, 'pending');assert.equal(fs.existsSync(sidecarPaths(input).receipt), true);diff --git a/docs/assets/archify-live-proof.json b/docs/assets/archify-live-proof.jsonindex 2c0193b2..40bb3287 100644--- a/docs/assets/archify-live-proof.json+++ b/docs/assets/archify-live-proof.json@@ -13,7 +13,7 @@{"id": "signal-flow","artifact": "docs/gallery/artifacts/agent-tool-call.workflow.html",- "artifactSha256": "efde3cb66601c0cbfaf1243015370db9dd9a47f062d7abb5442b68c46fc6174b",+ "artifactSha256": "1bd86d288342e5d8ccbc92e5671171195f581e7aa2b0e477d557a5b6924f2647","view": "happy-path","eyebrow": "WORKFLOW · SIGNAL FLOW","title": "Agent Tool Call",@@ -22,7 +22,7 @@{"id": "blueprint","artifact": "docs/gallery/artifacts/production-deployment.architecture.html",- "artifactSha256": "b37cb56052b3e5c8f58040227c40b02dba80079ac5dedcfef2d34202e586b9f6",+ "artifactSha256": "ad4901d2f507cef6a8692e199a06334780cf1ef13176f4656bb2a2a08faf2808","view": "request-boundary","eyebrow": "ARCHITECTURE · BLUEPRINT","title": "Production Deployment",@@ -31,7 +31,7 @@{"id": "classic","artifact": "docs/gallery/artifacts/cache-miss.sequence.html",- "artifactSha256": "ddb51bfbbeb7f64f8b427a590c417f8cae34766240ad3e985920095ea691e50f",+ "artifactSha256": "2056359a30ffae1948874761fcbcbdc2401062584008681c18565d56310c028d","view": "cache-fallback","eyebrow": "SEQUENCE · CLASSIC","title": "Cache Miss Request",diff --git a/docs/gallery.html b/docs/gallery.htmlindex 9490c94f..7a65f3d1 100644--- a/docs/gallery.html+++ b/docs/gallery.html@@ -339,7 +339,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">12N · 11E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="efde3cb66601c0cbfaf1243015370db9dd9a47f062d7abb5442b68c46fc6174b">efde3cb66601</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="1bd86d288342e5d8ccbc92e5671171195f581e7aa2b0e477d557a5b6924f2647">1bd86d288342</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/agent-tool-call.workflow.html?present=1&play=1#view=happy-path" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -369,7 +369,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">12N · 12E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="b37cb56052b3e5c8f58040227c40b02dba80079ac5dedcfef2d34202e586b9f6">b37cb56052b3</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="ad4901d2f507cef6a8692e199a06334780cf1ef13176f4656bb2a2a08faf2808">ad4901d2f507</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/production-deployment.architecture.html?present=1&play=1#view=request-boundary" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -398,7 +398,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">7N · 12E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="ddb51bfbbeb7f64f8b427a590c417f8cae34766240ad3e985920095ea691e50f">ddb51bfbbeb7</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="2056359a30ffae1948874761fcbcbdc2401062584008681c18565d56310c028d">2056359a30ff</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/cache-miss.sequence.html?present=1&play=1#view=cache-fallback" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -427,7 +427,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">10N · 10E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="d6eca6db2807d709dac5e1019f0a59b0719dee53d890192dda9b0672afff287c">d6eca6db2807</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="e57652c5d56168774c3133ad7864adda2bd9a1195b6672ad49e2c55da12497c2">e57652c5d561</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/release-delivery.workflow.html?present=1&play=1#view=approval-to-production" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -456,7 +456,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">11N · 10E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="2bf86a5f3355b6a44210a39aee8690b39536b03b56920f6fa52f5809b8a93ac1">2bf86a5f3355</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="b4050780e9e2e9fe567ea34fb8b10412f667da0d66b4fc31730e222964ba1a03">b4050780e9e2</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/incident-response.workflow.html?present=1&play=1#view=mitigate-and-verify" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -485,7 +485,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">10N · 10E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="17fbc96ad3aa79214da2333fe20ed508084e48a26e6193d20acbf83795587665">17fbc96ad3aa</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="26aaa3815bffa920a5f28a7ca034880ef49e7a099fc190aa52ab771356c91db2">26aaa3815bff</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/product-analytics.dataflow.html?present=1&play=1#view=consent-boundary" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -514,7 +514,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">7N · 14E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="2bc264bf59c59828b5174db31f06a77bf8b053f8f8c5eb0737c38be63b4949c2">2bc264bf59c5</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="9f7c01124c11ceee6eeb28b66cafea2595da9d491a28aca92897bf057baf74d9">9f7c01124c11</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/async-job-roundtrip.sequence.html?present=1&play=1#view=work-and-retry" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -543,7 +543,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">12N · 12E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="9294f98104336d31cf70988cb3748d28b53bdb0b30567a25853c93e57d21dd0a">9294f9810433</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="45475994137e2ec4791067d7a78d38441e4a968e7957ecadcd0f2071e3be90af">45475994137e</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/event-stream.dataflow.html?present=1&play=1#view=order-transit" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -572,7 +572,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">10N · 6E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="dd8222b55435a49403057a96d6bd4894f082ea09f783f73546022fc3b71330e7">dd8222b55435</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="f5ecaa6f9852be1324ae68352ca6f637590c0a0d1681afa4fcbae95d66f4db7a">f5ecaa6f9852</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/agent-run.lifecycle.html?present=1&play=1#view=main-lifecycle" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -601,7 +601,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">11N · 6E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="bf47d297d4d0c69b435deb9a2dc1a9e40d1de7338bdd0453baa97657bf28c976">bf47d297d4d0</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="ead5d13c9c75003785bd1cd499d748d405887fc74a54e3d6d952063595f2c6f0">ead5d13c9c75</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/deployment-release.lifecycle.html?present=1&play=1#view=rollback-outcomes" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -630,7 +630,7 @@<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">9/9 pass</span></div><div class="receipt-cell"><span class="receipt-label">Composition</span><span class="receipt-value ok" title="0 crossings · 0 border runs · 0 micro segments · 0 cramped turns">SHOWCASE · PASS</span></div><div class="receipt-cell"><span class="receipt-label">Graph</span><span class="receipt-value">10N · 9E</span></div>- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="a73b9d6c003cadc6fa93d520a817fffcb0fba8a1c5aa57922c071186c48e00f7">a73b9d6c003c</span></div>+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="7b91e4febd662a633f0754930dc34e91db692225d3cd7504ff6c5c01ed9bb86b">7b91e4febd66</span></div></div><div class="card-actions"><a class="card-link primary" href="gallery/artifacts/web-app.architecture.html?present=1&play=1#view=request-path" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>@@ -716,8 +716,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 12,"edgeCount": 11,- "artifactBytes": 647987,- "artifactSha256": "efde3cb66601c0cbfaf1243015370db9dd9a47f062d7abb5442b68c46fc6174b",+ "artifactBytes": 658874,+ "artifactSha256": "1bd86d288342e5d8ccbc92e5671171195f581e7aa2b0e477d557a5b6924f2647","sourceBytes": 6367,"sourceSha256": "9c94c8c0b2104478b77befb4cc5e343d381acba6e66645ab17616fde20b60e05","checks": [@@ -816,8 +816,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": "deployment-ownership","nodeCount": 12,"edgeCount": 12,- "artifactBytes": 652388,- "artifactSha256": "b37cb56052b3e5c8f58040227c40b02dba80079ac5dedcfef2d34202e586b9f6",+ "artifactBytes": 663275,+ "artifactSha256": "ad4901d2f507cef6a8692e199a06334780cf1ef13176f4656bb2a2a08faf2808","sourceBytes": 5476,"sourceSha256": "ec484aa8576664fdb207b543fa49486b23273faccb7a5071e1a0becfb48c22eb","checks": [@@ -916,8 +916,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 7,"edgeCount": 12,- "artifactBytes": 644404,- "artifactSha256": "ddb51bfbbeb7f64f8b427a590c417f8cae34766240ad3e985920095ea691e50f",+ "artifactBytes": 655291,+ "artifactSha256": "2056359a30ffae1948874761fcbcbdc2401062584008681c18565d56310c028d","sourceBytes": 4345,"sourceSha256": "4bbaa6ca3cd4036002fd5d0f3a332eb922cec69d09bac3d7925f95beb4308389","checks": [@@ -1016,8 +1016,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 10,"edgeCount": 10,- "artifactBytes": 646779,- "artifactSha256": "d6eca6db2807d709dac5e1019f0a59b0719dee53d890192dda9b0672afff287c",+ "artifactBytes": 657666,+ "artifactSha256": "e57652c5d56168774c3133ad7864adda2bd9a1195b6672ad49e2c55da12497c2","sourceBytes": 5164,"sourceSha256": "e5c880417eac1623923c3dd5461e0c78acd762e1621a28bd53fc14a84cad6a91","checks": [@@ -1116,8 +1116,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 11,"edgeCount": 10,- "artifactBytes": 644108,- "artifactSha256": "2bf86a5f3355b6a44210a39aee8690b39536b03b56920f6fa52f5809b8a93ac1",+ "artifactBytes": 654995,+ "artifactSha256": "b4050780e9e2e9fe567ea34fb8b10412f667da0d66b4fc31730e222964ba1a03","sourceBytes": 5375,"sourceSha256": "5c760c82eee545dfb7da38a4e628059d7891af4cfbfc13c8a7009ea64f69aa1b","checks": [@@ -1216,8 +1216,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 10,"edgeCount": 10,- "artifactBytes": 648037,- "artifactSha256": "17fbc96ad3aa79214da2333fe20ed508084e48a26e6193d20acbf83795587665",+ "artifactBytes": 658924,+ "artifactSha256": "26aaa3815bffa920a5f28a7ca034880ef49e7a099fc190aa52ab771356c91db2","sourceBytes": 5627,"sourceSha256": "6fa38a7ccedf96da592d60b392783b846188eaa3ec9136c6dc06ca020e43a110","checks": [@@ -1316,8 +1316,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 7,"edgeCount": 14,- "artifactBytes": 644814,- "artifactSha256": "2bc264bf59c59828b5174db31f06a77bf8b053f8f8c5eb0737c38be63b4949c2",+ "artifactBytes": 655701,+ "artifactSha256": "9f7c01124c11ceee6eeb28b66cafea2595da9d491a28aca92897bf057baf74d9","sourceBytes": 4370,"sourceSha256": "545f20920c89b69c2bb1f15508d5543fddbeb15cffba61e102206e04bd5a5cd9","checks": [@@ -1416,8 +1416,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 12,"edgeCount": 12,- "artifactBytes": 651988,- "artifactSha256": "9294f98104336d31cf70988cb3748d28b53bdb0b30567a25853c93e57d21dd0a",+ "artifactBytes": 662875,+ "artifactSha256": "45475994137e2ec4791067d7a78d38441e4a968e7957ecadcd0f2071e3be90af","sourceBytes": 5433,"sourceSha256": "a92d6597ddbe164f395da32a7d4b33cfae08edd7d9600a6fb45a2058e5bbb43e","checks": [@@ -1516,8 +1516,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 10,"edgeCount": 6,- "artifactBytes": 641672,- "artifactSha256": "dd8222b55435a49403057a96d6bd4894f082ea09f783f73546022fc3b71330e7",+ "artifactBytes": 652559,+ "artifactSha256": "f5ecaa6f9852be1324ae68352ca6f637590c0a0d1681afa4fcbae95d66f4db7a","sourceBytes": 4417,"sourceSha256": "af939579dcafc8b4c49f09594591577994398aee57a57369d4c791dfc0d85a42","checks": [@@ -1616,8 +1616,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 11,"edgeCount": 6,- "artifactBytes": 642658,- "artifactSha256": "bf47d297d4d0c69b435deb9a2dc1a9e40d1de7338bdd0453baa97657bf28c976",+ "artifactBytes": 653545,+ "artifactSha256": "ead5d13c9c75003785bd1cd499d748d405887fc74a54e3d6d952063595f2c6f0","sourceBytes": 4274,"sourceSha256": "735c2c5819266e6ea2a71775b6eefce98b53030ce90cb721dc8e1d022ce5be71","checks": [@@ -1716,8 +1716,8 @@ receipt 99 checks / 11 artifacts / deterministic hashes</pre>"engineeringProfile": null,"nodeCount": 10,"edgeCount": 9,- "artifactBytes": 642750,- "artifactSha256": "a73b9d6c003cadc6fa93d520a817fffcb0fba8a1c5aa57922c071186c48e00f7",+ "artifactBytes": 653637,+ "artifactSha256": "7b91e4febd662a633f0754930dc34e91db692225d3cd7504ff6c5c01ed9bb86b","sourceBytes": 3793,"sourceSha256": "483350f5297df682aba4e4a0fa491307ce3d3abd725ae4df07fab177490752cf","checks": [diff --git a/docs/gallery/artifacts/agent-run.lifecycle.html b/docs/gallery/artifacts/agent-run.lifecycle.htmlindex 3200c804..70742acd 100644--- a/docs/gallery/artifacts/agent-run.lifecycle.html+++ b/docs/gallery/artifacts/agent-run.lifecycle.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10531,6 +10538,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10668,40 +10715,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10729,6 +10747,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10834,6 +11055,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10946,6 +11170,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11303,7 +11530,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13190,7 +13423,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13203,6 +13436,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/agent-tool-call.workflow.html b/docs/gallery/artifacts/agent-tool-call.workflow.htmlindex bc6acb85..41c328fb 100644--- a/docs/gallery/artifacts/agent-tool-call.workflow.html+++ b/docs/gallery/artifacts/agent-tool-call.workflow.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10579,6 +10586,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10716,40 +10763,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10777,6 +10795,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10882,6 +11103,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10994,6 +11218,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11351,7 +11578,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13238,7 +13471,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13251,6 +13484,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/async-job-roundtrip.sequence.html b/docs/gallery/artifacts/async-job-roundtrip.sequence.htmlindex c54a756d..fd0ce931 100644--- a/docs/gallery/artifacts/async-job-roundtrip.sequence.html+++ b/docs/gallery/artifacts/async-job-roundtrip.sequence.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10609,6 +10616,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10746,40 +10793,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10807,6 +10825,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10912,6 +11133,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -11024,6 +11248,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11381,7 +11608,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13268,7 +13501,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13281,6 +13514,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/cache-miss.sequence.html b/docs/gallery/artifacts/cache-miss.sequence.htmlindex ae9d189f..802dccfd 100644--- a/docs/gallery/artifacts/cache-miss.sequence.html+++ b/docs/gallery/artifacts/cache-miss.sequence.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10597,6 +10604,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10734,40 +10781,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10795,6 +10813,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10900,6 +11121,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -11012,6 +11236,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11369,7 +11596,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13256,7 +13489,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13269,6 +13502,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/deployment-release.lifecycle.html b/docs/gallery/artifacts/deployment-release.lifecycle.htmlindex ef494f25..0dc90dbb 100644--- a/docs/gallery/artifacts/deployment-release.lifecycle.html+++ b/docs/gallery/artifacts/deployment-release.lifecycle.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10543,6 +10550,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10680,40 +10727,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10741,6 +10759,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10846,6 +11067,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10958,6 +11182,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11315,7 +11542,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13202,7 +13435,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13215,6 +13448,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/event-stream.dataflow.html b/docs/gallery/artifacts/event-stream.dataflow.htmlindex a6f33569..28ef8d49 100644--- a/docs/gallery/artifacts/event-stream.dataflow.html+++ b/docs/gallery/artifacts/event-stream.dataflow.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10621,6 +10628,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10758,40 +10805,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10819,6 +10837,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10924,6 +11145,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -11036,6 +11260,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11393,7 +11620,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13280,7 +13513,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13293,6 +13526,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/incident-response.workflow.html b/docs/gallery/artifacts/incident-response.workflow.htmlindex f1233b99..fc84515a 100644--- a/docs/gallery/artifacts/incident-response.workflow.html+++ b/docs/gallery/artifacts/incident-response.workflow.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10548,6 +10555,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10685,40 +10732,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10746,6 +10764,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10851,6 +11072,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10963,6 +11187,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11320,7 +11547,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13207,7 +13440,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13220,6 +13453,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/product-analytics.dataflow.html b/docs/gallery/artifacts/product-analytics.dataflow.htmlindex 57e151b0..2ba52bf5 100644--- a/docs/gallery/artifacts/product-analytics.dataflow.html+++ b/docs/gallery/artifacts/product-analytics.dataflow.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10582,6 +10589,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10719,40 +10766,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10780,6 +10798,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10885,6 +11106,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10997,6 +11221,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11354,7 +11581,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13241,7 +13474,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13254,6 +13487,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/production-deployment.architecture.html b/docs/gallery/artifacts/production-deployment.architecture.htmlindex d2d1c723..bd49167b 100644--- a/docs/gallery/artifacts/production-deployment.architecture.html+++ b/docs/gallery/artifacts/production-deployment.architecture.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10613,6 +10620,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10750,40 +10797,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10811,6 +10829,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10916,6 +11137,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -11028,6 +11252,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11385,7 +11612,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13272,7 +13505,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13285,6 +13518,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/release-delivery.workflow.html b/docs/gallery/artifacts/release-delivery.workflow.htmlindex a148890b..e5174245 100644--- a/docs/gallery/artifacts/release-delivery.workflow.html+++ b/docs/gallery/artifacts/release-delivery.workflow.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10574,6 +10581,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10711,40 +10758,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10772,6 +10790,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10877,6 +11098,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10989,6 +11213,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11346,7 +11573,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13233,7 +13466,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13246,6 +13479,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/artifacts/web-app.architecture.html b/docs/gallery/artifacts/web-app.architecture.htmlindex 7bc5a4f8..a1588db3 100644--- a/docs/gallery/artifacts/web-app.architecture.html+++ b/docs/gallery/artifacts/web-app.architecture.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10546,6 +10553,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10683,40 +10730,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10744,6 +10762,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10849,6 +11070,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10961,6 +11185,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11318,7 +11545,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13205,7 +13438,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13218,6 +13451,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/docs/gallery/manifest.json b/docs/gallery/manifest.jsonindex 0d8de502..66f3ba85 100644--- a/docs/gallery/manifest.json+++ b/docs/gallery/manifest.json@@ -27,8 +27,8 @@"engineeringProfile": null,"nodeCount": 12,"edgeCount": 11,- "artifactBytes": 647987,- "artifactSha256": "efde3cb66601c0cbfaf1243015370db9dd9a47f062d7abb5442b68c46fc6174b",+ "artifactBytes": 658874,+ "artifactSha256": "1bd86d288342e5d8ccbc92e5671171195f581e7aa2b0e477d557a5b6924f2647","sourceBytes": 6367,"sourceSha256": "9c94c8c0b2104478b77befb4cc5e343d381acba6e66645ab17616fde20b60e05","checks": [@@ -127,8 +127,8 @@"engineeringProfile": "deployment-ownership","nodeCount": 12,"edgeCount": 12,- "artifactBytes": 652388,- "artifactSha256": "b37cb56052b3e5c8f58040227c40b02dba80079ac5dedcfef2d34202e586b9f6",+ "artifactBytes": 663275,+ "artifactSha256": "ad4901d2f507cef6a8692e199a06334780cf1ef13176f4656bb2a2a08faf2808","sourceBytes": 5476,"sourceSha256": "ec484aa8576664fdb207b543fa49486b23273faccb7a5071e1a0becfb48c22eb","checks": [@@ -227,8 +227,8 @@"engineeringProfile": null,"nodeCount": 7,"edgeCount": 12,- "artifactBytes": 644404,- "artifactSha256": "ddb51bfbbeb7f64f8b427a590c417f8cae34766240ad3e985920095ea691e50f",+ "artifactBytes": 655291,+ "artifactSha256": "2056359a30ffae1948874761fcbcbdc2401062584008681c18565d56310c028d","sourceBytes": 4345,"sourceSha256": "4bbaa6ca3cd4036002fd5d0f3a332eb922cec69d09bac3d7925f95beb4308389","checks": [@@ -327,8 +327,8 @@"engineeringProfile": null,"nodeCount": 10,"edgeCount": 10,- "artifactBytes": 646779,- "artifactSha256": "d6eca6db2807d709dac5e1019f0a59b0719dee53d890192dda9b0672afff287c",+ "artifactBytes": 657666,+ "artifactSha256": "e57652c5d56168774c3133ad7864adda2bd9a1195b6672ad49e2c55da12497c2","sourceBytes": 5164,"sourceSha256": "e5c880417eac1623923c3dd5461e0c78acd762e1621a28bd53fc14a84cad6a91","checks": [@@ -427,8 +427,8 @@"engineeringProfile": null,"nodeCount": 11,"edgeCount": 10,- "artifactBytes": 644108,- "artifactSha256": "2bf86a5f3355b6a44210a39aee8690b39536b03b56920f6fa52f5809b8a93ac1",+ "artifactBytes": 654995,+ "artifactSha256": "b4050780e9e2e9fe567ea34fb8b10412f667da0d66b4fc31730e222964ba1a03","sourceBytes": 5375,"sourceSha256": "5c760c82eee545dfb7da38a4e628059d7891af4cfbfc13c8a7009ea64f69aa1b","checks": [@@ -527,8 +527,8 @@"engineeringProfile": null,"nodeCount": 10,"edgeCount": 10,- "artifactBytes": 648037,- "artifactSha256": "17fbc96ad3aa79214da2333fe20ed508084e48a26e6193d20acbf83795587665",+ "artifactBytes": 658924,+ "artifactSha256": "26aaa3815bffa920a5f28a7ca034880ef49e7a099fc190aa52ab771356c91db2","sourceBytes": 5627,"sourceSha256": "6fa38a7ccedf96da592d60b392783b846188eaa3ec9136c6dc06ca020e43a110","checks": [@@ -627,8 +627,8 @@"engineeringProfile": null,"nodeCount": 7,"edgeCount": 14,- "artifactBytes": 644814,- "artifactSha256": "2bc264bf59c59828b5174db31f06a77bf8b053f8f8c5eb0737c38be63b4949c2",+ "artifactBytes": 655701,+ "artifactSha256": "9f7c01124c11ceee6eeb28b66cafea2595da9d491a28aca92897bf057baf74d9","sourceBytes": 4370,"sourceSha256": "545f20920c89b69c2bb1f15508d5543fddbeb15cffba61e102206e04bd5a5cd9","checks": [@@ -727,8 +727,8 @@"engineeringProfile": null,"nodeCount": 12,"edgeCount": 12,- "artifactBytes": 651988,- "artifactSha256": "9294f98104336d31cf70988cb3748d28b53bdb0b30567a25853c93e57d21dd0a",+ "artifactBytes": 662875,+ "artifactSha256": "45475994137e2ec4791067d7a78d38441e4a968e7957ecadcd0f2071e3be90af","sourceBytes": 5433,"sourceSha256": "a92d6597ddbe164f395da32a7d4b33cfae08edd7d9600a6fb45a2058e5bbb43e","checks": [@@ -827,8 +827,8 @@"engineeringProfile": null,"nodeCount": 10,"edgeCount": 6,- "artifactBytes": 641672,- "artifactSha256": "dd8222b55435a49403057a96d6bd4894f082ea09f783f73546022fc3b71330e7",+ "artifactBytes": 652559,+ "artifactSha256": "f5ecaa6f9852be1324ae68352ca6f637590c0a0d1681afa4fcbae95d66f4db7a","sourceBytes": 4417,"sourceSha256": "af939579dcafc8b4c49f09594591577994398aee57a57369d4c791dfc0d85a42","checks": [@@ -927,8 +927,8 @@"engineeringProfile": null,"nodeCount": 11,"edgeCount": 6,- "artifactBytes": 642658,- "artifactSha256": "bf47d297d4d0c69b435deb9a2dc1a9e40d1de7338bdd0453baa97657bf28c976",+ "artifactBytes": 653545,+ "artifactSha256": "ead5d13c9c75003785bd1cd499d748d405887fc74a54e3d6d952063595f2c6f0","sourceBytes": 4274,"sourceSha256": "735c2c5819266e6ea2a71775b6eefce98b53030ce90cb721dc8e1d022ce5be71","checks": [@@ -1027,8 +1027,8 @@"engineeringProfile": null,"nodeCount": 10,"edgeCount": 9,- "artifactBytes": 642750,- "artifactSha256": "a73b9d6c003cadc6fa93d520a817fffcb0fba8a1c5aa57922c071186c48e00f7",+ "artifactBytes": 653637,+ "artifactSha256": "7b91e4febd662a633f0754930dc34e91db692225d3cd7504ff6c5c01ed9bb86b","sourceBytes": 3793,"sourceSha256": "483350f5297df682aba4e4a0fa491307ce3d3abd725ae4df07fab177490752cf","checks": [diff --git a/examples/dataflow-product-analytics.html b/examples/dataflow-product-analytics.htmlindex 57e151b0..2ba52bf5 100644--- a/examples/dataflow-product-analytics.html+++ b/examples/dataflow-product-analytics.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10582,6 +10589,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10719,40 +10766,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10780,6 +10798,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10885,6 +11106,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10997,6 +11221,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11354,7 +11581,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13241,7 +13474,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13254,6 +13487,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/examples/lifecycle-agent-run.html b/examples/lifecycle-agent-run.htmlindex 3200c804..70742acd 100644--- a/examples/lifecycle-agent-run.html+++ b/examples/lifecycle-agent-run.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10531,6 +10538,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10668,40 +10715,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10729,6 +10747,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10834,6 +11055,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10946,6 +11170,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11303,7 +11530,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13190,7 +13423,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13203,6 +13436,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/examples/sequence-cache-miss-request.html b/examples/sequence-cache-miss-request.htmlindex ae9d189f..802dccfd 100644--- a/examples/sequence-cache-miss-request.html+++ b/examples/sequence-cache-miss-request.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10597,6 +10604,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10734,40 +10781,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10795,6 +10813,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10900,6 +11121,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -11012,6 +11236,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11369,7 +11596,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13256,7 +13489,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13269,6 +13502,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/examples/web-app-rendered.html b/examples/web-app-rendered.htmlindex 7bc5a4f8..a1588db3 100644--- a/examples/web-app-rendered.html+++ b/examples/web-app-rendered.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10546,6 +10553,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10683,40 +10730,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10744,6 +10762,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10849,6 +11070,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10961,6 +11185,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11318,7 +11545,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13205,7 +13438,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13218,6 +13451,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/examples/web-app.html b/examples/web-app.htmlindex 7bc5a4f8..a1588db3 100644--- a/examples/web-app.html+++ b/examples/web-app.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10546,6 +10553,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10683,40 +10730,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10744,6 +10762,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10849,6 +11070,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10961,6 +11185,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11318,7 +11545,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13205,7 +13438,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13218,6 +13451,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;diff --git a/examples/workflow-agent-tool-call-rendered.html b/examples/workflow-agent-tool-call-rendered.htmlindex bc6acb85..41c328fb 100644--- a/examples/workflow-agent-tool-call-rendered.html+++ b/examples/workflow-agent-tool-call-rendered.html@@ -586,6 +586,7 @@justify-content: center;min-height: 0;padding: 0.75rem;+ padding-bottom: calc(0.75rem + var(--archify-nav-reserve));}html[data-present="true"]:not([data-embed="true"]) .diagram-container > svg {width: 100%;@@ -722,10 +723,12 @@}.diagram-container {+ --archify-nav-reserve: 0px;background: var(--panel);border-radius: 1rem;border: 1px solid var(--panel-border);padding: 1.5rem;+ padding-bottom: calc(1.5rem + var(--archify-nav-reserve));overflow: hidden;position: relative;}@@ -1052,7 +1055,7 @@.overview-map {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 12;width: 11.25rem;overflow: hidden;@@ -1226,7 +1229,7 @@.semantic-lens {position: absolute;right: 1rem;- bottom: 4.15rem;+ bottom: calc(4.15rem + var(--archify-nav-reserve));z-index: 24;width: min(20rem, calc(100% - 2rem));overflow: hidden;@@ -1401,7 +1404,7 @@.route-probe {position: absolute;left: 1rem;- bottom: 1rem;+ bottom: calc(1rem + var(--archify-nav-reserve));z-index: 12;width: min(46rem, calc(100% - 25rem));min-width: 18rem;@@ -2800,7 +2803,10 @@scrolling at 900–1080px heights. */@media (min-width: 768px) and (max-height: 1100px) {.header { margin-bottom: 1rem; }- .diagram-container { padding: 0.875rem; }+ .diagram-container {+ padding: 0.875rem;+ padding-bottom: calc(0.875rem + var(--archify-nav-reserve));+ }.cards { margin-top: 1rem; }.card { padding: 1rem; }}@@ -2922,6 +2928,7 @@svg[data-chapter-preview] [data-node-id],svg[data-chapter-preview] [data-edge-from] { opacity: 1 !important; filter: none !important; }.diagram-container, .card { box-shadow: none; border-color: #e2e8f0; }+ .diagram-container { --archify-nav-reserve: 0px !important; }html[data-preset="signal-flow"] .diagram-container,html[data-preset="signal-flow"] .card { background: #ffffff; }.cards { grid-template-columns: 1fr 1fr; }@@ -10579,6 +10586,46 @@embed, presentation, print, and non-wide diagrams retain their ownestablished layout contracts.============================================================ */+ Archify.waitForStableLayout = function (options) {+ options = options || {};+ var maximumFrames = Math.max(1, Number(options.maximumFrames) || 240);+ var fontsReady = document.fonts && document.fonts.ready+ ? document.fonts.ready.catch(function () {})+ : Promise.resolve();+ return fontsReady.then(function () {+ if (typeof options.schedule === 'function') options.schedule();+ return new Promise(function (resolve, reject) {+ var previous = '';+ var stableFrames = 0;+ var sampledFrames = 0;+ function sample() {+ sampledFrames += 1;+ if (typeof options.pending === 'function' && options.pending()) {+ previous = '';+ stableFrames = 0;+ } else {+ var current = typeof options.snapshot === 'function' ? options.snapshot() : '';+ if (current === previous) stableFrames += 1;+ else {+ previous = current;+ stableFrames = 0;+ }+ if (stableFrames >= 3) {+ resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });+ return;+ }+ }+ if (sampledFrames >= maximumFrames) {+ reject(new Error(options.timeoutMessage || 'Layout did not reach stable dimensions.'));+ return;+ }+ requestAnimationFrame(sample);+ }+ requestAnimationFrame(sample);+ });+ });+ };+Archify.readerLayout = (function () {var html = document.documentElement;var body = document.body;@@ -10716,40 +10763,11 @@].join('|');}function whenStable() {- var fontsReady = document.fonts && document.fonts.ready- ? document.fonts.ready.catch(function () {})- : Promise.resolve();- return fontsReady.then(function () {- schedule();- return new Promise(function (resolve, reject) {- var previous = '';- var stableFrames = 0;- var sampledFrames = 0;- function sample() {- sampledFrames += 1;- if (frame || settleFrame) {- previous = '';- stableFrames = 0;- } else {- var current = stableSnapshot();- if (current === previous) stableFrames += 1;- else {- previous = current;- stableFrames = 0;- }- if (stableFrames >= 3) {- resolve({ stable: true, snapshot: current, sampledFrames: sampledFrames });- return;- }- }- if (sampledFrames >= 240) {- reject(new Error('Adaptive reader layout did not reach stable dimensions.'));- return;- }- requestAnimationFrame(sample);- }- requestAnimationFrame(sample);- });+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Adaptive reader layout did not reach stable dimensions.'});}@@ -10777,6 +10795,209 @@};})();+ /* ============================================================+ Viewer Chrome Layout — keep HTML controls clear of the canonical SVG+ legend without changing authored geometry. The dock keeps its existing+ position unless its zero-reserve position would cover the legend; only+ then does a small bottom safe rail become part of the reader budget.+ ============================================================ */+ Archify.viewerChromeLayout = (function () {+ var html = document.documentElement;+ var container = document.querySelector('.diagram-container');+ var svg = container && container.querySelector(':scope > svg');+ var nav = container && container.querySelector('.diagram-nav');+ var legend = svg && svg.querySelector('[data-legend]');+ var frame = 0;+ var settleFrame = 0;+ var reserve = 0;+ var collisionLatched = false;+ var probingBaseline = false;+ var probePromise = null;+ var baselineIntersectionArea = 0;+ var lastReceipt = null;+ var SAFE_GAP = 10;++ function visible(element) {+ if (!element || element.hidden) return false;+ var style = window.getComputedStyle(element);+ return style.display !== 'none' && style.visibility !== 'hidden';+ }+ function usable(rect) {+ return Boolean(rect && rect.width > 0 && rect.height > 0);+ }+ function intersectionArea(a, b) {+ var width = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));+ var height = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));+ return width * height;+ }+ function eligible() {+ return Boolean(+ container && svg && nav && legend &&+ window.innerWidth > 720 &&+ html.getAttribute('data-embed') !== 'true' &&+ (!window.matchMedia || !window.matchMedia('print').matches) &&+ visible(nav) && visible(legend)+ );+ }+ function writeReserve(next, options) {+ options = options || {};+ next = Math.max(0, Math.ceil(next));+ if (Math.abs(next - reserve) < 1) return false;+ reserve = next;+ if (reserve) {+ container.style.setProperty('--archify-nav-reserve', reserve + 'px');+ container.setAttribute('data-nav-safe-rail', 'true');+ } else {+ container.style.removeProperty('--archify-nav-reserve');+ container.removeAttribute('data-nav-safe-rail');+ }+ if (Archify.readerLayout && typeof Archify.readerLayout.schedule === 'function') {+ Archify.readerLayout.schedule();+ }+ if (options.quiet !== true) {+ if (settleFrame) cancelAnimationFrame(settleFrame);+ settleFrame = requestAnimationFrame(function () {+ settleFrame = 0;+ schedule();+ });+ }+ return true;+ }+ function clear() {+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: probingBaseline });+ lastReceipt = {+ eligible: false,+ active: false,+ reserve: 0,+ gap: SAFE_GAP,+ baselineIntersectionArea: 0,+ intersectionArea: 0+ };+ return lastReceipt;+ }+ function measure() {+ frame = 0;+ if (probingBaseline) return null;+ if (!eligible()) return clear();++ var navRect = nav.getBoundingClientRect();+ var legendRect = legend.getBoundingClientRect();+ var svgRect = svg.getBoundingClientRect();+ if (!usable(navRect) || !usable(legendRect) || !usable(svgRect)) return clear();++ var actualIntersectionArea = intersectionArea(navRect, legendRect);+ if (!collisionLatched && reserve === 0) {+ baselineIntersectionArea = actualIntersectionArea;+ if (actualIntersectionArea > 0) {+ collisionLatched = true;+ if (writeReserve(Math.max(0, svgRect.bottom + SAFE_GAP - navRect.top))) return null;+ }+ } else if (collisionLatched && reserve > 0 && actualIntersectionArea > 0) {+ /* Once zero-reserve geometry proves a collision, keep that decision+ latched while Adaptive Reader incorporates the rail. If the first+ rail is not quite tall enough (notably in Presentation flex+ layout), grow only by the remaining vertical overlap. */+ var remaining = Math.max(1, legendRect.bottom + SAFE_GAP - navRect.top);+ if (writeReserve(reserve + remaining)) return null;+ }++ navRect = nav.getBoundingClientRect();+ legendRect = legend.getBoundingClientRect();+ lastReceipt = {+ eligible: true,+ active: reserve > 0,+ reserve: reserve,+ gap: SAFE_GAP,+ baselineIntersectionArea: Math.round(baselineIntersectionArea * 100) / 100,+ intersectionArea: Math.round(intersectionArea(navRect, legendRect) * 100) / 100+ };+ return lastReceipt;+ }+ function reprobe() {+ if (probingBaseline) return probePromise || Promise.resolve(false);+ if (!reserve && !collisionLatched) {+ schedule();+ return Promise.resolve(false);+ }+ probingBaseline = true;+ collisionLatched = false;+ baselineIntersectionArea = 0;+ writeReserve(0, { quiet: true });+ var readerReady = Archify.readerLayout && typeof Archify.readerLayout.whenStable === 'function'+ ? Archify.readerLayout.whenStable().catch(function () {})+ : Promise.resolve();+ probePromise = readerReady.then(function () {+ probingBaseline = false;+ probePromise = null;+ schedule();+ return true;+ });+ return probePromise;+ }+ function schedule() {+ if (frame) return;+ frame = requestAnimationFrame(measure);+ }+ function stableSnapshot() {+ var containerRect = container ? container.getBoundingClientRect() : { width: 0, height: 0 };+ var navRect = nav ? nav.getBoundingClientRect() : { top: 0, left: 0 };+ var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };+ return [+ reserve,+ Math.round(containerRect.width * 100) / 100,+ Math.round(containerRect.height * 100) / 100,+ Math.round(navRect.left * 100) / 100,+ Math.round(navRect.top * 100) / 100,+ Math.round(legendRect.left * 100) / 100,+ Math.round(legendRect.top * 100) / 100,+ collisionLatched ? 'latched' : 'clear',+ lastReceipt ? lastReceipt.intersectionArea : ''+ ].join('|');+ }+ function whenStable() {+ return Archify.waitForStableLayout({+ schedule: schedule,+ pending: function () { return Boolean(frame || settleFrame || probingBaseline); },+ snapshot: stableSnapshot,+ timeoutMessage: 'Viewer chrome layout did not reach stable dimensions.'+ });+ }++ window.addEventListener('resize', reprobe, { passive: true });+ window.addEventListener('load', schedule, { once: true });+ window.addEventListener('beforeprint', schedule);+ window.addEventListener('afterprint', reprobe);+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(reprobe).catch(function () {});+ if (typeof ResizeObserver === 'function') {+ var resizeObserver = new ResizeObserver(schedule);+ [nav, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ }+ if (typeof MutationObserver === 'function') {+ var contentObserver = new MutationObserver(function (records) {+ var viewerModeChanged = records.some(function (record) { return record.target === html; });+ if (viewerModeChanged) reprobe();+ else schedule();+ });+ if (legend) contentObserver.observe(legend, { attributes: true, childList: true, subtree: true });+ contentObserver.observe(html, {+ attributes: true,+ attributeFilter: ['data-embed', 'data-present', 'data-preset', 'data-theme']+ });+ }+ schedule();++ return {+ measure: measure,+ schedule: schedule,+ reprobe: reprobe,+ whenStable: whenStable,+ active: function () { return reserve > 0; },+ receipt: function () { return lastReceipt || measure(); }+ };+ })();+Archify.view = (function () {var container = document.querySelector('.diagram-container');var svg = container.querySelector('svg');@@ -10882,6 +11103,9 @@container.classList.toggle('is-pannable', state.scale > 1);svg.setAttribute('data-view-scale', String(state.scale));if (Archify.radar && typeof Archify.radar.sync === 'function') Archify.radar.sync();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.schedule === 'function') {+ Archify.viewerChromeLayout.schedule();+ }}function sampleRenderedState() {var transform = '';@@ -10994,6 +11218,9 @@else stopCameraMotion('reset', false);state = { scale: 1, x: 0, y: 0, mode: 'overview' };apply();+ if (Archify.viewerChromeLayout && typeof Archify.viewerChromeLayout.reprobe === 'function') {+ Archify.viewerChromeLayout.reprobe();+ }}function centerAt(logicalX, logicalY, options) {options = options || {};@@ -11351,7 +11578,13 @@var panelRight = panelLeft + panel.offsetWidth;var lens = document.getElementById('focus-chip');var lensRect = lens && !lens.hidden ? lens.getBoundingClientRect() : null;- var blockers = [activeRect, lensRect].filter(function (rect) {+ var legend = diagram.querySelector('[data-legend]');+ var legendRect = legend && !legend.hidden && window.getComputedStyle(legend).display !== 'none'+ ? legend.getBoundingClientRect() : null;+ var nav = container.querySelector('.diagram-nav');+ var navRect = nav && !nav.hidden && window.getComputedStyle(nav).display !== 'none'+ ? nav.getBoundingClientRect() : null;+ var blockers = [activeRect, lensRect, legendRect, navRect].filter(function (rect) {return rect && rect.right > panelLeft && rect.left < panelRight;});var desiredTop = bottomLimit - panel.offsetHeight;@@ -13238,7 +13471,7 @@}function dockPanel(byId) {panel.removeAttribute('data-dock-side');- if (panel.hidden || !selectedKinds.length || window.innerWidth <= 720) return 'right';+ if (panel.hidden || window.innerWidth <= 720) return 'right';var panelRect = panel.getBoundingClientRect();var containerRect = container.getBoundingClientRect();if (!panelRect.width || !panelRect.height) return 'right';@@ -13251,6 +13484,17 @@var rightCandidate = { left: containerRect.right - 16 - width, right: containerRect.right - 16, top: top, bottom: panelRect.bottom };var leftScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(leftCandidate, rect); }, 0);var rightScore = selectedRects.reduce(function (score, rect) { return score + overlapArea(rightCandidate, rect); }, 0);+ var legend = svg.querySelector('[data-legend]');+ var nav = container.querySelector('.diagram-nav');+ var protectedRects = [legend, nav].filter(function (element) {+ return element && !element.hidden && window.getComputedStyle(element).display !== 'none';+ }).map(function (element) { return element.getBoundingClientRect(); });+ leftScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(leftCandidate, rect) * 1000;+ }, 0);+ rightScore += protectedRects.reduce(function (score, rect) {+ return score + overlapArea(rightCandidate, rect) * 1000;+ }, 0);var side = leftScore < rightScore ? 'left' : 'right';panel.setAttribute('data-dock-side', side);return side;