nextra-dgmo 0.5.12 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-render-LLERULDS.js → client-render-JZEXFLL4.js} +2 -2
- package/dist/{client-render-LLERULDS.js.map → client-render-JZEXFLL4.js.map} +1 -1
- package/dist/nextra-client.js +1 -1
- package/dist/nextra-client.js.map +1 -1
- package/dist/nextra-render-client.js +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
// node_modules/.pnpm/remark-dgmo@0.16.
|
|
3
|
+
// node_modules/.pnpm/remark-dgmo@0.16.5_@diagrammo+dgmo@0.91.1_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/dist/client-render.js
|
|
4
4
|
(() => {
|
|
5
5
|
const g = globalThis;
|
|
6
6
|
g.__dgmoReferenceRenderer = () => import("@diagrammo/dgmo/block");
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
g.dispatchEvent(new Event("dgmo:renderer-ready"));
|
|
9
9
|
}
|
|
10
10
|
})();
|
|
11
|
-
//# sourceMappingURL=client-render-
|
|
11
|
+
//# sourceMappingURL=client-render-JZEXFLL4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/.pnpm/remark-dgmo@0.16.
|
|
1
|
+
{"version":3,"sources":["../node_modules/.pnpm/remark-dgmo@0.16.5_@diagrammo+dgmo@0.91.1_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/src/client-render.ts"],"sourcesContent":["/**\n * Cloud references — the OPT-IN renderer (Diagrammo Cloud story 10.4).\n *\n * Load this alongside `remark-dgmo/client.js` if you want a referenced diagram\n * that has changed since your last build to be **re-rendered in the reader's\n * browser** rather than merely flagged as updated.\n *\n * ```js\n * import 'remark-dgmo/client.js';\n * import 'remark-dgmo/client-render.js'; // opt in to the swap\n * ```\n *\n * ## Why it is a separate file\n *\n * Because the cost is real and it lands on the adopter. Measured on\n * `astro-dgmo`'s fixture (2026-07-30): with this one dynamic import living in\n * the base client, the built site went from **1 chunk / 7,990 gzipped bytes to\n * 90 chunks / 634,199**. Bundlers resolve a static-analyzable dynamic import at\n * BUILD time — \"lazy\" says when the reader downloads it, not whether the site\n * ships it. Keeping the renderer in a module nobody imports by default is the\n * only way a bundler can decline to follow it.\n *\n * ## Why it imports nothing, not even from this package\n *\n * Hosts INLINE both files into one script scope (Astro's `injectScript`\n * concatenates them), so anything this module pulled in would be declared twice\n * and the build would fail with `Identifier … has already been declared`. The\n * handshake is therefore a global plus an event, both deliberately named, and\n * the whole file is wrapped so it declares nothing at the top level.\n */\n\n(() => {\n const g = globalThis as {\n __dgmoReferenceRenderer?: () => Promise<unknown>;\n dispatchEvent?: (event: Event) => boolean;\n };\n\n g.__dgmoReferenceRenderer = () => import('@diagrammo/dgmo/block');\n\n // The base client has almost certainly already made its pass and found no\n // renderer. Tell it to look again, so a diagram that moved is swapped on this\n // load rather than the next one.\n if (typeof Event === 'function' && typeof g.dispatchEvent === 'function') {\n g.dispatchEvent(new Event('dgmo:renderer-ready'));\n }\n})();\n"],"mappings":";;;CA+BC,MAAM;AACL,QAAM,IAAI;AAKV,IAAE,0BAA0B,MAAM,OAAO,uBAAuB;AAKhE,MAAI,OAAO,UAAU,cAAc,OAAO,EAAE,kBAAkB,YAAY;AACxE,MAAE,cAAc,IAAI,MAAM,qBAAqB,CAAC;EAClD;AACF,GAAG;","names":[]}
|
package/dist/nextra-client.js
CHANGED
|
@@ -5,7 +5,7 @@ import "nextra-dgmo/client.css";
|
|
|
5
5
|
import { useEffect } from "react";
|
|
6
6
|
import { usePathname } from "next/navigation";
|
|
7
7
|
|
|
8
|
-
// node_modules/.pnpm/remark-dgmo@0.16.
|
|
8
|
+
// node_modules/.pnpm/remark-dgmo@0.16.5_@diagrammo+dgmo@0.91.1_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/dist/client.js
|
|
9
9
|
import { startCountdowns } from "@diagrammo/dgmo/countdown";
|
|
10
10
|
import { startClocks } from "@diagrammo/dgmo/clock";
|
|
11
11
|
var TOMBSTONE_TEXT = "This diagram is no longer shared.";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/nextra-client.tsx","../node_modules/.pnpm/remark-dgmo@0.16.3_@diagrammo+dgmo@0.89.0_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/src/client.ts","../node_modules/.pnpm/remark-dgmo@0.16.3_@diagrammo+dgmo@0.89.0_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/src/tombstone-card.ts","../node_modules/.pnpm/remark-dgmo@0.16.3_@diagrammo+dgmo@0.89.0_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/src/reference-refresh.ts"],"sourcesContent":["/**\n * Nextra-shaped client wrapper for `remark-dgmo`'s framework-neutral\n * `bindDgmo()` function. Drop this once inside your `app/layout.tsx`\n * (typically alongside Nextra's layout) and it will:\n *\n * - run `bindDgmo()` on initial mount, tightening every diagram's\n * viewBox to content bounds and wiring showcase-mode copy buttons;\n * - re-run `bindDgmo()` on every client-side route change (Next's\n * app router does not refire `DOMContentLoaded` semantics on soft\n * navigation).\n *\n * Lives in this package — not in `remark-dgmo` — so that Next's `'use\n * client'` directive and `next/navigation` import stay out of the\n * framework-agnostic core.\n */\n// Side-effect CSS import: Next's app-router CSS pipeline picks this up\n// because the component is a Client Component imported from a layout.\n// Self-references the package via its exports map so it works at both\n// build time (tsup marks it external) and consumer time (Next resolves\n// it through node_modules/nextra-dgmo/dist/client.css). Mounting\n// `<DgmoClient />` is now the only thing a consumer has to do for both\n// runtime rebinding AND theme-aware styling.\nimport 'nextra-dgmo/client.css';\nimport { useEffect } from 'react';\nimport { usePathname } from 'next/navigation';\nimport { bindDgmo } from 'remark-dgmo/client.js';\n\nexport function DgmoClient(): null {\n const pathname = usePathname();\n\n useEffect(() => {\n // bindDgmo is idempotent — it scans for already-bound buttons and\n // skips them — so calling it on every pathname change is safe and\n // covers both initial paint and subsequent SPA navigations.\n bindDgmo();\n }, [pathname]);\n\n return null;\n}\n\nexport default DgmoClient;\n","/**\n * Framework-neutral client-side enhancement for diagrams emitted by\n * `remark-dgmo`:\n *\n * - Bind a delegated click handler for the showcase toolbar buttons:\n * `.dgmo-copy` copies the source string in `data-dgmo-source` to the\n * clipboard. `.dgmo-open` is an `<a href>` whose default-action\n * navigation is preserved — except when it lives inside a `<summary>`\n * (the collapsible toolbar case), where we have to manually navigate\n * because the same click's `preventDefault()` cancels both the\n * summary's toggle AND the anchor's nav.\n * - Tighten each diagram's `viewBox` to its actual content bounds via\n * `SVGGraphicsElement.getBBox()`, since SVG-export from the renderer\n * embeds a generous bounding box.\n *\n * `bindDgmo()` is safe to call multiple times: the click handler is bound\n * once-and-only-once (idempotent), and viewBox tightening is run every\n * invocation so SPA-style frameworks (Docusaurus) can re-run it after\n * route changes.\n *\n * In a non-browser environment, `bindDgmo()` is a no-op. We can't just check\n * for `window`/`document`: some SSG renderers (Docusaurus's static export among\n * them) evaluate client modules against a PARTIAL DOM that defines `window` and\n * `document` but NOT the browser-only APIs this function relies on\n * (`MutationObserver`, `requestAnimationFrame`, `SVGGraphicsElement.getBBox`).\n * So we feature-detect those too and bail unless we're in a real browser —\n * otherwise the module-level auto-init below throws during server render.\n */\n\n// Lean, zero-import ~1 KB ticker for the `countdown` chart type — the only\n// dynamic dgmo chart. Its own subpath so this client bundle never pulls the\n// render pipeline. Lights up all five remark host wrappers (Astro, Docusaurus,\n// Fumadocs, Nextra, VitePress) — they all call bindDgmo().\nimport { startCountdowns } from '@diagrammo/dgmo/countdown';\n// Same deal for the `clock` chart type — a sibling ~1 KB 1s ticker on its own\n// subpath. Updates the baked `data-dgmo-clock` analog/digital world-clock rows.\nimport { startClocks } from '@diagrammo/dgmo/clock';\n// Cloud references (story 10.4). Small and static; the RENDERER it may need is\n// dynamically imported, and only once a diagram is known to have moved.\nimport { refreshCloudReferences } from './reference-refresh.js';\n\nlet clickHandlerBound = false;\nlet themeObserverBound = false;\n\nfunction isInteractiveBrowser(): boolean {\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined' &&\n typeof MutationObserver !== 'undefined' &&\n typeof requestAnimationFrame !== 'undefined'\n );\n}\n\nexport function bindDgmo(): void {\n if (!isInteractiveBrowser()) return;\n\n if (!clickHandlerBound) {\n // Capture phase, not bubble: the handler must run BEFORE any\n // framework-level click handling. Docusaurus (markdown.format 'md')\n // maps the raw <details> onto its theme Details component, whose React\n // onClick — delegated at the app root — toggles the panel for ANY click\n // inside the <summary>, including our copy/open buttons. Capturing at\n // document and stopping propagation for in-summary buttons keeps those\n // clicks ours; plain summary clicks pass through untouched so the\n // toggle (native or framework-managed) still works.\n document.addEventListener(\n 'click',\n (e) => {\n void handleToolbarBtnClick(e);\n },\n true\n );\n // Auto-collapse an open source panel once the pointer AND focus have both\n // left the block — the expanded code shouldn't linger after you move on.\n // Delegated (the click handler is document-level too); `relatedTarget` is\n // where the pointer/focus went, so a move to a child of the same block\n // keeps it open.\n document.addEventListener(\n 'mouseout',\n (e) =>\n collapseIdleSourcePanels(\n (e as MouseEvent).relatedTarget as Node | null\n ),\n true\n );\n document.addEventListener(\n 'focusout',\n (e) =>\n collapseIdleSourcePanels(\n (e as FocusEvent).relatedTarget as Node | null\n ),\n true\n );\n clickHandlerBound = true;\n }\n tightenViewBoxes();\n\n // Seed the dynamic chart types (countdown, clock) and register their 1s\n // tickers (idempotent; no-op when none are on the page). Both call\n // `window.setInterval`, so gate on it: a partial DOM can clear the\n // interactive-browser guard above yet still lack timers (some SSG runtimes).\n if (typeof window.setInterval === 'function') {\n startCountdowns();\n startClocks();\n }\n\n // Color-mode toggles flip which dual-render wrapper is `display: none`.\n // The wrapper that was hidden at load couldn't be measured (getBBox\n // returns 0 on display:none subtrees), so its SVG keeps the full\n // un-tightened viewBox and looks tiny when it becomes visible. Watch\n // for the host's color-mode signal flipping and re-tighten then.\n //\n // Double-rAF defers the measurement until AFTER the browser has\n // finished the layout pass that the display-change triggered. Without\n // it, MutationObserver fires synchronously before layout and getBBox\n // still returns 0 on the freshly-visible element.\n // Cloud references: check whether any referenced diagram has moved since the\n // build. Fires and forgets — a refresh must never be able to delay or break\n // the page it runs on — and returns immediately on a page with no references,\n // which is every page on the wrappers that are not piloting this.\n void refreshCloudReferences();\n\n if (!themeObserverBound) {\n const html = document.documentElement;\n const reTighten = () => {\n requestAnimationFrame(() => requestAnimationFrame(tightenViewBoxes));\n };\n new MutationObserver(reTighten).observe(html, {\n attributes: true,\n attributeFilter: ['data-theme', 'class'],\n });\n themeObserverBound = true;\n }\n}\n\n/**\n * Close any open `<details.dgmo-source-wrap>` whose block is no longer under\n * the pointer and holds no focus. `movedTo` is the event's relatedTarget (the\n * element the pointer/focus moved to); staying within the same block is a\n * no-op. Belt-and-suspenders with `:hover` + `activeElement` so a mouse-out\n * that still leaves focus inside (or vice-versa) keeps the panel open.\n */\nfunction collapseIdleSourcePanels(movedTo: Node | null): void {\n const open = document.querySelectorAll<HTMLDetailsElement>(\n 'details.dgmo-source-wrap[open]'\n );\n open.forEach((d) => {\n const block = d.closest('.dgmo');\n if (!block) return;\n if (movedTo && block.contains(movedTo)) return;\n if (block.contains(document.activeElement)) return;\n if (block.matches(':hover')) return;\n d.open = false;\n });\n}\n\nasync function handleToolbarBtnClick(e: Event): Promise<void> {\n const target = e.target as Element | null;\n if (!target || typeof target.closest !== 'function') return;\n const btn = target.closest('.dgmo-toolbar-btn') as HTMLElement | null;\n if (!btn) return;\n\n // The showcase toolbar IS the <summary> of a <details> disclosure, so a\n // click on any descendant would also toggle the disclosure unless we\n // cancel the default action. preventDefault here cancels the summary's\n // toggle — but it also cancels an anchor's navigation, so we have to\n // manually re-open the link below when the open-in-editor button is\n // nested inside a summary.\n const insideSummary = !!btn.closest('summary');\n if (insideSummary) {\n e.preventDefault();\n // Keep the click from reaching framework toggle handlers (Docusaurus's\n // Details component collapses the panel on any in-summary click).\n e.stopPropagation();\n }\n\n if (btn.matches('button.dgmo-expand')) {\n openDgmoLightbox(btn);\n return;\n }\n\n if (btn.matches('button.dgmo-copy')) {\n const src = btn.dataset['dgmoSource'] ?? '';\n try {\n await navigator.clipboard.writeText(src);\n } catch {\n return;\n }\n btn.classList.add('dgmo-copy--success');\n setTimeout(() => btn.classList.remove('dgmo-copy--success'), 1500);\n return;\n }\n\n if (insideSummary && btn.matches('a.dgmo-open')) {\n const anchor = btn as HTMLAnchorElement;\n if (anchor.href) {\n window.open(\n anchor.href,\n anchor.target || '_blank',\n 'noopener,noreferrer'\n );\n }\n }\n}\n\n// ============================================================\n// Full-screen lightbox (expand toolbar button)\n// ============================================================\n//\n// MIRROR of the canonical helper in @diagrammo/dgmo's `auto/shared.ts`\n// (`openDgmoLightbox`), kept near-verbatim here for the same reason copy/open\n// handling is mirrored per surface. The `.dgmo-lightbox*` CSS is single-sourced\n// in dgmo's BLOCK_CSS (this package's client.css is a generated byte-copy).\n\nconst LIGHTBOX_XLINK_NS = 'http://www.w3.org/1999/xlink';\nconst LIGHTBOX_REF_ATTRS = [\n 'clip-path',\n 'mask',\n 'filter',\n 'fill',\n 'stroke',\n 'marker-start',\n 'marker-mid',\n 'marker-end',\n];\nlet lightboxIdSeq = 0;\n\nconst LIGHTBOX_CLOSE_ICON =\n '<svg width=\"20\" height=\"20\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"m4 4 8 8\"/><path d=\"m12 4-8 8\"/></svg>';\n\n/**\n * Namespace a cloned SVG's ids + internal `url(#id)`/`href=\"#id\"` refs so the\n * clone can't clash with the still-mounted inline copy (WebKit resolves\n * duplicate ids to the first match, corrupting gradients/clips/masks).\n */\nfunction namespaceLightboxSvgIds(root: SVGElement, prefix: string): void {\n const map = new Map<string, string>();\n root.querySelectorAll('[id]').forEach((el) => {\n const oldId = el.getAttribute('id');\n if (!oldId) return;\n const newId = prefix + oldId;\n map.set(oldId, newId);\n el.setAttribute('id', newId);\n });\n if (map.size === 0) return;\n const remap = (value: string): string =>\n value.replace(/url\\(#([^)]+)\\)/g, (m, id: string) => {\n const next = map.get(id);\n return next ? `url(#${next})` : m;\n });\n root.querySelectorAll('*').forEach((el) => {\n for (const attr of LIGHTBOX_REF_ATTRS) {\n const v = el.getAttribute(attr);\n if (v && v.includes('url(#')) el.setAttribute(attr, remap(v));\n }\n const style = el.getAttribute('style');\n if (style && style.includes('url(#'))\n el.setAttribute('style', remap(style));\n const href = el.getAttribute('href');\n if (href && href.startsWith('#') && map.has(href.slice(1)))\n el.setAttribute('href', '#' + map.get(href.slice(1)));\n const xhref = el.getAttributeNS(LIGHTBOX_XLINK_NS, 'href');\n if (xhref && xhref.startsWith('#') && map.has(xhref.slice(1)))\n el.setAttributeNS(\n LIGHTBOX_XLINK_NS,\n 'href',\n '#' + map.get(xhref.slice(1))\n );\n });\n}\n\n/**\n * Open the diagram belonging to `fromButton`'s block in a full-viewport\n * `<dialog>` lightbox: clone the currently-visible color-mode SVG, namespace\n * its ids, then `showModal()`. Escape / backdrop-click / close button dismiss.\n */\nfunction openDgmoLightbox(fromButton: Element): void {\n if (typeof document === 'undefined') return;\n const block = fromButton.closest('.dgmo');\n if (!block) return;\n\n const wrappers = block.querySelectorAll('.dgmo-light, .dgmo-dark, .dgmo-svg');\n let svg: SVGSVGElement | null = null;\n let bg: string | null = null;\n for (const w of Array.from(wrappers)) {\n if (window.getComputedStyle(w).display === 'none') continue;\n const found = w.querySelector('svg');\n if (found) {\n svg = found as SVGSVGElement;\n bg = w.getAttribute('data-dgmo-bg');\n break;\n }\n }\n if (!svg) svg = block.querySelector('svg');\n if (!svg) return;\n\n const clone = svg.cloneNode(true) as SVGSVGElement;\n namespaceLightboxSvgIds(clone, `dgmo-lb-${++lightboxIdSeq}-`);\n\n const dialog = document.createElement('dialog');\n dialog.className = 'dgmo-lightbox';\n dialog.setAttribute('aria-label', 'Diagram, full screen');\n\n const closeBtn = document.createElement('button');\n closeBtn.type = 'button';\n closeBtn.className = 'dgmo-lightbox-close';\n closeBtn.setAttribute('aria-label', 'Close full screen');\n closeBtn.innerHTML = LIGHTBOX_CLOSE_ICON;\n\n const host = document.createElement('div');\n host.className = 'dgmo-lightbox-svg';\n // Always paint an opaque surface behind the enlarged diagram — transparent\n // embeds strip the chart bg from the SVG, so without this the page shows\n // through the expanded view. Use the block's own palette bg when stashed.\n if (bg) host.style.background = bg;\n host.appendChild(clone);\n\n dialog.appendChild(closeBtn);\n dialog.appendChild(host);\n document.body.appendChild(dialog);\n\n const close = (): void => {\n if (dialog.open) dialog.close();\n };\n closeBtn.addEventListener('click', close);\n dialog.addEventListener('click', (e) => {\n if (e.target === dialog) close();\n });\n dialog.addEventListener('close', () => dialog.remove());\n dialog.showModal();\n}\n\nfunction tightenViewBoxes(): void {\n const WRAPPER_SELECTORS = '.dgmo-light, .dgmo-dark, .dgmo-svg';\n document.querySelectorAll(WRAPPER_SELECTORS).forEach((node) => {\n const wrapper = node as HTMLElement;\n const svg = wrapper.querySelector('svg') as SVGSVGElement | null;\n if (!svg) return;\n\n // `getBBox()` returns 0,0,0,0 on elements whose ancestor is `display: none`.\n // Under dual-render the inactive color-mode wrapper IS display:none at load,\n // so its SVG would stay un-tightened — and then look small after the user\n // toggles into it. Set the wrapper to inline-style `display: block`\n // synchronously, read getBBox, then restore. Modern browsers don't paint\n // between these synchronous DOM writes, so there's no visible flicker.\n const computed = window.getComputedStyle(wrapper);\n const wasHidden = computed.display === 'none';\n const savedInlineDisplay = wrapper.style.display;\n if (wasHidden) {\n wrapper.style.display = 'block';\n // Force a synchronous layout pass before getBBox so the freshly-\n // shown element actually has bounds. Without this, some browsers\n // still report 0,0,0,0 because they batch the display change for\n // the next frame.\n void wrapper.offsetHeight;\n }\n\n try {\n const bbox = (svg as unknown as SVGGraphicsElement).getBBox();\n if (bbox.width > 0 && bbox.height > 0) {\n const pad = 16;\n svg.setAttribute(\n 'viewBox',\n `${bbox.x - pad} ${bbox.y - pad} ${bbox.width + pad * 2} ${\n bbox.height + pad * 2\n }`\n );\n }\n } catch {\n // ignore: SVG not yet in the DOM, or getBBox unsupported\n }\n\n if (wasHidden) {\n wrapper.style.display = savedInlineDisplay;\n // Clearing the only inline property leaves `style=\"\"` on the\n // element in Chrome/Safari. React 19's post-hydration check reads\n // that empty attribute as a server-vs-client mismatch on the\n // wrapper div (the wrapper is React-owned; only its `innerHTML`\n // is dangerouslySetInnerHTML). Drop the empty attribute so the\n // wrapper round-trips back to its SSR shape.\n if (savedInlineDisplay === '' && wrapper.getAttribute('style') === '') {\n wrapper.removeAttribute('style');\n }\n }\n });\n}\n\n// Auto-init on initial load. Docusaurus-style SPA wrappers also re-call\n// bindDgmo on route changes; that's safe (the click handler is bound once,\n// viewBox tightening runs every time).\nif (isInteractiveBrowser()) {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', bindDgmo);\n } else {\n bindDgmo();\n }\n}\n","/**\n * The tombstone card — what a withdrawn cloud reference renders as.\n *\n * Not an error card. Nothing went wrong here: an author unshared a diagram they\n * had shared, which is a thing they are allowed to do, and the document that\n * referenced it is now simply pointing at something that is no longer public.\n * Rendering our cached copy instead would mean publishing content somebody took\n * back, so this card is what stands in its place.\n *\n * 🔴 It carries NO identifying content — no title, no space, no author, no\n * thumbnail. That is a requirement, not a style choice (Cloud story 7.13 T5):\n * once the response carries nothing sensitive there is nothing to opt out of,\n * which is what keeps a per-diagram privacy setting out of the product. The copy\n * matches the API's own `TOMBSTONE_DETAIL`, deliberately — a reader who follows\n * the link should not be told two different stories.\n */\n\n/** The whole of it. Do not add attribution here without reading 7.13 first. */\nexport const TOMBSTONE_TEXT = 'This diagram is no longer shared.';\n\n/**\n * Local, four-line attribute escape rather than an import from dgmo's block\n * entry, which does not export one. The values here are all ours (class names\n * from options), but they are host-supplied strings landing in markup, and the\n * one place that rule gets relaxed is the place it eventually bites.\n */\nfunction escapeAttr(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\nexport interface TombstoneCardOptions {\n /** Base class, matching the surrounding blocks (default `dgmo`). */\n className?: string;\n wrapper?: 'figure' | 'div';\n /** Extra classes, for wrappers still emitting legacy names. */\n legacyClassNames?: string[];\n}\n\nexport function tombstoneCardHtml(options: TombstoneCardOptions = {}): string {\n const base = options.className ?? 'dgmo';\n const wrapper = options.wrapper ?? 'figure';\n const classes = [\n base,\n `${base}--tombstone`,\n ...(options.legacyClassNames ?? []),\n ].join(' ');\n return (\n `<${wrapper} class=\"${escapeAttr(classes)}\" role=\"note\">` +\n `<p class=\"${escapeAttr(base)}-tombstone-text\">${TOMBSTONE_TEXT}</p>` +\n `</${wrapper}>`\n );\n}\n","/**\n * Cloud references — the client half (Diagrammo Cloud story 10.4).\n *\n * The build baked a diagram into the page. This checks, after the page is idle,\n * whether the diagram it points at has moved since, and swaps it if — and only\n * if — swapping is safe.\n *\n * ## What this is allowed to cost\n *\n * Almost nothing, on almost every page. The check is one conditional fetch per\n * referenced diagram against an edge-cached endpoint, and the overwhelmingly\n * common answer is \"unchanged\", which costs no work at all.\n *\n * 🔴 **There is no renderer in this module, not even behind a dynamic\n * `import()`, and that is the whole reason the file is shaped this way.**\n *\n * Measured on `astro-dgmo`'s own fixture, 2026-07-30: a plain\n * `await import('@diagrammo/dgmo/block')` here — dynamic, on a branch that\n * almost never runs — took the built site from **1 chunk / 7,990 gzipped bytes\n * to 90 chunks / 634,199**. Bundlers resolve a static-analyzable dynamic import\n * at BUILD time; \"lazy\" describes when the reader downloads it, not whether the\n * adopter ships it. Readers would not have paid for it, but every adopter's\n * `dist/` would, and the wrapper's own size assertion fails on the spot.\n *\n * So the default is to **notice, not to re-render**: a moved diagram gets a\n * small link to the live one. A site that genuinely wants the swap opts in by\n * loading `remark-dgmo/client-render.js`, which is the only module that\n * mentions the renderer — and therefore the only one whose graph a bundler can\n * follow.\n *\n * The one import here is `./tombstone-card.js`, for a single string. That file\n * imports nothing at all, so it costs the adopter a sentence rather than a\n * graph — but it is the reason the rule above is stated as \"no renderer\" and\n * not \"no imports\": check what a new one drags in before adding it.\n *\n * ## The one thing it removes\n *\n * A **withdrawn** diagram (`410`) is taken off the page and replaced with the\n * same card the build draws. That is the single case where this script changes\n * what a reader can see rather than adding a note beside it, and it is the case\n * where leaving the page alone means publishing something its author took back.\n * Every other answer — 404, 5xx, a timeout, a blocked request — leaves the\n * baked diagram exactly where it is.\n *\n * ## What it must never do\n *\n * Break the page it runs on. This code executes on somebody else's site, on a\n * diagram that already renders correctly, so **every failure path leaves the\n * baked diagram exactly as it is**: a blocked fetch (a CSP without our origin\n * is the expected case), a failed dynamic import, an offline reader, a renderer\n * whose version disagrees with the one that baked the page. Each of those ends\n * at the same place — a small \"updated\" affordance, or silence.\n *\n * ⚠️ This module ships inside `remark-dgmo/client.js`, which `vitepress-dgmo`\n * loads even though it does not use the remark plugin. On a page with no\n * `[data-dgmo-ref]` it must do nothing at all, and there is a test for that.\n */\n\nimport { TOMBSTONE_TEXT } from './tombstone-card.js';\n\n/** Where the source endpoint lives. Overridable for self-host and tests. */\nconst DEFAULT_API_BASE = 'https://api.diagrammo.app';\n/** Where a human goes to see the live diagram. */\nconst DEFAULT_APP_BASE = 'https://online.diagrammo.app';\n\n/** Aspect-ratio drift a swap may absorb before it counts as reflowing the page. */\nconst MAX_ASPECT_DRIFT = 0.25;\n\nexport interface ReferenceRefreshOptions {\n apiBase?: string;\n appBase?: string;\n fetchImpl?: typeof fetch;\n /** Injected in tests; production defers to idle. */\n schedule?: (run: () => void) => void;\n /** Injected in tests so the 1.9 MB renderer isn't loaded to prove a branch. */\n loadRenderer?: () => Promise<RendererLike>;\n document?: Document;\n}\n\nexport interface RendererLike {\n renderDgmoBlock: (\n source: string,\n options?: Record<string, unknown>\n ) => Promise<{ html: string }>;\n}\n\n/**\n * The opt-in renderer, registered by `remark-dgmo/client-render.js`.\n *\n * A registry rather than an import, because this module must stay free of any\n * reference to the render package — a bundler that can see one pulls its whole\n * graph into every adopter's build whether or not a diagram ever changes.\n *\n * Held on `globalThis` rather than in a module variable, and that is not\n * laziness: hosts inline these two files as SEPARATE script sources (Astro's\n * `injectScript` reads each one's text), so each carries its own copy of this\n * module and a module-level variable set by one would be invisible to the\n * other. A global is the only handshake that survives being bundled twice.\n */\nconst REGISTRY_KEY = '__dgmoReferenceRenderer';\n\ntype RegistryHost = { [REGISTRY_KEY]?: (() => Promise<RendererLike>) | null };\n\nexport function setReferenceRenderer(\n load: (() => Promise<RendererLike>) | null\n): void {\n (globalThis as RegistryHost)[REGISTRY_KEY] = load;\n}\n\nfunction registeredRenderer(): (() => Promise<RendererLike>) | null {\n return (globalThis as RegistryHost)[REGISTRY_KEY] ?? null;\n}\n\n/**\n * `client-render.js` fires this once it has registered the renderer. Listening\n * for it is what lets the opt-in module stay import-free: it cannot call into\n * this one, so it announces itself instead, and a diagram that moved gets its\n * swap on this page load rather than the next.\n */\nif (typeof globalThis.addEventListener === 'function') {\n globalThis.addEventListener('dgmo:renderer-ready', () => {\n void refreshCloudReferences();\n });\n}\n\ninterface SourceResponse {\n source?: unknown;\n dgmoVersion?: unknown;\n updatedAt?: unknown;\n}\n\n/**\n * How long the idle path may wait before running anyway. Matches the\n * `setTimeout` fallback below, so the check is bounded on every browser rather\n * than only on the ones lacking `requestIdleCallback`.\n */\nconst SCHEDULE_TIMEOUT_MS = 1000;\n\n/**\n * 🔴 The `timeout` is load-bearing, not a nicety. `requestIdleCallback(cb)` with\n * no deadline is a request the browser may defer for as long as it likes — and a\n * page carrying dozens of diagrams, which is exactly the kind of page that has a\n * live link on it, can keep a browser busy long enough that \"idle\" never\n * arrives. It read as the feature being broken: the diagram had changed, the API\n * said so, and the page did nothing at all — no swap and no notice, because the\n * callback that would have produced either had not run.\n *\n * The asymmetry was the tell. A browser WITHOUT `requestIdleCallback` fell\n * through to `setTimeout(run, 1000)` and always worked; a browser with it got no\n * guarantee whatsoever. Found on Safari 2026-08-03, against the astro-dgmo\n * showcase (~64 dual-rendered charts, 550 KB of gzipped HTML).\n */\nfunction defaultSchedule(run: () => void): void {\n const idle = (\n globalThis as {\n requestIdleCallback?: (\n cb: () => void,\n opts?: { timeout: number }\n ) => number;\n }\n ).requestIdleCallback;\n if (typeof idle === 'function') idle(run, { timeout: SCHEDULE_TIMEOUT_MS });\n else setTimeout(run, SCHEDULE_TIMEOUT_MS);\n}\n\n/**\n * Check every referenced diagram on the page and refresh what safely can be.\n * Resolves once the pass is done, so a test can await it; production fires it\n * and forgets.\n */\nexport async function refreshCloudReferences(\n options: ReferenceRefreshOptions = {}\n): Promise<void> {\n const doc = options.document ?? globalThis.document;\n if (!doc) return;\n\n const blocks = Array.from(\n doc.querySelectorAll<HTMLElement>('[data-dgmo-ref]')\n );\n // The inert path, and the common one: no references, no work, no fetch.\n if (blocks.length === 0) return;\n\n // 🔴 `.bind(globalThis)` is what makes this work in a browser at all.\n // `fetch` is a WebIDL operation on `Window`: it throws\n // `Illegal invocation` unless its `this` IS the global. Stored on an options\n // object and invoked as `ctx.fetchImpl(url)`, `this` becomes that plain\n // object — so the call threw, `refreshOne`'s `catch` swallowed it as \"offline\n // or blocked by CSP\", and the page did nothing at all. See the call site.\n const raw = options.fetchImpl ?? globalThis.fetch;\n if (typeof raw !== 'function') return;\n const fetchImpl = options.fetchImpl ? raw : raw.bind(globalThis);\n\n const apiBase = (options.apiBase ?? DEFAULT_API_BASE).replace(/\\/+$/, '');\n const schedule = options.schedule ?? defaultSchedule;\n\n await new Promise<void>((resolve) => {\n schedule(() => {\n void (async () => {\n // One request per distinct id, however many blocks name it.\n const byId = new Map<string, HTMLElement[]>();\n for (const el of blocks) {\n const id = el.dataset['dgmoRef'];\n if (!id) continue;\n byId.set(id, [...(byId.get(id) ?? []), el]);\n }\n await Promise.all(\n [...byId.entries()].map(([id, els]) =>\n refreshOne(id, els, { ...options, apiBase, fetchImpl, doc })\n )\n );\n resolve();\n })();\n });\n });\n}\n\nasync function refreshOne(\n id: string,\n els: HTMLElement[],\n ctx: ReferenceRefreshOptions & {\n apiBase: string;\n fetchImpl: typeof fetch;\n doc: Document;\n }\n): Promise<void> {\n let body: SourceResponse;\n try {\n // 🔴 Read it off `ctx` FIRST, then call it. `ctx.fetchImpl(url)` is a\n // method call, so `this` would be `ctx` — and a native `fetch` whose `this`\n // is a plain object throws `Illegal invocation`, which the catch below then\n // reports to nobody. This is not hypothetical: it is why a live link never\n // once refreshed in a reader's browser.\n const { fetchImpl } = ctx;\n const res = await fetchImpl(\n `${ctx.apiBase}/public/diagrams/${encodeURIComponent(id)}/source`\n );\n // 🔴 A withdrawn diagram (410) stops drawing, here, in the reader's\n // browser — changed 2026-08-10 (issue 101), and the reasoning it reverses\n // is worth keeping because it was half right.\n //\n // It used to fall into `!res.ok` and do nothing, on the grounds that\n // \"silently BLANKING a rendered diagram in a reader's browser is not this\n // code's call to make\". The objection was to leaving a hole, and it still\n // stands — nothing here blanks anything. What it draws is the same\n // tombstone the BUILD draws from the same `410`, so the client is not\n // inventing a policy, it is applying the one already chosen a few files\n // away.\n //\n // What settled it is a sentence we print to the publisher beside the Stop\n // showing button: \"Stop showing replaces the live chart with a note that it\n // is no longer shared\". That is the only specification of Stop showing\n // anywhere. The build kept it, Obsidian kept it, the desktop app kept it,\n // the plain-page element kept it — and this path, the most public of the\n // five and the one running on a site that may never rebuild, did not.\n //\n // Only 410. A 404, a 5xx and a timeout still leave the baked diagram\n // exactly where it is: those mean \"cannot say\", and withdrawal is the one\n // answer that is deliberate and final.\n if (res.status === 410) {\n for (const el of els) drawTombstone(el, ctx.doc);\n return;\n }\n if (!res.ok) return;\n body = (await res.json()) as SourceResponse;\n } catch {\n // Blocked by CSP, offline, DNS, our outage — all the same answer: the page\n // keeps the diagram it already has. This is the expected path on a site\n // whose Content-Security-Policy omits our origin, and it is precisely why\n // that failure cannot be measured from here.\n return;\n }\n\n const source = typeof body.source === 'string' ? body.source : null;\n const updatedAt = typeof body.updatedAt === 'number' ? body.updatedAt : null;\n const dgmoVersion =\n typeof body.dgmoVersion === 'string' ? body.dgmoVersion : '';\n if (source === null || updatedAt === null) return;\n\n for (const el of els) {\n const bakedAt = Number(el.dataset['dgmoRefUpdated'] ?? '');\n // Unchanged — the overwhelmingly common case, and the whole point of\n // comparing before doing anything expensive.\n if (Number.isFinite(bakedAt) && bakedAt >= updatedAt) continue;\n\n // The renderer that baked this page and the one that authored the new\n // revision disagree, so a re-render here could look different in ways\n // nobody chose. Say so instead of swapping.\n if (dgmoVersion && el.dataset['dgmoRefVersion'] !== dgmoVersion) {\n markUpdated(el, id, ctx);\n continue;\n }\n\n await swapOrMark(el, id, source, ctx);\n }\n}\n\nasync function swapOrMark(\n el: HTMLElement,\n id: string,\n source: string,\n ctx: ReferenceRefreshOptions & { doc: Document }\n): Promise<void> {\n const load = ctx.loadRenderer ?? registeredRenderer();\n // The default path, and the one almost every site takes: nobody registered a\n // renderer, so say the diagram moved and leave it alone.\n if (!load) {\n markUpdated(el, id, ctx);\n return;\n }\n\n let renderer: RendererLike;\n try {\n renderer = await load();\n } catch {\n markUpdated(el, id, ctx); // renderer unavailable: label it, don't break it\n return;\n }\n\n try {\n const opts = readBakeOptions(el);\n const { html } = await renderer.renderDgmoBlock(source, opts);\n const next = parseWrapper(html, ctx.doc);\n if (!next || !fitsTheBox(el, next)) {\n markUpdated(el, id, ctx);\n return;\n }\n el.innerHTML = next.innerHTML;\n el.dataset['dgmoRefRefreshed'] = 'true';\n } catch {\n markUpdated(el, id, ctx);\n }\n}\n\n/**\n * The render options this block was baked with, so a swap matches what is\n * already on the page rather than reverting to defaults — a diagram that\n * silently changes palette on refresh reads as a bug, not as freshness.\n */\nfunction readBakeOptions(el: HTMLElement): Record<string, unknown> {\n const raw = el.dataset['dgmoRefOpts'];\n if (!raw) return {};\n try {\n return JSON.parse(raw) as Record<string, unknown>;\n } catch {\n return {};\n }\n}\n\nfunction parseWrapper(html: string, doc: Document): HTMLElement | null {\n const host = doc.createElement('div');\n host.innerHTML = html;\n return host.firstElementChild as HTMLElement | null;\n}\n\n/**\n * Would the new render reflow the page? Compared by aspect ratio from the\n * emitted `viewBox`, which is what the blocks are sized by. An unmeasurable\n * pair is treated as \"fits\": refusing every swap we cannot measure would make\n * the feature not work at all on the surfaces least able to tell us why.\n */\nfunction fitsTheBox(current: HTMLElement, next: HTMLElement): boolean {\n const a = aspect(current);\n const b = aspect(next);\n if (a === null || b === null) return true;\n return Math.abs(a - b) / a <= MAX_ASPECT_DRIFT;\n}\n\nfunction aspect(el: HTMLElement): number | null {\n const svg = el.querySelector('svg');\n const box = svg\n ?.getAttribute('viewBox')\n ?.split(/[\\s,]+/)\n .map(Number);\n if (!box || box.length !== 4) return null;\n const [, , w, h] = box as [number, number, number, number];\n if (!w || !h) return null;\n return w / h;\n}\n\n/**\n * Turn a baked block into the withdrawn card, in place (issue 101).\n *\n * 🔴 It mutates the block rather than replacing it with `tombstoneCardHtml`'s\n * markup, and the difference matters: the wrapper carries `data-dgmo-ref` and\n * its siblings, and a fresh element would drop them — so a second pass would\n * stop recognising this block as a reference at all. Same classes, same role,\n * same sentence; different route to it.\n *\n * The sentence itself is imported rather than retyped. It is the one thing that\n * must not drift from what the build draws, and it is already shared with the\n * API's own `TOMBSTONE_DETAIL` for the same reason — a reader who follows the\n * link must not be told two different stories.\n *\n * 🔴 No title, no space, no author, no thumbnail. Carrying nothing identifying\n * is what keeps a per-diagram privacy setting out of the product (Cloud story\n * 7.13); see `tombstone-card.ts` before adding anything here.\n */\nfunction drawTombstone(el: HTMLElement, doc: Document): void {\n if (el.dataset['dgmoRefWithdrawn'] === 'true') return;\n el.dataset['dgmoRefWithdrawn'] = 'true';\n\n // The base class the host chose, read off the block instead of assumed: the\n // emitter writes `<base> <base>--<variant> [legacy…]`, so the first class IS\n // the base, and a site using `className: 'diagram'` gets its own names.\n const base = el.classList[0] ?? 'dgmo';\n el.classList.remove(`${base}--diagram`, `${base}--showcase`);\n el.classList.add(`${base}--tombstone`);\n // `note`, not `alert`. Nothing went wrong — somebody exercised a control they\n // were given, and a screen reader announcing an emergency would be wrong\n // about what happened.\n el.setAttribute('role', 'note');\n\n const text = doc.createElement('p');\n text.className = `${base}-tombstone-text`;\n text.textContent = TOMBSTONE_TEXT;\n // Emptied by hand rather than with `replaceChildren`, which is newer than the\n // oldest browser this script has any business breaking on. It runs on\n // somebody else's site.\n el.textContent = '';\n el.appendChild(text);\n}\n\n/**\n * The fallback for every path that cannot safely swap: a small link to the live\n * diagram. Idempotent, and deliberately quiet — a docs page peppered with\n * badges is worse than one that is a few days behind.\n */\nfunction markUpdated(\n el: HTMLElement,\n id: string,\n ctx: ReferenceRefreshOptions & { doc: Document }\n): void {\n if (el.dataset['dgmoRefStale'] === 'true') return;\n el.dataset['dgmoRefStale'] = 'true';\n const appBase = (ctx.appBase ?? DEFAULT_APP_BASE).replace(/\\/+$/, '');\n const link = ctx.doc.createElement('a');\n link.className = 'dgmo-updated';\n link.href = `${appBase}/d/${encodeURIComponent(id)}`;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n link.textContent = 'This diagram has been updated';\n el.appendChild(link);\n}\n"],"mappings":";;;AAsBA,OAAO;AACP,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;;;ACS5B,SAAS,uBAAuB;AAGhC,SAAS,mBAAmB;AClBrB,IAAM,iBAAiB;AC2C9B,IAAM,mBAAmB;AAEzB,IAAM,mBAAmB;AAGzB,IAAM,mBAAmB;AAiCzB,IAAM,eAAe;AAUrB,SAAS,qBAA2D;AAClE,SAAQ,WAA4B,YAAY,KAAK;AACvD;AAQA,IAAI,OAAO,WAAW,qBAAqB,YAAY;AACrD,aAAW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oB;AAC1B,WAAS,iBAAiB,iBAAiB,EAAE,QAAQ,CAAC,SAAS;AAC7D,UAAM,UAAU;AAChB,UAAM,MAAM,QAAQ,cAAc,KAAK;AACvC,QAAI,CAAC,IAAK;AAQV,UAAM,WAAW,OAAO,iBAAiB,OAAO;AAChD,UAAM,YAAY,SAAS,YAAY;AACvC,UAAM,qBAAqB,QAAQ,MAAM;AACzC,QAAI,WAAW;AACb,cAAQ,MAAM,UAAU;AAKxB,WAAK,QAAQ;IACf;AAEA,QAAI;AACF,YAAM,OAAQ,IAAsC,QAAQ;AAC5D,UAAI,KAAK,QAAQ,KAAK,KAAK,SAAS,GAAG;AACrC,cAAM,MAAM;AACZ,YAAI;UACF;UACA,GAAG,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,QAAQ,MAAM,CAAC,IACrD,KAAK,SAAS,MAAM,CACtB;QACF;MACF;IACF,QAAQ;IAER;AAEA,QAAI,WAAW;AACb,cAAQ,MAAM,UAAU;AAOxB,UAAI,uBAAuB,MAAM,QAAQ,aAAa,OAAO,MAAM,IAAI;AACrE,gBAAQ,gBAAgB,OAAO;MACjC;IACF;EACF,CAAC;AACH;AAKA,IAAI,qBAAqB,GAAG;AAC1B,MAAI,SAAS,eAAe,WAAW;AACrC,aAAS,iBAAiB,oBAAoB,QAAQ;EACxD,OAAO;AACL,aAAS;EACX;AACF;;;ADjXO,SAAS,aAAmB;AACjC,QAAM,WAAW,YAAY;AAE7B,YAAU,MAAM;AAId,aAAS;AAAA,EACX,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AACT;AAEA,IAAO,wBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/nextra-client.tsx","../node_modules/.pnpm/remark-dgmo@0.16.5_@diagrammo+dgmo@0.91.1_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/src/client.ts","../node_modules/.pnpm/remark-dgmo@0.16.5_@diagrammo+dgmo@0.91.1_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/src/tombstone-card.ts","../node_modules/.pnpm/remark-dgmo@0.16.5_@diagrammo+dgmo@0.91.1_@lezer+common@1.5.2_@lezer+highlight@1.2.3_@lezer+lr@1.4.10_/node_modules/remark-dgmo/src/reference-refresh.ts"],"sourcesContent":["/**\n * Nextra-shaped client wrapper for `remark-dgmo`'s framework-neutral\n * `bindDgmo()` function. Drop this once inside your `app/layout.tsx`\n * (typically alongside Nextra's layout) and it will:\n *\n * - run `bindDgmo()` on initial mount, tightening every diagram's\n * viewBox to content bounds and wiring showcase-mode copy buttons;\n * - re-run `bindDgmo()` on every client-side route change (Next's\n * app router does not refire `DOMContentLoaded` semantics on soft\n * navigation).\n *\n * Lives in this package — not in `remark-dgmo` — so that Next's `'use\n * client'` directive and `next/navigation` import stay out of the\n * framework-agnostic core.\n */\n// Side-effect CSS import: Next's app-router CSS pipeline picks this up\n// because the component is a Client Component imported from a layout.\n// Self-references the package via its exports map so it works at both\n// build time (tsup marks it external) and consumer time (Next resolves\n// it through node_modules/nextra-dgmo/dist/client.css). Mounting\n// `<DgmoClient />` is now the only thing a consumer has to do for both\n// runtime rebinding AND theme-aware styling.\nimport 'nextra-dgmo/client.css';\nimport { useEffect } from 'react';\nimport { usePathname } from 'next/navigation';\nimport { bindDgmo } from 'remark-dgmo/client.js';\n\nexport function DgmoClient(): null {\n const pathname = usePathname();\n\n useEffect(() => {\n // bindDgmo is idempotent — it scans for already-bound buttons and\n // skips them — so calling it on every pathname change is safe and\n // covers both initial paint and subsequent SPA navigations.\n bindDgmo();\n }, [pathname]);\n\n return null;\n}\n\nexport default DgmoClient;\n","/**\n * Framework-neutral client-side enhancement for diagrams emitted by\n * `remark-dgmo`:\n *\n * - Bind a delegated click handler for the showcase toolbar buttons:\n * `.dgmo-copy` copies the source string in `data-dgmo-source` to the\n * clipboard. `.dgmo-open` is an `<a href>` whose default-action\n * navigation is preserved — except when it lives inside a `<summary>`\n * (the collapsible toolbar case), where we have to manually navigate\n * because the same click's `preventDefault()` cancels both the\n * summary's toggle AND the anchor's nav.\n * - Tighten each diagram's `viewBox` to its actual content bounds via\n * `SVGGraphicsElement.getBBox()`, since SVG-export from the renderer\n * embeds a generous bounding box.\n *\n * `bindDgmo()` is safe to call multiple times: the click handler is bound\n * once-and-only-once (idempotent), and viewBox tightening is run every\n * invocation so SPA-style frameworks (Docusaurus) can re-run it after\n * route changes.\n *\n * In a non-browser environment, `bindDgmo()` is a no-op. We can't just check\n * for `window`/`document`: some SSG renderers (Docusaurus's static export among\n * them) evaluate client modules against a PARTIAL DOM that defines `window` and\n * `document` but NOT the browser-only APIs this function relies on\n * (`MutationObserver`, `requestAnimationFrame`, `SVGGraphicsElement.getBBox`).\n * So we feature-detect those too and bail unless we're in a real browser —\n * otherwise the module-level auto-init below throws during server render.\n */\n\n// Lean, zero-import ~1 KB ticker for the `countdown` chart type — the only\n// dynamic dgmo chart. Its own subpath so this client bundle never pulls the\n// render pipeline. Lights up all five remark host wrappers (Astro, Docusaurus,\n// Fumadocs, Nextra, VitePress) — they all call bindDgmo().\nimport { startCountdowns } from '@diagrammo/dgmo/countdown';\n// Same deal for the `clock` chart type — a sibling ~1 KB 1s ticker on its own\n// subpath. Updates the baked `data-dgmo-clock` analog/digital world-clock rows.\nimport { startClocks } from '@diagrammo/dgmo/clock';\n// Cloud references (story 10.4). Small and static; the RENDERER it may need is\n// dynamically imported, and only once a diagram is known to have moved.\nimport { refreshCloudReferences } from './reference-refresh.js';\n\nlet clickHandlerBound = false;\nlet themeObserverBound = false;\n\nfunction isInteractiveBrowser(): boolean {\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined' &&\n typeof MutationObserver !== 'undefined' &&\n typeof requestAnimationFrame !== 'undefined'\n );\n}\n\nexport function bindDgmo(): void {\n if (!isInteractiveBrowser()) return;\n\n if (!clickHandlerBound) {\n // Capture phase, not bubble: the handler must run BEFORE any\n // framework-level click handling. Docusaurus (markdown.format 'md')\n // maps the raw <details> onto its theme Details component, whose React\n // onClick — delegated at the app root — toggles the panel for ANY click\n // inside the <summary>, including our copy/open buttons. Capturing at\n // document and stopping propagation for in-summary buttons keeps those\n // clicks ours; plain summary clicks pass through untouched so the\n // toggle (native or framework-managed) still works.\n document.addEventListener(\n 'click',\n (e) => {\n void handleToolbarBtnClick(e);\n },\n true\n );\n // Auto-collapse an open source panel once the pointer AND focus have both\n // left the block — the expanded code shouldn't linger after you move on.\n // Delegated (the click handler is document-level too); `relatedTarget` is\n // where the pointer/focus went, so a move to a child of the same block\n // keeps it open.\n document.addEventListener(\n 'mouseout',\n (e) =>\n collapseIdleSourcePanels(\n (e as MouseEvent).relatedTarget as Node | null\n ),\n true\n );\n document.addEventListener(\n 'focusout',\n (e) =>\n collapseIdleSourcePanels(\n (e as FocusEvent).relatedTarget as Node | null\n ),\n true\n );\n clickHandlerBound = true;\n }\n tightenViewBoxes();\n\n // Seed the dynamic chart types (countdown, clock) and register their 1s\n // tickers (idempotent; no-op when none are on the page). Both call\n // `window.setInterval`, so gate on it: a partial DOM can clear the\n // interactive-browser guard above yet still lack timers (some SSG runtimes).\n if (typeof window.setInterval === 'function') {\n startCountdowns();\n startClocks();\n }\n\n // Color-mode toggles flip which dual-render wrapper is `display: none`.\n // The wrapper that was hidden at load couldn't be measured (getBBox\n // returns 0 on display:none subtrees), so its SVG keeps the full\n // un-tightened viewBox and looks tiny when it becomes visible. Watch\n // for the host's color-mode signal flipping and re-tighten then.\n //\n // Double-rAF defers the measurement until AFTER the browser has\n // finished the layout pass that the display-change triggered. Without\n // it, MutationObserver fires synchronously before layout and getBBox\n // still returns 0 on the freshly-visible element.\n // Cloud references: check whether any referenced diagram has moved since the\n // build. Fires and forgets — a refresh must never be able to delay or break\n // the page it runs on — and returns immediately on a page with no references,\n // which is every page on the wrappers that are not piloting this.\n void refreshCloudReferences();\n\n if (!themeObserverBound) {\n const html = document.documentElement;\n const reTighten = () => {\n requestAnimationFrame(() => requestAnimationFrame(tightenViewBoxes));\n };\n new MutationObserver(reTighten).observe(html, {\n attributes: true,\n attributeFilter: ['data-theme', 'class'],\n });\n themeObserverBound = true;\n }\n}\n\n/**\n * Close any open `<details.dgmo-source-wrap>` whose block is no longer under\n * the pointer and holds no focus. `movedTo` is the event's relatedTarget (the\n * element the pointer/focus moved to); staying within the same block is a\n * no-op. Belt-and-suspenders with `:hover` + `activeElement` so a mouse-out\n * that still leaves focus inside (or vice-versa) keeps the panel open.\n */\nfunction collapseIdleSourcePanels(movedTo: Node | null): void {\n const open = document.querySelectorAll<HTMLDetailsElement>(\n 'details.dgmo-source-wrap[open]'\n );\n open.forEach((d) => {\n const block = d.closest('.dgmo');\n if (!block) return;\n if (movedTo && block.contains(movedTo)) return;\n if (block.contains(document.activeElement)) return;\n if (block.matches(':hover')) return;\n d.open = false;\n });\n}\n\nasync function handleToolbarBtnClick(e: Event): Promise<void> {\n const target = e.target as Element | null;\n if (!target || typeof target.closest !== 'function') return;\n const btn = target.closest('.dgmo-toolbar-btn') as HTMLElement | null;\n if (!btn) return;\n\n // The showcase toolbar IS the <summary> of a <details> disclosure, so a\n // click on any descendant would also toggle the disclosure unless we\n // cancel the default action. preventDefault here cancels the summary's\n // toggle — but it also cancels an anchor's navigation, so we have to\n // manually re-open the link below when the open-in-editor button is\n // nested inside a summary.\n const insideSummary = !!btn.closest('summary');\n if (insideSummary) {\n e.preventDefault();\n // Keep the click from reaching framework toggle handlers (Docusaurus's\n // Details component collapses the panel on any in-summary click).\n e.stopPropagation();\n }\n\n if (btn.matches('button.dgmo-expand')) {\n openDgmoLightbox(btn);\n return;\n }\n\n if (btn.matches('button.dgmo-copy')) {\n const src = btn.dataset['dgmoSource'] ?? '';\n try {\n await navigator.clipboard.writeText(src);\n } catch {\n return;\n }\n btn.classList.add('dgmo-copy--success');\n setTimeout(() => btn.classList.remove('dgmo-copy--success'), 1500);\n return;\n }\n\n if (insideSummary && btn.matches('a.dgmo-open')) {\n const anchor = btn as HTMLAnchorElement;\n if (anchor.href) {\n window.open(\n anchor.href,\n anchor.target || '_blank',\n 'noopener,noreferrer'\n );\n }\n }\n}\n\n// ============================================================\n// Full-screen lightbox (expand toolbar button)\n// ============================================================\n//\n// MIRROR of the canonical helper in @diagrammo/dgmo's `auto/shared.ts`\n// (`openDgmoLightbox`), kept near-verbatim here for the same reason copy/open\n// handling is mirrored per surface. The `.dgmo-lightbox*` CSS is single-sourced\n// in dgmo's BLOCK_CSS (this package's client.css is a generated byte-copy).\n\nconst LIGHTBOX_XLINK_NS = 'http://www.w3.org/1999/xlink';\nconst LIGHTBOX_REF_ATTRS = [\n 'clip-path',\n 'mask',\n 'filter',\n 'fill',\n 'stroke',\n 'marker-start',\n 'marker-mid',\n 'marker-end',\n];\nlet lightboxIdSeq = 0;\n\nconst LIGHTBOX_CLOSE_ICON =\n '<svg width=\"20\" height=\"20\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"m4 4 8 8\"/><path d=\"m12 4-8 8\"/></svg>';\n\n/**\n * Namespace a cloned SVG's ids + internal `url(#id)`/`href=\"#id\"` refs so the\n * clone can't clash with the still-mounted inline copy (WebKit resolves\n * duplicate ids to the first match, corrupting gradients/clips/masks).\n */\nfunction namespaceLightboxSvgIds(root: SVGElement, prefix: string): void {\n const map = new Map<string, string>();\n root.querySelectorAll('[id]').forEach((el) => {\n const oldId = el.getAttribute('id');\n if (!oldId) return;\n const newId = prefix + oldId;\n map.set(oldId, newId);\n el.setAttribute('id', newId);\n });\n if (map.size === 0) return;\n const remap = (value: string): string =>\n value.replace(/url\\(#([^)]+)\\)/g, (m, id: string) => {\n const next = map.get(id);\n return next ? `url(#${next})` : m;\n });\n root.querySelectorAll('*').forEach((el) => {\n for (const attr of LIGHTBOX_REF_ATTRS) {\n const v = el.getAttribute(attr);\n if (v && v.includes('url(#')) el.setAttribute(attr, remap(v));\n }\n const style = el.getAttribute('style');\n if (style && style.includes('url(#'))\n el.setAttribute('style', remap(style));\n const href = el.getAttribute('href');\n if (href && href.startsWith('#') && map.has(href.slice(1)))\n el.setAttribute('href', '#' + map.get(href.slice(1)));\n const xhref = el.getAttributeNS(LIGHTBOX_XLINK_NS, 'href');\n if (xhref && xhref.startsWith('#') && map.has(xhref.slice(1)))\n el.setAttributeNS(\n LIGHTBOX_XLINK_NS,\n 'href',\n '#' + map.get(xhref.slice(1))\n );\n });\n}\n\n/**\n * Open the diagram belonging to `fromButton`'s block in a full-viewport\n * `<dialog>` lightbox: clone the currently-visible color-mode SVG, namespace\n * its ids, then `showModal()`. Escape / backdrop-click / close button dismiss.\n */\nfunction openDgmoLightbox(fromButton: Element): void {\n if (typeof document === 'undefined') return;\n const block = fromButton.closest('.dgmo');\n if (!block) return;\n\n const wrappers = block.querySelectorAll('.dgmo-light, .dgmo-dark, .dgmo-svg');\n let svg: SVGSVGElement | null = null;\n let bg: string | null = null;\n for (const w of Array.from(wrappers)) {\n if (window.getComputedStyle(w).display === 'none') continue;\n const found = w.querySelector('svg');\n if (found) {\n svg = found as SVGSVGElement;\n bg = w.getAttribute('data-dgmo-bg');\n break;\n }\n }\n if (!svg) svg = block.querySelector('svg');\n if (!svg) return;\n\n const clone = svg.cloneNode(true) as SVGSVGElement;\n namespaceLightboxSvgIds(clone, `dgmo-lb-${++lightboxIdSeq}-`);\n\n const dialog = document.createElement('dialog');\n dialog.className = 'dgmo-lightbox';\n dialog.setAttribute('aria-label', 'Diagram, full screen');\n\n const closeBtn = document.createElement('button');\n closeBtn.type = 'button';\n closeBtn.className = 'dgmo-lightbox-close';\n closeBtn.setAttribute('aria-label', 'Close full screen');\n closeBtn.innerHTML = LIGHTBOX_CLOSE_ICON;\n\n const host = document.createElement('div');\n host.className = 'dgmo-lightbox-svg';\n // Always paint an opaque surface behind the enlarged diagram — transparent\n // embeds strip the chart bg from the SVG, so without this the page shows\n // through the expanded view. Use the block's own palette bg when stashed.\n if (bg) host.style.background = bg;\n host.appendChild(clone);\n\n dialog.appendChild(closeBtn);\n dialog.appendChild(host);\n document.body.appendChild(dialog);\n\n const close = (): void => {\n if (dialog.open) dialog.close();\n };\n closeBtn.addEventListener('click', close);\n dialog.addEventListener('click', (e) => {\n if (e.target === dialog) close();\n });\n dialog.addEventListener('close', () => dialog.remove());\n dialog.showModal();\n}\n\nfunction tightenViewBoxes(): void {\n const WRAPPER_SELECTORS = '.dgmo-light, .dgmo-dark, .dgmo-svg';\n document.querySelectorAll(WRAPPER_SELECTORS).forEach((node) => {\n const wrapper = node as HTMLElement;\n const svg = wrapper.querySelector('svg') as SVGSVGElement | null;\n if (!svg) return;\n\n // `getBBox()` returns 0,0,0,0 on elements whose ancestor is `display: none`.\n // Under dual-render the inactive color-mode wrapper IS display:none at load,\n // so its SVG would stay un-tightened — and then look small after the user\n // toggles into it. Set the wrapper to inline-style `display: block`\n // synchronously, read getBBox, then restore. Modern browsers don't paint\n // between these synchronous DOM writes, so there's no visible flicker.\n const computed = window.getComputedStyle(wrapper);\n const wasHidden = computed.display === 'none';\n const savedInlineDisplay = wrapper.style.display;\n if (wasHidden) {\n wrapper.style.display = 'block';\n // Force a synchronous layout pass before getBBox so the freshly-\n // shown element actually has bounds. Without this, some browsers\n // still report 0,0,0,0 because they batch the display change for\n // the next frame.\n void wrapper.offsetHeight;\n }\n\n try {\n const bbox = (svg as unknown as SVGGraphicsElement).getBBox();\n if (bbox.width > 0 && bbox.height > 0) {\n const pad = 16;\n svg.setAttribute(\n 'viewBox',\n `${bbox.x - pad} ${bbox.y - pad} ${bbox.width + pad * 2} ${\n bbox.height + pad * 2\n }`\n );\n }\n } catch {\n // ignore: SVG not yet in the DOM, or getBBox unsupported\n }\n\n if (wasHidden) {\n wrapper.style.display = savedInlineDisplay;\n // Clearing the only inline property leaves `style=\"\"` on the\n // element in Chrome/Safari. React 19's post-hydration check reads\n // that empty attribute as a server-vs-client mismatch on the\n // wrapper div (the wrapper is React-owned; only its `innerHTML`\n // is dangerouslySetInnerHTML). Drop the empty attribute so the\n // wrapper round-trips back to its SSR shape.\n if (savedInlineDisplay === '' && wrapper.getAttribute('style') === '') {\n wrapper.removeAttribute('style');\n }\n }\n });\n}\n\n// Auto-init on initial load. Docusaurus-style SPA wrappers also re-call\n// bindDgmo on route changes; that's safe (the click handler is bound once,\n// viewBox tightening runs every time).\nif (isInteractiveBrowser()) {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', bindDgmo);\n } else {\n bindDgmo();\n }\n}\n","/**\n * The tombstone card — what a withdrawn cloud reference renders as.\n *\n * Not an error card. Nothing went wrong here: an author unshared a diagram they\n * had shared, which is a thing they are allowed to do, and the document that\n * referenced it is now simply pointing at something that is no longer public.\n * Rendering our cached copy instead would mean publishing content somebody took\n * back, so this card is what stands in its place.\n *\n * 🔴 It carries NO identifying content — no title, no space, no author, no\n * thumbnail. That is a requirement, not a style choice (Cloud story 7.13 T5):\n * once the response carries nothing sensitive there is nothing to opt out of,\n * which is what keeps a per-diagram privacy setting out of the product. The copy\n * matches the API's own `TOMBSTONE_DETAIL`, deliberately — a reader who follows\n * the link should not be told two different stories.\n */\n\n/** The whole of it. Do not add attribution here without reading 7.13 first. */\nexport const TOMBSTONE_TEXT = 'This diagram is no longer shared.';\n\n/**\n * Local, four-line attribute escape rather than an import from dgmo's block\n * entry, which does not export one. The values here are all ours (class names\n * from options), but they are host-supplied strings landing in markup, and the\n * one place that rule gets relaxed is the place it eventually bites.\n */\nfunction escapeAttr(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/</g, '<')\n .replace(/>/g, '>');\n}\n\nexport interface TombstoneCardOptions {\n /** Base class, matching the surrounding blocks (default `dgmo`). */\n className?: string;\n wrapper?: 'figure' | 'div';\n /** Extra classes, for wrappers still emitting legacy names. */\n legacyClassNames?: string[];\n}\n\nexport function tombstoneCardHtml(options: TombstoneCardOptions = {}): string {\n const base = options.className ?? 'dgmo';\n const wrapper = options.wrapper ?? 'figure';\n const classes = [\n base,\n `${base}--tombstone`,\n ...(options.legacyClassNames ?? []),\n ].join(' ');\n return (\n `<${wrapper} class=\"${escapeAttr(classes)}\" role=\"note\">` +\n `<p class=\"${escapeAttr(base)}-tombstone-text\">${TOMBSTONE_TEXT}</p>` +\n `</${wrapper}>`\n );\n}\n","/**\n * Cloud references — the client half (Diagrammo Cloud story 10.4).\n *\n * The build baked a diagram into the page. This checks, after the page is idle,\n * whether the diagram it points at has moved since, and swaps it if — and only\n * if — swapping is safe.\n *\n * ## What this is allowed to cost\n *\n * Almost nothing, on almost every page. The check is one conditional fetch per\n * referenced diagram against an edge-cached endpoint, and the overwhelmingly\n * common answer is \"unchanged\", which costs no work at all.\n *\n * 🔴 **There is no renderer in this module, not even behind a dynamic\n * `import()`, and that is the whole reason the file is shaped this way.**\n *\n * Measured on `astro-dgmo`'s own fixture, 2026-07-30: a plain\n * `await import('@diagrammo/dgmo/block')` here — dynamic, on a branch that\n * almost never runs — took the built site from **1 chunk / 7,990 gzipped bytes\n * to 90 chunks / 634,199**. Bundlers resolve a static-analyzable dynamic import\n * at BUILD time; \"lazy\" describes when the reader downloads it, not whether the\n * adopter ships it. Readers would not have paid for it, but every adopter's\n * `dist/` would, and the wrapper's own size assertion fails on the spot.\n *\n * So the default is to **notice, not to re-render**: a moved diagram gets a\n * small link to the live one. A site that genuinely wants the swap opts in by\n * loading `remark-dgmo/client-render.js`, which is the only module that\n * mentions the renderer — and therefore the only one whose graph a bundler can\n * follow.\n *\n * The one import here is `./tombstone-card.js`, for a single string. That file\n * imports nothing at all, so it costs the adopter a sentence rather than a\n * graph — but it is the reason the rule above is stated as \"no renderer\" and\n * not \"no imports\": check what a new one drags in before adding it.\n *\n * ## The one thing it removes\n *\n * A **withdrawn** diagram (`410`) is taken off the page and replaced with the\n * same card the build draws. That is the single case where this script changes\n * what a reader can see rather than adding a note beside it, and it is the case\n * where leaving the page alone means publishing something its author took back.\n * Every other answer — 404, 5xx, a timeout, a blocked request — leaves the\n * baked diagram exactly where it is.\n *\n * ## What it must never do\n *\n * Break the page it runs on. This code executes on somebody else's site, on a\n * diagram that already renders correctly, so **every failure path leaves the\n * baked diagram exactly as it is**: a blocked fetch (a CSP without our origin\n * is the expected case), a failed dynamic import, an offline reader, a renderer\n * whose version disagrees with the one that baked the page. Each of those ends\n * at the same place — a small \"updated\" affordance, or silence.\n *\n * ⚠️ This module ships inside `remark-dgmo/client.js`, which `vitepress-dgmo`\n * loads even though it does not use the remark plugin. On a page with no\n * `[data-dgmo-ref]` it must do nothing at all, and there is a test for that.\n */\n\nimport { TOMBSTONE_TEXT } from './tombstone-card.js';\n\n/** Where the source endpoint lives. Overridable for self-host and tests. */\nconst DEFAULT_API_BASE = 'https://api.diagrammo.app';\n/** Where a human goes to see the live diagram. */\nconst DEFAULT_APP_BASE = 'https://online.diagrammo.app';\n\n/** Aspect-ratio drift a swap may absorb before it counts as reflowing the page. */\nconst MAX_ASPECT_DRIFT = 0.25;\n\nexport interface ReferenceRefreshOptions {\n apiBase?: string;\n appBase?: string;\n fetchImpl?: typeof fetch;\n /** Injected in tests; production defers to idle. */\n schedule?: (run: () => void) => void;\n /** Injected in tests so the 1.9 MB renderer isn't loaded to prove a branch. */\n loadRenderer?: () => Promise<RendererLike>;\n document?: Document;\n}\n\nexport interface RendererLike {\n renderDgmoBlock: (\n source: string,\n options?: Record<string, unknown>\n ) => Promise<{ html: string }>;\n}\n\n/**\n * The opt-in renderer, registered by `remark-dgmo/client-render.js`.\n *\n * A registry rather than an import, because this module must stay free of any\n * reference to the render package — a bundler that can see one pulls its whole\n * graph into every adopter's build whether or not a diagram ever changes.\n *\n * Held on `globalThis` rather than in a module variable, and that is not\n * laziness: hosts inline these two files as SEPARATE script sources (Astro's\n * `injectScript` reads each one's text), so each carries its own copy of this\n * module and a module-level variable set by one would be invisible to the\n * other. A global is the only handshake that survives being bundled twice.\n */\nconst REGISTRY_KEY = '__dgmoReferenceRenderer';\n\ntype RegistryHost = { [REGISTRY_KEY]?: (() => Promise<RendererLike>) | null };\n\nexport function setReferenceRenderer(\n load: (() => Promise<RendererLike>) | null\n): void {\n (globalThis as RegistryHost)[REGISTRY_KEY] = load;\n}\n\nfunction registeredRenderer(): (() => Promise<RendererLike>) | null {\n return (globalThis as RegistryHost)[REGISTRY_KEY] ?? null;\n}\n\n/**\n * `client-render.js` fires this once it has registered the renderer. Listening\n * for it is what lets the opt-in module stay import-free: it cannot call into\n * this one, so it announces itself instead, and a diagram that moved gets its\n * swap on this page load rather than the next.\n */\nif (typeof globalThis.addEventListener === 'function') {\n globalThis.addEventListener('dgmo:renderer-ready', () => {\n void refreshCloudReferences();\n });\n}\n\ninterface SourceResponse {\n source?: unknown;\n dgmoVersion?: unknown;\n updatedAt?: unknown;\n}\n\n/**\n * How long the idle path may wait before running anyway. Matches the\n * `setTimeout` fallback below, so the check is bounded on every browser rather\n * than only on the ones lacking `requestIdleCallback`.\n */\nconst SCHEDULE_TIMEOUT_MS = 1000;\n\n/**\n * 🔴 The `timeout` is load-bearing, not a nicety. `requestIdleCallback(cb)` with\n * no deadline is a request the browser may defer for as long as it likes — and a\n * page carrying dozens of diagrams, which is exactly the kind of page that has a\n * live link on it, can keep a browser busy long enough that \"idle\" never\n * arrives. It read as the feature being broken: the diagram had changed, the API\n * said so, and the page did nothing at all — no swap and no notice, because the\n * callback that would have produced either had not run.\n *\n * The asymmetry was the tell. A browser WITHOUT `requestIdleCallback` fell\n * through to `setTimeout(run, 1000)` and always worked; a browser with it got no\n * guarantee whatsoever. Found on Safari 2026-08-03, against the astro-dgmo\n * showcase (~64 dual-rendered charts, 550 KB of gzipped HTML).\n */\nfunction defaultSchedule(run: () => void): void {\n const idle = (\n globalThis as {\n requestIdleCallback?: (\n cb: () => void,\n opts?: { timeout: number }\n ) => number;\n }\n ).requestIdleCallback;\n if (typeof idle === 'function') idle(run, { timeout: SCHEDULE_TIMEOUT_MS });\n else setTimeout(run, SCHEDULE_TIMEOUT_MS);\n}\n\n/**\n * Check every referenced diagram on the page and refresh what safely can be.\n * Resolves once the pass is done, so a test can await it; production fires it\n * and forgets.\n */\nexport async function refreshCloudReferences(\n options: ReferenceRefreshOptions = {}\n): Promise<void> {\n const doc = options.document ?? globalThis.document;\n if (!doc) return;\n\n const blocks = Array.from(\n doc.querySelectorAll<HTMLElement>('[data-dgmo-ref]')\n );\n // The inert path, and the common one: no references, no work, no fetch.\n if (blocks.length === 0) return;\n\n // 🔴 `.bind(globalThis)` is what makes this work in a browser at all.\n // `fetch` is a WebIDL operation on `Window`: it throws\n // `Illegal invocation` unless its `this` IS the global. Stored on an options\n // object and invoked as `ctx.fetchImpl(url)`, `this` becomes that plain\n // object — so the call threw, `refreshOne`'s `catch` swallowed it as \"offline\n // or blocked by CSP\", and the page did nothing at all. See the call site.\n const raw = options.fetchImpl ?? globalThis.fetch;\n if (typeof raw !== 'function') return;\n const fetchImpl = options.fetchImpl ? raw : raw.bind(globalThis);\n\n const apiBase = (options.apiBase ?? DEFAULT_API_BASE).replace(/\\/+$/, '');\n const schedule = options.schedule ?? defaultSchedule;\n\n await new Promise<void>((resolve) => {\n schedule(() => {\n void (async () => {\n // One request per distinct id, however many blocks name it.\n const byId = new Map<string, HTMLElement[]>();\n for (const el of blocks) {\n const id = el.dataset['dgmoRef'];\n if (!id) continue;\n byId.set(id, [...(byId.get(id) ?? []), el]);\n }\n await Promise.all(\n [...byId.entries()].map(([id, els]) =>\n refreshOne(id, els, { ...options, apiBase, fetchImpl, doc })\n )\n );\n resolve();\n })();\n });\n });\n}\n\nasync function refreshOne(\n id: string,\n els: HTMLElement[],\n ctx: ReferenceRefreshOptions & {\n apiBase: string;\n fetchImpl: typeof fetch;\n doc: Document;\n }\n): Promise<void> {\n let body: SourceResponse;\n try {\n // 🔴 Read it off `ctx` FIRST, then call it. `ctx.fetchImpl(url)` is a\n // method call, so `this` would be `ctx` — and a native `fetch` whose `this`\n // is a plain object throws `Illegal invocation`, which the catch below then\n // reports to nobody. This is not hypothetical: it is why a live link never\n // once refreshed in a reader's browser.\n const { fetchImpl } = ctx;\n const res = await fetchImpl(\n `${ctx.apiBase}/public/diagrams/${encodeURIComponent(id)}/source`\n );\n // 🔴 A withdrawn diagram (410) stops drawing, here, in the reader's\n // browser — changed 2026-08-10 (issue 101), and the reasoning it reverses\n // is worth keeping because it was half right.\n //\n // It used to fall into `!res.ok` and do nothing, on the grounds that\n // \"silently BLANKING a rendered diagram in a reader's browser is not this\n // code's call to make\". The objection was to leaving a hole, and it still\n // stands — nothing here blanks anything. What it draws is the same\n // tombstone the BUILD draws from the same `410`, so the client is not\n // inventing a policy, it is applying the one already chosen a few files\n // away.\n //\n // What settled it is a sentence we print to the publisher beside the Stop\n // showing button: \"Stop showing replaces the live chart with a note that it\n // is no longer shared\". That is the only specification of Stop showing\n // anywhere. The build kept it, Obsidian kept it, the desktop app kept it,\n // the plain-page element kept it — and this path, the most public of the\n // five and the one running on a site that may never rebuild, did not.\n //\n // Only 410. A 404, a 5xx and a timeout still leave the baked diagram\n // exactly where it is: those mean \"cannot say\", and withdrawal is the one\n // answer that is deliberate and final.\n if (res.status === 410) {\n for (const el of els) drawTombstone(el, ctx.doc);\n return;\n }\n if (!res.ok) return;\n body = (await res.json()) as SourceResponse;\n } catch {\n // Blocked by CSP, offline, DNS, our outage — all the same answer: the page\n // keeps the diagram it already has. This is the expected path on a site\n // whose Content-Security-Policy omits our origin, and it is precisely why\n // that failure cannot be measured from here.\n return;\n }\n\n const source = typeof body.source === 'string' ? body.source : null;\n const updatedAt = typeof body.updatedAt === 'number' ? body.updatedAt : null;\n const dgmoVersion =\n typeof body.dgmoVersion === 'string' ? body.dgmoVersion : '';\n if (source === null || updatedAt === null) return;\n\n for (const el of els) {\n const bakedAt = Number(el.dataset['dgmoRefUpdated'] ?? '');\n // Unchanged — the overwhelmingly common case, and the whole point of\n // comparing before doing anything expensive.\n if (Number.isFinite(bakedAt) && bakedAt >= updatedAt) continue;\n\n // The renderer that baked this page and the one that authored the new\n // revision disagree, so a re-render here could look different in ways\n // nobody chose. Say so instead of swapping.\n if (dgmoVersion && el.dataset['dgmoRefVersion'] !== dgmoVersion) {\n markUpdated(el, id, ctx);\n continue;\n }\n\n await swapOrMark(el, id, source, ctx);\n }\n}\n\nasync function swapOrMark(\n el: HTMLElement,\n id: string,\n source: string,\n ctx: ReferenceRefreshOptions & { doc: Document }\n): Promise<void> {\n const load = ctx.loadRenderer ?? registeredRenderer();\n // The default path, and the one almost every site takes: nobody registered a\n // renderer, so say the diagram moved and leave it alone.\n if (!load) {\n markUpdated(el, id, ctx);\n return;\n }\n\n let renderer: RendererLike;\n try {\n renderer = await load();\n } catch {\n markUpdated(el, id, ctx); // renderer unavailable: label it, don't break it\n return;\n }\n\n try {\n const opts = readBakeOptions(el);\n const { html } = await renderer.renderDgmoBlock(source, opts);\n const next = parseWrapper(html, ctx.doc);\n if (!next || !fitsTheBox(el, next)) {\n markUpdated(el, id, ctx);\n return;\n }\n el.innerHTML = next.innerHTML;\n el.dataset['dgmoRefRefreshed'] = 'true';\n } catch {\n markUpdated(el, id, ctx);\n }\n}\n\n/**\n * The render options this block was baked with, so a swap matches what is\n * already on the page rather than reverting to defaults — a diagram that\n * silently changes palette on refresh reads as a bug, not as freshness.\n */\nfunction readBakeOptions(el: HTMLElement): Record<string, unknown> {\n const raw = el.dataset['dgmoRefOpts'];\n if (!raw) return {};\n try {\n return JSON.parse(raw) as Record<string, unknown>;\n } catch {\n return {};\n }\n}\n\nfunction parseWrapper(html: string, doc: Document): HTMLElement | null {\n const host = doc.createElement('div');\n host.innerHTML = html;\n return host.firstElementChild as HTMLElement | null;\n}\n\n/**\n * Would the new render reflow the page? Compared by aspect ratio from the\n * emitted `viewBox`, which is what the blocks are sized by. An unmeasurable\n * pair is treated as \"fits\": refusing every swap we cannot measure would make\n * the feature not work at all on the surfaces least able to tell us why.\n */\nfunction fitsTheBox(current: HTMLElement, next: HTMLElement): boolean {\n const a = aspect(current);\n const b = aspect(next);\n if (a === null || b === null) return true;\n return Math.abs(a - b) / a <= MAX_ASPECT_DRIFT;\n}\n\nfunction aspect(el: HTMLElement): number | null {\n const svg = el.querySelector('svg');\n const box = svg\n ?.getAttribute('viewBox')\n ?.split(/[\\s,]+/)\n .map(Number);\n if (!box || box.length !== 4) return null;\n const [, , w, h] = box as [number, number, number, number];\n if (!w || !h) return null;\n return w / h;\n}\n\n/**\n * Turn a baked block into the withdrawn card, in place (issue 101).\n *\n * 🔴 It mutates the block rather than replacing it with `tombstoneCardHtml`'s\n * markup, and the difference matters: the wrapper carries `data-dgmo-ref` and\n * its siblings, and a fresh element would drop them — so a second pass would\n * stop recognising this block as a reference at all. Same classes, same role,\n * same sentence; different route to it.\n *\n * The sentence itself is imported rather than retyped. It is the one thing that\n * must not drift from what the build draws, and it is already shared with the\n * API's own `TOMBSTONE_DETAIL` for the same reason — a reader who follows the\n * link must not be told two different stories.\n *\n * 🔴 No title, no space, no author, no thumbnail. Carrying nothing identifying\n * is what keeps a per-diagram privacy setting out of the product (Cloud story\n * 7.13); see `tombstone-card.ts` before adding anything here.\n */\nfunction drawTombstone(el: HTMLElement, doc: Document): void {\n if (el.dataset['dgmoRefWithdrawn'] === 'true') return;\n el.dataset['dgmoRefWithdrawn'] = 'true';\n\n // The base class the host chose, read off the block instead of assumed: the\n // emitter writes `<base> <base>--<variant> [legacy…]`, so the first class IS\n // the base, and a site using `className: 'diagram'` gets its own names.\n const base = el.classList[0] ?? 'dgmo';\n el.classList.remove(`${base}--diagram`, `${base}--showcase`);\n el.classList.add(`${base}--tombstone`);\n // `note`, not `alert`. Nothing went wrong — somebody exercised a control they\n // were given, and a screen reader announcing an emergency would be wrong\n // about what happened.\n el.setAttribute('role', 'note');\n\n const text = doc.createElement('p');\n text.className = `${base}-tombstone-text`;\n text.textContent = TOMBSTONE_TEXT;\n // Emptied by hand rather than with `replaceChildren`, which is newer than the\n // oldest browser this script has any business breaking on. It runs on\n // somebody else's site.\n el.textContent = '';\n el.appendChild(text);\n}\n\n/**\n * The fallback for every path that cannot safely swap: a small link to the live\n * diagram. Idempotent, and deliberately quiet — a docs page peppered with\n * badges is worse than one that is a few days behind.\n */\nfunction markUpdated(\n el: HTMLElement,\n id: string,\n ctx: ReferenceRefreshOptions & { doc: Document }\n): void {\n if (el.dataset['dgmoRefStale'] === 'true') return;\n el.dataset['dgmoRefStale'] = 'true';\n const appBase = (ctx.appBase ?? DEFAULT_APP_BASE).replace(/\\/+$/, '');\n const link = ctx.doc.createElement('a');\n link.className = 'dgmo-updated';\n link.href = `${appBase}/d/${encodeURIComponent(id)}`;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n link.textContent = 'This diagram has been updated';\n el.appendChild(link);\n}\n"],"mappings":";;;AAsBA,OAAO;AACP,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;;;ACS5B,SAAS,uBAAuB;AAGhC,SAAS,mBAAmB;AClBrB,IAAM,iBAAiB;AC2C9B,IAAM,mBAAmB;AAEzB,IAAM,mBAAmB;AAGzB,IAAM,mBAAmB;AAiCzB,IAAM,eAAe;AAUrB,SAAS,qBAA2D;AAClE,SAAQ,WAA4B,YAAY,KAAK;AACvD;AAQA,IAAI,OAAO,WAAW,qBAAqB,YAAY;AACrD,aAAW,iBAAiB,uBAAuB,MAAM;AACvD,SAAK,uBAAuB;EAC9B,CAAC;AACH;AAaA,IAAM,sBAAsB;AAgB5B,SAAS,gBAAgB,KAAuB;AAC9C,QAAM,OACJ,WAMA;AACF,MAAI,OAAO,SAAS,WAAY,MAAK,KAAK,EAAE,SAAS,oBAAoB,CAAC;MACrE,YAAW,KAAK,mBAAmB;AAC1C;AAOA,eAAsB,uBACpB,UAAmC,CAAC,GACrB;AACf,QAAM,MAAM,QAAQ,YAAY,WAAW;AAC3C,MAAI,CAAC,IAAK;AAEV,QAAM,SAAS,MAAM;IACnB,IAAI,iBAA8B,iBAAiB;EACrD;AAEA,MAAI,OAAO,WAAW,EAAG;AAQzB,QAAM,MAAM,QAA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AK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,QAAQ,MAAM,CAAC,IACrD,KAAK,SAAS,MAAM,CACtB;QACF;MACF;IACF,QAAQ;IAER;AAEA,QAAI,WAAW;AACb,cAAQ,MAAM,UAAU;AAOxB,UAAI,uBAAuB,MAAM,QAAQ,aAAa,OAAO,MAAM,IAAI;AACrE,gBAAQ,gBAAgB,OAAO;MACjC;IACF;EACF,CAAC;AACH;AAKA,IAAI,qBAAqB,GAAG;AAC1B,MAAI,SAAS,eAAe,WAAW;AACrC,aAAS,iBAAiB,oBAAoB,QAAQ;EACxD,OAAO;AACL,aAAS;EACX;AACF;;;ADjXO,SAAS,aAAmB;AACjC,QAAM,WAAW,YAAY;AAE7B,YAAU,MAAM;AAId,aAAS;AAAA,EACX,GAAG,CAAC,QAAQ,CAAC;AAEb,SAAO;AACT;AAEA,IAAO,wBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextra-dgmo",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.14",
|
|
4
4
|
"description": "Nextra integration to render DGMO diagrams from fenced code blocks at build time. Two-step install: `withDgmo()` in next.config.mjs plus `<DgmoClient />` in app/layout.tsx — the client component handles route-change rebinding and auto-imports the theme-aware stylesheet.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Diagrammo LLC",
|
|
@@ -103,10 +103,10 @@
|
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"remark-dgmo": ">=0.16.
|
|
106
|
+
"remark-dgmo": ">=0.16.5 <1"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@diagrammo/dgmo": ">=0.
|
|
109
|
+
"@diagrammo/dgmo": ">=0.91.1 <1",
|
|
110
110
|
"@eslint/js": "^10.0.1",
|
|
111
111
|
"@types/node": "^22.10.0",
|
|
112
112
|
"@types/react": "^19.0.0",
|